@gurge/sdk 0.3.13 → 0.3.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +184 -32
- package/common/src/API/API.cjs +1 -1
- package/common/src/API/API.d.ts +0 -5
- package/common/src/API/API.mjs +114 -119
- package/common/src/API/TokenCallsCachedHelper.cjs +1 -0
- package/common/src/API/TokenCallsCachedHelper.d.ts +15 -0
- package/common/src/API/TokenCallsCachedHelper.mjs +62 -0
- package/common/src/API/callLifiAPI.cjs +1 -1
- package/common/src/API/callLifiAPI.mjs +2 -7
- package/common/src/API/enclaveUtxoCalls.cjs +1 -1
- package/common/src/API/enclaveUtxoCalls.mjs +6 -7
- package/common/src/API/getServerURL.cjs +1 -1
- package/common/src/API/getServerURL.mjs +2 -2
- package/common/src/API/scheduled-transactions-calls.cjs +1 -1
- package/common/src/API/scheduled-transactions-calls.mjs +3 -3
- package/common/src/API/token-calls.cjs +1 -1
- package/common/src/API/token-calls.d.ts +1 -1
- package/common/src/API/token-calls.mjs +3 -13
- package/common/src/constants/chains.constants.cjs +1 -1
- package/common/src/constants/chains.constants.d.ts +1 -0
- package/common/src/constants/chains.constants.mjs +3 -2
- package/common/src/constants/deploy-data/mergeDeployData.cjs +1 -1
- package/common/src/constants/deploy-data/mergeDeployData.mjs +11 -10
- package/common/src/constants/deploy-data/shared-deploy-data-tron.json.cjs +1 -1
- package/common/src/constants/deploy-data/shared-deploy-data-tron.json.mjs +60 -3517
- package/common/src/constants/events.constants.cjs +1 -1
- package/common/src/constants/events.constants.mjs +3 -1
- package/common/src/constants/index.cjs +1 -1
- package/common/src/constants/index.d.ts +0 -3
- package/common/src/constants/index.mjs +0 -3
- package/common/src/constants/lifi.constants.cjs +1 -1
- package/common/src/constants/lifi.constants.mjs +3 -6
- package/common/src/constants/mediaUrls.constants.d.ts +0 -1
- package/common/src/constants/rewards.constants.d.ts +0 -2
- package/common/src/constants/server.constants.cjs +1 -1
- package/common/src/constants/server.constants.d.ts +1 -5
- package/common/src/constants/server.constants.mjs +3 -8
- package/common/src/constants/vite.constants.cjs +1 -1
- package/common/src/constants/vite.constants.d.ts +1 -0
- package/common/src/constants/vite.constants.mjs +3 -3
- package/common/src/crypto/BabyJubRN.cjs +1 -0
- package/common/src/crypto/BabyJubRN.d.ts +18 -0
- package/common/src/crypto/BabyJubRN.mjs +33 -0
- package/common/src/crypto/babyJub.cjs +1 -1
- package/common/src/crypto/babyJub.mjs +7 -5
- package/common/src/crypto/poseidon.cjs +1 -1
- package/common/src/crypto/poseidon.mjs +22 -12
- package/common/src/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/common/src/data-structures/Hinkal/Hinkal.d.ts +10 -6
- package/common/src/data-structures/Hinkal/Hinkal.mjs +104 -113
- package/common/src/data-structures/Hinkal/IHinkal.d.ts +9 -5
- package/common/src/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
- package/common/src/data-structures/Hinkal/handleAutoDepositBack.mjs +37 -37
- package/common/src/data-structures/Hinkal/hinkalDepositAndBridge.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDepositAndBridge.d.ts +2 -2
- package/common/src/data-structures/Hinkal/hinkalDepositAndBridge.mjs +8 -5
- package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.d.ts +2 -2
- package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +4 -1
- package/common/src/data-structures/Hinkal/hinkalNearDepositAndBridge.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalNearDepositAndBridge.mjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.mjs +4 -4
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.utils.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.utils.mjs +3 -3
- package/common/src/data-structures/Hinkal/hinkalProoflessDepositViaWrapper.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalProoflessDepositViaWrapper.mjs +15 -15
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.d.ts +2 -2
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +4 -1
- package/common/src/data-structures/Hinkal/index.d.ts +0 -1
- package/common/src/data-structures/Hinkal/prepareDepositOnChainUtxosZkProof.cjs +1 -1
- package/common/src/data-structures/Hinkal/prepareDepositOnChainUtxosZkProof.mjs +1 -1
- package/common/src/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/common/src/data-structures/Hinkal/resetMerkleTrees.mjs +29 -31
- package/common/src/data-structures/TokenDBs/AlchemyPublicTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/AlchemyPublicTokensDB.mjs +7 -6
- package/common/src/data-structures/TokenDBs/ArcPublicTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/ArcPublicTokensDB.mjs +18 -18
- package/common/src/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/EventsPublicTokensDB.mjs +43 -43
- package/common/src/data-structures/TokenDBs/PublicTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/PublicTokensDB.mjs +23 -20
- package/common/src/data-structures/TokenDBs/TempoPublicTokensDB.cjs +1 -0
- package/common/src/data-structures/TokenDBs/TempoPublicTokensDB.d.ts +9 -0
- package/common/src/data-structures/TokenDBs/TempoPublicTokensDB.mjs +41 -0
- package/common/src/data-structures/TokenDBs/TronPublicTokensDB.cjs +1 -0
- package/common/src/data-structures/TokenDBs/TronPublicTokensDB.d.ts +9 -0
- package/common/src/data-structures/TokenDBs/TronPublicTokensDB.mjs +47 -0
- package/common/src/data-structures/TokenDBs/index.cjs +1 -1
- package/common/src/data-structures/TokenDBs/index.d.ts +2 -0
- package/common/src/data-structures/TokenDBs/index.mjs +2 -0
- package/common/src/data-structures/event-service/evm/BlockchainEventEmitter.d.ts +3 -3
- package/common/src/data-structures/event-service/evm/ClientBlockchainEventEmitter.d.ts +2 -2
- package/common/src/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.d.ts +2 -2
- package/common/src/data-structures/event-service/solana/SolanaBlockchainEventEmitter.d.ts +3 -3
- package/common/src/data-structures/index.d.ts +1 -0
- package/common/src/data-structures/private-balances/BalanceChangedHandler.cjs +1 -0
- package/common/src/data-structures/private-balances/BalanceChangedHandler.d.ts +9 -0
- package/common/src/data-structures/private-balances/BalanceChangedHandler.mjs +12 -0
- package/common/src/data-structures/private-balances/HinkalPrivateBalanceController.cjs +1 -0
- package/common/src/data-structures/{Hinkal → private-balances}/HinkalPrivateBalanceController.d.ts +4 -2
- package/common/src/data-structures/{Hinkal → private-balances}/HinkalPrivateBalanceController.mjs +34 -90
- package/common/src/data-structures/private-balances/index.cjs +1 -0
- package/common/src/data-structures/private-balances/index.d.ts +3 -0
- package/common/src/data-structures/private-balances/index.mjs +3 -0
- package/common/src/data-structures/private-balances/privateBalancesReducer.cjs +1 -0
- package/common/src/data-structures/private-balances/privateBalancesReducer.d.ts +2 -0
- package/common/src/data-structures/private-balances/privateBalancesReducer.mjs +73 -0
- package/common/src/data-structures/token-price-fetcher/TokenChecker.cjs +1 -1
- package/common/src/data-structures/token-price-fetcher/TokenChecker.mjs +5 -5
- package/common/src/error-handling/error-codes.constants.cjs +1 -1
- package/common/src/error-handling/error-codes.constants.d.ts +2 -5
- package/common/src/error-handling/error-codes.constants.mjs +3 -6
- package/common/src/externalABIs/index.cjs +1 -1
- package/common/src/externalABIs/index.d.ts +1 -36
- package/common/src/externalABIs/index.mjs +3 -5
- package/common/src/functions/index.cjs +1 -1
- package/common/src/functions/index.d.ts +0 -1
- package/common/src/functions/index.mjs +4 -5
- package/common/src/functions/pre-transaction/buildCommitmentValidationData.cjs +1 -1
- package/common/src/functions/pre-transaction/buildCommitmentValidationData.mjs +37 -36
- package/common/src/functions/pre-transaction/merge-with-fee-structure-emporium.cjs +1 -1
- package/common/src/functions/pre-transaction/merge-with-fee-structure-emporium.mjs +4 -4
- package/common/src/functions/pre-transaction/sendV0Transaction.cjs +2 -2
- package/common/src/functions/pre-transaction/sendV0Transaction.mjs +54 -42
- package/common/src/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/common/src/functions/private-wallet/emporium.helpers.mjs +17 -17
- package/common/src/functions/private-wallet/emporium.swap.helpers.cjs +1 -1
- package/common/src/functions/private-wallet/emporium.swap.helpers.mjs +16 -16
- package/common/src/functions/snarkjs/common.snarkjs.cjs +1 -1
- package/common/src/functions/snarkjs/common.snarkjs.d.ts +9 -1
- package/common/src/functions/snarkjs/common.snarkjs.mjs +13 -9
- package/common/src/functions/snarkjs/getMerkleTreeSiblingsAndRootHashes.cjs +1 -1
- package/common/src/functions/snarkjs/getMerkleTreeSiblingsAndRootHashes.d.ts +2 -3
- package/common/src/functions/snarkjs/getMerkleTreeSiblingsAndRootHashes.mjs +49 -32
- package/common/src/functions/utils/abi.utils.cjs +1 -0
- package/common/src/functions/utils/abi.utils.d.ts +3 -0
- package/common/src/functions/utils/abi.utils.mjs +5 -0
- package/common/src/functions/utils/bigint-math.utils.cjs +1 -0
- package/common/src/functions/utils/bigint-math.utils.d.ts +2 -0
- package/common/src/functions/utils/bigint-math.utils.mjs +12 -0
- package/common/src/functions/utils/dispatchBalanceRefreshes.cjs +1 -1
- package/common/src/functions/utils/dispatchBalanceRefreshes.mjs +1 -1
- package/common/src/functions/utils/enclaveHandshakeService.cjs +1 -0
- package/common/src/functions/utils/enclaveHandshakeService.d.ts +10 -0
- package/common/src/functions/utils/enclaveHandshakeService.mjs +22 -0
- package/common/src/functions/utils/encryptInputForEnclave.cjs +1 -1
- package/common/src/functions/utils/encryptInputForEnclave.mjs +23 -25
- package/common/src/functions/utils/erc20tokenFunctions.cjs +1 -1
- package/common/src/functions/utils/erc20tokenFunctions.d.ts +4 -1
- package/common/src/functions/utils/erc20tokenFunctions.mjs +28 -12
- package/common/src/functions/utils/evmNetworkFunctions.cjs +1 -1
- package/common/src/functions/utils/evmNetworkFunctions.d.ts +1 -0
- package/common/src/functions/utils/evmNetworkFunctions.mjs +4 -0
- package/common/src/functions/utils/getUtxosFromReceipt.utils.cjs +1 -1
- package/common/src/functions/utils/getUtxosFromReceipt.utils.mjs +10 -10
- package/common/src/functions/utils/index.cjs +1 -1
- package/common/src/functions/utils/index.d.ts +4 -0
- package/common/src/functions/utils/index.mjs +4 -0
- package/common/src/functions/utils/map.utils.cjs +1 -0
- package/common/src/functions/utils/map.utils.d.ts +1 -0
- package/common/src/functions/utils/map.utils.mjs +9 -0
- package/common/src/functions/utils/mutexes.utils.cjs +1 -1
- package/common/src/functions/utils/mutexes.utils.d.ts +2 -2
- package/common/src/functions/utils/mutexes.utils.mjs +4 -3
- package/common/src/functions/utils/process.utils.cjs +1 -1
- package/common/src/functions/utils/process.utils.d.ts +1 -0
- package/common/src/functions/utils/process.utils.mjs +7 -2
- package/common/src/functions/utils/tron.utils.cjs +1 -1
- package/common/src/functions/utils/tron.utils.d.ts +1 -0
- package/common/src/functions/utils/tron.utils.mjs +1 -1
- package/common/src/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
- package/common/src/functions/web3/events/getInputUtxoAndBalance.mjs +26 -26
- package/common/src/functions/web3/events/getShieldedBalance.cjs +1 -1
- package/common/src/functions/web3/events/getShieldedBalance.mjs +29 -11
- package/common/src/functions/web3/events/index.cjs +1 -1
- package/common/src/functions/web3/events/index.d.ts +0 -1
- package/common/src/functions/web3/events/index.mjs +0 -1
- package/common/src/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/common/src/functions/web3/functionCalls/transactCallDirect.mjs +4 -4
- package/common/src/functions/web3/functionCalls/waitForErc20Approvals.cjs +1 -1
- package/common/src/functions/web3/functionCalls/waitForErc20Approvals.mjs +10 -10
- package/common/src/functions/web3/index.cjs +1 -1
- package/common/src/functions/web3/index.mjs +0 -1
- package/common/src/functions/web3/lifiAPI.cjs +1 -1
- package/common/src/functions/web3/lifiAPI.mjs +7 -38
- package/common/src/functions/web3/oneInchAPI.cjs +1 -1
- package/common/src/functions/web3/oneInchAPI.mjs +10 -10
- package/common/src/functions/web3/uniswapAPI.cjs +1 -1
- package/common/src/functions/web3/uniswapAPI.mjs +16 -16
- package/common/src/mutexes/chainBalanceRwLock.cjs +1 -0
- package/common/src/mutexes/chainBalanceRwLock.d.ts +18 -0
- package/common/src/mutexes/chainBalanceRwLock.mjs +31 -0
- package/common/src/mutexes/index.d.ts +1 -0
- package/common/src/types/cache.types.cjs +1 -1
- package/common/src/types/cache.types.d.ts +2 -0
- package/common/src/types/cache.types.mjs +1 -1
- package/common/src/types/commitments.types.d.ts +0 -10
- package/common/src/types/hinkal.types.cjs +1 -1
- package/common/src/types/hinkal.types.d.ts +4 -7
- package/common/src/types/hinkal.types.mjs +1 -1
- package/common/src/types/index.cjs +1 -1
- package/common/src/types/index.d.ts +0 -1
- package/common/src/types/index.mjs +1 -2
- package/common/src/types/new-rewards.type.cjs +1 -1
- package/common/src/types/new-rewards.type.d.ts +0 -1
- package/common/src/types/new-rewards.type.mjs +1 -1
- package/common/src/types/scheduled-transactions.types.d.ts +5 -0
- package/common/src/webworker/logError-BTCYh_YM.js +2 -0
- package/common/src/webworker/package.json +34 -4
- package/common/src/webworker/snarkjsWorker/snarkjsWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/snarkjsWorker/snarkjsWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/snarkjsWorkerNode.cjs +1 -1
- package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/utxoWorkerNode.cjs +1 -1
- package/common/src/webworker/viteWorkerURL.constant.cjs +4 -4
- package/common/src/webworker/viteWorkerURL.constant.mjs +4 -4
- package/common/src/webworker/workerFactory.cjs +1 -1
- package/common/src/webworker/workerFactory.d.ts +1 -0
- package/common/src/webworker/workerFactory.mjs +3 -2
- package/common/src/webworker/workerProxy-DPeuP2Mg.js +1 -0
- package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/zkProofWorkerNode.cjs +1 -1
- package/functions/index.cjs +1 -1
- package/functions/index.mjs +0 -4
- package/functions/integrations/index.cjs +1 -1
- package/functions/integrations/index.mjs +0 -4
- package/functions/integrations/swapApi.cjs +1 -1
- package/functions/integrations/swapApi.d.ts +21 -7
- package/functions/integrations/swapApi.mjs +29 -10
- package/functions/utils/refreshBalance.cjs +1 -1
- package/functions/utils/refreshBalance.mjs +2 -2
- package/index.cjs +1 -1
- package/index.mjs +4 -8
- package/internal/token.utils.cjs +1 -1
- package/internal/token.utils.d.ts +1 -3
- package/internal/token.utils.mjs +10 -21
- package/package.json +34 -4
- package/react-native/HinkalWebViewWorker.cjs +98 -0
- package/react-native/HinkalWebViewWorker.d.ts +2 -0
- package/react-native/HinkalWebViewWorker.mjs +174 -0
- package/react-native/bridge/HinkalRNWorker.cjs +1 -0
- package/react-native/bridge/HinkalRNWorker.d.ts +13 -0
- package/react-native/bridge/HinkalRNWorker.mjs +26 -0
- package/react-native/bridge/serialization.utils.cjs +1 -0
- package/react-native/bridge/serialization.utils.d.ts +3 -0
- package/react-native/bridge/serialization.utils.mjs +13 -0
- package/react-native/metro-config.js +90 -0
- package/react-native/shims/circomlibjs-hinkal-fork.js +14 -0
- package/react-native/shims/circomlibjs.js +15 -0
- package/react-native/shims/constants.js +7 -0
- package/react-native/shims/crypto.js +103 -0
- package/react-native/shims/ffjavascript.js +5 -0
- package/react-native/shims/fs.js +5 -0
- package/react-native/shims/globals.js +10 -0
- package/react-native/shims/idb-keyval.js +75 -0
- package/react-native/shims/multiformats.js +1 -0
- package/react-native/shims/os.js +7 -0
- package/react-native/shims/path.js +11 -0
- package/react-native/shims/readline.js +6 -0
- package/react-native/shims/snarkjs.js +21 -0
- package/react-native/shims/url.js +5 -0
- package/react-native/shims/web-worker.js +7 -0
- package/react-native/shims/worker_threads.js +6 -0
- package/react-native/shims.d.ts +16 -0
- package/react-native/workerCDNUrls.cjs +1 -0
- package/react-native/workerCDNUrls.d.ts +2 -0
- package/react-native/workerCDNUrls.mjs +14 -0
- package/sdk/package.json.cjs +1 -0
- package/sdk/package.json.mjs +130 -0
- package/services/Hinkal.cjs +1 -1
- package/services/Hinkal.d.ts +6 -5
- package/services/Hinkal.mjs +50 -48
- package/types/IHinkal.d.ts +6 -5
- package/common/src/API/kycCalls.cjs +0 -1
- package/common/src/API/kycCalls.d.ts +0 -14
- package/common/src/API/kycCalls.mjs +0 -26
- package/common/src/constants/assets.constants.cjs +0 -1
- package/common/src/constants/assets.constants.d.ts +0 -13
- package/common/src/constants/assets.constants.mjs +0 -4
- package/common/src/constants/kyc.constants.cjs +0 -1
- package/common/src/constants/kyc.constants.d.ts +0 -29
- package/common/src/constants/kyc.constants.mjs +0 -126
- package/common/src/constants/token.limits.constants.cjs +0 -1
- package/common/src/constants/token.limits.constants.d.ts +0 -5
- package/common/src/constants/token.limits.constants.mjs +0 -3
- package/common/src/data-structures/Hinkal/HinkalPrivateBalanceController.cjs +0 -1
- package/common/src/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +0 -1
- package/common/src/data-structures/Hinkal/hinkalGetZkMeProvider.d.ts +0 -28
- package/common/src/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +0 -22
- package/common/src/externalABIs/BabPassport.json.cjs +0 -1
- package/common/src/externalABIs/BabPassport.json.mjs +0 -20
- package/common/src/externalABIs/GalxePassport.json.cjs +0 -1
- package/common/src/externalABIs/GalxePassport.json.mjs +0 -37
- package/common/src/functions/kyc/aiPriseHelper.d.ts +0 -0
- package/common/src/functions/kyc/checkTokenLimitsUSD.cjs +0 -1
- package/common/src/functions/kyc/checkTokenLimitsUSD.d.ts +0 -1
- package/common/src/functions/kyc/checkTokenLimitsUSD.mjs +0 -29
- package/common/src/functions/kyc/index.cjs +0 -1
- package/common/src/functions/kyc/index.d.ts +0 -3
- package/common/src/functions/kyc/index.mjs +0 -3
- package/common/src/functions/kyc/openDefaultPassportWindow.cjs +0 -1
- package/common/src/functions/kyc/openDefaultPassportWindow.d.ts +0 -1
- package/common/src/functions/kyc/openDefaultPassportWindow.mjs +0 -7
- package/common/src/functions/kyc/passportHelper.cjs +0 -1
- package/common/src/functions/kyc/passportHelper.d.ts +0 -3
- package/common/src/functions/kyc/passportHelper.mjs +0 -1
- package/common/src/functions/kyc/zkMeHelper.cjs +0 -1
- package/common/src/functions/kyc/zkMeHelper.d.ts +0 -4
- package/common/src/functions/kyc/zkMeHelper.mjs +0 -42
- package/common/src/functions/web3/events/balanceChangedHandler.cjs +0 -1
- package/common/src/functions/web3/events/balanceChangedHandler.d.ts +0 -5
- package/common/src/functions/web3/events/balanceChangedHandler.mjs +0 -21
- package/common/src/types/kyc.types.cjs +0 -1
- package/common/src/types/kyc.types.d.ts +0 -41
- package/common/src/types/kyc.types.mjs +0 -10
- package/common/src/webworker/logError-CmD5XYI9.js +0 -2
- package/common/src/webworker/workerProxy-C49-EPZz.js +0 -1
|
@@ -3,54 +3,52 @@ import { ContractType as n } from "../../types/ethereum-network.types.mjs";
|
|
|
3
3
|
import { PrivateBalanceUpdateType as r } from "../../types/balances.types.mjs";
|
|
4
4
|
import { EventCategory as i } from "../../types/events.types.mjs";
|
|
5
5
|
import "../../types/index.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
6
|
+
import { getOrCreateMapValue as a } from "../../functions/utils/map.utils.mjs";
|
|
7
|
+
import { getChainBalanceFetchingMutex as o } from "../../functions/utils/mutexes.utils.mjs";
|
|
8
|
+
import { createCustomSolanaConnection as s } from "../../functions/utils/create-provider.mjs";
|
|
9
|
+
import { getContractAddress as c } from "../../functions/utils/getContractAddress.mjs";
|
|
10
|
+
import { balanceChangedHandler as l } from "../private-balances/BalanceChangedHandler.mjs";
|
|
11
|
+
import { ClientBlockchainEventEmitter as u } from "../event-service/evm/ClientBlockchainEventEmitter.mjs";
|
|
12
|
+
import { ClientSolanaBlockchainEventEmitter as d } from "../event-service/solana/ClientSolanaBlockchainEventEmitter.mjs";
|
|
12
13
|
import "../event-service/index.mjs";
|
|
13
|
-
import { SnapshotFetcherService as
|
|
14
|
-
import { ClientSolanaCommitmentsSnapshotService as
|
|
15
|
-
import { ClientSolanaNullifierSnapshotService as
|
|
16
|
-
import { ClientCommitmentsSnapshotService as
|
|
17
|
-
import { ClientNullifierSnapshotService as
|
|
14
|
+
import { SnapshotFetcherService as f } from "../snapshot/SnapshotFetcherService.mjs";
|
|
15
|
+
import { ClientSolanaCommitmentsSnapshotService as p } from "../snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.mjs";
|
|
16
|
+
import { ClientSolanaNullifierSnapshotService as m } from "../snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.mjs";
|
|
17
|
+
import { ClientCommitmentsSnapshotService as h } from "../snapshot/evm-snapshots/ClientCommitmentsSnapshotService.mjs";
|
|
18
|
+
import { ClientNullifierSnapshotService as g } from "../snapshot/evm-snapshots/ClientNullifierSnapshotService.mjs";
|
|
18
19
|
import "../snapshot/index.mjs";
|
|
19
|
-
import { PublicKey as
|
|
20
|
-
import { Mutex as
|
|
20
|
+
import { PublicKey as _ } from "@solana/web3.js";
|
|
21
|
+
import { Mutex as v } from "async-mutex";
|
|
21
22
|
//#region libs/shared/common/src/data-structures/Hinkal/resetMerkleTrees.ts
|
|
22
|
-
var
|
|
23
|
-
let
|
|
24
|
-
|
|
25
|
-
}, b = async (_, v) => {
|
|
26
|
-
let b = (v ?? _.getSupportedChains()).map((v) => y(v).runExclusive(async () => {
|
|
27
|
-
_.commitmentsSnapshotServiceByChain[v]?.intervalClear(), _.nullifierSnapshotServiceByChain[v]?.intervalClear();
|
|
23
|
+
var y = /* @__PURE__ */ new Map(), b = (e) => a(y, e, () => new v()), x = async (a, v) => {
|
|
24
|
+
let y = (v ?? a.getSupportedChains()).map((v) => b(v).runExclusive(async () => {
|
|
25
|
+
a.commitmentsSnapshotServiceByChain[v]?.intervalClear(), a.nullifierSnapshotServiceByChain[v]?.intervalClear();
|
|
28
26
|
let { maxPageSize: y, fetchRpcUrl: b, contractData: x } = t[v], S;
|
|
29
27
|
if (e(v)) {
|
|
30
28
|
let e = x.hinkalAddress;
|
|
31
29
|
if (!b || !e) throw Error("Fetch RPC URL or Solana program ID is not set");
|
|
32
|
-
S = new
|
|
30
|
+
S = new d(v, s(b), new _(e), 0, o(v), y);
|
|
33
31
|
let t = x.hinkalIdl;
|
|
34
32
|
t && S.setIdl(t);
|
|
35
|
-
let n = new
|
|
36
|
-
|
|
33
|
+
let n = new f(v, e);
|
|
34
|
+
a.commitmentsSnapshotServiceByChain[v] = new p(S, n), a.nullifierSnapshotServiceByChain[v] = new m(S, n);
|
|
37
35
|
} else {
|
|
38
|
-
let e =
|
|
39
|
-
S = new
|
|
40
|
-
let
|
|
41
|
-
|
|
36
|
+
let e = a.getContractWithFetcherByChainId(v, n.HinkalContract), t = a.getContractWithFetcherByChainId(v, n.DepositOnChainUtxos), r = o(v);
|
|
37
|
+
S = new u(i.MainContractEvents, v, e, 0, r, y, t);
|
|
38
|
+
let s = new f(v, c(e));
|
|
39
|
+
a.commitmentsSnapshotServiceByChain[v] = new h(S, s), a.nullifierSnapshotServiceByChain[v] = new g(S, s);
|
|
42
40
|
}
|
|
43
|
-
let C =
|
|
41
|
+
let C = a.commitmentsSnapshotServiceByChain[v], w = a.nullifierSnapshotServiceByChain[v];
|
|
44
42
|
if (!C || !w) throw Error(`Missing snapshot service for chain ${v}`);
|
|
45
|
-
await Promise.all([C.init(), w.init()]), await S.init(),
|
|
46
|
-
e > 0 &&
|
|
43
|
+
await Promise.all([C.init(), w.init()]), await S.init(), a.merkleTreeHinkalByChain[v] = C.merkleTree, a.nullifiersByChain[v] = w.nullifiers, a.encryptedOutputsByChain[v] = C.encryptedOutputs, S.onEventsProcessed = (e) => {
|
|
44
|
+
e > 0 && l.dispatch({
|
|
47
45
|
updateType: r.FreshWithoutLoader,
|
|
48
46
|
updateTokensListBefore: !0,
|
|
49
47
|
chainIdToUpdate: v
|
|
50
48
|
});
|
|
51
49
|
};
|
|
52
50
|
}));
|
|
53
|
-
await Promise.allSettled(
|
|
51
|
+
await Promise.allSettled(y);
|
|
54
52
|
};
|
|
55
53
|
//#endregion
|
|
56
|
-
export {
|
|
54
|
+
export { x as resetMerkleTrees };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../functions/utils/caseInsensitive.utils.cjs`),r=require(`../../types/cache.types.cjs`),i=require(`../http/HttpClient.cjs`);require(`../http/index.cjs`);const a=require(`../../error-handling/logger.cjs`),o=require(`../../API/API.cjs`),s=require(`../../functions/utils/string.utils.cjs`),c=require(`./token-visibility-db.cjs`),l=require(`../../functions/utils/erc20tokenFunctions.cjs`),u=require(`../../functions/utils/create-provider.cjs`),d=require(`../../functions/utils/publicBalance.utils.cjs`);let f=require(`@solana/web3.js`),p=require(`idb-keyval`),m=require(`@solana/spl-token`);var h=new class{fetchedTokens={};ALCHEMY_URLS={[e.chainIds.ethMainnet]:`eth-mainnet`,[e.chainIds.polygon]:`polygon-mainnet`,[e.chainIds.arbMainnet]:`arb-mainnet`,[e.chainIds.optimism]:`opt-mainnet`,[e.chainIds.optimismTest]:`opt-mainnet`,[e.chainIds.base]:`base-mainnet`,[e.chainIds.solanaMainnet]:`solana-mainnet`};KNOWN_GOOD_NFTS={[e.chainIds.base]:[`0x20bc8d248fe9c18a947406cea50d716828ab821f`],[e.chainIds.optimism]:[`0x3c3e0e73b53a19bcaf4178b8f9c9428fd2a2775e`]};isWhitelistedNFT(e,t){return this.KNOWN_GOOD_NFTS[t]?this.KNOWN_GOOD_NFTS[t].some(t=>n.caseInsensitiveEqual(e,t)):!1}async getPublicTokens(e,t){let n=s.getStateKey(t,e)
|
|
1
|
+
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../functions/utils/caseInsensitive.utils.cjs`),r=require(`../../types/cache.types.cjs`),i=require(`../http/HttpClient.cjs`);require(`../http/index.cjs`);const a=require(`../../error-handling/logger.cjs`),o=require(`../../API/API.cjs`),s=require(`../../functions/utils/string.utils.cjs`),c=require(`./token-visibility-db.cjs`),l=require(`../../functions/utils/erc20tokenFunctions.cjs`),u=require(`../../functions/utils/create-provider.cjs`),d=require(`../../functions/utils/publicBalance.utils.cjs`);let f=require(`@solana/web3.js`),p=require(`idb-keyval`),m=require(`@solana/spl-token`);var h=new class{fetchedTokens={};ALCHEMY_URLS={[e.chainIds.ethMainnet]:`eth-mainnet`,[e.chainIds.polygon]:`polygon-mainnet`,[e.chainIds.arbMainnet]:`arb-mainnet`,[e.chainIds.optimism]:`opt-mainnet`,[e.chainIds.optimismTest]:`opt-mainnet`,[e.chainIds.base]:`base-mainnet`,[e.chainIds.solanaMainnet]:`solana-mainnet`,[e.chainIds.sepoliaTestnet]:`eth-sepolia`};KNOWN_GOOD_NFTS={[e.chainIds.base]:[`0x20bc8d248fe9c18a947406cea50d716828ab821f`],[e.chainIds.optimism]:[`0x3c3e0e73b53a19bcaf4178b8f9c9428fd2a2775e`]};isWhitelistedNFT(e,t){return this.KNOWN_GOOD_NFTS[t]?this.KNOWN_GOOD_NFTS[t].some(t=>n.caseInsensitiveEqual(e,t)):!1}async getPublicTokens(e,t){let n=s.getStateKey(t,e);return l.overlayTokensWithRegistryData((await(0,p.get)(r.StorageKeys.ALCHEMY_PUBLIC_TOKENS))?.[n]||[],e)}async getFetchedTokens(e,t){let n=s.getStateKey(t,e);return l.overlayTokensWithRegistryData(this.fetchedTokens[n]||[],e)}fetchAndUpdatePublicTokens(t,n){return e.isSolanaLike(n)?this.fetchAndUpdateSolanaTokens(t,n):this.fetchAndUpdateEVMTokens(t,n)}async fetchAndUpdateSolanaTokens(e,t){let i=s.getStateKey(e,t),[a,l]=await Promise.all([this.getSolanaTokenAddresses(t,e),this.getNFTAddresses(t,e)]),u=Array.from(new Set([...a,...l]));if(!u.length)return;let d=(await o.API.tokensInfoCall(t,u)).filter(e=>!!e),f=await c.tokenVisibilityStorage.hideSpamsAndFetchHiddenTokensAddresses(t,d),m=d.filter(e=>!n.lowerCaseIncludes(f,e.erc20TokenAddress));await(0,p.update)(r.StorageKeys.ALCHEMY_PUBLIC_TOKENS,(e={})=>{let t={...e,[i]:m};return this.fetchedTokens=t,t})}async getWalletTokenAddresses(t,n){return e.isSolanaLike(t)?this.getSolanaTokenAddresses(t,n):this.getEVMTokenAddresses(t,n)}async fetchAndUpdateEVMTokens(e,i){let a=s.getStateKey(e,i),l=await this.getEVMTokenAddresses(i,e),u=await this.getNFTTokens(i,e),d=u.map(e=>e.contractAddress),f=[...l,...d];if(!f.length)return;let m=(await o.API.tokensInfoCall(i,f)).map((e,r)=>{if(e)return e;let a=f[r],o=u.find(e=>n.caseInsensitiveEqual(e.contractAddress,a));return o&&o.tokenIds&&o.tokenIds.length>0&&this.isWhitelistedNFT(a,i)?{chainId:i,name:`Unknown NFT`,symbol:`NFT`,erc20TokenAddress:a,decimals:0,nftTokenType:t.TokenType.ERC721,tokenIds:o.tokenIds}:null}).filter(e=>!!e),h=await c.tokenVisibilityStorage.hideSpamsAndFetchHiddenTokensAddresses(i,m),g=m.filter(e=>!n.lowerCaseIncludes(h,e.erc20TokenAddress)).map(e=>({...e,tokenIds:u.find(t=>n.caseInsensitiveEqual(t.contractAddress,e.erc20TokenAddress))?.tokenIds}));await(0,p.update)(r.StorageKeys.ALCHEMY_PUBLIC_TOKENS,(e={})=>{let t={...e,[a]:g};return this.fetchedTokens=t,t})}async getSolanaTokenAddresses(n,r){let{fetchRpcUrl:i}=e.networkRegistry[n];if(!i)throw Error(`RPC URL not found for the specified chain ID`);let a=u.createCustomSolanaConnection(i),o=await a.getBalance(new f.PublicKey(r)),[s,c]=await Promise.all([a.getParsedTokenAccountsByOwner(new f.PublicKey(r),{programId:m.TOKEN_PROGRAM_ID}),a.getParsedTokenAccountsByOwner(new f.PublicKey(r),{programId:m.TOKEN_2022_PROGRAM_ID})]),l=[...s.value,...c.value].filter(e=>{let{amount:t}=e.account.data.parsed.info.tokenAmount;return BigInt(t)>0n}).map(e=>e.account.data.parsed.info.mint);return o>0&&l.unshift(t.solanaNativeAddress),Array.from(new Set(l))}async getNFTAddresses(n,r){let{fetchRpcUrl:o}=e.networkRegistry[n];if(!o)throw Error(`RPC URL not found for the specified chain ID`);try{let e=[],n=1;do{let{items:a=[],page:s}=(await i.httpClient.post(o,{jsonrpc:`2.0`,id:1,method:`getAssetsByOwner`,params:{ownerAddress:r,page:n,limit:1e3,displayOptions:{showFungible:!1,showCollectionMetadata:!0}}})).result||{},c=a.filter(e=>e.interface&&t.SOLANA_NFT_INTERFACES.includes(e.interface)).map(e=>e.id);e.push(...c),n=s&&s>n?s:0}while(n>0);return e}catch(e){return a.Logger.error(`Failed to fetch NFTs from DAS API`,e),[]}}async getEVMTokenAddresses(n,r){let a=await d.getPublicBalanceByTokenAddress(n,r,t.zeroAddress),o=this.ALCHEMY_URLS[n];if(!o)throw Error(`Alchemy URL not found for the specified chain ID: ${n}`);let s=`https://${o}.g.alchemy.com/v2/${e.ALCHEMY_API_KEY}`,c=[],l;do{let e=[r,`erc20`];l&&e.push({pageKey:l});let{result:t}=await i.httpClient.post(s,{jsonrpc:`2.0`,id:1,method:`alchemy_getTokenBalances`,params:e});c.push(...t?.tokenBalances??[]),l=t?.pageKey}while(l);a&&a>0n&&c.push({contractAddress:t.zeroAddress,tokenBalance:a.toString()});let u={};return c.forEach(e=>{(!u[e.contractAddress]||BigInt(e.tokenBalance)>0n)&&(u[e.contractAddress]=e)}),Object.keys(u)}async getNFTTokens(t,n){let r=`https://${this.ALCHEMY_URLS[t]}.g.alchemy.com/nft/v3/${e.ALCHEMY_API_KEY}/getNFTsForOwner`,a=[],o;do{let e=new URLSearchParams({owner:n,withMetadata:`false`,pageSize:`100`});o&&e.append(`pageKey`,o);let{ownedNfts:t=[],pageKey:s}=await i.httpClient.get(`${r}?${e.toString()}`);a.push(...t),o=s}while(o);let s=a.filter(({contractAddress:e,tokenId:t})=>e&&t).reduce((e,{contractAddress:t,tokenId:n})=>{let r=t.toLowerCase();return e.has(r)||e.set(r,[]),e.get(r)?.push(n),e},new Map);return Array.from(s.entries()).map(([e,t])=>({contractAddress:e,tokenIds:t}))}};exports.alchemyPublicTokensDB=h;
|
|
@@ -8,7 +8,7 @@ import { Logger as f } from "../../error-handling/logger.mjs";
|
|
|
8
8
|
import { API as p } from "../../API/API.mjs";
|
|
9
9
|
import { getStateKey as m } from "../../functions/utils/string.utils.mjs";
|
|
10
10
|
import { tokenVisibilityStorage as h } from "./token-visibility-db.mjs";
|
|
11
|
-
import {
|
|
11
|
+
import { overlayTokensWithRegistryData as g } from "../../functions/utils/erc20tokenFunctions.mjs";
|
|
12
12
|
import { createCustomSolanaConnection as _ } from "../../functions/utils/create-provider.mjs";
|
|
13
13
|
import { getPublicBalanceByTokenAddress as v } from "../../functions/utils/publicBalance.utils.mjs";
|
|
14
14
|
import { PublicKey as y } from "@solana/web3.js";
|
|
@@ -23,7 +23,8 @@ var w = new class {
|
|
|
23
23
|
[t.optimism]: "opt-mainnet",
|
|
24
24
|
[t.optimismTest]: "opt-mainnet",
|
|
25
25
|
[t.base]: "base-mainnet",
|
|
26
|
-
[t.solanaMainnet]: "solana-mainnet"
|
|
26
|
+
[t.solanaMainnet]: "solana-mainnet",
|
|
27
|
+
[t.sepoliaTestnet]: "eth-sepolia"
|
|
27
28
|
};
|
|
28
29
|
KNOWN_GOOD_NFTS = {
|
|
29
30
|
[t.base]: ["0x20bc8d248fe9c18a947406cea50d716828ab821f"],
|
|
@@ -33,12 +34,12 @@ var w = new class {
|
|
|
33
34
|
return this.KNOWN_GOOD_NFTS[t] ? this.KNOWN_GOOD_NFTS[t].some((t) => c(e, t)) : !1;
|
|
34
35
|
}
|
|
35
36
|
async getPublicTokens(e, t) {
|
|
36
|
-
let n = m(t, e)
|
|
37
|
-
return
|
|
37
|
+
let n = m(t, e);
|
|
38
|
+
return g((await b(u.ALCHEMY_PUBLIC_TOKENS))?.[n] || [], e);
|
|
38
39
|
}
|
|
39
40
|
async getFetchedTokens(e, t) {
|
|
40
41
|
let n = m(t, e);
|
|
41
|
-
return
|
|
42
|
+
return g(this.fetchedTokens[n] || [], e);
|
|
42
43
|
}
|
|
43
44
|
fetchAndUpdatePublicTokens(e, t) {
|
|
44
45
|
return n(t) ? this.fetchAndUpdateSolanaTokens(e, t) : this.fetchAndUpdateEVMTokens(e, t);
|
|
@@ -123,7 +124,7 @@ var w = new class {
|
|
|
123
124
|
}
|
|
124
125
|
async getEVMTokenAddresses(t, n) {
|
|
125
126
|
let r = await v(t, n, s), i = this.ALCHEMY_URLS[t];
|
|
126
|
-
if (!i) throw Error(
|
|
127
|
+
if (!i) throw Error(`Alchemy URL not found for the specified chain ID: ${t}`);
|
|
127
128
|
let a = `https://${i}.g.alchemy.com/v2/${e}`, o = [], c;
|
|
128
129
|
do {
|
|
129
130
|
let e = [n, "erc20"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../../../_virtual/_rolldown/runtime.cjs`),t=require(`../../constants/chains.constants.cjs`),n=require(`../../constants/protocol.constants.cjs`),r=require(`../../
|
|
1
|
+
const e=require(`../../../../_virtual/_rolldown/runtime.cjs`),t=require(`../../constants/chains.constants.cjs`),n=require(`../../constants/protocol.constants.cjs`),r=require(`../../functions/utils/caseInsensitive.utils.cjs`),i=require(`../../types/ethereum-network.types.cjs`),a=require(`../../types/cache.types.cjs`),o=require(`../../error-handling/logger.cjs`),s=require(`../../API/API.cjs`),c=require(`../../functions/utils/string.utils.cjs`),l=require(`./token-visibility-db.cjs`),u=require(`../../functions/web3/getContractMetadata.cjs`);let d=require(`idb-keyval`),f=require(`axios`);f=e.__toESM(f);var p=class{API_BASE=`https://testnet.arcscan.app/api`;fetchedTokens={};async getPublicTokens(e){let n=c.getStateKey(e,t.chainIds.arcTestnet);return(await(0,d.get)(a.StorageKeys.ARC_PUBLIC_TOKENS))?.[n]||[]}getFetchedTokens(e){let n=c.getStateKey(e,t.chainIds.arcTestnet);return this.fetchedTokens[n]||[]}async fetchAndUpdatePublicTokens(e){let i=c.getStateKey(e,t.chainIds.arcTestnet),o=await this.getERC20TokenAddresses(e),u=await this.getNFTTokens(e),f=u.map(e=>e.contractAddress),p=[...o,...f];if(!p.length)return;let m=(await s.API.tokensInfoCall(t.chainIds.arcTestnet,p)).map((e,i)=>{if(e)return e;let a=p[i],o=u.find(e=>r.caseInsensitiveEqual(e.contractAddress,a));return o&&o.tokenIds&&o.tokenIds.length>0?{chainId:t.chainIds.arcTestnet,name:`Unknown NFT`,symbol:`NFT`,erc20TokenAddress:a,decimals:0,nftTokenType:n.TokenType.ERC721,tokenIds:o.tokenIds}:null}).filter(e=>!!e),h=await l.tokenVisibilityStorage.hideSpamsAndFetchHiddenTokensAddresses(t.chainIds.arcTestnet,m),g=m.filter(e=>!r.lowerCaseIncludes(h,e.erc20TokenAddress)).map(e=>({...e,tokenIds:u.find(t=>r.caseInsensitiveEqual(t.contractAddress,e.erc20TokenAddress))?.tokenIds}));await(0,d.update)(a.StorageKeys.ARC_PUBLIC_TOKENS,(e={})=>{let t={...e,[i]:g};return this.fetchedTokens=t,t})}async getERC20TokenAddresses(e){let n=[];try{let r=(await f.default.post(`${this.API_BASE}?module=account&action=tokentx&address=${e}`)).data;if(r.status===`1`&&r.result){let a=[...new Set(r.result.map(({contractAddress:e})=>e))];for(let r of a)try{let a=u.getContractWithFetcherByChainId(t.chainIds.arcTestnet,i.ContractType.ERC20Contract,r),o=BigInt(await a.balanceOf(e));o>0n&&n.push({contractAddress:r,tokenBalance:o.toString()})}catch(e){o.Logger.error(`Error fetching ARC testnet token balance:`,e)}}}catch(e){o.Logger.error(`Error fetching ARC testnet token transactions:`,e)}return n.filter(({tokenBalance:e})=>Number(e)!==0).map(({contractAddress:e})=>e)}async getNFTTokens(e){let t=`${this.API_BASE}/v2/addresses/${e}/nft?type=ERC-721,ERC-1155`,n=[],r;do{let e=r?`&${new URLSearchParams(r)}`:``,{data:i}=await f.default.get(`${t}${e}`),{items:a=[],next_page_params:o}=i;n.push(...a),r=o?{token_contract_address_hash:o.token_contract_address_hash,token_id:o.token_id,token_type:o.token_type}:void 0}while(r);let i=n.reduce((e,t)=>{let n=t.token.address_hash.toLowerCase(),r=t.id;return e.has(n)||e.set(n,[]),e.get(n)?.push(r),e},new Map);return Array.from(i.entries()).map(([e,t])=>({contractAddress:e,tokenIds:t}))}},m=new p;exports.ArcPublicTokensDB=p,exports.arcPublicTokensDB=m;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { chainIds as e } from "../../constants/chains.constants.mjs";
|
|
2
2
|
import { TokenType as t } from "../../constants/protocol.constants.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { caseInsensitiveEqual as n, lowerCaseIncludes as r } from "../../functions/utils/caseInsensitive.utils.mjs";
|
|
4
|
+
import { ContractType as i } from "../../types/ethereum-network.types.mjs";
|
|
5
5
|
import { StorageKeys as a } from "../../types/cache.types.mjs";
|
|
6
6
|
import { Logger as o } from "../../error-handling/logger.mjs";
|
|
7
7
|
import { API as s } from "../../API/API.mjs";
|
|
@@ -22,12 +22,12 @@ var m = class {
|
|
|
22
22
|
let n = c(t, e.arcTestnet);
|
|
23
23
|
return this.fetchedTokens[n] || [];
|
|
24
24
|
}
|
|
25
|
-
async fetchAndUpdatePublicTokens(
|
|
26
|
-
let o = c(
|
|
25
|
+
async fetchAndUpdatePublicTokens(i) {
|
|
26
|
+
let o = c(i, e.arcTestnet), u = await this.getERC20TokenAddresses(i), d = await this.getNFTTokens(i), p = d.map((e) => e.contractAddress), m = [...u, ...p];
|
|
27
27
|
if (!m.length) return;
|
|
28
|
-
let h = (await s.tokensInfoCall(e.arcTestnet, m)).map((
|
|
29
|
-
if (
|
|
30
|
-
let a = m[i], o = d.find((e) =>
|
|
28
|
+
let h = (await s.tokensInfoCall(e.arcTestnet, m)).map((r, i) => {
|
|
29
|
+
if (r) return r;
|
|
30
|
+
let a = m[i], o = d.find((e) => n(e.contractAddress, a));
|
|
31
31
|
return o && o.tokenIds && o.tokenIds.length > 0 ? {
|
|
32
32
|
chainId: e.arcTestnet,
|
|
33
33
|
name: "Unknown NFT",
|
|
@@ -37,9 +37,9 @@ var m = class {
|
|
|
37
37
|
nftTokenType: t.ERC721,
|
|
38
38
|
tokenIds: o.tokenIds
|
|
39
39
|
} : null;
|
|
40
|
-
}).filter((e) => !!e), g = await l.hideSpamsAndFetchHiddenTokensAddresses(e.arcTestnet, h), _ = h.filter((e) => !
|
|
40
|
+
}).filter((e) => !!e), g = await l.hideSpamsAndFetchHiddenTokensAddresses(e.arcTestnet, h), _ = h.filter((e) => !r(g, e.erc20TokenAddress)).map((e) => ({
|
|
41
41
|
...e,
|
|
42
|
-
tokenIds: d.find((t) =>
|
|
42
|
+
tokenIds: d.find((t) => n(t.contractAddress, e.erc20TokenAddress))?.tokenIds
|
|
43
43
|
}));
|
|
44
44
|
await f(a.ARC_PUBLIC_TOKENS, (e = {}) => {
|
|
45
45
|
let t = {
|
|
@@ -50,15 +50,15 @@ var m = class {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
async getERC20TokenAddresses(t) {
|
|
53
|
-
let
|
|
53
|
+
let n = [];
|
|
54
54
|
try {
|
|
55
|
-
let
|
|
56
|
-
if (
|
|
57
|
-
let a = [...new Set(
|
|
58
|
-
for (let
|
|
59
|
-
let a = u(e.arcTestnet,
|
|
60
|
-
o > 0n &&
|
|
61
|
-
contractAddress:
|
|
55
|
+
let r = (await p.post(`${this.API_BASE}?module=account&action=tokentx&address=${t}`)).data;
|
|
56
|
+
if (r.status === "1" && r.result) {
|
|
57
|
+
let a = [...new Set(r.result.map(({ contractAddress: e }) => e))];
|
|
58
|
+
for (let r of a) try {
|
|
59
|
+
let a = u(e.arcTestnet, i.ERC20Contract, r), o = BigInt(await a.balanceOf(t));
|
|
60
|
+
o > 0n && n.push({
|
|
61
|
+
contractAddress: r,
|
|
62
62
|
tokenBalance: o.toString()
|
|
63
63
|
});
|
|
64
64
|
} catch (e) {
|
|
@@ -68,7 +68,7 @@ var m = class {
|
|
|
68
68
|
} catch (e) {
|
|
69
69
|
o.error("Error fetching ARC testnet token transactions:", e);
|
|
70
70
|
}
|
|
71
|
-
return
|
|
71
|
+
return n.filter(({ tokenBalance: e }) => Number(e) !== 0).map(({ contractAddress: e }) => e);
|
|
72
72
|
}
|
|
73
73
|
async getNFTTokens(e) {
|
|
74
74
|
let t = `${this.API_BASE}/v2/addresses/${e}/nft?type=ERC-721,ERC-1155`, n = [], r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/protocol.constants.cjs`),t=require(`../../functions/utils/caseInsensitive.utils.cjs`),n=require(`../../types/cache.types.cjs`),r=require(`../../error-handling/logger.cjs`),i=require(`../../API/API.cjs`),
|
|
1
|
+
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/protocol.constants.cjs`),t=require(`../../functions/utils/caseInsensitive.utils.cjs`),n=require(`../../types/cache.types.cjs`),r=require(`../../error-handling/logger.cjs`),i=require(`../../functions/utils/tron.utils.cjs`),a=require(`../../API/API.cjs`),o=require(`../../functions/utils/string.utils.cjs`),s=require(`./token-visibility-db.cjs`),c=require(`../../functions/utils/erc20tokenFunctions.cjs`),l=require(`../../functions/utils/create-provider.cjs`),u=require(`../../constants/events.constants.cjs`);require(`../../functions/index.cjs`);let d=require(`ethers`),f=require(`idb-keyval`),p=require(`async-mutex`);var m=new class{fetchedTokens={};updateMutexes={};transferEventTopic=d.ethers.id(`Transfer(address,address,uint256)`);chunkSize=2e3;getMutex(e){return this.updateMutexes[e]||(this.updateMutexes[e]=new p.Mutex),this.updateMutexes[e]}async getPublicTokens(e,t){let r=o.getStateKey(t,e);return c.overlayTokensWithRegistryData((await(0,f.get)(n.StorageKeys.EVENTS_PUBLIC_TOKENS))?.[r]||[],e)}async getFetchedTokens(e,t){let n=o.getStateKey(t,e);return c.overlayTokensWithRegistryData(this.fetchedTokens[n]||[],e)}async fetchAndUpdatePublicTokens(e,i){let a=o.getStateKey(e,i);await this.getMutex(a).runExclusive(async()=>{try{let r=(await this.getPublicTokens(i,e)).map(e=>e.erc20TokenAddress),{toEvents:o,fromEvents:c,latestBlock:l}=await this.getEvents(e,i),u=[...o,...c],{erc20Tokens:d}=await this.fetchPublicTokens(u,i,r),p=await s.tokenVisibilityStorage.hideSpamsAndFetchHiddenTokensAddresses(i,d),m=d.filter(e=>!t.lowerCaseIncludes(p,e.erc20TokenAddress));await(0,f.update)(n.StorageKeys.EVENTS_PUBLIC_TOKENS,(e={})=>{let n=e[a]||[],r=n.map(e=>e.erc20TokenAddress),i=m.filter(e=>!t.lowerCaseIncludes(r,e.erc20TokenAddress));n.push(...i);let s=this.updateTokenIds(c,o,n),l={...e,[a]:s};return this.fetchedTokens=l,l}),l&&await this.updateLastProcessedBlock(i,e,l)}catch(e){r.Logger.error(`public tokens db error`,e)}})}async getLastProcessedBlock(e,t){return(await(0,f.get)(n.StorageKeys.PUBLIC_TOKENS_LAST_PROCESSED_BLOCKS)||{})[o.getStateKey(t,e)]||u.EVENTS_INITIAL_BLOCKS[e]}async updateLastProcessedBlock(e,t,r){await(0,f.update)(n.StorageKeys.PUBLIC_TOKENS_LAST_PROCESSED_BLOCKS,(n={})=>{let i=o.getStateKey(t,e);return{...n,[i]:r}})}async getEvents(e,t){try{let n=l.createJsonRpcProvider(t),r=await this.getLastProcessedBlock(t,e)+1,a=await n.getBlockNumber(),o=i.addressToHexFormat(e),s=d.ethers.zeroPadValue(o,32),c=[],u=[];for(let e=r;e<=a;e+=this.chunkSize){let t=Math.min(e+this.chunkSize-1,a),r={topics:[this.transferEventTopic,null,s],fromBlock:e,toBlock:t},i={topics:[this.transferEventTopic,s,null],fromBlock:e,toBlock:t},[o,l]=await Promise.all([n.getLogs(r),n.getLogs(i)]);c.push(...o),u.push(...l)}return{toEvents:c,fromEvents:u,latestBlock:a}}catch(n){return r.Logger.error(`Error fetching events:`,n,`chainId`,t,`walletAddress`,e),{toEvents:[],fromEvents:[],latestBlock:void 0}}}updateTokenIds(e,t,n){let r=new Map;return n.forEach(e=>{if(c.isNFTToken(e)&&e.tokenIds){let t=e.erc20TokenAddress.toLowerCase();r.set(t,[...e.tokenIds])}}),t.forEach(e=>{if(e.topics.length<=3)return;let t=e.address.toLowerCase(),n=BigInt(e.topics[3]).toString();r.has(t)||r.set(t,[]),r.get(t)?.push(n)}),e.forEach(e=>{if(e.topics.length<=3)return;let t=e.address.toLowerCase(),n=r.get(t);if(n?.length){let t=BigInt(e.topics[3]).toString(),r=n.indexOf(t);r!==-1&&n.splice(r,1)}}),n.forEach(e=>{if(c.isNFTToken(e)){let t=e.erc20TokenAddress.toLowerCase(),n=r.get(t);e.tokenIds=n?.length&&n.length>0?n:void 0}}),n}async fetchPublicTokens(n,i,o){try{let r=[e.zeroAddress,...new Set(n.map(e=>e.address))].filter(e=>e&&!t.lowerCaseIncludes(o,e));return r.length?{erc20Tokens:(await a.API.tokensInfoCall(i,r)).filter(e=>!!e)}:{erc20Tokens:[]}}catch(e){return r.Logger.error(`Error fetching public tokens:`,e),{erc20Tokens:[]}}}};exports.eventsPublicTokensDB=m;
|
|
@@ -2,44 +2,44 @@ import { zeroAddress as e } from "../../constants/protocol.constants.mjs";
|
|
|
2
2
|
import { lowerCaseIncludes as t } from "../../functions/utils/caseInsensitive.utils.mjs";
|
|
3
3
|
import { StorageKeys as n } from "../../types/cache.types.mjs";
|
|
4
4
|
import { Logger as r } from "../../error-handling/logger.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import "../../constants/
|
|
5
|
+
import { addressToHexFormat as i } from "../../functions/utils/tron.utils.mjs";
|
|
6
|
+
import { API as a } from "../../API/API.mjs";
|
|
7
|
+
import { getStateKey as o } from "../../functions/utils/string.utils.mjs";
|
|
8
|
+
import { tokenVisibilityStorage as s } from "./token-visibility-db.mjs";
|
|
9
|
+
import { isNFTToken as c, overlayTokensWithRegistryData as l } from "../../functions/utils/erc20tokenFunctions.mjs";
|
|
10
|
+
import { createJsonRpcProvider as u } from "../../functions/utils/create-provider.mjs";
|
|
11
|
+
import { EVENTS_INITIAL_BLOCKS as d } from "../../constants/events.constants.mjs";
|
|
12
12
|
import "../../functions/index.mjs";
|
|
13
|
-
import { ethers as
|
|
14
|
-
import { get as
|
|
15
|
-
import { Mutex as
|
|
16
|
-
var
|
|
13
|
+
import { ethers as f } from "ethers";
|
|
14
|
+
import { get as p, update as m } from "idb-keyval";
|
|
15
|
+
import { Mutex as h } from "async-mutex";
|
|
16
|
+
var g = new class {
|
|
17
17
|
fetchedTokens = {};
|
|
18
18
|
updateMutexes = {};
|
|
19
|
-
transferEventTopic =
|
|
19
|
+
transferEventTopic = f.id("Transfer(address,address,uint256)");
|
|
20
20
|
chunkSize = 2e3;
|
|
21
21
|
getMutex(e) {
|
|
22
|
-
return this.updateMutexes[e] || (this.updateMutexes[e] = new
|
|
22
|
+
return this.updateMutexes[e] || (this.updateMutexes[e] = new h()), this.updateMutexes[e];
|
|
23
23
|
}
|
|
24
24
|
async getPublicTokens(e, t) {
|
|
25
|
-
let r =
|
|
26
|
-
return
|
|
25
|
+
let r = o(t, e);
|
|
26
|
+
return l((await p(n.EVENTS_PUBLIC_TOKENS))?.[r] || [], e);
|
|
27
27
|
}
|
|
28
28
|
async getFetchedTokens(e, t) {
|
|
29
|
-
let n =
|
|
30
|
-
return
|
|
29
|
+
let n = o(t, e);
|
|
30
|
+
return l(this.fetchedTokens[n] || [], e);
|
|
31
31
|
}
|
|
32
32
|
async fetchAndUpdatePublicTokens(e, i) {
|
|
33
|
-
let
|
|
34
|
-
await this.getMutex(
|
|
33
|
+
let a = o(e, i);
|
|
34
|
+
await this.getMutex(a).runExclusive(async () => {
|
|
35
35
|
try {
|
|
36
|
-
let r = (await this.getPublicTokens(i, e)).map((e) => e.erc20TokenAddress), { toEvents:
|
|
37
|
-
await
|
|
38
|
-
let n = e[
|
|
36
|
+
let r = (await this.getPublicTokens(i, e)).map((e) => e.erc20TokenAddress), { toEvents: o, fromEvents: c, latestBlock: l } = await this.getEvents(e, i), u = [...o, ...c], { erc20Tokens: d } = await this.fetchPublicTokens(u, i, r), f = await s.hideSpamsAndFetchHiddenTokensAddresses(i, d), p = d.filter((e) => !t(f, e.erc20TokenAddress));
|
|
37
|
+
await m(n.EVENTS_PUBLIC_TOKENS, (e = {}) => {
|
|
38
|
+
let n = e[a] || [], r = n.map((e) => e.erc20TokenAddress), i = p.filter((e) => !t(r, e.erc20TokenAddress));
|
|
39
39
|
n.push(...i);
|
|
40
|
-
let
|
|
40
|
+
let s = this.updateTokenIds(c, o, n), l = {
|
|
41
41
|
...e,
|
|
42
|
-
[
|
|
42
|
+
[a]: s
|
|
43
43
|
};
|
|
44
44
|
return this.fetchedTokens = l, l;
|
|
45
45
|
}), l && await this.updateLastProcessedBlock(i, e, l);
|
|
@@ -49,11 +49,11 @@ var h = new class {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
async getLastProcessedBlock(e, t) {
|
|
52
|
-
return (await
|
|
52
|
+
return (await p(n.PUBLIC_TOKENS_LAST_PROCESSED_BLOCKS) || {})[o(t, e)] || d[e];
|
|
53
53
|
}
|
|
54
54
|
async updateLastProcessedBlock(e, t, r) {
|
|
55
|
-
await
|
|
56
|
-
let i =
|
|
55
|
+
await m(n.PUBLIC_TOKENS_LAST_PROCESSED_BLOCKS, (n = {}) => {
|
|
56
|
+
let i = o(t, e);
|
|
57
57
|
return {
|
|
58
58
|
...n,
|
|
59
59
|
[i]: r
|
|
@@ -62,31 +62,31 @@ var h = new class {
|
|
|
62
62
|
}
|
|
63
63
|
async getEvents(e, t) {
|
|
64
64
|
try {
|
|
65
|
-
let n =
|
|
66
|
-
for (let e = r; e <=
|
|
67
|
-
let t = Math.min(e + this.chunkSize - 1,
|
|
65
|
+
let n = u(t), r = await this.getLastProcessedBlock(t, e) + 1, a = await n.getBlockNumber(), o = i(e), s = f.zeroPadValue(o, 32), c = [], l = [];
|
|
66
|
+
for (let e = r; e <= a; e += this.chunkSize) {
|
|
67
|
+
let t = Math.min(e + this.chunkSize - 1, a), r = {
|
|
68
68
|
topics: [
|
|
69
69
|
this.transferEventTopic,
|
|
70
70
|
null,
|
|
71
|
-
|
|
71
|
+
s
|
|
72
72
|
],
|
|
73
73
|
fromBlock: e,
|
|
74
74
|
toBlock: t
|
|
75
|
-
},
|
|
75
|
+
}, i = {
|
|
76
76
|
topics: [
|
|
77
77
|
this.transferEventTopic,
|
|
78
|
-
|
|
78
|
+
s,
|
|
79
79
|
null
|
|
80
80
|
],
|
|
81
81
|
fromBlock: e,
|
|
82
82
|
toBlock: t
|
|
83
|
-
}, [
|
|
84
|
-
|
|
83
|
+
}, [o, u] = await Promise.all([n.getLogs(r), n.getLogs(i)]);
|
|
84
|
+
c.push(...o), l.push(...u);
|
|
85
85
|
}
|
|
86
86
|
return {
|
|
87
|
-
toEvents:
|
|
88
|
-
fromEvents:
|
|
89
|
-
latestBlock:
|
|
87
|
+
toEvents: c,
|
|
88
|
+
fromEvents: l,
|
|
89
|
+
latestBlock: a
|
|
90
90
|
};
|
|
91
91
|
} catch (n) {
|
|
92
92
|
return r.error("Error fetching events:", n, "chainId", t, "walletAddress", e), {
|
|
@@ -99,7 +99,7 @@ var h = new class {
|
|
|
99
99
|
updateTokenIds(e, t, n) {
|
|
100
100
|
let r = /* @__PURE__ */ new Map();
|
|
101
101
|
return n.forEach((e) => {
|
|
102
|
-
if (
|
|
102
|
+
if (c(e) && e.tokenIds) {
|
|
103
103
|
let t = e.erc20TokenAddress.toLowerCase();
|
|
104
104
|
r.set(t, [...e.tokenIds]);
|
|
105
105
|
}
|
|
@@ -115,20 +115,20 @@ var h = new class {
|
|
|
115
115
|
r !== -1 && n.splice(r, 1);
|
|
116
116
|
}
|
|
117
117
|
}), n.forEach((e) => {
|
|
118
|
-
if (
|
|
118
|
+
if (c(e)) {
|
|
119
119
|
let t = e.erc20TokenAddress.toLowerCase(), n = r.get(t);
|
|
120
120
|
e.tokenIds = n?.length && n.length > 0 ? n : void 0;
|
|
121
121
|
}
|
|
122
122
|
}), n;
|
|
123
123
|
}
|
|
124
|
-
async fetchPublicTokens(n,
|
|
124
|
+
async fetchPublicTokens(n, i, o) {
|
|
125
125
|
try {
|
|
126
126
|
let r = [e, ...new Set(n.map((e) => e.address))].filter((e) => e && !t(o, e));
|
|
127
|
-
return r.length ? { erc20Tokens: (await
|
|
127
|
+
return r.length ? { erc20Tokens: (await a.tokensInfoCall(i, r)).filter((e) => !!e) } : { erc20Tokens: [] };
|
|
128
128
|
} catch (e) {
|
|
129
129
|
return r.error("Error fetching public tokens:", e), { erc20Tokens: [] };
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
}();
|
|
133
133
|
//#endregion
|
|
134
|
-
export {
|
|
134
|
+
export { g as eventsPublicTokensDB };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../functions/utils/string.utils.cjs`),
|
|
1
|
+
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../error-handling/logger.cjs`),n=require(`../../functions/utils/string.utils.cjs`),r=require(`./AlchemyPublicTokensDB.cjs`),i=require(`./EventsPublicTokensDB.cjs`),a=require(`./ArcPublicTokensDB.cjs`),o=require(`./TronPublicTokensDB.cjs`),s=require(`./TempoPublicTokensDB.cjs`);var c=class{useAlternativeDB={};async getPublicTokens(t,c){let l=n.getStateKey(c,t);return this.useAlternativeDB[l]?i.eventsPublicTokensDB.getPublicTokens(t,c):t===e.chainIds.arcTestnet?a.arcPublicTokensDB.getPublicTokens(c):e.isTronLike(t)?o.tronPublicTokensDB.getPublicTokens(c,t):e.isTempo(t)?s.tempoPublicTokensDB.getPublicTokens(c,t):r.alchemyPublicTokensDB.getPublicTokens(t,c)}async getFetchedTokens(t,c){let l=n.getStateKey(c,t);return this.useAlternativeDB[l]?i.eventsPublicTokensDB.getFetchedTokens(t,c):t===e.chainIds.arcTestnet?a.arcPublicTokensDB.getFetchedTokens(c):e.isTronLike(t)?o.tronPublicTokensDB.getFetchedTokens(c,t):e.isTempo(t)?s.tempoPublicTokensDB.getFetchedTokens(c,t):r.alchemyPublicTokensDB.getFetchedTokens(t,c)}async fetchAndUpdatePublicTokens(c,l){let u=n.getStateKey(c,l);try{l===e.chainIds.arcTestnet?await a.arcPublicTokensDB.fetchAndUpdatePublicTokens(c):e.isTronLike(l)?await o.tronPublicTokensDB.fetchAndUpdatePublicTokens(c,l):e.isTempo(l)?await s.tempoPublicTokensDB.fetchAndUpdatePublicTokens(c,l):await r.alchemyPublicTokensDB.fetchAndUpdatePublicTokens(c,l),this.useAlternativeDB[u]=!1}catch(n){if(t.Logger.error(`error`,n),e.isSolanaLike(l))return;await i.eventsPublicTokensDB.fetchAndUpdatePublicTokens(c,l),this.useAlternativeDB[u]=!0}}};new c,exports.PublicTokensDB=c;
|
|
@@ -1,29 +1,32 @@
|
|
|
1
|
-
import { chainIds as e, isSolanaLike as t } from "../../constants/chains.constants.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { chainIds as e, isSolanaLike as t, isTempo as n, isTronLike as r } from "../../constants/chains.constants.mjs";
|
|
2
|
+
import { Logger as i } from "../../error-handling/logger.mjs";
|
|
3
|
+
import { getStateKey as a } from "../../functions/utils/string.utils.mjs";
|
|
4
|
+
import { alchemyPublicTokensDB as o } from "./AlchemyPublicTokensDB.mjs";
|
|
5
|
+
import { eventsPublicTokensDB as s } from "./EventsPublicTokensDB.mjs";
|
|
6
|
+
import { arcPublicTokensDB as c } from "./ArcPublicTokensDB.mjs";
|
|
7
|
+
import { tronPublicTokensDB as l } from "./TronPublicTokensDB.mjs";
|
|
8
|
+
import { tempoPublicTokensDB as u } from "./TempoPublicTokensDB.mjs";
|
|
6
9
|
//#region libs/shared/common/src/data-structures/TokenDBs/PublicTokensDB.ts
|
|
7
|
-
var
|
|
10
|
+
var d = class {
|
|
8
11
|
useAlternativeDB = {};
|
|
9
|
-
async getPublicTokens(t,
|
|
10
|
-
let
|
|
11
|
-
return t === e.arcTestnet ?
|
|
12
|
+
async getPublicTokens(t, i) {
|
|
13
|
+
let d = a(i, t);
|
|
14
|
+
return this.useAlternativeDB[d] ? s.getPublicTokens(t, i) : t === e.arcTestnet ? c.getPublicTokens(i) : r(t) ? l.getPublicTokens(i, t) : n(t) ? u.getPublicTokens(i, t) : o.getPublicTokens(t, i);
|
|
12
15
|
}
|
|
13
|
-
async getFetchedTokens(t,
|
|
14
|
-
let
|
|
15
|
-
return t === e.arcTestnet ?
|
|
16
|
+
async getFetchedTokens(t, i) {
|
|
17
|
+
let d = a(i, t);
|
|
18
|
+
return this.useAlternativeDB[d] ? s.getFetchedTokens(t, i) : t === e.arcTestnet ? c.getFetchedTokens(i) : r(t) ? l.getFetchedTokens(i, t) : n(t) ? u.getFetchedTokens(i, t) : o.getFetchedTokens(t, i);
|
|
16
19
|
}
|
|
17
|
-
async fetchAndUpdatePublicTokens(
|
|
18
|
-
let
|
|
20
|
+
async fetchAndUpdatePublicTokens(d, f) {
|
|
21
|
+
let p = a(d, f);
|
|
19
22
|
try {
|
|
20
|
-
|
|
21
|
-
} catch {
|
|
22
|
-
if (t(
|
|
23
|
-
await
|
|
23
|
+
f === e.arcTestnet ? await c.fetchAndUpdatePublicTokens(d) : r(f) ? await l.fetchAndUpdatePublicTokens(d, f) : n(f) ? await u.fetchAndUpdatePublicTokens(d, f) : await o.fetchAndUpdatePublicTokens(d, f), this.useAlternativeDB[p] = !1;
|
|
24
|
+
} catch (e) {
|
|
25
|
+
if (i.error("error", e), t(f)) return;
|
|
26
|
+
await s.fetchAndUpdatePublicTokens(d, f), this.useAlternativeDB[p] = !0;
|
|
24
27
|
}
|
|
25
28
|
}
|
|
26
29
|
};
|
|
27
|
-
new
|
|
30
|
+
new d();
|
|
28
31
|
//#endregion
|
|
29
|
-
export {
|
|
32
|
+
export { d as PublicTokensDB };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../functions/utils/caseInsensitive.utils.cjs`),t=require(`../../types/cache.types.cjs`),n=require(`../../API/API.cjs`),r=require(`../../functions/utils/string.utils.cjs`),i=require(`./token-visibility-db.cjs`),a=require(`../../functions/utils/erc20tokenFunctions.cjs`),o=require(`../../functions/utils/publicBalance.utils.cjs`);let s=require(`idb-keyval`);var c=class{fetchedTokens={};async getPublicTokens(e,n){let i=r.getStateKey(e,n);return a.overlayTokensWithRegistryData((await(0,s.get)(t.StorageKeys.TEMPO_PUBLIC_TOKENS))?.[i]||[],n)}async getFetchedTokens(e,t){let n=r.getStateKey(e,t);return a.overlayTokensWithRegistryData(this.fetchedTokens[n]||[],t)}async fetchAndUpdatePublicTokens(a,o){let c=r.getStateKey(a,o),l=await this.getHeldTokenAddresses(a,o);if(!l.length)return;let u=(await n.API.tokensInfoCall(o,l)).filter(e=>!!e),d=await i.tokenVisibilityStorage.hideSpamsAndFetchHiddenTokensAddresses(o,u),f=u.filter(t=>!e.lowerCaseIncludes(d,t.erc20TokenAddress));await(0,s.update)(t.StorageKeys.TEMPO_PUBLIC_TOKENS,(e={})=>{let t={...e,[c]:f};return this.fetchedTokens=t,t})}async getHeldTokenAddresses(e,t){let n=await a.getErc20TokensForChainAPI(t),r=await Promise.all(n.map(async n=>{let r=await o.getPublicBalanceByTokenAddress(t,e,n.erc20TokenAddress);return r&&r>0n?n.erc20TokenAddress:null}));return Array.from(new Set(r.filter(e=>!!e)))}},l=new c;exports.TempoPublicTokensDB=c,exports.tempoPublicTokensDB=l;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ERC20Token } from '../../types/token.types';
|
|
2
|
+
export declare class TempoPublicTokensDB {
|
|
3
|
+
private fetchedTokens;
|
|
4
|
+
getPublicTokens(walletAddress: string, chainId: number): Promise<ERC20Token[]>;
|
|
5
|
+
getFetchedTokens(walletAddress: string, chainId: number): Promise<ERC20Token[]>;
|
|
6
|
+
fetchAndUpdatePublicTokens(walletAddress: string, chainId: number): Promise<void>;
|
|
7
|
+
private getHeldTokenAddresses;
|
|
8
|
+
}
|
|
9
|
+
export declare const tempoPublicTokensDB: TempoPublicTokensDB;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { lowerCaseIncludes as e } from "../../functions/utils/caseInsensitive.utils.mjs";
|
|
2
|
+
import { StorageKeys as t } from "../../types/cache.types.mjs";
|
|
3
|
+
import { API as n } from "../../API/API.mjs";
|
|
4
|
+
import { getStateKey as r } from "../../functions/utils/string.utils.mjs";
|
|
5
|
+
import { tokenVisibilityStorage as i } from "./token-visibility-db.mjs";
|
|
6
|
+
import { getErc20TokensForChainAPI as a, overlayTokensWithRegistryData as o } from "../../functions/utils/erc20tokenFunctions.mjs";
|
|
7
|
+
import { getPublicBalanceByTokenAddress as s } from "../../functions/utils/publicBalance.utils.mjs";
|
|
8
|
+
import { get as c, update as l } from "idb-keyval";
|
|
9
|
+
//#region libs/shared/common/src/data-structures/TokenDBs/TempoPublicTokensDB.ts
|
|
10
|
+
var u = class {
|
|
11
|
+
fetchedTokens = {};
|
|
12
|
+
async getPublicTokens(e, n) {
|
|
13
|
+
let i = r(e, n);
|
|
14
|
+
return o((await c(t.TEMPO_PUBLIC_TOKENS))?.[i] || [], n);
|
|
15
|
+
}
|
|
16
|
+
async getFetchedTokens(e, t) {
|
|
17
|
+
let n = r(e, t);
|
|
18
|
+
return o(this.fetchedTokens[n] || [], t);
|
|
19
|
+
}
|
|
20
|
+
async fetchAndUpdatePublicTokens(a, o) {
|
|
21
|
+
let s = r(a, o), c = await this.getHeldTokenAddresses(a, o);
|
|
22
|
+
if (!c.length) return;
|
|
23
|
+
let u = (await n.tokensInfoCall(o, c)).filter((e) => !!e), d = await i.hideSpamsAndFetchHiddenTokensAddresses(o, u), f = u.filter((t) => !e(d, t.erc20TokenAddress));
|
|
24
|
+
await l(t.TEMPO_PUBLIC_TOKENS, (e = {}) => {
|
|
25
|
+
let t = {
|
|
26
|
+
...e,
|
|
27
|
+
[s]: f
|
|
28
|
+
};
|
|
29
|
+
return this.fetchedTokens = t, t;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async getHeldTokenAddresses(e, t) {
|
|
33
|
+
let n = await a(t), r = await Promise.all(n.map(async (n) => {
|
|
34
|
+
let r = await s(t, e, n.erc20TokenAddress);
|
|
35
|
+
return r && r > 0n ? n.erc20TokenAddress : null;
|
|
36
|
+
}));
|
|
37
|
+
return Array.from(new Set(r.filter((e) => !!e)));
|
|
38
|
+
}
|
|
39
|
+
}, d = new u();
|
|
40
|
+
//#endregion
|
|
41
|
+
export { u as TempoPublicTokensDB, d as tempoPublicTokensDB };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/protocol.constants.cjs`),t=require(`../../functions/utils/caseInsensitive.utils.cjs`),n=require(`../../types/cache.types.cjs`),r=require(`../http/HttpClient.cjs`);require(`../http/index.cjs`);const i=require(`../../functions/utils/tron.utils.cjs`),a=require(`../../API/API.cjs`),o=require(`../../functions/utils/string.utils.cjs`),s=require(`./token-visibility-db.cjs`),c=require(`../../functions/utils/erc20tokenFunctions.cjs`);let l=require(`idb-keyval`);var u=class{fetchedTokens={};async getPublicTokens(e,t){let r=o.getStateKey(e,t);return c.overlayTokensWithRegistryData((await(0,l.get)(n.StorageKeys.TRON_PUBLIC_TOKENS))?.[r]||[],t)}async getFetchedTokens(e,t){let n=o.getStateKey(e,t);return c.overlayTokensWithRegistryData(this.fetchedTokens[n]||[],t)}async fetchAndUpdatePublicTokens(e,r){let i=o.getStateKey(e,r),c=await this.getHeldTokenAddresses(e,r);if(!c.length)return;let u=(await a.API.tokensInfoCall(r,c)).filter(e=>!!e),d=await s.tokenVisibilityStorage.hideSpamsAndFetchHiddenTokensAddresses(r,u),f=u.filter(e=>!t.lowerCaseIncludes(d,e.erc20TokenAddress));await(0,l.update)(n.StorageKeys.TRON_PUBLIC_TOKENS,(e={})=>{let t={...e,[i]:f};return this.fetchedTokens=t,t})}async getHeldTokenAddresses(t,n){let a=i.toTronBase58IfHex(t),o=`${i.getTronWalletRpcUrl(n)}/v1/accounts/${a}`,s=(await r.httpClient.get(o))?.data?.[0];if(!s)return[];let c=[];return s.balance&&s.balance>0&&c.push(e.zeroAddress),(s.trc20??[]).forEach(e=>{Object.entries(e).forEach(([e,t])=>{BigInt(t)>0n&&c.push(i.addressToHexFormat(e))})}),Array.from(new Set(c))}},d=new u;exports.TronPublicTokensDB=u,exports.tronPublicTokensDB=d;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ERC20Token } from '../../types/token.types';
|
|
2
|
+
export declare class TronPublicTokensDB {
|
|
3
|
+
private fetchedTokens;
|
|
4
|
+
getPublicTokens(walletAddress: string, chainId: number): Promise<ERC20Token[]>;
|
|
5
|
+
getFetchedTokens(walletAddress: string, chainId: number): Promise<ERC20Token[]>;
|
|
6
|
+
fetchAndUpdatePublicTokens(walletAddress: string, chainId: number): Promise<void>;
|
|
7
|
+
private getHeldTokenAddresses;
|
|
8
|
+
}
|
|
9
|
+
export declare const tronPublicTokensDB: TronPublicTokensDB;
|