diff --git a/src/components/NftTransfersTable.vue b/src/components/NftTransfersTable.vue index 190ca9095..266930131 100644 --- a/src/components/NftTransfersTable.vue +++ b/src/components/NftTransfersTable.vue @@ -49,7 +49,7 @@ const { t: $t } = useI18n(); const $store = useStore(); const toggleDisplayDecimals = () => $store.dispatch('general/toggleDisplayDecimals'); -// --------------------- + interface TransfersResponse { code: number; success: boolean; @@ -89,7 +89,7 @@ interface TransferData { timestamp: string; } -// --------------------- + const props = withDefaults(defineProps(), { title: '', diff --git a/src/core/mocks/CoreConfig.ts b/src/core/mocks/CoreConfig.ts index 44edca59c..3bb53af06 100644 --- a/src/core/mocks/CoreConfig.ts +++ b/src/core/mocks/CoreConfig.ts @@ -389,5 +389,5 @@ events.onNetworkChanged.subscribe(() => { }); export const getCore = () => Core; -// ---------------------------------------------------------------- + diff --git a/src/lib/contract/ContractManager.js b/src/lib/contract/ContractManager.js index 8b7ea5a1f..47cd81041 100644 --- a/src/lib/contract/ContractManager.js +++ b/src/lib/contract/ContractManager.js @@ -78,6 +78,7 @@ export default class ContractManager { this.indexerApi = indexerApi; this.systemContractList = false; this.tokenList = false; + this.abisCache = {}; } getNetworkContract(address) { @@ -395,21 +396,35 @@ export default class ContractManager { if (force) { const contract = await this.getContractForced(address); - // now we need to check if the contract is verified - if (contract) { + // ABI taken from sourcify.dev ------------------------------- + const checkSumAddress = toChecksumAddress(address); + if (!this.abisCache[checkSumAddress]) { try { - const checkSumAddress = toChecksumAddress(address); - await axios.get( + // also this way we check if the contract is verified + const response = await axios.get( `${useChainStore().currentChain.settings.getTrustedContractsBucket()}/${checkSumAddress}/source.json`, ); contract.verified = true; + const metadata_file = response.data.files.find(file => file.name === 'metadata.json'); + if (metadata_file) { + const metadata = JSON.parse(metadata_file.content); + const abi = metadata.output.abi; + if (abi) { + this.abisCache[checkSumAddress] = abi; + contract.abi = this.abisCache[checkSumAddress]; + contract.autoloadedAbi = false; + } + } // stored again with the verified flag this.addContractToCache(address, contract); } catch (e) { + console.error(`Could not retrieve contract ABI for ${address}: ${e.message}`); // if fetching the source.json fails, the contract is not verified contract.verified = false; } } + contract.abi = this.abisCache[checkSumAddress] || contract.abi; + // ---------------------------------------------------- return contract; }