@hinkal/common 0.2.13 → 0.2.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/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/getRelayerURL.cjs +1 -1
- package/API/getRelayerURL.mjs +4 -4
- package/API/getServerURL.cjs +1 -1
- package/API/getServerURL.d.ts +1 -1
- package/API/getServerURL.mjs +14 -12
- 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 +14 -0
- package/API/tenderly.api.mjs +55 -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 +11 -11
- 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 +2 -2
- package/constants/chains.constants.mjs +32 -35
- 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 +10115 -3422
- package/constants/deploy-data/deploy-data-avalanche.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-avalanche.json.mjs +10112 -3415
- package/constants/deploy-data/deploy-data-base.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-base.json.mjs +9408 -3725
- package/constants/deploy-data/deploy-data-bnbMainnet.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-bnbMainnet.json.mjs +9893 -3194
- package/constants/deploy-data/deploy-data-ethMainnet.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-ethMainnet.json.mjs +6318 -3587
- 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 +10113 -3422
- package/constants/deploy-data/deploy-data-polygon.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-polygon.json.mjs +10092 -3423
- 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 +8 -0
- package/constants/protocol.constants.mjs +29 -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 +34 -6
- package/constants/server.constants.mjs +48 -20
- 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 +350 -110
- package/constants/token-data/arbMainnetRegistryFixed.json.cjs +1 -1
- package/constants/token-data/arbMainnetRegistryFixed.json.mjs +334 -100
- package/constants/token-data/avalancheRegistry.json.cjs +1 -1
- package/constants/token-data/avalancheRegistry.json.mjs +236 -68
- package/constants/token-data/avalancheRegistryFixed.json.cjs +1 -1
- package/constants/token-data/avalancheRegistryFixed.json.mjs +236 -68
- package/constants/token-data/baseRegistry.json.cjs +1 -1
- package/constants/token-data/baseRegistry.json.mjs +224 -59
- package/constants/token-data/baseRegistryFixed.json.cjs +1 -1
- package/constants/token-data/baseRegistryFixed.json.mjs +212 -56
- 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 +1017 -344
- package/constants/token-data/ethMainnetRegistryFixed.json.cjs +1 -1
- package/constants/token-data/ethMainnetRegistryFixed.json.mjs +946 -303
- package/constants/token-data/index.cjs +1 -0
- package/constants/token-data/index.d.ts +1496 -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 +530 -155
- package/constants/token-data/polygonRegistryFixed.json.cjs +1 -1
- package/constants/token-data/polygonRegistryFixed.json.mjs +504 -147
- 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 +7 -1
- package/constants/vite.constants.mjs +27 -22
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +48 -20
- package/data-structures/Hinkal/Hinkal.mjs +264 -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 +86 -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 +7 -2
- package/data-structures/merkle-tree/MerkleTree.mjs +85 -70
- 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 +20 -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/getTokenHolder.cjs +1 -0
- package/functions/web3/getTokenHolder.d.ts +1 -0
- package/functions/web3/getTokenHolder.mjs +12 -0
- package/functions/web3/index.d.ts +1 -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 +739 -609
- 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,86 @@
|
|
|
1
|
+
import { ethers as h } from "ethers";
|
|
2
|
+
import { get as B, update as L } from "idb-keyval";
|
|
3
|
+
import { API as g } from "../../API/API.mjs";
|
|
4
|
+
import { chainIds as c, networkRegistry as S } from "../../constants/chains.constants.mjs";
|
|
5
|
+
import { Logger as w } from "../../error-handling/logger.mjs";
|
|
6
|
+
import { lowerCaseIncludes as b } from "../../functions/utils/caseInsensitive.utils.mjs";
|
|
7
|
+
import { StorageKeys as f } from "../../types/cache.types.mjs";
|
|
8
|
+
import { getStateKey as p } from "../../functions/utils/string.utils.mjs";
|
|
9
|
+
import { zeroAddress as E } from "../../constants/protocol.constants.mjs";
|
|
10
|
+
class y {
|
|
11
|
+
fetchedTokens = {};
|
|
12
|
+
transferEventTopic = h.utils.id("Transfer(address,address,uint256)");
|
|
13
|
+
INITIAL_BLOCKS = {
|
|
14
|
+
[c.arbMainnet]: 339713830,
|
|
15
|
+
[c.avalanche]: 62576092,
|
|
16
|
+
[c.base]: 30613576,
|
|
17
|
+
[c.bnbMainnet]: 50188154,
|
|
18
|
+
[c.ethMainnet]: 22548343,
|
|
19
|
+
[c.optimism]: 136203723,
|
|
20
|
+
[c.polygon]: 71872141
|
|
21
|
+
};
|
|
22
|
+
async getPublicTokens(e, t) {
|
|
23
|
+
const o = p(t, e);
|
|
24
|
+
return (await B(f.PUBLIC_TOKENS))?.[o] || [];
|
|
25
|
+
}
|
|
26
|
+
async getLastProcessedBlock(e, t) {
|
|
27
|
+
const o = await B(f.PUBLIC_TOKENS_LAST_PROCESSED_BLOCKS) || {}, s = p(t, e);
|
|
28
|
+
return o[s] || this.INITIAL_BLOCKS[e];
|
|
29
|
+
}
|
|
30
|
+
async updateLastProcessedBlock(e, t, o) {
|
|
31
|
+
await L(f.PUBLIC_TOKENS_LAST_PROCESSED_BLOCKS, (s = {}) => {
|
|
32
|
+
const r = p(t, e);
|
|
33
|
+
return {
|
|
34
|
+
...s,
|
|
35
|
+
[r]: o
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async fetchPublicTokens(e, t, o) {
|
|
40
|
+
try {
|
|
41
|
+
const { fetchRpcUrl: s } = S[t];
|
|
42
|
+
if (!s)
|
|
43
|
+
throw Error("No fetchRpcUrl in PublicTokensDB");
|
|
44
|
+
const r = new h.providers.JsonRpcProvider(s), a = await this.getLastProcessedBlock(t, e), l = await r.getBlockNumber(), n = h.utils.hexZeroPad(e.toLowerCase(), 32), k = {
|
|
45
|
+
topics: [this.transferEventTopic, null, n],
|
|
46
|
+
fromBlock: a
|
|
47
|
+
}, d = {
|
|
48
|
+
topics: [this.transferEventTopic, n, null],
|
|
49
|
+
fromBlock: a
|
|
50
|
+
}, [m, u] = await Promise.all([r.getLogs(k), r.getLogs(d)]), T = [...m, ...u], P = [E, ...new Set(T.map((i) => i.address))].filter(
|
|
51
|
+
(i) => i && !b(o, i)
|
|
52
|
+
);
|
|
53
|
+
return P.length ? { erc20Tokens: (await g.tokensInfoCall(t, P)).filter(
|
|
54
|
+
(i) => !!i
|
|
55
|
+
), latestBlock: l } : { erc20Tokens: [], latestBlock: l };
|
|
56
|
+
} catch (s) {
|
|
57
|
+
return w.error("Error fetching public tokens:", s), { erc20Tokens: [], latestBlock: void 0 };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// this function should be called when:
|
|
61
|
+
// 1) user first initiates wallet on a given chain
|
|
62
|
+
// 2) user manually press refresh balances button
|
|
63
|
+
async fetchAndUpdatePublicTokens(e, t) {
|
|
64
|
+
const s = (await this.getPublicTokens(t, e)).map((n) => n.erc20TokenAddress), { erc20Tokens: r, latestBlock: a } = await this.fetchPublicTokens(e, t, s), l = p(e, t);
|
|
65
|
+
await L(f.PUBLIC_TOKENS, (n = {}) => {
|
|
66
|
+
const k = n[l] || [], d = k.map((T) => T.erc20TokenAddress), m = r.filter(
|
|
67
|
+
(T) => !b(d, T.erc20TokenAddress)
|
|
68
|
+
);
|
|
69
|
+
k.push(...m);
|
|
70
|
+
const u = {
|
|
71
|
+
...n,
|
|
72
|
+
[l]: k
|
|
73
|
+
};
|
|
74
|
+
return this.fetchedTokens = u, u;
|
|
75
|
+
}), a && await this.updateLastProcessedBlock(t, e, a);
|
|
76
|
+
}
|
|
77
|
+
getFetchedTokens(e, t) {
|
|
78
|
+
const o = p(t, e);
|
|
79
|
+
return this.fetchedTokens[o] || [];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const M = new y();
|
|
83
|
+
export {
|
|
84
|
+
y as PublicTokensDB,
|
|
85
|
+
M as publicTokensDB
|
|
86
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../functions/utils/serialize.utils.cjs"),n=require("./BaseCacheDevice.cjs");class h extends n.BaseCacheDevice{isAttached=!1;get(e){return this.getInMemory(e)}set(e,t){this.setInMemory(e,t)}serialize(){return Object.fromEntries([...this.inMemoryCache].map(([e,t])=>[e,s.CustomJSONStringify(t)]))}attach(e){if(this.isAttached)throw new Error("can't reattach cache device");return this.isAttached=!0,(...i)=>{const r=s.CustomJSONStringify(i),c=this.get(r);if(c!==void 0)return c;const a=e(...i);return this.set(r,a),a}}}exports.AttachableMemoryCacheDevice=h;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseCacheDevice } from './BaseCacheDevice';
|
|
2
|
+
export declare class AttachableMemoryCacheDevice<T> extends BaseCacheDevice<T> {
|
|
3
|
+
private isAttached;
|
|
4
|
+
get(key: string): T | undefined;
|
|
5
|
+
set(key: string, value: T): void;
|
|
6
|
+
serialize(): Record<string, string>;
|
|
7
|
+
attach<ArgsType extends unknown[]>(func: (...args: ArgsType) => T): (...args: ArgsType) => T;
|
|
8
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CustomJSONStringify as s } from "../../functions/utils/serialize.utils.mjs";
|
|
2
|
+
import { BaseCacheDevice as h } from "./BaseCacheDevice.mjs";
|
|
3
|
+
class l extends h {
|
|
4
|
+
isAttached = !1;
|
|
5
|
+
get(t) {
|
|
6
|
+
return this.getInMemory(t);
|
|
7
|
+
}
|
|
8
|
+
set(t, e) {
|
|
9
|
+
this.setInMemory(t, e);
|
|
10
|
+
}
|
|
11
|
+
serialize() {
|
|
12
|
+
return Object.fromEntries([...this.inMemoryCache].map(([t, e]) => [t, s(e)]));
|
|
13
|
+
}
|
|
14
|
+
attach(t) {
|
|
15
|
+
if (this.isAttached)
|
|
16
|
+
throw new Error("can't reattach cache device");
|
|
17
|
+
return this.isAttached = !0, (...r) => {
|
|
18
|
+
const a = s(r), c = this.get(a);
|
|
19
|
+
if (c !== void 0)
|
|
20
|
+
return c;
|
|
21
|
+
const i = t(...r);
|
|
22
|
+
return this.set(a, i), i;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
l as AttachableMemoryCacheDevice
|
|
28
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../../functions/utils/serialize.utils.cjs");class s{inMemoryCache=new Map;constructor(e){e&&this.mergeWithSerialized(e)}getInMemory(e){return this.inMemoryCache.get(e)??void 0}setInMemory(e,t){this.inMemoryCache.set(e,t)}mergeWithSerialized(e){Object.entries(e).forEach(([t,i])=>{this.set(t,r.CustomJSONParse(i))})}}exports.BaseCacheDevice=s;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { ICacheDevice } from '../../types/ICacheDevice';
|
|
2
|
-
export declare abstract class BaseCacheDevice implements ICacheDevice {
|
|
3
|
-
protected inMemoryCache: Map<string,
|
|
4
|
-
|
|
5
|
-
protected
|
|
6
|
-
|
|
7
|
-
abstract
|
|
2
|
+
export declare abstract class BaseCacheDevice<T = string> implements ICacheDevice<T> {
|
|
3
|
+
protected inMemoryCache: Map<string, T>;
|
|
4
|
+
constructor(serialized?: Record<string, string>);
|
|
5
|
+
protected getInMemory(key: string): T | undefined;
|
|
6
|
+
protected setInMemory(key: string, value: T): void;
|
|
7
|
+
abstract get(key: string): T | undefined;
|
|
8
|
+
abstract set(key: string, value: T): void;
|
|
9
|
+
abstract serialize(): Record<string, string>;
|
|
10
|
+
mergeWithSerialized(serialized: Record<string, string>): void;
|
|
8
11
|
}
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import { CustomJSONParse as i } from "../../functions/utils/serialize.utils.mjs";
|
|
2
|
+
class h {
|
|
2
3
|
inMemoryCache = /* @__PURE__ */ new Map();
|
|
4
|
+
constructor(e) {
|
|
5
|
+
e && this.mergeWithSerialized(e);
|
|
6
|
+
}
|
|
3
7
|
getInMemory(e) {
|
|
4
8
|
return this.inMemoryCache.get(e) ?? void 0;
|
|
5
9
|
}
|
|
6
|
-
setInMemory(e,
|
|
7
|
-
this.inMemoryCache.set(e,
|
|
10
|
+
setInMemory(e, t) {
|
|
11
|
+
this.inMemoryCache.set(e, t);
|
|
12
|
+
}
|
|
13
|
+
mergeWithSerialized(e) {
|
|
14
|
+
Object.entries(e).forEach(([t, r]) => {
|
|
15
|
+
this.set(t, i(r));
|
|
16
|
+
});
|
|
8
17
|
}
|
|
9
18
|
}
|
|
10
19
|
export {
|
|
11
|
-
|
|
20
|
+
h as BaseCacheDevice
|
|
12
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../../error-handling/logError.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../../functions/utils/serialize.utils.cjs"),r=require("../../error-handling/logError.cjs"),o=require("./BaseCacheDevice.cjs");class a extends o.BaseCacheDevice{filePath;useFileCache;constructor(e,i){super(),this.useFileCache=!!e,this.filePath=i,this.readFileFromDevice()}readFileFromDevice(){if(this.useFileCache&&this.filePath)try{const e=require("fs");if(e.existsSync(this.filePath)){const i=JSON.parse(e.readFileSync(this.filePath).toString());Object.entries(i).forEach(([s,c])=>{this.setInMemory(s,c)})}}catch(e){r.logError("FileCacheDevice Constructor Error",{err:e})}}get(e){return this.getInMemory(e)}set(e,i){if(this.readFileFromDevice(),this.setInMemory(e,i),this.useFileCache&&this.filePath)try{require("fs").writeFileSync(this.filePath,JSON.stringify(Object.fromEntries(this.inMemoryCache)))}catch(t){r.logError("FileCacheDevice set function",{err:t})}}serialize(){return Object.fromEntries([...this.inMemoryCache].map(([e,i])=>[e,h.CustomJSONStringify(i)]))}}exports.FileCacheDevice=a;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { CustomJSONStringify as h } from "../../functions/utils/serialize.utils.mjs";
|
|
1
2
|
import { logError as r } from "../../error-handling/logError.mjs";
|
|
2
|
-
import { BaseCacheDevice as
|
|
3
|
-
class
|
|
3
|
+
import { BaseCacheDevice as o } from "./BaseCacheDevice.mjs";
|
|
4
|
+
class m extends o {
|
|
4
5
|
filePath;
|
|
5
6
|
useFileCache;
|
|
6
7
|
constructor(e, i) {
|
|
@@ -31,7 +32,10 @@ class l extends h {
|
|
|
31
32
|
r("FileCacheDevice set function", { err: t });
|
|
32
33
|
}
|
|
33
34
|
}
|
|
35
|
+
serialize() {
|
|
36
|
+
return Object.fromEntries([...this.inMemoryCache].map(([e, i]) => [e, h(i)]));
|
|
37
|
+
}
|
|
34
38
|
}
|
|
35
39
|
export {
|
|
36
|
-
|
|
40
|
+
m as FileCacheDevice
|
|
37
41
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../functions/utils/serialize.utils.cjs"),r=require("./BaseCacheDevice.cjs");class i extends r.BaseCacheDevice{localDataStorage;constructor(e,t){super(),!e&&typeof localStorage<"u"&&(this.localDataStorage=localStorage),t&&this.mergeWithSerialized(t)}get(e){return this.localDataStorage?this.localDataStorage.getItem(e)??void 0:this.getInMemory(e)}set(e,t){this.localDataStorage?this.localDataStorage.setItem(e,t):this.setInMemory(e,t)}serialize(){const e=this.localDataStorage?Object.entries(localStorage):[...this.inMemoryCache];return Object.fromEntries(e.map(([t,a])=>[t,o.CustomJSONStringify(a)]))}}exports.LocalStorageCacheDevice=i;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BaseCacheDevice } from './BaseCacheDevice';
|
|
2
2
|
export declare class LocalStorageCacheDevice extends BaseCacheDevice {
|
|
3
3
|
private localDataStorage;
|
|
4
|
-
constructor();
|
|
4
|
+
constructor(disableCaching?: boolean, serializedCache?: Record<string, string>);
|
|
5
5
|
get(key: string): string | undefined;
|
|
6
6
|
set(key: string, value: string): void;
|
|
7
|
+
serialize(): Record<string, string>;
|
|
7
8
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { CustomJSONStringify as o } from "../../functions/utils/serialize.utils.mjs";
|
|
2
|
+
import { BaseCacheDevice as r } from "./BaseCacheDevice.mjs";
|
|
3
|
+
class c extends r {
|
|
3
4
|
localDataStorage;
|
|
4
|
-
constructor() {
|
|
5
|
-
super(), typeof localStorage < "u" && (this.localDataStorage = localStorage);
|
|
5
|
+
constructor(t, e) {
|
|
6
|
+
super(), !t && typeof localStorage < "u" && (this.localDataStorage = localStorage), e && this.mergeWithSerialized(e);
|
|
6
7
|
}
|
|
7
8
|
get(t) {
|
|
8
9
|
return this.localDataStorage ? this.localDataStorage.getItem(t) ?? void 0 : this.getInMemory(t);
|
|
@@ -10,7 +11,11 @@ class l extends a {
|
|
|
10
11
|
set(t, e) {
|
|
11
12
|
this.localDataStorage ? this.localDataStorage.setItem(t, e) : this.setInMemory(t, e);
|
|
12
13
|
}
|
|
14
|
+
serialize() {
|
|
15
|
+
const t = this.localDataStorage ? Object.entries(localStorage) : [...this.inMemoryCache];
|
|
16
|
+
return Object.fromEntries(t.map(([e, a]) => [e, o(a)]));
|
|
17
|
+
}
|
|
13
18
|
}
|
|
14
19
|
export {
|
|
15
|
-
|
|
20
|
+
c as LocalStorageCacheDevice
|
|
16
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("ethers"),x=require("../utxo/Utxo.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("ethers"),x=require("../utxo/Utxo.cjs"),l=require("./keys.cjs"),i=e=>{const t=U.ethers.utils.defaultAbiCoder.decode(["uint256","address","tuple(uint256, uint256, uint256, uint256)","uint256","uint256"],e),n=t[0].toBigInt(),r=t[1],s=t[2][0].toBigInt(),o=t[2][1].toHexString(),c=t[2][2].toBigInt(),d=t[2][3].toBigInt(),a=t[3].toString(),g=t[4].toNumber();return{amount:n,erc20TokenAddress:r,randomization:s,stealthAddress:o,H0:c,H1:d,timeStamp:a,tokenId:g}},u=(e,t)=>{const{amount:n,erc20TokenAddress:r,timeStamp:s,tokenId:o,randomization:c,stealthAddress:d}=i(e);return{amount:n,erc20TokenAddress:r,timeStamp:s,tokenId:o,randomization:c,shieldedPrivateKey:t,stealthAddress:d}},m=(e,t)=>new x.Utxo(u(e,t)),h=(e,t)=>{const{randomization:n,H0:r,H1:s}=i(e),o=l.UserKeys.checkSignature(n,r,s,t);if(!o)throw new Error("UTXO doesn't belong to user");return o};exports.abiDecodeUtxo=i;exports.checkUtxoSignature=h;exports.decodeUtxo=m;exports.decodeUtxoConstructorArgs=u;
|
|
@@ -5,36 +5,37 @@ const c = (o) => {
|
|
|
5
5
|
const t = m.utils.defaultAbiCoder.decode(
|
|
6
6
|
["uint256", "address", "tuple(uint256, uint256, uint256, uint256)", "uint256", "uint256"],
|
|
7
7
|
o
|
|
8
|
-
),
|
|
8
|
+
), n = t[0].toBigInt(), r = t[1], s = t[2][0].toBigInt(), e = t[2][1].toHexString(), i = t[2][2].toBigInt(), d = t[2][3].toBigInt(), u = t[3].toString(), a = t[4].toNumber();
|
|
9
9
|
return {
|
|
10
|
-
amount:
|
|
10
|
+
amount: n,
|
|
11
11
|
erc20TokenAddress: r,
|
|
12
12
|
randomization: s,
|
|
13
|
-
stealthAddress:
|
|
13
|
+
stealthAddress: e,
|
|
14
14
|
H0: i,
|
|
15
15
|
H1: d,
|
|
16
16
|
timeStamp: u,
|
|
17
17
|
tokenId: a
|
|
18
18
|
};
|
|
19
19
|
}, U = (o, t) => {
|
|
20
|
-
const { amount:
|
|
20
|
+
const { amount: n, erc20TokenAddress: r, timeStamp: s, tokenId: e, randomization: i, stealthAddress: d } = c(o);
|
|
21
21
|
return {
|
|
22
|
-
amount:
|
|
22
|
+
amount: n,
|
|
23
23
|
erc20TokenAddress: r,
|
|
24
24
|
timeStamp: s,
|
|
25
|
-
tokenId:
|
|
25
|
+
tokenId: e,
|
|
26
26
|
randomization: i,
|
|
27
|
-
shieldedPrivateKey: t
|
|
27
|
+
shieldedPrivateKey: t,
|
|
28
|
+
stealthAddress: d
|
|
28
29
|
};
|
|
29
|
-
}, k = (o, t) => new g(U(o, t)),
|
|
30
|
-
const { randomization:
|
|
31
|
-
if (!
|
|
30
|
+
}, k = (o, t) => new g(U(o, t)), A = (o, t) => {
|
|
31
|
+
const { randomization: n, H0: r, H1: s } = c(o), e = x.checkSignature(n, r, s, t);
|
|
32
|
+
if (!e)
|
|
32
33
|
throw new Error("UTXO doesn't belong to user");
|
|
33
|
-
return
|
|
34
|
+
return e;
|
|
34
35
|
};
|
|
35
36
|
export {
|
|
36
37
|
c as abiDecodeUtxo,
|
|
37
|
-
|
|
38
|
+
A as checkUtxoSignature,
|
|
38
39
|
k as decodeUtxo,
|
|
39
40
|
U as decodeUtxoConstructorArgs
|
|
40
41
|
};
|
|
@@ -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("ethers"),p=require("libsodium-wrappers"),u=require("../../constants/protocol.constants.cjs"),K=require("../../crypto/babyJub.cjs"),a=require("../../crypto/poseidon.cjs"),o=require("./keyUtils.cjs"),g=require("../cacheDevices/AttachableMemoryCacheDevice.cjs"),d=new g.AttachableMemoryCacheDevice,l=new g.AttachableMemoryCacheDevice,P={privateKey:"",publicKey:""};class b{signature;constructor(e){this.signature=e}getSignature(){return this.requireSignature(),this.signature}setSignature(e){this.signature=e}requireSignature(){if(!this.signature)throw Error("No signature provided")}verifyMessage(e){return this.requireSignature(),h.utils.verifyMessage(e,this.signature)}getShieldedPrivateKey=()=>(this.requireSignature(),h.ethers.utils.keccak256(this.signature));getShieldedPublicKey=()=>(this.requireSignature(),a.poseidonHash(this.getShieldedPrivateKey()));getAccessKey=()=>(this.requireSignature(),a.poseidonHash(this.getShieldedPrivateKey(),this.getShieldedPublicKey()));getWalletSalt=e=>(this.requireSignature(),a.poseidonHash(this.getShieldedPublicKey(),this.getShieldedPrivateKey(),e));getInHinkalAddress=e=>{this.requireSignature();const t=a.poseidonHash(this.getShieldedPrivateKey(),e);return BigInt(t)};getBackendToken=()=>(this.requireSignature(),a.poseidonHash(this.getAccessKey(),this.getShieldedPublicKey()));static getRandomizedStealthPair=d.attach((e,t)=>{const i=K.babyJubInstance(),s=BigInt(t)%u.CIRCOM_P,n=e*s%u.CIRCOM_P,r=i.mulPointEscalar(i.Base8,e),c=i.mulPointEscalar(i.Base8,n),y=[BigInt(i.F.toString(r[0])),BigInt(i.F.toString(r[1]))],S=[BigInt(i.F.toString(c[0])),BigInt(i.F.toString(c[1]))];return{H0:y,H1:S}});static getStealthAddressCompressedPoints=(e,t)=>{const{H0:i,H1:s}=this.getRandomizedStealthPair(e,t),[n,r]=[i,s].map(c=>BigInt(c[1])+2n**255n*o.getCircomSign(c[0]));return{h0:n,h1:r}};static getStealthAddress=l.attach((e,t)=>{const{H0:i,H1:s}=this.getRandomizedStealthPair(e,t),r=[2n*o.getCircomSign(i[0])+o.getCircomSign(s[0]),i[1],s[1]];return a.poseidonHash(...r)});static getStealthAddressWithEKey=(e,t)=>({stealthAddress:this.getStealthAddress(e,t),encryptionKey:this.getEncryptionKeyPair(t).publicKey});static checkSignature=(e,t,i,s)=>{const{h0:n,h1:r}=this.getStealthAddressCompressedPoints(e,s);return t===n&&i===r};static getEncryptionKeyPair=e=>{const t=p.crypto_box_seed_keypair(h.ethers.utils.arrayify(e));return{privateKey:h.ethers.utils.hexlify(t.privateKey),publicKey:h.ethers.utils.hexlify(t.publicKey)}}}exports.EncryptionKeyPairDefaultValue=P;exports.UserKeys=b;exports.stealthAddressCacheDevice=l;exports.stealthPairCacheDevice=d;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AttachableMemoryCacheDevice } from '../cacheDevices/AttachableMemoryCacheDevice';
|
|
2
|
+
export declare const stealthPairCacheDevice: AttachableMemoryCacheDevice<{
|
|
3
|
+
H0: [bigint, bigint];
|
|
4
|
+
H1: [bigint, bigint];
|
|
5
|
+
}>;
|
|
6
|
+
export declare const stealthAddressCacheDevice: AttachableMemoryCacheDevice<string>;
|
|
2
7
|
export interface EncryptionKeyPair {
|
|
3
8
|
privateKey: string;
|
|
4
9
|
publicKey: string;
|
|
@@ -30,14 +35,19 @@ export declare class UserKeys {
|
|
|
30
35
|
*/
|
|
31
36
|
getAccessKey: () => string;
|
|
32
37
|
getWalletSalt: (walletNonce: bigint) => string;
|
|
38
|
+
/**
|
|
39
|
+
* generate inHinkalAddress - a user unique address linking him with a specific app
|
|
40
|
+
* @returns inHinkalAddress in bigint
|
|
41
|
+
*/
|
|
42
|
+
getInHinkalAddress: (interactionAddress: string) => bigint;
|
|
33
43
|
/**
|
|
34
44
|
* generate backend token, which is used for access control on backend
|
|
35
45
|
* @returns accessKey in hexstring with 0x prefixed
|
|
36
46
|
*/
|
|
37
47
|
getBackendToken: () => string;
|
|
38
48
|
static getRandomizedStealthPair: (s: bigint, privateKey: string) => {
|
|
39
|
-
H0:
|
|
40
|
-
H1:
|
|
49
|
+
H0: [bigint, bigint];
|
|
50
|
+
H1: [bigint, bigint];
|
|
41
51
|
};
|
|
42
52
|
static getStealthAddressCompressedPoints: (s: bigint, privateKey: string) => {
|
|
43
53
|
h0: bigint;
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import { utils as y, ethers as o } from "ethers";
|
|
2
2
|
import S from "libsodium-wrappers";
|
|
3
|
-
import { CIRCOM_P as
|
|
3
|
+
import { CIRCOM_P as g } from "../../constants/protocol.constants.mjs";
|
|
4
4
|
import { babyJubInstance as m } from "../../crypto/babyJub.mjs";
|
|
5
|
-
import { poseidonHash as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
const
|
|
5
|
+
import { poseidonHash as a } from "../../crypto/poseidon.mjs";
|
|
6
|
+
import { getCircomSign as u } from "./keyUtils.mjs";
|
|
7
|
+
import { AttachableMemoryCacheDevice as c } from "../cacheDevices/AttachableMemoryCacheDevice.mjs";
|
|
8
|
+
const p = new c(), K = new c(), H = {
|
|
9
9
|
privateKey: "",
|
|
10
10
|
publicKey: ""
|
|
11
11
|
};
|
|
12
|
-
class
|
|
12
|
+
class k {
|
|
13
13
|
signature;
|
|
14
|
-
constructor(
|
|
15
|
-
this.signature =
|
|
14
|
+
constructor(e) {
|
|
15
|
+
this.signature = e;
|
|
16
16
|
}
|
|
17
17
|
getSignature() {
|
|
18
18
|
return this.requireSignature(), this.signature;
|
|
19
19
|
}
|
|
20
|
-
setSignature(
|
|
21
|
-
this.signature =
|
|
20
|
+
setSignature(e) {
|
|
21
|
+
this.signature = e;
|
|
22
22
|
}
|
|
23
23
|
requireSignature() {
|
|
24
24
|
if (!this.signature)
|
|
25
25
|
throw Error("No signature provided");
|
|
26
26
|
}
|
|
27
|
-
verifyMessage(
|
|
28
|
-
return this.requireSignature(), y.verifyMessage(
|
|
27
|
+
verifyMessage(e) {
|
|
28
|
+
return this.requireSignature(), y.verifyMessage(e, this.signature);
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* get shielded private key from message signature used to login to the application,
|
|
@@ -39,51 +39,62 @@ class H {
|
|
|
39
39
|
* that the user provided
|
|
40
40
|
* @retuns shielded public key in hexstring with 0x prefixed
|
|
41
41
|
*/
|
|
42
|
-
getShieldedPublicKey = () => (this.requireSignature(),
|
|
42
|
+
getShieldedPublicKey = () => (this.requireSignature(), a(this.getShieldedPrivateKey()));
|
|
43
43
|
/**
|
|
44
44
|
* generate access token, this accessKey is what should be sent to the server for signing
|
|
45
45
|
* @returns accessKey in hexstring with 0x prefixed
|
|
46
46
|
*/
|
|
47
|
-
getAccessKey = () => (this.requireSignature(),
|
|
48
|
-
getWalletSalt = (
|
|
47
|
+
getAccessKey = () => (this.requireSignature(), a(this.getShieldedPrivateKey(), this.getShieldedPublicKey()));
|
|
48
|
+
getWalletSalt = (e) => (this.requireSignature(), a(this.getShieldedPublicKey(), this.getShieldedPrivateKey(), e));
|
|
49
|
+
/**
|
|
50
|
+
* generate inHinkalAddress - a user unique address linking him with a specific app
|
|
51
|
+
* @returns inHinkalAddress in bigint
|
|
52
|
+
*/
|
|
53
|
+
getInHinkalAddress = (e) => {
|
|
54
|
+
this.requireSignature();
|
|
55
|
+
const t = a(this.getShieldedPrivateKey(), e);
|
|
56
|
+
return BigInt(t);
|
|
57
|
+
};
|
|
49
58
|
/**
|
|
50
59
|
* generate backend token, which is used for access control on backend
|
|
51
60
|
* @returns accessKey in hexstring with 0x prefixed
|
|
52
61
|
*/
|
|
53
|
-
getBackendToken = () => (this.requireSignature(),
|
|
54
|
-
static getRandomizedStealthPair =
|
|
55
|
-
(
|
|
56
|
-
const
|
|
62
|
+
getBackendToken = () => (this.requireSignature(), a(this.getAccessKey(), this.getShieldedPublicKey()));
|
|
63
|
+
static getRandomizedStealthPair = p.attach(
|
|
64
|
+
(e, t) => {
|
|
65
|
+
const i = m(), r = BigInt(t) % g, n = e * r % g, s = i.mulPointEscalar(i.Base8, e), h = i.mulPointEscalar(i.Base8, n), d = [BigInt(i.F.toString(s[0])), BigInt(i.F.toString(s[1]))], l = [BigInt(i.F.toString(h[0])), BigInt(i.F.toString(h[1]))];
|
|
57
66
|
return { H0: d, H1: l };
|
|
58
67
|
}
|
|
59
68
|
);
|
|
60
|
-
static getStealthAddressCompressedPoints = (
|
|
61
|
-
const { H0:
|
|
69
|
+
static getStealthAddressCompressedPoints = (e, t) => {
|
|
70
|
+
const { H0: i, H1: r } = this.getRandomizedStealthPair(e, t), [n, s] = [i, r].map((h) => BigInt(h[1]) + 2n ** 255n * u(h[0]));
|
|
62
71
|
return { h0: n, h1: s };
|
|
63
72
|
};
|
|
64
|
-
static getStealthAddress =
|
|
65
|
-
const { H0:
|
|
66
|
-
return
|
|
73
|
+
static getStealthAddress = K.attach((e, t) => {
|
|
74
|
+
const { H0: i, H1: r } = this.getRandomizedStealthPair(e, t), s = [2n * u(i[0]) + u(r[0]), i[1], r[1]];
|
|
75
|
+
return a(...s);
|
|
67
76
|
});
|
|
68
|
-
static getStealthAddressWithEKey = (
|
|
69
|
-
static checkSignature = (t, i,
|
|
70
|
-
const { h0: n, h1: s } = this.getStealthAddressCompressedPoints(
|
|
71
|
-
return
|
|
77
|
+
static getStealthAddressWithEKey = (e, t) => ({ stealthAddress: this.getStealthAddress(e, t), encryptionKey: this.getEncryptionKeyPair(t).publicKey });
|
|
78
|
+
static checkSignature = (e, t, i, r) => {
|
|
79
|
+
const { h0: n, h1: s } = this.getStealthAddressCompressedPoints(e, r);
|
|
80
|
+
return t === n && i === s;
|
|
72
81
|
};
|
|
73
82
|
/**
|
|
74
83
|
* generate private and public keypair
|
|
75
84
|
* @param seed seed to use to deterministically generate key, must be in DataHexString format
|
|
76
85
|
* and must correspond to 32 bytes
|
|
77
86
|
*/
|
|
78
|
-
static getEncryptionKeyPair = (
|
|
79
|
-
const
|
|
87
|
+
static getEncryptionKeyPair = (e) => {
|
|
88
|
+
const t = S.crypto_box_seed_keypair(o.utils.arrayify(e));
|
|
80
89
|
return {
|
|
81
|
-
privateKey: o.utils.hexlify(
|
|
82
|
-
publicKey: o.utils.hexlify(
|
|
90
|
+
privateKey: o.utils.hexlify(t.privateKey),
|
|
91
|
+
publicKey: o.utils.hexlify(t.publicKey)
|
|
83
92
|
};
|
|
84
93
|
};
|
|
85
94
|
}
|
|
86
95
|
export {
|
|
87
|
-
|
|
88
|
-
|
|
96
|
+
H as EncryptionKeyPairDefaultValue,
|
|
97
|
+
k as UserKeys,
|
|
98
|
+
K as stealthAddressCacheDevice,
|
|
99
|
+
p as stealthPairCacheDevice
|
|
89
100
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class i{tokenRegistry;constructor(){this.tokenRegistry=[]}setTokensFromCache(s){this.tokenRegistry=s}getCustomTokens(s){return this.tokenRegistry.filter(t=>t.chainId===s)}tokenExists(s,t){return s.find(e=>e.erc20TokenAddress===t.erc20TokenAddress||e.symbol===t.symbol||e.name===t.name)}addCustomToken(s){const{chainId:t}=s,e=this.getCustomTokens(t);this.tokenExists(e,s)||this.tokenRegistry.push(s)}removeCustomToken(s){const{chainId:t}=s,r=this.getCustomTokens(t).filter(o=>o.erc20TokenAddress!==s.erc20TokenAddress);this.tokenRegistry=r}}const n=new i;exports.customTokenRegistry=n;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { ERC20Token } from '../../types
|
|
1
|
+
import { ERC20Token } from '../../types';
|
|
2
2
|
declare class CustomTokenRegistry {
|
|
3
|
-
private localStorageKey;
|
|
4
3
|
tokenRegistry: ERC20Token[];
|
|
5
4
|
constructor();
|
|
6
|
-
|
|
5
|
+
setTokensFromCache(newTokenRegistries: ERC20Token[]): void;
|
|
7
6
|
getCustomTokens(chainId: number): ERC20Token[];
|
|
8
7
|
tokenExists(registry: ERC20Token[], tokenToCheck: ERC20Token): ERC20Token | undefined;
|
|
9
8
|
addCustomToken(token: ERC20Token): void;
|
|
@@ -1,33 +1,29 @@
|
|
|
1
|
-
class
|
|
2
|
-
localStorageKey = "tokenRegistry";
|
|
1
|
+
class i {
|
|
3
2
|
tokenRegistry;
|
|
4
3
|
constructor() {
|
|
5
|
-
|
|
6
|
-
const t = localStorage.getItem(this.localStorageKey);
|
|
7
|
-
t && (this.tokenRegistry = JSON.parse(t));
|
|
8
|
-
}
|
|
4
|
+
this.tokenRegistry = [];
|
|
9
5
|
}
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
setTokensFromCache(s) {
|
|
7
|
+
this.tokenRegistry = s;
|
|
12
8
|
}
|
|
13
|
-
getCustomTokens(
|
|
14
|
-
return this.tokenRegistry.filter((
|
|
9
|
+
getCustomTokens(s) {
|
|
10
|
+
return this.tokenRegistry.filter((t) => t.chainId === s);
|
|
15
11
|
}
|
|
16
|
-
tokenExists(
|
|
17
|
-
return
|
|
18
|
-
(e) => e.erc20TokenAddress ===
|
|
12
|
+
tokenExists(s, t) {
|
|
13
|
+
return s.find(
|
|
14
|
+
(e) => e.erc20TokenAddress === t.erc20TokenAddress || e.symbol === t.symbol || e.name === t.name
|
|
19
15
|
);
|
|
20
16
|
}
|
|
21
|
-
addCustomToken(
|
|
22
|
-
const { chainId:
|
|
23
|
-
this.tokenExists(e,
|
|
17
|
+
addCustomToken(s) {
|
|
18
|
+
const { chainId: t } = s, e = this.getCustomTokens(t);
|
|
19
|
+
this.tokenExists(e, s) || this.tokenRegistry.push(s);
|
|
24
20
|
}
|
|
25
|
-
removeCustomToken(
|
|
26
|
-
const { chainId:
|
|
27
|
-
this.tokenRegistry = r
|
|
21
|
+
removeCustomToken(s) {
|
|
22
|
+
const { chainId: t } = s, r = this.getCustomTokens(t).filter((n) => n.erc20TokenAddress !== s.erc20TokenAddress);
|
|
23
|
+
this.tokenRegistry = r;
|
|
28
24
|
}
|
|
29
25
|
}
|
|
30
|
-
const
|
|
26
|
+
const c = new i();
|
|
31
27
|
export {
|
|
32
|
-
|
|
28
|
+
c as customTokenRegistry
|
|
33
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../constants/protocol.constants.cjs"),a=require("../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const n=require("../../functions/utils/amounts.utils.cjs"),o=require("../merkle-tree/MerkleTree.cjs");require("ethers");require("../../error-handling/error-codes.constants.cjs");const l=require("./AbstractSnapshotService.cjs"),u=require("../../functions/utils/merkleTree.utils.cjs");class i extends l.AbstractSnapshotService{constructor(e,s,r,d){super(e,{name:"NewAccessKeyAdded",args:["accessKey","index","senderAddress"]},s,r,d)}_merkleTree;_senderAddresses;_senderAddressIndexMap;get merkleTree(){return this._merkleTree}get senderAddresses(){return this._senderAddresses}get senderAddressIndexMap(){return this._senderAddressIndexMap}serializeSnapshot(e){return{merkleTree:e.payload.merkleTree.toJSON(),senderAddresses:Array.from(e.payload.senderAddresses),latestBlockNumber:e.latestBlockNumber,reserveBlockNumber:e.reserveBlockNumber,senderAddressIndexMap:Array.from(e.payload.senderAddressIndexMap).map(([s,r])=>({address:s,index:r}))}}deserializeSnapshot(e){let s,r;return e.latestBlockNumber&&e.merkleTree?s=u.contructMerkleTreeFromSerialized(e.merkleTree):s=o.MerkleTree.create(a.poseidonFunction,0n),e.latestBlockNumber&&e.senderAddressIndexMap?r=new Map(e.senderAddressIndexMap.map(({address:d,index:t})=>[d,t])):r=new Map,{latestBlockNumber:e.latestBlockNumber??0,reserveBlockNumber:e.reserveBlockNumber??0,payload:{merkleTree:s,senderAddresses:e.senderAddresses??[],senderAddressIndexMap:r}}}acceptEvent(e,s){try{return this._merkleTree.insert(e.accessKey,e.index),this._senderAddressIndexMap.set(e.senderAddress,Math.max(Number(e.index),this._senderAddressIndexMap.get(e.senderAddress)??0)),this._senderAddresses.includes(e.senderAddress)||this._senderAddresses.push(e.senderAddress),e.accessKey===0n&&e.senderAddress===c.zeroAddress&&this._merkleTree.remove(e.index),!0}catch(r){return console.error(r),!1}}mapEvent(e){const{accessKey:s,index:r,senderAddress:d}=e;return{accessKey:n.toBigInt(s),index:n.toBigInt(r),senderAddress:d}}getSnapshotPayload(){return{merkleTree:this._merkleTree,senderAddresses:this._senderAddresses,senderAddressIndexMap:this._senderAddressIndexMap}}populateSnapshot({payload:{merkleTree:e,senderAddresses:s,senderAddressIndexMap:r}}){this._merkleTree=e,this._senderAddresses=s,this._senderAddressIndexMap=r}}exports.AbstractAccessTokenSnapshotService=i;
|