@hinkal/common 0.3.2 → 0.3.3
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/README.md +15 -18
- package/common/src/API/API.cjs +1 -1
- package/common/src/API/API.d.ts +5 -5
- package/common/src/API/API.mjs +78 -78
- package/common/src/API/callRelayer.d.ts +3 -0
- package/common/src/API/enclaveUtxoCalls.cjs +1 -1
- package/common/src/API/enclaveUtxoCalls.d.ts +8 -7
- package/common/src/API/enclaveUtxoCalls.mjs +5 -3
- package/common/src/API/getOdosPriceForToken.cjs +1 -0
- package/common/src/API/getOdosPriceForToken.d.ts +1 -0
- package/common/src/API/getOdosPriceForToken.mjs +14 -0
- package/common/src/API/getWebsiteURL.d.ts +0 -1
- package/common/src/API/index.cjs +1 -1
- package/common/src/API/index.d.ts +0 -1
- package/common/src/API/index.mjs +1 -2
- package/common/src/API/rewardsUserCalls.cjs +1 -1
- package/common/src/API/rewardsUserCalls.d.ts +0 -2
- package/common/src/API/rewardsUserCalls.mjs +2 -3
- package/common/src/API/tenderly.api.cjs +1 -1
- package/common/src/API/tenderly.api.d.ts +5 -10
- package/common/src/API/tenderly.api.mjs +1 -1
- package/common/src/constants/addresses.constants.cjs +1 -1
- package/common/src/constants/addresses.constants.d.ts +4 -46
- package/common/src/constants/addresses.constants.mjs +19 -60
- package/common/src/constants/balance.constants.cjs +1 -0
- package/common/src/constants/balance.constants.d.ts +1 -0
- package/common/src/constants/balance.constants.mjs +4 -0
- package/common/src/constants/chains.constants.cjs +1 -1
- package/common/src/constants/chains.constants.d.ts +3 -1
- package/common/src/constants/chains.constants.mjs +117 -131
- package/common/src/constants/coingecko.constants.cjs +1 -1
- package/common/src/constants/coingecko.constants.d.ts +2 -0
- package/common/src/constants/coingecko.constants.mjs +1 -1
- package/common/src/constants/contracts.constants.cjs +1 -1
- package/common/src/constants/contracts.constants.d.ts +0 -109
- package/common/src/constants/contracts.constants.mjs +13 -22
- package/common/src/constants/deploy-data/deploy-data-arbMainnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-arbMainnet.json.mjs +1 -3
- package/common/src/constants/deploy-data/deploy-data-arcTestnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-arcTestnet.json.mjs +6 -6
- package/common/src/constants/deploy-data/deploy-data-base.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-base.json.mjs +1 -3
- package/common/src/constants/deploy-data/deploy-data-bnbMainnet.json.cjs +1 -0
- package/common/src/constants/deploy-data/deploy-data-bnbMainnet.json.mjs +10 -0
- package/common/src/constants/deploy-data/deploy-data-ethMainnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-ethMainnet.json.mjs +1 -3
- package/common/src/constants/deploy-data/deploy-data-localhost.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-localhost.json.mjs +0 -3
- package/common/src/constants/deploy-data/deploy-data-optimism.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-optimism.json.mjs +6 -8
- package/common/src/constants/deploy-data/deploy-data-optimismTest.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-optimismTest.json.mjs +1 -4
- package/common/src/constants/deploy-data/deploy-data-polygon.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-polygon.json.mjs +1 -3
- package/common/src/constants/deploy-data/deploy-data-sepoliaTestnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-sepoliaTestnet.json.mjs +0 -1
- package/common/src/constants/deploy-data/deploy-data-solana.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-solana.json.mjs +2 -2
- package/common/src/constants/deploy-data/deploy-data-tempo.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-tempo.json.mjs +6 -7
- package/common/src/constants/deploy-data/deploy-data-tronMainnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-tronMainnet.json.mjs +2 -4
- package/common/src/constants/deploy-data/deploy-data-tronNile.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-tronNile.json.mjs +2 -4
- package/common/src/constants/deploy-data/index.cjs +1 -1
- package/common/src/constants/deploy-data/index.d.ts +2 -1
- package/common/src/constants/deploy-data/index.mjs +16 -15
- package/common/src/constants/deploy-data/shared-deploy-data-solana.json.cjs +1 -1
- package/common/src/constants/deploy-data/shared-deploy-data-solana.json.mjs +1 -1
- package/common/src/constants/deploy-data/shared-deploy-data-tron.json.cjs +1 -1
- package/common/src/constants/deploy-data/shared-deploy-data-tron.json.mjs +2 -35
- package/common/src/constants/events.constants.cjs +1 -1
- package/common/src/constants/events.constants.mjs +3 -2
- package/common/src/constants/fees.constants.cjs +1 -1
- package/common/src/constants/fees.constants.mjs +2 -2
- package/common/src/constants/index.cjs +1 -1
- package/common/src/constants/index.d.ts +0 -1
- package/common/src/constants/index.mjs +1 -0
- package/common/src/constants/protocol.constants.cjs +2 -2
- package/common/src/constants/protocol.constants.d.ts +3 -1
- package/common/src/constants/protocol.constants.mjs +2 -2
- package/common/src/constants/server.constants.cjs +1 -1
- package/common/src/constants/server.constants.d.ts +1 -2
- package/common/src/constants/server.constants.mjs +1 -2
- package/common/src/constants/tokens.constants.cjs +1 -1
- package/common/src/constants/tokens.constants.mjs +1 -1
- package/common/src/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/common/src/data-structures/Hinkal/Hinkal.mjs +26 -22
- package/common/src/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
- package/common/src/data-structures/Hinkal/handleAutoDepositBack.d.ts +1 -1
- package/common/src/data-structures/Hinkal/handleAutoDepositBack.mjs +36 -35
- package/common/src/data-structures/Hinkal/hinkalActionReceive.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalActionReceive.mjs +3 -3
- package/common/src/data-structures/Hinkal/hinkalBridgePrivateToPrivate.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalBridgePrivateToPrivate.mjs +60 -58
- package/common/src/data-structures/Hinkal/hinkalClaimUtxo.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalClaimUtxo.mjs +42 -47
- package/common/src/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDeposit.d.ts +1 -0
- package/common/src/data-structures/Hinkal/hinkalDeposit.mjs +50 -116
- package/common/src/data-structures/Hinkal/hinkalDepositAndBridge.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDepositAndBridge.mjs +102 -92
- package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.d.ts +3 -2
- package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +104 -59
- package/common/src/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +4 -4
- package/common/src/data-structures/Hinkal/hinkalNearDepositAndBridge.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalNearDepositAndBridge.mjs +7 -3
- package/common/src/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalPrivateWallet.mjs +51 -39
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.d.ts +1 -2
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.mjs +53 -131
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.utils.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.utils.d.ts +1 -1
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.utils.mjs +29 -47
- package/common/src/data-structures/Hinkal/hinkalProxyToPrivate.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalProxyToPrivate.mjs +3 -3
- package/common/src/data-structures/Hinkal/hinkalSolanaClaimUtxo.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaClaimUtxo.mjs +70 -45
- package/common/src/data-structures/Hinkal/hinkalSolanaDeposit.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaDeposit.d.ts +2 -2
- package/common/src/data-structures/Hinkal/hinkalSolanaDeposit.mjs +47 -45
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.d.ts +8 -4
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +133 -81
- package/common/src/data-structures/Hinkal/hinkalSolanaProoflessDeposit.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaProoflessDeposit.d.ts +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaProoflessDeposit.mjs +16 -12
- package/common/src/data-structures/Hinkal/hinkalSolanaProxyShield.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaProxyShield.d.ts +2 -2
- package/common/src/data-structures/Hinkal/hinkalSolanaProxyShield.mjs +61 -54
- package/common/src/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaSwap.mjs +87 -51
- package/common/src/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaTransfer.d.ts +1 -0
- package/common/src/data-structures/Hinkal/hinkalSolanaTransfer.mjs +95 -50
- package/common/src/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +60 -34
- package/common/src/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSwap.mjs +29 -32
- package/common/src/data-structures/Hinkal/hinkalTransact.cjs +1 -0
- package/common/src/data-structures/Hinkal/hinkalTransact.d.ts +3 -0
- package/common/src/data-structures/Hinkal/hinkalTransact.mjs +90 -0
- package/common/src/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalTransfer.mjs +40 -45
- package/common/src/data-structures/Hinkal/hinkalTronDepositToSelf.cjs +1 -0
- package/common/src/data-structures/Hinkal/hinkalTronDepositToSelf.d.ts +8 -0
- package/common/src/data-structures/Hinkal/hinkalTronDepositToSelf.mjs +30 -0
- package/common/src/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalWithdraw.mjs +35 -45
- package/common/src/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +167 -95
- package/common/src/data-structures/Hinkal/prepareTronDepositToSelf.cjs +1 -0
- package/common/src/data-structures/Hinkal/prepareTronDepositToSelf.d.ts +27 -0
- package/common/src/data-structures/Hinkal/prepareTronDepositToSelf.mjs +31 -0
- package/common/src/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/common/src/data-structures/Hinkal/resetMerkleTrees.mjs +1 -0
- package/common/src/data-structures/IndexedDB/activity-db.cjs +1 -1
- package/common/src/data-structures/IndexedDB/activity-db.mjs +34 -34
- package/common/src/data-structures/IndexedDB/signatures-db.cjs +1 -1
- package/common/src/data-structures/IndexedDB/signatures-db.mjs +11 -11
- package/common/src/data-structures/TokenDBs/AlchemyPublicTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/AlchemyPublicTokensDB.mjs +11 -10
- package/common/src/data-structures/TokenDBs/ArcPublicTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/ArcPublicTokensDB.mjs +14 -14
- package/common/src/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/EventsPublicTokensDB.mjs +26 -26
- package/common/src/data-structures/TokenDBs/PrivateTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/PrivateTokensDB.mjs +15 -15
- package/common/src/data-structures/TokenDBs/TempoPublicTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/TempoPublicTokensDB.mjs +12 -16
- package/common/src/data-structures/TokenDBs/TronPublicTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/TronPublicTokensDB.d.ts +1 -0
- package/common/src/data-structures/TokenDBs/TronPublicTokensDB.mjs +8 -4
- package/common/src/data-structures/crypto-keys/decodeUTXO.cjs +1 -1
- package/common/src/data-structures/crypto-keys/decodeUTXO.d.ts +1 -0
- package/common/src/data-structures/crypto-keys/decodeUTXO.mjs +12 -12
- package/common/src/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
- package/common/src/data-structures/event-service/evm/BlockchainEventEmitter.mjs +12 -12
- package/common/src/data-structures/event-service/helpers/ClientEventHelper.cjs +1 -1
- package/common/src/data-structures/event-service/helpers/ClientEventHelper.mjs +6 -6
- package/common/src/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.cjs +1 -1
- package/common/src/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.mjs +27 -23
- package/common/src/data-structures/merkle-tree/MerkleTree.cjs +1 -1
- package/common/src/data-structures/merkle-tree/MerkleTree.d.ts +10 -0
- package/common/src/data-structures/merkle-tree/MerkleTree.mjs +9 -1
- package/common/src/data-structures/private-balances/HinkalPrivateBalanceController.cjs +1 -1
- package/common/src/data-structures/private-balances/HinkalPrivateBalanceController.d.ts +3 -0
- package/common/src/data-structures/private-balances/HinkalPrivateBalanceController.mjs +64 -54
- package/common/src/error-handling/error-codes.constants.cjs +1 -1
- package/common/src/error-handling/error-codes.constants.d.ts +6 -11
- package/common/src/error-handling/error-codes.constants.mjs +8 -13
- package/common/src/error-handling/get-error.message.cjs +1 -1
- package/common/src/error-handling/get-error.message.mjs +27 -14
- package/common/src/externalABIs/index.cjs +1 -1
- package/common/src/externalABIs/index.d.ts +1 -113
- package/common/src/externalABIs/index.mjs +2 -6
- package/common/src/functions/auto-deposit-back-helpers/select-gas-token.cjs +1 -1
- package/common/src/functions/auto-deposit-back-helpers/select-gas-token.mjs +8 -8
- package/common/src/functions/index.cjs +1 -1
- package/common/src/functions/index.d.ts +0 -1
- package/common/src/functions/index.mjs +12 -15
- package/common/src/functions/pre-transaction/calculateSolanaNullifierCount.cjs +1 -1
- package/common/src/functions/pre-transaction/calculateSolanaNullifierCount.mjs +39 -5
- package/common/src/functions/pre-transaction/getExternalSwapAddress.cjs +1 -1
- package/common/src/functions/pre-transaction/getExternalSwapAddress.mjs +2 -18
- package/common/src/functions/pre-transaction/getSolanaCalldataHash.cjs +1 -1
- package/common/src/functions/pre-transaction/getSolanaCalldataHash.d.ts +1 -1
- package/common/src/functions/pre-transaction/getSolanaCalldataHash.mjs +11 -10
- package/common/src/functions/pre-transaction/getVolatileTransferAmount.cjs +1 -1
- package/common/src/functions/pre-transaction/getVolatileTransferAmount.mjs +12 -12
- package/common/src/functions/pre-transaction/index.cjs +1 -1
- package/common/src/functions/pre-transaction/index.d.ts +1 -2
- package/common/src/functions/pre-transaction/index.mjs +1 -2
- package/common/src/functions/pre-transaction/outputUtxoProcessing.cjs +1 -1
- package/common/src/functions/pre-transaction/outputUtxoProcessing.d.ts +1 -1
- package/common/src/functions/pre-transaction/outputUtxoProcessing.mjs +7 -8
- package/common/src/functions/pre-transaction/solana.cjs +1 -1
- package/common/src/functions/pre-transaction/solana.d.ts +13 -0
- package/common/src/functions/pre-transaction/solana.mjs +46 -22
- package/common/src/functions/pre-transaction/store-proof.cjs +1 -1
- package/common/src/functions/pre-transaction/store-proof.d.ts +1 -1
- package/common/src/functions/pre-transaction/store-proof.mjs +1 -0
- package/common/src/functions/pre-transaction/waitForDepositedUtxosInMerkleTree.cjs +1 -1
- package/common/src/functions/pre-transaction/waitForDepositedUtxosInMerkleTree.mjs +1 -1
- package/common/src/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/common/src/functions/private-wallet/emporium.helpers.mjs +12 -13
- package/common/src/functions/private-wallet/emporium.swap.helpers.cjs +1 -1
- package/common/src/functions/private-wallet/emporium.swap.helpers.d.ts +0 -1
- package/common/src/functions/private-wallet/emporium.swap.helpers.mjs +38 -80
- package/common/src/functions/private-wallet/index.cjs +1 -1
- package/common/src/functions/private-wallet/index.d.ts +0 -1
- package/common/src/functions/private-wallet/index.mjs +0 -1
- package/common/src/functions/snarkjs/common.snarkjs.cjs +1 -1
- package/common/src/functions/snarkjs/common.snarkjs.d.ts +2 -2
- package/common/src/functions/snarkjs/common.snarkjs.mjs +89 -52
- package/common/src/functions/snarkjs/constant.cjs +1 -1
- package/common/src/functions/snarkjs/constant.d.ts +32 -0
- package/common/src/functions/snarkjs/constant.mjs +32 -0
- package/common/src/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
- package/common/src/functions/snarkjs/constructGeneralZkProof.d.ts +1 -1
- package/common/src/functions/snarkjs/constructGeneralZkProof.mjs +78 -65
- package/common/src/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/common/src/functions/snarkjs/constructSolanaZkProof.d.ts +4 -1
- package/common/src/functions/snarkjs/constructSolanaZkProof.mjs +44 -39
- package/common/src/functions/snarkjs/constructTxEnclave.cjs +1 -0
- package/common/src/functions/snarkjs/constructTxEnclave.d.ts +32 -0
- package/common/src/functions/snarkjs/constructTxEnclave.mjs +162 -0
- package/common/src/functions/snarkjs/fetchTronInsertionSiblings.cjs +1 -0
- package/common/src/functions/snarkjs/fetchTronInsertionSiblings.d.ts +7 -0
- package/common/src/functions/snarkjs/fetchTronInsertionSiblings.mjs +13 -0
- package/common/src/functions/snarkjs/generateCircomData.cjs +1 -1
- package/common/src/functions/snarkjs/generateCircomData.d.ts +1 -1
- package/common/src/functions/snarkjs/generateCircomData.mjs +33 -27
- package/common/src/functions/snarkjs/generateMainAndCommitmentZkProof.cjs +1 -1
- package/common/src/functions/snarkjs/generateMainAndCommitmentZkProof.d.ts +1 -1
- package/common/src/functions/snarkjs/generateMainAndCommitmentZkProof.mjs +7 -7
- package/common/src/functions/snarkjs/generateZkProof.cjs +1 -1
- package/common/src/functions/snarkjs/generateZkProof.d.ts +1 -1
- package/common/src/functions/snarkjs/generateZkProof.mjs +9 -16
- package/common/src/functions/snarkjs/signedMessageHash.cjs +1 -1
- package/common/src/functions/snarkjs/signedMessageHash.d.ts +11 -0
- package/common/src/functions/snarkjs/signedMessageHash.mjs +21 -3
- package/common/src/functions/snarkjs/verifySignedEnclaveResponse.cjs +1 -0
- package/common/src/functions/snarkjs/verifySignedEnclaveResponse.d.ts +1 -0
- package/common/src/functions/snarkjs/verifySignedEnclaveResponse.mjs +11 -0
- package/common/src/functions/utils/addresses.cjs +1 -1
- package/common/src/functions/utils/addresses.d.ts +1 -0
- package/common/src/functions/utils/addresses.mjs +6 -2
- package/common/src/functions/utils/buildClaimableDepositPlan.d.ts +2 -2
- package/common/src/functions/utils/convertIntegrationProviderToExternalActionId.cjs +1 -1
- package/common/src/functions/utils/convertIntegrationProviderToExternalActionId.mjs +1 -1
- package/common/src/functions/utils/deposit-claimable.utils.cjs +1 -1
- package/common/src/functions/utils/deposit-claimable.utils.d.ts +1 -1
- package/common/src/functions/utils/deposit-claimable.utils.mjs +3 -1
- package/common/src/functions/utils/enclave-utxo-storage.cjs +1 -1
- package/common/src/functions/utils/enclave-utxo-storage.mjs +1 -1
- package/common/src/functions/utils/fees.utils.cjs +1 -1
- package/common/src/functions/utils/fees.utils.mjs +31 -31
- package/common/src/functions/utils/formatter.d.ts +1 -0
- package/common/src/functions/utils/getUtxosFromReceipt.utils.cjs +1 -1
- package/common/src/functions/utils/getUtxosFromReceipt.utils.mjs +6 -6
- package/common/src/functions/utils/getUtxosFromReceiptSolana.cjs +1 -1
- package/common/src/functions/utils/getUtxosFromReceiptSolana.mjs +11 -10
- package/common/src/functions/utils/index.cjs +1 -1
- package/common/src/functions/utils/index.d.ts +2 -2
- package/common/src/functions/utils/index.mjs +11 -10
- package/common/src/functions/utils/process.utils.cjs +1 -1
- package/common/src/functions/utils/process.utils.d.ts +0 -1
- package/common/src/functions/utils/process.utils.mjs +2 -11
- package/common/src/functions/utils/publicBalance.utils.cjs +1 -1
- package/common/src/functions/utils/publicBalance.utils.mjs +2 -1
- package/common/src/functions/utils/transfer-claimable.utils.cjs +1 -1
- package/common/src/functions/utils/transfer-claimable.utils.mjs +2 -2
- package/common/src/functions/utils/tron.utils.cjs +1 -1
- package/common/src/functions/utils/tron.utils.d.ts +5 -14
- package/common/src/functions/utils/tron.utils.mjs +91 -127
- package/common/src/functions/utils/waasStamp.cjs +1 -0
- package/common/src/functions/utils/waasStamp.d.ts +5 -0
- package/common/src/functions/utils/waasStamp.mjs +2 -0
- package/common/src/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
- package/common/src/functions/web3/events/getInputUtxoAndBalance.d.ts +3 -8
- package/common/src/functions/web3/events/getInputUtxoAndBalance.mjs +44 -48
- package/common/src/functions/web3/events/getInputUtxosEnclave.cjs +1 -1
- package/common/src/functions/web3/events/getInputUtxosEnclave.d.ts +4 -3
- package/common/src/functions/web3/events/getInputUtxosEnclave.mjs +34 -25
- package/common/src/functions/web3/events/getShieldedBalance.cjs +1 -1
- package/common/src/functions/web3/events/getShieldedBalance.d.ts +1 -1
- package/common/src/functions/web3/events/getShieldedBalance.mjs +88 -76
- package/common/src/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
- package/common/src/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +9 -6
- package/common/src/functions/web3/functionCalls/approveToken.cjs +1 -1
- package/common/src/functions/web3/functionCalls/approveToken.mjs +12 -12
- package/common/src/functions/web3/functionCalls/submitProof.cjs +1 -0
- package/common/src/functions/web3/functionCalls/submitProof.d.ts +5 -0
- package/common/src/functions/web3/functionCalls/submitProof.mjs +26 -0
- package/common/src/functions/web3/functionCalls/transactCallDirectTron.cjs +1 -1
- package/common/src/functions/web3/functionCalls/transactCallDirectTron.d.ts +7 -3
- package/common/src/functions/web3/functionCalls/transactCallDirectTron.mjs +81 -87
- package/common/src/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/common/src/functions/web3/functionCalls/transactCallRelayer.d.ts +6 -11
- package/common/src/functions/web3/functionCalls/transactCallRelayer.mjs +4 -2
- package/common/src/functions/web3/functionCalls/waitForErc20Approvals.cjs +1 -1
- package/common/src/functions/web3/functionCalls/waitForErc20Approvals.mjs +6 -6
- package/common/src/functions/web3/getContractMetadata.cjs +1 -1
- package/common/src/functions/web3/getContractMetadata.mjs +1 -1
- package/common/src/functions/web3/getTokenHolder.cjs +1 -1
- package/common/src/functions/web3/getTokenHolder.mjs +3 -2
- package/common/src/functions/web3/index.cjs +1 -1
- package/common/src/functions/web3/index.d.ts +0 -3
- package/common/src/functions/web3/index.mjs +0 -3
- package/common/src/functions/web3/lifiAPI.cjs +1 -1
- package/common/src/functions/web3/lifiAPI.mjs +1 -1
- package/common/src/providers/TronProviderAdapter.cjs +1 -1
- package/common/src/providers/TronProviderAdapter.mjs +7 -1
- package/common/src/providers/WagmiProviderAdapter.cjs +1 -1
- package/common/src/providers/WagmiProviderAdapter.mjs +5 -5
- package/common/src/types/activities.types.cjs +1 -1
- package/common/src/types/activities.types.d.ts +0 -9
- package/common/src/types/activities.types.mjs +1 -1
- package/common/src/types/admin.types.cjs +1 -1
- package/common/src/types/admin.types.d.ts +3 -1
- package/common/src/types/admin.types.mjs +1 -1
- package/common/src/types/bridging-tx.types.d.ts +8 -0
- package/common/src/types/cache.types.cjs +1 -1
- package/common/src/types/cache.types.d.ts +2 -1
- package/common/src/types/cache.types.mjs +1 -1
- package/common/src/types/circom-data.types.d.ts +6 -0
- package/common/src/types/commitments.types.d.ts +2 -0
- package/common/src/types/dashboard-transaction.types.d.ts +3 -0
- package/common/src/types/ethereum-network.types.cjs +1 -1
- package/common/src/types/ethereum-network.types.d.ts +6 -15
- package/common/src/types/ethereum-network.types.mjs +1 -1
- package/common/src/types/external-action.types.cjs +1 -1
- package/common/src/types/external-action.types.d.ts +2 -5
- package/common/src/types/external-action.types.mjs +1 -1
- package/common/src/types/hinkal.types.cjs +1 -1
- package/common/src/types/hinkal.types.d.ts +4 -7
- package/common/src/types/hinkal.types.mjs +1 -1
- package/common/src/types/index.cjs +1 -1
- package/common/src/types/index.d.ts +2 -0
- package/common/src/types/index.mjs +1 -0
- package/common/src/types/near-intents.types.d.ts +1 -0
- package/common/src/types/offscreen.types.cjs +1 -1
- package/common/src/types/offscreen.types.d.ts +0 -1
- package/common/src/types/offscreen.types.mjs +1 -1
- package/common/src/types/pay-activities.types.d.ts +3 -0
- package/common/src/types/remote-proof.types.d.ts +0 -6
- package/common/src/types/remote-tx-build.types.d.ts +242 -0
- package/common/src/types/scheduled-transactions.types.d.ts +3 -0
- package/common/src/types/solana.types.d.ts +7 -0
- package/common/src/types/tenderly.api.types.d.ts +70 -0
- package/common/src/types/transact.types.cjs +1 -0
- package/common/src/types/transact.types.d.ts +53 -0
- package/common/src/types/transact.types.mjs +6 -0
- package/common/src/webworker/{logError-uy41lNp1.js → logError-CxZzSALU.js} +1 -1
- package/common/src/webworker/package.json +12 -12
- package/common/src/webworker/snarkjsWorker/snarkjsWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/snarkjsWorker/snarkjsWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/snarkjsWorkerNode.cjs +1 -1
- package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/utxoWorkerNode.cjs +1 -1
- package/common/src/webworker/viteWorkerURL.constant.cjs +3 -3
- package/common/src/webworker/viteWorkerURL.constant.mjs +3 -3
- package/common/src/webworker/workerProxy-swwPYw6e.js +1 -0
- package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/zkProofWorkerNode.cjs +1 -1
- package/index.cjs +1 -1
- package/index.mjs +1 -1
- package/internal/swapApi.cjs +1 -1
- package/internal/swapApi.d.ts +3 -3
- package/internal/swapApi.mjs +22 -25
- package/package.json +12 -12
- package/services/Hinkal.cjs +1 -1
- package/services/Hinkal.d.ts +3 -3
- package/services/Hinkal.mjs +7 -7
- package/types/IHinkal.d.ts +3 -3
- package/types/swap.types.d.ts +3 -20
- package/common/src/API/callOdosAPI.cjs +0 -1
- package/common/src/API/callOdosAPI.d.ts +0 -63
- package/common/src/API/callOdosAPI.mjs +0 -18
- package/common/src/API/callOneInchAPI.cjs +0 -1
- package/common/src/API/callOneInchAPI.d.ts +0 -24
- package/common/src/API/callOneInchAPI.mjs +0 -16
- package/common/src/constants/rewards.constants.d.ts +0 -2
- package/common/src/externalABIs/IQuoterV2.json.cjs +0 -1
- package/common/src/externalABIs/IQuoterV2.json.mjs +0 -203
- package/common/src/externalABIs/ISwapRouter.json.cjs +0 -1
- package/common/src/externalABIs/ISwapRouter.json.mjs +0 -537
- package/common/src/externalABIs/IUniswapV3Factory.json.cjs +0 -1
- package/common/src/externalABIs/IUniswapV3Factory.json.mjs +0 -188
- package/common/src/externalABIs/IUniswapV3Pool.json.cjs +0 -1
- package/common/src/externalABIs/IUniswapV3Pool.json.mjs +0 -938
- package/common/src/externalABIs/UniswapV2PoolAbi.json.cjs +0 -1
- package/common/src/externalABIs/UniswapV2PoolAbi.json.mjs +0 -78
- package/common/src/functions/pre-transaction/interaction-to-action.cjs +0 -1
- package/common/src/functions/pre-transaction/interaction-to-action.d.ts +0 -2
- package/common/src/functions/pre-transaction/interaction-to-action.mjs +0 -1
- package/common/src/functions/pre-transaction/recipientUtxoProcessing.cjs +0 -1
- package/common/src/functions/pre-transaction/recipientUtxoProcessing.d.ts +0 -3
- package/common/src/functions/pre-transaction/recipientUtxoProcessing.mjs +0 -30
- package/common/src/functions/private-wallet/opProducer.cjs +0 -1
- package/common/src/functions/private-wallet/opProducer.d.ts +0 -5
- package/common/src/functions/private-wallet/opProducer.mjs +0 -3
- package/common/src/functions/snarkjs/generateZkProofEnclave.cjs +0 -1
- package/common/src/functions/snarkjs/generateZkProofEnclave.d.ts +0 -5
- package/common/src/functions/snarkjs/generateZkProofEnclave.mjs +0 -27
- package/common/src/functions/utils/get-signature-header.cjs +0 -1
- package/common/src/functions/utils/get-signature-header.d.ts +0 -5
- package/common/src/functions/utils/get-signature-header.mjs +0 -4
- package/common/src/functions/web3/odosAPI.cjs +0 -1
- package/common/src/functions/web3/odosAPI.d.ts +0 -5
- package/common/src/functions/web3/odosAPI.mjs +0 -35
- package/common/src/functions/web3/oneInchAPI.cjs +0 -1
- package/common/src/functions/web3/oneInchAPI.d.ts +0 -5
- package/common/src/functions/web3/oneInchAPI.mjs +0 -44
- package/common/src/functions/web3/uniswapAPI.cjs +0 -1
- package/common/src/functions/web3/uniswapAPI.d.ts +0 -16
- package/common/src/functions/web3/uniswapAPI.mjs +0 -60
- package/common/src/webworker/workerProxy-MheXtWa4.js +0 -1
|
@@ -1,48 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { caseInsensitiveEqual as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { getOnchainChainId as e, networkRegistry as t } from "../../constants/chains.constants.mjs";
|
|
2
|
+
import { caseInsensitiveEqual as n } from "../../functions/utils/caseInsensitive.utils.mjs";
|
|
3
|
+
import { poseidonFunction as r } from "../../crypto/poseidon.mjs";
|
|
4
|
+
import { transactionErrorCodes as i } from "../../error-handling/error-codes.constants.mjs";
|
|
5
|
+
import { randomBigInt as a } from "../../functions/web3/etherFunctions.mjs";
|
|
6
|
+
import { isValidPrivateAddress as o } from "../../functions/utils/addresses.mjs";
|
|
7
|
+
import { ExternalActionId as s } from "../../types/external-action.types.mjs";
|
|
8
|
+
import { AdminTransactionType as c } from "../../types/admin.types.mjs";
|
|
9
|
+
import { SubmitMode as l } from "../../types/transact.types.mjs";
|
|
10
10
|
import "../../error-handling/index.mjs";
|
|
11
|
-
import { constructAdminData as
|
|
12
|
-
import { AccountActions as
|
|
13
|
-
import { recipientUtxoProcessing as d } from "../../functions/pre-transaction/recipientUtxoProcessing.mjs";
|
|
11
|
+
import { constructAdminData as u } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
12
|
+
import { AccountActions as d } from "../AccountActions/AccountActions.mjs";
|
|
14
13
|
import { getFeeStructure as f } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
15
14
|
import "../../functions/pre-transaction/index.mjs";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import { transactCallRelayer as _ } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
15
|
+
import { encodeEmporiumMetadata as p, getAuthorizationDataIfNeeded as m } from "../../functions/private-wallet/emporium.helpers.mjs";
|
|
16
|
+
import { hinkalTransact as h } from "./hinkalTransact.mjs";
|
|
17
|
+
import { uniswapWorkaround as g } from "../../functions/utils/involves-permit2-op.mjs";
|
|
18
|
+
import { convertEmporiumOpToCallInfo as _ } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
|
|
21
19
|
import { mergeWithFeeStructure as v } from "../../functions/pre-transaction/merge-with-fee-structure.mjs";
|
|
22
20
|
import { mergeWithFeeStructureEmporium as y } from "../../functions/pre-transaction/merge-with-fee-structure-emporium.mjs";
|
|
23
21
|
import { handleAutoDepositBack as b } from "./handleAutoDepositBack.mjs";
|
|
24
22
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalPrivateWallet.ts
|
|
25
|
-
var x = async (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
23
|
+
var x = async (x, S, C, w, T, E, D, O, k, A, j, M = !1, N, P, F) => {
|
|
24
|
+
if (F && !o(F.recipientInfo)) throw Error(i.RECIPIENT_FORMAT_INCORRECT);
|
|
25
|
+
if (D.length > 0 && !O) throw Error("Subaccount is required for private wallet transactions");
|
|
26
|
+
let I = C.map((e) => e.erc20TokenAddress), L = await x.getEthereumAddressByChain(S), R = O ? d.getAddressFromSubAccount(S, O) : void 0, { contractData: z } = t[S], { emporiumAddress: B } = z;
|
|
27
|
+
if (!B) throw Error("No Emporium Address Provided");
|
|
28
|
+
let V = A ?? await f(S, k, I, s.Emporium, E.map((e) => _(e, R ?? "", S)));
|
|
29
|
+
for (R ? await y(x, S, R, E, I, w, V, D.find((e) => n(e.token.erc20TokenAddress, V.feeToken))?.amount ?? 0n) : await v(S, I, w, V); T.length < I.length;) T.push(!1);
|
|
30
|
+
let H = j ?? await x.getRandomRelay(S, !0);
|
|
31
|
+
if (!H) throw Error(i.RELAYER_NOT_AVAILABLE);
|
|
32
|
+
let U = O ? d.getPrivateKeyFromSubAccount(S, O) : void 0, W = e(S), G = U ? d.getSignerAddressFromPrivateKey(W, U) : void 0, K = a(31), q = x.generateProofRemotely ? await p(S, B, U, E, r(K), G) : void 0, J = await m(S, U), Y = g(E), X = u(P, S, D.map((e) => e.token.erc20TokenAddress), D.map((e) => e.amount), L, P === c.PublicSwap ? D.map(({ token: e }) => e) : void 0), Z, Q = await h(x, {
|
|
33
|
+
chainId: S,
|
|
34
|
+
erc20Addresses: I,
|
|
35
|
+
amountChanges: w,
|
|
36
|
+
externalAddress: B,
|
|
37
|
+
externalActionId: s.Emporium,
|
|
38
|
+
externalActionMetadata: q,
|
|
39
|
+
onChainCreation: T,
|
|
40
|
+
feeStructure: V,
|
|
41
|
+
relay: H,
|
|
42
|
+
messageSeed: K,
|
|
43
|
+
recipientAddress: F ? [F.recipientInfo] : void 0,
|
|
44
|
+
recipientAmounts: F ? [I.map((e) => n(e, F.token.erc20TokenAddress) ? F.amount : 0n)] : void 0,
|
|
45
|
+
subAccountPrivateKey: U,
|
|
46
|
+
emporiumOps: E,
|
|
47
|
+
onTxSubmitLocally: (e) => {
|
|
48
|
+
Z = e;
|
|
49
|
+
},
|
|
50
|
+
submit: {
|
|
51
|
+
mode: l.Relayer,
|
|
52
|
+
adminData: X,
|
|
53
|
+
authorizationData: J,
|
|
54
|
+
withUniswapWorkAround: Y
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return M && O && b(x, S, R, O, V.feeToken, N, D, Z), Q;
|
|
46
58
|
};
|
|
47
59
|
//#endregion
|
|
48
|
-
export {
|
|
60
|
+
export { x as hinkalPrivateWallet };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../types/hinkal.types.cjs`),r=require(`../../functions/utils/caseInsensitive.utils.cjs`),i=require(`../../
|
|
1
|
+
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../types/hinkal.types.cjs`),r=require(`../../functions/utils/caseInsensitive.utils.cjs`),i=require(`../../types/ethereum-network.types.cjs`),a=require(`../../functions/utils/token-check.utils.cjs`),o=require(`../../functions/pre-transaction/constructAdminData.cjs`),s=require(`../../functions/utils/getContractAddress.cjs`),c=require(`../../functions/web3/functionCalls/constructBatchCall.cjs`),l=require(`../../functions/web3/functionCalls/waitForErc20Approvals.cjs`),u=require(`../../API/admin-calls.cjs`),d=require(`../../functions/utils/getRecipientInfoFromUserKeys.cjs`),f=require(`./hinkalProoflessDeposit.utils.cjs`);var p=async(p,m,h,g,_,v=!1,y=n.zeroProoflessFeeStructure,b=``,x,S=!1)=>{let C=a.validateAndGetChainId(m);if(e.isTronLike(C))throw Error(`Proofless deposit is not supported on Tron`);let w=await p.getEthereumAddressByChain(C),T=g??m.map(()=>d.getStealthAddressStructureFromUserKeys(p.userKeys));if(T.length!==m.length)throw Error(`Stealth address structures length must be equal to erc20 tokens length`);if(f.assertNoDuplicateStealthAddressStructures(T),g&&!_)throw Error(`recipientEncryptionKeysOverride is required whenever stealthAddressStructuresOverride is provided`);if(_&&_.length!==m.length)throw Error(`recipientEncryptionKeysOverride length must be equal to erc20 tokens length`);let E=f.buildProoflessEncryptedOutputs(T,_??f.getOwnRecipientEncryptionKeys(p.userKeys,m.length)),D=y.feeAmount>0n,O=D?p.getContractWithSigner(C,i.ContractType.HinkalWrapperContract):p.getContractWithSigner(C,i.ContractType.HinkalContract),k=D?[m.map(({erc20TokenAddress:e})=>e),h,T,E,v,y,b]:[m.map(({erc20TokenAddress:e})=>e),h,T,E,v,b],A=r.caseInsensitiveEqual(y.feeToken,t.zeroAddress),j=m.reduce((e,n,i)=>r.caseInsensitiveEqual(n.erc20TokenAddress,t.zeroAddress)?e+h[i]:e,0n)+(A?y.feeAmount:0n);if(S)return O.prooflessDeposit.populateTransaction(...k,{value:j>0n?j:void 0});let M=p.getProviderAdapter(C),N=f.aggregateAmountsForApproval(!A&&y.feeAmount>0n?[...m,{erc20TokenAddress:y.feeToken,chainId:C}]:m,!A&&y.feeAmount>0n?[...h,y.feeAmount]:h),P=N.filter(({token:e,balance:n})=>!r.caseInsensitiveEqual(e.erc20TokenAddress,t.zeroAddress)&&n>0n),F;if(P.length>0&&await M.supportsBatchCall?.(C)&&M.sendBatchCallsTransaction){let e=c.buildApproveAndProoflessDepositCalls(P.map(({token:e})=>e.erc20TokenAddress),P.map(({balance:e})=>e),s.getContractAddress(O),O,m.map(({erc20TokenAddress:e})=>e),h,T,E,v,D?y:void 0,b,j);F=await M.sendBatchCallsTransaction(C,e)}else{await f.approveTokens(p,C,s.getContractAddress(O),N);let e=await p.getEthereumAddressByChain(C),t=N.map(({token:e,balance:t})=>({tokenAddress:e.erc20TokenAddress,requiredAmount:t}));await l.waitForErc20Approvals(p,C,e,s.getContractAddress(O),t),F=await O.prooflessDeposit(...k,{value:j>0n?j:void 0})}let I=F.hash;return u.emitTxPublicData(o.constructAdminData(x,C,m.map(({erc20TokenAddress:e})=>e),h,w)),I};exports.hinkalProoflessDeposit=p;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
|
-
import { Types as TronWebTypes } from 'tronweb';
|
|
3
2
|
import { ERC20Token } from '../../types/token.types';
|
|
4
3
|
import { IHinkal } from './IHinkal';
|
|
5
4
|
import { StealthAddressStructure } from '../../types/circom-data.types';
|
|
6
5
|
import { ProoflessFeeStructure } from '../../types/hinkal.types';
|
|
7
6
|
import { AdminTransactionType } from '../../types/admin.types';
|
|
8
|
-
export declare const hinkalProoflessDeposit: (hinkal: IHinkal, erc20Tokens: ERC20Token[], amountChanges: bigint[], stealthAddressStructuresOverride?: StealthAddressStructure[], recipientEncryptionKeysOverride?: string[], createBlockedUtxos?: boolean, feeStructure?: ProoflessFeeStructure, orderId?: string, action?: AdminTransactionType, returnTxData?: boolean) => Promise<string | ethers.TransactionRequest
|
|
7
|
+
export declare const hinkalProoflessDeposit: (hinkal: IHinkal, erc20Tokens: ERC20Token[], amountChanges: bigint[], stealthAddressStructuresOverride?: StealthAddressStructure[], recipientEncryptionKeysOverride?: string[], createBlockedUtxos?: boolean, feeStructure?: ProoflessFeeStructure, orderId?: string, action?: AdminTransactionType, returnTxData?: boolean) => Promise<string | ethers.TransactionRequest>;
|
|
@@ -1,136 +1,58 @@
|
|
|
1
|
-
import { isTronLike as e
|
|
2
|
-
import {
|
|
3
|
-
import { zeroProoflessFeeStructure as
|
|
4
|
-
import { caseInsensitiveEqual as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { waitForErc20Approvals as v, waitForTronErc20Approvals as y } from "../../functions/web3/functionCalls/waitForErc20Approvals.mjs";
|
|
15
|
-
import { emitTxPublicData as b } from "../../API/admin-calls.mjs";
|
|
16
|
-
import { aggregateAmountsForApproval as x, approveTokens as S, approveTronTokens as C, assertNoDuplicateStealthAddressStructures as w, buildProoflessEncryptedOutputs as T, getOwnRecipientEncryptionKeys as E } from "./hinkalProoflessDeposit.utils.mjs";
|
|
1
|
+
import { isTronLike as e } from "../../constants/chains.constants.mjs";
|
|
2
|
+
import { zeroAddress as t } from "../../constants/protocol.constants.mjs";
|
|
3
|
+
import { zeroProoflessFeeStructure as n } from "../../types/hinkal.types.mjs";
|
|
4
|
+
import { caseInsensitiveEqual as r } from "../../functions/utils/caseInsensitive.utils.mjs";
|
|
5
|
+
import { ContractType as i } from "../../types/ethereum-network.types.mjs";
|
|
6
|
+
import { validateAndGetChainId as a } from "../../functions/utils/token-check.utils.mjs";
|
|
7
|
+
import { constructAdminData as o } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
8
|
+
import { getContractAddress as s } from "../../functions/utils/getContractAddress.mjs";
|
|
9
|
+
import { buildApproveAndProoflessDepositCalls as c } from "../../functions/web3/functionCalls/constructBatchCall.mjs";
|
|
10
|
+
import { waitForErc20Approvals as l } from "../../functions/web3/functionCalls/waitForErc20Approvals.mjs";
|
|
11
|
+
import { emitTxPublicData as u } from "../../API/admin-calls.mjs";
|
|
12
|
+
import { getStealthAddressStructureFromUserKeys as d } from "../../functions/utils/getRecipientInfoFromUserKeys.mjs";
|
|
13
|
+
import { aggregateAmountsForApproval as f, approveTokens as p, assertNoDuplicateStealthAddressStructures as m, buildProoflessEncryptedOutputs as h, getOwnRecipientEncryptionKeys as g } from "./hinkalProoflessDeposit.utils.mjs";
|
|
17
14
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalProoflessDeposit.ts
|
|
18
|
-
var
|
|
19
|
-
let
|
|
20
|
-
if (D
|
|
21
|
-
let O =
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
{
|
|
48
|
-
|
|
49
|
-
value: m
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
type: "bool",
|
|
53
|
-
value: h
|
|
54
|
-
}
|
|
55
|
-
], R = D ? "prooflessDeposit(address[],uint256[],(uint256,uint256,uint256,uint256,uint256)[],bytes[],bool,(address,address,uint256),string)" : "prooflessDeposit(address[],uint256[],(uint256,uint256,uint256,uint256,uint256)[],bytes[],bool,string)", z = D ? [
|
|
56
|
-
...L,
|
|
57
|
-
{
|
|
58
|
-
type: "tuple(address,address,uint256)",
|
|
59
|
-
value: [
|
|
60
|
-
l(_.feeRecipient),
|
|
61
|
-
M ? _.feeToken : l(_.feeToken),
|
|
62
|
-
_.feeAmount.toString()
|
|
63
|
-
]
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
type: "string",
|
|
67
|
-
value: v
|
|
68
|
-
}
|
|
69
|
-
] : [...L, {
|
|
70
|
-
type: "string",
|
|
71
|
-
value: v
|
|
72
|
-
}], B = z.map(({ value: e }) => e);
|
|
73
|
-
F > 0n && await s(x, i, O, A, c(k, "prooflessDeposit", B), F);
|
|
74
|
-
let { transaction: V } = await x.transactionBuilder.triggerSmartContract(O, R, {
|
|
75
|
-
feeLimit: n,
|
|
76
|
-
callValue: F > 0n ? Number(F) : 0
|
|
77
|
-
}, z, A);
|
|
78
|
-
if (b) return V;
|
|
79
|
-
await C(x, A, O, P), await y(x, A, O, Array.from(P.entries()).map(([e, t]) => ({
|
|
80
|
-
tokenAddress: e,
|
|
81
|
-
requiredAmount: t
|
|
82
|
-
}))), await g(i, O, "prooflessDeposit", k, B, A, F > 0n ? F : void 0);
|
|
83
|
-
let H = await x.trx.sign(V), U = await x.trx.sendRawTransaction(H);
|
|
84
|
-
if (!U.result) throw o.error("Tron prooflessDeposit broadcast failed", U), Error("Tron prooflessDeposit broadcast failed");
|
|
85
|
-
let W = typeof U == "string" ? U : U?.txid ?? U?.transaction?.txID;
|
|
86
|
-
if (!W) throw Error("Tron prooflessDeposit failed (missing txid)");
|
|
87
|
-
return W;
|
|
88
|
-
}, O = async (t, n, o, s, c, l = !1, u = i, g = "", y, C = !1) => {
|
|
89
|
-
let O = f(n), k = e(O), A = await t.getEthereumAddressByChain(O), j = s ?? n.map(() => m(t.userKeys));
|
|
90
|
-
if (j.length !== n.length) throw Error("Stealth address structures length must be equal to erc20 tokens length");
|
|
91
|
-
if (w(j), s && !c) throw Error("recipientEncryptionKeysOverride is required whenever stealthAddressStructuresOverride is provided");
|
|
92
|
-
if (c && c.length !== n.length) throw Error("recipientEncryptionKeysOverride length must be equal to erc20 tokens length");
|
|
93
|
-
let M = T(n, j, c ?? E(t.userKeys, n.length)), N;
|
|
94
|
-
if (k) {
|
|
95
|
-
let e = await D(t, O, n, o, j, M, l, u, g, C);
|
|
96
|
-
if (C) return e;
|
|
97
|
-
N = e;
|
|
15
|
+
var _ = async (_, v, y, b, x, S = !1, C = n, w = "", T, E = !1) => {
|
|
16
|
+
let D = a(v);
|
|
17
|
+
if (e(D)) throw Error("Proofless deposit is not supported on Tron");
|
|
18
|
+
let O = await _.getEthereumAddressByChain(D), k = b ?? v.map(() => d(_.userKeys));
|
|
19
|
+
if (k.length !== v.length) throw Error("Stealth address structures length must be equal to erc20 tokens length");
|
|
20
|
+
if (m(k), b && !x) throw Error("recipientEncryptionKeysOverride is required whenever stealthAddressStructuresOverride is provided");
|
|
21
|
+
if (x && x.length !== v.length) throw Error("recipientEncryptionKeysOverride length must be equal to erc20 tokens length");
|
|
22
|
+
let A = h(k, x ?? g(_.userKeys, v.length)), j = C.feeAmount > 0n, M = j ? _.getContractWithSigner(D, i.HinkalWrapperContract) : _.getContractWithSigner(D, i.HinkalContract), N = j ? [
|
|
23
|
+
v.map(({ erc20TokenAddress: e }) => e),
|
|
24
|
+
y,
|
|
25
|
+
k,
|
|
26
|
+
A,
|
|
27
|
+
S,
|
|
28
|
+
C,
|
|
29
|
+
w
|
|
30
|
+
] : [
|
|
31
|
+
v.map(({ erc20TokenAddress: e }) => e),
|
|
32
|
+
y,
|
|
33
|
+
k,
|
|
34
|
+
A,
|
|
35
|
+
S,
|
|
36
|
+
w
|
|
37
|
+
], P = r(C.feeToken, t), F = v.reduce((e, n, i) => r(n.erc20TokenAddress, t) ? e + y[i] : e, 0n) + (P ? C.feeAmount : 0n);
|
|
38
|
+
if (E) return M.prooflessDeposit.populateTransaction(...N, { value: F > 0n ? F : void 0 });
|
|
39
|
+
let I = _.getProviderAdapter(D), L = f(!P && C.feeAmount > 0n ? [...v, {
|
|
40
|
+
erc20TokenAddress: C.feeToken,
|
|
41
|
+
chainId: D
|
|
42
|
+
}] : v, !P && C.feeAmount > 0n ? [...y, C.feeAmount] : y), R = L.filter(({ token: e, balance: n }) => !r(e.erc20TokenAddress, t) && n > 0n), z;
|
|
43
|
+
if (R.length > 0 && await I.supportsBatchCall?.(D) && I.sendBatchCallsTransaction) {
|
|
44
|
+
let e = c(R.map(({ token: e }) => e.erc20TokenAddress), R.map(({ balance: e }) => e), s(M), M, v.map(({ erc20TokenAddress: e }) => e), y, k, A, S, j ? C : void 0, w, F);
|
|
45
|
+
z = await I.sendBatchCallsTransaction(D, e);
|
|
98
46
|
} else {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
u,
|
|
106
|
-
g
|
|
107
|
-
] : [
|
|
108
|
-
n.map(({ erc20TokenAddress: e }) => e),
|
|
109
|
-
o,
|
|
110
|
-
j,
|
|
111
|
-
M,
|
|
112
|
-
l,
|
|
113
|
-
g
|
|
114
|
-
], c = a(u.feeToken, r), f = n.reduce((e, t, n) => a(t.erc20TokenAddress, r) ? e + o[n] : e, 0n) + (c ? u.feeAmount : 0n);
|
|
115
|
-
if (C) return i.prooflessDeposit.populateTransaction(...s, { value: f > 0n ? f : void 0 });
|
|
116
|
-
let p = t.getProviderAdapter(O), m = x(!c && u.feeAmount > 0n ? [...n, {
|
|
117
|
-
erc20TokenAddress: u.feeToken,
|
|
118
|
-
chainId: O
|
|
119
|
-
}] : n, !c && u.feeAmount > 0n ? [...o, u.feeAmount] : o), y = m.filter(({ token: e, balance: t }) => !a(e.erc20TokenAddress, r) && t > 0n), b;
|
|
120
|
-
if (y.length > 0 && await p.supportsBatchCall?.(O) && p.sendBatchCallsTransaction) {
|
|
121
|
-
let t = _(y.map(({ token: e }) => e.erc20TokenAddress), y.map(({ balance: e }) => e), h(i), i, n.map(({ erc20TokenAddress: e }) => e), o, j, M, l, e ? u : void 0, g, f);
|
|
122
|
-
b = await p.sendBatchCallsTransaction(O, t);
|
|
123
|
-
} else {
|
|
124
|
-
await S(t, O, h(i), m);
|
|
125
|
-
let e = await t.getEthereumAddressByChain(O), n = m.map(({ token: e, balance: t }) => ({
|
|
126
|
-
tokenAddress: e.erc20TokenAddress,
|
|
127
|
-
requiredAmount: t
|
|
128
|
-
}));
|
|
129
|
-
await v(t, O, e, h(i), n), b = await i.prooflessDeposit(...s, { value: f > 0n ? f : void 0 });
|
|
130
|
-
}
|
|
131
|
-
N = b.hash;
|
|
47
|
+
await p(_, D, s(M), L);
|
|
48
|
+
let e = await _.getEthereumAddressByChain(D), t = L.map(({ token: e, balance: t }) => ({
|
|
49
|
+
tokenAddress: e.erc20TokenAddress,
|
|
50
|
+
requiredAmount: t
|
|
51
|
+
}));
|
|
52
|
+
await l(_, D, e, s(M), t), z = await M.prooflessDeposit(...N, { value: F > 0n ? F : void 0 });
|
|
132
53
|
}
|
|
133
|
-
|
|
54
|
+
let B = z.hash;
|
|
55
|
+
return u(o(T, D, v.map(({ erc20TokenAddress: e }) => e), y, O)), B;
|
|
134
56
|
};
|
|
135
57
|
//#endregion
|
|
136
|
-
export {
|
|
58
|
+
export { _ as hinkalProoflessDeposit };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../constants/protocol.constants.cjs`),t=require(`../../functions/utils/caseInsensitive.utils.cjs`),n=require(`../crypto-keys/keys.cjs`),r=require(`../../
|
|
1
|
+
const e=require(`../../constants/protocol.constants.cjs`),t=require(`../../functions/utils/caseInsensitive.utils.cjs`),n=require(`../crypto-keys/keys.cjs`),r=require(`../../types/ethereum-network.types.cjs`),i=require(`../../functions/utils/token-check.utils.cjs`),a=require(`../crypto-keys/encryptDecryptUtxo.cjs`);require(`../../externalABIs/index.cjs`);const o=require(`../../functions/utils/tx-confirmation.utils.cjs`);var s=(e,t)=>{if(e.length!==t.length)throw Error(`stealthAddressStructures and recipientEncryptionKeys must have equal length`);return e.map((e,n)=>{let r=t[n];if(!r)throw Error(`Missing encryptionKey for proofless deposit output ${n}: required so the enclave can attribute this UTXO to its owner`);return`0x${Buffer.from(a.encryptEncryptionKeyAndStealthAddress(r,e.stealthAddress)).toString(`hex`)}`})},c=(e,t)=>{let r=n.UserKeys.getEncryptionKeyPair(e.getShieldedPrivateKey()).publicKey;return Array.from({length:t},()=>r)},l=(e,t)=>{let n=[],r=0;for(let a=0;a<e.length;a+=1){let o=!1;for(let s=0;s<r;s+=1)if(i.isSameERC20Token(n[s].token,e[a])){n[s].balance+=t[a],o=!0;break}o||(n[r]={token:e[a],balance:t[a]},r+=1)}return n},u=async(n,i,a,s)=>{for(let c=0;c<s.length;c+=1)t.caseInsensitiveEqual(s[c].token.erc20TokenAddress,e.zeroAddress)||await o.waitForEthereumTransactionConfirmation(i,(await n.getContractWithSigner(i,r.ContractType.ERC20Contract,s[c].token.erc20TokenAddress).approve(a,s[c].balance)).hash)},d=e=>{let t=new Set;e.forEach(({H0x:e,stealthAddress:n})=>{let r=`${e.toString()}:${n.toString()}`;if(t.has(r))throw Error(`Duplicate randomization and stealth address pair detected in stealthAddressStructures`);t.add(r)})};exports.aggregateAmountsForApproval=l,exports.approveTokens=u,exports.assertNoDuplicateStealthAddressStructures=d,exports.buildProoflessEncryptedOutputs=s,exports.getOwnRecipientEncryptionKeys=c;
|
|
@@ -2,7 +2,7 @@ import { ERC20Token, TokenBalance } from '../../types/token.types';
|
|
|
2
2
|
import { StealthAddressStructure } from '../../types/circom-data.types';
|
|
3
3
|
import { UserKeys } from '../crypto-keys/keys';
|
|
4
4
|
import { IHinkal } from './IHinkal';
|
|
5
|
-
export declare const buildProoflessEncryptedOutputs: (
|
|
5
|
+
export declare const buildProoflessEncryptedOutputs: (stealthAddressStructures: StealthAddressStructure[], recipientEncryptionKeys: string[]) => string[];
|
|
6
6
|
export declare const getOwnRecipientEncryptionKeys: (userKeys: UserKeys, count: number) => string[];
|
|
7
7
|
export declare const aggregateAmountsForApproval: (erc20Tokens: ERC20Token[], amounts: bigint[]) => TokenBalance[];
|
|
8
8
|
export declare const approveTokens: (hinkal: IHinkal, chainId: number, spenderAddress: string, tokensWithBalances: TokenBalance[]) => Promise<void>;
|
|
@@ -1,57 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { caseInsensitiveEqual as
|
|
3
|
-
import { UserKeys as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import { waitForEthereumTransactionConfirmation as
|
|
1
|
+
import { zeroAddress as e } from "../../constants/protocol.constants.mjs";
|
|
2
|
+
import { caseInsensitiveEqual as t } from "../../functions/utils/caseInsensitive.utils.mjs";
|
|
3
|
+
import { UserKeys as n } from "../crypto-keys/keys.mjs";
|
|
4
|
+
import { ContractType as r } from "../../types/ethereum-network.types.mjs";
|
|
5
|
+
import { isSameERC20Token as i } from "../../functions/utils/token-check.utils.mjs";
|
|
6
|
+
import { encryptEncryptionKeyAndStealthAddress as a } from "../crypto-keys/encryptDecryptUtxo.mjs";
|
|
7
|
+
import "../../externalABIs/index.mjs";
|
|
8
|
+
import { waitForEthereumTransactionConfirmation as o } from "../../functions/utils/tx-confirmation.utils.mjs";
|
|
9
9
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalProoflessDeposit.utils.ts
|
|
10
|
-
var
|
|
11
|
-
if (
|
|
12
|
-
return
|
|
13
|
-
let r = n
|
|
14
|
-
if (!r) throw Error(`Missing encryptionKey for proofless deposit output ${
|
|
15
|
-
return `0x${Buffer.from(
|
|
10
|
+
var s = (e, t) => {
|
|
11
|
+
if (e.length !== t.length) throw Error("stealthAddressStructures and recipientEncryptionKeys must have equal length");
|
|
12
|
+
return e.map((e, n) => {
|
|
13
|
+
let r = t[n];
|
|
14
|
+
if (!r) throw Error(`Missing encryptionKey for proofless deposit output ${n}: required so the enclave can attribute this UTXO to its owner`);
|
|
15
|
+
return `0x${Buffer.from(a(r, e.stealthAddress)).toString("hex")}`;
|
|
16
16
|
});
|
|
17
|
-
},
|
|
18
|
-
let
|
|
19
|
-
return Array.from({ length: t }, () =>
|
|
20
|
-
},
|
|
17
|
+
}, c = (e, t) => {
|
|
18
|
+
let r = n.getEncryptionKeyPair(e.getShieldedPrivateKey()).publicKey;
|
|
19
|
+
return Array.from({ length: t }, () => r);
|
|
20
|
+
}, l = (e, t) => {
|
|
21
21
|
let n = [], r = 0;
|
|
22
|
-
for (let
|
|
23
|
-
let
|
|
24
|
-
for (let s = 0; s < r; s += 1) if (
|
|
25
|
-
n[s].balance += t[
|
|
22
|
+
for (let a = 0; a < e.length; a += 1) {
|
|
23
|
+
let o = !1;
|
|
24
|
+
for (let s = 0; s < r; s += 1) if (i(n[s].token, e[a])) {
|
|
25
|
+
n[s].balance += t[a], o = !0;
|
|
26
26
|
break;
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
token: e[
|
|
30
|
-
balance: t[
|
|
28
|
+
o || (n[r] = {
|
|
29
|
+
token: e[a],
|
|
30
|
+
balance: t[a]
|
|
31
31
|
}, r += 1);
|
|
32
32
|
}
|
|
33
33
|
return n;
|
|
34
|
-
},
|
|
35
|
-
for (let
|
|
36
|
-
},
|
|
37
|
-
let o = Array.from(a.entries());
|
|
38
|
-
for (let a = 0; a < o.length; a += 1) {
|
|
39
|
-
let [s, c] = o[a], l = await t.contract(i, s).allowance(n, r).call({ from: n });
|
|
40
|
-
if (BigInt(String(l)) < c) {
|
|
41
|
-
let { transaction: i } = await t.transactionBuilder.triggerSmartContract(s, "approve(address,uint256)", { feeLimit: e }, [{
|
|
42
|
-
type: "address",
|
|
43
|
-
value: r
|
|
44
|
-
}, {
|
|
45
|
-
type: "uint256",
|
|
46
|
-
value: c.toString()
|
|
47
|
-
}], n), a = await t.trx.sign(i), o = await t.trx.sendRawTransaction(a);
|
|
48
|
-
if (!o.result) {
|
|
49
|
-
let e = o.code ?? "UNKNOWN", t = o.message ? Buffer.from(o.message, "hex").toString() : "no message";
|
|
50
|
-
throw Error(`Tron token approval failed: ${e} - ${t}`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}, m = (e) => {
|
|
34
|
+
}, u = async (n, i, a, s) => {
|
|
35
|
+
for (let c = 0; c < s.length; c += 1) t(s[c].token.erc20TokenAddress, e) || await o(i, (await n.getContractWithSigner(i, r.ERC20Contract, s[c].token.erc20TokenAddress).approve(a, s[c].balance)).hash);
|
|
36
|
+
}, d = (e) => {
|
|
55
37
|
let t = /* @__PURE__ */ new Set();
|
|
56
38
|
e.forEach(({ H0x: e, stealthAddress: n }) => {
|
|
57
39
|
let r = `${e.toString()}:${n.toString()}`;
|
|
@@ -60,4 +42,4 @@ var l = (e, t, n) => {
|
|
|
60
42
|
});
|
|
61
43
|
};
|
|
62
44
|
//#endregion
|
|
63
|
-
export {
|
|
45
|
+
export { l as aggregateAmountsForApproval, u as approveTokens, d as assertNoDuplicateStealthAddressStructures, s as buildProoflessEncryptedOutputs, c as getOwnRecipientEncryptionKeys };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../error-handling/error-codes.constants.cjs`),t=require(`../../functions/utils/addresses.cjs`),n=require(`../../types/external-action.types.cjs`),r=require(`../../functions/utils/token-check.utils.cjs`),i=require(`../../functions/pre-transaction/getVolatileTransferAmount.cjs`),a=require(`../AccountActions/AccountActions.cjs`),o=require(`../../functions/pre-transaction/getFeeStructure.cjs`),s=require(`../../functions/
|
|
1
|
+
const e=require(`../../error-handling/error-codes.constants.cjs`),t=require(`../../functions/utils/addresses.cjs`),n=require(`../../types/external-action.types.cjs`),r=require(`../../functions/utils/token-check.utils.cjs`),i=require(`../../functions/pre-transaction/getVolatileTransferAmount.cjs`),a=require(`../AccountActions/AccountActions.cjs`),o=require(`../../functions/pre-transaction/getFeeStructure.cjs`),s=require(`../../functions/private-wallet/emporium.helpers.cjs`),c=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`);var l=async(l,u,d,f,p,m,h,g)=>{if(!h)throw Error(`hinkalProxyToPrivate: subAccount should be provided`);if(!p)throw Error(`Fee token is required in hinkalProxyToPrivate`);if(!t.isValidPrivateAddress(f))throw Error(e.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);let _=r.validateAndGetChainId(u),v=a.AccountActions.getAddressFromSubAccount(_,h);if(!v)throw Error(`Public account address is not available`);let y=u.map(e=>e.erc20TokenAddress),b=await i.modifyVolatileTokenAmountChanges(_,u,d,v),x=s.createTransaferEmporiumOpsBatch(l,_,y,b),S=m??await o.getFeeStructure(_,p,y,n.ExternalActionId.Emporium,x.map(e=>c.convertEmporiumOpToCallInfo(e,v,_))),C=u.map((e,t)=>({token:e,amount:-1n*b[t]}));return l.actionPrivateWallet(_,[u[0]],[0n],[!1],x,C,h,p,S,void 0,void 0,void 0,g,{recipientInfo:f,amount:b[0],token:u[0]})};exports.hinkalProxyToPrivate=l;
|
|
@@ -5,8 +5,8 @@ import { validateAndGetChainId as r } from "../../functions/utils/token-check.ut
|
|
|
5
5
|
import { modifyVolatileTokenAmountChanges as i } from "../../functions/pre-transaction/getVolatileTransferAmount.mjs";
|
|
6
6
|
import { AccountActions as a } from "../AccountActions/AccountActions.mjs";
|
|
7
7
|
import { getFeeStructure as o } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { createTransaferEmporiumOpsBatch as s } from "../../functions/private-wallet/emporium.helpers.mjs";
|
|
9
|
+
import { convertEmporiumOpToCallInfo as c } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
|
|
10
10
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalProxyToPrivate.ts
|
|
11
11
|
var l = async (l, u, d, f, p, m, h, g) => {
|
|
12
12
|
if (!h) throw Error("hinkalProxyToPrivate: subAccount should be provided");
|
|
@@ -14,7 +14,7 @@ var l = async (l, u, d, f, p, m, h, g) => {
|
|
|
14
14
|
if (!t(f)) throw Error(e.RECIPIENT_FORMAT_INCORRECT);
|
|
15
15
|
let _ = r(u), v = a.getAddressFromSubAccount(_, h);
|
|
16
16
|
if (!v) throw Error("Public account address is not available");
|
|
17
|
-
let y = u.map((e) => e.erc20TokenAddress), b = await i(_, u, d, v), x =
|
|
17
|
+
let y = u.map((e) => e.erc20TokenAddress), b = await i(_, u, d, v), x = s(l, _, y, b), S = m ?? await o(_, p, y, n.Emporium, x.map((e) => c(e, v, _))), C = u.map((e, t) => ({
|
|
18
18
|
token: e,
|
|
19
19
|
amount: -1n * b[t]
|
|
20
20
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../error-handling/error-codes.constants.cjs`),r=require(`../../functions/web3/etherFunctions.cjs`),i=require(`../crypto-keys/keys.cjs`),a=require(`../../functions/utils/time.utils.cjs`),o=require(`../utxo/Utxo.cjs`),s=require(`../../types/external-action.types.cjs`);require(`../../types/index.cjs`);const c=require(`../../functions/utils/token-check.utils.cjs`),l=require(`../../functions/snarkjs/constructTxEnclave.cjs`),u=require(`../../functions/pre-transaction/getFeeStructure.cjs`),d=require(`../../functions/web3/functionCalls/transactCallRelayer.cjs`),f=require(`../../functions/snarkjs/constructSolanaZkProof.cjs`);var p=async(e,n,r,i,a,o,s,c,u,d,f)=>{let{jobId:p,signedMessageHash:m}=await l.prepareSolanaTxEnclaveCall(e,{chainId:n,mintAddresses:[r],amountChanges:i,relayAddress:a,recipient:t.solanaNativeAddress,signer:a,functionName:`transfer`,accounts:o,relayerFee:u,variableRate:0n,hinkalInstructions:[],remainingAccounts:[],recipientAddress:s,recipientAmounts:[c],inputCommitments:[f]},d),{R8:h,S:g}=d.signEddsa(BigInt(m));return l.finalizeSolanaTxEnclaveCallRelay(p,{R8:h,S:g},n)},m=async(l,m,h,g,_)=>{let v=c.validateAndGetChainId([m]),y=m.erc20TokenAddress;if(h.getTokenAddress(v)!==y)throw Error(`Off-chain UTXO token mismatch`);let b=_?new i.UserKeys(_):new i.UserKeys(h.nullifyingKey,h.nullifyingKey);if(!h.nullifyingKey&&!_)throw Error(`Claimable UTXO nullifyingKey is missing`);let x=b.getShieldedPrivateKey();if(h.nullifyingKey&&h.nullifyingKey!==x)throw Error(`Claimable UTXO key mismatch`);let{originalDeployer:S}=e.networkRegistry[v].contractData;if(!S)throw Error(`missing data`);let C=o.Utxo.createFrom(h,{nullifyingKey:x}),w=g??await u.getFeeStructure(v,y,[y],s.ExternalActionId.Transact,void 0,void 0,{mintTo:y,nullifierCount:1,rootInsertCount:2});if(w.feeToken!==y)throw Error(`Claim fee token mismatch: fee must be paid from claimed UTXO token`);let T=w.variableRate>0n?w.variableRate:t.HINKAL_PRIVATE_SEND_VARIABLE_RATE;if(C.amount<=w.flatFee)throw Error(n.transactionErrorCodes.INSUFFICIENT_FUNDS_TO_TRANSACT);let E=C.amount-w.flatFee,D=E*T/10000n,O=E-D;if(O<=0n)throw Error(n.transactionErrorCodes.RECIPIENT_AMOUNT_INVALID);let k=w.flatFee+D,A=l.getRecipientInfo(),[j,M,N,,,P]=A.split(`,`);if(!M||!N||!j||!P)throw Error(`Invalid recipient info`);let F=a.getCurrentTimeInSeconds().toString(),I=new o.Utxo({amount:0n,erc20TokenAddress:C.erc20TokenAddress,mintAddress:C.mintAddress,nullifyingKey:b.getShieldedPrivateKey(),spendingPublicKey:b.getSpendingKeyPair().pubSpendingBJJPoint}),L=new o.Utxo({amount:0n,erc20TokenAddress:C.erc20TokenAddress,mintAddress:C.mintAddress,nullifyingKey:b.getShieldedPrivateKey(),timeStamp:F,spendingPublicKey:b.getSpendingKeyPair().pubSpendingBJJPoint}),R=new o.Utxo({amount:O,erc20TokenAddress:C.erc20TokenAddress,mintAddress:C.mintAddress,timeStamp:F,H0:[BigInt(M),BigInt(N)],stealthAddress:j,encryptionKey:P}),z=[C,I],B=[L,R],V=await l.getRandomRelay(v,!0);if(!V)throw Error(n.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let H={recipient:V,mint:y===`11111111111111111111111111111111`?void 0:y};if(l.generateProofRemotely)return p(l,v,y,[-(O+k)],V,H,A,O,k,b,C.getCommitment());let U=i.UserKeys.findCorrectRandomization(r.randomBigInt(31),b.getShieldedPrivateKey()),W={tokenNumber:1,nullifierAmount:z.length,outputAmount:B.length},{proofAArr:G,proofBArr:K,proofCArr:q,publicInputsArr:J,commitmentValidationData:Y,rootHashHinkalIndex:X,encryptedOutputs:Z}=await f.constructSolanaZkProof(l.merkleTreeHinkalByChain[v],b,[y],[z],[B],U,k,0n,t.solanaNativeAddress,V,W,void 0,v);return d.solanaTransactCallRelayer({chainId:v,relayAddress:V,functionName:`transfer`,args:{proofAArr:G,proofBArr:K,proofCArr:q,publicInputsArr:J,encryptedOutputs:Z,relayerFee:k.toString(),dimensions:W,rootHashIndex:X.toString()},accounts:H,commitmentValidationData:Y})};exports.hinkalSolanaClaimUtxo=m;
|