Skip to content

Commit

Permalink
chore: add installed property to ModalWallet, handle install screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Cussone committed Oct 31, 2024
1 parent c23616c commit 7a44258
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/helpers/mapModalWallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export function getModalWallet(
id: connector.id,
icon: connector.icon,
connector: connectorOrCompoundConnector,
installed: true,
title:
"title" in connector && isString(connector.title)
? connector.title
Expand Down Expand Up @@ -74,14 +75,16 @@ export const mapModalWallets = ({

const connectors = orderedByInstall
.map<ModalWallet | null>((_c) => {
const isCompoundConnector = (_c as StarknetkitCompoundConnector)
.isCompoundConnector
const c = extractConnector(_c)

const installed = installedWallets.find((w) => w.id === c?.id)
if (installed) {
let icon
let name

if ((_c as StarknetkitCompoundConnector).isCompoundConnector) {
if (isCompoundConnector) {
icon = _c.icon
name = _c.name
} else {
Expand All @@ -100,6 +103,7 @@ export const mapModalWallets = ({
id: installed.id,
icon,
connector: _c,
installed: true,
downloads: discoveryWallets.find((d) => d.id === c?.id)?.downloads,
}
}
Expand All @@ -120,6 +124,7 @@ export const mapModalWallets = ({
id: discovery.id,
icon: { light: discoveryIcon, dark: discoveryIcon },
connector: _c,
installed: false,
download: downloads[storeVersion as keyof typeof downloads],
downloads: downloads,
}
Expand Down
8 changes: 6 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,17 @@ export const connect = async ({
throw new Error("Connector error")
}

modal.$set({ selectedWallet: modalWallet })

if (!modalWallet.installed) {
return modal.$set({ layout: Layout.extensionDownloadList })
}

selectedConnector = extractConnector(
modalWallet.connector,
useFallback,
)

modal.$set({ selectedWallet: modalWallet })

if (resultType === "wallet") {
if (selectedConnector?.name === "Argent (mobile)") {
modal.$set({ layout: Layout.qrCode })
Expand Down
1 change: 1 addition & 0 deletions src/types/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export type ModalWallet = {
name: string
id: string
icon: ConnectorIcons
installed: boolean
download?: string
downloads?: Record<string, string>
subtitle?: string
Expand Down

0 comments on commit 7a44258

Please sign in to comment.