11import type { WalletProvider } from "@starknet-io/get-starknet-core"
22import { isString } from "lodash-es"
33import type { StarknetWindowObject } from "@starknet-io/types-js"
4- import {
4+ import type {
55 Connector ,
66 StarknetkitCompoundConnector ,
77 StarknetkitConnector ,
@@ -30,10 +30,13 @@ export function getModalWallet(
3030 | Connector
3131 | StarknetkitConnector
3232 | StarknetkitCompoundConnector ,
33- discoveryWallets ?: WalletProvider [ ] ,
34- _storeVersion ?: StoreVersion | null ,
33+ options ?: {
34+ installedWallets ?: StarknetWindowObject [ ]
35+ discoveryWallets ?: WalletProvider [ ]
36+ storeVersion ?: StoreVersion | null
37+ } ,
3538) : ModalWallet {
36- let storeVersion = _storeVersion
39+ let storeVersion = options ?. storeVersion
3740 if ( ! storeVersion ) {
3841 storeVersion = getStoreVersionFromBrowser ( )
3942 }
@@ -44,17 +47,21 @@ export function getModalWallet(
4447
4548 const isCompound = isCompoundConnector ( connectorOrCompoundConnector )
4649
47- const downloads = discoveryWallets ?. find (
50+ const downloads = options ?. discoveryWallets ?. find (
4851 ( d ) =>
4952 d . id === ( connector . id === "argentMobile" ? "argentX" : connector . id ) ,
5053 ) ?. downloads
5154
55+ const installed =
56+ connector . id === "argentMobile" ||
57+ Boolean ( options ?. installedWallets ?. find ( ( w ) => w . id === connector . id ) )
58+
5259 return {
60+ installed,
5361 name : isCompound ? connectorOrCompoundConnector . name : connector . name ,
5462 id : connector . id ,
5563 icon : isCompound ? connectorOrCompoundConnector . icon : connector . icon ,
5664 connector : connectorOrCompoundConnector ,
57- installed : connector . id === "argentMobile" ,
5865 title :
5966 "title" in connector && isString ( connector . title )
6067 ? connector . title
@@ -105,7 +112,6 @@ export const mapModalWallets = ({
105112 if ( installed ) {
106113 let icon
107114 let name
108- let download
109115
110116 if ( isCompound ) {
111117 icon = _c . icon
@@ -166,7 +172,7 @@ export const mapModalWallets = ({
166172 return null
167173 }
168174
169- return getModalWallet ( _c , discoveryWallets )
175+ return getModalWallet ( _c , { discoveryWallets } )
170176 } )
171177 . filter ( ( c ) : c is ModalWallet => c !== null )
172178
0 commit comments