From ac16d2c8b79e0ad2800e63577e55fc0bfbfa142f Mon Sep 17 00:00:00 2001 From: Georges KABBOUCHI Date: Thu, 29 Jul 2021 00:50:35 +0300 Subject: [PATCH] fixes --- composables/useAaveV2Position.ts | 7 ++++--- composables/useWeb3.ts | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/composables/useAaveV2Position.ts b/composables/useAaveV2Position.ts index 033f170..9282ea5 100644 --- a/composables/useAaveV2Position.ts +++ b/composables/useAaveV2Position.ts @@ -68,10 +68,11 @@ export function useAaveV2Position( const { activeAccount } = useDSA(); const { getTokenByKey, allATokensV2 } = useToken(); - const resolver = + const resolver = computed(() => chainId.value === 1 ? "0xFb3a1D56eD56F046721B9aCa749895100754578b" - : "0xD6E0803d0eB34af8Ea135835512D7E77960b28F1"; + : "0xD6E0803d0eB34af8Ea135835512D7E77960b28F1" + ); const fetchPosition = async () => { if (!web3.value) { @@ -84,7 +85,7 @@ export function useAaveV2Position( const aaveResolverInstance = new web3.value.eth.Contract( aaveV2ABI as AbiItem[], - resolver + resolver.value ); const aaveTokensArr = atokensV2[networkName.value].allTokens.map( diff --git a/composables/useWeb3.ts b/composables/useWeb3.ts index fe043c2..e335e78 100644 --- a/composables/useWeb3.ts +++ b/composables/useWeb3.ts @@ -87,7 +87,6 @@ export function useWeb3() { }; const setProvider = provider => { - web3Provider = provider; if (web3Modal.cachedProvider === "walletconnect") { provider.on("accountsChanged", () => { location.reload(); @@ -114,6 +113,9 @@ export function useWeb3() { }; const refreshWeb3 = async () => { + if (!web3Provider) { + return; + } let newWeb3 = new Web3(web3Provider); chainId.value = await newWeb3.eth.getChainId(); web3.value = newWeb3; @@ -128,6 +130,6 @@ export function useWeb3() { activate, deactivate, networkName, - refreshWeb3, + refreshWeb3 }; }