Skip to content

Commit

Permalink
Merge pull request #79 from argentlabs/develop
Browse files Browse the repository at this point in the history
Release 1.1.4
  • Loading branch information
bluecco authored Feb 27, 2024
2 parents 0c00bce + b5854c9 commit 88ca07b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "starknetkit",
"version": "1.1.3",
"version": "1.1.4",
"repository": "github:argentlabs/starknetkit",
"private": false,
"browser": {
Expand Down
13 changes: 12 additions & 1 deletion src/helpers/mapModalWallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,16 @@ export const mapModalWallets = ({
return []
}

return availableConnectors
const allInstalledWallets = installedWallets.map((w) =>
availableConnectors.find((c) => c.id === w.id),
)

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

const connectors = orderedByInstall
.map<ModalWallet | null>((c) => {
const installed = installedWallets.find((w) => w.id === c.id)
if (installed) {
Expand Down Expand Up @@ -74,4 +83,6 @@ export const mapModalWallets = ({
}
})
.filter((c): c is ModalWallet => c !== null)

return connectors
}
21 changes: 13 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,22 @@ export const connect = async ({

const lastWalletId = localStorage.getItem("starknetLastConnectedWallet")
if (modalMode === "neverAsk") {
const connector = availableConnectors.find((c) => c.id === lastWalletId)
try {
const connector = availableConnectors.find((c) => c.id === lastWalletId)

if (resultType === "wallet") {
await connector?.connect()
}
if (resultType === "wallet") {
await connector?.connect()
}

selectedConnector = connector ?? null
selectedConnector = connector ?? null

return {
connector,
wallet: connector?.wallet ?? null,
return {
connector,
wallet: connector?.wallet ?? null,
}
} catch (error) {
removeStarknetLastConnectedWallet()
throw new Error(error)
}
}

Expand Down

0 comments on commit 88ca07b

Please sign in to comment.