@hinkal/common 0.2.12 → 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 +9 -3
- package/API/API.mjs +44 -34
- 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 +6 -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/kycCalls.cjs +1 -1
- package/API/kycCalls.d.ts +0 -4
- package/API/kycCalls.mjs +11 -15
- package/API/rewardsPointsCalls.d.ts +0 -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/README.md +0 -61
- 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 +26 -38
- package/constants/contracts.constants.cjs +1 -1
- package/constants/contracts.constants.mjs +108 -108
- 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-localhost.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-localhost.json.mjs +1652 -829
- package/constants/deploy-data/deploy-data-optimism.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-optimism.json.mjs +9707 -3957
- 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/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.d.ts +0 -1
- package/constants/rewards.constants.mjs +14 -13
- package/constants/server.constants.cjs +1 -1
- package/constants/server.constants.d.ts +8 -3
- package/constants/server.constants.mjs +16 -11
- package/constants/token-data/ERC20Registry.cjs +1 -1
- package/constants/token-data/ERC20Registry.mjs +10 -9
- package/constants/token-data/arbMainnetRegistry.json.cjs +1 -1
- package/constants/token-data/arbMainnetRegistry.json.mjs +88 -88
- package/constants/token-data/arbMainnetRegistryFixed.json.cjs +1 -1
- package/constants/token-data/arbMainnetRegistryFixed.json.mjs +78 -78
- package/constants/token-data/avalancheRegistry.json.cjs +1 -1
- package/constants/token-data/avalancheRegistry.json.mjs +49 -49
- package/constants/token-data/avalancheRegistryFixed.json.cjs +1 -1
- package/constants/token-data/avalancheRegistryFixed.json.mjs +49 -49
- package/constants/token-data/baseRegistry.json.cjs +1 -1
- package/constants/token-data/baseRegistry.json.mjs +32 -32
- package/constants/token-data/baseRegistryFixed.json.cjs +1 -1
- package/constants/token-data/baseRegistryFixed.json.mjs +29 -29
- package/constants/token-data/bnbMainnetRegistry.json.cjs +1 -1
- package/constants/token-data/bnbMainnetRegistry.json.mjs +65 -65
- package/constants/token-data/bnbMainnetRegistryFixed.json.cjs +1 -1
- package/constants/token-data/bnbMainnetRegistryFixed.json.mjs +65 -65
- package/constants/token-data/ethMainnetRegistry.json.cjs +1 -1
- package/constants/token-data/ethMainnetRegistry.json.mjs +227 -227
- package/constants/token-data/ethMainnetRegistryFixed.json.cjs +1 -1
- package/constants/token-data/ethMainnetRegistryFixed.json.mjs +191 -191
- package/constants/token-data/index.d.ts +91 -0
- package/constants/token-data/localhostRegistry.json.cjs +1 -1
- package/constants/token-data/localhostRegistry.json.mjs +294 -277
- package/constants/token-data/optimismRegistry.json.cjs +1 -1
- package/constants/token-data/optimismRegistry.json.mjs +702 -182
- package/constants/token-data/optimismRegistryFixed.json.cjs +1 -1
- package/constants/token-data/optimismRegistryFixed.json.mjs +678 -175
- package/constants/token-data/polygonRegistry.json.cjs +1 -1
- package/constants/token-data/polygonRegistry.json.mjs +109 -109
- package/constants/token-data/polygonRegistryFixed.json.cjs +1 -1
- package/constants/token-data/polygonRegistryFixed.json.mjs +101 -101
- 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 +46 -21
- package/data-structures/Hinkal/Hinkal.mjs +260 -92
- package/data-structures/Hinkal/IHinkal.d.ts +35 -11
- package/data-structures/Hinkal/hinkalActionBeefy.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionBeefy.mjs +5 -4
- package/data-structures/Hinkal/hinkalActionConvex.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionConvex.mjs +4 -3
- package/data-structures/Hinkal/hinkalActionCurve.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionCurve.mjs +5 -4
- 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 +9 -8
- package/data-structures/Hinkal/hinkalActionPendle.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionPendle.mjs +17 -16
- package/data-structures/Hinkal/hinkalActionPendleLP.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionPendleLP.mjs +14 -12
- 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.mjs +12 -9
- package/data-structures/Hinkal/hinkalActionVolatile.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionVolatile.mjs +25 -21
- 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 +96 -71
- package/data-structures/Hinkal/hinkalGetRecipientInfo.cjs +1 -1
- package/data-structures/Hinkal/hinkalGetRecipientInfo.d.ts +1 -1
- package/data-structures/Hinkal/hinkalGetRecipientInfo.mjs +5 -11
- package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
- package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +6 -18
- 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 -38
- 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 +68 -60
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.d.ts +3 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +76 -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 +34 -46
- 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 +4 -1
- package/data-structures/merkle-tree/MerkleTree.mjs +66 -65
- package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.cjs +1 -1
- package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.d.ts +1 -1
- package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.mjs +10 -6
- package/data-structures/provider-adapter/IProviderAdapter.d.ts +2 -0
- package/data-structures/snapshot/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientAccessTokenSnapshotService.mjs +6 -10
- 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 +6 -10
- package/data-structures/snapshot/ClientNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientNullifierSnapshotService.mjs +6 -10
- 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 +6 -5
- package/data-structures/transactions-manager/TransactionsManager.mjs +95 -100
- 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 +20 -3
- package/error-handling/error-codes.constants.mjs +139 -126
- 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/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 -28
- 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 +17 -4
- package/functions/private-wallet/emporium.helpers.mjs +119 -12
- 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 +2 -0
- package/functions/private-wallet/opProducer.cjs +1 -1
- package/functions/private-wallet/opProducer.mjs +1 -1
- package/functions/private-wallet/smartContractWalletCalculator.cjs +1 -0
- package/functions/private-wallet/smartContractWalletCalculator.d.ts +5 -0
- package/functions/private-wallet/smartContractWalletCalculator.mjs +25 -0
- package/functions/protocols/convex.protocols.cjs +1 -1
- package/functions/protocols/convex.protocols.mjs +10 -8
- package/functions/protocols/pendle.helpers.cjs +1 -1
- package/functions/protocols/pendle.helpers.mjs +16 -12
- 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 -2
- package/functions/snarkjs/constant.mjs +313 -93
- 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 +141 -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 -4
- package/functions/snarkjs/generateZkProofEnclave.cjs +1 -1
- package/functions/snarkjs/generateZkProofEnclave.d.ts +2 -1
- package/functions/snarkjs/generateZkProofEnclave.mjs +22 -29
- package/functions/snarkjs/generateZkProofSelf.cjs +1 -1
- package/functions/snarkjs/generateZkProofSelf.d.ts +2 -2
- package/functions/snarkjs/generateZkProofSelf.mjs +10 -10
- 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 +31 -9
- package/functions/utils/cacheDevice.utils.cjs +1 -1
- package/functions/utils/cacheDevice.utils.mjs +5 -3
- 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 +22 -14
- package/functions/utils/evmNetworkFunctions.cjs +1 -1
- package/functions/utils/evmNetworkFunctions.mjs +6 -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 +3 -0
- package/functions/utils/string.utils.mjs +31 -7
- 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/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 +79 -82
- 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 +19 -17
- 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 +29 -42
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.d.ts +2 -2
- package/functions/web3/functionCalls/transactCallRelayer.mjs +26 -5
- package/functions/web3/odosAPI.cjs +1 -1
- package/functions/web3/odosAPI.mjs +6 -3
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.mjs +6 -3
- 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.mjs +6 -3
- package/index.cjs +1 -1
- package/index.mjs +756 -612
- package/package.json +6 -2
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.d.ts +7 -3
- package/providers/EthersProviderAdapter.mjs +31 -11
- package/providers/WagmiProviderAdapter.cjs +1 -1
- package/providers/WagmiProviderAdapter.d.ts +3 -1
- package/providers/WagmiProviderAdapter.mjs +12 -4
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +17 -11
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +17 -11
- 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 +66 -62
- 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 +43 -5
- package/types/hinkal.types.mjs +37 -13
- package/types/index.d.ts +9 -0
- package/types/rewards.types.cjs +1 -1
- package/types/rewards.types.d.ts +3 -4
- package/types/rewards.types.mjs +12 -12
- 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/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 -31
- 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
|
@@ -1,77 +1,85 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
import { transactionErrorCodes as S } from "../../error-handling/error-codes.constants.mjs";
|
|
2
|
+
import { outputUtxoProcessing as U } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
3
|
+
import { constructZkProof as L } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
4
|
+
import { addPaddingToUtxos as M } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
5
|
+
import { estimateGasRelayer as h } from "../../functions/web3/functionCalls/estimateGasRelayer.mjs";
|
|
6
|
+
import { transactCallRelayer as F } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
7
|
+
import { getFeeStructure as H } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
8
|
+
import { mergeWithFeeStructure as K } from "../../functions/pre-transaction/merge-with-fee-structure.mjs";
|
|
9
|
+
import { ExternalActionId as N } from "../../types/external-action.types.mjs";
|
|
10
|
+
import { defaultHinkalLogicArgs as W } from "../../types/hinkal.types.mjs";
|
|
11
|
+
import { outputApprovalDataProcessing as _ } from "../../functions/pre-transaction/outputApprovalDataProcessing.mjs";
|
|
12
|
+
import { ContractType as $ } from "../../types/ethereum-network.types.mjs";
|
|
13
|
+
import { shouldPatchAccessTokenMerkleTree as q } from "../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs";
|
|
14
|
+
import { getSignatureDataForTransact as z } from "../../functions/pre-transaction/getSignatureDataForTransact.mjs";
|
|
15
|
+
import { getExternalSwapAddress as B } from "../../functions/pre-transaction/getExternalSwapAddress.mjs";
|
|
16
|
+
const st = async (t, o, r, n, x, d, C, y = !1, T = !1) => {
|
|
17
|
+
const c = C ?? await H(t.getCurrentChainId(), d, o, N.Transact);
|
|
18
|
+
K(t.getCurrentChainId(), o, r, c);
|
|
19
|
+
const w = B(t, n), s = {
|
|
20
|
+
externalActionId: n,
|
|
21
|
+
externalAddress: w,
|
|
22
|
+
externalActionMetadata: x
|
|
23
|
+
}, a = [...await M(t, o, r)], A = `swapperM${r.length.toString()}x${a[0].length}x1`, v = [!1, !0, !1].slice(0, r.length), p = [], i = W(r.length, t.userKeys);
|
|
24
|
+
for (let e = 0; e < o.length; e += 1) {
|
|
25
|
+
const { outputUtxos: P } = U(
|
|
26
|
+
t.userKeys,
|
|
27
|
+
a[e],
|
|
28
|
+
r[e],
|
|
29
|
+
void 0,
|
|
30
|
+
void 0,
|
|
31
|
+
!1
|
|
32
|
+
);
|
|
33
|
+
p.push(P);
|
|
34
|
+
const { useApprovalUtxoData: l } = _(t, a[e], r[e]);
|
|
35
|
+
l && (i.useApprovalUtxoData[e] = l, i.doPreTxApproval = !0);
|
|
27
36
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
t.getCurrentChainId(),
|
|
37
|
+
const m = await t.getRandomRelay();
|
|
38
|
+
if (!m)
|
|
39
|
+
throw Error(S.RELAYER_NOT_AVAILABLE);
|
|
40
|
+
const { patchAccessTokenMerkleTree: E, kycRequired: R, hasAccessToken: D } = await q(
|
|
41
|
+
t,
|
|
34
42
|
o,
|
|
35
|
-
r
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
for (let a = 0; a < o.length; a += 1) {
|
|
45
|
-
const { outputUtxos: R } = T(t.userKeys, n[a], e[a]);
|
|
46
|
-
d.push(R);
|
|
47
|
-
}
|
|
48
|
-
const l = await t.getRandomRelay();
|
|
49
|
-
if (!l)
|
|
50
|
-
throw Error(I.RELAYER_NOT_AVAILABLE);
|
|
51
|
-
const { zkCallData: m, circomData: p, dimData: f } = await b(
|
|
43
|
+
r
|
|
44
|
+
), I = await z(
|
|
45
|
+
t.getCurrentChainId(),
|
|
46
|
+
await t.getEthereumAddress(),
|
|
47
|
+
t.userKeys,
|
|
48
|
+
R,
|
|
49
|
+
D
|
|
50
|
+
), { zkCallData: u, circomData: g, dimData: f } = await L(
|
|
51
|
+
"v1x1",
|
|
52
52
|
t.merkleTreeHinkal,
|
|
53
53
|
t.merkleTreeAccessToken,
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
a,
|
|
55
|
+
p,
|
|
56
56
|
t.userKeys,
|
|
57
|
-
|
|
57
|
+
A,
|
|
58
58
|
s.externalActionId,
|
|
59
59
|
s.externalAddress,
|
|
60
60
|
s.externalActionMetadata,
|
|
61
61
|
t.generateProofRemotely,
|
|
62
|
-
|
|
62
|
+
m,
|
|
63
63
|
t.getCurrentChainId(),
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
v,
|
|
65
|
+
void 0,
|
|
66
|
+
void 0,
|
|
67
|
+
void 0,
|
|
68
|
+
E,
|
|
69
|
+
i,
|
|
70
|
+
void 0,
|
|
71
|
+
c,
|
|
72
|
+
t.getContractWithFetcher($.HinkalHelperContract),
|
|
73
|
+
I
|
|
66
74
|
);
|
|
67
|
-
return
|
|
75
|
+
return y ? await h(t, u, f, g) : await F(
|
|
68
76
|
t.getCurrentChainId(),
|
|
69
|
-
|
|
77
|
+
u,
|
|
70
78
|
f,
|
|
71
|
-
|
|
72
|
-
|
|
79
|
+
g,
|
|
80
|
+
T
|
|
73
81
|
);
|
|
74
82
|
};
|
|
75
83
|
export {
|
|
76
|
-
|
|
84
|
+
st as hinkalSwap
|
|
77
85
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../constants/protocol.constants.cjs"),m=require("../../error-handling/error-codes.constants.cjs"),F=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),I=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),U=require("../../functions/web3/events/getShieldedBalance.cjs"),M=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),R=require("../../functions/web3/functionCalls/transactCallDirect.cjs"),_=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),k=require("../../types/external-action.types.cjs"),W=require("../../types/hinkal.types.cjs"),L=require("../../functions/pre-transaction/outputApprovalDataProcessing.cjs"),N=require("../../functions/pre-transaction/getFeeStructure.cjs"),H=require("../../functions/pre-transaction/merge-with-fee-structure.cjs");require("../../types/circom-data.types.cjs");const K=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("../../types/activities.types.cjs");const G=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),b=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),z=async(e,p,r,C,a,T,w,y=!1)=>{const o=p.map(t=>t.erc20TokenAddress);let c;a||(c=w??await N.getFeeStructure(e.getCurrentChainId(),T,o,k.ExternalActionId.Transact),H.mergeWithFeeStructure(e.getCurrentChainId(),o,r,c));const n=p[0];if(!n)throw Error("Deposit Action: No Token Found");const i={externalActionId:0n,externalAddress:C,externalActionMetadata:"0x00"},s=[...await U.addPaddingToUtxos(e,o,r)],h=`swapperM${r.length.toString()}x${s[0].length}x1`,x=[],u=W.defaultHinkalLogicArgs(r.length,e.userKeys);for(let t=0;t<o.length;t+=1){const{outputUtxos:S}=F.outputUtxoProcessing(e.userKeys,s[t],r[t],void 0,void 0,!1);x.push(S);const{useApprovalUtxoData:q}=L.outputApprovalDataProcessing(e,s[t],r[t]);q&&(u.useApprovalUtxoData[t]=q,u.doPreTxApproval=!0)}const A=await e.getRandomRelay();if(!a&&!A)throw Error(m.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{patchAccessTokenMerkleTree:v,kycRequired:D,hasAccessToken:P}=await b.shouldPatchAccessTokenMerkleTree(e,o,r),E=await G.getSignatureDataForTransact(e.getCurrentChainId(),await e.getEthereumAddress(),e.userKeys,D,P),{zkCallData:d,circomData:g,dimData:l}=await I.constructZkProof("v1x1",e.merkleTreeHinkal,e.merkleTreeAccessToken,s,x,e.userKeys,h,i.externalActionId,i.externalAddress,i.externalActionMetadata,e.generateProofRemotely,a?f.zeroAddress:A,e.getCurrentChainId(),void 0,void 0,void 0,void 0,v,u,void 0,c,e.getContractWithFetcher(K.ContractType.HinkalHelperContract),E);if(y)return await M.estimateGasRelayer(e,d,l,g);if(a){if(!n)throw Error("Withdraw Action: No Token Found");return await R.transactCallDirect(e,r[0],n,d,g,l)}return await _.transactCallRelayer(e.getCurrentChainId(),d,l,g)};exports.hinkalWithdraw=z;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { IHinkal } from './IHinkal';
|
|
2
|
-
|
|
2
|
+
import { FeeStructure } from '../../types/hinkal.types';
|
|
3
|
+
import { ERC20Token } from '../../types';
|
|
4
|
+
export declare const hinkalWithdraw: (hinkal: IHinkal, erc20Tokens: ERC20Token[], deltaAmounts: bigint[], recipientAddress: string, isRelayerOff: boolean, feeToken?: string, feeStructureOverride?: FeeStructure, onlyGasEstimate?: boolean) => Promise<any>;
|
|
@@ -1,69 +1,95 @@
|
|
|
1
|
-
import { zeroAddress as
|
|
2
|
-
import { transactionErrorCodes as
|
|
3
|
-
import { getERC20Token as y } from "../../functions/utils/erc20tokenFunctions.mjs";
|
|
4
|
-
import { getFlatFees as D } from "../../functions/pre-transaction/getFlatFees.mjs";
|
|
5
|
-
import { processAmountChanges as U } from "../../functions/pre-transaction/processAmountChanges.mjs";
|
|
1
|
+
import { zeroAddress as U } from "../../constants/protocol.constants.mjs";
|
|
2
|
+
import { transactionErrorCodes as h } from "../../error-handling/error-codes.constants.mjs";
|
|
6
3
|
import { outputUtxoProcessing as F } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
7
|
-
import { constructZkProof as
|
|
8
|
-
import { addPaddingToUtxos as
|
|
9
|
-
import { estimateGasRelayer as
|
|
10
|
-
import { transactCallDirect as
|
|
11
|
-
import { transactCallRelayer as
|
|
12
|
-
import { ExternalActionId as
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
4
|
+
import { constructZkProof as L } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
5
|
+
import { addPaddingToUtxos as M } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
6
|
+
import { estimateGasRelayer as R } from "../../functions/web3/functionCalls/estimateGasRelayer.mjs";
|
|
7
|
+
import { transactCallDirect as S } from "../../functions/web3/functionCalls/transactCallDirect.mjs";
|
|
8
|
+
import { transactCallRelayer as H } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
9
|
+
import { ExternalActionId as K } from "../../types/external-action.types.mjs";
|
|
10
|
+
import { defaultHinkalLogicArgs as N } from "../../types/hinkal.types.mjs";
|
|
11
|
+
import { outputApprovalDataProcessing as W } from "../../functions/pre-transaction/outputApprovalDataProcessing.mjs";
|
|
12
|
+
import { getFeeStructure as z } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
13
|
+
import { mergeWithFeeStructure as _ } from "../../functions/pre-transaction/merge-with-fee-structure.mjs";
|
|
14
|
+
import "../../types/circom-data.types.mjs";
|
|
15
|
+
import { ContractType as $ } from "../../types/ethereum-network.types.mjs";
|
|
16
|
+
import "../../types/transactions.types.mjs";
|
|
17
|
+
import "../../types/curve.types.mjs";
|
|
18
|
+
import "../../types/activities.types.mjs";
|
|
19
|
+
import { getSignatureDataForTransact as q } from "../../functions/pre-transaction/getSignatureDataForTransact.mjs";
|
|
20
|
+
import { shouldPatchAccessTokenMerkleTree as B } from "../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs";
|
|
21
|
+
const pt = async (t, g, e, C, a, w, T, l = !1) => {
|
|
22
|
+
const o = g.map((r) => r.erc20TokenAddress);
|
|
23
|
+
let i;
|
|
24
|
+
a || (i = T ?? await z(t.getCurrentChainId(), w, o, K.Transact), _(t.getCurrentChainId(), o, e, i));
|
|
25
|
+
const c = g[0];
|
|
26
|
+
if (!c)
|
|
29
27
|
throw Error("Deposit Action: No Token Found");
|
|
30
|
-
const
|
|
28
|
+
const n = {
|
|
31
29
|
externalActionId: 0n,
|
|
32
|
-
externalAddress:
|
|
30
|
+
externalAddress: C,
|
|
33
31
|
externalActionMetadata: "0x00"
|
|
34
|
-
},
|
|
35
|
-
for (let
|
|
36
|
-
const { outputUtxos:
|
|
37
|
-
|
|
32
|
+
}, s = [...await M(t, o, e)], v = `swapperM${e.length.toString()}x${s[0].length}x1`, x = [], m = N(e.length, t.userKeys);
|
|
33
|
+
for (let r = 0; r < o.length; r += 1) {
|
|
34
|
+
const { outputUtxos: P } = F(
|
|
35
|
+
t.userKeys,
|
|
36
|
+
s[r],
|
|
37
|
+
e[r],
|
|
38
|
+
void 0,
|
|
39
|
+
void 0,
|
|
40
|
+
!1
|
|
41
|
+
);
|
|
42
|
+
x.push(P);
|
|
43
|
+
const { useApprovalUtxoData: A } = W(t, s[r], e[r]);
|
|
44
|
+
A && (m.useApprovalUtxoData[r] = A, m.doPreTxApproval = !0);
|
|
38
45
|
}
|
|
39
46
|
const f = await t.getRandomRelay();
|
|
40
47
|
if (!a && !f)
|
|
41
|
-
throw Error(
|
|
42
|
-
const {
|
|
48
|
+
throw Error(h.RELAYER_NOT_AVAILABLE);
|
|
49
|
+
const { patchAccessTokenMerkleTree: y, kycRequired: D, hasAccessToken: E } = await B(
|
|
50
|
+
t,
|
|
51
|
+
o,
|
|
52
|
+
e
|
|
53
|
+
), I = await q(
|
|
54
|
+
t.getCurrentChainId(),
|
|
55
|
+
await t.getEthereumAddress(),
|
|
56
|
+
t.userKeys,
|
|
57
|
+
D,
|
|
58
|
+
E
|
|
59
|
+
), { zkCallData: p, circomData: d, dimData: u } = await L(
|
|
60
|
+
"v1x1",
|
|
43
61
|
t.merkleTreeHinkal,
|
|
44
62
|
t.merkleTreeAccessToken,
|
|
45
|
-
|
|
46
|
-
|
|
63
|
+
s,
|
|
64
|
+
x,
|
|
47
65
|
t.userKeys,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
66
|
+
v,
|
|
67
|
+
n.externalActionId,
|
|
68
|
+
n.externalAddress,
|
|
69
|
+
n.externalActionMetadata,
|
|
52
70
|
t.generateProofRemotely,
|
|
53
|
-
a ?
|
|
71
|
+
a ? U : f,
|
|
54
72
|
t.getCurrentChainId(),
|
|
55
|
-
|
|
56
|
-
|
|
73
|
+
void 0,
|
|
74
|
+
void 0,
|
|
75
|
+
void 0,
|
|
76
|
+
void 0,
|
|
77
|
+
y,
|
|
78
|
+
m,
|
|
79
|
+
void 0,
|
|
80
|
+
i,
|
|
81
|
+
t.getContractWithFetcher($.HinkalHelperContract),
|
|
82
|
+
I
|
|
57
83
|
);
|
|
58
|
-
if (
|
|
59
|
-
return await
|
|
84
|
+
if (l)
|
|
85
|
+
return await R(t, p, u, d);
|
|
60
86
|
if (a) {
|
|
61
|
-
if (!
|
|
87
|
+
if (!c)
|
|
62
88
|
throw Error("Withdraw Action: No Token Found");
|
|
63
|
-
return await
|
|
89
|
+
return await S(t, e[0], c, p, d, u);
|
|
64
90
|
}
|
|
65
|
-
return await
|
|
91
|
+
return await H(t.getCurrentChainId(), p, u, d);
|
|
66
92
|
};
|
|
67
93
|
export {
|
|
68
|
-
|
|
94
|
+
pt as hinkalWithdraw
|
|
69
95
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../constants/chains.constants.cjs"),n=require("../../functions/web3/events/balanceChangedHandler.cjs");require("../../types/circom-data.types.cjs");const r=require("../../types/ethereum-network.types.cjs");require("../../constants/vite.constants.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("../../types/activities.types.cjs");const c=require("../snapshot/ClientAccessTokenSnapshotService.cjs"),o=require("../snapshot/ClientApprovalsSnapshotService.cjs"),i=require("../snapshot/ClientCommitmentsSnapshotService.cjs"),a=require("../snapshot/ClientNullifierSnapshotService.cjs"),S=async e=>{const{maxPageSize:t}=s.networkRegistry[e.getCurrentChainId()];e.commitmentsSnapshotService?.intervalClear(),e.commitmentsSnapshotService=new i.ClientCommitmentsSnapshotService(e.getContractWithFetcher(r.ContractType.HinkalContract),t),e.nullifierSnapshotService?.intervalClear(),e.nullifierSnapshotService=new a.ClientNullifierSnapshotService(e.getContractWithFetcher(r.ContractType.HinkalContract),t),e.accessTokenSnapshotService?.intervalClear(),e.accessTokenSnapshotService=new c.ClientAccessTokenSnapshotService(e.getContractWithFetcher(r.ContractType.AccessTokenContract),t),e.approvalsSnapshotService?.intervalClear(),e.approvalsSnapshotService=new o.ClientApprovalsSnapshotService(e.getContractWithFetcher(r.ContractType.HinkalContract),t),await Promise.all([e.commitmentsSnapshotService.init(),e.nullifierSnapshotService.init(),e.accessTokenSnapshotService.init(),e.approvalsSnapshotService.init()]),e.merkleTreeHinkal=e.commitmentsSnapshotService.merkleTree,e.merkleTreeAccessToken=e.accessTokenSnapshotService.merkleTree,e.nullifiers=e.nullifierSnapshotService.nullifiers,e.encryptedOutputs=e.commitmentsSnapshotService.encryptedOutputs,e.approvals=e.approvalsSnapshotService.approvals,e.commitmentsSnapshotService.onNewEvent=n.balanceChangedHandler,e.nullifierSnapshotService.onNewEvent=n.balanceChangedHandler};exports.resetMerkleTrees=S;
|
|
@@ -1,29 +1,36 @@
|
|
|
1
|
-
import { networkRegistry as
|
|
1
|
+
import { networkRegistry as c } from "../../constants/chains.constants.mjs";
|
|
2
2
|
import { balanceChangedHandler as o } from "../../functions/web3/events/balanceChangedHandler.mjs";
|
|
3
3
|
import "../../types/circom-data.types.mjs";
|
|
4
4
|
import { ContractType as r } from "../../types/ethereum-network.types.mjs";
|
|
5
|
+
import "../../constants/vite.constants.mjs";
|
|
5
6
|
import "../../types/transactions.types.mjs";
|
|
6
7
|
import "../../types/curve.types.mjs";
|
|
7
|
-
import
|
|
8
|
+
import "../../types/activities.types.mjs";
|
|
9
|
+
import { ClientAccessTokenSnapshotService as s } from "../snapshot/ClientAccessTokenSnapshotService.mjs";
|
|
10
|
+
import { ClientApprovalsSnapshotService as n } from "../snapshot/ClientApprovalsSnapshotService.mjs";
|
|
8
11
|
import { ClientCommitmentsSnapshotService as i } from "../snapshot/ClientCommitmentsSnapshotService.mjs";
|
|
9
|
-
import { ClientNullifierSnapshotService as
|
|
10
|
-
const
|
|
11
|
-
const { maxPageSize: t } =
|
|
12
|
+
import { ClientNullifierSnapshotService as p } from "../snapshot/ClientNullifierSnapshotService.mjs";
|
|
13
|
+
const h = async (e) => {
|
|
14
|
+
const { maxPageSize: t } = c[e.getCurrentChainId()];
|
|
12
15
|
e.commitmentsSnapshotService?.intervalClear(), e.commitmentsSnapshotService = new i(
|
|
13
16
|
e.getContractWithFetcher(r.HinkalContract),
|
|
14
17
|
t
|
|
15
|
-
), e.nullifierSnapshotService?.intervalClear(), e.nullifierSnapshotService = new
|
|
18
|
+
), e.nullifierSnapshotService?.intervalClear(), e.nullifierSnapshotService = new p(
|
|
16
19
|
e.getContractWithFetcher(r.HinkalContract),
|
|
17
20
|
t
|
|
18
|
-
), e.accessTokenSnapshotService?.intervalClear(), e.accessTokenSnapshotService = new
|
|
19
|
-
e.getContractWithFetcher(r.
|
|
21
|
+
), e.accessTokenSnapshotService?.intervalClear(), e.accessTokenSnapshotService = new s(
|
|
22
|
+
e.getContractWithFetcher(r.AccessTokenContract),
|
|
23
|
+
t
|
|
24
|
+
), e.approvalsSnapshotService?.intervalClear(), e.approvalsSnapshotService = new n(
|
|
25
|
+
e.getContractWithFetcher(r.HinkalContract),
|
|
20
26
|
t
|
|
21
27
|
), await Promise.all([
|
|
22
28
|
e.commitmentsSnapshotService.init(),
|
|
23
29
|
e.nullifierSnapshotService.init(),
|
|
24
|
-
e.accessTokenSnapshotService.init()
|
|
25
|
-
|
|
30
|
+
e.accessTokenSnapshotService.init(),
|
|
31
|
+
e.approvalsSnapshotService.init()
|
|
32
|
+
]), e.merkleTreeHinkal = e.commitmentsSnapshotService.merkleTree, e.merkleTreeAccessToken = e.accessTokenSnapshotService.merkleTree, e.nullifiers = e.nullifierSnapshotService.nullifiers, e.encryptedOutputs = e.commitmentsSnapshotService.encryptedOutputs, e.approvals = e.approvalsSnapshotService.approvals, e.commitmentsSnapshotService.onNewEvent = o, e.nullifierSnapshotService.onNewEvent = o;
|
|
26
33
|
};
|
|
27
34
|
export {
|
|
28
|
-
|
|
35
|
+
h as resetMerkleTrees
|
|
29
36
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("idb-keyval"),h=require("ethers");require("../../types/circom-data.types.cjs");require("../../constants/vite.constants.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");const y=require("../../types/activities.types.cjs");class S{STORAGE_KEY="tx-activity";generateTxId(){const t=new Date().getTime(),e=Math.random().toString(36).substring(2,15);return`tx_${t}_${e}`}async getTransactionRecord(){return await l.get(this.STORAGE_KEY)||{}}async saveTransactionRecord(t){await l.set(this.STORAGE_KEY,t)}async saveTxRequest(t){const{from:e,to:a,gas:i,gasPrice:s,value:n,chainId:o,status:c,txHash:r,activityType:u,tokensReceive:d,tokensSpend:m,ownerPublicAddress:v,activityIcon:w,dappUrl:p,integrationProvider:x}=t,g=this.generateTxId(),T=await this.getTransactionRecord(),R={id:g,from:e,to:a,gas:i,gasPrice:s,value:n,chainId:o,txHash:r,activityType:u,status:c??y.ActivityStatus.PENDING,timestamp:new Date,tokensReceive:d,tokensSpend:m,ownerPublicAddress:v,activityIcon:w,dappUrl:p,integrationProvider:x};return T[g]=R,console.log({record:T}),await this.saveTransactionRecord(T),g}async getTxRequest(t){return(await this.getTransactionRecord())[t]||null}async getAllTxRequests(t){const e=await this.getTransactionRecord();return Object.values(e).filter(a=>a.chainId===t).sort((a,i)=>new Date(i.timestamp).getTime()-new Date(a.timestamp).getTime())}async updateTxStatusAndHash(t,e,a,i,s,n,o,c){const r=await this.getTxRequest(t);if(!r)throw new Error("Transaction not found");const u=await this.getTransactionRecord(),d={...r,status:e,txHash:a,value:r.value??i,from:r.from??s,to:r.to??n,gas:o,gasPrice:c,timestamp:new Date};return u[t]=d,await this.saveTransactionRecord(u),d}async updateActivity(t,e,a,i,s,n,o,c){try{await this.updateTxStatusAndHash(t,e,a,i,s,n,o,c)}catch(r){console.log("error in updating tx request",r)}}async removePendingTransactions(t){try{const e=await this.getTransactionRecord();delete e[t],await this.saveTransactionRecord(e)}catch(e){console.log("error in deleting tx requests",e)}}async updatePendingTransactions(t,e){try{if(!t.success){await this.updateActivity(e,y.ActivityStatus.FAILED);return}if("tx"in t){const{tx:a}=t;await this.updateActivity(e,y.ActivityStatus.CONFIRMED,a.hash,h.BigNumber.from(a.value??0n).toHexString(),a.from,a.to,h.BigNumber.from(a.gas??0n),h.BigNumber.from(a.gasPrice??0n))}}catch(a){console.log("error in updating pending transactions",a)}}}const A=new S;exports.activityStorage=A;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Activity, ActivityAddRequest, SandboxResponse } from '../../types';
|
|
2
|
+
declare class ActivityStorage {
|
|
3
|
+
private readonly STORAGE_KEY;
|
|
4
|
+
private generateTxId;
|
|
5
|
+
private getTransactionRecord;
|
|
6
|
+
private saveTransactionRecord;
|
|
7
|
+
saveTxRequest(txRequest: ActivityAddRequest): Promise<string>;
|
|
8
|
+
private getTxRequest;
|
|
9
|
+
getAllTxRequests(chainId: number): Promise<Activity[]>;
|
|
10
|
+
private updateTxStatusAndHash;
|
|
11
|
+
private updateActivity;
|
|
12
|
+
removePendingTransactions(pendingActivityId: string): Promise<void>;
|
|
13
|
+
updatePendingTransactions(transactionResponse: SandboxResponse, pendingActivityId: string): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export declare const activityStorage: ActivityStorage;
|
|
16
|
+
export {};
|
|
@@ -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
|
+
};
|