Skip to content

Commit

Permalink
fixing current network (#213)
Browse files Browse the repository at this point in the history
Co-authored-by: Mario Christopher <[email protected]>
  • Loading branch information
stanleyyconsensys and mario-christopher authored Mar 7, 2024
1 parent f22d5c3 commit 83d1088
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 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": "SeitYNVUTrRF2Nay0C/ln9CEIwk77t5cHHbCVuTh/Ec=",
"shasum": "lLTHMW/oau9o6LzRE+2n+2qHCooLpe1RSJJPR/6UOEU=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
16 changes: 11 additions & 5 deletions packages/starknet-snap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { addErc20Token } from './addErc20Token';
import { getStoredErc20Tokens } from './getStoredErc20Tokens';
import { estimateFee } from './estimateFee';
import { getStoredUserAccounts } from './getStoredUserAccounts';
import { SnapState } from './types/snapState';
import { AccContract, SnapState } from './types/snapState';
import { extractPrivateKey } from './extractPrivateKey';
import { extractPublicKey } from './extractPublicKey';
import { addNetwork } from './addNetwork';
Expand Down Expand Up @@ -263,9 +263,16 @@ export const onHomePage: OnHomePageHandler = async () => {
},
});

if (state && state.accContracts.length > 0) {
const userAddress = state.accContracts[0].address;
const chainId = state.accContracts[0].chainId;
let accContract: AccContract;
if (state.currentNetwork) {
accContract = state.accContracts.find(n => n.chainId == state.currentNetwork.chainId);
} else {
accContract = state.accContracts[0];
}

if (accContract) {
const userAddress = accContract.address;
const chainId = accContract.chainId;
const network = getNetworkFromChainId(state, chainId);
panelItems.push(row('Address', address(`${userAddress}`)));
panelItems.push(row('Network', text(`${network.name}`)));
Expand Down Expand Up @@ -301,7 +308,6 @@ export const onHomePage: OnHomePageHandler = async () => {
),
);
}

return {
content: panel(panelItems),
};
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3154,16 +3154,16 @@ __metadata:
linkType: hard

"@consensys/starknet-snap@file:../starknet-snap::locator=wallet-ui%40workspace%3Apackages%2Fwallet-ui":
version: 2.4.0
resolution: "@consensys/starknet-snap@file:../starknet-snap#../starknet-snap::hash=bdd60c&locator=wallet-ui%40workspace%3Apackages%2Fwallet-ui"
version: 2.5.1
resolution: "@consensys/starknet-snap@file:../starknet-snap#../starknet-snap::hash=f43351&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: ddbcecfa69dd0bbe71fc654e022e279de1d453a4eb5d9286b962adfd72eb967a52882b5d9d6009e4c02528adf21584a5545daa6f1c12874c2162f27cb331fb24
checksum: f6c425fa95f59effaa3cb47e30e5f5a339fb47e9cd5b0337f229213642436efb5fe8dc6b4df4de75a9b4e4524793145c78914514ff2d11bd055f365c2ce180d5
languageName: node
linkType: hard

Expand Down

0 comments on commit 83d1088

Please sign in to comment.