From cc8faf253dddaa93bec7a589e75e56d9d9430703 Mon Sep 17 00:00:00 2001 From: Georges KABBOUCHI Date: Sun, 29 Aug 2021 01:28:58 +0300 Subject: [PATCH] wip --- package.json | 2 +- src/index.ts | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 8a52a2d..046aa3d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kabbouchi/vue-web3", - "version": "0.2.8", + "version": "0.2.10", "description": "Vue web3 composition api", "license": "MIT", "main": "dist/cjs/index.js", diff --git a/src/index.ts b/src/index.ts index 269e87e..c604c9c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -80,15 +80,27 @@ export const useWeb3 = () => { } const handleUpdate = async (update: ConnectorUpdate): Promise => { - provider.value = update.provider - chainId.value = + if (update.provider) { + provider.value = update.provider + } + + const cId = update.chainId === undefined ? undefined : normalizeChainId(update.chainId) - account.value = + + if (cId) { + chainId.value = cId + } + + const acc = typeof update.account === 'string' ? normalizeAccount(update.account) : update.account + + if (acc) { + account.value = acc + } } const handleError = (e: Error): void => {