Skip to content

Commit

Permalink
chore: add custom order for connectors
Browse files Browse the repository at this point in the history
  • Loading branch information
bluecco committed Jul 2, 2024
1 parent 054b0f9 commit 6f72017
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/helpers/mapModalWallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ interface SetConnectorsExpandedParams {
installedWallets: StarknetWindowObject[]
discoveryWallets: WalletProvider[]
storeVersion: StoreVersion | null
customOrder: boolean
}

export const mapModalWallets = ({
availableConnectors,
installedWallets,
discoveryWallets,
storeVersion,
customOrder,
}: SetConnectorsExpandedParams): ModalWallet[] => {
const starknetMobile =
window?.starknet_argentX as unknown as StarknetWindowObject & {
Expand All @@ -32,10 +34,12 @@ export const mapModalWallets = ({
availableConnectors.find((c) => c.id === w.id),
)

const orderedByInstall = [
...availableConnectors.filter((c) => allInstalledWallets.includes(c)),
...availableConnectors.filter((c) => !allInstalledWallets.includes(c)),
]
const orderedByInstall = customOrder
? availableConnectors
: [
...availableConnectors.filter((c) => allInstalledWallets.includes(c)),
...availableConnectors.filter((c) => !allInstalledWallets.includes(c)),
]

const connectors = orderedByInstall
.map<ModalWallet | null>((c) => {
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export const connect = async ({
installedWallets,
discoveryWallets: await sn.getDiscoveryWallets(restOptions),
storeVersion,
customOrder: connectors?.length > 0,
})

const getTarget = (): ShadowRoot => {
Expand Down

0 comments on commit 6f72017

Please sign in to comment.