@sabaaa1/common 0.1.6 → 0.1.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 +16 -12
- package/API/API.mjs +73 -69
- package/API/accessCodeCalls.cjs +1 -0
- package/API/accessCodeCalls.d.ts +23 -0
- package/API/accessCodeCalls.mjs +23 -0
- package/API/admin-calls.cjs +1 -1
- package/API/admin-calls.mjs +5 -7
- package/API/ai-calls.cjs +1 -1
- package/API/ai-calls.mjs +11 -10
- package/API/brotherhoodCalls.cjs +1 -1
- package/API/brotherhoodCalls.mjs +43 -69
- package/API/callLifiAPI.cjs +1 -1
- package/API/callLifiAPI.mjs +8 -7
- package/API/callOdosAPI.cjs +1 -1
- package/API/callOdosAPI.mjs +16 -16
- package/API/callOkxAPI.cjs +1 -0
- package/API/callOkxAPI.d.ts +10 -0
- package/API/callOkxAPI.mjs +13 -0
- package/API/callOneInchAPI.cjs +1 -1
- package/API/callOneInchAPI.mjs +8 -7
- package/API/callRelayer.cjs +1 -1
- package/API/callRelayer.d.ts +11 -0
- package/API/callRelayer.mjs +15 -7
- package/API/checkRisk.cjs +1 -1
- package/API/checkRisk.mjs +5 -4
- package/API/duneAPI.cjs +1 -1
- package/API/duneAPI.mjs +2 -3
- package/API/enclaveCalls.cjs +1 -1
- package/API/enclaveCalls.mjs +9 -11
- package/API/fetchCommitmentsCache.cjs +1 -1
- package/API/fetchCommitmentsCache.d.ts +2 -2
- package/API/fetchCommitmentsCache.mjs +13 -10
- package/API/generate-trading-points.cjs +1 -1
- package/API/generate-trading-points.mjs +34 -39
- package/API/get-token-data.cjs +1 -1
- package/API/get-token-data.mjs +5 -4
- package/API/getBridgeProtocols.cjs +1 -1
- package/API/getBridgeProtocols.mjs +4 -3
- package/API/getGasEstimates.cjs +1 -1
- package/API/getGasEstimates.d.ts +2 -1
- package/API/getGasEstimates.mjs +14 -16
- package/API/getLifiStatus.cjs +1 -1
- package/API/getLifiStatus.mjs +11 -10
- package/API/getRelayerURL.cjs +1 -1
- package/API/getRelayerURL.mjs +4 -4
- package/API/getServerURL.cjs +1 -1
- package/API/getServerURL.mjs +42 -36
- package/API/getTokenPrice.cjs +1 -1
- package/API/getTokenPrice.d.ts +0 -11
- package/API/getTokenPrice.mjs +8 -23
- package/API/getWebsiteURL.cjs +1 -1
- package/API/getWebsiteURL.d.ts +1 -1
- package/API/getWebsiteURL.mjs +6 -7
- package/API/index.d.ts +2 -1
- package/API/is-tx-stateless.cjs +1 -1
- package/API/is-tx-stateless.mjs +17 -22
- package/API/kycCalls.cjs +1 -1
- package/API/kycCalls.d.ts +2 -2
- package/API/kycCalls.mjs +31 -30
- package/API/leaderboardCalls.cjs +1 -1
- package/API/leaderboardCalls.mjs +11 -16
- package/API/proxyAccountsCalls.cjs +1 -1
- package/API/proxyAccountsCalls.mjs +19 -18
- package/API/referralsCalls.cjs +1 -1
- package/API/referralsCalls.mjs +16 -24
- package/API/relayCalls.cjs +1 -1
- package/API/relayCalls.mjs +6 -8
- package/API/resolve-sns.cjs +1 -0
- package/API/resolve-sns.d.ts +1 -0
- package/API/resolve-sns.mjs +12 -0
- package/API/restoreSnapshots.cjs +1 -1
- package/API/restoreSnapshots.mjs +5 -5
- package/API/rewardsUserCalls.cjs +1 -1
- package/API/rewardsUserCalls.mjs +37 -54
- package/API/seedless-calls.cjs +1 -0
- package/API/seedless-calls.d.ts +53 -0
- package/API/seedless-calls.mjs +12 -0
- package/API/send-telegram-callback.cjs +1 -1
- package/API/send-telegram-callback.mjs +9 -11
- package/API/simulate-batch-tx.cjs +1 -1
- package/API/simulate-batch-tx.mjs +11 -13
- package/API/solana-calls.cjs +1 -0
- package/API/solana-calls.d.ts +34 -0
- package/API/solana-calls.mjs +19 -0
- package/API/tenderly.api.cjs +1 -1
- package/API/tenderly.api.mjs +48 -59
- package/API/token-calls.cjs +1 -1
- package/API/token-calls.mjs +11 -13
- package/API/weeklyAnalyticCalls.cjs +1 -1
- package/API/weeklyAnalyticCalls.mjs +9 -14
- package/README.md +164 -0
- package/_virtual/_commonjsHelpers.cjs +1 -0
- package/_virtual/_commonjsHelpers.mjs +30 -0
- package/_virtual/bn.cjs +1 -0
- package/_virtual/bn.mjs +4 -0
- package/_virtual/bn2.cjs +1 -0
- package/_virtual/bn2.mjs +4 -0
- package/_virtual/common.cjs +1 -0
- package/_virtual/common.mjs +4 -0
- package/_virtual/common2.cjs +1 -0
- package/_virtual/common2.mjs +4 -0
- package/_virtual/hash.cjs +1 -0
- package/_virtual/hash.mjs +4 -0
- package/_virtual/index.cjs +1 -0
- package/_virtual/index.mjs +6 -0
- package/_virtual/index10.cjs +1 -0
- package/_virtual/index10.mjs +6 -0
- package/_virtual/index11.cjs +1 -0
- package/_virtual/index11.mjs +6 -0
- package/_virtual/index12.cjs +1 -0
- package/_virtual/index12.mjs +6 -0
- package/_virtual/index13.cjs +1 -0
- package/_virtual/index13.mjs +6 -0
- package/_virtual/index14.cjs +1 -0
- package/_virtual/index14.mjs +6 -0
- package/_virtual/index15.cjs +1 -0
- package/_virtual/index15.mjs +6 -0
- package/_virtual/index16.cjs +1 -0
- package/_virtual/index16.mjs +6 -0
- package/_virtual/index17.cjs +1 -0
- package/_virtual/index17.mjs +6 -0
- package/_virtual/index18.cjs +1 -0
- package/_virtual/index18.mjs +6 -0
- package/_virtual/index19.cjs +1 -0
- package/_virtual/index19.mjs +6 -0
- package/_virtual/index2.cjs +1 -0
- package/_virtual/index2.mjs +6 -0
- package/_virtual/index20.cjs +1 -0
- package/_virtual/index20.mjs +6 -0
- package/_virtual/index21.cjs +1 -0
- package/_virtual/index21.mjs +6 -0
- package/_virtual/index22.cjs +1 -0
- package/_virtual/index22.mjs +4 -0
- package/_virtual/index3.cjs +1 -0
- package/_virtual/index3.mjs +6 -0
- package/_virtual/index4.cjs +1 -0
- package/_virtual/index4.mjs +6 -0
- package/_virtual/index5.cjs +1 -0
- package/_virtual/index5.mjs +6 -0
- package/_virtual/index6.cjs +1 -0
- package/_virtual/index6.mjs +6 -0
- package/_virtual/index7.cjs +1 -0
- package/_virtual/index7.mjs +6 -0
- package/_virtual/index8.cjs +1 -0
- package/_virtual/index8.mjs +6 -0
- package/_virtual/index9.cjs +1 -0
- package/_virtual/index9.mjs +6 -0
- package/_virtual/inherits_browser.cjs +1 -0
- package/_virtual/inherits_browser.mjs +4 -0
- package/_virtual/ripemd.cjs +1 -0
- package/_virtual/ripemd.mjs +4 -0
- package/_virtual/scrypt.cjs +1 -0
- package/_virtual/scrypt.mjs +4 -0
- package/_virtual/sha.cjs +1 -0
- package/_virtual/sha.mjs +4 -0
- package/_virtual/sha3.cjs +1 -0
- package/_virtual/sha3.mjs +4 -0
- package/_virtual/utils.cjs +1 -0
- package/_virtual/utils.mjs +4 -0
- package/_virtual/utils2.cjs +1 -0
- package/_virtual/utils2.mjs +4 -0
- package/constants/backend.constants.cjs +1 -1
- package/constants/backend.constants.d.ts +2 -1
- package/constants/backend.constants.mjs +5 -7
- package/constants/chains.constants.cjs +1 -1
- package/constants/chains.constants.d.ts +5 -0
- package/constants/chains.constants.mjs +63 -35
- package/constants/coingecko.constants.cjs +1 -1
- package/constants/coingecko.constants.d.ts +1 -1
- package/constants/coingecko.constants.mjs +18 -11
- package/constants/contracts.constants.cjs +1 -1
- package/constants/contracts.constants.mjs +19 -15
- package/constants/deploy-data/deploy-data-arbMainnet.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-arbMainnet.json.mjs +1218 -8
- package/constants/deploy-data/deploy-data-arcTestnet.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-arcTestnet.json.mjs +1214 -4
- package/constants/deploy-data/deploy-data-base.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-base.json.mjs +1218 -8
- package/constants/deploy-data/deploy-data-ethMainnet.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-ethMainnet.json.mjs +1213 -3
- package/constants/deploy-data/deploy-data-optimism.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-optimism.json.mjs +1218 -8
- package/constants/deploy-data/deploy-data-polygon.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-polygon.json.mjs +1218 -8
- package/constants/deploy-data/deploy-data-solana.json.cjs +1 -0
- package/constants/deploy-data/deploy-data-solana.json.mjs +6111 -0
- package/constants/deploy-data/index.d.ts +2 -1
- package/constants/index.d.ts +1 -1
- package/constants/mediaUrls.constants.cjs +1 -1
- package/constants/mediaUrls.constants.d.ts +9 -0
- package/constants/mediaUrls.constants.mjs +13 -4
- package/constants/okx.constants.cjs +1 -0
- package/constants/okx.constants.d.ts +2 -0
- package/constants/okx.constants.mjs +5 -0
- package/constants/protocol.constants.cjs +1 -1
- package/constants/protocol.constants.d.ts +12 -1
- package/constants/protocol.constants.mjs +37 -29
- package/constants/save-depths.cjs +1 -1
- package/constants/save-depths.mjs +4 -1
- package/constants/server.constants.cjs +1 -1
- package/constants/server.constants.d.ts +23 -10
- package/constants/server.constants.mjs +102 -89
- package/constants/token-data/ERC20Registry.cjs +1 -1
- package/constants/token-data/ERC20Registry.mjs +49 -35
- package/constants/token-data/index.cjs +1 -1
- package/constants/token-data/index.d.ts +17 -1
- package/constants/token-data/index.mjs +29 -25
- package/constants/token-data/solanaLocalnetRegistry.json.cjs +1 -0
- package/constants/token-data/solanaLocalnetRegistry.json.mjs +24 -0
- package/constants/token-data/solanaMainnetRegistry.json.cjs +1 -0
- package/constants/token-data/solanaMainnetRegistry.json.mjs +560 -0
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.cjs +1 -1
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.mjs +41 -41
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +19 -10
- package/data-structures/Hinkal/Hinkal.mjs +290 -125
- package/data-structures/Hinkal/IHinkal.d.ts +18 -11
- package/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.mjs +36 -32
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.mjs +24 -23
- package/data-structures/Hinkal/hinkalActionReceive.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionReceive.mjs +13 -12
- package/data-structures/Hinkal/hinkalCheckSolanaTokenRegistry.cjs +1 -0
- package/data-structures/Hinkal/hinkalCheckSolanaTokenRegistry.d.ts +3 -0
- package/data-structures/Hinkal/hinkalCheckSolanaTokenRegistry.mjs +28 -0
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -1
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +11 -8
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -0
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.d.ts +4 -0
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +167 -0
- package/data-structures/Hinkal/hinkalGetRecipientInfo.cjs +1 -1
- package/data-structures/Hinkal/hinkalGetRecipientInfo.d.ts +1 -1
- package/data-structures/Hinkal/hinkalGetRecipientInfo.mjs +4 -4
- package/data-structures/Hinkal/hinkalMultiSend.cjs +1 -1
- package/data-structures/Hinkal/hinkalMultiSend.mjs +6 -6
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.d.ts +2 -2
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +109 -93
- package/data-structures/Hinkal/hinkalProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxySwap.mjs +23 -22
- package/data-structures/Hinkal/hinkalProxyToPrivate.cjs +1 -0
- package/data-structures/Hinkal/hinkalProxyToPrivate.d.ts +6 -0
- package/data-structures/Hinkal/hinkalProxyToPrivate.mjs +45 -0
- package/data-structures/Hinkal/hinkalSignSubAccount.cjs +1 -1
- package/data-structures/Hinkal/hinkalSignSubAccount.mjs +11 -9
- package/data-structures/Hinkal/hinkalSolanaDeposit.cjs +1 -0
- package/data-structures/Hinkal/hinkalSolanaDeposit.d.ts +4 -0
- package/data-structures/Hinkal/hinkalSolanaDeposit.mjs +133 -0
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -0
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.d.ts +3 -0
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +216 -0
- package/data-structures/Hinkal/hinkalSolanaProxySend.cjs +1 -0
- package/data-structures/Hinkal/hinkalSolanaProxySend.d.ts +6 -0
- package/data-structures/Hinkal/hinkalSolanaProxySend.mjs +55 -0
- package/data-structures/Hinkal/hinkalSolanaProxyShield.cjs +1 -0
- package/data-structures/Hinkal/hinkalSolanaProxyShield.d.ts +6 -0
- package/data-structures/Hinkal/hinkalSolanaProxyShield.mjs +99 -0
- package/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -0
- package/data-structures/Hinkal/hinkalSolanaProxySwap.d.ts +5 -0
- package/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +96 -0
- package/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -0
- package/data-structures/Hinkal/hinkalSolanaSwap.d.ts +4 -0
- package/data-structures/Hinkal/hinkalSolanaSwap.mjs +120 -0
- package/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -0
- package/data-structures/Hinkal/hinkalSolanaTransfer.d.ts +3 -0
- package/data-structures/Hinkal/hinkalSolanaTransfer.mjs +90 -0
- package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -0
- package/data-structures/Hinkal/hinkalSolanaWithdraw.d.ts +3 -0
- package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +106 -0
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +33 -27
- package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalTransfer.mjs +20 -14
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +15 -9
- package/data-structures/Hinkal/index.d.ts +4 -0
- package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.mjs +56 -23
- package/data-structures/IndexedDB/activity-db.cjs +1 -1
- package/data-structures/IndexedDB/activity-db.d.ts +0 -1
- package/data-structures/IndexedDB/activity-db.mjs +86 -86
- package/data-structures/IndexedDB/balances-db.cjs +1 -1
- package/data-structures/IndexedDB/balances-db.mjs +15 -12
- package/data-structures/IndexedDB/contact-db.cjs +1 -1
- package/data-structures/IndexedDB/contact-db.mjs +29 -26
- package/data-structures/IndexedDB/signatures-db.cjs +1 -1
- package/data-structures/IndexedDB/signatures-db.mjs +14 -10
- package/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs +1 -1
- package/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.d.ts +2 -2
- package/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.mjs +32 -31
- package/data-structures/TokenDBs/AlchemyPublicTokensDB.cjs +1 -1
- package/data-structures/TokenDBs/AlchemyPublicTokensDB.d.ts +6 -1
- package/data-structures/TokenDBs/AlchemyPublicTokensDB.mjs +154 -79
- package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +24 -21
- package/data-structures/TokenDBs/PrivateTokensDB.cjs +1 -1
- package/data-structures/TokenDBs/PrivateTokensDB.mjs +39 -34
- package/data-structures/crypto-keys/decodeUTXO.cjs +1 -1
- package/data-structures/crypto-keys/decodeUTXO.d.ts +15 -3
- package/data-structures/crypto-keys/decodeUTXO.mjs +84 -26
- package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
- package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +36 -30
- package/data-structures/crypto-keys/keys.cjs +1 -1
- package/data-structures/crypto-keys/keys.d.ts +19 -5
- package/data-structures/crypto-keys/keys.mjs +117 -60
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.cjs +1 -0
- package/data-structures/event-service/{AbstractAccessTokenSnapshotService.d.ts → evm/AbstractAccessTokenSnapshotService.d.ts} +2 -2
- package/data-structures/event-service/{AbstractAccessTokenSnapshotService.mjs → evm/AbstractAccessTokenSnapshotService.mjs} +6 -6
- package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.cjs +1 -0
- package/data-structures/event-service/{AbstractApprovalsSnapshotService.d.ts → evm/AbstractApprovalsSnapshotService.d.ts} +2 -2
- package/data-structures/event-service/{AbstractApprovalsSnapshotService.mjs → evm/AbstractApprovalsSnapshotService.mjs} +2 -2
- package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.cjs +1 -0
- package/data-structures/event-service/{AbstractCommitmentsSnapshotService.d.ts → evm/AbstractCommitmentsSnapshotService.d.ts} +3 -3
- package/data-structures/event-service/{AbstractCommitmentsSnapshotService.mjs → evm/AbstractCommitmentsSnapshotService.mjs} +24 -21
- package/data-structures/event-service/evm/AbstractEventService.cjs +1 -0
- package/data-structures/event-service/{AbstractEventService.d.ts → evm/AbstractEventService.d.ts} +1 -1
- package/data-structures/event-service/evm/AbstractEventService.mjs +37 -0
- package/data-structures/event-service/{AbstractNullifierSnapshotService.d.ts → evm/AbstractNullifierSnapshotService.d.ts} +1 -1
- package/data-structures/event-service/evm/AbstractSnapshotService.cjs +1 -0
- package/data-structures/event-service/{AbstractSnapshotService.mjs → evm/AbstractSnapshotService.mjs} +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -0
- package/data-structures/event-service/{BlockchainEventEmitter.d.ts → evm/BlockchainEventEmitter.d.ts} +2 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.mjs +89 -0
- package/data-structures/event-service/index.d.ts +13 -7
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.cjs +1 -0
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.d.ts +34 -0
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.mjs +87 -0
- package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.cjs +1 -0
- package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.d.ts +29 -0
- package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.mjs +96 -0
- package/data-structures/event-service/solana/AbstractSolanaEventService.cjs +1 -0
- package/data-structures/event-service/solana/AbstractSolanaEventService.d.ts +22 -0
- package/data-structures/event-service/solana/AbstractSolanaEventService.mjs +33 -0
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.cjs +1 -0
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.d.ts +21 -0
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.mjs +49 -0
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.cjs +1 -0
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.d.ts +22 -0
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.mjs +33 -0
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.cjs +1 -0
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.d.ts +39 -0
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.mjs +153 -0
- package/data-structures/http/BasicHttpClient.cjs +1 -0
- package/data-structures/http/BasicHttpClient.d.ts +11 -0
- package/data-structures/http/BasicHttpClient.mjs +25 -0
- package/data-structures/http/HttpClient.cjs +1 -0
- package/data-structures/http/HttpClient.d.ts +10 -0
- package/data-structures/http/HttpClient.mjs +15 -0
- package/data-structures/http/index.d.ts +2 -0
- package/data-structures/index.d.ts +1 -0
- package/data-structures/provider-adapter/IProviderAdapter.d.ts +1 -3
- package/data-structures/snapshot/SnapshotFetcherService.d.ts +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs +1 -0
- package/data-structures/snapshot/{ClientAccessTokenSnapshotService.d.ts → evm-snapshots/ClientAccessTokenSnapshotService.d.ts} +2 -2
- package/data-structures/snapshot/{ClientAccessTokenSnapshotService.mjs → evm-snapshots/ClientAccessTokenSnapshotService.mjs} +13 -9
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -0
- package/data-structures/snapshot/{ClientApprovalsSnapshotService.d.ts → evm-snapshots/ClientApprovalsSnapshotService.d.ts} +2 -3
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +43 -0
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.cjs +1 -0
- package/data-structures/snapshot/{ClientCommitmentsSnapshotService.d.ts → evm-snapshots/ClientCommitmentsSnapshotService.d.ts} +2 -2
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.mjs +35 -0
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.cjs +1 -0
- package/data-structures/snapshot/{ClientNullifierSnapshotService.d.ts → evm-snapshots/ClientNullifierSnapshotService.d.ts} +2 -2
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.mjs +34 -0
- package/data-structures/snapshot/index.d.ts +7 -0
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.cjs +1 -0
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.d.ts +8 -0
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.mjs +42 -0
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.cjs +1 -0
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.d.ts +8 -0
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.mjs +34 -0
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.cjs +1 -0
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.d.ts +8 -0
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.mjs +34 -0
- package/data-structures/token-price-fetcher/TokenChecker.cjs +1 -1
- package/data-structures/token-price-fetcher/TokenChecker.mjs +5 -4
- package/data-structures/utxo/Utxo.cjs +1 -1
- package/data-structures/utxo/Utxo.d.ts +6 -1
- package/data-structures/utxo/Utxo.mjs +37 -24
- package/error-handling/error-codes.constants.cjs +1 -1
- package/error-handling/error-codes.constants.d.ts +2 -0
- package/error-handling/error-codes.constants.mjs +4 -2
- package/functions/connectors.types.d.ts +14 -0
- package/functions/index.d.ts +1 -0
- package/functions/pre-transaction/addressTableLookup.cjs +1 -0
- package/functions/pre-transaction/addressTableLookup.d.ts +4 -0
- package/functions/pre-transaction/addressTableLookup.mjs +44 -0
- package/functions/pre-transaction/constructAdminData.cjs +1 -1
- package/functions/pre-transaction/constructAdminData.d.ts +2 -1
- package/functions/pre-transaction/constructAdminData.mjs +30 -12
- package/functions/pre-transaction/convert-okx-instructions.cjs +1 -0
- package/functions/pre-transaction/convert-okx-instructions.d.ts +12 -0
- package/functions/pre-transaction/convert-okx-instructions.mjs +30 -0
- package/functions/pre-transaction/getSolanaCalldataHash.cjs +1 -0
- package/functions/pre-transaction/getSolanaCalldataHash.d.ts +4 -0
- package/functions/pre-transaction/getSolanaCalldataHash.mjs +36 -0
- package/functions/pre-transaction/getVolatileTransferAmount.cjs +1 -1
- package/functions/pre-transaction/getVolatileTransferAmount.mjs +11 -7
- package/functions/pre-transaction/index.d.ts +10 -0
- package/functions/pre-transaction/initTokenLimitIfNeeded.cjs +1 -0
- package/functions/pre-transaction/initTokenLimitIfNeeded.d.ts +3 -0
- package/functions/pre-transaction/initTokenLimitIfNeeded.mjs +20 -0
- package/functions/pre-transaction/outputUtxoProcessing.cjs +1 -1
- package/functions/pre-transaction/outputUtxoProcessing.mjs +14 -13
- 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 +13 -12
- package/functions/pre-transaction/recipientUtxoProcessing.cjs +1 -0
- package/functions/pre-transaction/recipientUtxoProcessing.d.ts +3 -0
- package/functions/pre-transaction/recipientUtxoProcessing.mjs +36 -0
- package/functions/pre-transaction/sendInitNullifiersTransaction.cjs +1 -0
- package/functions/pre-transaction/sendInitNullifiersTransaction.d.ts +11 -0
- package/functions/pre-transaction/sendInitNullifiersTransaction.mjs +41 -0
- package/functions/pre-transaction/sendV0Transaction.cjs +1 -0
- package/functions/pre-transaction/sendV0Transaction.d.ts +22 -0
- package/functions/pre-transaction/sendV0Transaction.mjs +121 -0
- package/functions/pre-transaction/solana-public-signals.cjs +1 -0
- package/functions/pre-transaction/solana-public-signals.d.ts +19 -0
- package/functions/pre-transaction/solana-public-signals.mjs +60 -0
- package/functions/pre-transaction/solana.cjs +1 -0
- package/functions/pre-transaction/solana.d.ts +17 -0
- package/functions/pre-transaction/solana.mjs +96 -0
- package/functions/pre-transaction/solanaTransfer.utils.cjs +1 -0
- package/functions/pre-transaction/solanaTransfer.utils.d.ts +6 -0
- package/functions/pre-transaction/solanaTransfer.utils.mjs +38 -0
- package/functions/pre-transaction/store-instructions.cjs +1 -0
- package/functions/pre-transaction/store-instructions.d.ts +4 -0
- package/functions/pre-transaction/store-instructions.mjs +9 -0
- package/functions/pre-transaction/store-proof.cjs +1 -0
- package/functions/pre-transaction/store-proof.d.ts +7 -0
- package/functions/pre-transaction/store-proof.mjs +55 -0
- package/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.helpers.mjs +33 -29
- package/functions/private-wallet/emporium.swap.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.swap.helpers.d.ts +1 -1
- package/functions/private-wallet/emporium.swap.helpers.mjs +79 -69
- package/functions/snarkjs/constant.cjs +1 -1
- package/functions/snarkjs/constant.d.ts +40 -0
- package/functions/snarkjs/constant.mjs +66 -23
- package/functions/snarkjs/constructEmporiumProof.cjs +1 -1
- package/functions/snarkjs/constructEmporiumProof.mjs +32 -32
- package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
- package/functions/snarkjs/constructGeneralZkProof.d.ts +1 -1
- package/functions/snarkjs/constructGeneralZkProof.mjs +63 -61
- package/functions/snarkjs/constructSolanaZkProof.cjs +1 -0
- package/functions/snarkjs/constructSolanaZkProof.d.ts +13 -0
- package/functions/snarkjs/constructSolanaZkProof.mjs +109 -0
- package/functions/snarkjs/generateCircomData.cjs +1 -1
- package/functions/snarkjs/generateCircomData.d.ts +1 -1
- package/functions/snarkjs/generateCircomData.mjs +9 -9
- package/functions/snarkjs/generateZkProofEnclave.cjs +1 -1
- package/functions/snarkjs/generateZkProofEnclave.mjs +10 -9
- package/functions/snarkjs/getZKFiles.cjs +1 -1
- package/functions/snarkjs/getZKFiles.mjs +13 -13
- package/functions/snarkjs/index.d.ts +1 -0
- package/functions/utils/addresses.cjs +1 -1
- package/functions/utils/addresses.d.ts +1 -1
- package/functions/utils/addresses.mjs +21 -17
- package/functions/utils/amounts.utils.cjs +1 -1
- package/functions/utils/amounts.utils.d.ts +1 -0
- package/functions/utils/amounts.utils.mjs +53 -40
- package/functions/utils/bytes32.utils.cjs +1 -0
- package/functions/utils/bytes32.utils.d.ts +2 -0
- package/functions/utils/bytes32.utils.mjs +10 -0
- package/functions/utils/cacheDevice.utils.cjs +1 -1
- package/functions/utils/cacheDevice.utils.mjs +2 -3
- package/functions/utils/cacheFunctions.cjs +1 -1
- package/functions/utils/cacheFunctions.mjs +53 -52
- package/functions/utils/convertIntegrationProviderToExternalActionId.cjs +1 -1
- package/functions/utils/convertIntegrationProviderToExternalActionId.mjs +1 -0
- package/functions/utils/create-provider.cjs +1 -1
- package/functions/utils/create-provider.d.ts +4 -1
- package/functions/utils/create-provider.mjs +8 -6
- package/functions/utils/encodeTokenWithId.cjs +1 -1
- package/functions/utils/encodeTokenWithId.d.ts +1 -1
- package/functions/utils/encodeTokenWithId.mjs +6 -2
- package/functions/utils/encryptInputForEnclave.cjs +1 -1
- package/functions/utils/encryptInputForEnclave.mjs +29 -28
- package/functions/utils/erc20tokenFunctions.cjs +1 -1
- package/functions/utils/erc20tokenFunctions.mjs +29 -29
- package/functions/utils/ethers-formatter.utils.cjs +1 -1
- package/functions/utils/ethers-formatter.utils.d.ts +2 -0
- package/functions/utils/ethers-formatter.utils.mjs +45 -15
- package/functions/utils/evmNetworkFunctions.cjs +1 -1
- package/functions/utils/evmNetworkFunctions.mjs +3 -4
- package/functions/utils/fees.utils.cjs +1 -1
- package/functions/utils/fees.utils.d.ts +1 -0
- package/functions/utils/fees.utils.mjs +19 -9
- package/functions/utils/get-hinkal-approvals.cjs +1 -1
- package/functions/utils/get-hinkal-approvals.mjs +1 -1
- package/functions/utils/getBlockExplorerUrl.cjs +1 -1
- package/functions/utils/getBlockExplorerUrl.mjs +2 -2
- package/functions/utils/getRecipientInfoFromUserKeys.cjs +1 -1
- package/functions/utils/getRecipientInfoFromUserKeys.d.ts +0 -1
- package/functions/utils/getRecipientInfoFromUserKeys.mjs +10 -13
- package/functions/utils/getUtxosFromReceipt.utils.cjs +1 -0
- package/functions/utils/getUtxosFromReceipt.utils.d.ts +4 -0
- package/functions/utils/getUtxosFromReceipt.utils.mjs +29 -0
- package/functions/utils/getUtxosFromReceiptSolana.cjs +1 -0
- package/functions/utils/getUtxosFromReceiptSolana.d.ts +5 -0
- package/functions/utils/getUtxosFromReceiptSolana.mjs +19 -0
- package/functions/utils/index.d.ts +5 -1
- package/functions/utils/networks.utils.cjs +1 -1
- package/functions/utils/networks.utils.mjs +2 -3
- package/functions/utils/nftTokenFunctions.cjs +1 -1
- package/functions/utils/nftTokenFunctions.mjs +8 -4
- package/functions/utils/prepareHinkal.cjs +1 -0
- package/functions/utils/prepareHinkal.d.ts +7 -1
- package/functions/utils/prepareHinkal.mjs +88 -0
- package/functions/utils/publicBalance.utils.cjs +1 -1
- package/functions/utils/publicBalance.utils.d.ts +1 -0
- package/functions/utils/publicBalance.utils.mjs +75 -45
- package/functions/utils/solanaMint.utils.cjs +1 -0
- package/functions/utils/solanaMint.utils.d.ts +10 -0
- package/functions/utils/solanaMint.utils.mjs +14 -0
- package/functions/utils/time.utils.cjs +1 -1
- package/functions/utils/time.utils.d.ts +1 -1
- package/functions/utils/time.utils.mjs +11 -11
- package/functions/utils/userAgent.cjs +1 -1
- package/functions/utils/userAgent.mjs +6 -7
- package/functions/utils/walletBalances.utils.cjs +1 -1
- package/functions/utils/walletBalances.utils.d.ts +2 -1
- package/functions/utils/walletBalances.utils.mjs +18 -17
- package/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
- package/functions/web3/events/getInputUtxoAndBalance.mjs +98 -91
- package/functions/web3/events/getInputUtxosEnclave.cjs +1 -1
- package/functions/web3/events/getInputUtxosEnclave.mjs +38 -16
- package/functions/web3/events/getShieldedBalance.cjs +2 -2
- package/functions/web3/events/getShieldedBalance.mjs +70 -62
- package/functions/web3/events/getTransactionLogEvents.cjs +1 -1
- package/functions/web3/events/getTransactionLogEvents.d.ts +3 -2
- package/functions/web3/events/getTransactionLogEvents.mjs +12 -9
- package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -0
- package/functions/web3/fetchSolanaMerkleTreeRootHash.d.ts +4 -0
- package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +45 -0
- package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
- package/functions/web3/functionCalls/accessTokenCalls.d.ts +2 -0
- package/functions/web3/functionCalls/accessTokenCalls.mjs +25 -7
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.d.ts +20 -0
- package/functions/web3/functionCalls/transactCallRelayer.mjs +61 -19
- package/functions/web3/getContractMetadata.cjs +1 -1
- package/functions/web3/getContractMetadata.mjs +20 -50
- package/functions/web3/getTokenHolder.cjs +1 -1
- package/functions/web3/getTokenHolder.mjs +29 -24
- package/functions/web3/index.d.ts +2 -0
- package/functions/web3/odosAPI.cjs +1 -1
- package/functions/web3/odosAPI.mjs +11 -8
- package/functions/web3/okxAPI.cjs +1 -0
- package/functions/web3/okxAPI.d.ts +8 -0
- package/functions/web3/okxAPI.mjs +43 -0
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.mjs +7 -4
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.mjs +22 -18
- package/functions/web3/signAndSendSerializedTransaction.cjs +1 -0
- package/functions/web3/signAndSendSerializedTransaction.d.ts +2 -0
- package/functions/web3/signAndSendSerializedTransaction.mjs +11 -0
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.mjs +7 -4
- package/index.cjs +1 -1
- package/index.mjs +922 -810
- package/package.json +12 -16
- package/providers/CustomEthersProvider.cjs +1 -0
- package/providers/{TorExternalProvider.d.ts → CustomEthersProvider.d.ts} +2 -2
- package/providers/CustomEthersProvider.mjs +29 -0
- package/providers/CustomSolanaConnection.cjs +1 -0
- package/providers/CustomSolanaConnection.d.ts +4 -0
- package/providers/CustomSolanaConnection.mjs +33 -0
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.d.ts +1 -2
- package/providers/EthersProviderAdapter.mjs +8 -48
- package/providers/SolanaProviderAdapter.cjs +1 -0
- package/providers/SolanaProviderAdapter.d.ts +44 -0
- package/providers/SolanaProviderAdapter.mjs +125 -0
- package/providers/WagmiProviderAdapter.cjs +1 -1
- package/providers/WagmiProviderAdapter.d.ts +1 -2
- package/providers/WagmiProviderAdapter.mjs +26 -24
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +10 -7
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +9 -6
- package/types/IMultiThreadedUtxoUtils.d.ts +2 -2
- package/types/TransactionSimulator.types.d.ts +1 -0
- package/types/activities.types.cjs +1 -1
- package/types/activities.types.d.ts +1 -0
- package/types/activities.types.mjs +6 -4
- package/types/admin.types.cjs +1 -1
- package/types/admin.types.d.ts +16 -0
- package/types/admin.types.mjs +1 -1
- package/types/all-points.types.d.ts +0 -1
- package/types/cache.types.cjs +1 -1
- package/types/cache.types.d.ts +8 -1
- package/types/cache.types.mjs +1 -1
- package/types/circom-data.types.d.ts +6 -0
- package/types/commitments.types.d.ts +12 -0
- package/types/ethereum-network.types.cjs +1 -1
- package/types/ethereum-network.types.d.ts +9 -3
- package/types/ethereum-network.types.mjs +1 -1
- package/types/external-action.types.cjs +1 -1
- package/types/external-action.types.d.ts +3 -1
- package/types/external-action.types.mjs +2 -2
- package/types/hinkal.types.cjs +1 -1
- package/types/hinkal.types.d.ts +3 -2
- package/types/hinkal.types.mjs +8 -8
- package/types/http.types.d.ts +8 -0
- package/types/index.d.ts +3 -2
- package/types/new-rewards.type.d.ts +2 -9
- package/types/offscreen.types.cjs +1 -1
- package/types/offscreen.types.d.ts +2 -1
- package/types/offscreen.types.mjs +2 -2
- package/types/okx.types.d.ts +57 -0
- package/types/rewards.types.d.ts +0 -11
- package/types/sandbox.types.cjs +1 -1
- package/types/sandbox.types.d.ts +19 -2
- package/types/sandbox.types.mjs +2 -2
- package/types/solana.types.d.ts +75 -0
- package/types/token.types.d.ts +6 -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.d.ts +0 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLogic.mjs +28 -30
- package/webworker/utxoWorker/utxoWorker.types.d.ts +2 -0
- 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 +33 -31
- package/webworker/viteWorkerURL.constant.cjs +21 -1
- package/webworker/viteWorkerURL.constant.mjs +21 -12
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
- package/API/mysteryBoxesCalls.cjs +0 -1
- package/API/mysteryBoxesCalls.d.ts +0 -60
- package/API/mysteryBoxesCalls.mjs +0 -66
- package/assets/snarkjsWorkerLauncher-CWaDqRaL.js +0 -14803
- package/assets/utxoWorkerLauncher-BUhBaUSg.js +0 -115868
- package/assets/zkProofWorkerLauncher-DlWQP3l9.js +0 -115360
- package/constants/mystery-boxes.constants.cjs +0 -1
- package/constants/mystery-boxes.constants.d.ts +0 -63
- package/constants/mystery-boxes.constants.mjs +0 -355
- package/data-structures/event-service/AbstractAccessTokenSnapshotService.cjs +0 -1
- package/data-structures/event-service/AbstractApprovalsSnapshotService.cjs +0 -1
- package/data-structures/event-service/AbstractCommitmentsSnapshotService.cjs +0 -1
- package/data-structures/event-service/AbstractEventService.cjs +0 -1
- package/data-structures/event-service/AbstractEventService.mjs +0 -33
- package/data-structures/event-service/AbstractSnapshotService.cjs +0 -1
- package/data-structures/event-service/BlockchainEventEmitter.cjs +0 -1
- package/data-structures/event-service/BlockchainEventEmitter.mjs +0 -80
- package/data-structures/snapshot/ClientAccessTokenSnapshotService.cjs +0 -1
- package/data-structures/snapshot/ClientApprovalsSnapshotService.cjs +0 -1
- package/data-structures/snapshot/ClientApprovalsSnapshotService.mjs +0 -23
- package/data-structures/snapshot/ClientCommitmentsSnapshotService.cjs +0 -1
- package/data-structures/snapshot/ClientCommitmentsSnapshotService.mjs +0 -31
- package/data-structures/snapshot/ClientNullifierSnapshotService.cjs +0 -1
- package/data-structures/snapshot/ClientNullifierSnapshotService.mjs +0 -30
- package/functions/utils/mystery-box-auction.utils.cjs +0 -1
- package/functions/utils/mystery-box-auction.utils.d.ts +0 -8
- package/functions/utils/mystery-box-auction.utils.mjs +0 -51
- package/providers/TorExternalProvider.cjs +0 -1
- package/providers/TorExternalProvider.mjs +0 -29
- package/types/merch-order.types.cjs +0 -1
- package/types/merch-order.types.d.ts +0 -16
- package/types/merch-order.types.mjs +0 -4
- package/types/mystery-boxes.types.cjs +0 -1
- package/types/mystery-boxes.types.d.ts +0 -43
- package/types/mystery-boxes.types.mjs +0 -6
- /package/data-structures/event-service/{AbstractNullifierSnapshotService.cjs → evm/AbstractNullifierSnapshotService.cjs} +0 -0
- /package/data-structures/event-service/{AbstractNullifierSnapshotService.mjs → evm/AbstractNullifierSnapshotService.mjs} +0 -0
- /package/data-structures/event-service/{AbstractSnapshotService.d.ts → evm/AbstractSnapshotService.d.ts} +0 -0
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import { utils as
|
|
2
|
-
import
|
|
3
|
-
import { CIRCOM_P as
|
|
4
|
-
import { babyJubInstance as
|
|
5
|
-
import { poseidonHash as
|
|
6
|
-
import { getCircomSign as
|
|
7
|
-
import { AttachableMemoryCacheDevice as
|
|
8
|
-
import { ethers as
|
|
9
|
-
import { networkRegistry as
|
|
10
|
-
|
|
1
|
+
import { utils as o, ethers as d } from "ethers";
|
|
2
|
+
import w from "libsodium-wrappers";
|
|
3
|
+
import { CIRCOM_P as m } from "../../constants/protocol.constants.mjs";
|
|
4
|
+
import { babyJubInstance as b } from "../../crypto/babyJub.mjs";
|
|
5
|
+
import { poseidonHash as c } from "../../crypto/poseidon.mjs";
|
|
6
|
+
import { getCircomSign as y } from "./keyUtils.mjs";
|
|
7
|
+
import { AttachableMemoryCacheDevice as v } from "../cacheDevices/AttachableMemoryCacheDevice.mjs";
|
|
8
|
+
import { ethers as u, hexlify as F } from "ethers-v6h";
|
|
9
|
+
import { isSolanaLike as h, networkRegistry as p } from "../../constants/chains.constants.mjs";
|
|
10
|
+
import { Keypair as g, VersionedTransaction as K } from "@solana/web3.js";
|
|
11
|
+
import k from "tweetnacl";
|
|
12
|
+
import P from "bs58";
|
|
13
|
+
import { createCustomSolanaConnection as A } from "../../functions/utils/create-provider.mjs";
|
|
14
|
+
const E = new v(), R = new v(), L = {
|
|
11
15
|
privateKey: "",
|
|
12
16
|
publicKey: ""
|
|
13
17
|
};
|
|
14
|
-
class
|
|
18
|
+
class l {
|
|
15
19
|
signature;
|
|
16
20
|
constructor(e) {
|
|
17
21
|
this.signature = e;
|
|
@@ -27,80 +31,133 @@ class D {
|
|
|
27
31
|
throw Error("No signature provided");
|
|
28
32
|
}
|
|
29
33
|
verifyMessage(e) {
|
|
30
|
-
return this.requireSignature(),
|
|
34
|
+
return this.requireSignature(), o.verifyMessage(e, this.signature);
|
|
31
35
|
}
|
|
32
36
|
/**
|
|
33
37
|
* get shielded private key from message signature used to login to the application,
|
|
34
38
|
* this private key is used to generate encryption keypairs as well as public key
|
|
35
39
|
* @retuns 0x-prefixed shielded private key
|
|
36
40
|
*/
|
|
37
|
-
getShieldedPrivateKey = () => (this.requireSignature(),
|
|
41
|
+
getShieldedPrivateKey = () => (this.requireSignature(), d.utils.keccak256(this.signature));
|
|
38
42
|
/**
|
|
39
43
|
* generate shielded public key from private key
|
|
40
44
|
* @param privateKey the key used to generate the shielded public key, this should be the signature
|
|
41
45
|
* that the user provided
|
|
42
46
|
* @retuns shielded public key in hexstring with 0x prefixed
|
|
43
47
|
*/
|
|
44
|
-
getShieldedPublicKey = () => (this.requireSignature(),
|
|
48
|
+
getShieldedPublicKey = () => (this.requireSignature(), c(this.getShieldedPrivateKey()));
|
|
49
|
+
/**
|
|
50
|
+
* deterministically derive an EVM address from the shielded private key
|
|
51
|
+
*/
|
|
52
|
+
getDerivedEthereumAddress = () => (this.requireSignature(), new u.Wallet(this.getShieldedPrivateKey()).address);
|
|
53
|
+
/**
|
|
54
|
+
* deterministically derive a Solana public key from the shielded private key
|
|
55
|
+
*/
|
|
56
|
+
getDerivedSolanaPublicKey = () => (this.requireSignature(), g.fromSeed(o.arrayify(this.getShieldedPrivateKey())).publicKey.toBase58());
|
|
45
57
|
/**
|
|
46
58
|
* generate access token, this accessKey is what should be sent to the server for signing
|
|
47
59
|
* @returns accessKey in hexstring with 0x prefixed
|
|
48
60
|
*/
|
|
49
|
-
getAccessKey = () => (this.requireSignature(),
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
61
|
+
getAccessKey = () => (this.requireSignature(), c(this.getShieldedPrivateKey(), this.getShieldedPublicKey()));
|
|
62
|
+
getSignerPrivateKeyFromNonce = (e) => {
|
|
63
|
+
this.requireSignature();
|
|
64
|
+
const r = c(e, this.getShieldedPrivateKey(), this.getShieldedPublicKey());
|
|
65
|
+
return o.keccak256(o.toUtf8Bytes(r));
|
|
66
|
+
};
|
|
67
|
+
getSignerSolanaPrivateKeyFromNonce = (e) => {
|
|
68
|
+
const r = this.getSignerPrivateKeyFromNonce(e), t = o.arrayify(r), i = g.fromSeed(t);
|
|
69
|
+
return P.encode(i.secretKey);
|
|
70
|
+
};
|
|
71
|
+
getEvmPrivateKeyFromSolanaPrivateKey = (e) => {
|
|
72
|
+
const t = P.decode(e).slice(0, 32);
|
|
73
|
+
return F(t);
|
|
74
|
+
};
|
|
75
|
+
static getSignerFromPrivateKey = (e, r) => {
|
|
76
|
+
if (h(e)) {
|
|
77
|
+
const i = o.arrayify(r);
|
|
78
|
+
return g.fromSeed(i);
|
|
79
|
+
}
|
|
80
|
+
return new u.Wallet(r);
|
|
81
|
+
};
|
|
82
|
+
static getSignerAddressFromPrivateKey(e, r) {
|
|
83
|
+
const t = l.getSignerFromPrivateKey(e, r);
|
|
84
|
+
return t instanceof g ? t.publicKey.toString() : t.address;
|
|
70
85
|
}
|
|
71
|
-
|
|
86
|
+
static signMessageFromPrivateKey = async (e, r, t) => {
|
|
87
|
+
const i = l.getSignerFromPrivateKey(e, r);
|
|
88
|
+
if (i instanceof g) {
|
|
89
|
+
const a = o.isHexString(t) ? o.arrayify(t) : new TextEncoder().encode(t), s = k.sign.detached(a, i.secretKey);
|
|
90
|
+
return `0x${Buffer.from(s).toString("hex")}`;
|
|
91
|
+
}
|
|
92
|
+
const n = o.isHexString(t) ? o.arrayify(t) : t;
|
|
93
|
+
return i.signMessage(n);
|
|
94
|
+
};
|
|
95
|
+
static signSolanaTransactionFromPrivateKey = (e, r, t) => {
|
|
96
|
+
if (!h(e))
|
|
97
|
+
throw new Error("Solana transaction signing is only available for Solana chains");
|
|
98
|
+
const i = l.getSignerFromPrivateKey(e, r);
|
|
99
|
+
if (!(i instanceof g))
|
|
100
|
+
throw new Error("Unable to derive Solana keypair for signing");
|
|
101
|
+
t.sign([i]);
|
|
102
|
+
};
|
|
103
|
+
static sendAndSignTransactionFromPrivateKey = async (e, r, t) => {
|
|
104
|
+
const i = l.getSignerFromPrivateKey(e, r), { fetchRpcUrl: n } = p[e];
|
|
105
|
+
if (!n)
|
|
106
|
+
throw new Error("No RPC URL found for chainId");
|
|
107
|
+
if (i instanceof g) {
|
|
108
|
+
if (!(t instanceof K))
|
|
109
|
+
throw new Error("Invalid transaction type for Solana");
|
|
110
|
+
return t.sign([i]), await A(n).sendRawTransaction(t.serialize());
|
|
111
|
+
}
|
|
112
|
+
if (t instanceof K)
|
|
113
|
+
throw new Error("Invalid transaction type for EVM");
|
|
114
|
+
const a = new u.JsonRpcProvider(n);
|
|
115
|
+
return (await i.connect(a).sendTransaction(t)).hash;
|
|
116
|
+
};
|
|
117
|
+
static signTypedDataFromPrivateKey = async (e, r, t, i, n) => {
|
|
118
|
+
if (h(e))
|
|
119
|
+
throw new Error("Solana does not support typed data");
|
|
120
|
+
return await l.getSignerFromPrivateKey(e, r).signTypedData(t, i, n);
|
|
121
|
+
};
|
|
122
|
+
static authorizeDelegation = async (e, r, t, i) => {
|
|
123
|
+
if (h(e))
|
|
124
|
+
throw new Error("Solana does not support delegation");
|
|
125
|
+
const n = new u.JsonRpcProvider(p[e].fetchRpcUrl);
|
|
126
|
+
return await l.getSignerFromPrivateKey(e, r).connect(n).authorize({ address: t, ...i !== void 0 && { nonce: i } });
|
|
127
|
+
};
|
|
128
|
+
getWalletSalt = (e) => (this.requireSignature(), c(this.getShieldedPublicKey(), this.getShieldedPrivateKey(), e));
|
|
72
129
|
/**
|
|
73
130
|
* generate inHinkalAddress - a user unique address linking him with a specific app
|
|
74
131
|
* @returns inHinkalAddress in bigint
|
|
75
132
|
*/
|
|
76
133
|
getInHinkalAddress = (e) => {
|
|
77
134
|
this.requireSignature();
|
|
78
|
-
const
|
|
79
|
-
return BigInt(
|
|
135
|
+
const r = c(this.getShieldedPrivateKey(), e);
|
|
136
|
+
return BigInt(r);
|
|
80
137
|
};
|
|
81
138
|
/**
|
|
82
139
|
* generate backend token, which is used for access control on backend
|
|
83
140
|
* @returns accessKey in hexstring with 0x prefixed
|
|
84
141
|
*/
|
|
85
|
-
getBackendToken = () => (this.requireSignature(),
|
|
86
|
-
static getRandomizedStealthPair =
|
|
87
|
-
(e,
|
|
88
|
-
const
|
|
89
|
-
return { H0:
|
|
142
|
+
getBackendToken = () => (this.requireSignature(), c(this.getAccessKey(), this.getShieldedPublicKey()));
|
|
143
|
+
static getRandomizedStealthPair = E.attach(
|
|
144
|
+
(e, r) => {
|
|
145
|
+
const t = b(), i = BigInt(r) % m, n = e * i % m, a = t.mulPointEscalar(t.Base8, e), s = t.mulPointEscalar(t.Base8, n), S = [BigInt(t.F.toString(a[0])), BigInt(t.F.toString(a[1]))], f = [BigInt(t.F.toString(s[0])), BigInt(t.F.toString(s[1]))];
|
|
146
|
+
return { H0: S, H1: f };
|
|
90
147
|
}
|
|
91
148
|
);
|
|
92
|
-
static getStealthAddressCompressedPoints = (e,
|
|
93
|
-
const { H0:
|
|
94
|
-
return { h0: n, h1:
|
|
149
|
+
static getStealthAddressCompressedPoints = (e, r) => {
|
|
150
|
+
const { H0: t, H1: i } = this.getRandomizedStealthPair(e, r), [n, a] = [t, i].map((s) => BigInt(s[1]) + 2n ** 255n * y(s[0]));
|
|
151
|
+
return { h0: n, h1: a };
|
|
95
152
|
};
|
|
96
|
-
static getStealthAddress =
|
|
97
|
-
const { H0:
|
|
98
|
-
return
|
|
153
|
+
static getStealthAddress = R.attach((e, r) => {
|
|
154
|
+
const { H0: t, H1: i } = this.getRandomizedStealthPair(e, r), a = [2n * y(t[0]) + y(i[0]), t[1], i[1]];
|
|
155
|
+
return c(...a);
|
|
99
156
|
});
|
|
100
|
-
static getStealthAddressWithEKey = (e,
|
|
101
|
-
static checkSignature = (e,
|
|
102
|
-
const { h0: n, h1:
|
|
103
|
-
return
|
|
157
|
+
static getStealthAddressWithEKey = (e, r) => ({ stealthAddress: this.getStealthAddress(e, r), encryptionKey: this.getEncryptionKeyPair(r).publicKey });
|
|
158
|
+
static checkSignature = (e, r, t, i) => {
|
|
159
|
+
const { h0: n, h1: a } = this.getStealthAddressCompressedPoints(e, i);
|
|
160
|
+
return r === n && t === a;
|
|
104
161
|
};
|
|
105
162
|
/**
|
|
106
163
|
* generate private and public keypair
|
|
@@ -108,16 +165,16 @@ class D {
|
|
|
108
165
|
* and must correspond to 32 bytes
|
|
109
166
|
*/
|
|
110
167
|
static getEncryptionKeyPair = (e) => {
|
|
111
|
-
const
|
|
168
|
+
const r = w.crypto_box_seed_keypair(d.utils.arrayify(e));
|
|
112
169
|
return {
|
|
113
|
-
privateKey:
|
|
114
|
-
publicKey:
|
|
170
|
+
privateKey: d.utils.hexlify(r.privateKey),
|
|
171
|
+
publicKey: d.utils.hexlify(r.publicKey)
|
|
115
172
|
};
|
|
116
173
|
};
|
|
117
174
|
}
|
|
118
175
|
export {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
176
|
+
L as EncryptionKeyPairDefaultValue,
|
|
177
|
+
l as UserKeys,
|
|
178
|
+
R as stealthAddressCacheDevice,
|
|
179
|
+
E as stealthPairCacheDevice
|
|
123
180
|
};
|
|
@@ -0,0 +1 @@
|
|
|
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 t=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"),i=require("../../../functions/utils/merkleTree.utils.cjs");class u extends l.AbstractSnapshotService{constructor(e){super(e,"NewAccessKeyAdded")}_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,senderAddressIndexMap:Array.from(e.payload.senderAddressIndexMap).map(([s,r])=>({address:s,index:r}))}}deserializeSnapshot(e){let s,r;return e.latestBlockNumber&&e.merkleTree?s=i.contructMerkleTreeFromSerialized(e.merkleTree):s=o.MerkleTree.create(a.poseidonFunction,0n),e.latestBlockNumber&&e.senderAddressIndexMap?r=new Map(e.senderAddressIndexMap.map(({address:d,index:n})=>[d,n])):r=new Map,{latestBlockNumber:e.latestBlockNumber??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:t.toBigInt(s),index:t.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=u;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MerkleTree, MerkleTreeJson } from '
|
|
2
|
-
import { AccessTokenEvent } from '
|
|
1
|
+
import { MerkleTree, MerkleTreeJson } from '../../merkle-tree';
|
|
2
|
+
import { AccessTokenEvent } from '../../../types';
|
|
3
3
|
import { AbstractSnapshotService, Snapshot } from './AbstractSnapshotService';
|
|
4
4
|
import { BlockchainEventEmitter } from './BlockchainEventEmitter';
|
|
5
5
|
export type SenderAddressIndexMapJson = {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { zeroAddress as m } from "
|
|
2
|
-
import { poseidonFunction as o } from "
|
|
1
|
+
import { zeroAddress as m } from "../../../constants/protocol.constants.mjs";
|
|
2
|
+
import { poseidonFunction as o } from "../../../crypto/poseidon.mjs";
|
|
3
3
|
import "circomlibjs-hinkal-fork";
|
|
4
4
|
import "libsodium-wrappers";
|
|
5
5
|
import "process";
|
|
6
6
|
import "buffer";
|
|
7
|
-
import { toBigInt as t } from "
|
|
8
|
-
import { MerkleTree as a } from "
|
|
7
|
+
import { toBigInt as t } from "../../../functions/utils/amounts.utils.mjs";
|
|
8
|
+
import { MerkleTree as a } from "../../merkle-tree/MerkleTree.mjs";
|
|
9
9
|
import "ethers";
|
|
10
|
-
import "
|
|
10
|
+
import "../../../error-handling/error-codes.constants.mjs";
|
|
11
11
|
import { AbstractSnapshotService as l } from "./AbstractSnapshotService.mjs";
|
|
12
|
-
import { contructMerkleTreeFromSerialized as A } from "
|
|
12
|
+
import { contructMerkleTreeFromSerialized as A } from "../../../functions/utils/merkleTree.utils.mjs";
|
|
13
13
|
class b extends l {
|
|
14
14
|
constructor(e) {
|
|
15
15
|
super(e, "NewAccessKeyAdded");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./AbstractSnapshotService.cjs"),v=require("../../../functions/utils/amounts.utils.cjs"),u=require("../../../functions/utils/caseInsensitive.utils.cjs");class A extends c.AbstractSnapshotService{constructor(e){super(e,"NewApprovedUtxo")}_approvals=new Map;events=new Set;get approvals(){return this._approvals}getEventKey(e,t,s){return typeof e!="bigint"||typeof s!="string"||typeof t!="string"?null:`${s}-${t}-${e}`}serializeSnapshot(e){const t=Object.fromEntries(e.payload.approvals),s=Object.entries(t).map(([p,i])=>{const l=i.map(n=>({amount:n.amount.toString(),tokenAddress:n.tokenAddress,inHinkalAddress:n.inHinkalAddress.toString()}));return[p,l]}),r=Object.fromEntries(s);return{latestBlockNumber:e.latestBlockNumber,approvals:r,events:[...this.events]}}deserializeSnapshot(e){const t=e.approvals,s=Object.entries(t).map(([p,i])=>{const l=i.map(n=>({amount:BigInt(n.amount),tokenAddress:n.tokenAddress,inHinkalAddress:BigInt(n.inHinkalAddress)}));return[p,l]}),r=new Map(s);return{latestBlockNumber:e.latestBlockNumber??0,payload:{approvals:r,events:new Set(e.events)}}}getSnapshotPayload(){return{approvals:this._approvals,events:this.events}}populateSnapshot({payload:{approvals:e,events:t}}){this._approvals=e,this.events=t}mapEvent(e){const{approveTo:t,tokenAddress:s,amount:r,inHinkalAddress:p}=e;return{approveTo:t,tokenAddress:s,amount:v.toBigInt(r),inHinkalAddress:v.toBigInt(p)}}acceptEvent(e,t,s){const r=this.getEventKey(e.inHinkalAddress,e.tokenAddress,s);if(r&&!this.events.has(r)){const{amount:p,tokenAddress:i,inHinkalAddress:l}=e,n={amount:p,tokenAddress:i,inHinkalAddress:l};let a=this.approvals.get(e.approveTo)||[],d=!1;for(let o=0;o<a.length;o+=1)u.caseInsensitiveEqual(i,a[o].tokenAddress)&&l===a[o].inHinkalAddress&&(a[o].amount+=p,d=!0);if(a=a.filter(o=>o.amount!==0n),d&&a.length===0)this.approvals.delete(e.approveTo);else{const o=d?a:[...a,n];this.approvals.set(e.approveTo,o)}return s&&this.events.add(r),!0}return!1}}exports.AbstractApprovalsSnapshotService=A;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AbstractSnapshotService, Snapshot } from './AbstractSnapshotService';
|
|
2
|
-
import { NewApprovedUtxoEvent } from '
|
|
2
|
+
import { NewApprovedUtxoEvent } from '../../../types/commitments.types';
|
|
3
3
|
import { BlockchainEventEmitter } from './BlockchainEventEmitter';
|
|
4
|
-
import { ApprovedUtxo } from '
|
|
4
|
+
import { ApprovedUtxo } from '../../../types/hinkal.types';
|
|
5
5
|
export type ApprovalsSnapshotPayload = {
|
|
6
6
|
readonly approvals: Map<string, ApprovedUtxo[]>;
|
|
7
7
|
readonly events: Set<string>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractSnapshotService as c } from "./AbstractSnapshotService.mjs";
|
|
2
|
-
import { toBigInt as v } from "
|
|
3
|
-
import { caseInsensitiveEqual as u } from "
|
|
2
|
+
import { toBigInt as v } from "../../../functions/utils/amounts.utils.mjs";
|
|
3
|
+
import { caseInsensitiveEqual as u } from "../../../functions/utils/caseInsensitive.utils.mjs";
|
|
4
4
|
class g extends c {
|
|
5
5
|
constructor(e) {
|
|
6
6
|
super(e, "NewApprovedUtxo");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const l=require("../../merkle-tree/MerkleTree.cjs");require("ethers");require("../../../error-handling/error-codes.constants.cjs");const u=require("../../../functions/utils/amounts.utils.cjs"),o=require("./AbstractSnapshotService.cjs"),p=require("../../../functions/utils/merkleTree.utils.cjs");class a extends o.AbstractSnapshotService{constructor(e){super(e,"NewCommitment")}_merkleTree;_encryptedOutputs;get merkleTree(){return this._merkleTree}get encryptedOutputs(){return this._encryptedOutputs}serializeSnapshot(e){return{merkleTree:e.payload.merkleTree.toJSON(),latestBlockNumber:e.latestBlockNumber,encryptedOutputs:e.payload.encryptedOutputs.map(t=>({value:t.value,isPositive:String(t.isPositive),isBlocked:t.isBlocked??!1}))}}deserializeSnapshot(e){let t;e.latestBlockNumber&&e.merkleTree?t=p.contructMerkleTreeFromSerialized(e.merkleTree):t=l.MerkleTree.create(c.poseidonFunction,0n);const s=e.encryptedOutputs?.map(r=>({value:r.value,isPositive:JSON.parse(r.isPositive),isBlocked:r.isBlocked??!1}));return{latestBlockNumber:e.latestBlockNumber??0,payload:{merkleTree:t,encryptedOutputs:s||[]}}}getSnapshotPayload(){return{merkleTree:this._merkleTree,encryptedOutputs:this._encryptedOutputs}}populateSnapshot({payload:{merkleTree:e,encryptedOutputs:t}}){this._merkleTree=e,this._encryptedOutputs=t}mapEvent(e){const{commitment:t,index:s,encryptedOutput:r}=e;return{commitment:u.toBigInt(t),index:u.toBigInt(s),encryptedOutput:r}}acceptEvent(e,t,s,r){if(!this.encryptedOutputs.map(i=>i.value).includes(e.encryptedOutput)){if(!this._merkleTree.insert(e.commitment,e.index>=0?e.index:-1n*e.index))return!1;const n={value:e.encryptedOutput,isPositive:e.index>=0n,isBlocked:r??!1};return this._encryptedOutputs.push(n),!0}return!1}}exports.AbstractCommitmentsSnapshotService=a;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MerkleTree, MerkleTreeJson } from '
|
|
2
|
-
import { CommitmentEvent, EncryptedOutputWithSign } from '
|
|
1
|
+
import { MerkleTree, MerkleTreeJson } from '../../merkle-tree';
|
|
2
|
+
import { CommitmentEvent, EncryptedOutputWithSign } from '../../../types';
|
|
3
3
|
import { AbstractSnapshotService, Snapshot } from './AbstractSnapshotService';
|
|
4
4
|
import { BlockchainEventEmitter } from './BlockchainEventEmitter';
|
|
5
5
|
export type CommitmentsSnapshotPayload = {
|
|
@@ -25,5 +25,5 @@ export declare abstract class AbstractCommitmentsSnapshotService extends Abstrac
|
|
|
25
25
|
};
|
|
26
26
|
protected populateSnapshot({ payload: { merkleTree, encryptedOutputs }, }: Snapshot<CommitmentsSnapshotPayload>): void;
|
|
27
27
|
protected mapEvent(event: CommitmentEvent): CommitmentEvent<bigint>;
|
|
28
|
-
protected acceptEvent(event: CommitmentEvent<bigint>, _blockNumber: number): boolean;
|
|
28
|
+
protected acceptEvent(event: CommitmentEvent<bigint>, _blockNumber: number, _txHash?: string, isBlocked?: boolean): boolean;
|
|
29
29
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { poseidonFunction as
|
|
1
|
+
import { poseidonFunction as m } from "../../../crypto/poseidon.mjs";
|
|
2
2
|
import "circomlibjs-hinkal-fork";
|
|
3
3
|
import "libsodium-wrappers";
|
|
4
4
|
import "process";
|
|
5
5
|
import "buffer";
|
|
6
|
-
import { MerkleTree as
|
|
6
|
+
import { MerkleTree as c } from "../../merkle-tree/MerkleTree.mjs";
|
|
7
7
|
import "ethers";
|
|
8
|
-
import "
|
|
9
|
-
import { toBigInt as
|
|
10
|
-
import { AbstractSnapshotService as
|
|
11
|
-
import { contructMerkleTreeFromSerialized as n } from "
|
|
12
|
-
class
|
|
8
|
+
import "../../../error-handling/error-codes.constants.mjs";
|
|
9
|
+
import { toBigInt as p } from "../../../functions/utils/amounts.utils.mjs";
|
|
10
|
+
import { AbstractSnapshotService as o } from "./AbstractSnapshotService.mjs";
|
|
11
|
+
import { contructMerkleTreeFromSerialized as n } from "../../../functions/utils/merkleTree.utils.mjs";
|
|
12
|
+
class b extends o {
|
|
13
13
|
constructor(e) {
|
|
14
14
|
super(e, "NewCommitment");
|
|
15
15
|
}
|
|
@@ -27,22 +27,24 @@ class S extends m {
|
|
|
27
27
|
latestBlockNumber: e.latestBlockNumber,
|
|
28
28
|
encryptedOutputs: e.payload.encryptedOutputs.map((t) => ({
|
|
29
29
|
value: t.value,
|
|
30
|
-
isPositive: String(t.isPositive)
|
|
30
|
+
isPositive: String(t.isPositive),
|
|
31
|
+
isBlocked: t.isBlocked ?? !1
|
|
31
32
|
}))
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
deserializeSnapshot(e) {
|
|
35
36
|
let t;
|
|
36
|
-
e.latestBlockNumber && e.merkleTree ? t = n(e.merkleTree) : t =
|
|
37
|
-
const
|
|
38
|
-
value:
|
|
39
|
-
isPositive: JSON.parse(
|
|
37
|
+
e.latestBlockNumber && e.merkleTree ? t = n(e.merkleTree) : t = c.create(m, 0n);
|
|
38
|
+
const s = e.encryptedOutputs?.map((r) => ({
|
|
39
|
+
value: r.value,
|
|
40
|
+
isPositive: JSON.parse(r.isPositive),
|
|
41
|
+
isBlocked: r.isBlocked ?? !1
|
|
40
42
|
}));
|
|
41
43
|
return {
|
|
42
44
|
latestBlockNumber: e.latestBlockNumber ?? 0,
|
|
43
45
|
payload: {
|
|
44
46
|
merkleTree: t,
|
|
45
|
-
encryptedOutputs:
|
|
47
|
+
encryptedOutputs: s || []
|
|
46
48
|
}
|
|
47
49
|
};
|
|
48
50
|
}
|
|
@@ -58,20 +60,21 @@ class S extends m {
|
|
|
58
60
|
this._merkleTree = e, this._encryptedOutputs = t;
|
|
59
61
|
}
|
|
60
62
|
mapEvent(e) {
|
|
61
|
-
const { commitment: t, index:
|
|
63
|
+
const { commitment: t, index: s, encryptedOutput: r } = e;
|
|
62
64
|
return {
|
|
63
|
-
commitment:
|
|
64
|
-
index:
|
|
65
|
-
encryptedOutput:
|
|
65
|
+
commitment: p(t),
|
|
66
|
+
index: p(s),
|
|
67
|
+
encryptedOutput: r
|
|
66
68
|
};
|
|
67
69
|
}
|
|
68
|
-
acceptEvent(e, t) {
|
|
69
|
-
if (!this.encryptedOutputs.map((
|
|
70
|
+
acceptEvent(e, t, s, r) {
|
|
71
|
+
if (!this.encryptedOutputs.map((i) => i.value).includes(e.encryptedOutput)) {
|
|
70
72
|
if (!this._merkleTree.insert(e.commitment, e.index >= 0 ? e.index : -1n * e.index))
|
|
71
73
|
return !1;
|
|
72
74
|
const u = {
|
|
73
75
|
value: e.encryptedOutput,
|
|
74
|
-
isPositive: e.index >= 0n
|
|
76
|
+
isPositive: e.index >= 0n,
|
|
77
|
+
isBlocked: r ?? !1
|
|
75
78
|
};
|
|
76
79
|
return this._encryptedOutputs.push(u), !0;
|
|
77
80
|
}
|
|
@@ -79,5 +82,5 @@ class S extends m {
|
|
|
79
82
|
}
|
|
80
83
|
}
|
|
81
84
|
export {
|
|
82
|
-
|
|
85
|
+
b as AbstractCommitmentsSnapshotService
|
|
83
86
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("../../../functions/utils/resolve-sync.utils.cjs");class h{blockchainEventEmitter;eventName;constructor(e,t){this.blockchainEventEmitter=e,this.eventName=t,e.addEventProcessorFunction(this.processEventsPage.bind(this))}get latestBlockNumber(){return this.blockchainEventEmitter.latestBlockNumber}intervalClear(){this.blockchainEventEmitter.intervalClear()}async processEventsPage(e){const t=new Set;e.forEach(({event:s,transactionHash:n})=>{s==="BlockedUtxosCreated"&&t.add(n)});const c=[];await v.resolveSync(e.map(s=>async()=>{if(s.event!==this.eventName)return;const{args:n,blockNumber:i,transactionHash:r}=s;if(!n)throw new Error("Wrong event structure");const a=this.mapEvent(n),l=t.has(r);await this.acceptEvent(a,i,r,l)&&c.push(a)}));const o=c.length;return await this.afterEventsAccepted(o),c.length}}exports.AbstractEventService=h;
|
package/data-structures/event-service/{AbstractEventService.d.ts → evm/AbstractEventService.d.ts}
RENAMED
|
@@ -6,7 +6,7 @@ export declare abstract class AbstractEventService<EventType, SerializedEventTyp
|
|
|
6
6
|
get latestBlockNumber(): number;
|
|
7
7
|
intervalClear(): void;
|
|
8
8
|
private processEventsPage;
|
|
9
|
-
protected abstract acceptEvent(event: EventType, blockNumber: number, txHash?: string): boolean | Promise<boolean>;
|
|
9
|
+
protected abstract acceptEvent(event: EventType, blockNumber: number, txHash?: string, isBlocked?: boolean): boolean | Promise<boolean>;
|
|
10
10
|
protected abstract mapEvent(event: SerializedEventType): EventType;
|
|
11
11
|
protected abstract afterEventsAccepted(eventsCount: number): Promise<void>;
|
|
12
12
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { resolveSync as v } from "../../../functions/utils/resolve-sync.utils.mjs";
|
|
2
|
+
class u {
|
|
3
|
+
blockchainEventEmitter;
|
|
4
|
+
eventName;
|
|
5
|
+
constructor(t, e) {
|
|
6
|
+
this.blockchainEventEmitter = t, this.eventName = e, t.addEventProcessorFunction(this.processEventsPage.bind(this));
|
|
7
|
+
}
|
|
8
|
+
get latestBlockNumber() {
|
|
9
|
+
return this.blockchainEventEmitter.latestBlockNumber;
|
|
10
|
+
}
|
|
11
|
+
intervalClear() {
|
|
12
|
+
this.blockchainEventEmitter.intervalClear();
|
|
13
|
+
}
|
|
14
|
+
async processEventsPage(t) {
|
|
15
|
+
const e = /* @__PURE__ */ new Set();
|
|
16
|
+
t.forEach(({ event: s, transactionHash: n }) => {
|
|
17
|
+
s === "BlockedUtxosCreated" && e.add(n);
|
|
18
|
+
});
|
|
19
|
+
const c = [];
|
|
20
|
+
await v(
|
|
21
|
+
t.map((s) => async () => {
|
|
22
|
+
if (s.event !== this.eventName)
|
|
23
|
+
return;
|
|
24
|
+
const { args: n, blockNumber: i, transactionHash: a } = s;
|
|
25
|
+
if (!n)
|
|
26
|
+
throw new Error("Wrong event structure");
|
|
27
|
+
const r = this.mapEvent(n), h = e.has(a);
|
|
28
|
+
await this.acceptEvent(r, i, a, h) && c.push(r);
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
const o = c.length;
|
|
32
|
+
return await this.afterEventsAccepted(o), c.length;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
u as AbstractEventService
|
|
37
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BigNumber } from 'ethers';
|
|
2
|
-
import { NullifierEvent } from '
|
|
2
|
+
import { NullifierEvent } from '../../../types/commitments.types';
|
|
3
3
|
import { AbstractSnapshotService, Snapshot } from './AbstractSnapshotService';
|
|
4
4
|
import { BlockchainEventEmitter } from './BlockchainEventEmitter';
|
|
5
5
|
export type NullifierSnapshotPayload = {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../../constants/save-depths.cjs"),a=require("./AbstractEventService.cjs");class i extends a.AbstractEventService{savedLatestBlockNumber=0;chainId=0;constructor(t,e){super(t,e)}async init(){await this.loadSnapshot(),this.chainId=(await this.blockchainEventEmitter.contract.provider.getNetwork()).chainId}async retrieveEventsFromLatestBlock(){await this.blockchainEventEmitter.retrieveEvents(this.latestBlockNumber)}async loadSnapshot(){const t=await this.fetchSnapshot(),e=this.deserializeSnapshot(t);this.populateSnapshot(e),this.blockchainEventEmitter.syncFromAtMost(e.latestBlockNumber),this.savedLatestBlockNumber=e.latestBlockNumber}saveSnapshot(){return this.savedLatestBlockNumber=this.latestBlockNumber,this.persistSnapshot(this.serializeSnapshot({latestBlockNumber:this.latestBlockNumber,payload:this.getSnapshotPayload()}))}async afterEventsAccepted(t){(t>0||this.savedLatestBlockNumber+s.saveDepths[this.chainId]<this.latestBlockNumber)&&await this.saveSnapshot()}}exports.AbstractSnapshotService=i;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../../../constants/reorg-depths.constants.cjs"),c=require("../../../functions/utils/resolve-sync.utils.cjs"),m=require("../../../functions/utils/mutexes.utils.cjs");class y{contract;depositOnChainUtxosContract;_latestBlockNumber;_initialBlockNumber;onEventsProcessed;eventProcessors=new Set;maxPageSize;isReady=!1;isServer;intervalId;inProgress;constructor(e,r,l,s,i){this.contract=e,this.depositOnChainUtxosContract=i,this._initialBlockNumber=r,this.maxPageSize=s,this.isServer=l,this.inProgress=!1}get latestBlockNumber(){return this._latestBlockNumber??this._initialBlockNumber}syncFromAtMost(e){(this._latestBlockNumber===void 0||e<this._latestBlockNumber)&&(this._latestBlockNumber=e)}intervalClear(){this.isReady=!1,this.eventProcessors=new Set,clearInterval(this.intervalId)}async init(){if(this.isReady)throw new Error("Already initialized");this.isReady=!0,await this.retrieveEvents(this.latestBlockNumber+1),this.intervalId=setInterval(async()=>{await this.retrieveEvents(this.latestBlockNumber)},3500)}requireReady(){if(!this.isReady)throw new Error("Not ready")}addEventProcessorFunction(e){if(this.isReady)throw new Error("Can't add event processor after event emitter initialized");this.eventProcessors.add(e)}async getLastBlockNumberForEventRequest(){const e=await this.contract.provider.getBlockNumber();if(!this.isServer)return e;const{chainId:r}=await this.contract.provider.getNetwork();return Math.max(this.latestBlockNumber,e-d.blockReorgDepth[r]+1)}async retrieveEvents(e,r=!1){return this.requireReady(),await m.balanceFetchingMutex.runExclusive(async()=>{try{if(this.inProgress&&!r)return!1;this.inProgress=!0;let s=0;const i=await this.getLastBlockNumberForEventRequest();if(i<e)return this.inProgress=!1,!1;const h=c.getSequence(e,i,this.maxPageSize),n=[];if(await c.resolveSync(h.map(({from:t,to:a})=>async()=>{const o=await this.contract.queryFilter("*",t,a);n.push(...o)})),this.depositOnChainUtxosContract){const{depositOnChainUtxosContract:t}=this;await c.resolveSync(h.map(({from:a,to:o})=>async()=>{const v=await t.queryFilter("*",a,o);n.push(...v)}))}const u=await Promise.all([...this.eventProcessors].map(t=>t(n)));return this._latestBlockNumber=i,s+=u.reduce((t,a)=>t+a,0),this.onEventsProcessed?.(s),this.inProgress=!1,!0}catch(s){return console.log("retrieveEvents error:",{err:s}),this.inProgress=!1,!1}})}}exports.BlockchainEventEmitter=y;
|
|
@@ -2,6 +2,7 @@ import { ethers } from 'ethers';
|
|
|
2
2
|
export type EventProcessorFunction = (events: ethers.Event[]) => Promise<number> | number;
|
|
3
3
|
export declare class BlockchainEventEmitter {
|
|
4
4
|
readonly contract: ethers.Contract;
|
|
5
|
+
readonly depositOnChainUtxosContract?: ethers.Contract;
|
|
5
6
|
private _latestBlockNumber;
|
|
6
7
|
private _initialBlockNumber;
|
|
7
8
|
onEventsProcessed?: (acceptedEventCount: number) => void;
|
|
@@ -11,7 +12,7 @@ export declare class BlockchainEventEmitter {
|
|
|
11
12
|
private isServer;
|
|
12
13
|
private intervalId?;
|
|
13
14
|
private inProgress;
|
|
14
|
-
constructor(contract: ethers.Contract, initialBlockNumber: number, isServer: boolean, maxPageSize?: number);
|
|
15
|
+
constructor(contract: ethers.Contract, initialBlockNumber: number, isServer: boolean, maxPageSize?: number, depositOnChainUtxosContract?: ethers.Contract);
|
|
15
16
|
get latestBlockNumber(): number;
|
|
16
17
|
syncFromAtMost(blockNumber: number): void;
|
|
17
18
|
intervalClear(): void;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { blockReorgDepth as d } from "../../../constants/reorg-depths.constants.mjs";
|
|
2
|
+
import { getSequence as m, resolveSync as h } from "../../../functions/utils/resolve-sync.utils.mjs";
|
|
3
|
+
import { balanceFetchingMutex as y } from "../../../functions/utils/mutexes.utils.mjs";
|
|
4
|
+
class g {
|
|
5
|
+
contract;
|
|
6
|
+
depositOnChainUtxosContract;
|
|
7
|
+
_latestBlockNumber;
|
|
8
|
+
_initialBlockNumber;
|
|
9
|
+
onEventsProcessed;
|
|
10
|
+
eventProcessors = /* @__PURE__ */ new Set();
|
|
11
|
+
maxPageSize;
|
|
12
|
+
isReady = !1;
|
|
13
|
+
isServer;
|
|
14
|
+
intervalId;
|
|
15
|
+
inProgress;
|
|
16
|
+
// to remove race conditions
|
|
17
|
+
constructor(t, r, c, s, i) {
|
|
18
|
+
this.contract = t, this.depositOnChainUtxosContract = i, this._initialBlockNumber = r, this.maxPageSize = s, this.isServer = c, this.inProgress = !1;
|
|
19
|
+
}
|
|
20
|
+
get latestBlockNumber() {
|
|
21
|
+
return this._latestBlockNumber ?? this._initialBlockNumber;
|
|
22
|
+
}
|
|
23
|
+
syncFromAtMost(t) {
|
|
24
|
+
(this._latestBlockNumber === void 0 || t < this._latestBlockNumber) && (this._latestBlockNumber = t);
|
|
25
|
+
}
|
|
26
|
+
intervalClear() {
|
|
27
|
+
this.isReady = !1, this.eventProcessors = /* @__PURE__ */ new Set(), clearInterval(this.intervalId);
|
|
28
|
+
}
|
|
29
|
+
async init() {
|
|
30
|
+
if (this.isReady)
|
|
31
|
+
throw new Error("Already initialized");
|
|
32
|
+
this.isReady = !0, await this.retrieveEvents(this.latestBlockNumber + 1), this.intervalId = setInterval(async () => {
|
|
33
|
+
await this.retrieveEvents(this.latestBlockNumber);
|
|
34
|
+
}, 3500);
|
|
35
|
+
}
|
|
36
|
+
requireReady() {
|
|
37
|
+
if (!this.isReady)
|
|
38
|
+
throw new Error("Not ready");
|
|
39
|
+
}
|
|
40
|
+
addEventProcessorFunction(t) {
|
|
41
|
+
if (this.isReady)
|
|
42
|
+
throw new Error("Can't add event processor after event emitter initialized");
|
|
43
|
+
this.eventProcessors.add(t);
|
|
44
|
+
}
|
|
45
|
+
async getLastBlockNumberForEventRequest() {
|
|
46
|
+
const t = await this.contract.provider.getBlockNumber();
|
|
47
|
+
if (!this.isServer)
|
|
48
|
+
return t;
|
|
49
|
+
const { chainId: r } = await this.contract.provider.getNetwork();
|
|
50
|
+
return Math.max(this.latestBlockNumber, t - d[r] + 1);
|
|
51
|
+
}
|
|
52
|
+
async retrieveEvents(t, r = !1) {
|
|
53
|
+
return this.requireReady(), await y.runExclusive(async () => {
|
|
54
|
+
try {
|
|
55
|
+
if (this.inProgress && !r)
|
|
56
|
+
return !1;
|
|
57
|
+
this.inProgress = !0;
|
|
58
|
+
let s = 0;
|
|
59
|
+
const i = await this.getLastBlockNumberForEventRequest();
|
|
60
|
+
if (i < t)
|
|
61
|
+
return this.inProgress = !1, !1;
|
|
62
|
+
const l = m(t, i, this.maxPageSize), n = [];
|
|
63
|
+
if (await h(
|
|
64
|
+
l.map(({ from: e, to: a }) => async () => {
|
|
65
|
+
const o = await this.contract.queryFilter("*", e, a);
|
|
66
|
+
n.push(...o);
|
|
67
|
+
})
|
|
68
|
+
), this.depositOnChainUtxosContract) {
|
|
69
|
+
const { depositOnChainUtxosContract: e } = this;
|
|
70
|
+
await h(
|
|
71
|
+
l.map(({ from: a, to: o }) => async () => {
|
|
72
|
+
const v = await e.queryFilter("*", a, o);
|
|
73
|
+
n.push(...v);
|
|
74
|
+
})
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
const u = await Promise.all(
|
|
78
|
+
[...this.eventProcessors].map((e) => e(n))
|
|
79
|
+
);
|
|
80
|
+
return this._latestBlockNumber = i, s += u.reduce((e, a) => e + a, 0), this.onEventsProcessed?.(s), this.inProgress = !1, !0;
|
|
81
|
+
} catch (s) {
|
|
82
|
+
return console.log("retrieveEvents error:", { err: s }), this.inProgress = !1, !1;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
g as BlockchainEventEmitter
|
|
89
|
+
};
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
export * from './AbstractAccessTokenSnapshotService';
|
|
2
|
-
export * from './AbstractCommitmentsSnapshotService';
|
|
3
|
-
export * from './AbstractApprovalsSnapshotService';
|
|
4
|
-
export * from './AbstractNullifierSnapshotService';
|
|
5
|
-
export * from './AbstractSnapshotService';
|
|
6
|
-
export * from './AbstractEventService';
|
|
7
|
-
export * from './BlockchainEventEmitter';
|
|
1
|
+
export * from './evm/AbstractAccessTokenSnapshotService';
|
|
2
|
+
export * from './evm/AbstractCommitmentsSnapshotService';
|
|
3
|
+
export * from './evm/AbstractApprovalsSnapshotService';
|
|
4
|
+
export * from './evm/AbstractNullifierSnapshotService';
|
|
5
|
+
export * from './evm/AbstractSnapshotService';
|
|
6
|
+
export * from './evm/AbstractEventService';
|
|
7
|
+
export * from './evm/BlockchainEventEmitter';
|
|
8
|
+
export * from './solana/SolanaBlockchainEventEmitter';
|
|
9
|
+
export * from './solana/AbstractSolanaEventService';
|
|
10
|
+
export * from './solana/AbstractSolanaSnapshotService';
|
|
11
|
+
export * from './solana/AbstractSolanaNullifierSnapshotService';
|
|
12
|
+
export * from './solana/AbstractSolanaCommitmentsSnapshotService';
|
|
13
|
+
export * from './solana/AbstractSolanaAccessTokenSnapshotService';
|