Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/NftTransfersTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const { t: $t } = useI18n();
const $store = useStore();
const toggleDisplayDecimals = () => $store.dispatch('general/toggleDisplayDecimals');

// ---------------------

interface TransfersResponse {
code: number;
success: boolean;
Expand Down Expand Up @@ -89,7 +89,7 @@ interface TransferData {
timestamp: string;
}

// ---------------------


const props = withDefaults(defineProps<NftTransferProps>(), {
title: '',
Expand Down
2 changes: 1 addition & 1 deletion src/core/mocks/CoreConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,5 +389,5 @@ events.onNetworkChanged.subscribe(() => {
});

export const getCore = () => Core;
// ----------------------------------------------------------------


23 changes: 19 additions & 4 deletions src/lib/contract/ContractManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export default class ContractManager {
this.indexerApi = indexerApi;
this.systemContractList = false;
this.tokenList = false;
this.abisCache = {};
}

getNetworkContract(address) {
Expand Down Expand Up @@ -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;
}

Expand Down