Skip to content

Commit

Permalink
fix network dropdown selected
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjah committed Nov 21, 2024
1 parent 2059b60 commit 5f88b16
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/massalabs/metamask-massa.git"
},
"source": {
"shasum": "iiRWI4joXMEzwWG6xh2p4qU/av3uF8sSap8XaFvJseE=",
"shasum": "Yj5vc0Btmwc469HpD7oRnhRAXLXh+XGnxX4mWP421fU=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
20 changes: 15 additions & 5 deletions packages/snap/src/components/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ export const HomePage: SnapComponent<HomePageProps> = ({
balance,
}) => {
const networkName = CHAIN_ID_TO_NETWORK_NAME[networkInfo.chainId] ?? 'Custom';

const networkList =
networkName === MAINNET
? [MAINNET, BUILDNET, LABNET]
: [BUILDNET, MAINNET, LABNET];

const dropDown = (
<Dropdown name="network-change">
{networkList.map((network) => (
<Option value={network}>{network}</Option>
))}
</Dropdown>
);

return (
<Container>
<Box>
Expand All @@ -43,11 +57,7 @@ export const HomePage: SnapComponent<HomePageProps> = ({
<Heading>Network:</Heading>
<Card title="Current:" value={networkName} extra={networkInfo.rpcUrl} />
<Text>Select a network:</Text>
<Dropdown name="network-change">
<Option value={MAINNET}>Mainnet</Option>
<Option value={BUILDNET}>Buildnet</Option>
<Option value={LABNET}>Labnet</Option>
</Dropdown>
{dropDown}
<Form name="custom-network-form">
<Field label="Custom Rpc Url">
<Input name="custom-rpc" placeholder="http://localhost:33035" />
Expand Down

0 comments on commit 5f88b16

Please sign in to comment.