@hinkal/common 0.2.13 → 0.2.14
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/API/API.cjs +1 -1
- package/API/API.d.ts +10 -3
- package/API/API.mjs +42 -31
- package/API/ai-calls.cjs +1 -0
- package/API/ai-calls.d.ts +9 -0
- package/API/ai-calls.mjs +13 -0
- package/API/callCurveAPI.cjs +1 -1
- package/API/callCurveAPI.mjs +28 -22
- package/API/callRelayer.d.ts +3 -2
- package/API/dataServerCalls.cjs +1 -1
- package/API/dataServerCalls.d.ts +4 -0
- package/API/dataServerCalls.mjs +11 -7
- package/API/duneAPI.cjs +1 -1
- package/API/duneAPI.mjs +7 -4
- package/API/fetchCommitmentsCache.cjs +1 -1
- package/API/fetchCommitmentsCache.d.ts +9 -1
- package/API/fetchCommitmentsCache.mjs +6 -5
- package/API/getGasEstimates.cjs +1 -1
- package/API/getGasEstimates.d.ts +2 -1
- package/API/getGasEstimates.mjs +10 -9
- package/API/getServerURL.d.ts +1 -1
- package/API/index.d.ts +2 -0
- package/API/is-tx-stateless.cjs +1 -0
- package/API/is-tx-stateless.d.ts +3 -0
- package/API/is-tx-stateless.mjs +9 -0
- package/API/rewardsPointsCalls.cjs +1 -1
- package/API/rewardsPointsCalls.d.ts +3 -3
- package/API/rewardsPointsCalls.mjs +1 -3
- package/API/tenderly.api.cjs +1 -0
- package/API/tenderly.api.d.ts +12 -0
- package/API/tenderly.api.mjs +47 -0
- package/API/token-calls.cjs +1 -0
- package/API/token-calls.d.ts +2 -0
- package/API/token-calls.mjs +9 -0
- package/API/userVerifyTransactions.cjs +1 -1
- package/API/userVerifyTransactions.d.ts +6 -7
- package/API/userVerifyTransactions.mjs +13 -14
- package/constants/addresses.constants.cjs +1 -0
- package/constants/addresses.constants.d.ts +16 -0
- package/constants/addresses.constants.mjs +50 -0
- package/constants/assets.constants.cjs +1 -1
- package/constants/assets.constants.mjs +13 -13
- package/constants/axelar.constants.cjs +1 -1
- package/constants/axelar.constants.mjs +5 -5
- package/constants/balance.constants.cjs +1 -0
- package/constants/balance.constants.d.ts +1 -0
- package/constants/balance.constants.mjs +4 -0
- package/constants/chains.constants.cjs +1 -1
- package/constants/chains.constants.d.ts +0 -2
- package/constants/chains.constants.mjs +28 -40
- package/constants/contracts.constants.cjs +1 -1
- package/constants/contracts.constants.mjs +144 -140
- package/constants/conversion.constants.cjs +1 -0
- package/constants/conversion.constants.d.ts +1 -0
- package/constants/conversion.constants.mjs +4 -0
- package/constants/deploy-data/deploy-data-arbMainnet.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-arbMainnet.json.mjs +846 -11
- package/constants/deploy-data/deploy-data-avalanche.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-avalanche.json.mjs +848 -13
- package/constants/deploy-data/deploy-data-base.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-base.json.mjs +852 -17
- package/constants/deploy-data/deploy-data-bnbMainnet.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-bnbMainnet.json.mjs +855 -20
- package/constants/deploy-data/deploy-data-ethMainnet.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-ethMainnet.json.mjs +850 -15
- package/constants/deploy-data/deploy-data-localhost.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-localhost.json.mjs +3208 -1550
- package/constants/deploy-data/deploy-data-optimism.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-optimism.json.mjs +10010 -3429
- package/constants/deploy-data/deploy-data-polygon.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-polygon.json.mjs +844 -9
- package/constants/fees.constants.cjs +1 -1
- package/constants/fees.constants.d.ts +5 -3
- package/constants/fees.constants.mjs +22 -19
- package/constants/index.d.ts +6 -0
- package/constants/kyc.constants.cjs +1 -1
- package/constants/kyc.constants.mjs +30 -18
- package/constants/mediaUrls.constants.cjs +1 -0
- package/constants/mediaUrls.constants.d.ts +23 -0
- package/constants/mediaUrls.constants.mjs +26 -0
- package/constants/permit2.constants.cjs +1 -0
- package/constants/permit2.constants.d.ts +2 -0
- package/constants/permit2.constants.mjs +5 -0
- package/constants/protocol.constants.cjs +1 -1
- package/constants/protocol.constants.d.ts +6 -0
- package/constants/protocol.constants.mjs +27 -15
- package/constants/rewards.constants.cjs +1 -1
- package/constants/rewards.constants.mjs +14 -12
- package/constants/server.constants.cjs +1 -1
- package/constants/server.constants.d.ts +14 -6
- package/constants/server.constants.mjs +24 -16
- package/constants/token-data/ERC20Registry.cjs +1 -1
- package/constants/token-data/ERC20Registry.mjs +49 -48
- package/constants/token-data/arbMainnetRegistry.json.cjs +1 -1
- package/constants/token-data/arbMainnetRegistry.json.mjs +89 -86
- package/constants/token-data/arbMainnetRegistryFixed.json.cjs +1 -1
- package/constants/token-data/arbMainnetRegistryFixed.json.mjs +79 -76
- package/constants/token-data/avalancheRegistry.json.cjs +1 -1
- package/constants/token-data/avalancheRegistry.json.mjs +51 -48
- package/constants/token-data/avalancheRegistryFixed.json.cjs +1 -1
- package/constants/token-data/avalancheRegistryFixed.json.mjs +51 -48
- package/constants/token-data/baseRegistry.json.cjs +1 -1
- package/constants/token-data/baseRegistry.json.mjs +34 -31
- package/constants/token-data/baseRegistryFixed.json.cjs +1 -1
- package/constants/token-data/baseRegistryFixed.json.mjs +31 -28
- package/constants/token-data/bnbMainnetRegistry.json.cjs +1 -1
- package/constants/token-data/bnbMainnetRegistry.json.mjs +67 -64
- package/constants/token-data/bnbMainnetRegistryFixed.json.cjs +1 -1
- package/constants/token-data/bnbMainnetRegistryFixed.json.mjs +67 -64
- package/constants/token-data/ethMainnetRegistry.json.cjs +1 -1
- package/constants/token-data/ethMainnetRegistry.json.mjs +229 -226
- package/constants/token-data/ethMainnetRegistryFixed.json.cjs +1 -1
- package/constants/token-data/ethMainnetRegistryFixed.json.mjs +193 -190
- package/constants/token-data/index.cjs +1 -0
- package/constants/token-data/index.d.ts +1063 -15
- package/constants/token-data/index.mjs +34 -0
- package/constants/token-data/localhostRegistry.json.cjs +1 -1
- package/constants/token-data/localhostRegistry.json.mjs +296 -276
- package/constants/token-data/optimismRegistry.json.cjs +1 -1
- package/constants/token-data/optimismRegistry.json.mjs +703 -180
- package/constants/token-data/optimismRegistryFixed.json.cjs +1 -1
- package/constants/token-data/optimismRegistryFixed.json.mjs +679 -173
- package/constants/token-data/polygonRegistry.json.cjs +1 -1
- package/constants/token-data/polygonRegistry.json.mjs +110 -107
- package/constants/token-data/polygonRegistryFixed.json.cjs +1 -1
- package/constants/token-data/polygonRegistryFixed.json.mjs +102 -99
- package/constants/token.limits.constants.cjs +1 -0
- package/constants/token.limits.constants.d.ts +5 -0
- package/constants/token.limits.constants.mjs +30 -0
- package/constants/vite.constants.cjs +1 -1
- package/constants/vite.constants.d.ts +5 -0
- package/constants/vite.constants.mjs +26 -22
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +48 -20
- package/data-structures/Hinkal/Hinkal.mjs +263 -85
- package/data-structures/Hinkal/IHinkal.d.ts +37 -10
- package/data-structures/Hinkal/hinkalActionBeefy.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionBeefy.mjs +25 -23
- package/data-structures/Hinkal/hinkalActionConvex.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionConvex.mjs +11 -9
- package/data-structures/Hinkal/hinkalActionCurve.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionCurve.mjs +18 -16
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.cjs +1 -0
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.d.ts +3 -0
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.mjs +61 -0
- package/data-structures/Hinkal/hinkalActionLidoEth.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionLidoEth.mjs +24 -22
- package/data-structures/Hinkal/hinkalActionPendle.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionPendle.d.ts +1 -1
- package/data-structures/Hinkal/hinkalActionPendle.mjs +17 -15
- package/data-structures/Hinkal/hinkalActionPendleLP.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionPendleLP.mjs +29 -26
- package/data-structures/Hinkal/hinkalActionReceive.cjs +1 -0
- package/data-structures/Hinkal/hinkalActionReceive.d.ts +4 -0
- package/data-structures/Hinkal/hinkalActionReceive.mjs +39 -0
- package/data-structures/Hinkal/hinkalActionStake.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionStake.d.ts +1 -1
- package/data-structures/Hinkal/hinkalActionStake.mjs +15 -11
- package/data-structures/Hinkal/hinkalActionVolatile.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionVolatile.d.ts +1 -1
- package/data-structures/Hinkal/hinkalActionVolatile.mjs +31 -26
- package/data-structures/Hinkal/hinkalApprove.cjs +1 -0
- package/data-structures/Hinkal/hinkalApprove.d.ts +2 -0
- package/data-structures/Hinkal/hinkalApprove.mjs +120 -0
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -0
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.d.ts +3 -0
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +12 -0
- package/data-structures/Hinkal/hinkalDeploySubAccount.cjs +1 -0
- package/data-structures/Hinkal/hinkalDeploySubAccount.d.ts +3 -0
- package/data-structures/Hinkal/hinkalDeploySubAccount.mjs +15 -0
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.d.ts +3 -2
- package/data-structures/Hinkal/hinkalDeposit.mjs +116 -52
- package/data-structures/Hinkal/hinkalGetRecipientInfo.cjs +1 -0
- package/data-structures/Hinkal/hinkalGetRecipientInfo.d.ts +2 -0
- package/data-structures/Hinkal/hinkalGetRecipientInfo.mjs +10 -0
- package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
- package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +6 -17
- package/data-structures/Hinkal/hinkalInsideTransact.cjs +1 -0
- package/data-structures/Hinkal/hinkalInsideTransact.d.ts +2 -0
- package/data-structures/Hinkal/hinkalInsideTransact.mjs +111 -0
- package/data-structures/Hinkal/hinkalMultiSend.cjs +1 -0
- package/data-structures/Hinkal/hinkalMultiSend.d.ts +3 -0
- package/data-structures/Hinkal/hinkalMultiSend.mjs +13 -0
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.d.ts +2 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +83 -37
- package/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -0
- package/data-structures/Hinkal/hinkalProoflessDeposit.d.ts +4 -0
- package/data-structures/Hinkal/hinkalProoflessDeposit.mjs +46 -0
- package/data-structures/Hinkal/hinkalProxySwap.cjs +1 -0
- package/data-structures/Hinkal/hinkalProxySwap.d.ts +5 -0
- package/data-structures/Hinkal/hinkalProxySwap.mjs +36 -0
- package/data-structures/Hinkal/hinkalSignSubAccount.cjs +1 -0
- package/data-structures/Hinkal/hinkalSignSubAccount.d.ts +3 -0
- package/data-structures/Hinkal/hinkalSignSubAccount.mjs +20 -0
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.d.ts +2 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +69 -60
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.d.ts +3 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +77 -50
- package/data-structures/Hinkal/index.d.ts +1 -0
- package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.mjs +18 -11
- package/data-structures/IndexedDB/activity-db.cjs +1 -0
- package/data-structures/IndexedDB/activity-db.d.ts +16 -0
- package/data-structures/IndexedDB/activity-db.mjs +124 -0
- package/data-structures/IndexedDB/balances-db.cjs +1 -0
- package/data-structures/IndexedDB/balances-db.d.ts +13 -0
- package/data-structures/IndexedDB/balances-db.mjs +75 -0
- package/data-structures/IndexedDB/contact-db.cjs +1 -0
- package/data-structures/IndexedDB/contact-db.d.ts +11 -0
- package/data-structures/IndexedDB/contact-db.mjs +44 -0
- package/data-structures/IndexedDB/index.d.ts +5 -0
- package/data-structures/IndexedDB/prices-db.cjs +1 -0
- package/data-structures/IndexedDB/prices-db.d.ts +9 -0
- package/data-structures/IndexedDB/prices-db.mjs +62 -0
- package/data-structures/IndexedDB/private-balances-db.cjs +1 -0
- package/data-structures/IndexedDB/private-balances-db.d.ts +9 -0
- package/data-structures/IndexedDB/private-balances-db.mjs +28 -0
- package/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs +1 -1
- package/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.mjs +47 -44
- package/data-structures/TokenDBs/PrivateTokensDB.cjs +1 -0
- package/data-structures/TokenDBs/PrivateTokensDB.d.ts +11 -0
- package/data-structures/TokenDBs/PrivateTokensDB.mjs +53 -0
- package/data-structures/TokenDBs/PublicTokensDB.cjs +1 -0
- package/data-structures/TokenDBs/PublicTokensDB.d.ts +13 -0
- package/data-structures/TokenDBs/PublicTokensDB.mjs +81 -0
- package/data-structures/TokenDBs/index.d.ts +2 -0
- package/data-structures/cacheDevices/AttachableMemoryCacheDevice.cjs +1 -0
- package/data-structures/cacheDevices/AttachableMemoryCacheDevice.d.ts +8 -0
- package/data-structures/cacheDevices/AttachableMemoryCacheDevice.mjs +28 -0
- package/data-structures/cacheDevices/BaseCacheDevice.cjs +1 -1
- package/data-structures/cacheDevices/BaseCacheDevice.d.ts +9 -6
- package/data-structures/cacheDevices/BaseCacheDevice.mjs +13 -4
- package/data-structures/cacheDevices/FileCacheDevice.cjs +1 -1
- package/data-structures/cacheDevices/FileCacheDevice.d.ts +1 -0
- package/data-structures/cacheDevices/FileCacheDevice.mjs +7 -3
- package/data-structures/cacheDevices/LocalStorageCacheDevice.cjs +1 -1
- package/data-structures/cacheDevices/LocalStorageCacheDevice.d.ts +2 -1
- package/data-structures/cacheDevices/LocalStorageCacheDevice.mjs +10 -5
- package/data-structures/crypto-keys/decodeUTXO.cjs +1 -1
- package/data-structures/crypto-keys/decodeUTXO.mjs +13 -12
- package/data-structures/crypto-keys/keys.cjs +1 -1
- package/data-structures/crypto-keys/keys.d.ts +13 -3
- package/data-structures/crypto-keys/keys.mjs +45 -34
- package/data-structures/custom-token-registry/CustomTokenRegistry.cjs +1 -1
- package/data-structures/custom-token-registry/CustomTokenRegistry.d.ts +2 -3
- package/data-structures/custom-token-registry/CustomTokenRegistry.mjs +17 -21
- package/data-structures/event-service/AbstractAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/event-service/AbstractAccessTokenSnapshotService.mjs +15 -29
- package/data-structures/event-service/AbstractApprovalsSnapshotService.cjs +1 -0
- package/data-structures/event-service/AbstractApprovalsSnapshotService.d.ts +30 -0
- package/data-structures/event-service/AbstractApprovalsSnapshotService.mjs +104 -0
- package/data-structures/event-service/AbstractCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/event-service/AbstractCommitmentsSnapshotService.mjs +24 -37
- package/data-structures/event-service/AbstractEventService.cjs +1 -1
- package/data-structures/event-service/AbstractEventService.d.ts +1 -1
- package/data-structures/event-service/AbstractEventService.mjs +15 -15
- package/data-structures/event-service/index.d.ts +1 -0
- package/data-structures/index.d.ts +2 -0
- package/data-structures/merkle-tree/MerkleTree.cjs +1 -1
- package/data-structures/merkle-tree/MerkleTree.d.ts +6 -1
- package/data-structures/merkle-tree/MerkleTree.mjs +79 -65
- package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.cjs +1 -0
- package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.d.ts +3 -0
- package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.mjs +13 -0
- package/data-structures/merkle-tree/index.d.ts +1 -0
- package/data-structures/provider-adapter/IProviderAdapter.d.ts +2 -0
- package/data-structures/snapshot/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientAccessTokenSnapshotService.mjs +3 -2
- package/data-structures/snapshot/ClientApprovalsSnapshotService.cjs +1 -0
- package/data-structures/snapshot/ClientApprovalsSnapshotService.d.ts +8 -0
- package/data-structures/snapshot/ClientApprovalsSnapshotService.mjs +23 -0
- package/data-structures/snapshot/ClientCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientCommitmentsSnapshotService.mjs +3 -2
- package/data-structures/snapshot/ClientNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientNullifierSnapshotService.mjs +6 -5
- package/data-structures/token-price-fetcher/TokenChecker.cjs +1 -1
- package/data-structures/token-price-fetcher/TokenChecker.d.ts +1 -0
- package/data-structures/token-price-fetcher/TokenChecker.mjs +4 -2
- package/data-structures/transactions-manager/TransactionsManager.cjs +1 -1
- package/data-structures/transactions-manager/TransactionsManager.d.ts +8 -6
- package/data-structures/transactions-manager/TransactionsManager.mjs +124 -122
- package/data-structures/transactions-manager/history/getBeefyData.cjs +1 -1
- package/data-structures/transactions-manager/history/getBeefyData.mjs +3 -2
- package/data-structures/transactions-manager/history/getConvexData.cjs +1 -1
- package/data-structures/transactions-manager/history/getConvexData.mjs +3 -2
- package/data-structures/transactions-manager/history/getCurveData.cjs +1 -1
- package/data-structures/transactions-manager/history/getCurveData.mjs +3 -2
- package/data-structures/transactions-manager/history/getLidoData.cjs +1 -1
- package/data-structures/transactions-manager/history/getLidoData.mjs +3 -2
- package/data-structures/transactions-manager/history/getPendleData.cjs +1 -1
- package/data-structures/transactions-manager/history/getPendleData.mjs +13 -12
- package/data-structures/transactions-manager/history/getTxDetails.cjs +1 -1
- package/data-structures/transactions-manager/history/getTxDetails.mjs +22 -20
- package/data-structures/transactions-manager/history/getVolatileData.cjs +1 -1
- package/data-structures/transactions-manager/history/getVolatileData.mjs +11 -10
- package/data-structures/transactions-manager/history/history.types.cjs +1 -1
- package/data-structures/transactions-manager/history/history.types.mjs +4 -2
- package/data-structures/utxo/Utxo.cjs +1 -1
- package/data-structures/utxo/Utxo.d.ts +3 -3
- package/data-structures/utxo/Utxo.mjs +8 -7
- package/error-handling/error-codes.constants.cjs +2 -2
- package/error-handling/error-codes.constants.d.ts +22 -1
- package/error-handling/error-codes.constants.mjs +129 -112
- package/error-handling/get-error.message.cjs +1 -1
- package/error-handling/get-error.message.mjs +29 -25
- package/error-handling/index.d.ts +1 -0
- package/error-handling/logger.cjs +1 -0
- package/error-handling/logger.d.ts +5 -0
- package/error-handling/logger.mjs +16 -0
- package/error-handling/types.cjs +1 -1
- package/error-handling/types.d.ts +3 -1
- package/error-handling/types.mjs +2 -2
- package/externalABIs/BabPassport.json.cjs +1 -1
- package/externalABIs/BabPassport.json.mjs +8 -3
- package/externalABIs/BeefyRouterAbi.json.cjs +1 -1
- package/externalABIs/BeefyRouterAbi.json.mjs +5 -2
- package/externalABIs/BeefyStrategyAbi.json.cjs +1 -1
- package/externalABIs/BeefyStrategyAbi.json.mjs +5 -2
- package/externalABIs/BeefyVaultAbi.json.cjs +1 -1
- package/externalABIs/BeefyVaultAbi.json.mjs +5 -2
- package/externalABIs/BeefyZapAbi.json.cjs +1 -1
- package/externalABIs/BeefyZapAbi.json.mjs +5 -2
- package/externalABIs/BeefyZapOneInchAbi.json.cjs +1 -1
- package/externalABIs/BeefyZapOneInchAbi.json.mjs +5 -2
- package/externalABIs/ConvexBoosterAbi.json.cjs +1 -1
- package/externalABIs/ConvexBoosterAbi.json.mjs +5 -2
- package/externalABIs/ConvexBoosterAbiMainnet.json.cjs +1 -1
- package/externalABIs/ConvexBoosterAbiMainnet.json.mjs +5 -2
- package/externalABIs/ConvexRewardPoolAbi.json.cjs +1 -1
- package/externalABIs/ConvexRewardPoolAbi.json.mjs +5 -2
- package/externalABIs/CurveReadingWrapperAbi.json.cjs +1 -1
- package/externalABIs/CurveReadingWrapperAbi.json.mjs +5 -2
- package/externalABIs/CurveWrappedMainPool.json.cjs +1 -1
- package/externalABIs/CurveWrappedMainPool.json.mjs +5 -2
- package/externalABIs/CurveZap.json.cjs +1 -1
- package/externalABIs/CurveZap.json.mjs +5 -2
- package/externalABIs/CvxCrvUtilities.json.cjs +1 -1
- package/externalABIs/CvxCrvUtilities.json.mjs +5 -2
- package/externalABIs/ERC20.json.cjs +1 -1
- package/externalABIs/ERC20.json.mjs +20 -3
- package/externalABIs/GalxePassport.json.cjs +1 -1
- package/externalABIs/GalxePassport.json.mjs +8 -3
- package/externalABIs/IQuoterV2.json.cjs +1 -1
- package/externalABIs/IQuoterV2.json.mjs +20 -3
- package/externalABIs/ISwapRouter.json.cjs +1 -1
- package/externalABIs/ISwapRouter.json.mjs +5 -2
- package/externalABIs/IUniswapV3Factory.json.cjs +1 -1
- package/externalABIs/IUniswapV3Factory.json.mjs +20 -3
- package/externalABIs/IUniswapV3Pool.json.cjs +1 -1
- package/externalABIs/IUniswapV3Pool.json.mjs +20 -3
- package/externalABIs/PendleRouterAbi.json.cjs +1 -1
- package/externalABIs/PendleRouterAbi.json.mjs +5 -2
- package/externalABIs/UniswapV2PoolAbi.json.cjs +1 -1
- package/externalABIs/UniswapV2PoolAbi.json.mjs +16 -3
- package/externalABIs/index.cjs +1 -0
- package/externalABIs/index.d.ts +307 -11
- package/externalABIs/index.mjs +23 -0
- package/externalABIs/transactionsProver.json.cjs +1 -1
- package/externalABIs/transactionsProver.json.mjs +20 -3
- package/functions/kyc/zkMeHelper.cjs +1 -1
- package/functions/kyc/zkMeHelper.d.ts +0 -1
- package/functions/kyc/zkMeHelper.mjs +8 -11
- package/functions/pre-transaction/getExternalSwapAddress.cjs +1 -0
- package/functions/pre-transaction/getExternalSwapAddress.d.ts +3 -0
- package/functions/pre-transaction/getExternalSwapAddress.mjs +26 -0
- package/functions/pre-transaction/getFeeStructure.cjs +1 -0
- package/functions/pre-transaction/getFeeStructure.d.ts +4 -0
- package/functions/pre-transaction/getFeeStructure.mjs +30 -0
- package/functions/pre-transaction/getFlatFees.cjs +1 -1
- package/functions/pre-transaction/getFlatFees.d.ts +3 -7
- package/functions/pre-transaction/getFlatFees.mjs +52 -46
- package/functions/pre-transaction/getSignatureDataForTransact.cjs +1 -0
- package/functions/pre-transaction/getSignatureDataForTransact.d.ts +3 -0
- package/functions/pre-transaction/getSignatureDataForTransact.mjs +6 -0
- package/functions/pre-transaction/index.d.ts +1 -0
- package/functions/pre-transaction/interaction-to-action.cjs +1 -1
- package/functions/pre-transaction/interaction-to-action.mjs +3 -2
- package/functions/pre-transaction/merge-with-fee-structure.cjs +1 -0
- package/functions/pre-transaction/merge-with-fee-structure.d.ts +2 -0
- package/functions/pre-transaction/merge-with-fee-structure.mjs +25 -0
- package/functions/pre-transaction/outputApprovalDataProcessing.cjs +1 -0
- package/functions/pre-transaction/outputApprovalDataProcessing.d.ts +16 -0
- package/functions/pre-transaction/outputApprovalDataProcessing.mjs +42 -0
- package/functions/pre-transaction/outputUtxoProcessing.cjs +1 -1
- package/functions/pre-transaction/outputUtxoProcessing.d.ts +1 -1
- package/functions/pre-transaction/outputUtxoProcessing.mjs +19 -30
- package/functions/pre-transaction/process-gas-estimates.cjs +1 -1
- package/functions/pre-transaction/process-gas-estimates.d.ts +2 -2
- package/functions/pre-transaction/process-gas-estimates.mjs +17 -27
- package/functions/pre-transaction/processAmountChanges.cjs +1 -1
- package/functions/pre-transaction/processAmountChanges.mjs +34 -23
- package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs +1 -0
- package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.d.ts +6 -0
- package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs +7 -0
- package/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.helpers.d.ts +9 -1
- package/functions/private-wallet/emporium.helpers.mjs +117 -22
- package/functions/private-wallet/emporium.swap.helpers.cjs +1 -0
- package/functions/private-wallet/emporium.swap.helpers.d.ts +5 -0
- package/functions/private-wallet/emporium.swap.helpers.mjs +92 -0
- package/functions/private-wallet/index.d.ts +1 -0
- package/functions/private-wallet/opProducer.cjs +1 -1
- package/functions/private-wallet/opProducer.mjs +9 -10
- package/functions/private-wallet/smartContractWalletCalculator.cjs +1 -1
- package/functions/private-wallet/smartContractWalletCalculator.d.ts +5 -1
- package/functions/private-wallet/smartContractWalletCalculator.mjs +22 -17
- package/functions/protocols/convex.protocols.cjs +1 -1
- package/functions/protocols/convex.protocols.mjs +11 -8
- package/functions/protocols/pendle.helpers.cjs +1 -1
- package/functions/protocols/pendle.helpers.mjs +20 -15
- package/functions/snarkjs/common.snarkjs.cjs +1 -1
- package/functions/snarkjs/common.snarkjs.d.ts +8 -5
- package/functions/snarkjs/common.snarkjs.mjs +177 -87
- package/functions/snarkjs/constant.cjs +1 -1
- package/functions/snarkjs/constant.d.ts +223 -1
- package/functions/snarkjs/constant.mjs +315 -94
- package/functions/snarkjs/constructEmporiumProof.cjs +1 -1
- package/functions/snarkjs/constructEmporiumProof.d.ts +6 -3
- package/functions/snarkjs/constructEmporiumProof.mjs +148 -84
- package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
- package/functions/snarkjs/constructGeneralZkProof.d.ts +5 -3
- package/functions/snarkjs/constructGeneralZkProof.mjs +142 -86
- package/functions/snarkjs/generateCircomData.cjs +1 -1
- package/functions/snarkjs/generateCircomData.d.ts +3 -2
- package/functions/snarkjs/generateCircomData.mjs +33 -35
- package/functions/snarkjs/generateZkProof.cjs +1 -1
- package/functions/snarkjs/generateZkProof.d.ts +2 -2
- package/functions/snarkjs/generateZkProof.mjs +4 -15
- package/functions/snarkjs/generateZkProofEnclave.cjs +1 -0
- package/functions/snarkjs/generateZkProofEnclave.d.ts +6 -0
- package/functions/snarkjs/generateZkProofEnclave.mjs +26 -0
- package/functions/snarkjs/generateZkProofSelf.cjs +1 -0
- package/functions/snarkjs/generateZkProofSelf.d.ts +5 -0
- package/functions/snarkjs/generateZkProofSelf.mjs +17 -0
- package/functions/snarkjs/getOriginalSender.cjs +1 -0
- package/functions/snarkjs/getOriginalSender.d.ts +1 -0
- package/functions/snarkjs/getOriginalSender.mjs +5 -0
- package/functions/snarkjs/getZKFiles.cjs +1 -1
- package/functions/snarkjs/getZKFiles.d.ts +3 -2
- package/functions/snarkjs/getZKFiles.mjs +14 -5
- package/functions/utils/addresses.cjs +1 -0
- package/functions/utils/addresses.d.ts +4 -0
- package/functions/utils/addresses.mjs +20 -0
- package/functions/utils/amounts.utils.cjs +1 -1
- package/functions/utils/amounts.utils.d.ts +4 -1
- package/functions/utils/amounts.utils.mjs +29 -27
- package/functions/utils/arraysMatch.cjs +1 -0
- package/functions/utils/arraysMatch.d.ts +1 -0
- package/functions/utils/arraysMatch.mjs +4 -0
- package/functions/utils/axelar.utils.cjs +1 -1
- package/functions/utils/axelar.utils.d.ts +1 -0
- package/functions/utils/axelar.utils.mjs +32 -9
- package/functions/utils/cacheDevice.utils.cjs +1 -1
- package/functions/utils/cacheDevice.utils.mjs +11 -8
- package/functions/utils/cacheFunctions.cjs +1 -1
- package/functions/utils/cacheFunctions.d.ts +10 -7
- package/functions/utils/cacheFunctions.mjs +62 -39
- package/functions/utils/convertEmporiumOpToCallInfo.cjs +1 -0
- package/functions/utils/convertEmporiumOpToCallInfo.d.ts +2 -0
- package/functions/utils/convertEmporiumOpToCallInfo.mjs +10 -0
- package/functions/utils/convertIntegrationProviderToExternalActionId.cjs +1 -1
- package/functions/utils/convertIntegrationProviderToExternalActionId.d.ts +2 -1
- package/functions/utils/convertIntegrationProviderToExternalActionId.mjs +7 -10
- package/functions/utils/encodeTokenWithId.cjs +1 -0
- package/functions/utils/encodeTokenWithId.d.ts +2 -0
- package/functions/utils/encodeTokenWithId.mjs +4 -0
- package/functions/utils/encryptInputForEnclave.cjs +1 -0
- package/functions/utils/encryptInputForEnclave.d.ts +8 -0
- package/functions/utils/encryptInputForEnclave.mjs +43 -0
- package/functions/utils/erc20tokenFunctions.cjs +1 -1
- package/functions/utils/erc20tokenFunctions.d.ts +8 -2
- package/functions/utils/erc20tokenFunctions.mjs +23 -14
- package/functions/utils/evmNetworkFunctions.cjs +1 -1
- package/functions/utils/evmNetworkFunctions.mjs +7 -4
- package/functions/utils/external-action.utils.d.ts +2 -2
- package/functions/utils/fees.utils.cjs +1 -0
- package/functions/utils/fees.utils.d.ts +2 -0
- package/functions/utils/fees.utils.mjs +14 -0
- package/functions/utils/getBlockExplorerUrl.cjs +1 -0
- package/functions/utils/getBlockExplorerUrl.d.ts +1 -0
- package/functions/utils/getBlockExplorerUrl.mjs +6 -0
- package/functions/utils/getRecipientInfoFromUserKeys.cjs +1 -0
- package/functions/utils/getRecipientInfoFromUserKeys.d.ts +3 -0
- package/functions/utils/getRecipientInfoFromUserKeys.mjs +18 -0
- package/functions/utils/index.d.ts +12 -0
- package/functions/utils/involves-permit2-op.cjs +1 -0
- package/functions/utils/involves-permit2-op.d.ts +1 -0
- package/functions/utils/involves-permit2-op.mjs +5 -0
- package/functions/utils/merkleTree.utils.cjs +1 -0
- package/functions/utils/merkleTree.utils.d.ts +2 -0
- package/functions/utils/merkleTree.utils.mjs +19 -0
- package/functions/utils/prepareHinkal.d.ts +6 -0
- package/functions/utils/processUseApprovalUtxoData.cjs +1 -0
- package/functions/utils/processUseApprovalUtxoData.d.ts +3 -0
- package/functions/utils/processUseApprovalUtxoData.mjs +19 -0
- package/functions/utils/publicBalance.utils.cjs +1 -0
- package/functions/utils/publicBalance.utils.d.ts +5 -0
- package/functions/utils/publicBalance.utils.mjs +25 -0
- package/functions/utils/replaceAddressInCalldata.cjs +1 -0
- package/functions/utils/replaceAddressInCalldata.d.ts +1 -0
- package/functions/utils/replaceAddressInCalldata.mjs +7 -0
- package/functions/utils/rpc-int-encode.cjs +1 -0
- package/functions/utils/rpc-int-encode.d.ts +2 -0
- package/functions/utils/rpc-int-encode.mjs +8 -0
- package/functions/utils/serialize.utils.cjs +1 -1
- package/functions/utils/serialize.utils.d.ts +1 -0
- package/functions/utils/serialize.utils.mjs +3 -2
- package/functions/utils/string.utils.cjs +1 -1
- package/functions/utils/string.utils.d.ts +2 -0
- package/functions/utils/string.utils.mjs +28 -14
- package/functions/utils/time.utils.cjs +1 -1
- package/functions/utils/time.utils.d.ts +1 -0
- package/functions/utils/time.utils.mjs +4 -3
- package/functions/utils/token-check.utils.cjs +1 -0
- package/functions/utils/token-check.utils.d.ts +1 -0
- package/functions/utils/token-check.utils.mjs +10 -0
- package/functions/utils/upToDateState.cjs +1 -0
- package/functions/utils/upToDateState.d.ts +2 -0
- package/functions/utils/upToDateState.mjs +11 -0
- package/functions/utils/userAgent.cjs +1 -1
- package/functions/utils/userAgent.mjs +8 -8
- package/functions/web3/events/balanceChangedCustomHandler.cjs +1 -0
- package/functions/web3/events/balanceChangedCustomHandler.d.ts +2 -0
- package/functions/web3/events/balanceChangedCustomHandler.mjs +14 -0
- package/functions/web3/events/balanceChangedHandler.cjs +1 -1
- package/functions/web3/events/balanceChangedHandler.mjs +5 -4
- package/functions/web3/events/getApprovedBalance.cjs +1 -0
- package/functions/web3/events/getApprovedBalance.d.ts +7 -0
- package/functions/web3/events/getApprovedBalance.mjs +80 -0
- package/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
- package/functions/web3/events/getInputUtxoAndBalance.d.ts +16 -3
- package/functions/web3/events/getInputUtxoAndBalance.mjs +128 -46
- package/functions/web3/events/getShieldedBalance.cjs +2 -2
- package/functions/web3/events/getShieldedBalance.d.ts +1 -1
- package/functions/web3/events/getShieldedBalance.mjs +70 -65
- package/functions/web3/events/index.d.ts +2 -0
- package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
- package/functions/web3/functionCalls/accessTokenCalls.d.ts +2 -2
- package/functions/web3/functionCalls/accessTokenCalls.mjs +20 -18
- package/functions/web3/functionCalls/approveToken.cjs +1 -1
- package/functions/web3/functionCalls/approveToken.mjs +8 -7
- package/functions/web3/functionCalls/approveTokensToHinkal.cjs +1 -0
- package/functions/web3/functionCalls/approveTokensToHinkal.d.ts +4 -0
- package/functions/web3/functionCalls/approveTokensToHinkal.mjs +11 -0
- package/functions/web3/functionCalls/estimateGasRelayer.cjs +1 -1
- package/functions/web3/functionCalls/estimateGasRelayer.d.ts +2 -2
- package/functions/web3/functionCalls/estimateGasRelayer.mjs +14 -8
- package/functions/web3/functionCalls/inHinkalApprovalCalls.cjs +1 -0
- package/functions/web3/functionCalls/inHinkalApprovalCalls.d.ts +5 -0
- package/functions/web3/functionCalls/inHinkalApprovalCalls.mjs +32 -0
- package/functions/web3/functionCalls/relayFunctions.d.ts +1 -15
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.d.ts +2 -2
- package/functions/web3/functionCalls/transactCallDirect.mjs +31 -30
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.d.ts +2 -2
- package/functions/web3/functionCalls/transactCallRelayer.mjs +32 -9
- package/functions/web3/getContractMetadata.cjs +1 -0
- package/functions/web3/getContractMetadata.d.ts +5 -0
- package/functions/web3/getContractMetadata.mjs +30 -0
- package/functions/web3/odosAPI.cjs +1 -1
- package/functions/web3/odosAPI.d.ts +1 -2
- package/functions/web3/odosAPI.mjs +23 -19
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.d.ts +1 -2
- package/functions/web3/oneInchAPI.mjs +20 -15
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.mjs +3 -2
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.d.ts +4 -4
- package/functions/web3/uniswapAPI.mjs +57 -43
- package/index.cjs +1 -1
- package/index.mjs +761 -639
- package/package.json +19 -8
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.d.ts +8 -3
- package/providers/EthersProviderAdapter.mjs +52 -43
- package/providers/WagmiProviderAdapter.cjs +1 -1
- package/providers/WagmiProviderAdapter.d.ts +4 -1
- package/providers/WagmiProviderAdapter.mjs +53 -56
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +18 -10
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +18 -10
- package/types/API.types.d.ts +21 -0
- package/types/ICacheDevice.d.ts +4 -3
- package/types/TransactionSimulator.types.d.ts +9 -0
- package/types/activities.types.cjs +1 -0
- package/types/activities.types.d.ts +45 -0
- package/types/activities.types.mjs +13 -0
- package/types/balances.types.cjs +1 -0
- package/types/balances.types.d.ts +17 -0
- package/types/balances.types.mjs +4 -0
- package/types/cache.types.cjs +1 -0
- package/types/cache.types.d.ts +27 -0
- package/types/cache.types.mjs +4 -0
- package/types/circom-data.types.d.ts +29 -9
- package/types/commitments.types.d.ts +6 -0
- package/types/contacts.types.d.ts +5 -0
- package/types/crypto.types.d.ts +1 -0
- package/types/earlyAccessCode.types.d.ts +4 -0
- package/types/ethereum-network.types.cjs +1 -1
- package/types/ethereum-network.types.d.ts +8 -3
- package/types/ethereum-network.types.mjs +1 -1
- package/types/external-action.types.cjs +1 -1
- package/types/external-action.types.d.ts +2 -1
- package/types/external-action.types.mjs +1 -1
- package/types/fee.types.d.ts +9 -0
- package/types/hinkal.types.cjs +1 -1
- package/types/hinkal.types.d.ts +48 -0
- package/types/hinkal.types.mjs +38 -13
- package/types/index.d.ts +9 -0
- package/types/kyc.types.cjs +1 -1
- package/types/kyc.types.d.ts +1 -1
- package/types/kyc.types.mjs +1 -1
- package/types/remote-proof.types.d.ts +15 -0
- package/types/rewards.types.d.ts +9 -0
- package/types/sandbox.types.cjs +1 -0
- package/types/sandbox.types.d.ts +157 -0
- package/types/sandbox.types.mjs +4 -0
- package/types/tenderly.api.types.d.ts +180 -0
- package/types/time.types.cjs +1 -1
- package/types/time.types.mjs +1 -1
- package/types/token-with-id.types.d.ts +4 -0
- package/types/token.types.d.ts +23 -0
- package/types/transactions.types.cjs +1 -1
- package/types/transactions.types.d.ts +31 -0
- package/types/transactions.types.mjs +8 -5
- package/types/wc.types.d.ts +89 -0
- package/types/with-id.types.d.ts +3 -0
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLogic.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLogic.mjs +26 -26
- package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLogic.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLogic.mjs +58 -50
- package/webworker/viteWorkerURL.constant.cjs +3 -3
- package/webworker/viteWorkerURL.constant.mjs +3 -3
- package/webworker/workerFactory.cjs +1 -1
- package/webworker/workerFactory.mjs +2 -2
- package/webworker/workerProxy.cjs +1 -1
- package/webworker/workerProxy.d.ts +11 -11
- package/webworker/workerProxy.mjs +24 -26
- package/webworker/zkProofWorker/zkProofWorker.types.d.ts +2 -0
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLogic.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLogic.mjs +47 -61
- package/functions/utils/memoize.utils.cjs +0 -1
- package/functions/utils/memoize.utils.mjs +0 -14
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { get as R, set as f } from "idb-keyval";
|
|
2
|
+
import { BigNumber as T } from "ethers";
|
|
3
|
+
import "../../types/circom-data.types.mjs";
|
|
4
|
+
import "../../constants/vite.constants.mjs";
|
|
5
|
+
import "../../types/transactions.types.mjs";
|
|
6
|
+
import "../../types/curve.types.mjs";
|
|
7
|
+
import { ActivityStatus as h } from "../../types/activities.types.mjs";
|
|
8
|
+
class A {
|
|
9
|
+
STORAGE_KEY = "tx-activity";
|
|
10
|
+
generateTxId() {
|
|
11
|
+
const t = (/* @__PURE__ */ new Date()).getTime(), e = Math.random().toString(36).substring(2, 15);
|
|
12
|
+
return `tx_${t}_${e}`;
|
|
13
|
+
}
|
|
14
|
+
async getTransactionRecord() {
|
|
15
|
+
return await R(this.STORAGE_KEY) || {};
|
|
16
|
+
}
|
|
17
|
+
async saveTransactionRecord(t) {
|
|
18
|
+
await f(this.STORAGE_KEY, t);
|
|
19
|
+
}
|
|
20
|
+
async saveTxRequest(t) {
|
|
21
|
+
const {
|
|
22
|
+
from: e,
|
|
23
|
+
to: a,
|
|
24
|
+
gas: n,
|
|
25
|
+
gasPrice: s,
|
|
26
|
+
value: i,
|
|
27
|
+
chainId: o,
|
|
28
|
+
status: c,
|
|
29
|
+
txHash: r,
|
|
30
|
+
activityType: d,
|
|
31
|
+
tokensReceive: u,
|
|
32
|
+
tokensSpend: p,
|
|
33
|
+
ownerPublicAddress: l,
|
|
34
|
+
activityIcon: w,
|
|
35
|
+
dappUrl: v,
|
|
36
|
+
integrationProvider: y
|
|
37
|
+
} = t, g = this.generateTxId(), m = await this.getTransactionRecord(), x = {
|
|
38
|
+
id: g,
|
|
39
|
+
from: e,
|
|
40
|
+
to: a,
|
|
41
|
+
gas: n,
|
|
42
|
+
gasPrice: s,
|
|
43
|
+
value: i,
|
|
44
|
+
chainId: o,
|
|
45
|
+
txHash: r,
|
|
46
|
+
activityType: d,
|
|
47
|
+
status: c ?? h.PENDING,
|
|
48
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
49
|
+
tokensReceive: u,
|
|
50
|
+
tokensSpend: p,
|
|
51
|
+
ownerPublicAddress: l,
|
|
52
|
+
activityIcon: w,
|
|
53
|
+
dappUrl: v,
|
|
54
|
+
integrationProvider: y
|
|
55
|
+
};
|
|
56
|
+
return m[g] = x, console.log({ record: m }), await this.saveTransactionRecord(m), g;
|
|
57
|
+
}
|
|
58
|
+
async getTxRequest(t) {
|
|
59
|
+
return (await this.getTransactionRecord())[t] || null;
|
|
60
|
+
}
|
|
61
|
+
async getAllTxRequests(t) {
|
|
62
|
+
const e = await this.getTransactionRecord();
|
|
63
|
+
return Object.values(e).filter((a) => a.chainId === t).sort((a, n) => new Date(n.timestamp).getTime() - new Date(a.timestamp).getTime());
|
|
64
|
+
}
|
|
65
|
+
async updateTxStatusAndHash(t, e, a, n, s, i, o, c) {
|
|
66
|
+
const r = await this.getTxRequest(t);
|
|
67
|
+
if (!r)
|
|
68
|
+
throw new Error("Transaction not found");
|
|
69
|
+
const d = await this.getTransactionRecord(), u = {
|
|
70
|
+
...r,
|
|
71
|
+
status: e,
|
|
72
|
+
txHash: a,
|
|
73
|
+
value: r.value ?? n,
|
|
74
|
+
from: r.from ?? s,
|
|
75
|
+
to: r.to ?? i,
|
|
76
|
+
gas: o,
|
|
77
|
+
gasPrice: c,
|
|
78
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
79
|
+
};
|
|
80
|
+
return d[t] = u, await this.saveTransactionRecord(d), u;
|
|
81
|
+
}
|
|
82
|
+
async updateActivity(t, e, a, n, s, i, o, c) {
|
|
83
|
+
try {
|
|
84
|
+
await this.updateTxStatusAndHash(t, e, a, n, s, i, o, c);
|
|
85
|
+
} catch (r) {
|
|
86
|
+
console.log("error in updating tx request", r);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async removePendingTransactions(t) {
|
|
90
|
+
try {
|
|
91
|
+
const e = await this.getTransactionRecord();
|
|
92
|
+
delete e[t], await this.saveTransactionRecord(e);
|
|
93
|
+
} catch (e) {
|
|
94
|
+
console.log("error in deleting tx requests", e);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async updatePendingTransactions(t, e) {
|
|
98
|
+
try {
|
|
99
|
+
if (!t.success) {
|
|
100
|
+
await this.updateActivity(e, h.FAILED);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if ("tx" in t) {
|
|
104
|
+
const { tx: a } = t;
|
|
105
|
+
await this.updateActivity(
|
|
106
|
+
e,
|
|
107
|
+
h.CONFIRMED,
|
|
108
|
+
a.hash,
|
|
109
|
+
T.from(a.value ?? 0n).toHexString(),
|
|
110
|
+
a.from,
|
|
111
|
+
a.to,
|
|
112
|
+
T.from(a.gas ?? 0n),
|
|
113
|
+
T.from(a.gasPrice ?? 0n)
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
} catch (a) {
|
|
117
|
+
console.log("error in updating pending transactions", a);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const b = new A();
|
|
122
|
+
export {
|
|
123
|
+
b as activityStorage
|
|
124
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("idb-keyval");require("ethers");require("../../constants/contracts.constants.cjs");require("circomlibjs-hinkal-fork");require("../../error-handling/error-codes.constants.cjs");require("../crypto-keys/keys.cjs");require("../../functions/utils/external-action.utils.cjs");require("../../constants/token-data/index.cjs");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../../types/circom-data.types.cjs");require("../../constants/vite.constants.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("../../types/activities.types.cjs");require("axios");require("../../constants/chains.constants.cjs");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/reorg-depths.constants.cjs");const g=require("../../error-handling/logger.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../functions/utils/userAgent.cjs");const q=require("../../functions/utils/string.utils.cjs");require("../volatile-helper/VolatileHelper.cjs");class B{balancesRecordLabel="walletsBalances";async getBalances(){return await o.get(this.balancesRecordLabel)}async getBalancesByWallet(e,a){const r=await this.getBalances();if(!r)return;const t=q.getStateKey(e,a);return r[t]}async setBalances(e,a,r,t){let u=[];if(t.length===0)return await this.getBalancesByWallet(a,e)??[];try{await o.update(this.balancesRecordLabel,(i={})=>{const n=q.getStateKey(a,e),l=this.createBalanceLookup(i[n]),s=this.createBalanceLookup(r);return t.forEach(({erc20TokenAddress:c})=>{c in s?l[c]=s[c]:delete l[c]}),u=Object.values(l),{...i,[n]:u}})}catch(i){g.Logger.error("Failed to update wallet balances:",i)}return u}createBalanceLookup(e=[]){return e.reduce((a,r)=>({...a,[r.token.erc20TokenAddress]:r}),{})}}const b=new B;exports.publicBalancesStorage=b;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ERC20Token, TokenBalance } from '../../types';
|
|
2
|
+
interface WalletBalances {
|
|
3
|
+
[key: string]: TokenBalance[];
|
|
4
|
+
}
|
|
5
|
+
declare class PublicBalancesStorage {
|
|
6
|
+
readonly balancesRecordLabel = "walletsBalances";
|
|
7
|
+
getBalances(): Promise<WalletBalances | undefined>;
|
|
8
|
+
getBalancesByWallet(address: string, chainId: number): Promise<TokenBalance[] | undefined>;
|
|
9
|
+
setBalances(chainId: number, ethereumAddress: string, balances: TokenBalance[], tokensToUpdate: ERC20Token[]): Promise<TokenBalance[]>;
|
|
10
|
+
private createBalanceLookup;
|
|
11
|
+
}
|
|
12
|
+
export declare const publicBalancesStorage: PublicBalancesStorage;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { get as m, update as B } from "idb-keyval";
|
|
2
|
+
import "ethers";
|
|
3
|
+
import "../../constants/contracts.constants.mjs";
|
|
4
|
+
import "circomlibjs-hinkal-fork";
|
|
5
|
+
import "../../error-handling/error-codes.constants.mjs";
|
|
6
|
+
import "../crypto-keys/keys.mjs";
|
|
7
|
+
import "../../functions/utils/external-action.utils.mjs";
|
|
8
|
+
import "../../constants/token-data/index.mjs";
|
|
9
|
+
import "../../functions/utils/convertIntegrationProviderToExternalActionId.mjs";
|
|
10
|
+
import "../../types/circom-data.types.mjs";
|
|
11
|
+
import "../../constants/vite.constants.mjs";
|
|
12
|
+
import "../../types/transactions.types.mjs";
|
|
13
|
+
import "../../types/curve.types.mjs";
|
|
14
|
+
import "../../types/activities.types.mjs";
|
|
15
|
+
import "axios";
|
|
16
|
+
import "../../constants/chains.constants.mjs";
|
|
17
|
+
import "libsodium-wrappers";
|
|
18
|
+
import "process";
|
|
19
|
+
import "buffer";
|
|
20
|
+
import "../../constants/reorg-depths.constants.mjs";
|
|
21
|
+
import { Logger as u } from "../../error-handling/logger.mjs";
|
|
22
|
+
import "../../constants/kyc.constants.mjs";
|
|
23
|
+
import "../../constants/coingecko.constants.mjs";
|
|
24
|
+
import "../../constants/axelar.constants.mjs";
|
|
25
|
+
import "../../constants/rewards.constants.mjs";
|
|
26
|
+
import "../../constants/addresses.constants.mjs";
|
|
27
|
+
import "../../constants/token.limits.constants.mjs";
|
|
28
|
+
import "../../functions/utils/userAgent.mjs";
|
|
29
|
+
import { getStateKey as s } from "../../functions/utils/string.utils.mjs";
|
|
30
|
+
import "../volatile-helper/VolatileHelper.mjs";
|
|
31
|
+
class g {
|
|
32
|
+
balancesRecordLabel = "walletsBalances";
|
|
33
|
+
async getBalances() {
|
|
34
|
+
return await m(this.balancesRecordLabel);
|
|
35
|
+
}
|
|
36
|
+
async getBalancesByWallet(t, a) {
|
|
37
|
+
const e = await this.getBalances();
|
|
38
|
+
if (!e)
|
|
39
|
+
return;
|
|
40
|
+
const r = s(t, a);
|
|
41
|
+
return e[r];
|
|
42
|
+
}
|
|
43
|
+
async setBalances(t, a, e, r) {
|
|
44
|
+
let c = [];
|
|
45
|
+
if (r.length === 0)
|
|
46
|
+
return await this.getBalancesByWallet(a, t) ?? [];
|
|
47
|
+
try {
|
|
48
|
+
await B(this.balancesRecordLabel, (o = {}) => {
|
|
49
|
+
const n = s(a, t), l = this.createBalanceLookup(o[n]), p = this.createBalanceLookup(e);
|
|
50
|
+
return r.forEach(({ erc20TokenAddress: i }) => {
|
|
51
|
+
i in p ? l[i] = p[i] : delete l[i];
|
|
52
|
+
}), c = Object.values(l), {
|
|
53
|
+
...o,
|
|
54
|
+
[n]: c
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
} catch (o) {
|
|
58
|
+
u.error("Failed to update wallet balances:", o);
|
|
59
|
+
}
|
|
60
|
+
return c;
|
|
61
|
+
}
|
|
62
|
+
createBalanceLookup(t = []) {
|
|
63
|
+
return t.reduce(
|
|
64
|
+
(a, e) => ({
|
|
65
|
+
...a,
|
|
66
|
+
[e.token.erc20TokenAddress]: e
|
|
67
|
+
}),
|
|
68
|
+
{}
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const X = new g();
|
|
73
|
+
export {
|
|
74
|
+
X as publicBalancesStorage
|
|
75
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("idb-keyval"),d=require("../../error-handling/logger.cjs");class l{STORAGE_KEY="contacts";checkForDuplicate(a,t,e){if(a.find(({ethereumAddress:o,nickname:r})=>(o===t.ethereumAddress||r===t.nickname)&&o!==e)!==void 0)throw new Error("Duplicate Contact attribute")}async createContact(a,t){const e=a.toLowerCase(),c=await s.get(this.STORAGE_KEY)??{},o=c[e]??[];this.checkForDuplicate(o,t),o.push(t),c[e]=o,await s.set(this.STORAGE_KEY,c)}async getContacts(a){try{const t=a.toLowerCase(),e=await s.get(this.STORAGE_KEY);return!e||!e[t]?[]:e[t]}catch(t){return d.Logger.error("Error while getting contacts:",t),[]}}async editContact(a,t,e){const c=a.toLowerCase(),o=await s.get(this.STORAGE_KEY),r=o?.[c];if(!o||!r)throw new Error("Contacts could not be fetched");this.checkForDuplicate(r,e,t);const n=r.findIndex(({ethereumAddress:i})=>i===t);if(n===-1)throw new Error("Contact to be edited was not found");r[n]=e,o[c]=r,await s.set(this.STORAGE_KEY,o)}async deleteContact(a,t){const e=a.toLowerCase(),c=await s.get(this.STORAGE_KEY),o=c?.[e];if(!c||!o)throw new Error("Contacts could not be fetched");const r=o.filter(({ethereumAddress:n})=>n!==t);c[e]=r,await s.set(this.STORAGE_KEY,c)}}const w=new l;exports.contactStorage=w;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Contact } from '../../types/contacts.types';
|
|
2
|
+
declare class ContactStorage {
|
|
3
|
+
private readonly STORAGE_KEY;
|
|
4
|
+
private checkForDuplicate;
|
|
5
|
+
createContact(walletAddress: string, newContact: Contact): Promise<void>;
|
|
6
|
+
getContacts(walletAddress: string): Promise<Contact[]>;
|
|
7
|
+
editContact(walletAddress: string, oldContactAddress: string, editedContact: Contact): Promise<void>;
|
|
8
|
+
deleteContact(walletAddress: string, contactAddressToDelete: string): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export declare const contactStorage: ContactStorage;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { get as n, set as i } from "idb-keyval";
|
|
2
|
+
import { Logger as w } from "../../error-handling/logger.mjs";
|
|
3
|
+
class h {
|
|
4
|
+
STORAGE_KEY = "contacts";
|
|
5
|
+
checkForDuplicate(c, t, o) {
|
|
6
|
+
if (c.find(
|
|
7
|
+
({ ethereumAddress: e, nickname: r }) => (e === t.ethereumAddress || r === t.nickname) && e !== o
|
|
8
|
+
) !== void 0)
|
|
9
|
+
throw new Error("Duplicate Contact attribute");
|
|
10
|
+
}
|
|
11
|
+
async createContact(c, t) {
|
|
12
|
+
const o = c.toLowerCase(), a = await n(this.STORAGE_KEY) ?? {}, e = a[o] ?? [];
|
|
13
|
+
this.checkForDuplicate(e, t), e.push(t), a[o] = e, await i(this.STORAGE_KEY, a);
|
|
14
|
+
}
|
|
15
|
+
async getContacts(c) {
|
|
16
|
+
try {
|
|
17
|
+
const t = c.toLowerCase(), o = await n(this.STORAGE_KEY);
|
|
18
|
+
return !o || !o[t] ? [] : o[t];
|
|
19
|
+
} catch (t) {
|
|
20
|
+
return w.error("Error while getting contacts:", t), [];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
async editContact(c, t, o) {
|
|
24
|
+
const a = c.toLowerCase(), e = await n(this.STORAGE_KEY), r = e?.[a];
|
|
25
|
+
if (!e || !r)
|
|
26
|
+
throw new Error("Contacts could not be fetched");
|
|
27
|
+
this.checkForDuplicate(r, o, t);
|
|
28
|
+
const s = r.findIndex(({ ethereumAddress: d }) => d === t);
|
|
29
|
+
if (s === -1)
|
|
30
|
+
throw new Error("Contact to be edited was not found");
|
|
31
|
+
r[s] = o, e[a] = r, await i(this.STORAGE_KEY, e);
|
|
32
|
+
}
|
|
33
|
+
async deleteContact(c, t) {
|
|
34
|
+
const o = c.toLowerCase(), a = await n(this.STORAGE_KEY), e = a?.[o];
|
|
35
|
+
if (!a || !e)
|
|
36
|
+
throw new Error("Contacts could not be fetched");
|
|
37
|
+
const r = e.filter(({ ethereumAddress: s }) => s !== t);
|
|
38
|
+
a[o] = r, await i(this.STORAGE_KEY, a);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const C = new h();
|
|
42
|
+
export {
|
|
43
|
+
C as contactStorage
|
|
44
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("idb-keyval"),p=require("../../API/API.cjs"),l=require("../../functions/utils/string.utils.cjs");class g{tokenPricesRecordLabel="tokenPrices";async getPrices(){return await P.get(this.tokenPricesRecordLabel)}async updatePrices(e,t){if(!t.length)return[];const{prices:r}=await p.API.getTokenPrices(e,t);return await P.update(this.tokenPricesRecordLabel,(i={})=>{const c={...i};return r.forEach((s,o)=>{c[l.getStateKey(t[o],e)]=s}),c}),r}async getAndUpdatePrices(e,t){const r=await this.getPrices();let i=new Array(t.length).fill(0);if(!r)i=await this.updatePrices(e,t);else{const c=[],s=[];t.forEach((a,n)=>{const u=l.getStateKey(a,e);r[u]?i[n]=r[u]:(c.push(a),s.push(n))});const o=await this.updatePrices(e,c);s.forEach((a,n)=>{i[a]=o[n]})}return i}async updateCachedPricesByChain(e){const t=await this.getPrices();if(!t||Object.keys(t).length===0)return;const r=Object.entries(t).filter(([c])=>{const[,s]=c.split("-");return parseInt(s,10)===e}).map(([c])=>c.split("-")[0]);if(r.length===0)return;const{prices:i}=await p.API.getTokenPrices(e,r);await P.update(this.tokenPricesRecordLabel,(c={})=>{const s={...c};return i.forEach((o,a)=>{const n=l.getStateKey(r[a],e);s[n]=o}),s})}}const h=new g;exports.pricesStorage=h;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare class PricesStorage {
|
|
2
|
+
readonly tokenPricesRecordLabel = "tokenPrices";
|
|
3
|
+
getPrices(): Promise<Record<string, number> | undefined>;
|
|
4
|
+
updatePrices(chainId: number, erc20Addresses: string[]): Promise<number[]>;
|
|
5
|
+
getAndUpdatePrices(currentChainId: number, erc20Addresses: string[]): Promise<number[]>;
|
|
6
|
+
updateCachedPricesByChain(chainId: number): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare const pricesStorage: PricesStorage;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { get as u, update as l } from "idb-keyval";
|
|
2
|
+
import { API as h } from "../../API/API.mjs";
|
|
3
|
+
import { getStateKey as P } from "../../functions/utils/string.utils.mjs";
|
|
4
|
+
class f {
|
|
5
|
+
tokenPricesRecordLabel = "tokenPrices";
|
|
6
|
+
async getPrices() {
|
|
7
|
+
return await u(this.tokenPricesRecordLabel);
|
|
8
|
+
}
|
|
9
|
+
async updatePrices(e, t) {
|
|
10
|
+
if (!t.length)
|
|
11
|
+
return [];
|
|
12
|
+
const { prices: r } = await h.getTokenPrices(e, t);
|
|
13
|
+
return await l(this.tokenPricesRecordLabel, (i = {}) => {
|
|
14
|
+
const c = { ...i };
|
|
15
|
+
return r.forEach((s, o) => {
|
|
16
|
+
c[P(t[o], e)] = s;
|
|
17
|
+
}), c;
|
|
18
|
+
}), r;
|
|
19
|
+
}
|
|
20
|
+
// Fetches token prices and updates missing prices as needed.
|
|
21
|
+
async getAndUpdatePrices(e, t) {
|
|
22
|
+
const r = await this.getPrices();
|
|
23
|
+
let i = new Array(t.length).fill(0);
|
|
24
|
+
if (!r)
|
|
25
|
+
i = await this.updatePrices(e, t);
|
|
26
|
+
else {
|
|
27
|
+
const c = [], s = [];
|
|
28
|
+
t.forEach((a, n) => {
|
|
29
|
+
const p = P(a, e);
|
|
30
|
+
r[p] ? i[n] = r[p] : (c.push(a), s.push(n));
|
|
31
|
+
});
|
|
32
|
+
const o = await this.updatePrices(e, c);
|
|
33
|
+
s.forEach((a, n) => {
|
|
34
|
+
i[a] = o[n];
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return i;
|
|
38
|
+
}
|
|
39
|
+
async updateCachedPricesByChain(e) {
|
|
40
|
+
const t = await this.getPrices();
|
|
41
|
+
if (!t || Object.keys(t).length === 0)
|
|
42
|
+
return;
|
|
43
|
+
const r = Object.entries(t).filter(([c]) => {
|
|
44
|
+
const [, s] = c.split("-");
|
|
45
|
+
return parseInt(s, 10) === e;
|
|
46
|
+
}).map(([c]) => c.split("-")[0]);
|
|
47
|
+
if (r.length === 0)
|
|
48
|
+
return;
|
|
49
|
+
const { prices: i } = await h.getTokenPrices(e, r);
|
|
50
|
+
await l(this.tokenPricesRecordLabel, (c = {}) => {
|
|
51
|
+
const s = { ...c };
|
|
52
|
+
return i.forEach((o, a) => {
|
|
53
|
+
const n = P(r[a], e);
|
|
54
|
+
s[n] = o;
|
|
55
|
+
}), s;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const m = new f();
|
|
60
|
+
export {
|
|
61
|
+
m as pricesStorage
|
|
62
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("idb-keyval"),n=require("../../functions/utils/string.utils.cjs");class r{balancesRecordLabel="privateWalletsBalances";async getBalances(){return await l.get(this.balancesRecordLabel)}async getBalancesByWallet(e,t){const a=await this.getBalances();if(!a)return;const s=n.getStateKey(e,t,!0);return a[s]}async setBalances(e,t,a){await l.update(this.balancesRecordLabel,(s={})=>{const c=n.getStateKey(e,t,!0);return{...s,[c]:a}})}}const i=new r;exports.privateBalancesStorage=i;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TokenBalance } from '../../types/token.types';
|
|
2
|
+
declare class PrivateBalancesStorage {
|
|
3
|
+
readonly balancesRecordLabel = "privateWalletsBalances";
|
|
4
|
+
getBalances(): Promise<Record<string, TokenBalance[]> | undefined>;
|
|
5
|
+
getBalancesByWallet(address: string, chainId: number): Promise<TokenBalance[] | undefined>;
|
|
6
|
+
setBalances(address: string, chainId: number, newBalances: TokenBalance[]): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare const privateBalancesStorage: PrivateBalancesStorage;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { get as c, update as r } from "idb-keyval";
|
|
2
|
+
import { getStateKey as l } from "../../functions/utils/string.utils.mjs";
|
|
3
|
+
class o {
|
|
4
|
+
balancesRecordLabel = "privateWalletsBalances";
|
|
5
|
+
async getBalances() {
|
|
6
|
+
return await c(this.balancesRecordLabel);
|
|
7
|
+
}
|
|
8
|
+
async getBalancesByWallet(a, t) {
|
|
9
|
+
const e = await this.getBalances();
|
|
10
|
+
if (!e)
|
|
11
|
+
return;
|
|
12
|
+
const s = l(a, t, !0);
|
|
13
|
+
return e[s];
|
|
14
|
+
}
|
|
15
|
+
async setBalances(a, t, e) {
|
|
16
|
+
await r(this.balancesRecordLabel, (s = {}) => {
|
|
17
|
+
const n = l(a, t, !0);
|
|
18
|
+
return {
|
|
19
|
+
...s,
|
|
20
|
+
[n]: e
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const u = new o();
|
|
26
|
+
export {
|
|
27
|
+
u as privateBalancesStorage
|
|
28
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../crypto-keys/keys.cjs"),d=require("../utxo/Utxo.cjs"),l=require("../../webworker/utxoWorker/utxoWorker.types.cjs"),U=require("../../webworker/performTaskWithWorker.cjs"),S=require("../../webworker/worker.registry.cjs"),m=require("../../constants/vite.constants.cjs");class _{NUM_WORKERS;NUM_WORKERS_BATCH_PROCESS;constructor(){m.isNode?(this.NUM_WORKERS=1,this.NUM_WORKERS_BATCH_PROCESS=1):(this.NUM_WORKERS=3,this.NUM_WORKERS_BATCH_PROCESS=Math.ceil(navigator.deviceMemory??4))}async createUtxoPromise(s){return await U.performTaskWithWorker({type:S.WorkerVariant.UTXO,payload:s})}async batchFilterUtxosWithNullifier(s,t){const a=this.sliceArrayIntoParts(s,this.NUM_WORKERS).map(e=>this.createUtxoPromise({type:l.UtxoWorkerActionType.BATCH_FILTER_UTXOS_WITH_NULLIFIER,data:{utxos:e.map(n=>n.getConstructableParams()),nullifiers:t}})),i=await Promise.all(a);return i.forEach(e=>{h.stealthPairCacheDevice.mergeWithSerialized(e.stealthPairCache),h.stealthAddressCacheDevice.mergeWithSerialized(e.stealthAddressCache)}),i.flatMap(e=>e.utxoConstructors).map(e=>new d.Utxo(e))}async buildBatchProcess(s,t){const a=this.sliceArrayIntoParts(s,this.NUM_WORKERS).map(c=>this.createUtxoPromise({type:l.UtxoWorkerActionType.BUILD_UTXOS,data:{signature:t.getSignature(),encryptedOutputs:c}}));return(await Promise.all(a)).flat().map(c=>new d.Utxo(c))}sliceArrayIntoParts(s,t){const r=Math.ceil(s.length/t);return Array.from({length:t},(i,e)=>s.slice(r*e,r*(e+1)))}findLastOutput(s,t){let r=t;return s.forEach(a=>{a!==t&&(r=a)}),r}async batchProcess(s,t,r){const a=this.sliceArrayIntoParts(s,this.NUM_WORKERS_BATCH_PROCESS),i=r.getSignature(),e=a.map(o=>{const u={type:l.UtxoWorkerActionType.DECIPHER_OUTPUTS,data:{encryptedOutputs:o,lastOutput:t,signature:i}};return this.createUtxoPromise(u)}),n=await Promise.all(e),c=n.map(({additionalEncryptedOutputs:o})=>o).flat(),p=new Set,R=c.reduce((o,u)=>p.has(u.value)?o:(p.add(u.value),[...o,u]),[]),y=this.findLastOutput(n.map(o=>o.lastOutput),t);return{additionalEncryptedOutputs:R,lastOutput:y??t}}}exports.MultiThreadedUtxoUtils=_;
|
|
@@ -1,77 +1,80 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
1
|
+
import { stealthPairCacheDevice as d, stealthAddressCacheDevice as S } from "../crypto-keys/keys.mjs";
|
|
2
|
+
import { Utxo as h } from "../utxo/Utxo.mjs";
|
|
3
|
+
import { UtxoWorkerActionType as l } from "../../webworker/utxoWorker/utxoWorker.types.mjs";
|
|
4
|
+
import { performTaskWithWorker as O } from "../../webworker/performTaskWithWorker.mjs";
|
|
5
|
+
import { WorkerVariant as U } from "../../webworker/worker.registry.mjs";
|
|
6
|
+
import { isNode as y } from "../../constants/vite.constants.mjs";
|
|
7
|
+
class T {
|
|
7
8
|
NUM_WORKERS;
|
|
8
9
|
NUM_WORKERS_BATCH_PROCESS;
|
|
9
10
|
constructor() {
|
|
10
|
-
|
|
11
|
+
y ? (this.NUM_WORKERS = 1, this.NUM_WORKERS_BATCH_PROCESS = 1) : (this.NUM_WORKERS = 3, this.NUM_WORKERS_BATCH_PROCESS = Math.ceil(navigator.deviceMemory ?? 4));
|
|
11
12
|
}
|
|
12
|
-
async createUtxoPromise(
|
|
13
|
-
return await
|
|
14
|
-
type:
|
|
15
|
-
payload:
|
|
13
|
+
async createUtxoPromise(e) {
|
|
14
|
+
return await O({
|
|
15
|
+
type: U.UTXO,
|
|
16
|
+
payload: e
|
|
16
17
|
});
|
|
17
18
|
}
|
|
18
|
-
async batchFilterUtxosWithNullifier(
|
|
19
|
-
const
|
|
20
|
-
(
|
|
21
|
-
type:
|
|
19
|
+
async batchFilterUtxosWithNullifier(e, t) {
|
|
20
|
+
const a = this.sliceArrayIntoParts(e, this.NUM_WORKERS).map(
|
|
21
|
+
(s) => this.createUtxoPromise({
|
|
22
|
+
type: l.BATCH_FILTER_UTXOS_WITH_NULLIFIER,
|
|
22
23
|
data: {
|
|
23
|
-
utxos:
|
|
24
|
+
utxos: s.map((n) => n.getConstructableParams()),
|
|
24
25
|
nullifiers: t
|
|
25
26
|
}
|
|
26
27
|
})
|
|
27
|
-
);
|
|
28
|
-
return
|
|
28
|
+
), i = await Promise.all(a);
|
|
29
|
+
return i.forEach((s) => {
|
|
30
|
+
d.mergeWithSerialized(s.stealthPairCache), S.mergeWithSerialized(s.stealthAddressCache);
|
|
31
|
+
}), i.flatMap((s) => s.utxoConstructors).map((s) => new h(s));
|
|
29
32
|
}
|
|
30
|
-
async buildBatchProcess(
|
|
31
|
-
const
|
|
32
|
-
(
|
|
33
|
-
type:
|
|
34
|
-
data: { signature: t.getSignature(), encryptedOutputs:
|
|
33
|
+
async buildBatchProcess(e, t) {
|
|
34
|
+
const a = this.sliceArrayIntoParts(e, this.NUM_WORKERS).map(
|
|
35
|
+
(c) => this.createUtxoPromise({
|
|
36
|
+
type: l.BUILD_UTXOS,
|
|
37
|
+
data: { signature: t.getSignature(), encryptedOutputs: c }
|
|
35
38
|
})
|
|
36
39
|
);
|
|
37
|
-
return (await Promise.all(
|
|
40
|
+
return (await Promise.all(a)).flat().map((c) => new h(c));
|
|
38
41
|
}
|
|
39
|
-
sliceArrayIntoParts(
|
|
40
|
-
const
|
|
42
|
+
sliceArrayIntoParts(e, t) {
|
|
43
|
+
const r = Math.ceil(e.length / t);
|
|
41
44
|
return Array.from(
|
|
42
45
|
{ length: t },
|
|
43
|
-
(
|
|
46
|
+
(i, s) => e.slice(r * s, r * (s + 1))
|
|
44
47
|
);
|
|
45
48
|
}
|
|
46
|
-
findLastOutput(
|
|
47
|
-
let
|
|
48
|
-
return
|
|
49
|
-
|
|
50
|
-
}),
|
|
49
|
+
findLastOutput(e, t) {
|
|
50
|
+
let r = t;
|
|
51
|
+
return e.forEach((a) => {
|
|
52
|
+
a !== t && (r = a);
|
|
53
|
+
}), r;
|
|
51
54
|
}
|
|
52
|
-
async batchProcess(
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
type:
|
|
55
|
+
async batchProcess(e, t, r) {
|
|
56
|
+
const a = this.sliceArrayIntoParts(e, this.NUM_WORKERS_BATCH_PROCESS), i = r.getSignature(), s = a.map((o) => {
|
|
57
|
+
const u = {
|
|
58
|
+
type: l.DECIPHER_OUTPUTS,
|
|
56
59
|
data: {
|
|
57
|
-
encryptedOutputs:
|
|
60
|
+
encryptedOutputs: o,
|
|
58
61
|
lastOutput: t,
|
|
59
62
|
// doesn't matter what we pass here, it will not be used regardless
|
|
60
|
-
signature:
|
|
63
|
+
signature: i
|
|
61
64
|
}
|
|
62
65
|
};
|
|
63
|
-
return this.createUtxoPromise(
|
|
64
|
-
}),
|
|
65
|
-
|
|
66
|
+
return this.createUtxoPromise(u);
|
|
67
|
+
}), n = await Promise.all(s), c = n.map(({ additionalEncryptedOutputs: o }) => o).flat(), p = /* @__PURE__ */ new Set(), m = c.reduce((o, u) => p.has(u.value) ? o : (p.add(u.value), [...o, u]), []), R = this.findLastOutput(
|
|
68
|
+
n.map((o) => o.lastOutput),
|
|
66
69
|
t
|
|
67
70
|
);
|
|
68
71
|
return {
|
|
69
|
-
additionalEncryptedOutputs:
|
|
70
|
-
lastOutput:
|
|
72
|
+
additionalEncryptedOutputs: m,
|
|
73
|
+
lastOutput: R ?? t
|
|
71
74
|
// keep the last output the same if no new output is present
|
|
72
75
|
};
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
78
|
export {
|
|
76
|
-
|
|
79
|
+
T as MultiThreadedUtxoUtils
|
|
77
80
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("idb-keyval"),P=require("../../API/API.cjs"),g=require("../../error-handling/logger.cjs"),h=require("../../functions/utils/caseInsensitive.utils.cjs"),k=require("../../types/cache.types.cjs"),T=require("../../functions/utils/string.utils.cjs");class l{fetchedTokens={};initalFetched=!1;async updateFetchedTokens(){const e=await i.get(k.StorageKeys.PRIVATE_TOKENS);this.fetchedTokens=e??{},this.initalFetched=!0}async getPrivateTokens(e,t){const s=T.getStateKey(t,e);return(await i.get(k.StorageKeys.PRIVATE_TOKENS))?.[s]||[]}async fetchPrivateTokens(e,t,s){try{const r=[...new Set(t.map(n=>n.toLowerCase()))].filter(n=>n&&!h.lowerCaseIncludes(s,n));return g.Logger.log("tokenAddresses",r),r.length?(await P.API.tokensInfoCall(e,r)).filter(n=>!!n):[]}catch(r){return g.Logger.error("Error fetching private tokens:",r),[]}}async fetchAndUpdatePrivateTokens(e,t,s,r){const n=(await this.getPrivateTokens(t,s)).map(o=>o.erc20TokenAddress),y=r??await this.fetchPrivateTokens(t,e,n),d=T.getStateKey(s,t);await i.update(k.StorageKeys.PRIVATE_TOKENS,(o={})=>{const a=o?.[d]||[],p=a.map(c=>c.erc20TokenAddress),f=y.filter(c=>!h.lowerCaseIncludes(p,c.erc20TokenAddress));a.push(...f);const u={...o,[d]:a};return this.fetchedTokens=u,u})}getFetchedTokens(e,t){const s=T.getStateKey(t,e);return this.fetchedTokens[s]||[]}}const w=new l;exports.PrivateTokensDB=l;exports.privateTokensDB=w;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ERC20Token } from '../../types/token.types';
|
|
2
|
+
export declare class PrivateTokensDB {
|
|
3
|
+
private fetchedTokens;
|
|
4
|
+
initalFetched: boolean;
|
|
5
|
+
updateFetchedTokens(): Promise<void>;
|
|
6
|
+
getPrivateTokens(chainId: number, walletAddress: string): Promise<ERC20Token[]>;
|
|
7
|
+
private fetchPrivateTokens;
|
|
8
|
+
fetchAndUpdatePrivateTokens(erc20Addresses: string[], chainId: number, walletAddress: string, preFetchedTokens?: ERC20Token[]): Promise<void>;
|
|
9
|
+
getFetchedTokens(chainId: number, walletAddress: string): ERC20Token[];
|
|
10
|
+
}
|
|
11
|
+
export declare const privateTokensDB: PrivateTokensDB;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { get as p, update as l } from "idb-keyval";
|
|
2
|
+
import { API as w } from "../../API/API.mjs";
|
|
3
|
+
import { Logger as f } from "../../error-handling/logger.mjs";
|
|
4
|
+
import { lowerCaseIncludes as h } from "../../functions/utils/caseInsensitive.utils.mjs";
|
|
5
|
+
import { StorageKeys as i } from "../../types/cache.types.mjs";
|
|
6
|
+
import { getStateKey as k } from "../../functions/utils/string.utils.mjs";
|
|
7
|
+
class A {
|
|
8
|
+
fetchedTokens = {};
|
|
9
|
+
initalFetched = !1;
|
|
10
|
+
async updateFetchedTokens() {
|
|
11
|
+
const e = await p(i.PRIVATE_TOKENS);
|
|
12
|
+
this.fetchedTokens = e ?? {}, this.initalFetched = !0;
|
|
13
|
+
}
|
|
14
|
+
async getPrivateTokens(e, t) {
|
|
15
|
+
const s = k(t, e);
|
|
16
|
+
return (await p(i.PRIVATE_TOKENS))?.[s] || [];
|
|
17
|
+
}
|
|
18
|
+
async fetchPrivateTokens(e, t, s) {
|
|
19
|
+
try {
|
|
20
|
+
const r = [...new Set(t.map((o) => o.toLowerCase()))].filter(
|
|
21
|
+
(o) => o && !h(s, o)
|
|
22
|
+
);
|
|
23
|
+
return f.log("tokenAddresses", r), r.length ? (await w.tokensInfoCall(e, r)).filter(
|
|
24
|
+
(o) => !!o
|
|
25
|
+
) : [];
|
|
26
|
+
} catch (r) {
|
|
27
|
+
return f.error("Error fetching private tokens:", r), [];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async fetchAndUpdatePrivateTokens(e, t, s, r) {
|
|
31
|
+
const o = (await this.getPrivateTokens(t, s)).map((n) => n.erc20TokenAddress), v = r ?? await this.fetchPrivateTokens(t, e, o), T = k(s, t);
|
|
32
|
+
await l(i.PRIVATE_TOKENS, (n = {}) => {
|
|
33
|
+
const a = n?.[T] || [], u = a.map((c) => c.erc20TokenAddress), g = v.filter(
|
|
34
|
+
(c) => !h(u, c.erc20TokenAddress)
|
|
35
|
+
);
|
|
36
|
+
a.push(...g);
|
|
37
|
+
const d = {
|
|
38
|
+
...n,
|
|
39
|
+
[T]: a
|
|
40
|
+
};
|
|
41
|
+
return this.fetchedTokens = d, d;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
getFetchedTokens(e, t) {
|
|
45
|
+
const s = k(t, e);
|
|
46
|
+
return this.fetchedTokens[s] || [];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const C = new A();
|
|
50
|
+
export {
|
|
51
|
+
A as PrivateTokensDB,
|
|
52
|
+
C as privateTokensDB
|
|
53
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("ethers"),d=require("idb-keyval"),b=require("../../API/API.cjs"),y=require("../../constants/chains.constants.cjs"),L=require("../../error-handling/logger.cjs"),P=require("../../functions/utils/caseInsensitive.utils.cjs"),g=require("../../types/cache.types.cjs"),k=require("../../functions/utils/string.utils.cjs"),K=require("../../constants/protocol.constants.cjs");class B{fetchedTokens={};transferEventTopic=f.ethers.utils.id("Transfer(address,address,uint256)");INITIAL_BLOCKS={[y.chainIds.optimism]:124883692};async getPublicTokens(e,t){const o=k.getStateKey(t,e);return(await d.get(g.StorageKeys.PUBLIC_TOKENS))?.[o]||[]}async getLastProcessedBlock(e,t){const o=await d.get(g.StorageKeys.PUBLIC_TOKENS_LAST_PROCESSED_BLOCKS)||{},s=k.getStateKey(t,e);return o[s]||this.INITIAL_BLOCKS[e]}async updateLastProcessedBlock(e,t,o){await d.update(g.StorageKeys.PUBLIC_TOKENS_LAST_PROCESSED_BLOCKS,(s={})=>{const r=k.getStateKey(t,e);return{...s,[r]:o}})}async fetchPublicTokens(e,t,o){try{const{fetchRpcUrl:s}=y.networkRegistry[t];if(!s)throw Error("No fetchRpcUrl in PublicTokensDB");const r=new f.ethers.providers.JsonRpcProvider(s),i=await this.getLastProcessedBlock(t,e),a=await r.getBlockNumber(),n=f.ethers.utils.hexZeroPad(e.toLowerCase(),32),l={topics:[this.transferEventTopic,null,n],fromBlock:i},p={topics:[this.transferEventTopic,n,null],fromBlock:i},[S,T]=await Promise.all([r.getLogs(l),r.getLogs(p)]),u=[...S,...T],h=[K.zeroAddress,...new Set(u.map(c=>c.address))].filter(c=>c&&!P.lowerCaseIncludes(o,c));return h.length?{erc20Tokens:(await b.API.tokensInfoCall(t,h)).filter(c=>!!c),latestBlock:a}:{erc20Tokens:[],latestBlock:a}}catch(s){return L.Logger.error("Error fetching public tokens:",s),{erc20Tokens:[],latestBlock:void 0}}}async fetchAndUpdatePublicTokens(e,t){const s=(await this.getPublicTokens(t,e)).map(n=>n.erc20TokenAddress),{erc20Tokens:r,latestBlock:i}=await this.fetchPublicTokens(e,t,s),a=k.getStateKey(e,t);await d.update(g.StorageKeys.PUBLIC_TOKENS,(n={})=>{const l=n[a]||[],p=l.map(u=>u.erc20TokenAddress),S=r.filter(u=>!P.lowerCaseIncludes(p,u.erc20TokenAddress));l.push(...S);const T={...n,[a]:l};return this.fetchedTokens=T,T}),i&&await this.updateLastProcessedBlock(t,e,i)}getFetchedTokens(e,t){const o=k.getStateKey(t,e);return this.fetchedTokens[o]||[]}}const w=new B;exports.PublicTokensDB=B;exports.publicTokensDB=w;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ERC20Token } from '../../types/token.types';
|
|
2
|
+
export declare class PublicTokensDB {
|
|
3
|
+
private fetchedTokens;
|
|
4
|
+
private readonly transferEventTopic;
|
|
5
|
+
private readonly INITIAL_BLOCKS;
|
|
6
|
+
getPublicTokens(chainId: number, walletAddress: string): Promise<ERC20Token[]>;
|
|
7
|
+
private getLastProcessedBlock;
|
|
8
|
+
private updateLastProcessedBlock;
|
|
9
|
+
private fetchPublicTokens;
|
|
10
|
+
fetchAndUpdatePublicTokens(walletAddress: string, chainId: number): Promise<void>;
|
|
11
|
+
getFetchedTokens(chainId: number, walletAddress: string): ERC20Token[];
|
|
12
|
+
}
|
|
13
|
+
export declare const publicTokensDB: PublicTokensDB;
|