From 1f689f6f19cdb43c2be1b579b685b44b418e85ed Mon Sep 17 00:00:00 2001 From: Georges KABBOUCHI Date: Sun, 29 Aug 2021 02:44:41 +0300 Subject: [PATCH] wip --- package.json | 2 +- src/index.ts | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index dee669b..ba486b6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kabbouchi/vue-web3", - "version": "0.2.12", + "version": "0.2.13", "description": "Vue web3 composition api", "license": "MIT", "main": "dist/cjs/index.js", diff --git a/src/index.ts b/src/index.ts index 5181523..a1e987b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -85,19 +85,32 @@ export const useWeb3 = () => { return } - if (update.provider) { - provider.value = update.provider - } - const cId = update.chainId === undefined ? undefined : normalizeChainId(update.chainId) + if ( + cId !== undefined && + !!connector.value.supportedChainIds && + !connector.value.supportedChainIds.includes(cId) + ) { + const e = new UnsupportedChainIdError( + cId, + connector.value.supportedChainIds, + ) + onErrorCb.value ? onErrorCb.value(e) : handleError(e) + return + } + if (cId) { chainId.value = cId } + if (update.provider) { + provider.value = update.provider + } + const acc = typeof update.account === 'string' ? normalizeAccount(update.account)