Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#816 | change the strategy to only fetch contracts from cache #849

Closed
wants to merge 9 commits into from
7 changes: 0 additions & 7 deletions src/components/AddressOverview.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script lang="ts" setup>
import { useStore } from 'vuex';
import { useI18n } from 'vue-i18n';
import { WEI_PRECISION } from 'src/lib/utils';
import { prettyPrintFiatBalance } from 'src/antelope/wallets/utils';
import { useChainStore } from 'src/antelope';
import { SystemBalance } from 'src/lib/balance-utils';
Expand All @@ -27,7 +26,6 @@ function getBalanceDisplay(balance: string, symbol: string) {
}

const systemToken = useChainStore().currentChain.settings.getSystemToken();

</script>

<template>
Expand All @@ -46,11 +44,6 @@ const systemToken = useChainStore().currentChain.settings.getSystemToken();
width="18"
>
{{ getBalanceDisplay(props.balance.tokenQty, systemToken.symbol) }}
<ValueField
:value="props.balance.tokenQty"
:symbol="systemToken.symbol"
:decimals="WEI_PRECISION"
/>
</div>
</q-card-section>
<q-card-section v-if="!loadingComplete" >
Expand Down
17 changes: 9 additions & 8 deletions src/lib/contract/ContractManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class AddressCacheManager {
this.contractInfoByNetwork[network][addressLower] = info;
this.saveToLocalStorage();
}

this.removeNullAddress(address);
}

exists(address) {
Expand All @@ -80,7 +82,7 @@ class AddressCacheManager {
return this.contractInfoByNetwork[network] && this.contractInfoByNetwork[network][addressLower];
}

removeAddress(address) {
removeNullAddress(address) {
const addressLower = typeof address === 'string' ? address.toLowerCase() : '';
const network = this.getCurrentNetwork();
if (this.addressesByNetwork[network]) {
Expand Down Expand Up @@ -299,10 +301,11 @@ export default class ContractManager {
return;
}
let contract = this.factory.buildContract(contractData);

if(
typeof this.getNetworkContract(index) === 'undefined'
|| contract.abi?.length > 0 && !this.getNetworkContract(index).abi
|| contract.abi?.length > 0 && contract.abi.length > this.getNetworkContract(index).abi?.length
!this.getNetworkContract(index) && contract?.name
|| contract.abi?.length > 0 && !this.getNetworkContract(index)?.abi
|| contract.abi?.length > 0 && contract.abi.length > (this.getNetworkContract(index)?.abi?.length || 0)
){
this.setNetworkContract(index, contract);
}
Expand Down Expand Up @@ -384,10 +387,8 @@ export default class ContractManager {
} else if (this.nullContractsManager.existsContract(addressLower)) {
result = this.nullContractsManager.getContractInfo(addressLower);
} else {
result = await this.getContract(addressLower);
if (result) {
result = this.nullContractsManager.getContractInfo(addressLower);
}
// We are going to always assume that if the address is a contract, it is already in the cache
// Because the indexer API should always return all involved contracts in a query response
}
return result;
}
Expand Down
Loading