@hinkal/common 0.2.21 → 0.2.23
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 +14 -14
- package/API/API.mjs +88 -87
- package/API/admin-calls.cjs +1 -1
- package/API/admin-calls.d.ts +1 -1
- package/API/admin-calls.mjs +4 -4
- package/API/ai-calls.cjs +1 -0
- package/API/ai-calls.d.ts +17 -0
- package/API/ai-calls.mjs +21 -0
- package/API/callLifiAPI.cjs +1 -1
- package/API/callLifiAPI.d.ts +1 -1
- package/API/callLifiAPI.mjs +5 -5
- package/API/callMonitor.cjs +1 -1
- package/API/callMonitor.d.ts +1 -1
- package/API/callMonitor.mjs +7 -7
- package/API/callOdosAPI.cjs +1 -1
- package/API/callOdosAPI.mjs +11 -11
- package/API/callOkxAPI.cjs +1 -1
- package/API/callOkxAPI.d.ts +1 -1
- package/API/callOkxAPI.mjs +5 -5
- package/API/callOneInchAPI.cjs +1 -1
- package/API/callOneInchAPI.mjs +11 -10
- package/API/callRelayer.cjs +1 -1
- package/API/callRelayer.d.ts +5 -6
- package/API/callRelayer.mjs +11 -11
- package/API/checkRisk.cjs +1 -1
- package/API/checkRisk.d.ts +1 -1
- package/API/checkRisk.mjs +4 -4
- package/API/deposit-and-withdraw-status-calls.cjs +1 -0
- package/API/deposit-and-withdraw-status-calls.d.ts +20 -0
- package/API/deposit-and-withdraw-status-calls.mjs +18 -0
- package/API/duneAPI.cjs +1 -0
- package/API/duneAPI.d.ts +11 -0
- package/API/duneAPI.mjs +25 -0
- package/API/enclaveCalls.cjs +1 -1
- package/API/enclaveCalls.mjs +4 -5
- package/API/fetchCommitmentsCache.cjs +1 -1
- package/API/fetchCommitmentsCache.mjs +9 -9
- package/API/get-token-data.cjs +1 -1
- package/API/get-token-data.d.ts +1 -1
- package/API/get-token-data.mjs +5 -5
- package/API/getBridgeProtocols.cjs +1 -0
- package/API/getBridgeProtocols.d.ts +7 -0
- package/API/getBridgeProtocols.mjs +8 -0
- package/API/getGasEstimates.cjs +1 -1
- package/API/getGasEstimates.mjs +9 -9
- package/API/getLifiStatus.cjs +1 -0
- package/API/getLifiStatus.d.ts +24 -0
- package/API/getLifiStatus.mjs +15 -0
- package/API/getRelayerURL.cjs +1 -0
- package/API/getRelayerURL.d.ts +1 -0
- package/API/getRelayerURL.mjs +10 -0
- package/API/getServerURL.cjs +1 -1
- package/API/getServerURL.d.ts +3 -3
- package/API/getServerURL.mjs +67 -51
- package/API/getTokenPrice.cjs +1 -1
- package/API/getTokenPrice.d.ts +0 -5
- package/API/getTokenPrice.mjs +7 -14
- package/API/index.d.ts +3 -1
- package/API/is-tx-stateless.cjs +1 -1
- package/API/is-tx-stateless.d.ts +1 -1
- package/API/is-tx-stateless.mjs +12 -10
- package/API/kycCalls.cjs +1 -1
- package/API/kycCalls.d.ts +8 -4
- package/API/kycCalls.mjs +26 -23
- package/API/passwordCalls.cjs +1 -0
- package/API/passwordCalls.d.ts +9 -0
- package/API/passwordCalls.mjs +13 -0
- package/API/proxyAccountsCalls.cjs +1 -1
- package/API/proxyAccountsCalls.d.ts +2 -7
- package/API/proxyAccountsCalls.mjs +21 -27
- package/API/relayCalls.cjs +1 -1
- package/API/relayCalls.mjs +4 -4
- package/API/restoreSnapshots.cjs +1 -0
- package/API/restoreSnapshots.d.ts +1 -0
- package/API/restoreSnapshots.mjs +10 -0
- package/API/scheduled-transactions-calls.cjs +1 -1
- package/API/scheduled-transactions-calls.d.ts +9 -1
- package/API/scheduled-transactions-calls.mjs +9 -5
- package/API/simulate-batch-tx.cjs +1 -1
- package/API/simulate-batch-tx.d.ts +2 -2
- package/API/simulate-batch-tx.mjs +6 -7
- package/API/solana-calls.cjs +1 -1
- package/API/solana-calls.d.ts +3 -6
- package/API/solana-calls.mjs +15 -15
- package/API/temporaryWalletCalls.cjs +1 -1
- package/API/temporaryWalletCalls.mjs +19 -13
- package/API/token-calls.cjs +1 -1
- package/API/token-calls.mjs +5 -6
- package/README.md +64 -256
- package/constants/activity.constants.cjs +1 -1
- package/constants/activity.constants.mjs +0 -1
- package/constants/addresses.constants.cjs +1 -1
- package/constants/addresses.constants.mjs +9 -10
- package/constants/chains.constants.cjs +1 -1
- package/constants/chains.constants.d.ts +6 -0
- package/constants/chains.constants.mjs +52 -58
- package/constants/coingecko.constants.cjs +1 -1
- package/constants/coingecko.constants.d.ts +0 -1
- package/constants/coingecko.constants.mjs +10 -11
- package/constants/contracts.constants.cjs +1 -1
- package/constants/contracts.constants.d.ts +3 -3
- package/constants/contracts.constants.mjs +29 -29
- package/constants/deploy-data/deploy-data-solana.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-solana.json.mjs +2 -28
- package/constants/function-signatures.constants.cjs +1 -1
- package/constants/function-signatures.constants.d.ts +1 -0
- package/constants/function-signatures.constants.mjs +4 -3
- package/constants/kyc.constants.cjs +1 -1
- package/constants/kyc.constants.mjs +40 -39
- package/constants/mediaUrls.constants.cjs +1 -1
- package/constants/mediaUrls.constants.d.ts +0 -1
- package/constants/mediaUrls.constants.mjs +1 -2
- package/constants/permit2.constants.cjs +1 -1
- package/constants/permit2.constants.d.ts +1 -0
- package/constants/permit2.constants.mjs +11 -10
- package/constants/server.constants.cjs +1 -1
- package/constants/server.constants.d.ts +123 -19
- package/constants/server.constants.mjs +138 -35
- package/constants/tasks.constants.cjs +1 -1
- package/constants/tasks.constants.mjs +4 -5
- package/constants/vite.constants.cjs +1 -1
- package/constants/vite.constants.mjs +13 -36
- package/crypto/poseidon.cjs +1 -1
- package/crypto/poseidon.mjs +10 -10
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.cjs +1 -1
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.mjs +86 -83
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +56 -45
- package/data-structures/Hinkal/Hinkal.mjs +348 -315
- package/data-structures/Hinkal/IHinkal.d.ts +56 -42
- package/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.d.ts +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.mjs +49 -48
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.cjs +1 -0
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.d.ts +7 -0
- package/data-structures/Hinkal/hinkalActionFundApproveAndTransact.mjs +42 -0
- package/data-structures/Hinkal/hinkalActionReceive.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionReceive.mjs +24 -29
- package/data-structures/Hinkal/hinkalApprove.cjs +1 -0
- package/data-structures/Hinkal/hinkalApprove.d.ts +3 -0
- package/data-structures/Hinkal/hinkalApprove.mjs +114 -0
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -1
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +19 -20
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +84 -89
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.d.ts +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +96 -78
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.d.ts +4 -1
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +79 -75
- package/data-structures/Hinkal/hinkalDepostAndBridge.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepostAndBridge.d.ts +1 -1
- package/data-structures/Hinkal/hinkalDepostAndBridge.mjs +151 -140
- package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
- package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +5 -4
- package/data-structures/Hinkal/hinkalInsideTransact.cjs +1 -0
- package/data-structures/Hinkal/hinkalInsideTransact.d.ts +4 -0
- package/data-structures/Hinkal/hinkalInsideTransact.mjs +120 -0
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.d.ts +2 -2
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +118 -115
- package/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalProoflessDeposit.mjs +29 -30
- package/data-structures/Hinkal/hinkalProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxySwap.mjs +36 -40
- package/data-structures/Hinkal/hinkalProxyToPrivate.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxyToPrivate.mjs +32 -37
- package/data-structures/Hinkal/hinkalSignSubAccount.cjs +1 -1
- package/data-structures/Hinkal/hinkalSignSubAccount.d.ts +2 -1
- package/data-structures/Hinkal/hinkalSignSubAccount.mjs +15 -17
- package/data-structures/Hinkal/hinkalSolanaDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDeposit.d.ts +3 -4
- package/data-structures/Hinkal/hinkalSolanaDeposit.mjs +95 -84
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.d.ts +1 -2
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +180 -154
- package/data-structures/Hinkal/hinkalSolanaProxySend.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySend.d.ts +3 -2
- package/data-structures/Hinkal/hinkalSolanaProxySend.mjs +40 -43
- package/data-structures/Hinkal/hinkalSolanaProxyShield.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxyShield.mjs +67 -71
- package/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySwap.d.ts +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +59 -63
- package/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaSwap.mjs +46 -50
- package/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaTransfer.mjs +50 -52
- package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaWithdraw.d.ts +1 -2
- package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +65 -69
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +77 -71
- package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalTransfer.mjs +70 -72
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +78 -81
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +103 -106
- package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.d.ts +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.mjs +54 -108
- 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 +79 -97
- package/data-structures/IndexedDB/balances-db.cjs +1 -1
- package/data-structures/IndexedDB/balances-db.mjs +39 -43
- package/data-structures/IndexedDB/contact-db.cjs +1 -1
- package/data-structures/IndexedDB/contact-db.mjs +31 -36
- package/data-structures/IndexedDB/signatures-db.cjs +1 -1
- package/data-structures/IndexedDB/signatures-db.mjs +40 -26
- package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +82 -82
- package/data-structures/TokenDBs/token-visibility-db.cjs +1 -1
- package/data-structures/TokenDBs/token-visibility-db.mjs +36 -22
- package/data-structures/crypto-keys/decodeUTXO.cjs +1 -1
- package/data-structures/crypto-keys/decodeUTXO.mjs +45 -45
- package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
- package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +28 -27
- package/data-structures/crypto-keys/keys.cjs +1 -1
- package/data-structures/crypto-keys/keys.d.ts +10 -0
- package/data-structures/crypto-keys/keys.mjs +106 -47
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.d.ts +2 -3
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.mjs +9 -9
- package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.d.ts +2 -3
- package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.mjs +5 -5
- package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.d.ts +2 -3
- package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.mjs +6 -6
- package/data-structures/event-service/evm/AbstractEventService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractEventService.d.ts +2 -4
- package/data-structures/event-service/evm/AbstractEventService.mjs +13 -13
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.d.ts +2 -3
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.mjs +3 -3
- package/data-structures/event-service/evm/AbstractSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractSnapshotService.d.ts +2 -1
- package/data-structures/event-service/evm/AbstractSnapshotService.mjs +6 -2
- package/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.d.ts +5 -10
- package/data-structures/event-service/evm/BlockchainEventEmitter.mjs +40 -40
- package/data-structures/event-service/index.d.ts +0 -4
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.d.ts +2 -3
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.mjs +6 -6
- package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.d.ts +3 -4
- package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.mjs +8 -8
- package/data-structures/event-service/solana/AbstractSolanaEventService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaEventService.d.ts +10 -4
- package/data-structures/event-service/solana/AbstractSolanaEventService.mjs +7 -10
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.d.ts +2 -3
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.mjs +2 -2
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.d.ts +2 -1
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.mjs +2 -1
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.d.ts +16 -11
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.mjs +66 -64
- package/data-structures/index.d.ts +0 -3
- package/data-structures/presale/PresaleContractWrapper.cjs +1 -1
- package/data-structures/presale/PresaleContractWrapper.d.ts +3 -3
- package/data-structures/presale/PresaleContractWrapper.mjs +10 -10
- package/data-structures/provider-adapter/IProviderAdapter.d.ts +16 -11
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.mjs +18 -18
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +9 -9
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.mjs +4 -6
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.mjs +4 -6
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.mjs +4 -6
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.mjs +4 -5
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.mjs +4 -6
- package/error-handling/error-codes.constants.cjs +1 -1
- package/error-handling/error-codes.constants.d.ts +0 -1
- package/error-handling/error-codes.constants.mjs +3 -4
- package/error-handling/get-error.message.cjs +1 -1
- package/error-handling/get-error.message.mjs +27 -22
- package/error-handling/handleErrorRestore.cjs +1 -0
- package/error-handling/handleErrorRestore.d.ts +2 -0
- package/error-handling/handleErrorRestore.mjs +11 -0
- package/error-handling/index.d.ts +1 -0
- package/functions/kyc/authentoHelper.cjs +1 -0
- package/functions/kyc/authentoHelper.d.ts +12 -0
- package/functions/kyc/authentoHelper.mjs +30 -0
- package/functions/kyc/zkMeHelper.cjs +1 -1
- package/functions/kyc/zkMeHelper.mjs +16 -17
- package/functions/pre-transaction/constructAdminData.cjs +1 -1
- package/functions/pre-transaction/constructAdminData.d.ts +2 -2
- package/functions/pre-transaction/constructAdminData.mjs +18 -12
- package/functions/pre-transaction/getExternalSwapAddress.cjs +1 -1
- package/functions/pre-transaction/getExternalSwapAddress.d.ts +2 -1
- package/functions/pre-transaction/getExternalSwapAddress.mjs +8 -8
- package/functions/pre-transaction/getFlatFees.cjs +1 -1
- package/functions/pre-transaction/getFlatFees.mjs +2 -3
- package/functions/pre-transaction/getSolanaCalldataHash.cjs +1 -1
- package/functions/pre-transaction/getSolanaCalldataHash.mjs +21 -21
- package/functions/pre-transaction/getVolatileTransferAmount.cjs +1 -1
- package/functions/pre-transaction/getVolatileTransferAmount.mjs +36 -22
- package/functions/pre-transaction/interaction-to-action.cjs +1 -1
- package/functions/pre-transaction/interaction-to-action.mjs +2 -3
- package/functions/pre-transaction/merge-with-fee-structure-emporium.cjs +1 -1
- package/functions/pre-transaction/merge-with-fee-structure-emporium.d.ts +1 -1
- package/functions/pre-transaction/merge-with-fee-structure-emporium.mjs +17 -17
- package/functions/pre-transaction/outputApprovalDataProcessing.cjs +1 -1
- package/functions/pre-transaction/outputApprovalDataProcessing.d.ts +9 -1
- package/functions/pre-transaction/outputApprovalDataProcessing.mjs +34 -19
- package/functions/pre-transaction/sendV0Transaction.cjs +1 -1
- package/functions/pre-transaction/sendV0Transaction.mjs +50 -53
- package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs +1 -1
- package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.d.ts +1 -1
- package/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs +4 -4
- package/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.helpers.d.ts +12 -10
- package/functions/private-wallet/emporium.helpers.mjs +139 -102
- package/functions/private-wallet/emporium.swap.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.swap.helpers.d.ts +4 -1
- package/functions/private-wallet/emporium.swap.helpers.mjs +106 -103
- package/functions/private-wallet/opProducer.cjs +1 -1
- package/functions/private-wallet/opProducer.mjs +1 -1
- package/functions/snarkjs/common.snarkjs.cjs +1 -1
- package/functions/snarkjs/common.snarkjs.mjs +21 -18
- package/functions/snarkjs/constructEmporiumProof.cjs +1 -1
- package/functions/snarkjs/constructEmporiumProof.mjs +49 -49
- package/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/functions/snarkjs/constructSolanaZkProof.mjs +11 -10
- package/functions/snarkjs/fetchMerkleTreeSiblings.cjs +1 -1
- package/functions/snarkjs/fetchMerkleTreeSiblings.mjs +10 -11
- package/functions/utils/addresses.cjs +1 -1
- package/functions/utils/addresses.d.ts +0 -1
- package/functions/utils/addresses.mjs +11 -12
- package/functions/utils/cacheFunctions.cjs +1 -1
- package/functions/utils/cacheFunctions.d.ts +1 -1
- package/functions/utils/cacheFunctions.mjs +55 -54
- package/functions/utils/convertEmporiumOpToCallInfo.cjs +1 -1
- package/functions/utils/convertEmporiumOpToCallInfo.mjs +5 -5
- package/functions/utils/create-provider.cjs +1 -1
- package/functions/utils/create-provider.d.ts +2 -2
- package/functions/utils/create-provider.mjs +7 -11
- package/functions/utils/encryptInputForEnclave.cjs +1 -1
- package/functions/utils/encryptInputForEnclave.mjs +9 -9
- package/functions/utils/ethers-formatter.utils.d.ts +1 -1
- package/functions/utils/external-action.utils.cjs +1 -1
- package/functions/utils/external-action.utils.mjs +2 -2
- package/functions/utils/get-hinkal-approvals.cjs +1 -0
- package/functions/utils/get-hinkal-approvals.d.ts +3 -0
- package/functions/utils/get-hinkal-approvals.mjs +38 -0
- package/functions/utils/getContractAddress.cjs +1 -0
- package/functions/utils/getContractAddress.d.ts +2 -0
- package/functions/utils/getContractAddress.mjs +9 -0
- package/functions/utils/getDataFromTransaction.cjs +1 -1
- package/functions/utils/getDataFromTransaction.d.ts +0 -11
- package/functions/utils/getDataFromTransaction.mjs +26 -50
- package/functions/utils/getRecipientInfoFromUserKeys.cjs +1 -1
- package/functions/utils/getRecipientInfoFromUserKeys.mjs +1 -1
- package/functions/utils/getSignerFromContract.cjs +1 -0
- package/functions/utils/getSignerFromContract.d.ts +3 -0
- package/functions/utils/getSignerFromContract.mjs +16 -0
- package/functions/utils/getUtxosFromReceipt.utils.cjs +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.d.ts +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.mjs +14 -15
- package/functions/utils/inLogicMetadata.cjs +1 -1
- package/functions/utils/inLogicMetadata.mjs +2 -2
- package/functions/utils/index.d.ts +1 -0
- package/functions/utils/involves-permit2-op.cjs +1 -1
- package/functions/utils/involves-permit2-op.d.ts +1 -0
- package/functions/utils/involves-permit2-op.mjs +6 -4
- package/functions/utils/mutexes.utils.cjs +1 -1
- package/functions/utils/mutexes.utils.d.ts +1 -1
- package/functions/utils/mutexes.utils.mjs +3 -3
- package/functions/utils/nftTokenFunctions.cjs +1 -1
- package/functions/utils/nftTokenFunctions.mjs +23 -9
- package/functions/utils/prepareHinkal.cjs +1 -1
- package/functions/utils/prepareHinkal.d.ts +13 -6
- package/functions/utils/prepareHinkal.mjs +72 -45
- package/functions/utils/publicBalance.utils.cjs +1 -1
- package/functions/utils/publicBalance.utils.d.ts +1 -1
- package/functions/utils/publicBalance.utils.mjs +62 -57
- 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 -1
- package/functions/utils/rpc-int-encode.d.ts +1 -2
- package/functions/utils/rpc-int-encode.mjs +3 -6
- package/functions/utils/solanaMint.utils.cjs +1 -1
- package/functions/utils/solanaMint.utils.mjs +6 -6
- package/functions/utils/string.utils.cjs +1 -1
- package/functions/utils/string.utils.d.ts +0 -1
- package/functions/utils/string.utils.mjs +14 -18
- package/functions/utils/token-check.utils.cjs +1 -1
- package/functions/utils/token-check.utils.d.ts +0 -3
- package/functions/utils/token-check.utils.mjs +7 -18
- package/functions/utils/upToDateState.cjs +1 -1
- package/functions/utils/upToDateState.d.ts +1 -1
- package/functions/utils/upToDateState.mjs +4 -4
- package/functions/utils/walletBalances.utils.cjs +1 -1
- package/functions/utils/walletBalances.utils.d.ts +17 -2
- package/functions/utils/walletBalances.utils.mjs +36 -5
- package/functions/web3/EIP-712.cjs +1 -1
- package/functions/web3/EIP-712.d.ts +4 -4
- package/functions/web3/EIP-712.mjs +1 -1
- package/functions/web3/etherFunctions.cjs +1 -1
- package/functions/web3/etherFunctions.mjs +32 -29
- package/functions/web3/events/balanceChangedCustomHandler.cjs +1 -1
- package/functions/web3/events/balanceChangedCustomHandler.mjs +4 -5
- package/functions/web3/events/balanceChangedHandler.cjs +1 -1
- package/functions/web3/events/balanceChangedHandler.mjs +2 -3
- package/functions/web3/events/getApprovedBalance.cjs +1 -1
- package/functions/web3/events/getApprovedBalance.d.ts +4 -3
- package/functions/web3/events/getApprovedBalance.mjs +44 -39
- package/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
- package/functions/web3/events/getInputUtxoAndBalance.d.ts +3 -3
- package/functions/web3/events/getInputUtxoAndBalance.mjs +150 -129
- package/functions/web3/events/getInputUtxosEnclave.cjs +1 -1
- package/functions/web3/events/getInputUtxosEnclave.mjs +20 -20
- package/functions/web3/events/getShieldedBalance.cjs +2 -2
- package/functions/web3/events/getShieldedBalance.d.ts +1 -1
- package/functions/web3/events/getShieldedBalance.mjs +75 -73
- package/functions/web3/events/getTransactionLogEvents.cjs +1 -1
- package/functions/web3/events/getTransactionLogEvents.d.ts +3 -3
- package/functions/web3/events/getTransactionLogEvents.mjs +41 -40
- package/functions/web3/events/index.d.ts +0 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.d.ts +1 -2
- package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +12 -16
- package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
- package/functions/web3/functionCalls/accessTokenCalls.d.ts +6 -1
- package/functions/web3/functionCalls/accessTokenCalls.mjs +20 -12
- package/functions/web3/functionCalls/approveToken.cjs +1 -1
- package/functions/web3/functionCalls/approveToken.d.ts +1 -1
- package/functions/web3/functionCalls/approveToken.mjs +68 -69
- package/functions/web3/functionCalls/approveTokensToHinkal.cjs +1 -1
- package/functions/web3/functionCalls/approveTokensToHinkal.d.ts +1 -1
- package/functions/web3/functionCalls/approveTokensToHinkal.mjs +6 -6
- package/functions/web3/functionCalls/constructBatchCall.cjs +1 -1
- package/functions/web3/functionCalls/constructBatchCall.d.ts +2 -2
- package/functions/web3/functionCalls/constructBatchCall.mjs +10 -9
- package/functions/web3/functionCalls/estimateGasRelayer.cjs +1 -1
- package/functions/web3/functionCalls/estimateGasRelayer.d.ts +2 -1
- package/functions/web3/functionCalls/estimateGasRelayer.mjs +10 -10
- package/functions/web3/functionCalls/inHinkalApprovalCalls.cjs +1 -0
- package/functions/web3/functionCalls/inHinkalApprovalCalls.d.ts +5 -0
- package/functions/web3/functionCalls/inHinkalApprovalCalls.mjs +29 -0
- package/functions/web3/functionCalls/recoverTransactionFromError.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +47 -39
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.d.ts +3 -3
- package/functions/web3/functionCalls/transactCallRelayer.mjs +54 -56
- package/functions/web3/getContractMetadata.cjs +1 -1
- package/functions/web3/getContractMetadata.d.ts +1 -1
- package/functions/web3/getContractMetadata.mjs +21 -16
- package/functions/web3/getPublicAddressBalance.cjs +1 -1
- package/functions/web3/getPublicAddressBalance.d.ts +1 -1
- package/functions/web3/getPublicAddressBalance.mjs +7 -6
- package/functions/web3/getTokenHolder.cjs +1 -1
- package/functions/web3/getTokenHolder.mjs +32 -31
- package/functions/web3/index.d.ts +0 -1
- package/functions/web3/lifiAPI.cjs +1 -1
- package/functions/web3/lifiAPI.d.ts +1 -1
- package/functions/web3/lifiAPI.mjs +12 -12
- package/functions/web3/odosAPI.cjs +1 -1
- package/functions/web3/odosAPI.mjs +15 -3
- package/functions/web3/okxAPI.cjs +1 -1
- package/functions/web3/okxAPI.mjs +13 -13
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.mjs +20 -8
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.d.ts +6 -5
- package/functions/web3/runContractFunction.mjs +60 -46
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.d.ts +2 -2
- package/functions/web3/uniswapAPI.mjs +49 -38
- package/index.cjs +1 -1
- package/index.mjs +912 -914
- package/package.json +4 -6
- package/providers/CustomEthersProvider.d.ts +1 -1
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.d.ts +21 -14
- package/providers/EthersProviderAdapter.mjs +86 -53
- package/providers/SolanaProviderAdapter.cjs +1 -1
- package/providers/SolanaProviderAdapter.d.ts +12 -8
- package/providers/SolanaProviderAdapter.mjs +31 -16
- package/providers/WagmiProviderAdapter.cjs +1 -1
- package/providers/WagmiProviderAdapter.d.ts +20 -14
- package/providers/WagmiProviderAdapter.mjs +126 -91
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.d.ts +2 -2
- package/providers/prepareEthersHinkal.mjs +9 -16
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +9 -17
- package/types/TransactionSimulator.types.d.ts +9 -2
- package/types/activities.types.d.ts +2 -5
- package/types/admin.types.cjs +1 -1
- package/types/admin.types.d.ts +6 -0
- package/types/admin.types.mjs +2 -2
- package/types/balances.types.d.ts +1 -0
- package/types/big-intable.types.d.ts +3 -2
- package/types/bridging.types.d.ts +29 -0
- package/types/cache.types.cjs +1 -1
- package/types/cache.types.d.ts +3 -6
- package/types/cache.types.mjs +1 -1
- package/types/coingecko.types.d.ts +0 -5
- package/types/duneAPI.types.d.ts +9 -0
- package/types/ethereum-network.types.d.ts +10 -11
- package/types/hinkal.types.cjs +1 -1
- package/types/hinkal.types.d.ts +1 -1
- package/types/hinkal.types.mjs +18 -18
- package/types/index.d.ts +2 -2
- package/types/proxy.types.d.ts +3 -6
- package/types/sandbox.types.cjs +1 -1
- package/types/sandbox.types.d.ts +39 -10
- package/types/sandbox.types.mjs +2 -2
- package/types/scheduled-transactions.types.cjs +1 -1
- package/types/scheduled-transactions.types.d.ts +6 -0
- package/types/scheduled-transactions.types.mjs +3 -2
- package/types/session.types.d.ts +0 -2
- package/types/solana.types.d.ts +0 -9
- package/types/token-prices.types.cjs +1 -1
- package/types/token-prices.types.d.ts +0 -7
- package/types/token-prices.types.mjs +2 -4
- package/types/transactions.types.cjs +1 -1
- package/types/transactions.types.d.ts +2 -3
- package/types/transactions.types.mjs +6 -7
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
- 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 +1 -1
- package/webworker/viteWorkerURL.constant.cjs +3 -3
- package/webworker/viteWorkerURL.constant.mjs +3 -3
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
- package/API/get-token-price-chart-data.cjs +0 -1
- package/API/get-token-price-chart-data.d.ts +0 -16
- package/API/get-token-price-chart-data.mjs +0 -13
- package/API/onrampCalls.cjs +0 -1
- package/API/onrampCalls.d.ts +0 -20
- package/API/onrampCalls.mjs +0 -15
- package/API/unspent-utxos-calls.cjs +0 -1
- package/API/unspent-utxos-calls.d.ts +0 -26
- package/API/unspent-utxos-calls.mjs +0 -26
- package/data-structures/AccountActions/AccountActions.cjs +0 -1
- package/data-structures/AccountActions/AccountActions.d.ts +0 -18
- package/data-structures/AccountActions/AccountActions.mjs +0 -78
- package/data-structures/AccountActions/index.d.ts +0 -1
- package/data-structures/BlockchainEvent/BlockchainEvent.cjs +0 -1
- package/data-structures/BlockchainEvent/BlockchainEvent.d.ts +0 -14
- package/data-structures/BlockchainEvent/BlockchainEvent.mjs +0 -41
- package/data-structures/PublicBalance/PublicBalanceWatcher.cjs +0 -1
- package/data-structures/PublicBalance/PublicBalanceWatcher.d.ts +0 -20
- package/data-structures/PublicBalance/PublicBalanceWatcher.mjs +0 -124
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.cjs +0 -1
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.d.ts +0 -15
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.mjs +0 -64
- package/data-structures/PublicBalance/index.d.ts +0 -2
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.cjs +0 -1
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.d.ts +0 -11
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.mjs +0 -21
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.cjs +0 -1
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.d.ts +0 -6
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.mjs +0 -16
- package/data-structures/event-service/helpers/ClientEventHelper.cjs +0 -1
- package/data-structures/event-service/helpers/ClientEventHelper.d.ts +0 -11
- package/data-structures/event-service/helpers/ClientEventHelper.mjs +0 -26
- package/data-structures/event-service/helpers/PollingEventHelper.cjs +0 -1
- package/data-structures/event-service/helpers/PollingEventHelper.d.ts +0 -5
- package/data-structures/event-service/helpers/PollingEventHelper.mjs +0 -14
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.cjs +0 -1
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.d.ts +0 -11
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.mjs +0 -22
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.cjs +0 -1
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.d.ts +0 -6
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.mjs +0 -16
- package/functions/utils/enum.utils.cjs +0 -1
- package/functions/utils/enum.utils.mjs +0 -14
- package/functions/utils/socket.utils.cjs +0 -1
- package/functions/utils/socket.utils.d.ts +0 -1
- package/functions/utils/socket.utils.mjs +0 -12
- package/functions/web3/crypto.cjs +0 -1
- package/functions/web3/crypto.d.ts +0 -1
- package/functions/web3/crypto.mjs +0 -7
- package/functions/web3/events/web3RetrieveEvents.cjs +0 -1
- package/functions/web3/events/web3RetrieveEvents.d.ts +0 -14
- package/functions/web3/events/web3RetrieveEvents.mjs +0 -9
- package/types/events.types.cjs +0 -1
- package/types/events.types.d.ts +0 -9
- package/types/events.types.mjs +0 -5
- package/types/onramp.types.cjs +0 -1
- package/types/onramp.types.d.ts +0 -58
- package/types/onramp.types.mjs +0 -4
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
import { ethers as a } from "ethers";
|
|
2
1
|
import { PublicKey as T } from "@solana/web3.js";
|
|
3
|
-
import { poseidonHash as
|
|
2
|
+
import { poseidonHash as C } from "../../crypto/poseidon.mjs";
|
|
4
3
|
import { isSolanaLike as y } from "../../constants/chains.constants.mjs";
|
|
5
|
-
import { Utxo as
|
|
6
|
-
import { UserKeys as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
import { Utxo as E } from "../utxo/Utxo.mjs";
|
|
5
|
+
import { UserKeys as z } from "./keys.mjs";
|
|
6
|
+
import { ethers as d } from "ethers";
|
|
7
|
+
const f = "solana-on-chain-utxo:", x = 8, F = (e) => {
|
|
8
|
+
if (e.length !== x)
|
|
9
|
+
throw new Error(`Expected ${x} on-chain fields, received ${e.length}`);
|
|
10
|
+
const t = e.map((o, r) => {
|
|
11
|
+
const n = o instanceof Uint8Array ? o : Uint8Array.from(o);
|
|
12
12
|
if (n.length !== 32)
|
|
13
13
|
throw new Error(`Expected bytes32 length 32 at position ${r}, got ${n.length}`);
|
|
14
14
|
return `0x${Buffer.from(n).toString("hex")}`;
|
|
15
15
|
});
|
|
16
|
-
return `${
|
|
17
|
-
},
|
|
18
|
-
if (!
|
|
16
|
+
return `${f}${d.AbiCoder.defaultAbiCoder().encode(["bytes32[8]"], [t])}`;
|
|
17
|
+
}, O = (e) => e.startsWith(f), B = (e) => {
|
|
18
|
+
if (!O(e))
|
|
19
19
|
throw new Error("Invalid encoded Solana UTXO payload");
|
|
20
|
-
const [t] =
|
|
20
|
+
const [t] = d.AbiCoder.defaultAbiCoder().decode(
|
|
21
21
|
["bytes32[8]"],
|
|
22
|
-
|
|
23
|
-
),
|
|
24
|
-
if (!Array.isArray(
|
|
22
|
+
e.slice(f.length)
|
|
23
|
+
), o = t;
|
|
24
|
+
if (!Array.isArray(o) || o.length !== x)
|
|
25
25
|
throw new Error("Malformed encoded Solana UTXO payload");
|
|
26
26
|
const [
|
|
27
27
|
r,
|
|
28
28
|
n,
|
|
29
29
|
s,
|
|
30
30
|
i,
|
|
31
|
-
|
|
31
|
+
a,
|
|
32
32
|
c,
|
|
33
33
|
m,
|
|
34
|
-
|
|
35
|
-
] =
|
|
34
|
+
A
|
|
35
|
+
] = o, l = BigInt(r), g = BigInt(i), h = d.toBeHex(BigInt(a)), u = BigInt(c), H = BigInt(m), S = BigInt(A).toString(), p = Array.from(d.getBytes(n)), U = Array.from(d.getBytes(s)), b = Uint8Array.from([...p.slice(16), ...U.slice(16)]), w = new T(b).toBase58(), k = C(BigInt(n), BigInt(s));
|
|
36
36
|
return {
|
|
37
|
-
amount:
|
|
37
|
+
amount: l,
|
|
38
38
|
erc20TokenAddress: k,
|
|
39
39
|
mintAddress: w,
|
|
40
|
-
randomization:
|
|
40
|
+
randomization: g,
|
|
41
41
|
stealthAddress: h,
|
|
42
|
-
H0:
|
|
43
|
-
H1:
|
|
44
|
-
timeStamp:
|
|
42
|
+
H0: u,
|
|
43
|
+
H1: H,
|
|
44
|
+
timeStamp: S
|
|
45
45
|
};
|
|
46
|
-
},
|
|
47
|
-
const t =
|
|
46
|
+
}, I = (e) => {
|
|
47
|
+
const t = d.AbiCoder.defaultAbiCoder().decode(
|
|
48
48
|
["uint256", "address", "tuple(uint256, uint256, uint256, uint256)", "uint256", "uint256"],
|
|
49
|
-
|
|
50
|
-
),
|
|
49
|
+
e
|
|
50
|
+
), o = BigInt(t[0]), r = t[1], n = BigInt(t[2][0]), s = d.toBeHex(BigInt(t[2][1])), i = BigInt(t[2][2]), a = BigInt(t[2][3]), c = BigInt(t[3]).toString(), m = Number(t[4]);
|
|
51
51
|
return {
|
|
52
|
-
amount:
|
|
52
|
+
amount: o,
|
|
53
53
|
erc20TokenAddress: r,
|
|
54
54
|
randomization: n,
|
|
55
55
|
stealthAddress: s,
|
|
56
56
|
H0: i,
|
|
57
|
-
H1:
|
|
57
|
+
H1: a,
|
|
58
58
|
timeStamp: c,
|
|
59
59
|
tokenId: m
|
|
60
60
|
};
|
|
61
|
-
},
|
|
62
|
-
if (y(
|
|
63
|
-
const { amount: m, erc20TokenAddress:
|
|
61
|
+
}, $ = (e, t, o) => {
|
|
62
|
+
if (y(o)) {
|
|
63
|
+
const { amount: m, erc20TokenAddress: A, mintAddress: l, randomization: g, stealthAddress: h, timeStamp: u } = B(e);
|
|
64
64
|
return {
|
|
65
65
|
amount: m,
|
|
66
|
-
erc20TokenAddress:
|
|
67
|
-
mintAddress:
|
|
68
|
-
timeStamp:
|
|
66
|
+
erc20TokenAddress: A,
|
|
67
|
+
mintAddress: l,
|
|
68
|
+
timeStamp: u,
|
|
69
69
|
tokenId: 0,
|
|
70
|
-
randomization:
|
|
70
|
+
randomization: g,
|
|
71
71
|
shieldedPrivateKey: t,
|
|
72
72
|
stealthAddress: h
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
const { amount: r, erc20TokenAddress: n, timeStamp: s, tokenId: i, randomization:
|
|
75
|
+
const { amount: r, erc20TokenAddress: n, timeStamp: s, tokenId: i, randomization: a, stealthAddress: c } = I(e);
|
|
76
76
|
return {
|
|
77
77
|
amount: r,
|
|
78
78
|
erc20TokenAddress: n,
|
|
79
79
|
timeStamp: s,
|
|
80
80
|
tokenId: i,
|
|
81
|
-
randomization:
|
|
81
|
+
randomization: a,
|
|
82
82
|
shieldedPrivateKey: t,
|
|
83
83
|
stealthAddress: c
|
|
84
84
|
};
|
|
85
|
-
}, v = (
|
|
86
|
-
const { randomization: r, H0: n, H1: s } = y(
|
|
85
|
+
}, v = (e, t, o) => new E($(e, t, o)), M = (e, t, o) => {
|
|
86
|
+
const { randomization: r, H0: n, H1: s } = y(o) ? B(e) : I(e), i = z.checkSignature(r, n, s, t);
|
|
87
87
|
if (!i)
|
|
88
88
|
throw new Error("UTXO doesn't belong to user");
|
|
89
89
|
return i;
|
|
90
90
|
};
|
|
91
91
|
export {
|
|
92
|
-
|
|
92
|
+
I as abiDecodeUtxo,
|
|
93
93
|
M as checkUtxoSignature,
|
|
94
|
-
|
|
94
|
+
B as decodeSolanaOnChainUtxo,
|
|
95
95
|
v as decodeUtxo,
|
|
96
|
-
|
|
96
|
+
$ as decodeUtxoConstructorArgs,
|
|
97
97
|
F as encodeSolanaOnChainUtxo,
|
|
98
|
-
|
|
98
|
+
O as isSolanaOnChainUtxo
|
|
99
99
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("ethers"),a=require("libsodium-wrappers"),l=require("../utxo/Utxo.cjs"),m=require("@solana/web3.js"),B=require("./keys.cjs"),g=e=>{const r=[Buffer.from(o.ethers.toBeHex(e.amount)),Buffer.from(e.erc20TokenAddress),Buffer.from(o.ethers.toBeHex(e.randomization)),Buffer.from(e.getStealthAddress()),Buffer.from(o.ethers.toBeHex(BigInt(e.timeStamp))),Buffer.from(o.ethers.toBeHex(e.tokenId??0))];if(e.mintAddress){const t=new m.PublicKey(e.mintAddress).toBytes();r.push(Buffer.from(t))}const n=Buffer.concat(r);return a.crypto_box_seal(n,o.ethers.getBytes(e.getEncryptionKey()))},p=(e,r)=>{const{publicKey:n,privateKey:c}=B.UserKeys.getEncryptionKeyPair(r.getShieldedPrivateKey()),d=a.crypto_box_seal_open(e,o.ethers.getBytes(n),o.ethers.getBytes(c)),t=Buffer.from(d).toString("utf-8").split("0x").filter(s=>s.length!==0).map((s,y)=>{let i;return[0,2,4,5].includes(y)?i=BigInt(`0x${s}`):[1,3,6].includes(y)&&(i=`0x${s}`),i}),f=typeof t[6]=="string"?t[6]:void 0,u=f?new m.PublicKey(Buffer.from(f.slice(2),"hex")).toString():void 0;return{amount:t[0],erc20TokenAddress:t[1],randomization:t[2],stealthAddress:t[3],shieldedPrivateKey:r.getShieldedPrivateKey(),timeStamp:t[4].toString(),tokenId:t[5]?Number(t[5]):0,mintAddress:u}},h=(e,r)=>new l.Utxo(p(e,r));exports.decryptUtxo=h;exports.decryptUtxoConstructorArgs=p;exports.encryptUtxo=g;
|
|
@@ -1,46 +1,47 @@
|
|
|
1
|
-
import { ethers as
|
|
2
|
-
import
|
|
3
|
-
import { Utxo as
|
|
4
|
-
import { PublicKey as
|
|
5
|
-
import { UserKeys as
|
|
1
|
+
import { ethers as o } from "ethers";
|
|
2
|
+
import a from "libsodium-wrappers";
|
|
3
|
+
import { Utxo as B } from "../utxo/Utxo.mjs";
|
|
4
|
+
import { PublicKey as p } from "@solana/web3.js";
|
|
5
|
+
import { UserKeys as l } from "./keys.mjs";
|
|
6
6
|
const K = (e) => {
|
|
7
|
-
const
|
|
8
|
-
Buffer.from(
|
|
9
|
-
Buffer.from(
|
|
10
|
-
|
|
7
|
+
const r = [
|
|
8
|
+
Buffer.from(o.toBeHex(e.amount)),
|
|
9
|
+
Buffer.from(e.erc20TokenAddress),
|
|
10
|
+
// if it is zeroAddress toBeHex will return 0x00
|
|
11
|
+
Buffer.from(o.toBeHex(e.randomization)),
|
|
11
12
|
Buffer.from(e.getStealthAddress()),
|
|
12
|
-
Buffer.from(
|
|
13
|
-
Buffer.from(
|
|
13
|
+
Buffer.from(o.toBeHex(BigInt(e.timeStamp))),
|
|
14
|
+
Buffer.from(o.toBeHex(e.tokenId ?? 0))
|
|
14
15
|
];
|
|
15
16
|
if (e.mintAddress) {
|
|
16
|
-
const
|
|
17
|
-
|
|
17
|
+
const t = new p(e.mintAddress).toBytes();
|
|
18
|
+
r.push(Buffer.from(t));
|
|
18
19
|
}
|
|
19
|
-
const
|
|
20
|
-
return
|
|
21
|
-
},
|
|
22
|
-
const { publicKey:
|
|
20
|
+
const s = Buffer.concat(r);
|
|
21
|
+
return a.crypto_box_seal(s, o.getBytes(e.getEncryptionKey()));
|
|
22
|
+
}, g = (e, r) => {
|
|
23
|
+
const { publicKey: s, privateKey: f } = l.getEncryptionKeyPair(r.getShieldedPrivateKey()), d = a.crypto_box_seal_open(
|
|
23
24
|
e,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
), t = Buffer.from(
|
|
27
|
-
let
|
|
28
|
-
return [0, 2, 4, 5].includes(
|
|
29
|
-
}),
|
|
25
|
+
o.getBytes(s),
|
|
26
|
+
o.getBytes(f)
|
|
27
|
+
), t = Buffer.from(d).toString("utf-8").split("0x").filter((n) => n.length !== 0).map((n, c) => {
|
|
28
|
+
let i;
|
|
29
|
+
return [0, 2, 4, 5].includes(c) ? i = BigInt(`0x${n}`) : [1, 3, 6].includes(c) && (i = `0x${n}`), i;
|
|
30
|
+
}), m = typeof t[6] == "string" ? t[6] : void 0, y = m ? new p(Buffer.from(m.slice(2), "hex")).toString() : void 0;
|
|
30
31
|
return {
|
|
31
32
|
amount: t[0],
|
|
32
33
|
erc20TokenAddress: t[1],
|
|
33
34
|
randomization: t[2],
|
|
34
35
|
stealthAddress: t[3],
|
|
35
|
-
shieldedPrivateKey:
|
|
36
|
+
shieldedPrivateKey: r.getShieldedPrivateKey(),
|
|
36
37
|
timeStamp: t[4].toString(),
|
|
37
38
|
tokenId: t[5] ? Number(t[5]) : 0,
|
|
38
39
|
// tokenId
|
|
39
|
-
mintAddress:
|
|
40
|
+
mintAddress: y
|
|
40
41
|
};
|
|
41
|
-
}, S = (e,
|
|
42
|
+
}, S = (e, r) => new B(g(e, r));
|
|
42
43
|
export {
|
|
43
44
|
S as decryptUtxo,
|
|
44
|
-
|
|
45
|
+
g as decryptUtxoConstructorArgs,
|
|
45
46
|
K as encryptUtxo
|
|
46
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("ethers"),w=require("libsodium-wrappers"),S=require("../../constants/protocol.constants.cjs"),f=require("../../crypto/babyJub.cjs"),h=require("../../crypto/poseidon.cjs"),d=require("./keyUtils.cjs"),K=require("../cacheDevices/AttachableMemoryCacheDevice.cjs"),l=require("../../constants/chains.constants.cjs"),c=require("@solana/web3.js"),m=require("tweetnacl"),p=require("bs58"),b=require("../../functions/utils/create-provider.cjs"),v=new K.AttachableMemoryCacheDevice,P=new K.AttachableMemoryCacheDevice,q={privateKey:"",publicKey:""};class g{signature;constructor(e){this.signature=e}getSignature(){return this.requireSignature(),this.signature}setSignature(e){this.signature=e}requireSignature(){if(!this.signature)throw Error("No signature provided")}verifyMessage(e){return this.requireSignature(),n.ethers.verifyMessage(e,this.signature)}getShieldedPrivateKey=()=>(this.requireSignature(),n.ethers.keccak256(this.signature));getShieldedPublicKey=()=>(this.requireSignature(),h.poseidonHash(this.getShieldedPrivateKey()));getDerivedEthereumAddress=()=>(this.requireSignature(),new n.ethers.Wallet(this.getShieldedPrivateKey()).address);getDerivedSolanaPublicKey=()=>(this.requireSignature(),c.Keypair.fromSeed(n.ethers.getBytes(this.getShieldedPrivateKey())).publicKey.toBase58());getAccessKey=()=>(this.requireSignature(),h.poseidonHash(this.getShieldedPrivateKey(),this.getShieldedPublicKey()));getSignerPrivateKeyFromNonce=e=>{this.requireSignature();const r=h.poseidonHash(e,this.getShieldedPrivateKey(),this.getShieldedPublicKey());return n.ethers.keccak256(n.ethers.toUtf8Bytes(r))};getSignerSolanaPrivateKeyFromNonce=e=>{const r=this.getSignerPrivateKeyFromNonce(e),t=n.ethers.getBytes(r),i=c.Keypair.fromSeed(t);return p.encode(i.secretKey)};getEvmPrivateKeyFromSolanaPrivateKey=e=>{const t=p.decode(e).slice(0,32);return n.ethers.hexlify(t)};static getSignerFromPrivateKey=(e,r)=>{if(l.isSolanaLike(e)){const i=n.ethers.getBytes(r);return c.Keypair.fromSeed(i)}return new n.ethers.Wallet(r)};static getSignerAddressFromPrivateKey(e,r){const t=g.getSignerFromPrivateKey(e,r);return t instanceof c.Keypair?t.publicKey.toString():t.address}static signMessageFromPrivateKey=async(e,r,t)=>{const i=g.getSignerFromPrivateKey(e,r);if(i instanceof c.Keypair){const a=n.ethers.isHexString(t)?n.ethers.getBytes(t):new TextEncoder().encode(t),o=m.sign.detached(a,i.secretKey);return`0x${Buffer.from(o).toString("hex")}`}const s=n.ethers.isHexString(t)?n.ethers.getBytes(t):t;return i.signMessage(s)};static signSolanaTransactionFromPrivateKey=(e,r,t)=>{if(!l.isSolanaLike(e))throw new Error("Solana transaction signing is only available for Solana chains");const i=g.getSignerFromPrivateKey(e,r);if(!(i instanceof c.Keypair))throw new Error("Unable to derive Solana keypair for signing");t.sign([i])};static sendAndSignTransactionFromPrivateKey=async(e,r,t)=>{const i=g.getSignerFromPrivateKey(e,r),{fetchRpcUrl:s}=l.networkRegistry[e];if(!s)throw new Error("No RPC URL found for chainId");if(i instanceof c.Keypair){if(!(t instanceof c.VersionedTransaction))throw new Error("Invalid transaction type for Solana");return t.sign([i]),await b.createCustomSolanaConnection(s).sendRawTransaction(t.serialize())}if(t instanceof c.VersionedTransaction)throw new Error("Invalid transaction type for EVM");const a=new n.ethers.JsonRpcProvider(s);return(await i.connect(a).sendTransaction(t)).hash};static signTypedDataFromPrivateKey=async(e,r,t,i,s)=>{if(l.isSolanaLike(e))throw new Error("Solana does not support typed data");return await g.getSignerFromPrivateKey(e,r).signTypedData(t,i,s)};static authorizeDelegation=async(e,r,t,i)=>{if(l.isSolanaLike(e))throw new Error("Solana does not support delegation");const s=new n.ethers.JsonRpcProvider(l.networkRegistry[e].fetchRpcUrl);return await g.getSignerFromPrivateKey(e,r).connect(s).authorize({address:t,...i!==void 0&&{nonce:i}})};getWalletSalt=e=>(this.requireSignature(),h.poseidonHash(this.getShieldedPublicKey(),this.getShieldedPrivateKey(),e));getInHinkalAddress=e=>{this.requireSignature();const r=h.poseidonHash(this.getShieldedPrivateKey(),e);return BigInt(r)};getBackendToken=()=>(this.requireSignature(),h.poseidonHash(this.getAccessKey(),this.getShieldedPublicKey()));static getRandomizedStealthPair=v.attach((e,r)=>{const t=f.babyJubInstance(),i=BigInt(r)%S.CIRCOM_P,s=e*i%S.CIRCOM_P,a=t.mulPointEscalar(t.Base8,e),o=t.mulPointEscalar(t.Base8,s),u=[BigInt(t.F.toString(a[0])),BigInt(t.F.toString(a[1]))],y=[BigInt(t.F.toString(o[0])),BigInt(t.F.toString(o[1]))];return{H0:u,H1:y}});static getStealthAddressCompressedPoints=(e,r)=>{const{H0:t,H1:i}=this.getRandomizedStealthPair(e,r),[s,a]=[t,i].map(o=>BigInt(o[1])+2n**255n*d.getCircomSign(o[0]));return{h0:s,h1:a}};static getStealthAddress=P.attach((e,r)=>{const{H0:t,H1:i}=this.getRandomizedStealthPair(e,r),a=[2n*d.getCircomSign(t[0])+d.getCircomSign(i[0]),t[1],i[1]];return h.poseidonHash(...a)});static getStealthAddressWithEKey=(e,r)=>({stealthAddress:this.getStealthAddress(e,r),encryptionKey:this.getEncryptionKeyPair(r).publicKey});static checkSignature=(e,r,t,i)=>{const{h0:s,h1:a}=this.getStealthAddressCompressedPoints(e,i);return r===s&&t===a};static getEncryptionKeyPair=e=>{const r=w.crypto_box_seed_keypair(n.ethers.getBytes(e));return{privateKey:n.ethers.hexlify(r.privateKey),publicKey:n.ethers.hexlify(r.publicKey)}}}exports.EncryptionKeyPairDefaultValue=q;exports.UserKeys=g;exports.stealthAddressCacheDevice=P;exports.stealthPairCacheDevice=v;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
1
2
|
import { AttachableMemoryCacheDevice } from '../cacheDevices/AttachableMemoryCacheDevice';
|
|
3
|
+
import { VersionedTransaction } from '@solana/web3.js';
|
|
2
4
|
export declare const stealthPairCacheDevice: AttachableMemoryCacheDevice<{
|
|
3
5
|
H0: [bigint, bigint];
|
|
4
6
|
H1: [bigint, bigint];
|
|
@@ -44,6 +46,14 @@ export declare class UserKeys {
|
|
|
44
46
|
getAccessKey: () => string;
|
|
45
47
|
getSignerPrivateKeyFromNonce: (walletNonce: bigint) => string;
|
|
46
48
|
getSignerSolanaPrivateKeyFromNonce: (walletNonce: bigint) => string;
|
|
49
|
+
getEvmPrivateKeyFromSolanaPrivateKey: (solanaPrivateKey: string) => string;
|
|
50
|
+
private static getSignerFromPrivateKey;
|
|
51
|
+
static getSignerAddressFromPrivateKey(chainId: number, privateKey: string): string;
|
|
52
|
+
static signMessageFromPrivateKey: (chainId: number, privateKey: string, message: string) => Promise<string>;
|
|
53
|
+
static signSolanaTransactionFromPrivateKey: (chainId: number, privateKey: string, transaction: VersionedTransaction) => void;
|
|
54
|
+
static sendAndSignTransactionFromPrivateKey: (chainId: number, privateKey: string, transaction: ethers.TransactionRequest | VersionedTransaction) => Promise<string>;
|
|
55
|
+
static signTypedDataFromPrivateKey: (chainId: number, privateKey: string, domain: ethers.TypedDataDomain, types: Record<string, Array<ethers.TypedDataField>>, value: Record<string, any>) => Promise<string>;
|
|
56
|
+
static authorizeDelegation: (chainId: number, privateKey: string, implementation: string, nonce?: number) => Promise<ethers.Authorization>;
|
|
47
57
|
getWalletSalt: (walletNonce: bigint) => string;
|
|
48
58
|
/**
|
|
49
59
|
* generate inHinkalAddress - a user unique address linking him with a specific app
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
|
|
1
|
+
import { ethers as n } from "ethers";
|
|
2
|
+
import P from "libsodium-wrappers";
|
|
3
|
+
import { CIRCOM_P as S } from "../../constants/protocol.constants.mjs";
|
|
4
|
+
import { babyJubInstance as v } from "../../crypto/babyJub.mjs";
|
|
5
|
+
import { poseidonHash as c } from "../../crypto/poseidon.mjs";
|
|
6
|
+
import { getCircomSign as u } from "./keyUtils.mjs";
|
|
7
|
+
import { AttachableMemoryCacheDevice as K } from "../cacheDevices/AttachableMemoryCacheDevice.mjs";
|
|
8
|
+
import { isSolanaLike as d, networkRegistry as p } from "../../constants/chains.constants.mjs";
|
|
9
|
+
import { Keypair as g, VersionedTransaction as m } from "@solana/web3.js";
|
|
10
|
+
import w from "tweetnacl";
|
|
11
|
+
import f from "bs58";
|
|
12
|
+
import { createCustomSolanaConnection as b } from "../../functions/utils/create-provider.mjs";
|
|
13
|
+
const F = new K(), B = new K(), W = {
|
|
12
14
|
privateKey: "",
|
|
13
15
|
publicKey: ""
|
|
14
16
|
};
|
|
15
|
-
class
|
|
17
|
+
class l {
|
|
16
18
|
signature;
|
|
17
19
|
constructor(e) {
|
|
18
20
|
this.signature = e;
|
|
@@ -28,76 +30,133 @@ class x {
|
|
|
28
30
|
throw Error("No signature provided");
|
|
29
31
|
}
|
|
30
32
|
verifyMessage(e) {
|
|
31
|
-
return this.requireSignature(),
|
|
33
|
+
return this.requireSignature(), n.verifyMessage(e, this.signature);
|
|
32
34
|
}
|
|
33
35
|
/**
|
|
34
36
|
* get shielded private key from message signature used to login to the application,
|
|
35
37
|
* this private key is used to generate encryption keypairs as well as public key
|
|
36
38
|
* @retuns 0x-prefixed shielded private key
|
|
37
39
|
*/
|
|
38
|
-
getShieldedPrivateKey = () => (this.requireSignature(),
|
|
40
|
+
getShieldedPrivateKey = () => (this.requireSignature(), n.keccak256(this.signature));
|
|
39
41
|
/**
|
|
40
42
|
* generate shielded public key from private key
|
|
41
43
|
* @param privateKey the key used to generate the shielded public key, this should be the signature
|
|
42
44
|
* that the user provided
|
|
43
45
|
* @retuns shielded public key in hexstring with 0x prefixed
|
|
44
46
|
*/
|
|
45
|
-
getShieldedPublicKey = () => (this.requireSignature(),
|
|
47
|
+
getShieldedPublicKey = () => (this.requireSignature(), c(this.getShieldedPrivateKey()));
|
|
46
48
|
/**
|
|
47
49
|
* deterministically derive an EVM address from the shielded private key
|
|
48
50
|
*/
|
|
49
|
-
getDerivedEthereumAddress = () => (this.requireSignature(), new
|
|
51
|
+
getDerivedEthereumAddress = () => (this.requireSignature(), new n.Wallet(this.getShieldedPrivateKey()).address);
|
|
50
52
|
/**
|
|
51
53
|
* deterministically derive a Solana public key from the shielded private key
|
|
52
54
|
*/
|
|
53
|
-
getDerivedSolanaPublicKey = () => (this.requireSignature(),
|
|
55
|
+
getDerivedSolanaPublicKey = () => (this.requireSignature(), g.fromSeed(n.getBytes(this.getShieldedPrivateKey())).publicKey.toBase58());
|
|
54
56
|
/**
|
|
55
57
|
* generate access token, this accessKey is what should be sent to the server for signing
|
|
56
58
|
* @returns accessKey in hexstring with 0x prefixed
|
|
57
59
|
*/
|
|
58
|
-
getAccessKey = () => (this.requireSignature(),
|
|
60
|
+
getAccessKey = () => (this.requireSignature(), c(this.getShieldedPrivateKey(), this.getShieldedPublicKey()));
|
|
59
61
|
getSignerPrivateKeyFromNonce = (e) => {
|
|
60
62
|
this.requireSignature();
|
|
61
|
-
const
|
|
62
|
-
return
|
|
63
|
+
const r = c(e, this.getShieldedPrivateKey(), this.getShieldedPublicKey());
|
|
64
|
+
return n.keccak256(n.toUtf8Bytes(r));
|
|
63
65
|
};
|
|
64
66
|
getSignerSolanaPrivateKeyFromNonce = (e) => {
|
|
65
|
-
const
|
|
66
|
-
return
|
|
67
|
+
const r = this.getSignerPrivateKeyFromNonce(e), t = n.getBytes(r), i = g.fromSeed(t);
|
|
68
|
+
return f.encode(i.secretKey);
|
|
67
69
|
};
|
|
68
|
-
|
|
70
|
+
getEvmPrivateKeyFromSolanaPrivateKey = (e) => {
|
|
71
|
+
const t = f.decode(e).slice(0, 32);
|
|
72
|
+
return n.hexlify(t);
|
|
73
|
+
};
|
|
74
|
+
static getSignerFromPrivateKey = (e, r) => {
|
|
75
|
+
if (d(e)) {
|
|
76
|
+
const i = n.getBytes(r);
|
|
77
|
+
return g.fromSeed(i);
|
|
78
|
+
}
|
|
79
|
+
return new n.Wallet(r);
|
|
80
|
+
};
|
|
81
|
+
static getSignerAddressFromPrivateKey(e, r) {
|
|
82
|
+
const t = l.getSignerFromPrivateKey(e, r);
|
|
83
|
+
return t instanceof g ? t.publicKey.toString() : t.address;
|
|
84
|
+
}
|
|
85
|
+
static signMessageFromPrivateKey = async (e, r, t) => {
|
|
86
|
+
const i = l.getSignerFromPrivateKey(e, r);
|
|
87
|
+
if (i instanceof g) {
|
|
88
|
+
const a = n.isHexString(t) ? n.getBytes(t) : new TextEncoder().encode(t), o = w.sign.detached(a, i.secretKey);
|
|
89
|
+
return `0x${Buffer.from(o).toString("hex")}`;
|
|
90
|
+
}
|
|
91
|
+
const s = n.isHexString(t) ? n.getBytes(t) : t;
|
|
92
|
+
return i.signMessage(s);
|
|
93
|
+
};
|
|
94
|
+
static signSolanaTransactionFromPrivateKey = (e, r, t) => {
|
|
95
|
+
if (!d(e))
|
|
96
|
+
throw new Error("Solana transaction signing is only available for Solana chains");
|
|
97
|
+
const i = l.getSignerFromPrivateKey(e, r);
|
|
98
|
+
if (!(i instanceof g))
|
|
99
|
+
throw new Error("Unable to derive Solana keypair for signing");
|
|
100
|
+
t.sign([i]);
|
|
101
|
+
};
|
|
102
|
+
static sendAndSignTransactionFromPrivateKey = async (e, r, t) => {
|
|
103
|
+
const i = l.getSignerFromPrivateKey(e, r), { fetchRpcUrl: s } = p[e];
|
|
104
|
+
if (!s)
|
|
105
|
+
throw new Error("No RPC URL found for chainId");
|
|
106
|
+
if (i instanceof g) {
|
|
107
|
+
if (!(t instanceof m))
|
|
108
|
+
throw new Error("Invalid transaction type for Solana");
|
|
109
|
+
return t.sign([i]), await b(s).sendRawTransaction(t.serialize());
|
|
110
|
+
}
|
|
111
|
+
if (t instanceof m)
|
|
112
|
+
throw new Error("Invalid transaction type for EVM");
|
|
113
|
+
const a = new n.JsonRpcProvider(s);
|
|
114
|
+
return (await i.connect(a).sendTransaction(t)).hash;
|
|
115
|
+
};
|
|
116
|
+
static signTypedDataFromPrivateKey = async (e, r, t, i, s) => {
|
|
117
|
+
if (d(e))
|
|
118
|
+
throw new Error("Solana does not support typed data");
|
|
119
|
+
return await l.getSignerFromPrivateKey(e, r).signTypedData(t, i, s);
|
|
120
|
+
};
|
|
121
|
+
static authorizeDelegation = async (e, r, t, i) => {
|
|
122
|
+
if (d(e))
|
|
123
|
+
throw new Error("Solana does not support delegation");
|
|
124
|
+
const s = new n.JsonRpcProvider(p[e].fetchRpcUrl);
|
|
125
|
+
return await l.getSignerFromPrivateKey(e, r).connect(s).authorize({ address: t, ...i !== void 0 && { nonce: i } });
|
|
126
|
+
};
|
|
127
|
+
getWalletSalt = (e) => (this.requireSignature(), c(this.getShieldedPublicKey(), this.getShieldedPrivateKey(), e));
|
|
69
128
|
/**
|
|
70
129
|
* generate inHinkalAddress - a user unique address linking him with a specific app
|
|
71
130
|
* @returns inHinkalAddress in bigint
|
|
72
131
|
*/
|
|
73
132
|
getInHinkalAddress = (e) => {
|
|
74
133
|
this.requireSignature();
|
|
75
|
-
const
|
|
76
|
-
return BigInt(
|
|
134
|
+
const r = c(this.getShieldedPrivateKey(), e);
|
|
135
|
+
return BigInt(r);
|
|
77
136
|
};
|
|
78
137
|
/**
|
|
79
138
|
* generate backend token, which is used for access control on backend
|
|
80
139
|
* @returns accessKey in hexstring with 0x prefixed
|
|
81
140
|
*/
|
|
82
|
-
getBackendToken = () => (this.requireSignature(),
|
|
83
|
-
static getRandomizedStealthPair =
|
|
84
|
-
(e,
|
|
85
|
-
const
|
|
86
|
-
return { H0:
|
|
141
|
+
getBackendToken = () => (this.requireSignature(), c(this.getAccessKey(), this.getShieldedPublicKey()));
|
|
142
|
+
static getRandomizedStealthPair = F.attach(
|
|
143
|
+
(e, r) => {
|
|
144
|
+
const t = v(), i = BigInt(r) % S, s = e * i % S, a = t.mulPointEscalar(t.Base8, e), o = t.mulPointEscalar(t.Base8, s), h = [BigInt(t.F.toString(a[0])), BigInt(t.F.toString(a[1]))], y = [BigInt(t.F.toString(o[0])), BigInt(t.F.toString(o[1]))];
|
|
145
|
+
return { H0: h, H1: y };
|
|
87
146
|
}
|
|
88
147
|
);
|
|
89
|
-
static getStealthAddressCompressedPoints = (e,
|
|
90
|
-
const { H0:
|
|
91
|
-
return { h0:
|
|
148
|
+
static getStealthAddressCompressedPoints = (e, r) => {
|
|
149
|
+
const { H0: t, H1: i } = this.getRandomizedStealthPair(e, r), [s, a] = [t, i].map((o) => BigInt(o[1]) + 2n ** 255n * u(o[0]));
|
|
150
|
+
return { h0: s, h1: a };
|
|
92
151
|
};
|
|
93
|
-
static getStealthAddress =
|
|
94
|
-
const { H0:
|
|
95
|
-
return
|
|
152
|
+
static getStealthAddress = B.attach((e, r) => {
|
|
153
|
+
const { H0: t, H1: i } = this.getRandomizedStealthPair(e, r), a = [2n * u(t[0]) + u(i[0]), t[1], i[1]];
|
|
154
|
+
return c(...a);
|
|
96
155
|
});
|
|
97
|
-
static getStealthAddressWithEKey = (e,
|
|
98
|
-
static checkSignature = (e,
|
|
99
|
-
const { h0:
|
|
100
|
-
return
|
|
156
|
+
static getStealthAddressWithEKey = (e, r) => ({ stealthAddress: this.getStealthAddress(e, r), encryptionKey: this.getEncryptionKeyPair(r).publicKey });
|
|
157
|
+
static checkSignature = (e, r, t, i) => {
|
|
158
|
+
const { h0: s, h1: a } = this.getStealthAddressCompressedPoints(e, i);
|
|
159
|
+
return r === s && t === a;
|
|
101
160
|
};
|
|
102
161
|
/**
|
|
103
162
|
* generate private and public keypair
|
|
@@ -105,16 +164,16 @@ class x {
|
|
|
105
164
|
* and must correspond to 32 bytes
|
|
106
165
|
*/
|
|
107
166
|
static getEncryptionKeyPair = (e) => {
|
|
108
|
-
const
|
|
167
|
+
const r = P.crypto_box_seed_keypair(n.getBytes(e));
|
|
109
168
|
return {
|
|
110
|
-
privateKey:
|
|
111
|
-
publicKey:
|
|
169
|
+
privateKey: n.hexlify(r.privateKey),
|
|
170
|
+
publicKey: n.hexlify(r.publicKey)
|
|
112
171
|
};
|
|
113
172
|
};
|
|
114
173
|
}
|
|
115
174
|
export {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
175
|
+
W as EncryptionKeyPairDefaultValue,
|
|
176
|
+
l as UserKeys,
|
|
177
|
+
B as stealthAddressCacheDevice,
|
|
178
|
+
F as stealthPairCacheDevice
|
|
120
179
|
};
|
|
@@ -1 +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"),
|
|
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;
|
|
@@ -2,7 +2,6 @@ import { MerkleTree, MerkleTreeJson } from '../../merkle-tree';
|
|
|
2
2
|
import { AccessTokenEvent } from '../../../types';
|
|
3
3
|
import { AbstractSnapshotService, Snapshot } from './AbstractSnapshotService';
|
|
4
4
|
import { BlockchainEventEmitter } from './BlockchainEventEmitter';
|
|
5
|
-
import { BlockchainEvent } from '../../BlockchainEvent/BlockchainEvent';
|
|
6
5
|
export type SenderAddressIndexMapJson = {
|
|
7
6
|
address: string;
|
|
8
7
|
index: number;
|
|
@@ -18,7 +17,7 @@ export type AccessTokenSerializedSnapshot = {
|
|
|
18
17
|
senderAddresses?: string[];
|
|
19
18
|
senderAddressIndexMap?: SenderAddressIndexMapJson;
|
|
20
19
|
};
|
|
21
|
-
export declare abstract class AbstractAccessTokenSnapshotService extends AbstractSnapshotService<AccessTokenEvent<bigint>, AccessTokenSnapshotPayload, AccessTokenSerializedSnapshot> {
|
|
20
|
+
export declare abstract class AbstractAccessTokenSnapshotService extends AbstractSnapshotService<AccessTokenEvent<bigint>, AccessTokenEvent, AccessTokenSnapshotPayload, AccessTokenSerializedSnapshot> {
|
|
22
21
|
constructor(accessTokenEventFetcher: BlockchainEventEmitter);
|
|
23
22
|
private _merkleTree;
|
|
24
23
|
private _senderAddresses;
|
|
@@ -29,7 +28,7 @@ export declare abstract class AbstractAccessTokenSnapshotService extends Abstrac
|
|
|
29
28
|
protected serializeSnapshot(snapshot: Snapshot<AccessTokenSnapshotPayload>): AccessTokenSerializedSnapshot;
|
|
30
29
|
protected deserializeSnapshot(serializedSnapshot: AccessTokenSerializedSnapshot): Snapshot<AccessTokenSnapshotPayload>;
|
|
31
30
|
protected acceptEvent(event: AccessTokenEvent<bigint>, _blockNumber: number): boolean;
|
|
32
|
-
protected mapEvent(event:
|
|
31
|
+
protected mapEvent(event: AccessTokenEvent): AccessTokenEvent<bigint>;
|
|
33
32
|
protected getSnapshotPayload(): AccessTokenSnapshotPayload;
|
|
34
33
|
protected populateSnapshot({ payload: { merkleTree, senderAddresses, senderAddressIndexMap }, }: Snapshot<AccessTokenSnapshotPayload>): void;
|
|
35
34
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { zeroAddress as
|
|
2
|
-
import { poseidonFunction as
|
|
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";
|
|
@@ -8,9 +8,9 @@ import { toBigInt as t } from "../../../functions/utils/amounts.utils.mjs";
|
|
|
8
8
|
import { MerkleTree as a } from "../../merkle-tree/MerkleTree.mjs";
|
|
9
9
|
import "ethers";
|
|
10
10
|
import "../../../error-handling/error-codes.constants.mjs";
|
|
11
|
-
import { AbstractSnapshotService as
|
|
12
|
-
import { contructMerkleTreeFromSerialized as
|
|
13
|
-
class
|
|
11
|
+
import { AbstractSnapshotService as l } from "./AbstractSnapshotService.mjs";
|
|
12
|
+
import { contructMerkleTreeFromSerialized as A } from "../../../functions/utils/merkleTree.utils.mjs";
|
|
13
|
+
class b extends l {
|
|
14
14
|
constructor(e) {
|
|
15
15
|
super(e, "NewAccessKeyAdded");
|
|
16
16
|
}
|
|
@@ -39,7 +39,7 @@ class g extends A {
|
|
|
39
39
|
}
|
|
40
40
|
deserializeSnapshot(e) {
|
|
41
41
|
let s, r;
|
|
42
|
-
return e.latestBlockNumber && e.merkleTree ? s =
|
|
42
|
+
return e.latestBlockNumber && e.merkleTree ? s = A(e.merkleTree) : s = a.create(o, 0n), e.latestBlockNumber && e.senderAddressIndexMap ? r = new Map(
|
|
43
43
|
e.senderAddressIndexMap.map(({ address: d, index: n }) => [d, n])
|
|
44
44
|
) : r = /* @__PURE__ */ new Map(), {
|
|
45
45
|
latestBlockNumber: e.latestBlockNumber ?? 0,
|
|
@@ -55,13 +55,13 @@ class g extends A {
|
|
|
55
55
|
return this._merkleTree.insert(e.accessKey, e.index), this._senderAddressIndexMap.set(
|
|
56
56
|
e.senderAddress,
|
|
57
57
|
Math.max(Number(e.index), this._senderAddressIndexMap.get(e.senderAddress) ?? 0)
|
|
58
|
-
), this._senderAddresses.includes(e.senderAddress) || this._senderAddresses.push(e.senderAddress), e.accessKey === 0n && e.senderAddress ===
|
|
58
|
+
), this._senderAddresses.includes(e.senderAddress) || this._senderAddresses.push(e.senderAddress), e.accessKey === 0n && e.senderAddress === m && this._merkleTree.remove(e.index), !0;
|
|
59
59
|
} catch (r) {
|
|
60
60
|
return console.error(r), !1;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
mapEvent(e) {
|
|
64
|
-
const
|
|
64
|
+
const { accessKey: s, index: r, senderAddress: d } = e;
|
|
65
65
|
return {
|
|
66
66
|
accessKey: t(s),
|
|
67
67
|
index: t(r),
|
|
@@ -82,5 +82,5 @@ class g extends A {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
export {
|
|
85
|
-
|
|
85
|
+
b as AbstractAccessTokenSnapshotService
|
|
86
86
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./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;
|