Skip to content

Commit

Permalink
fix: snap homepage error when state omit (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
stanleyyconsensys authored Mar 27, 2024
1 parent ae24edf commit 41de2ea
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/starknet-snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/ConsenSys/starknet-snap.git"
},
"source": {
"shasum": "A3cyal6PKAzEQQ3ptdBUK106XMp5jQVh4kydh87u7AA=",
"shasum": "jWBDYBstwiVhsHmuaSyCGfe8CIjvXZOSBTPbEJLd6T0=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
11 changes: 7 additions & 4 deletions packages/starknet-snap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,14 @@ export const onHomePage: OnHomePageHandler = async () => {
},
});

// Account may not exist if the recover account process has not executed.
let accContract: AccContract;
if (state.currentNetwork) {
accContract = state.accContracts.find((n) => n.chainId == state.currentNetwork.chainId);
} else {
accContract = state.accContracts[0];
if (state) {
if (state.currentNetwork) {
accContract = state.accContracts.find((n) => n.chainId == state.currentNetwork.chainId);
} else if (state.accContracts && state.accContracts.length > 0) {
accContract = state.accContracts[0];
}
}

if (accContract) {
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3155,15 +3155,15 @@ __metadata:

"@consensys/starknet-snap@file:../starknet-snap::locator=wallet-ui%40workspace%3Apackages%2Fwallet-ui":
version: 2.5.2
resolution: "@consensys/starknet-snap@file:../starknet-snap#../starknet-snap::hash=180251&locator=wallet-ui%40workspace%3Apackages%2Fwallet-ui"
resolution: "@consensys/starknet-snap@file:../starknet-snap#../starknet-snap::hash=8a6ae2&locator=wallet-ui%40workspace%3Apackages%2Fwallet-ui"
dependencies:
"@metamask/snaps-sdk": 3.0.1
async-mutex: ^0.3.2
ethereum-unit-converter: ^0.0.17
ethers: ^5.5.1
starknet: ^5.14.0
starknet_v4.22.0: "npm:[email protected]"
checksum: 983f842b9dba2bec7cfcd8907f9dd8d420befc61e045b7138f1786f1662ff6c4f3279b8db49193cf2ae39dff0b9173a5475d1b072f918fda72d54d9d05d4bfd5
checksum: 2e9cf4fa50d9b385d0e53073f2611445e796e2bcb79407d6e47fbc0ba101881fd159910fb29968afec9e04e8ea753e511220640e99ca983571331d377c94b976
languageName: node
linkType: hard

Expand Down

0 comments on commit 41de2ea

Please sign in to comment.