From 2df90c2de27e8f3175f9586b09b9bd76e10850fb Mon Sep 17 00:00:00 2001 From: Majorfi Date: Mon, 16 Oct 2023 12:33:13 +0200 Subject: [PATCH] bump --- package.json | 2 +- src/utils/wagmi/provider.ts | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 92dd604a..77336b56 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@yearn-finance/web-lib", - "version": "3.0.53", + "version": "3.0.54", "main": "./dist/index.js", "types": "./dist/index.d.js", "files": [ diff --git a/src/utils/wagmi/provider.ts b/src/utils/wagmi/provider.ts index 3a1beca8..79ef0cc9 100644 --- a/src/utils/wagmi/provider.ts +++ b/src/utils/wagmi/provider.ts @@ -61,7 +61,17 @@ export async function handleTx< ** First, make sure we are using the correct chainID. ******************************************************************************************/ if (wagmiProvider.chainId !== args.chainID) { - await switchNetwork({chainId: args.chainID}); + try { + await switchNetwork({chainId: args.chainID}); + } catch (error) { + if (!(error instanceof BaseError)) { + return ({isSuccessful: false, error}); + } + toast.error(error.shortMessage); + args.statusHandler?.({...defaultTxStatus, error: true}); + console.error(error); + return ({isSuccessful: false, error}); + } } wagmiProvider = await toWagmiProvider(args.connector);