Skip to content

Commit

Permalink
update wallet-provider version in package-lock.json (#504)
Browse files Browse the repository at this point in the history
* update wallet-provider version in package-lock.json

* refactor: remove network switching functionality from MetamaskWallet component
  • Loading branch information
Ben-Rey authored Dec 20, 2024
1 parent 087a00e commit 2275265
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 34 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 1 addition & 31 deletions src/lib/ConnectMassaWallets/components/MetamaskWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,9 @@ import { WalletError } from './WalletError';
import Intl from '../i18n';
import { useAccountStore } from '../store';
import { METAMASK_INSTALL } from '../../massa-react/const';
import { Button } from '../../../components';
import { CHAIN_ID, Network } from '@massalabs/massa-web3';

export default function MetamaskWallet() {
const { connectedAccount, currentWallet, network, isFetching } =
useAccountStore();

function handleSwitchNetwork(network: Network): void {
if (!currentWallet) return;
if (network.chainId === CHAIN_ID.Mainnet) {
currentWallet.setRpcUrl('https://buildnet.massa.net/api/v2');
} else {
currentWallet.setRpcUrl('https://mainnet.massa.net/api/v2');
}
}
const { connectedAccount, isFetching } = useAccountStore();

if (!connectedAccount && !isFetching) {
return (
Expand All @@ -40,24 +28,6 @@ export default function MetamaskWallet() {
<div className="flex flex-col gap-4 mas-body">
<ConnectedAccount />
<MASBalance />
{network && currentWallet && (
<div className="flex gap-4">
<SwitchNetwork
networkName={network.name === 'mainnet' ? 'buildnet' : 'mainnet'}
onClick={() => handleSwitchNetwork(network)}
/>
</div>
)}
</div>
);
}

function SwitchNetwork({
networkName,
onClick,
}: {
networkName: string;
onClick: () => void;
}) {
return <Button onClick={onClick}>Switch To {networkName}</Button>;
}

0 comments on commit 2275265

Please sign in to comment.