Skip to content

Commit

Permalink
ensuring supportedInterfaces property when quering nfts transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
Viterbo committed Nov 16, 2023
1 parent 3a1ed9c commit 7b90885
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/antelope/chains/EVMChainSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ export default abstract class EVMChainSettings implements ChainSettings {

// process the shaped raw data into NFTs
async processNftRawData(shapedRawNfts: NftRawData[]): Promise<Collectible[]> {
console.log('EVMChainSettings.processNftRawData()', shapedRawNfts);
const contractStore = useContractStore();
const nftsStore = useNftsStore();

Expand Down Expand Up @@ -461,6 +462,7 @@ export default abstract class EVMChainSettings implements ChainSettings {
const ownersUpdatedWithinThreeMins = dateIsWithinXMinutes(nft.ownerDataLastFetched, 3);

if (!ownersUpdatedWithinThreeMins) {
console.log('EVMChainSettings.processNftRawData() antes de .getContractInstance()', nft.contractAddress, data, contract);
const contractInstance = await (await contractStore.getContract(CURRENT_CONTEXT, nft.contractAddress))?.getContractInstance();
if (!contractInstance) {
throw new AntelopeError('antelope.utils.error_contract_instance');
Expand Down Expand Up @@ -574,7 +576,16 @@ export default abstract class EVMChainSettings implements ChainSettings {
const url = `v1/account/${account}/transfers`;

return this.indexer.get(url, { params })
.then(response => response.data as IndexerAccountTransfersResponse);
.then(response => response.data as IndexerAccountTransfersResponse)
.then((data) => {
// we recreate the supportedInterfaces property if is not pressent in the response
Object.values(data.contracts).forEach((contract) => {
if (contract.supportedInterfaces === null && type !== undefined) {
contract.supportedInterfaces = [type];
}
});
return data;
});
}

async getTokenList(): Promise<TokenClass[]> {
Expand Down
2 changes: 1 addition & 1 deletion src/antelope/types/Filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface IndexerTransactionsFilter extends IndexerPaginationFilter {

export interface IndexerTransfersFilter extends IndexerPaginationFilter {
account: string;
type?: 'erc20' | 'erc721' | 'erc1155'; // filter by token type
type?: 'erc20' | 'erc721' | 'erc1155' | 'none'; // filter by token type
includePagination?: boolean; // include the total count and more flag in response
endBlock?: number; // last block to include in the query
startBlock?: number; // first block to include in the query
Expand Down

0 comments on commit 7b90885

Please sign in to comment.