From 0c6b7bc5e01b4254c6cf574571e923b570dc4e13 Mon Sep 17 00:00:00 2001 From: Jesse Schulman Date: Thu, 23 Jan 2025 09:10:22 -0800 Subject: [PATCH] Optimize approvals page to make fewer indexer API requests --- src/antelope/chains/evm/telos-evm-testnet/index.ts | 4 ++-- src/antelope/chains/evm/telos-evm/index.ts | 4 ++-- src/antelope/stores/allowances.ts | 9 ++++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/antelope/chains/evm/telos-evm-testnet/index.ts b/src/antelope/chains/evm/telos-evm-testnet/index.ts index 2d606ac4..2d890eae 100644 --- a/src/antelope/chains/evm/telos-evm-testnet/index.ts +++ b/src/antelope/chains/evm/telos-evm-testnet/index.ts @@ -46,9 +46,9 @@ const W_TOKEN = new TokenClass({ const RPC_ENDPOINT = { protocol: 'https', - host: 'testnet.telos.net', + host: 'rpc.testnet.telos.net', port: 443, - path: '/evm', + path: '/', }; const ESCROW_CONTRACT_ADDRESS = '0x7E9cF9fBc881652B05BB8F26298fFAB538163b6f'; const API_ENDPOINT = 'https://api-dev.telos.net/v1'; diff --git a/src/antelope/chains/evm/telos-evm/index.ts b/src/antelope/chains/evm/telos-evm/index.ts index 3a409935..f9a97981 100644 --- a/src/antelope/chains/evm/telos-evm/index.ts +++ b/src/antelope/chains/evm/telos-evm/index.ts @@ -46,9 +46,9 @@ const W_TOKEN = new TokenClass({ const RPC_ENDPOINT = { protocol: 'https', - host: 'mainnet.telos.net', + host: 'rpc.telos.net', port: 443, - path: '/evm', + path: '/', }; const ESCROW_CONTRACT_ADDRESS = '0x95F5713A1422Aa3FBD3DCB8D553945C128ee3855'; const API_ENDPOINT = 'https://api.telos.net/v1'; diff --git a/src/antelope/stores/allowances.ts b/src/antelope/stores/allowances.ts index 7a3fd730..5ef931dc 100644 --- a/src/antelope/stores/allowances.ts +++ b/src/antelope/stores/allowances.ts @@ -21,7 +21,7 @@ import { TransactionResponse, isErc20AllowanceRow, isErc721SingleAllowanceRow, - isNftCollectionAllowanceRow, + isNftCollectionAllowanceRow, EvmContractFactoryData, } from 'src/antelope/types'; import { createTraceFunction } from 'src/antelope/config'; import EVMChainSettings from 'src/antelope/chains/EVMChainSettings'; @@ -253,6 +253,13 @@ export const useAllowancesStore = defineStore(store_name, { const erc721AllowancesData = (allowancesResults[1] as IndexerAllowanceResponseErc721)?.results ?? []; const erc1155AllowancesData = (allowancesResults[2] as IndexerAllowanceResponseErc1155)?.results ?? []; + // Load these in the cache so they're available later and we don't abuse the indexer API + allowancesResults.map((result) => { + for (const [address, contract] of Object.entries(result.contracts)) { + useContractStore().createAndStoreContract(CURRENT_CONTEXT, address, contract as EvmContractFactoryData); + } + }); + const shapedErc20AllowanceRowPromises = Promise.allSettled(erc20AllowancesData.map(allowanceData => this.shapeErc20AllowanceRow(allowanceData))); const shapedErc721AllowanceRowPromises = Promise.allSettled(erc721AllowancesData.map(allowanceData => this.shapeErc721AllowanceRow(allowanceData))); const shapedErc1155AllowanceRowPromises = Promise.allSettled(erc1155AllowancesData.map(allowanceData => this.shapeErc1155AllowanceRow(allowanceData)));