@hinkal/common 0.3.2 → 0.3.4
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 +16 -19
- 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/crypto/index.cjs +1 -1
- package/common/src/crypto/index.d.ts +0 -1
- package/common/src/crypto/index.mjs +0 -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/crypto/ecdh-dual-path.cjs +0 -1
- package/common/src/crypto/ecdh-dual-path.d.ts +0 -13
- package/common/src/crypto/ecdh-dual-path.mjs +0 -6
- 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,118 +1,128 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PAY_SEND_VARIABLE_RATE as
|
|
3
|
-
import { caseInsensitiveEqual as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { hashEthereumAddress as
|
|
8
|
-
import { ExternalActionId as
|
|
9
|
-
import { DepositAndWithdrawPhase as
|
|
1
|
+
import { getOnchainChainId as e, networkRegistry as t } from "../../constants/chains.constants.mjs";
|
|
2
|
+
import { PAY_SEND_VARIABLE_RATE as n, zeroAddress as r } from "../../constants/protocol.constants.mjs";
|
|
3
|
+
import { caseInsensitiveEqual as i } from "../../functions/utils/caseInsensitive.utils.mjs";
|
|
4
|
+
import { poseidonFunction as a } from "../../crypto/poseidon.mjs";
|
|
5
|
+
import { transactionErrorCodes as o } from "../../error-handling/error-codes.constants.mjs";
|
|
6
|
+
import { randomBigInt as s } from "../../functions/web3/etherFunctions.mjs";
|
|
7
|
+
import { hashEthereumAddress as c, hashString as l } from "../../functions/utils/addresses.mjs";
|
|
8
|
+
import { ExternalActionId as u } from "../../types/external-action.types.mjs";
|
|
9
|
+
import { DepositAndWithdrawPhase as d } from "../../types/scheduled-transactions.types.mjs";
|
|
10
|
+
import { SubmitMode as f } from "../../types/transact.types.mjs";
|
|
10
11
|
import "../../types/index.mjs";
|
|
11
|
-
import { API as
|
|
12
|
-
import { validateAndGetChainId as
|
|
13
|
-
import { getErc20TokenFromAPI as
|
|
14
|
-
import { constructAdminData as
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { calculateGrossAmountWithFee as y } from "../../functions/utils/fees.utils.mjs";
|
|
20
|
-
import "../../functions/utils/index.mjs";
|
|
21
|
-
import { createLifiBridgeOps as b, getAuthorizationDataIfNeeded as x } from "../../functions/private-wallet/emporium.helpers.mjs";
|
|
22
|
-
import { constructZkProof as S } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
12
|
+
import { API as p } from "../../API/API.mjs";
|
|
13
|
+
import { validateAndGetChainId as m } from "../../functions/utils/token-check.utils.mjs";
|
|
14
|
+
import { getErc20TokenFromAPI as h } from "../../functions/utils/erc20tokenFunctions.mjs";
|
|
15
|
+
import { constructAdminData as g } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
16
|
+
import { AccountActions as _ } from "../AccountActions/AccountActions.mjs";
|
|
17
|
+
import { getFeeStructure as v } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
18
|
+
import { waitForDepositedUtxosInMerkleTree as y } from "../../functions/pre-transaction/waitForDepositedUtxosInMerkleTree.mjs";
|
|
19
|
+
import { createLifiBridgeOps as b, encodeEmporiumMetadata as x, getAuthorizationDataIfNeeded as S } from "../../functions/private-wallet/emporium.helpers.mjs";
|
|
23
20
|
import { transactCallRelayerBatch as C } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
21
|
+
import { hinkalTransact as w } from "./hinkalTransact.mjs";
|
|
22
|
+
import { SWAP_ROUTER_ADDRESSES as T } from "../../constants/addresses.constants.mjs";
|
|
23
|
+
import { safeUpdateDepositAndWithdrawStatus as E } from "../../API/deposit-and-withdraw-status-calls.mjs";
|
|
24
|
+
import { hinkalDepositOnChainUtxos as D } from "./hinkalDepositOnChainUtxos.mjs";
|
|
25
|
+
import { convertEmporiumOpToCallInfo as O } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
|
|
26
|
+
import { calculateGrossAmountWithFee as k } from "../../functions/utils/fees.utils.mjs";
|
|
27
|
+
import "../../functions/utils/index.mjs";
|
|
26
28
|
import "../../functions/index.mjs";
|
|
27
29
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalDepositAndBridge.ts
|
|
28
|
-
var
|
|
29
|
-
if (
|
|
30
|
-
let
|
|
31
|
-
if (!
|
|
32
|
-
let
|
|
33
|
-
if (!
|
|
34
|
-
let
|
|
35
|
-
if (!
|
|
36
|
-
let
|
|
37
|
-
for (let
|
|
38
|
-
let
|
|
39
|
-
await
|
|
40
|
-
let
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
30
|
+
var A = async (n, c, l, m, h, v, y, D, O, k, A) => {
|
|
31
|
+
if (m.length === 0) throw Error("No recipients to bridge");
|
|
32
|
+
let j = l.erc20TokenAddress, { contractData: M } = t[c], { emporiumAddress: N } = M;
|
|
33
|
+
if (!N) throw Error("No Emporium Address");
|
|
34
|
+
let P = T[u.Lifi][c];
|
|
35
|
+
if (!P) throw Error(`LIFI not configured for chain ${c}`);
|
|
36
|
+
let F = await n.getRandomRelay(c);
|
|
37
|
+
if (!F) throw Error(o.RELAYER_NOT_AVAILABLE);
|
|
38
|
+
let I = await n.getEthereumAddressByChain(c), L = n.generateProofRemotely, R = L ? 5 : 1, z = [];
|
|
39
|
+
for (let t = 0; t < m.length; t += R) {
|
|
40
|
+
let o = m.slice(t, t + R), l = await Promise.all(o.map(async ({ utxo: t, nativeUtxo: o, bridgeAmount: l, quote: d, temporarySubAccount: m, recipientAddress: y, destinationChainId: C, destinationTokenAddress: T }) => {
|
|
41
|
+
await p.addTemporaryWalletNonce(c, v, m.index);
|
|
42
|
+
let E = i(j, r), D = d.nativeFee > 0n && !E, O = [j], A = [-t.amount], M = [!1], R = [[t]];
|
|
43
|
+
D && o && (O.push(r), A.push(-o.amount), M.push(!1), R.push([o]));
|
|
44
|
+
let z = b(n, c, m.ethAddress, P, j, t.amount, l, d), B = g(k, c, O, [-t.amount], I), [V, H] = await Promise.all([(async () => {
|
|
45
|
+
let t = s(31), i = L ? await x(c, N, m.privateKey, z, a(t), _.getSignerAddressFromPrivateKey(e(c), m.privateKey)) : void 0;
|
|
46
|
+
return w(n, {
|
|
47
|
+
chainId: c,
|
|
48
|
+
erc20Addresses: O,
|
|
49
|
+
amountChanges: A,
|
|
50
|
+
externalAddress: N,
|
|
51
|
+
externalActionId: u.Emporium,
|
|
52
|
+
externalActionMetadata: i,
|
|
53
|
+
onChainCreation: M,
|
|
54
|
+
feeStructure: h,
|
|
55
|
+
relay: F ?? r,
|
|
56
|
+
messageSeed: t,
|
|
57
|
+
inputUtxos: R,
|
|
58
|
+
useBlockedUtxos: !0,
|
|
59
|
+
subAccountPrivateKey: m.privateKey,
|
|
60
|
+
emporiumOps: z,
|
|
61
|
+
submit: { mode: f.ProofOnly }
|
|
54
62
|
});
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
let P = b(t, s, u.ethAddress, A, D, e.amount, a, c), F = m(T, s, v, [-e.amount], M), [{ zkCallData: I, circomData: L, dimData: R, commitmentValidationData: z }, B] = await Promise.all([S(t.merkleTreeHinkalByChain[s], E, O, t.userKeys, l.Emporium, k, P, t.generateProofRemotely, p, j ?? n, s, C, void 0, void 0, u.privateKey), x(s, u.privateKey)]);
|
|
63
|
+
})(), S(c, m.privateKey)]), { zkCallData: U, circomData: W, dimData: G, commitmentValidationData: K, tronProofSignature: q } = V;
|
|
58
64
|
return {
|
|
59
|
-
zkCallData:
|
|
60
|
-
dimData:
|
|
61
|
-
circomData:
|
|
62
|
-
commitmentValidationData:
|
|
63
|
-
authorizationData:
|
|
64
|
-
recipientAddress:
|
|
65
|
-
adminData:
|
|
65
|
+
zkCallData: U,
|
|
66
|
+
dimData: G,
|
|
67
|
+
circomData: W,
|
|
68
|
+
commitmentValidationData: K,
|
|
69
|
+
authorizationData: H,
|
|
70
|
+
recipientAddress: y,
|
|
71
|
+
adminData: B,
|
|
72
|
+
tronProofSignature: q,
|
|
73
|
+
destinationChainId: C,
|
|
74
|
+
destinationTokenAddress: T,
|
|
75
|
+
destinationTokenAmount: d.expectedAmount.toString()
|
|
66
76
|
};
|
|
67
77
|
}));
|
|
68
|
-
|
|
78
|
+
z.push(...l);
|
|
69
79
|
}
|
|
70
|
-
await
|
|
71
|
-
id:
|
|
72
|
-
chainId:
|
|
73
|
-
hashedEthereumAddress:
|
|
74
|
-
phase:
|
|
80
|
+
await E({
|
|
81
|
+
id: y,
|
|
82
|
+
chainId: c,
|
|
83
|
+
hashedEthereumAddress: v,
|
|
84
|
+
phase: d.BEFORE_SCHEDULE_WITHDRAW
|
|
75
85
|
});
|
|
76
|
-
let
|
|
77
|
-
return await
|
|
78
|
-
id:
|
|
79
|
-
chainId:
|
|
80
|
-
hashedEthereumAddress:
|
|
81
|
-
phase:
|
|
82
|
-
scheduleId:
|
|
83
|
-
}),
|
|
84
|
-
},
|
|
85
|
-
let
|
|
86
|
-
if (!
|
|
87
|
-
let
|
|
88
|
-
if (
|
|
86
|
+
let B = await C(c, z, v, D, O, A);
|
|
87
|
+
return await E({
|
|
88
|
+
id: y,
|
|
89
|
+
chainId: c,
|
|
90
|
+
hashedEthereumAddress: v,
|
|
91
|
+
phase: d.AFTER_SCHEDULE_WITHDRAW,
|
|
92
|
+
scheduleId: B
|
|
93
|
+
}), B;
|
|
94
|
+
}, j = async (e, t, a, o, s, d, f, p, g = !0) => {
|
|
95
|
+
let _ = t.erc20TokenAddress, x = m([t]), S = p ? l(p) : void 0, C = c(await e.getEthereumAddressByChain(x)), w = T[u.Lifi][x];
|
|
96
|
+
if (!w) throw Error("LIFI router not configured");
|
|
97
|
+
let E, j = i(_, r);
|
|
98
|
+
if (s) E = s;
|
|
89
99
|
else {
|
|
90
|
-
let
|
|
91
|
-
|
|
100
|
+
let t = a[0], r = j ? t.bridgeAmount + t.quote.nativeFee : t.bridgeAmount, i = b(e, x, t.temporarySubAccount.ethAddress, w, _, r, t.bridgeAmount, t.quote).map((e) => O(e, t.temporarySubAccount.ethAddress, x));
|
|
101
|
+
E = await v(x, _, [_], u.Emporium, i, n);
|
|
92
102
|
}
|
|
93
103
|
let M = {
|
|
94
|
-
feeToken:
|
|
104
|
+
feeToken: E.feeToken,
|
|
95
105
|
flatFee: 0n,
|
|
96
106
|
variableRate: 0n
|
|
97
|
-
}, N = a.reduce((e, t) => e + t.quote.nativeFee, 0n) > 0n && !
|
|
107
|
+
}, N = a.reduce((e, t) => e + t.quote.nativeFee, 0n) > 0n && !i(_, r), P = a.map((e) => k(j ? e.bridgeAmount + e.quote.nativeFee : e.bridgeAmount, E)), F = a.map((e) => e.recipientAddress), { userDepositedUtxos: I, statusId: L, depositTxHash: R } = await D(e, x, t, P, F, M, C, g), z = [];
|
|
98
108
|
if (N) {
|
|
99
|
-
let t = await
|
|
109
|
+
let t = await h(x, r);
|
|
100
110
|
if (!t) throw Error("No native token");
|
|
101
|
-
let { userDepositedUtxos:
|
|
102
|
-
feeToken:
|
|
111
|
+
let { userDepositedUtxos: n } = await D(e, x, t, a.map((e) => k(e.quote.nativeFee, {
|
|
112
|
+
feeToken: E.feeToken,
|
|
103
113
|
flatFee: 0n,
|
|
104
|
-
variableRate:
|
|
105
|
-
})), F, M,
|
|
106
|
-
z =
|
|
114
|
+
variableRate: E.variableRate
|
|
115
|
+
})), F, M, C, g);
|
|
116
|
+
z = n;
|
|
107
117
|
}
|
|
108
|
-
return await
|
|
118
|
+
return await y(e, x, [...I, ...z]), {
|
|
109
119
|
depositTxHash: R,
|
|
110
|
-
scheduleId: await
|
|
120
|
+
scheduleId: await A(e, x, t, a.map((e, t) => ({
|
|
111
121
|
...e,
|
|
112
122
|
utxo: I[t].utxo,
|
|
113
123
|
nativeUtxo: N ? z[t]?.utxo : void 0
|
|
114
|
-
})),
|
|
124
|
+
})), E, C, L, o, d, f, S)
|
|
115
125
|
};
|
|
116
126
|
};
|
|
117
127
|
//#endregion
|
|
118
|
-
export {
|
|
128
|
+
export { j as hinkalDepositAndBridge };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../functions/utils/caseInsensitive.utils.cjs`),r=require(`../../error-handling/error-codes.constants.cjs`),i=require(
|
|
1
|
+
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../functions/utils/caseInsensitive.utils.cjs`),r=require(`../../error-handling/error-codes.constants.cjs`),i=require(`../utxo/Utxo.cjs`),a=require(`../../functions/utils/addresses.cjs`),o=require(`../../functions/utils/tron.utils.cjs`),s=require(`../../types/external-action.types.cjs`),c=require(`../../types/scheduled-transactions.types.cjs`),l=require(`../../types/transact.types.cjs`);require(`../../types/index.cjs`);const u=require(`../../functions/utils/token-check.utils.cjs`),d=require(`../crypto-keys/encryptDecryptUtxo.cjs`),f=require(`../../functions/snarkjs/common.snarkjs.cjs`),p=require(`../../functions/pre-transaction/constructAdminData.cjs`),m=require(`../../functions/snarkjs/constructTxEnclave.cjs`),h=require(`../../functions/pre-transaction/getFeeStructure.cjs`),g=require(`../../functions/pre-transaction/waitForDepositedUtxosInMerkleTree.cjs`),_=require(`../../functions/web3/functionCalls/transactCallDirectTron.cjs`),v=require(`../../functions/web3/functionCalls/transactCallRelayer.cjs`),y=require(`./hinkalTransact.cjs`),b=require(`../../functions/utils/tx-confirmation.utils.cjs`),x=require(`../../API/deposit-and-withdraw-status-calls.cjs`),S=require(`./hinkalDepositOnChainUtxos.cjs`),C=require(`./hinkalTronDepositToSelf.cjs`);require(`../../functions/index.cjs`);let w=require(`ethers`);var T=async(e,t,n,r,i,a,s,l=!0)=>{let u=n.erc20TokenAddress,p=r.map(e=>e+a.flatFee),h=p.reduce((e,t)=>e+t,0n),g=(await x.updateDepositAndWithdrawStatus({chainId:t,hashedEthereumAddress:s,phase:c.DepositAndWithdrawPhase.BEFORE_DEPOSIT})).id??void 0,{jobId:v,signedMessageHash:y}=await m.prepareTxEnclaveCall(e,{chainId:t,erc20Addresses:[u],amountChanges:[h],externalAddress:o.addressToHexFormat(await e.getEthereumAddressByChain(t)),selfOutputAmounts:p,createBlockedUtxos:!0}),{R8:S,S:C}=e.userKeys.signEddsa(BigInt(y)),{zkCallData:T,circomData:E,dimData:D,tronProofSignature:O}=await m.finalizeTxEnclaveCall(v,{R8:S,S:C}),k=f.deserializeCircomData(E),A=await _.transactCallDirectTron(e,t,h,n,T,k,D,void 0,void 0,l,O);await b.waitForEthereumTransactionConfirmation(t,A),await x.safeUpdateDepositAndWithdrawStatus({id:g,chainId:t,hashedEthereumAddress:s,phase:c.DepositAndWithdrawPhase.AFTER_DEPOSIT,depositTxHash:A});let j=k.encryptedOutputs?.[0];if(!j||j.length!==p.length)throw Error(`Enclave response missing encryptedOutputs for deposited UTXOs`);return{userDepositedUtxos:j.map((t,n)=>({recipientAddress:i[n],utxo:d.decryptUtxo(w.ethers.getBytes(t),e.userKeys)})),statusId:g,depositTxHash:A}},E=async(e,a,s,u,d,f,m,h,g,_,b,S)=>{if(u.length===0)throw Error(`userDepositedUtxos must not be empty`);let C=s.erc20TokenAddress,[w,T]=await Promise.all([e.getRandomRelay(a),e.getEthereumAddressByChain(a)]);if(!w)throw Error(r.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let E=e.generateProofRemotely?5:1,D=[],O=o.addressToHexFormat(T);for(let r=0;r<u.length;r+=E){let s=u.slice(r,r+E),c=await Promise.all(s.map(async({recipientAddress:s,utxo:c},u)=>{let f=r+u,m=o.addressToHexFormat(s),h=n.caseInsensitiveEqual(c.erc20TokenAddress,C)?c:i.Utxo.createFrom(c,{erc20TokenAddress:C}),g=p.constructAdminData(_,a,[C],[-c.amount],O),{zkCallData:v,circomData:b,dimData:x,commitmentValidationData:T,tronProofSignature:E}=await y.hinkalTransact(e,{chainId:a,erc20Addresses:[C],amountChanges:[-c.amount],externalAddress:m,feeStructure:d,relay:w??t.zeroAddress,inputUtxos:[[h]],useBlockedUtxos:!0,submit:{mode:l.SubmitMode.ProofOnly},skipLock:!0});return{zkCallData:v,dimData:x,circomData:b,commitmentValidationData:T,adminData:g,recipientAddress:s,tronProofSignature:E,destinationChainId:S?.chainId,destinationTokenAddress:S?.tokenAddress,destinationTokenAmount:S?.tokenAmounts?.[f]}}));D.push(...c)}await x.safeUpdateDepositAndWithdrawStatus({id:m,chainId:a,hashedEthereumAddress:f,phase:c.DepositAndWithdrawPhase.BEFORE_SCHEDULE_WITHDRAW});let k=await v.transactCallRelayerBatch(a,D,f,h,g,b);return await x.safeUpdateDepositAndWithdrawStatus({id:m,chainId:a,hashedEthereumAddress:f,phase:c.DepositAndWithdrawPhase.AFTER_SCHEDULE_WITHDRAW,scheduleId:k}),k},D=async(t,n,r,i,c,l,d,f,p,m=!0,_)=>{let v=u.validateAndGetChainId([n]),y=p?a.hashString(p):void 0,b=n.erc20TokenAddress,x=a.hashEthereumAddress(o.addressToHexFormat(await t.getEthereumAddressByChain(v))),w=l??await h.getFeeStructure(v,b,[b],s.ExternalActionId.Transact,[],10n),D=e.isTronLike(v),O=S.hinkalDepositOnChainUtxos;D&&(O=t.generateProofRemotely?T:C.hinkalTronDepositToSelf);let{userDepositedUtxos:k,statusId:A,depositTxHash:j}=await O(t,v,n,r,i,w,x,m);return await g.waitForDepositedUtxosInMerkleTree(t,v,k),{depositTxHash:j,scheduleId:await E(t,v,n,k,w,x,A,c,d,f,y,_)}};exports.hinkalDepositAndWithdraw=D;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IHinkal } from './IHinkal';
|
|
2
2
|
import { AdminTransactionType, DepositAndSendExtendedResult, ERC20Token, RecipientUtxo } from '../../types';
|
|
3
|
+
import { DestinationMetadata } from '../../types/bridging-tx.types';
|
|
3
4
|
import { FeeStructure } from '../../types/hinkal.types';
|
|
4
|
-
export declare const hinkalWithdrawBatch: (hinkal: IHinkal, chainId: number, erc20Token: ERC20Token, userDepositedUtxos: RecipientUtxo[], feeStructure: FeeStructure, hashedEthereumAddress: string, statusId: string | undefined, txCompletionTime?: number, ref?: string, action?: AdminTransactionType, hashedDashboardAccountId?: string) => Promise<string>;
|
|
5
|
+
export declare const hinkalWithdrawBatch: (hinkal: IHinkal, chainId: number, erc20Token: ERC20Token, userDepositedUtxos: RecipientUtxo[], feeStructure: FeeStructure, hashedEthereumAddress: string, statusId: string | undefined, txCompletionTime?: number, ref?: string, action?: AdminTransactionType, hashedDashboardAccountId?: string, destination?: DestinationMetadata) => Promise<string>;
|
|
5
6
|
export declare const hinkalDepositAndWithdraw: (hinkal: IHinkal, erc20Token: ERC20Token, recipientAmounts: bigint[], recipientAddresses: string[], txCompletionTime?: number, feeStructureOverride?: FeeStructure, // Should be passed fee for only one withdraw transaction, multiplication happening in this function
|
|
6
|
-
ref?: string, action?: AdminTransactionType, dashboardAccountId?: string, preEstimateGas?: boolean) => Promise<DepositAndSendExtendedResult>;
|
|
7
|
+
ref?: string, action?: AdminTransactionType, dashboardAccountId?: string, preEstimateGas?: boolean, destination?: DestinationMetadata) => Promise<DepositAndSendExtendedResult>;
|
|
@@ -2,74 +2,119 @@ import { isTronLike as e } from "../../constants/chains.constants.mjs";
|
|
|
2
2
|
import { zeroAddress as t } from "../../constants/protocol.constants.mjs";
|
|
3
3
|
import { caseInsensitiveEqual as n } from "../../functions/utils/caseInsensitive.utils.mjs";
|
|
4
4
|
import { transactionErrorCodes as r } from "../../error-handling/error-codes.constants.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
5
|
+
import { Utxo as i } from "../utxo/Utxo.mjs";
|
|
6
|
+
import { hashEthereumAddress as a, hashString as o } from "../../functions/utils/addresses.mjs";
|
|
7
|
+
import { addressToHexFormat as s } from "../../functions/utils/tron.utils.mjs";
|
|
8
|
+
import { ExternalActionId as c } from "../../types/external-action.types.mjs";
|
|
9
|
+
import { DepositAndWithdrawPhase as l } from "../../types/scheduled-transactions.types.mjs";
|
|
10
|
+
import { SubmitMode as u } from "../../types/transact.types.mjs";
|
|
11
11
|
import "../../types/index.mjs";
|
|
12
|
-
import { validateAndGetChainId as
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
12
|
+
import { validateAndGetChainId as d } from "../../functions/utils/token-check.utils.mjs";
|
|
13
|
+
import { decryptUtxo as f } from "../crypto-keys/encryptDecryptUtxo.mjs";
|
|
14
|
+
import { deserializeCircomData as p } from "../../functions/snarkjs/common.snarkjs.mjs";
|
|
15
|
+
import { constructAdminData as m } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
16
|
+
import { finalizeTxEnclaveCall as h, prepareTxEnclaveCall as g } from "../../functions/snarkjs/constructTxEnclave.mjs";
|
|
17
|
+
import { getFeeStructure as _ } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
18
|
+
import { waitForDepositedUtxosInMerkleTree as v } from "../../functions/pre-transaction/waitForDepositedUtxosInMerkleTree.mjs";
|
|
19
|
+
import { transactCallDirectTron as y } from "../../functions/web3/functionCalls/transactCallDirectTron.mjs";
|
|
20
|
+
import { transactCallRelayerBatch as b } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
21
|
+
import { hinkalTransact as x } from "./hinkalTransact.mjs";
|
|
22
|
+
import { waitForEthereumTransactionConfirmation as S } from "../../functions/utils/tx-confirmation.utils.mjs";
|
|
23
|
+
import { safeUpdateDepositAndWithdrawStatus as C, updateDepositAndWithdrawStatus as w } from "../../API/deposit-and-withdraw-status-calls.mjs";
|
|
24
|
+
import { hinkalDepositOnChainUtxos as T } from "./hinkalDepositOnChainUtxos.mjs";
|
|
25
|
+
import { hinkalTronDepositToSelf as E } from "./hinkalTronDepositToSelf.mjs";
|
|
20
26
|
import "../../functions/index.mjs";
|
|
27
|
+
import { ethers as D } from "ethers";
|
|
21
28
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.ts
|
|
22
|
-
var
|
|
23
|
-
let
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
29
|
+
var O = async (e, t, n, r, i, a, o, c = !0) => {
|
|
30
|
+
let u = n.erc20TokenAddress, d = r.map((e) => e + a.flatFee), m = d.reduce((e, t) => e + t, 0n), _ = (await w({
|
|
31
|
+
chainId: t,
|
|
32
|
+
hashedEthereumAddress: o,
|
|
33
|
+
phase: l.BEFORE_DEPOSIT
|
|
34
|
+
})).id ?? void 0, { jobId: v, signedMessageHash: b } = await g(e, {
|
|
35
|
+
chainId: t,
|
|
36
|
+
erc20Addresses: [u],
|
|
37
|
+
amountChanges: [m],
|
|
38
|
+
externalAddress: s(await e.getEthereumAddressByChain(t)),
|
|
39
|
+
selfOutputAmounts: d,
|
|
40
|
+
createBlockedUtxos: !0
|
|
41
|
+
}), { R8: x, S: T } = e.userKeys.signEddsa(BigInt(b)), { zkCallData: E, circomData: O, dimData: k, tronProofSignature: A } = await h(v, {
|
|
42
|
+
R8: x,
|
|
43
|
+
S: T
|
|
44
|
+
}), j = p(O), M = await y(e, t, m, n, E, j, k, void 0, void 0, c, A);
|
|
45
|
+
await S(t, M), await C({
|
|
46
|
+
id: _,
|
|
47
|
+
chainId: t,
|
|
48
|
+
hashedEthereumAddress: o,
|
|
49
|
+
phase: l.AFTER_DEPOSIT,
|
|
50
|
+
depositTxHash: M
|
|
51
|
+
});
|
|
52
|
+
let N = j.encryptedOutputs?.[0];
|
|
53
|
+
if (!N || N.length !== d.length) throw Error("Enclave response missing encryptedOutputs for deposited UTXOs");
|
|
54
|
+
return {
|
|
55
|
+
userDepositedUtxos: N.map((t, n) => ({
|
|
56
|
+
recipientAddress: i[n],
|
|
57
|
+
utxo: f(D.getBytes(t), e.userKeys)
|
|
58
|
+
})),
|
|
59
|
+
statusId: _,
|
|
60
|
+
depositTxHash: M
|
|
61
|
+
};
|
|
62
|
+
}, k = async (e, a, o, c, d, f, p, h, g, _, v, y) => {
|
|
63
|
+
if (c.length === 0) throw Error("userDepositedUtxos must not be empty");
|
|
64
|
+
let S = o.erc20TokenAddress, [w, T] = await Promise.all([e.getRandomRelay(a), e.getEthereumAddressByChain(a)]);
|
|
65
|
+
if (!w) throw Error(r.RELAYER_NOT_AVAILABLE);
|
|
66
|
+
let E = e.generateProofRemotely ? 5 : 1, D = [], O = s(T);
|
|
67
|
+
for (let r = 0; r < c.length; r += E) {
|
|
68
|
+
let o = c.slice(r, r + E), l = await Promise.all(o.map(async ({ recipientAddress: o, utxo: c }, l) => {
|
|
69
|
+
let f = r + l, p = s(o), h = n(c.erc20TokenAddress, S) ? c : i.createFrom(c, { erc20TokenAddress: S }), g = m(_, a, [S], [-c.amount], O), { zkCallData: v, circomData: b, dimData: C, commitmentValidationData: T, tronProofSignature: E } = await x(e, {
|
|
70
|
+
chainId: a,
|
|
71
|
+
erc20Addresses: [S],
|
|
72
|
+
amountChanges: [-c.amount],
|
|
73
|
+
externalAddress: p,
|
|
74
|
+
feeStructure: d,
|
|
75
|
+
relay: w ?? t,
|
|
76
|
+
inputUtxos: [[h]],
|
|
77
|
+
useBlockedUtxos: !0,
|
|
78
|
+
submit: { mode: u.ProofOnly },
|
|
79
|
+
skipLock: !0
|
|
80
|
+
});
|
|
41
81
|
return {
|
|
42
82
|
zkCallData: v,
|
|
43
|
-
dimData:
|
|
44
|
-
circomData:
|
|
45
|
-
commitmentValidationData:
|
|
46
|
-
adminData:
|
|
47
|
-
recipientAddress:
|
|
48
|
-
tronProofSignature:
|
|
83
|
+
dimData: C,
|
|
84
|
+
circomData: b,
|
|
85
|
+
commitmentValidationData: T,
|
|
86
|
+
adminData: g,
|
|
87
|
+
recipientAddress: o,
|
|
88
|
+
tronProofSignature: E,
|
|
89
|
+
destinationChainId: y?.chainId,
|
|
90
|
+
destinationTokenAddress: y?.tokenAddress,
|
|
91
|
+
destinationTokenAmount: y?.tokenAmounts?.[f]
|
|
49
92
|
};
|
|
50
93
|
}));
|
|
51
|
-
|
|
94
|
+
D.push(...l);
|
|
52
95
|
}
|
|
53
|
-
await
|
|
54
|
-
id:
|
|
55
|
-
chainId:
|
|
56
|
-
hashedEthereumAddress:
|
|
57
|
-
phase:
|
|
96
|
+
await C({
|
|
97
|
+
id: p,
|
|
98
|
+
chainId: a,
|
|
99
|
+
hashedEthereumAddress: f,
|
|
100
|
+
phase: l.BEFORE_SCHEDULE_WITHDRAW
|
|
58
101
|
});
|
|
59
|
-
let
|
|
60
|
-
return await
|
|
61
|
-
id:
|
|
62
|
-
chainId:
|
|
63
|
-
hashedEthereumAddress:
|
|
64
|
-
phase:
|
|
65
|
-
scheduleId:
|
|
66
|
-
}),
|
|
67
|
-
},
|
|
68
|
-
let
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
102
|
+
let k = await b(a, D, f, h, g, v);
|
|
103
|
+
return await C({
|
|
104
|
+
id: p,
|
|
105
|
+
chainId: a,
|
|
106
|
+
hashedEthereumAddress: f,
|
|
107
|
+
phase: l.AFTER_SCHEDULE_WITHDRAW,
|
|
108
|
+
scheduleId: k
|
|
109
|
+
}), k;
|
|
110
|
+
}, A = async (t, n, r, i, l, u, f, p, m, h = !0, g) => {
|
|
111
|
+
let y = d([n]), b = m ? o(m) : void 0, x = n.erc20TokenAddress, S = a(s(await t.getEthereumAddressByChain(y))), C = u ?? await _(y, x, [x], c.Transact, [], 10n), w = e(y), D = T;
|
|
112
|
+
w && (D = t.generateProofRemotely ? O : E);
|
|
113
|
+
let { userDepositedUtxos: A, statusId: j, depositTxHash: M } = await D(t, y, n, r, i, C, S, h);
|
|
114
|
+
return await v(t, y, A), {
|
|
115
|
+
depositTxHash: M,
|
|
116
|
+
scheduleId: await k(t, y, n, A, C, S, j, l, f, p, b, g)
|
|
72
117
|
};
|
|
73
118
|
};
|
|
74
119
|
//#endregion
|
|
75
|
-
export {
|
|
120
|
+
export { A as hinkalDepositAndWithdraw };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../types/scheduled-transactions.types.cjs`);require(`../../types/index.cjs`);const t=require(`../../functions/utils/
|
|
1
|
+
const e=require(`../../types/scheduled-transactions.types.cjs`);require(`../../types/index.cjs`);const t=require(`../../functions/utils/tx-confirmation.utils.cjs`),n=require(`../../functions/utils/getUtxosFromReceipt.utils.cjs`),r=require(`../../functions/utils/getRecipientInfoFromUserKeys.cjs`),i=require(`./hinkalProoflessDeposit.utils.cjs`),a=require(`./hinkalProoflessDeposit.cjs`),o=require(`../../API/deposit-and-withdraw-status-calls.cjs`);var s=async(s,c,l,u,d,f,p,m=!0)=>{let h=l.erc20TokenAddress,g=u.map(e=>e+f.flatFee),_=g.map(()=>l),v=g.map(()=>r.getStealthAddressStructureFromUserKeys(s.userKeys)),y=(await o.updateDepositAndWithdrawStatus({chainId:c,hashedEthereumAddress:p,phase:e.DepositAndWithdrawPhase.BEFORE_DEPOSIT})).id??void 0,b=await a.hinkalProoflessDeposit(s,_,g,v,i.getOwnRecipientEncryptionKeys(s.userKeys,g.length),!0);if(!b)throw Error(`Deposit transaction hash not found`);let x=await t.waitForEthereumTransactionConfirmation(c,b);await o.safeUpdateDepositAndWithdrawStatus({id:y,chainId:c,hashedEthereumAddress:p,phase:e.DepositAndWithdrawPhase.AFTER_DEPOSIT,depositTxHash:b});let S=n.getOnChainUtxosFromReceipt(x,s,c,h);if(S.length===0)throw Error(`No UTXOs found in deposit transaction. Check contract address and ABI.`);let C=[],w=[...S];return d.forEach((e,t)=>{let n=g[t],r=w.find(e=>e.amount===n);if(!r)throw Error(`Could not find newly created UTXO with amount ${n} for recipient ${e}.`);C.push({recipientAddress:e,utxo:r});let i=w.indexOf(r);w.splice(i,1)}),{userDepositedUtxos:C,statusId:y,depositTxHash:b}};exports.hinkalDepositOnChainUtxos=s;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { DepositAndWithdrawPhase as e } from "../../types/scheduled-transactions.types.mjs";
|
|
2
2
|
import "../../types/index.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { waitForEthereumTransactionConfirmation as t } from "../../functions/utils/tx-confirmation.utils.mjs";
|
|
4
4
|
import { getOnChainUtxosFromReceipt as n } from "../../functions/utils/getUtxosFromReceipt.utils.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { getStealthAddressStructureFromUserKeys as r } from "../../functions/utils/getRecipientInfoFromUserKeys.mjs";
|
|
6
6
|
import { getOwnRecipientEncryptionKeys as i } from "./hinkalProoflessDeposit.utils.mjs";
|
|
7
7
|
import { hinkalProoflessDeposit as a } from "./hinkalProoflessDeposit.mjs";
|
|
8
8
|
import { safeUpdateDepositAndWithdrawStatus as o, updateDepositAndWithdrawStatus as s } from "../../API/deposit-and-withdraw-status-calls.mjs";
|
|
9
9
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalDepositOnChainUtxos.ts
|
|
10
10
|
var c = async (c, l, u, d, f, p, m, h = !0) => {
|
|
11
|
-
let g = u.erc20TokenAddress, _ = d.map((e) => e + p.flatFee), v = _.map(() => u), y = _.map(() =>
|
|
11
|
+
let g = u.erc20TokenAddress, _ = d.map((e) => e + p.flatFee), v = _.map(() => u), y = _.map(() => r(c.userKeys)), b = (await s({
|
|
12
12
|
chainId: l,
|
|
13
13
|
hashedEthereumAddress: m,
|
|
14
14
|
phase: e.BEFORE_DEPOSIT
|
|
15
15
|
})).id ?? void 0, x = await a(c, v, _, y, i(c.userKeys, _.length), !0);
|
|
16
16
|
if (!x) throw Error("Deposit transaction hash not found");
|
|
17
|
-
let S = await
|
|
17
|
+
let S = await t(l, x);
|
|
18
18
|
await o({
|
|
19
19
|
id: b,
|
|
20
20
|
chainId: l,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../functions/utils/time.utils.cjs`),n=require(`../../functions/utils/token-check.utils.cjs`),r=require(`../../constants/bridging.constants.cjs`),i=require(`../../API/callNearIntentsAPI.cjs`),a=require(`../../functions/utils/nearIntents.utils.cjs`),o=require(`./hinkalDepositAndWithdraw.cjs`),s=require(`./hinkalSolanaDepositAndWithdraw.cjs`);var c=async(c,l,u,d,f,p,m,h,g,_)=>{if(u.length!==d.length)throw Error(`recipientAmounts and recipientAddresses length mismatch`);if(u.length===0)throw Error(`No recipients to bridge`);let v=n.validateAndGetChainId([l]),y=t.secondsToMs(p),b=new Date(y+r.NEAR_BRIDGE_QUOTE_DEADLINE_BUFFER_MS).toISOString(),x=await Promise.all(d.map(async(e,t)=>{let n=u[t],{quote:r}=await i.getNearIntentsQuote({dry:!1,swapType:`EXACT_INPUT`,slippageTolerance:f.slippageBps??100,originAsset:f.originAsset,depositType:`ORIGIN_CHAIN`,destinationAsset:f.destinationAsset,amount:n.toString(),recipient:e,recipientType:`DESTINATION_CHAIN`,refundTo:c.userKeys.getNearIntentsAccountId(),refundType:`INTENTS`,deadline:b});if(!r.depositAddress)throw Error(`NEAR Intents quote returned no deposit address for recipient ${e}`);if(r.deadline&&new Date(r.deadline).getTime()<y)throw Error(`Bridge quote expires before the scheduled execution time. Choose a sooner time.`);return{destinationRecipient:e,amount:n,depositAddress:r.depositAddress,quote:r}})),S=m??await a.buildNearBridgeFeeStructure(v,l,x[0].depositAddress),C=x.map(e=>e.amount),w=x.map(e=>e.depositAddress),T;return e.isSolanaLike(v)?{depositTxHash:
|
|
1
|
+
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../functions/utils/time.utils.cjs`),n=require(`../../functions/utils/token-check.utils.cjs`),r=require(`../../constants/bridging.constants.cjs`),i=require(`../../API/callNearIntentsAPI.cjs`),a=require(`../../functions/utils/nearIntents.utils.cjs`),o=require(`./hinkalDepositAndWithdraw.cjs`),s=require(`./hinkalSolanaDepositAndWithdraw.cjs`);var c=async(c,l,u,d,f,p,m,h,g,_)=>{if(u.length!==d.length)throw Error(`recipientAmounts and recipientAddresses length mismatch`);if(u.length===0)throw Error(`No recipients to bridge`);let v=n.validateAndGetChainId([l]),y=t.secondsToMs(p),b=new Date(y+r.NEAR_BRIDGE_QUOTE_DEADLINE_BUFFER_MS).toISOString(),x=await Promise.all(d.map(async(e,t)=>{let n=u[t],{quote:r}=await i.getNearIntentsQuote({dry:!1,swapType:`EXACT_INPUT`,slippageTolerance:f.slippageBps??100,originAsset:f.originAsset,depositType:`ORIGIN_CHAIN`,destinationAsset:f.destinationAsset,amount:n.toString(),recipient:e,recipientType:`DESTINATION_CHAIN`,refundTo:c.userKeys.getNearIntentsAccountId(),refundType:`INTENTS`,deadline:b});if(!r.depositAddress)throw Error(`NEAR Intents quote returned no deposit address for recipient ${e}`);if(r.deadline&&new Date(r.deadline).getTime()<y)throw Error(`Bridge quote expires before the scheduled execution time. Choose a sooner time.`);return{destinationRecipient:e,amount:n,depositAddress:r.depositAddress,quote:r}})),S=m??await a.buildNearBridgeFeeStructure(v,l,x[0].depositAddress),C=x.map(e=>e.amount),w=x.map(e=>e.depositAddress),T={chainId:f.destinationChainId===v?void 0:f.destinationChainId,tokenAddress:f.destinationTokenAddress,tokenAmounts:x.map(e=>e.quote.amountOut)},E;return e.isSolanaLike(v)?{depositTxHash:E}=await s.hinkalSolanaDepositAndWithdraw(c,l,C,w,p,S,h,g,_,x.map(e=>e.destinationRecipient),T):{depositTxHash:E}=await o.hinkalDepositAndWithdraw(c,l,C,w,p,S,h,g,_,void 0,T),{depositTxHash:E,legs:x}};exports.hinkalNearDepositAndBridge=c;
|
|
@@ -33,9 +33,13 @@ var c = async (c, l, u, d, f, p, m, h, g, _) => {
|
|
|
33
33
|
depositAddress: r.depositAddress,
|
|
34
34
|
quote: r
|
|
35
35
|
};
|
|
36
|
-
})), S = m ?? await a(v, l, x[0].depositAddress), C = x.map((e) => e.amount), w = x.map((e) => e.depositAddress), T
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
})), S = m ?? await a(v, l, x[0].depositAddress), C = x.map((e) => e.amount), w = x.map((e) => e.depositAddress), T = {
|
|
37
|
+
chainId: f.destinationChainId === v ? void 0 : f.destinationChainId,
|
|
38
|
+
tokenAddress: f.destinationTokenAddress,
|
|
39
|
+
tokenAmounts: x.map((e) => e.quote.amountOut)
|
|
40
|
+
}, E;
|
|
41
|
+
return e(v) ? {depositTxHash: E} = await s(c, l, C, w, p, S, h, g, _, x.map((e) => e.destinationRecipient), T) : {depositTxHash: E} = await o(c, l, C, w, p, S, h, g, _, void 0, T), {
|
|
42
|
+
depositTxHash: E,
|
|
39
43
|
legs: x
|
|
40
44
|
};
|
|
41
45
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../functions/utils/caseInsensitive.utils.cjs`),n=require(`../../error-handling/error-codes.constants.cjs`),
|
|
1
|
+
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../functions/utils/caseInsensitive.utils.cjs`),n=require(`../../crypto/poseidon.cjs`),r=require(`../../error-handling/error-codes.constants.cjs`),i=require(`../../functions/web3/etherFunctions.cjs`),a=require(`../../functions/utils/addresses.cjs`),o=require(`../../types/external-action.types.cjs`),s=require(`../../types/admin.types.cjs`),c=require(`../../types/transact.types.cjs`);require(`../../error-handling/index.cjs`);const l=require(`../../functions/pre-transaction/constructAdminData.cjs`),u=require(`../AccountActions/AccountActions.cjs`),d=require(`../../functions/pre-transaction/getFeeStructure.cjs`);require(`../../functions/pre-transaction/index.cjs`);const f=require(`../../functions/private-wallet/emporium.helpers.cjs`),p=require(`./hinkalTransact.cjs`),m=require(`../../functions/utils/involves-permit2-op.cjs`),h=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`),g=require(`../../functions/pre-transaction/merge-with-fee-structure.cjs`),_=require(`../../functions/pre-transaction/merge-with-fee-structure-emporium.cjs`),v=require(`./handleAutoDepositBack.cjs`);var y=async(y,b,x,S,C,w,T,E,D,O,k,A=!1,j,M,N)=>{if(N&&!a.isValidPrivateAddress(N.recipientInfo))throw Error(r.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);if(T.length>0&&!E)throw Error(`Subaccount is required for private wallet transactions`);let P=x.map(e=>e.erc20TokenAddress),F=await y.getEthereumAddressByChain(b),I=E?u.AccountActions.getAddressFromSubAccount(b,E):void 0,{contractData:L}=e.networkRegistry[b],{emporiumAddress:R}=L;if(!R)throw Error(`No Emporium Address Provided`);let z=O??await d.getFeeStructure(b,D,P,o.ExternalActionId.Emporium,w.map(e=>h.convertEmporiumOpToCallInfo(e,I??``,b)));for(I?await _.mergeWithFeeStructureEmporium(y,b,I,w,P,S,z,T.find(e=>t.caseInsensitiveEqual(e.token.erc20TokenAddress,z.feeToken))?.amount??0n):await g.mergeWithFeeStructure(b,P,S,z);C.length<P.length;)C.push(!1);let B=k??await y.getRandomRelay(b,!0);if(!B)throw Error(r.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let V=E?u.AccountActions.getPrivateKeyFromSubAccount(b,E):void 0,H=e.getOnchainChainId(b),U=V?u.AccountActions.getSignerAddressFromPrivateKey(H,V):void 0,W=i.randomBigInt(31),G=y.generateProofRemotely?await f.encodeEmporiumMetadata(b,R,V,w,n.poseidonFunction(W),U):void 0,K=await f.getAuthorizationDataIfNeeded(b,V),q=m.uniswapWorkaround(w),J=l.constructAdminData(M,b,T.map(e=>e.token.erc20TokenAddress),T.map(e=>e.amount),F,M===s.AdminTransactionType.PublicSwap?T.map(({token:e})=>e):void 0),Y,X=await p.hinkalTransact(y,{chainId:b,erc20Addresses:P,amountChanges:S,externalAddress:R,externalActionId:o.ExternalActionId.Emporium,externalActionMetadata:G,onChainCreation:C,feeStructure:z,relay:B,messageSeed:W,recipientAddress:N?[N.recipientInfo]:void 0,recipientAmounts:N?[P.map(e=>t.caseInsensitiveEqual(e,N.token.erc20TokenAddress)?N.amount:0n)]:void 0,subAccountPrivateKey:V,emporiumOps:w,onTxSubmitLocally:e=>{Y=e},submit:{mode:c.SubmitMode.Relayer,adminData:J,authorizationData:K,withUniswapWorkAround:q}});return A&&E&&v.handleAutoDepositBack(y,b,I,E,z.feeToken,j,T,Y),X};exports.hinkalPrivateWallet=y;
|