This commit is contained in:
Georges KABBOUCHI 2021-07-29 00:50:35 +03:00
parent 99336e1bb6
commit ac16d2c8b7
2 changed files with 8 additions and 5 deletions

View File

@ -68,10 +68,11 @@ export function useAaveV2Position(
const { activeAccount } = useDSA(); const { activeAccount } = useDSA();
const { getTokenByKey, allATokensV2 } = useToken(); const { getTokenByKey, allATokensV2 } = useToken();
const resolver = const resolver = computed(() =>
chainId.value === 1 chainId.value === 1
? "0xFb3a1D56eD56F046721B9aCa749895100754578b" ? "0xFb3a1D56eD56F046721B9aCa749895100754578b"
: "0xD6E0803d0eB34af8Ea135835512D7E77960b28F1"; : "0xD6E0803d0eB34af8Ea135835512D7E77960b28F1"
);
const fetchPosition = async () => { const fetchPosition = async () => {
if (!web3.value) { if (!web3.value) {
@ -84,7 +85,7 @@ export function useAaveV2Position(
const aaveResolverInstance = new web3.value.eth.Contract( const aaveResolverInstance = new web3.value.eth.Contract(
aaveV2ABI as AbiItem[], aaveV2ABI as AbiItem[],
resolver resolver.value
); );
const aaveTokensArr = atokensV2[networkName.value].allTokens.map( const aaveTokensArr = atokensV2[networkName.value].allTokens.map(

View File

@ -87,7 +87,6 @@ export function useWeb3() {
}; };
const setProvider = provider => { const setProvider = provider => {
web3Provider = provider;
if (web3Modal.cachedProvider === "walletconnect") { if (web3Modal.cachedProvider === "walletconnect") {
provider.on("accountsChanged", () => { provider.on("accountsChanged", () => {
location.reload(); location.reload();
@ -114,6 +113,9 @@ export function useWeb3() {
}; };
const refreshWeb3 = async () => { const refreshWeb3 = async () => {
if (!web3Provider) {
return;
}
let newWeb3 = new Web3(web3Provider); let newWeb3 = new Web3(web3Provider);
chainId.value = await newWeb3.eth.getChainId(); chainId.value = await newWeb3.eth.getChainId();
web3.value = newWeb3; web3.value = newWeb3;
@ -128,6 +130,6 @@ export function useWeb3() {
activate, activate,
deactivate, deactivate,
networkName, networkName,
refreshWeb3, refreshWeb3
}; };
} }