@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
|
@@ -5,102 +5,104 @@ import { getAmountInWei as i, randomBigInt as a } from "../../functions/web3/eth
|
|
|
5
5
|
import { UserKeys as o } from "../crypto-keys/keys.mjs";
|
|
6
6
|
import { waitLittle as s } from "../../functions/utils/time.utils.mjs";
|
|
7
7
|
import { hashEthereumAddress as c } from "../../functions/utils/addresses.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import { ExternalActionId as l } from "../../types/external-action.types.mjs";
|
|
9
|
+
import { TemporaryWalletRecoveryDestination as u } from "../../types/token.types.mjs";
|
|
10
|
+
import { API as d } from "../../API/API.mjs";
|
|
11
|
+
import { Logger as f } from "../../error-handling/logger.mjs";
|
|
12
12
|
import { getErc20TokenFromAPI as p } from "../../functions/utils/erc20tokenFunctions.mjs";
|
|
13
13
|
import { getFeeStructure as m } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
14
|
+
import { createLifiBridgeOps as h, createTransaferEmporiumOpsBatch as g } from "../../functions/private-wallet/emporium.helpers.mjs";
|
|
15
|
+
import { SWAP_ROUTER_ADDRESSES as _ } from "../../constants/addresses.constants.mjs";
|
|
16
|
+
import { BRIDGE_ARRIVAL_POLL_INTERVAL_MS as v, BRIDGE_ARRIVAL_TIMEOUT_MS as y, DEFAULT_BRIDGING_SLIPPAGE_DECIMAL as b, SLIPPAGE_SCALING_FACTOR as x } from "../../constants/bridging.constants.mjs";
|
|
17
|
+
import { RELAYER_TX_CONFIRMATION_TIMEOUT as S } from "../../constants/tx-confirmation.constants.mjs";
|
|
17
18
|
import "../../constants/index.mjs";
|
|
18
|
-
import {
|
|
19
|
-
import { getRecipientInfoFromUserKeys as S } from "../../functions/utils/getRecipientInfoFromUserKeys.mjs";
|
|
20
|
-
import { getPublicBalanceByTokenAddress as C } from "../../functions/utils/publicBalance.utils.mjs";
|
|
19
|
+
import { waitForEthereumTransactionConfirmation as C } from "../../functions/utils/tx-confirmation.utils.mjs";
|
|
21
20
|
import { getUtxosFromReceipt as w } from "../../functions/utils/getUtxosFromReceipt.utils.mjs";
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
21
|
+
import { getRecipientInfoFromUserKeys as T } from "../../functions/utils/getRecipientInfoFromUserKeys.mjs";
|
|
22
|
+
import { convertEmporiumOpToCallInfo as E } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
|
|
23
|
+
import { getPublicBalanceByTokenAddress as D } from "../../functions/utils/publicBalance.utils.mjs";
|
|
24
|
+
import { calculateModifiedFeeStructure as O, calculateTotalFee as k } from "../../functions/utils/fees.utils.mjs";
|
|
25
|
+
import { buildTempSubAccount as A, deriveTempWallet as j } from "../../functions/utils/temp-wallet.utils.mjs";
|
|
26
26
|
import { getLifiPrice as M } from "../../functions/web3/lifiAPI.mjs";
|
|
27
27
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalBridgePrivateToPrivate.ts
|
|
28
|
-
var N = async (e, r, o, s,
|
|
29
|
-
let { chainId:
|
|
30
|
-
if (!
|
|
31
|
-
let
|
|
32
|
-
calldata:
|
|
33
|
-
expectedAmount:
|
|
34
|
-
nativeFee:
|
|
35
|
-
},
|
|
36
|
-
await Promise.all([
|
|
37
|
-
let F = n(
|
|
28
|
+
var N = async (e, r, o, s, f, m, g) => {
|
|
29
|
+
let { chainId: v } = r, y = o.chainId, b = r.erc20TokenAddress, x = _[l.Lifi][v];
|
|
30
|
+
if (!x) throw Error(`LIFI not configured for chain ${v}`);
|
|
31
|
+
let S = a(6), { privateKey: C, ethAddress: w } = j(e, v, S), { lifiDataValue: T, outSwapAmountValue: E, extraNativeTokenFee: D } = await M(r, o, s, f, w, w), O = {
|
|
32
|
+
calldata: T,
|
|
33
|
+
expectedAmount: E,
|
|
34
|
+
nativeFee: D
|
|
35
|
+
}, k = i(r, s), N = A(S, C, w), P = c(await e.getEthereumAddressByChain(v));
|
|
36
|
+
await Promise.all([d.addTemporaryWalletNonce(v, P, Number(S), u.Confidential), d.addTemporaryWalletNonce(y, P, Number(S), u.Confidential)]);
|
|
37
|
+
let F = n(b, t), I = O.nativeFee > 0n && !F, L = F ? k + O.nativeFee : k, R = [r], z = [-L];
|
|
38
38
|
if (I) {
|
|
39
|
-
let e = await p(
|
|
39
|
+
let e = await p(v, t);
|
|
40
40
|
if (!e) throw Error("Native token not found for bridge fee");
|
|
41
|
-
R.push(e), z.push(-
|
|
41
|
+
R.push(e), z.push(-O.nativeFee);
|
|
42
42
|
}
|
|
43
|
-
let B =
|
|
43
|
+
let B = h(e, v, w, x, b, L, k, O), V = R.map((e, t) => ({
|
|
44
44
|
token: e,
|
|
45
45
|
amount: z[t]
|
|
46
46
|
}));
|
|
47
47
|
return {
|
|
48
|
-
nonce:
|
|
48
|
+
nonce: S,
|
|
49
49
|
tempSubAccount: N,
|
|
50
|
-
sourceTxHash: await e.actionPrivateWallet(
|
|
51
|
-
quote:
|
|
50
|
+
sourceTxHash: await e.actionPrivateWallet(v, R, z, z.map(() => !1), B, V, N, m ?? b, void 0, void 0, !1, void 0, g, void 0),
|
|
51
|
+
quote: O
|
|
52
52
|
};
|
|
53
53
|
}, P = async (e, t, n, r, i) => {
|
|
54
|
-
let a = BigInt(Math.round(i *
|
|
54
|
+
let a = BigInt(Math.round(i * x)), o = r.expectedAmount - r.expectedAmount * a / BigInt(x), c = o > 0n ? o : 1n, l = Date.now() + y;
|
|
55
55
|
for (; Date.now() < l;) {
|
|
56
|
-
let r = await
|
|
56
|
+
let r = await D(e, t, n);
|
|
57
57
|
if (r !== null && r >= c) return r;
|
|
58
|
-
await s(
|
|
58
|
+
await s(v);
|
|
59
59
|
}
|
|
60
60
|
throw Error(`Bridge did not land on destination temp wallet ${t} on chain ${e} within timeout.`);
|
|
61
61
|
}, F = async (t, n, i, a, s, c) => {
|
|
62
|
-
let
|
|
62
|
+
let u = n.chainId, d = n.erc20TokenAddress, f = i.ethAddress;
|
|
63
63
|
if (!f) throw Error("Missing temp wallet address for bridge shield");
|
|
64
|
-
let p =
|
|
65
|
-
if (
|
|
66
|
-
let
|
|
67
|
-
if ("recipientInfo" in s)
|
|
64
|
+
let p = g(t, u, [d], [a]), h = await O(u, n, a, await m(u, d, [d], l.Emporium, p.map((e) => E(e, f, u)), e)), _ = a - k(a, h);
|
|
65
|
+
if (_ <= 0n) throw Error(r.INSUFFICIENT_FUNDS_TO_TRANSACT);
|
|
66
|
+
let v, y;
|
|
67
|
+
if ("recipientInfo" in s) v = s.recipientInfo;
|
|
68
68
|
else {
|
|
69
69
|
let e = t.userKeys.getClaimableSignatureFromNonce(s.claimableNonce), n = new o(e);
|
|
70
|
-
|
|
70
|
+
y = {
|
|
71
71
|
signature: e,
|
|
72
72
|
keys: n,
|
|
73
73
|
ethAddress: s.recipientEthAddress
|
|
74
|
-
},
|
|
74
|
+
}, v = T(n);
|
|
75
75
|
}
|
|
76
|
-
let
|
|
77
|
-
if (
|
|
78
|
-
let e = await
|
|
79
|
-
if (!e) throw Error(`Could not fetch receipt for bridge shield tx ${
|
|
80
|
-
let [n] = w(e, t,
|
|
76
|
+
let b = await t.proxyToPrivate([n], [_], i, v, h.feeToken, h, c), x;
|
|
77
|
+
if (y) {
|
|
78
|
+
let e = await C(u, b, { evmTimeoutMs: S });
|
|
79
|
+
if (!e) throw Error(`Could not fetch receipt for bridge shield tx ${b}`);
|
|
80
|
+
let [n] = w(e, t, u, d, y.keys.getShieldedPrivateKey());
|
|
81
81
|
if (!n) throw Error("Could not find recipient UTXO in bridge shield tx");
|
|
82
|
-
|
|
83
|
-
chainId:
|
|
84
|
-
senderAddress: await t.getEthereumAddressByChain(
|
|
85
|
-
recipientAddress:
|
|
86
|
-
claimableSignature:
|
|
82
|
+
x = {
|
|
83
|
+
chainId: u,
|
|
84
|
+
senderAddress: await t.getEthereumAddressByChain(u),
|
|
85
|
+
recipientAddress: y.ethAddress,
|
|
86
|
+
claimableSignature: y.signature,
|
|
87
87
|
utxo: n
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
90
|
return {
|
|
91
|
-
destTxHash:
|
|
92
|
-
pendingEnclaveUtxo:
|
|
91
|
+
destTxHash: b,
|
|
92
|
+
pendingEnclaveUtxo: x,
|
|
93
|
+
shieldedAmount: _
|
|
93
94
|
};
|
|
94
|
-
}, I = async (e, t, n, r, i, a =
|
|
95
|
-
let { nonce:
|
|
95
|
+
}, I = async (e, t, n, r, i, a = b, o, s) => {
|
|
96
|
+
let { nonce: l, tempSubAccount: u, sourceTxHash: p, quote: m } = await N(e, t, n, r, a, o, s), h = u.ethAddress;
|
|
96
97
|
if (!h) throw Error("Missing temp wallet address for bridge");
|
|
97
|
-
let { destTxHash: g, pendingEnclaveUtxo: _ } = await F(e, n,
|
|
98
|
-
return (await Promise.allSettled(
|
|
99
|
-
e.status === "rejected" &&
|
|
98
|
+
let { destTxHash: g, pendingEnclaveUtxo: _, shieldedAmount: v } = await F(e, n, u, await P(n.chainId, h, n.erc20TokenAddress, m, a), i, s), y = c(await e.getEthereumAddressByChain(n.chainId)), x = [t.chainId, n.chainId];
|
|
99
|
+
return (await Promise.allSettled(x.map((e) => d.removeTemporaryWalletNonce(e, y, Number(l))))).forEach((e, t) => {
|
|
100
|
+
e.status === "rejected" && f.error(`Failed to remove temp-wallet nonce on chain ${x[t]}`, e.reason);
|
|
100
101
|
}), {
|
|
101
102
|
sourceTxHash: p,
|
|
102
103
|
destTxHash: g,
|
|
103
|
-
pendingEnclaveUtxo: _
|
|
104
|
+
pendingEnclaveUtxo: _,
|
|
105
|
+
destinationTokenAmount: v.toString()
|
|
104
106
|
};
|
|
105
107
|
};
|
|
106
108
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../constants/
|
|
1
|
+
const e=require(`../../constants/protocol.constants.cjs`),t=require(`../../functions/utils/caseInsensitive.utils.cjs`),n=require(`../../error-handling/error-codes.constants.cjs`),r=require(`../crypto-keys/keys.cjs`),i=require(`../utxo/Utxo.cjs`),a=require(`../../types/external-action.types.cjs`),o=require(`../../types/transact.types.cjs`),s=require(`../../functions/utils/token-check.utils.cjs`),c=require(`../../functions/pre-transaction/getFeeStructure.cjs`),l=require(`./hinkalTransact.cjs`);var u=async(u,d,f,p,m)=>{let h=s.validateAndGetChainId([d]),g=d.erc20TokenAddress;if(!t.caseInsensitiveEqual(g,f.erc20TokenAddress))throw Error(`Off-chain UTXO token mismatch`);let _=m?new r.UserKeys(m):new r.UserKeys(f.nullifyingKey,f.nullifyingKey);if(!f.nullifyingKey&&!m)throw Error(`Claimable UTXO nullifyingKey is missing`);let v=_.getShieldedPrivateKey();if(f.nullifyingKey&&f.nullifyingKey!==v)throw Error(`Claimable UTXO key mismatch`);let y=u.getRecipientInfo(),b=i.Utxo.createFrom(f,{nullifyingKey:v}),x=p??await c.getFeeStructure(h,g,[g],a.ExternalActionId.Transact);if(!t.caseInsensitiveEqual(x.feeToken,g))throw Error(`Claim fee token mismatch: fee must be paid from claimed UTXO token`);let S=x.variableRate>0n?x.variableRate:e.HINKAL_PRIVATE_SEND_VARIABLE_RATE;if(b.amount<=x.flatFee)throw Error(n.transactionErrorCodes.INSUFFICIENT_FUNDS_TO_TRANSACT);let C=b.amount-x.flatFee,w=C*S/10000n,T=C-w;if(T<=0n)throw Error(n.transactionErrorCodes.RECIPIENT_AMOUNT_INVALID);let E={feeToken:x.feeToken,flatFee:x.flatFee+w,variableRate:0n},D=[-b.amount],O=await u.getRandomRelay(h,!0);if(!O)throw Error(n.transactionErrorCodes.RELAYER_NOT_AVAILABLE);return l.hinkalTransact(u,{chainId:h,erc20Addresses:[g],amountChanges:D,externalAddress:O,feeStructure:E,relay:O,recipientAddress:[y],recipientAmounts:[[T]],inputUtxos:[[b]],userKeys:_,submit:{mode:o.SubmitMode.Relayer}})};exports.hinkalClaimUtxo=u;
|
|
@@ -1,51 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { outputUtxoProcessing as d } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
12
|
-
import { getFeeStructure as f } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
13
|
-
import { constructZkProof as p } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
14
|
-
import { transactCallRelayer as m } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
1
|
+
import { HINKAL_PRIVATE_SEND_VARIABLE_RATE as e } from "../../constants/protocol.constants.mjs";
|
|
2
|
+
import { caseInsensitiveEqual as t } from "../../functions/utils/caseInsensitive.utils.mjs";
|
|
3
|
+
import { transactionErrorCodes as n } from "../../error-handling/error-codes.constants.mjs";
|
|
4
|
+
import { UserKeys as r } from "../crypto-keys/keys.mjs";
|
|
5
|
+
import { Utxo as i } from "../utxo/Utxo.mjs";
|
|
6
|
+
import { ExternalActionId as a } from "../../types/external-action.types.mjs";
|
|
7
|
+
import { SubmitMode as o } from "../../types/transact.types.mjs";
|
|
8
|
+
import { validateAndGetChainId as s } from "../../functions/utils/token-check.utils.mjs";
|
|
9
|
+
import { getFeeStructure as c } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
10
|
+
import { hinkalTransact as l } from "./hinkalTransact.mjs";
|
|
15
11
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalClaimUtxo.ts
|
|
16
|
-
var
|
|
17
|
-
let
|
|
18
|
-
if (!
|
|
19
|
-
let
|
|
20
|
-
if (!
|
|
21
|
-
let
|
|
22
|
-
if (
|
|
23
|
-
let
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (D.amount <= k.flatFee) throw Error(r.INSUFFICIENT_FUNDS_TO_TRANSACT);
|
|
33
|
-
let j = D.amount - k.flatFee, M = j * A / 10000n, N = j - M;
|
|
34
|
-
if (N <= 0n) throw Error(r.RECIPIENT_AMOUNT_INVALID);
|
|
35
|
-
let P = {
|
|
36
|
-
feeToken: k.feeToken,
|
|
37
|
-
flatFee: k.flatFee + M,
|
|
12
|
+
var u = async (u, d, f, p, m) => {
|
|
13
|
+
let h = s([d]), g = d.erc20TokenAddress;
|
|
14
|
+
if (!t(g, f.erc20TokenAddress)) throw Error("Off-chain UTXO token mismatch");
|
|
15
|
+
let _ = m ? new r(m) : new r(f.nullifyingKey, f.nullifyingKey);
|
|
16
|
+
if (!f.nullifyingKey && !m) throw Error("Claimable UTXO nullifyingKey is missing");
|
|
17
|
+
let v = _.getShieldedPrivateKey();
|
|
18
|
+
if (f.nullifyingKey && f.nullifyingKey !== v) throw Error("Claimable UTXO key mismatch");
|
|
19
|
+
let y = u.getRecipientInfo(), b = i.createFrom(f, { nullifyingKey: v }), x = p ?? await c(h, g, [g], a.Transact);
|
|
20
|
+
if (!t(x.feeToken, g)) throw Error("Claim fee token mismatch: fee must be paid from claimed UTXO token");
|
|
21
|
+
let S = x.variableRate > 0n ? x.variableRate : e;
|
|
22
|
+
if (b.amount <= x.flatFee) throw Error(n.INSUFFICIENT_FUNDS_TO_TRANSACT);
|
|
23
|
+
let C = b.amount - x.flatFee, w = C * S / 10000n, T = C - w;
|
|
24
|
+
if (T <= 0n) throw Error(n.RECIPIENT_AMOUNT_INVALID);
|
|
25
|
+
let E = {
|
|
26
|
+
feeToken: x.feeToken,
|
|
27
|
+
flatFee: x.flatFee + w,
|
|
38
28
|
variableRate: 0n
|
|
39
|
-
},
|
|
40
|
-
if (!
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
29
|
+
}, D = [-b.amount], O = await u.getRandomRelay(h, !0);
|
|
30
|
+
if (!O) throw Error(n.RELAYER_NOT_AVAILABLE);
|
|
31
|
+
return l(u, {
|
|
32
|
+
chainId: h,
|
|
33
|
+
erc20Addresses: [g],
|
|
34
|
+
amountChanges: D,
|
|
35
|
+
externalAddress: O,
|
|
36
|
+
feeStructure: E,
|
|
37
|
+
relay: O,
|
|
38
|
+
recipientAddress: [y],
|
|
39
|
+
recipientAmounts: [[T]],
|
|
40
|
+
inputUtxos: [[b]],
|
|
41
|
+
userKeys: _,
|
|
42
|
+
submit: { mode: o.Relayer }
|
|
43
|
+
});
|
|
49
44
|
};
|
|
50
45
|
//#endregion
|
|
51
|
-
export {
|
|
46
|
+
export { u as hinkalClaimUtxo };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../
|
|
1
|
+
const e=require(`../../error-handling/error-codes.constants.cjs`),t=require(`../../functions/utils/addresses.cjs`),n=require(`../../functions/utils/tron.utils.cjs`),r=require(`../../types/transact.types.cjs`),i=require(`../../functions/utils/token-check.utils.cjs`),a=require(`../../functions/pre-transaction/constructAdminData.cjs`),o=require(`./hinkalTransact.cjs`),s=require(`../../API/admin-calls.cjs`);var c=async(e,t,a,s=!0,c=!1)=>{let l=i.validateAndGetChainId(t);return o.hinkalTransact(e,{chainId:l,erc20Addresses:t.map(e=>e.erc20TokenAddress),amountChanges:a,externalAddress:n.addressToHexFormat(await e.getEthereumAddressByChain(l)),submit:{mode:r.SubmitMode.Self,erc20Tokens:t,approvalAmounts:a,preEstimateGas:s,returnTxData:c}})},l=async(c,l,u,d,f=!0,p=!1,m)=>{if(d.length===0)throw Error(`recipientInfos must not be empty`);if(u.length!==d.length)throw Error(`amountsByRecipient must have one entry per recipientInfo`);let h=i.validateAndGetChainId(l),g=l.map(e=>e.erc20TokenAddress);d.forEach((n,r)=>{if(!t.isValidPrivateAddress(n))throw Error(e.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);if(u[r].length!==g.length)throw Error(`Each amountsByRecipient entry must have one amount per erc20Token`)});let _=g.map((e,t)=>u.reduce((e,n)=>e+n[t],0n)),v=n.addressToHexFormat(await c.getEthereumAddressByChain(h)),y=await o.hinkalTransact(c,{chainId:h,erc20Addresses:g,amountChanges:_.map(()=>0n),externalAddress:v,recipientAddress:d,recipientAmounts:u,forceEmptyUtxos:!0,submit:{mode:r.SubmitMode.Self,erc20Tokens:l,approvalAmounts:_,preEstimateGas:f,returnTxData:p}});return s.emitTxPublicData(a.constructAdminData(m,h,g,_,await c.getEthereumAddress())),y},u=async(e,t,n,r,i=!0,a=!1,o)=>l(e,t,[n],[r],i,a,o);exports.hinkalDeposit=c,exports.hinkalDepositForOther=u;
|
|
@@ -3,4 +3,5 @@ import { Types as TronWebTypes } from 'tronweb';
|
|
|
3
3
|
import { IHinkal } from './IHinkal';
|
|
4
4
|
import { AdminTransactionType, ERC20Token } from '../../types';
|
|
5
5
|
export declare const hinkalDeposit: (hinkal: IHinkal, erc20Tokens: ERC20Token[], amountChanges: bigint[], preEstimateGas?: boolean, returnTxData?: boolean) => Promise<ethers.TransactionResponse | ethers.TransactionRequest | string | TronWebTypes.Transaction<TronWebTypes.TriggerSmartContract>>;
|
|
6
|
+
export declare const hinkalDepositForOthers: (hinkal: IHinkal, erc20Tokens: ERC20Token[], amountsByRecipient: bigint[][], recipientInfos: string[], preEstimateGas?: boolean, returnTxData?: boolean, action?: AdminTransactionType) => Promise<ethers.TransactionResponse | ethers.TransactionRequest | string | TronWebTypes.Transaction<TronWebTypes.TriggerSmartContract>>;
|
|
6
7
|
export declare const hinkalDepositForOther: (hinkal: IHinkal, erc20Tokens: ERC20Token[], amountChanges: bigint[], recipientInfo: string, preEstimateGas?: boolean, returnTxData?: boolean, action?: AdminTransactionType) => Promise<ethers.TransactionResponse | ethers.TransactionRequest | string | TronWebTypes.Transaction<TronWebTypes.TriggerSmartContract>>;
|
|
@@ -1,118 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { validateAndGetChainId as v } from "../../functions/utils/token-check.utils.mjs";
|
|
10
|
-
import { addPaddingToUtxos as y } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
11
|
-
import { outputUtxoProcessing as b } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
12
|
-
import { constructAdminData as x } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
13
|
-
import { simulateTronTransaction as S } from "../../functions/utils/tronSimulation.utils.mjs";
|
|
14
|
-
import { constructZkProof as C } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
15
|
-
import { waitForTronErc20Approvals as w } from "../../functions/web3/functionCalls/waitForErc20Approvals.mjs";
|
|
16
|
-
import { transactCallDirect as T } from "../../functions/web3/functionCalls/transactCallDirect.mjs";
|
|
17
|
-
import { emitTxPublicData as E } from "../../API/admin-calls.mjs";
|
|
1
|
+
import { transactionErrorCodes as e } from "../../error-handling/error-codes.constants.mjs";
|
|
2
|
+
import { isValidPrivateAddress as t } from "../../functions/utils/addresses.mjs";
|
|
3
|
+
import { addressToHexFormat as n } from "../../functions/utils/tron.utils.mjs";
|
|
4
|
+
import { SubmitMode as r } from "../../types/transact.types.mjs";
|
|
5
|
+
import { validateAndGetChainId as i } from "../../functions/utils/token-check.utils.mjs";
|
|
6
|
+
import { constructAdminData as a } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
7
|
+
import { hinkalTransact as o } from "./hinkalTransact.mjs";
|
|
8
|
+
import { emitTxPublicData as s } from "../../API/admin-calls.mjs";
|
|
18
9
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalDeposit.ts
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
let
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
feeLimit: n,
|
|
61
|
-
callValue: F,
|
|
62
|
-
input: e
|
|
63
|
-
}, [], T);
|
|
64
|
-
return t;
|
|
65
|
-
}
|
|
66
|
-
await u(y, T, C, D), D.size > 0 && await w(y, T, C, Array.from(D.entries()).map(([e, t]) => ({
|
|
67
|
-
tokenAddress: e,
|
|
68
|
-
requiredAmount: t
|
|
69
|
-
}))), l && (await S(r, C, "transact", x, [
|
|
70
|
-
M,
|
|
71
|
-
O,
|
|
72
|
-
k,
|
|
73
|
-
A,
|
|
74
|
-
N,
|
|
75
|
-
P
|
|
76
|
-
], T, E > 0n ? E : void 0), await d(y, r, C, T, p(x, "transact", [
|
|
77
|
-
M,
|
|
78
|
-
O,
|
|
79
|
-
k,
|
|
80
|
-
A,
|
|
81
|
-
N,
|
|
82
|
-
P
|
|
83
|
-
]), E));
|
|
84
|
-
let I = await y.contract(x, C).transact(M, O, k, A, N, P).send({
|
|
85
|
-
feeLimit: n,
|
|
86
|
-
callValue: F
|
|
87
|
-
}), L = typeof I == "string" ? I : I?.txid ?? I?.transaction?.txID;
|
|
88
|
-
if (!L) throw Error("Tron deposit failed (missing txid)");
|
|
89
|
-
return L;
|
|
90
|
-
}, A = async (t, n, a, o = !0, s = !1) => {
|
|
91
|
-
let c = v(n), l = e(c), u = n.map((e) => e.erc20TokenAddress), [{ externalActionData: d, contractTransaction: f, contractToApprove: p }, { inputUtxosArray: m, outputUtxosArray: h }] = await Promise.all([D(t, c), O(t, c, u, a)]), { zkCallData: g, circomData: _, dimData: y } = await C(t.merkleTreeHinkalByChain[c], m, h, t.userKeys, d.externalActionId, d.externalAddress, d.externalActionMetadata, t.generateProofRemotely, i, r, c);
|
|
92
|
-
return l ? await k(t, c, n, a, g, _, y, o, s) : await T(t, c, a, n, g, _, y, p, f, o, s);
|
|
93
|
-
}, j = async (t, n, o, l, u = !0, d = !1, f) => {
|
|
94
|
-
let p = v(n), m = e(p), h = n.map((e) => e.erc20TokenAddress), [g, _, y, , , b] = l.split(",");
|
|
95
|
-
if (!c(l)) throw Error(a.RECIPIENT_FORMAT_INCORRECT);
|
|
96
|
-
let S = h.map((e) => [new s({
|
|
97
|
-
amount: 0n,
|
|
98
|
-
erc20TokenAddress: e,
|
|
99
|
-
nullifyingKey: t.userKeys.getShieldedPrivateKey(),
|
|
100
|
-
spendingPublicKey: t.userKeys.getSpendingKeyPair().pubSpendingBJJPoint
|
|
101
|
-
}), new s({
|
|
102
|
-
amount: 0n,
|
|
103
|
-
erc20TokenAddress: e,
|
|
104
|
-
nullifyingKey: t.userKeys.getShieldedPrivateKey(),
|
|
105
|
-
spendingPublicKey: t.userKeys.getSpendingKeyPair().pubSpendingBJJPoint
|
|
106
|
-
})]), w = h.map((e, t) => [new s({
|
|
107
|
-
amount: o[t],
|
|
108
|
-
erc20TokenAddress: e,
|
|
109
|
-
H0: [BigInt(_), BigInt(y)],
|
|
110
|
-
stealthAddress: g,
|
|
111
|
-
encryptionKey: b
|
|
112
|
-
})]), { externalActionData: O, contractTransaction: A, contractToApprove: j } = await D(t, p), { zkCallData: M, circomData: N, dimData: P } = await C(t.merkleTreeHinkalByChain[p], S, w, t.userKeys, O.externalActionId, O.externalAddress, O.externalActionMetadata, t.generateProofRemotely, i, r, p);
|
|
113
|
-
if (m) return await k(t, p, n, o, M, N, P, u, d);
|
|
114
|
-
let F = await T(t, p, o, n, M, N, P, j, A, u, d);
|
|
115
|
-
return E(x(f, p, h, o, await t.getEthereumAddress())), F;
|
|
116
|
-
};
|
|
10
|
+
var c = async (e, t, a, s = !0, c = !1) => {
|
|
11
|
+
let l = i(t);
|
|
12
|
+
return o(e, {
|
|
13
|
+
chainId: l,
|
|
14
|
+
erc20Addresses: t.map((e) => e.erc20TokenAddress),
|
|
15
|
+
amountChanges: a,
|
|
16
|
+
externalAddress: n(await e.getEthereumAddressByChain(l)),
|
|
17
|
+
submit: {
|
|
18
|
+
mode: r.Self,
|
|
19
|
+
erc20Tokens: t,
|
|
20
|
+
approvalAmounts: a,
|
|
21
|
+
preEstimateGas: s,
|
|
22
|
+
returnTxData: c
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}, l = async (c, l, u, d, f = !0, p = !1, m) => {
|
|
26
|
+
if (d.length === 0) throw Error("recipientInfos must not be empty");
|
|
27
|
+
if (u.length !== d.length) throw Error("amountsByRecipient must have one entry per recipientInfo");
|
|
28
|
+
let h = i(l), g = l.map((e) => e.erc20TokenAddress);
|
|
29
|
+
d.forEach((n, r) => {
|
|
30
|
+
if (!t(n)) throw Error(e.RECIPIENT_FORMAT_INCORRECT);
|
|
31
|
+
if (u[r].length !== g.length) throw Error("Each amountsByRecipient entry must have one amount per erc20Token");
|
|
32
|
+
});
|
|
33
|
+
let _ = g.map((e, t) => u.reduce((e, n) => e + n[t], 0n)), v = n(await c.getEthereumAddressByChain(h)), y = await o(c, {
|
|
34
|
+
chainId: h,
|
|
35
|
+
erc20Addresses: g,
|
|
36
|
+
amountChanges: _.map(() => 0n),
|
|
37
|
+
externalAddress: v,
|
|
38
|
+
recipientAddress: d,
|
|
39
|
+
recipientAmounts: u,
|
|
40
|
+
forceEmptyUtxos: !0,
|
|
41
|
+
submit: {
|
|
42
|
+
mode: r.Self,
|
|
43
|
+
erc20Tokens: l,
|
|
44
|
+
approvalAmounts: _,
|
|
45
|
+
preEstimateGas: f,
|
|
46
|
+
returnTxData: p
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return s(a(m, h, g, _, await c.getEthereumAddress())), y;
|
|
50
|
+
}, u = async (e, t, n, r, i = !0, a = !1, o) => l(e, t, [n], [r], i, a, o);
|
|
117
51
|
//#endregion
|
|
118
|
-
export {
|
|
52
|
+
export { c as hinkalDeposit, u as hinkalDepositForOther };
|
|
@@ -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(`../../
|
|
1
|
+
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../functions/utils/caseInsensitive.utils.cjs`),r=require(`../../crypto/poseidon.cjs`),i=require(`../../error-handling/error-codes.constants.cjs`),a=require(`../../functions/web3/etherFunctions.cjs`),o=require(`../../functions/utils/addresses.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(`../../API/API.cjs`),d=require(`../../functions/utils/token-check.utils.cjs`),f=require(`../../functions/utils/erc20tokenFunctions.cjs`),p=require(`../../functions/pre-transaction/constructAdminData.cjs`),m=require(`../AccountActions/AccountActions.cjs`),h=require(`../../functions/pre-transaction/getFeeStructure.cjs`),g=require(`../../functions/pre-transaction/waitForDepositedUtxosInMerkleTree.cjs`),_=require(`../../functions/private-wallet/emporium.helpers.cjs`),v=require(`../../functions/web3/functionCalls/transactCallRelayer.cjs`),y=require(`./hinkalTransact.cjs`),b=require(`../../constants/addresses.constants.cjs`),x=require(`../../API/deposit-and-withdraw-status-calls.cjs`),S=require(`./hinkalDepositOnChainUtxos.cjs`),C=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`),w=require(`../../functions/utils/fees.utils.cjs`);require(`../../functions/utils/index.cjs`),require(`../../functions/index.cjs`);var T=async(o,d,f,h,g,S,C,w,T,E,D)=>{if(h.length===0)throw Error(`No recipients to bridge`);let O=f.erc20TokenAddress,{contractData:k}=e.networkRegistry[d],{emporiumAddress:A}=k;if(!A)throw Error(`No Emporium Address`);let j=b.SWAP_ROUTER_ADDRESSES[s.ExternalActionId.Lifi][d];if(!j)throw Error(`LIFI not configured for chain ${d}`);let M=await o.getRandomRelay(d);if(!M)throw Error(i.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let N=await o.getEthereumAddressByChain(d),P=o.generateProofRemotely,F=P?5:1,I=[];for(let i=0;i<h.length;i+=F){let c=h.slice(i,i+F),f=await Promise.all(c.map(async({utxo:i,nativeUtxo:c,bridgeAmount:f,quote:h,temporarySubAccount:v,recipientAddress:b,destinationChainId:x,destinationTokenAddress:C})=>{await u.API.addTemporaryWalletNonce(d,S,v.index);let w=n.caseInsensitiveEqual(O,t.zeroAddress),T=h.nativeFee>0n&&!w,D=[O],k=[-i.amount],F=[!1],I=[[i]];T&&c&&(D.push(t.zeroAddress),k.push(-c.amount),F.push(!1),I.push([c]));let L=_.createLifiBridgeOps(o,d,v.ethAddress,j,O,i.amount,f,h),R=p.constructAdminData(E,d,D,[-i.amount],N),[z,B]=await Promise.all([(async()=>{let n=a.randomBigInt(31),i=P?await _.encodeEmporiumMetadata(d,A,v.privateKey,L,r.poseidonFunction(n),m.AccountActions.getSignerAddressFromPrivateKey(e.getOnchainChainId(d),v.privateKey)):void 0;return y.hinkalTransact(o,{chainId:d,erc20Addresses:D,amountChanges:k,externalAddress:A,externalActionId:s.ExternalActionId.Emporium,externalActionMetadata:i,onChainCreation:F,feeStructure:g,relay:M??t.zeroAddress,messageSeed:n,inputUtxos:I,useBlockedUtxos:!0,subAccountPrivateKey:v.privateKey,emporiumOps:L,submit:{mode:l.SubmitMode.ProofOnly}})})(),_.getAuthorizationDataIfNeeded(d,v.privateKey)]),{zkCallData:V,circomData:H,dimData:U,commitmentValidationData:W,tronProofSignature:G}=z;return{zkCallData:V,dimData:U,circomData:H,commitmentValidationData:W,authorizationData:B,recipientAddress:b,adminData:R,tronProofSignature:G,destinationChainId:x,destinationTokenAddress:C,destinationTokenAmount:h.expectedAmount.toString()}}));I.push(...f)}await x.safeUpdateDepositAndWithdrawStatus({id:C,chainId:d,hashedEthereumAddress:S,phase:c.DepositAndWithdrawPhase.BEFORE_SCHEDULE_WITHDRAW});let L=await v.transactCallRelayerBatch(d,I,S,w,T,D);return await x.safeUpdateDepositAndWithdrawStatus({id:C,chainId:d,hashedEthereumAddress:S,phase:c.DepositAndWithdrawPhase.AFTER_SCHEDULE_WITHDRAW,scheduleId:L}),L},E=async(e,r,i,a,c,l,u,p,m=!0)=>{let v=r.erc20TokenAddress,y=d.validateAndGetChainId([r]),x=p?o.hashString(p):void 0,E=o.hashEthereumAddress(await e.getEthereumAddressByChain(y)),D=b.SWAP_ROUTER_ADDRESSES[s.ExternalActionId.Lifi][y];if(!D)throw Error(`LIFI router not configured`);let O,k=n.caseInsensitiveEqual(v,t.zeroAddress);if(c)O=c;else{let n=i[0],r=k?n.bridgeAmount+n.quote.nativeFee:n.bridgeAmount,a=_.createLifiBridgeOps(e,y,n.temporarySubAccount.ethAddress,D,v,r,n.bridgeAmount,n.quote).map(e=>C.convertEmporiumOpToCallInfo(e,n.temporarySubAccount.ethAddress,y));O=await h.getFeeStructure(y,v,[v],s.ExternalActionId.Emporium,a,t.PAY_SEND_VARIABLE_RATE)}let A={feeToken:O.feeToken,flatFee:0n,variableRate:0n},j=i.reduce((e,t)=>e+t.quote.nativeFee,0n)>0n&&!n.caseInsensitiveEqual(v,t.zeroAddress),M=i.map(e=>w.calculateGrossAmountWithFee(k?e.bridgeAmount+e.quote.nativeFee:e.bridgeAmount,O)),N=i.map(e=>e.recipientAddress),{userDepositedUtxos:P,statusId:F,depositTxHash:I}=await S.hinkalDepositOnChainUtxos(e,y,r,M,N,A,E,m),L=[];if(j){let n=await f.getErc20TokenFromAPI(y,t.zeroAddress);if(!n)throw Error(`No native token`);let{userDepositedUtxos:r}=await S.hinkalDepositOnChainUtxos(e,y,n,i.map(e=>w.calculateGrossAmountWithFee(e.quote.nativeFee,{feeToken:O.feeToken,flatFee:0n,variableRate:O.variableRate})),N,A,E,m);L=r}return await g.waitForDepositedUtxosInMerkleTree(e,y,[...P,...L]),{depositTxHash:I,scheduleId:await T(e,y,r,i.map((e,t)=>({...e,utxo:P[t].utxo,nativeUtxo:j?L[t]?.utxo:void 0})),O,E,F,a,l,u,x)}};exports.hinkalDepositAndBridge=E;
|