Skip to content

Commit

Permalink
chore: update validateMetamask
Browse files Browse the repository at this point in the history
  • Loading branch information
shane-moore committed Jan 10, 2024
1 parent 7daf3d3 commit 019d5fb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 29 deletions.
12 changes: 9 additions & 3 deletions layer/store/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,9 @@ export const useSharedWalletStore = defineStore('sharedWallet', {
}
},

async validateAndQueue() {
queue() {
const walletStore = useSharedWalletStore()

await walletStore.validate()

if (walletStore.queueStatus === StatusType.Loading) {
throw new Error('You have a pending transaction.')
} else {
Expand All @@ -116,6 +114,14 @@ export const useSharedWalletStore = defineStore('sharedWallet', {
}
},

async validateAndQueue() {
const sharedWalletStore = useSharedWalletStore()

await sharedWalletStore.validate()

sharedWalletStore.queue()
},

async init() {
const walletStore = useSharedWalletStore()

Expand Down
27 changes: 1 addition & 26 deletions layer/wallet/metamask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,32 +55,7 @@ export const validateMetamask = async (address: string) => {
const metamaskChainIdDoesntMatchTheActiveChainId = chainId !== metamaskChainId

if (metamaskChainIdDoesntMatchTheActiveChainId) {
if (chainId === EthereumChainId.Kovan) {
throw new MetamaskException(
new Error('Please change your Metamask network to Kovan Test Network'),
{
code: UnspecifiedErrorCode,
type: ErrorType.WalletError
}
)
}
if (chainId === EthereumChainId.Goerli) {
throw new MetamaskException(
new Error('Please change your Metamask network to Goerli Test Network'),
{
code: UnspecifiedErrorCode,
type: ErrorType.WalletError
}
)
}

throw new MetamaskException(
new Error('Please change your Metamask network to Ethereum Mainnet'),
{
code: UnspecifiedErrorCode,
type: ErrorType.WalletError
}
)
return await UtilsWallets.updateMetamaskNetwork(chainId)
}

const metamaskProvider = await UtilsWallets.getMetamaskProvider()
Expand Down

0 comments on commit 019d5fb

Please sign in to comment.