@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
|
@@ -11,71 +11,80 @@ import { ExternalActionId as u } from "../../types/external-action.types.mjs";
|
|
|
11
11
|
import { DepositAndWithdrawPhase as d } from "../../types/scheduled-transactions.types.mjs";
|
|
12
12
|
import "../../types/index.mjs";
|
|
13
13
|
import { validateAndGetChainId as f } from "../../functions/utils/token-check.utils.mjs";
|
|
14
|
-
import {
|
|
15
|
-
import { buildAnchorStealthAddressStructure as
|
|
14
|
+
import { calcStealthAddressStructure as p } from "../../functions/snarkjs/common.snarkjs.mjs";
|
|
15
|
+
import { buildAnchorStealthAddressStructure as m, getMerkleAccountPublicKey as h, getStorageAccountPublicKey as g, getStorageVaultPublicKey as _, resolveSolanaRootBuckets as v } from "../../functions/pre-transaction/solana.mjs";
|
|
16
16
|
import { constructAdminData as y } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
17
|
+
import { finalizeSolanaTxEnclaveCall as b, prepareSolanaTxEnclaveCall as x } from "../../functions/snarkjs/constructTxEnclave.mjs";
|
|
18
|
+
import { fetchSolanaTransaction as S } from "../../functions/pre-transaction/sendV0Transaction.mjs";
|
|
19
|
+
import { getFeeStructure as C } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
20
|
+
import { waitForDepositedUtxosInMerkleTree as w } from "../../functions/pre-transaction/waitForDepositedUtxosInMerkleTree.mjs";
|
|
20
21
|
import "../../functions/pre-transaction/index.mjs";
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
22
|
+
import { solanaTransactCallRelayerBatch as T } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
23
|
+
import { buildProoflessEncryptedOutputs as E } from "./hinkalProoflessDeposit.utils.mjs";
|
|
24
|
+
import { safeUpdateDepositAndWithdrawStatus as D, updateDepositAndWithdrawStatus as O } from "../../API/deposit-and-withdraw-status-calls.mjs";
|
|
25
|
+
import { getOnChainUtxosFromReceiptSolana as k } from "../../functions/utils/getUtxosFromReceiptSolana.mjs";
|
|
26
|
+
import { calculateModifiedFeeStructure as A, calculateTotalFee as j } from "../../functions/utils/fees.utils.mjs";
|
|
23
27
|
import "../../functions/web3/index.mjs";
|
|
24
|
-
import { constructSolanaZkProof as
|
|
25
|
-
import { solanaTransactCallRelayerBatch as D } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
26
|
-
import { safeUpdateDepositAndWithdrawStatus as O, updateDepositAndWithdrawStatus as k } from "../../API/deposit-and-withdraw-status-calls.mjs";
|
|
28
|
+
import { constructSolanaZkProof as M } from "../../functions/snarkjs/constructSolanaZkProof.mjs";
|
|
27
29
|
import "../../functions/index.mjs";
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import { BN as M } from "@coral-xyz/anchor";
|
|
30
|
+
import { PublicKey as N } from "@solana/web3.js";
|
|
31
|
+
import { BN as P } from "@coral-xyz/anchor";
|
|
31
32
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.ts
|
|
32
|
-
var
|
|
33
|
+
var F = (n, a, o, c) => {
|
|
33
34
|
let { hinkalIdl: l, hinkalAddress: u, originalDeployer: d } = e[a].contractData;
|
|
34
35
|
if (!l) throw Error("No IDL configured for Solana program on this network");
|
|
35
36
|
if (!d) throw Error("missing original deployer");
|
|
36
|
-
let f = n.userKeys.getShieldedPrivateKey(),
|
|
37
|
+
let f = n.userKeys.getShieldedPrivateKey(), v = n.getSolanaProgram(l), y = n.getSolanaPublicKey(), b = new N(d), x = new N(u), { mintPublicKey: S } = s(o.erc20TokenAddress), C = S.toString(), w = g(x, b), T = _(x, b), E = h(x, b), D = c.map(() => p(i.findCorrectRandomization(r(31), f), f, n.userKeys.getSpendingKeyPair().pubSpendingBJJPoint)), O = D.map((e) => m(e)), k = i.getEncryptionKeyPair(f).publicKey, A = C === t;
|
|
37
38
|
return {
|
|
38
|
-
program:
|
|
39
|
+
program: v,
|
|
39
40
|
publicKey: y,
|
|
40
41
|
originalDeployer: b,
|
|
41
|
-
mint:
|
|
42
|
-
atasValue:
|
|
42
|
+
mint: A ? null : S,
|
|
43
|
+
atasValue: A ? null : void 0,
|
|
43
44
|
storageAccount: w,
|
|
44
45
|
storageVault: T,
|
|
45
46
|
merkleAccount: E,
|
|
46
47
|
amounts: c,
|
|
47
|
-
|
|
48
|
+
mintAddressString: C,
|
|
49
|
+
stealthAddressStructures: D,
|
|
50
|
+
anchorStealthStructures: O,
|
|
51
|
+
ownEncryptionKey: k
|
|
48
52
|
};
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
}, I = async (e) => {
|
|
54
|
+
let t = E(e.stealthAddressStructures, e.amounts.map(() => e.ownEncryptionKey)).map((e) => Buffer.from(e.slice(2), "hex")), { current: n, next: r } = await v(e.program, e.merkleAccount, e.amounts.length);
|
|
55
|
+
return e.program.methods.multiPaymentDeposit(e.amounts.map((e) => new P(e.toString())), e.anchorStealthStructures, t, !0).accounts({
|
|
56
|
+
mint: e.mint,
|
|
57
|
+
signer: e.publicKey,
|
|
58
|
+
signerAta: e.atasValue,
|
|
59
|
+
originalDeployer: e.originalDeployer,
|
|
60
|
+
storageAccount: e.storageAccount,
|
|
61
|
+
storageVault: e.storageVault,
|
|
62
|
+
merkleAccount: e.merkleAccount,
|
|
63
|
+
rootBucketCurrent: n,
|
|
64
|
+
rootBucketNext: r ?? e.program.programId,
|
|
65
|
+
storageVaultAta: e.atasValue
|
|
66
|
+
});
|
|
67
|
+
}, L = async (e, t, n, r, i, a, o) => {
|
|
68
|
+
let c = r.map((e) => e + j(e, a)), l = F(e, t, n, c), u = (await O({
|
|
60
69
|
chainId: t,
|
|
61
70
|
hashedEthereumAddress: o,
|
|
62
71
|
phase: d.BEFORE_DEPOSIT
|
|
63
|
-
})).id ?? void 0, f = await
|
|
72
|
+
})).id ?? void 0, f = await (await I(l)).rpc(), p = await l.program.provider.connection.getLatestBlockhash();
|
|
64
73
|
await l.program.provider.connection.confirmTransaction({
|
|
65
74
|
blockhash: p.blockhash,
|
|
66
75
|
lastValidBlockHeight: p.lastValidBlockHeight,
|
|
67
76
|
signature: f
|
|
68
77
|
}, "finalized");
|
|
69
|
-
let m = await
|
|
78
|
+
let m = await S(l.program.provider.connection, f, "finalized");
|
|
70
79
|
if (!m) throw Error("Transaction missing");
|
|
71
|
-
await
|
|
80
|
+
await D({
|
|
72
81
|
id: u,
|
|
73
82
|
chainId: t,
|
|
74
83
|
hashedEthereumAddress: o,
|
|
75
84
|
phase: d.AFTER_DEPOSIT,
|
|
76
85
|
depositTxHash: f
|
|
77
86
|
});
|
|
78
|
-
let { compressedAddress: h } = s(n.erc20TokenAddress), g =
|
|
87
|
+
let { compressedAddress: h } = s(n.erc20TokenAddress), g = k(m, l.program, e.userKeys, h), _ = [], v = [...g];
|
|
79
88
|
return i.forEach((e, t) => {
|
|
80
89
|
let n = c[t], r = v.find((e) => e.amount === n);
|
|
81
90
|
if (!r) throw Error(`Could not find newly created UTXO with amount ${n} for recipient ${e}.`);
|
|
@@ -88,77 +97,120 @@ var N = (n, a, o, c) => {
|
|
|
88
97
|
depositTxHash: f,
|
|
89
98
|
statusId: u
|
|
90
99
|
};
|
|
91
|
-
},
|
|
92
|
-
let
|
|
100
|
+
}, R = async (e, t, n, r, i, a, o, s) => {
|
|
101
|
+
let { jobId: c, signedMessageHash: l } = await x(e, {
|
|
102
|
+
chainId: t,
|
|
103
|
+
mintAddresses: [n],
|
|
104
|
+
amountChanges: [-r.amount],
|
|
105
|
+
relayAddress: a,
|
|
106
|
+
recipient: i,
|
|
107
|
+
signer: a,
|
|
108
|
+
functionName: "transact",
|
|
109
|
+
accounts: o,
|
|
110
|
+
relayerFee: s.flatFee,
|
|
111
|
+
variableRate: s.variableRate,
|
|
112
|
+
hinkalInstructions: [],
|
|
113
|
+
remainingAccounts: [],
|
|
114
|
+
inputCommitments: [r.getCommitment()],
|
|
115
|
+
useBlockedUtxos: !0
|
|
116
|
+
}), { R8: u, S: d } = e.userKeys.signEddsa(BigInt(l));
|
|
117
|
+
return b(c, {
|
|
118
|
+
R8: u,
|
|
119
|
+
S: d
|
|
120
|
+
});
|
|
121
|
+
}, z = async (c, l, u, f, p, m, h, g, _, v, b, x, S, C) => {
|
|
122
|
+
let w = u.erc20TokenAddress;
|
|
93
123
|
if (f.length === 0) throw Error("userDepositedUtxos must not be empty");
|
|
94
|
-
let { originalDeployer:
|
|
95
|
-
if (!
|
|
96
|
-
let
|
|
97
|
-
if (!
|
|
98
|
-
let
|
|
124
|
+
let { originalDeployer: E } = e[l].contractData;
|
|
125
|
+
if (!E) throw Error("missing data");
|
|
126
|
+
let O = await c.getRandomRelay(l, !0);
|
|
127
|
+
if (!O) throw Error(n.RELAYER_NOT_AVAILABLE);
|
|
128
|
+
let k = a().toString(), j = c.generateProofRemotely, N = j ? 5 : 1, P = [];
|
|
99
129
|
for (let e = 0; e < f.length; e += N) {
|
|
100
|
-
let n = f.slice(e, e + N), a = await Promise.all(n.map(async ({ recipientAddress:
|
|
101
|
-
let
|
|
130
|
+
let n = f.slice(e, e + N), a = await Promise.all(n.map(async ({ recipientAddress: n, utxo: a }, d) => {
|
|
131
|
+
let f = e + d, m = {
|
|
132
|
+
recipient: n,
|
|
133
|
+
mint: w === "11111111111111111111111111111111" ? void 0 : w
|
|
134
|
+
}, g = await A(l, u, h[f], p), _ = y(b, l, [w], [h[f]], await c.getEthereumAddress());
|
|
135
|
+
if (j) {
|
|
136
|
+
let { solanaArgs: e, commitmentValidationData: t } = await R(c, l, w, a, n, O, m, g);
|
|
137
|
+
return {
|
|
138
|
+
relayAddress: O,
|
|
139
|
+
functionName: "transact",
|
|
140
|
+
chainId: l,
|
|
141
|
+
recipientAmount: h[f].toString(),
|
|
142
|
+
args: e,
|
|
143
|
+
accounts: m,
|
|
144
|
+
adminData: _,
|
|
145
|
+
commitmentValidationData: t,
|
|
146
|
+
displayRecipient: S?.[f],
|
|
147
|
+
destinationChainId: C?.chainId,
|
|
148
|
+
destinationTokenAddress: C?.tokenAddress,
|
|
149
|
+
destinationTokenAmount: C?.tokenAmounts?.[f]
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
let { compressedAddress: v } = s(t), x = new o({
|
|
102
153
|
amount: 0n,
|
|
103
|
-
mintAddress:
|
|
104
|
-
erc20TokenAddress:
|
|
154
|
+
mintAddress: w,
|
|
155
|
+
erc20TokenAddress: v,
|
|
105
156
|
nullifyingKey: c.userKeys.getShieldedPrivateKey(),
|
|
106
|
-
timeStamp:
|
|
157
|
+
timeStamp: k,
|
|
107
158
|
spendingPublicKey: c.userKeys.getSpendingKeyPair().pubSpendingBJJPoint
|
|
108
|
-
}),
|
|
159
|
+
}), T = [a, x], E = [x], D = i.findCorrectRandomization(r(31), c.userKeys.getShieldedPrivateKey()), N = {
|
|
109
160
|
tokenNumber: 1,
|
|
110
|
-
nullifierAmount:
|
|
111
|
-
outputAmount:
|
|
112
|
-
},
|
|
113
|
-
recipient: e,
|
|
114
|
-
mint: T === "11111111111111111111111111111111" ? void 0 : T
|
|
115
|
-
};
|
|
161
|
+
nullifierAmount: T.length,
|
|
162
|
+
outputAmount: E.length
|
|
163
|
+
}, { proofAArr: P, proofBArr: F, proofCArr: I, publicInputsArr: L, commitmentValidationData: z, rootHashHinkalIndex: B, encryptedOutputs: V } = await M(c.merkleTreeHinkalByChain[l], c.userKeys, [w], [T], [E], D, g.flatFee, g.variableRate, n, O, N, void 0, l);
|
|
116
164
|
return {
|
|
117
|
-
relayAddress:
|
|
165
|
+
relayAddress: O,
|
|
118
166
|
functionName: "transact",
|
|
119
167
|
chainId: l,
|
|
120
|
-
recipientAmount:
|
|
168
|
+
recipientAmount: h[f].toString(),
|
|
121
169
|
args: {
|
|
122
|
-
proofAArr:
|
|
123
|
-
proofBArr:
|
|
124
|
-
proofCArr:
|
|
125
|
-
publicInputsArr:
|
|
126
|
-
encryptedOutputs:
|
|
127
|
-
relayerFee:
|
|
128
|
-
dimensions:
|
|
170
|
+
proofAArr: P,
|
|
171
|
+
proofBArr: F,
|
|
172
|
+
proofCArr: I,
|
|
173
|
+
publicInputsArr: L,
|
|
174
|
+
encryptedOutputs: V,
|
|
175
|
+
relayerFee: g.flatFee.toString(),
|
|
176
|
+
dimensions: N,
|
|
177
|
+
rootHashIndex: B.toString()
|
|
129
178
|
},
|
|
130
|
-
accounts:
|
|
131
|
-
adminData:
|
|
132
|
-
commitmentValidationData:
|
|
133
|
-
displayRecipient:
|
|
179
|
+
accounts: m,
|
|
180
|
+
adminData: _,
|
|
181
|
+
commitmentValidationData: z,
|
|
182
|
+
displayRecipient: S?.[f],
|
|
183
|
+
destinationChainId: C?.chainId,
|
|
184
|
+
destinationTokenAddress: C?.tokenAddress,
|
|
185
|
+
destinationTokenAmount: C?.tokenAmounts?.[f]
|
|
134
186
|
};
|
|
135
187
|
}));
|
|
136
188
|
P.push(...a);
|
|
137
189
|
}
|
|
138
|
-
await
|
|
139
|
-
id:
|
|
190
|
+
await D({
|
|
191
|
+
id: g,
|
|
140
192
|
chainId: l,
|
|
141
|
-
hashedEthereumAddress:
|
|
193
|
+
hashedEthereumAddress: m,
|
|
142
194
|
phase: d.BEFORE_SCHEDULE_WITHDRAW
|
|
143
195
|
});
|
|
144
|
-
let F = await
|
|
145
|
-
return await
|
|
146
|
-
id:
|
|
196
|
+
let F = await T(l, P, m, _, v, x);
|
|
197
|
+
return await D({
|
|
198
|
+
id: g,
|
|
147
199
|
chainId: l,
|
|
148
|
-
hashedEthereumAddress:
|
|
200
|
+
hashedEthereumAddress: m,
|
|
149
201
|
phase: d.AFTER_SCHEDULE_WITHDRAW,
|
|
150
202
|
scheduleId: F
|
|
151
203
|
}), F;
|
|
152
|
-
},
|
|
153
|
-
let
|
|
154
|
-
mintTo:
|
|
204
|
+
}, B = async (e, t, n, r, i, a, o, s, d, p, m) => {
|
|
205
|
+
let h = f([t]), g = t.erc20TokenAddress, _ = c(await e.getEthereumAddressByChain(h)), v = d ? l(d) : void 0, y = a ?? await C(h, g, [g], u.Transact, [], 5n, {
|
|
206
|
+
mintTo: g,
|
|
155
207
|
recipient: r[0],
|
|
156
208
|
nullifierCount: 1
|
|
157
|
-
}), { userDepositedUtxos:
|
|
158
|
-
return await
|
|
159
|
-
depositTxHash:
|
|
160
|
-
scheduleId: await
|
|
209
|
+
}), { userDepositedUtxos: b, depositTxHash: x, statusId: S } = await L(e, h, t, n, r, y, _);
|
|
210
|
+
return await w(e, h, b), {
|
|
211
|
+
depositTxHash: x,
|
|
212
|
+
scheduleId: await z(e, h, t, b, y, _, n, S, i, o, s, v, p, m)
|
|
161
213
|
};
|
|
162
214
|
};
|
|
163
215
|
//#endregion
|
|
164
|
-
export {
|
|
216
|
+
export { B as hinkalSolanaDepositAndWithdraw };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../functions/utils/token-check.utils.cjs`),
|
|
1
|
+
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../functions/utils/addresses.cjs`),n=require(`../../functions/utils/token-check.utils.cjs`),r=require(`../../functions/utils/getRecipientInfoFromUserKeys.cjs`),i=require(`./hinkalSolanaDeposit.cjs`);var a=async(a,o,s,c,l,u=!1,d,f=!1)=>{if(o.length===0)throw Error(`erc20Tokens must not be empty`);if(o.length!==s.length)throw Error(`erc20Tokens and amountChanges length mismatch`);if(!e.isSolanaLike(n.validateAndGetChainId(o)))throw Error(`hinkalSolanaProoflessDepositHash: non-Solana chain`);let p=o[0];if(!o.every(e=>e.erc20TokenAddress===p.erc20TokenAddress))throw Error(`Solana prooflessDeposit supports one mint per transaction`);if(c&&c.length!==s.length)throw Error(`Stealth address structures length mismatch`);if(l&&l.length!==s.length)throw Error(`Recipient encryption keys length mismatch`);if(c&&!l)throw Error(`recipientEncryptionKeysOverride is required when stealthAddressStructuresOverride is provided`);let m=r.getRecipientInfoFromUserKeys(a.userKeys);return i.submitSolanaProoflessDeposit(a,p,s,c??s.map(()=>t.constructStealthAddressStructure(m)),l??s.map(()=>t.getEncryptionKeyFromRecipientInfo(m)),u,d,f)};exports.hinkalSolanaProoflessDeposit=a;
|
|
@@ -2,4 +2,4 @@ import { StealthAddressStructure } from '../../types/circom-data.types';
|
|
|
2
2
|
import { ERC20Token } from '../../types/token.types';
|
|
3
3
|
import { IHinkal } from './IHinkal';
|
|
4
4
|
import { AdminTransactionType } from '../../types/admin.types';
|
|
5
|
-
export declare const hinkalSolanaProoflessDeposit: (hinkal: IHinkal, erc20Tokens: ERC20Token[], amountChanges: bigint[], stealthAddressStructuresOverride?: StealthAddressStructure[], action?: AdminTransactionType, returnTxData?: boolean) => Promise<string>;
|
|
5
|
+
export declare const hinkalSolanaProoflessDeposit: (hinkal: IHinkal, erc20Tokens: ERC20Token[], amountChanges: bigint[], stealthAddressStructuresOverride?: StealthAddressStructure[], recipientEncryptionKeysOverride?: string[], createBlockedUtxos?: boolean, action?: AdminTransactionType, returnTxData?: boolean) => Promise<string>;
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { isSolanaLike as e } from "../../constants/chains.constants.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { constructStealthAddressStructure as t, getEncryptionKeyFromRecipientInfo as n } from "../../functions/utils/addresses.mjs";
|
|
3
|
+
import { validateAndGetChainId as r } from "../../functions/utils/token-check.utils.mjs";
|
|
4
|
+
import { getRecipientInfoFromUserKeys as i } from "../../functions/utils/getRecipientInfoFromUserKeys.mjs";
|
|
5
|
+
import { submitSolanaProoflessDeposit as a } from "./hinkalSolanaDeposit.mjs";
|
|
5
6
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalSolanaProoflessDeposit.ts
|
|
6
|
-
var
|
|
7
|
-
if (
|
|
8
|
-
if (
|
|
9
|
-
if (!e(
|
|
10
|
-
let
|
|
11
|
-
if (!
|
|
12
|
-
if (
|
|
13
|
-
|
|
7
|
+
var o = async (o, s, c, l, u, d = !1, f, p = !1) => {
|
|
8
|
+
if (s.length === 0) throw Error("erc20Tokens must not be empty");
|
|
9
|
+
if (s.length !== c.length) throw Error("erc20Tokens and amountChanges length mismatch");
|
|
10
|
+
if (!e(r(s))) throw Error("hinkalSolanaProoflessDepositHash: non-Solana chain");
|
|
11
|
+
let m = s[0];
|
|
12
|
+
if (!s.every((e) => e.erc20TokenAddress === m.erc20TokenAddress)) throw Error("Solana prooflessDeposit supports one mint per transaction");
|
|
13
|
+
if (l && l.length !== c.length) throw Error("Stealth address structures length mismatch");
|
|
14
|
+
if (u && u.length !== c.length) throw Error("Recipient encryption keys length mismatch");
|
|
15
|
+
if (l && !u) throw Error("recipientEncryptionKeysOverride is required when stealthAddressStructuresOverride is provided");
|
|
16
|
+
let h = i(o.userKeys);
|
|
17
|
+
return a(o, m, c, l ?? c.map(() => t(h)), u ?? c.map(() => n(h)), d, f, p);
|
|
14
18
|
};
|
|
15
19
|
//#endregion
|
|
16
|
-
export {
|
|
20
|
+
export { o as hinkalSolanaProoflessDeposit };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`);require(`../../constants/protocol.constants.cjs`);const t=require(`../../error-handling/error-codes.constants.cjs`),n=require(`../../functions/utils/solanaMint.utils.cjs`),r=require(`../../functions/utils/addresses.cjs`),i=require(`../../functions/utils/token-check.utils.cjs`),a=require(`../../functions/pre-transaction/solana.cjs`),o=require(`../../functions/pre-transaction/constructAdminData.cjs`),s=require(`../../functions/utils/create-provider.cjs`),c=require(`../AccountActions/AccountActions.cjs`),l=require(`../../functions/pre-transaction/sendV0Transaction.cjs`),u=require(`../../API/admin-calls.cjs`);let
|
|
1
|
+
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`);require(`../../constants/protocol.constants.cjs`);const t=require(`../../error-handling/error-codes.constants.cjs`),n=require(`../../functions/utils/solanaMint.utils.cjs`),r=require(`../../functions/utils/addresses.cjs`),i=require(`../../functions/utils/token-check.utils.cjs`),a=require(`../../functions/pre-transaction/solana.cjs`),o=require(`../../functions/pre-transaction/constructAdminData.cjs`),s=require(`../../functions/utils/create-provider.cjs`),c=require(`../AccountActions/AccountActions.cjs`),l=require(`../../functions/pre-transaction/sendV0Transaction.cjs`),u=require(`../../API/admin-calls.cjs`),d=require(`./hinkalProoflessDeposit.utils.cjs`);let f=require(`@solana/web3.js`),p=require(`@coral-xyz/anchor`),m=require(`@solana/spl-token`);var h=async({program:e,mintPublicKey:t,mintAddressString:n,tokenAmount:r,stealthAddressStructure:i,recipientEncryptionKey:o,senderPublickey:s,originalDeployer:c,storageAccount:l,storageVault:u,merkleAccount:f,createBlockedUtxos:m})=>{let h=new p.BN(r.toString()),g=a.buildAnchorStealthAddressStructure(i),_=n===`11111111111111111111111111111111`?null:t,v=n===`11111111111111111111111111111111`?null:void 0,[y]=d.buildProoflessEncryptedOutputs([i],[o]),b=Buffer.from(y.slice(2),`hex`),{current:x,next:S}=await a.resolveSolanaRootBuckets(e,f,1);return e.methods.prooflessDeposit(h,g,b,m).accounts({mint:_,signer:s,signerAta:v,originalDeployer:c,storageAccount:l,storageVault:u,merkleAccount:f,rootBucketCurrent:x,rootBucketNext:S??e.programId,storageVaultAta:v}).instruction()},g=async(i,o,l,u,d,p,g=!1)=>{let _=p??i.getRecipientInfo();if(!r.isValidPrivateAddress(_))throw Error(t.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);let v=c.AccountActions.getAddressFromSubAccount(o,d);if(!v)throw Error(`Public account address is not available`);let{hinkalIdl:y,hinkalAddress:b,originalDeployer:x}=e.networkRegistry[o].contractData;if(!y)throw Error(`No IDL configured for Solana program on this network`);if(!x)throw Error(`missing original deployer`);let S=i.getSolanaProgram(y),C=new f.PublicKey(x),w=new f.PublicKey(b),T=new f.PublicKey(v),{erc20TokenAddress:E}=l,{fetchRpcUrl:D}=e.networkRegistry[o];if(!D)throw Error(`RPC URL not found for the specified chain ID`);let O=s.createCustomSolanaConnection(D),{mintPublicKey:k}=n.formatMintAddress(E),A=k.toString(),j=a.getStorageAccountPublicKey(w,C),M=a.getStorageVaultPublicKey(w,C),N=a.getMerkleAccountPublicKey(w,C),P=await h({program:S,mintPublicKey:k,mintAddressString:A,tokenAmount:u,stealthAddressStructure:r.constructStealthAddressStructure(_),recipientEncryptionKey:r.getEncryptionKeyFromRecipientInfo(_),senderPublickey:T,originalDeployer:C,storageAccount:j,storageVault:M,merkleAccount:N,createBlockedUtxos:g}),F=l.is2022Program?m.TOKEN_2022_PROGRAM_ID:m.TOKEN_PROGRAM_ID;return{connection:O,senderAddress:v,senderPublickey:T,instructions:[P],storageAccount:j,programId:F}},_=async(e,t,n,r,a,s=!1,c)=>{if(!r)throw Error(`subAccount is required`);let d=i.validateAndGetChainId([t]),[{connection:f,senderPublickey:p,instructions:m},h]=await Promise.all([g(e,d,t,n,r,a,s),e.getEthereumAddress()]),_=await l.sendProxyV0Transaction({connection:f,chainId:d,subAccount:r,payerPublicKey:p,instructions:m});return u.emitTxPublicData(o.constructAdminData(c,d,[t.erc20TokenAddress],[n],h)),_};exports.hinkalSolanaProxyShield=_;
|
|
@@ -2,5 +2,5 @@ import { ERC20Token } from '../../types/token.types';
|
|
|
2
2
|
import { IHinkal } from './IHinkal';
|
|
3
3
|
import { SubAccount } from '../../types/proxy.types';
|
|
4
4
|
import { AdminTransactionType } from '../../types/admin.types';
|
|
5
|
-
export declare const hinkalSolanaProxyShield: (hinkal: IHinkal, token: ERC20Token, tokenAmount: bigint, subAccount: SubAccount, recipientInfo?: string, action?: AdminTransactionType) => Promise<string>;
|
|
6
|
-
export declare const getSolanaProxyShieldSerializedTransaction: (hinkal: IHinkal, token: ERC20Token, tokenAmount: bigint, subAccount: SubAccount, recipientInfo?: string) => Promise<string>;
|
|
5
|
+
export declare const hinkalSolanaProxyShield: (hinkal: IHinkal, token: ERC20Token, tokenAmount: bigint, subAccount: SubAccount, recipientInfo?: string, createBlockedUtxos?: boolean, action?: AdminTransactionType) => Promise<string>;
|
|
6
|
+
export declare const getSolanaProxyShieldSerializedTransaction: (hinkal: IHinkal, token: ERC20Token, tokenAmount: bigint, subAccount: SubAccount, recipientInfo?: string, createBlockedUtxos?: boolean) => Promise<string>;
|
|
@@ -2,68 +2,75 @@ import { networkRegistry as e } from "../../constants/chains.constants.mjs";
|
|
|
2
2
|
import "../../constants/protocol.constants.mjs";
|
|
3
3
|
import { transactionErrorCodes as t } from "../../error-handling/error-codes.constants.mjs";
|
|
4
4
|
import { formatMintAddress as n } from "../../functions/utils/solanaMint.utils.mjs";
|
|
5
|
-
import { constructStealthAddressStructure as r,
|
|
6
|
-
import { validateAndGetChainId as
|
|
7
|
-
import { buildAnchorStealthAddressStructure as
|
|
8
|
-
import { constructAdminData as
|
|
9
|
-
import { createCustomSolanaConnection as
|
|
10
|
-
import { AccountActions as
|
|
11
|
-
import { sendProxyV0Transaction as
|
|
12
|
-
import { emitTxPublicData as
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
5
|
+
import { constructStealthAddressStructure as r, getEncryptionKeyFromRecipientInfo as i, isValidPrivateAddress as a } from "../../functions/utils/addresses.mjs";
|
|
6
|
+
import { validateAndGetChainId as o } from "../../functions/utils/token-check.utils.mjs";
|
|
7
|
+
import { buildAnchorStealthAddressStructure as s, getMerkleAccountPublicKey as c, getStorageAccountPublicKey as l, getStorageVaultPublicKey as u, resolveSolanaRootBuckets as d } from "../../functions/pre-transaction/solana.mjs";
|
|
8
|
+
import { constructAdminData as f } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
9
|
+
import { createCustomSolanaConnection as p } from "../../functions/utils/create-provider.mjs";
|
|
10
|
+
import { AccountActions as m } from "../AccountActions/AccountActions.mjs";
|
|
11
|
+
import { sendProxyV0Transaction as h } from "../../functions/pre-transaction/sendV0Transaction.mjs";
|
|
12
|
+
import { emitTxPublicData as g } from "../../API/admin-calls.mjs";
|
|
13
|
+
import { buildProoflessEncryptedOutputs as _ } from "./hinkalProoflessDeposit.utils.mjs";
|
|
14
|
+
import { PublicKey as v } from "@solana/web3.js";
|
|
15
|
+
import { BN as y } from "@coral-xyz/anchor";
|
|
16
|
+
import { TOKEN_2022_PROGRAM_ID as b, TOKEN_PROGRAM_ID as x } from "@solana/spl-token";
|
|
16
17
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalSolanaProxyShield.ts
|
|
17
|
-
var
|
|
18
|
-
let
|
|
19
|
-
return e.methods.prooflessDeposit(
|
|
20
|
-
mint:
|
|
21
|
-
signer:
|
|
22
|
-
signerAta:
|
|
23
|
-
originalDeployer:
|
|
24
|
-
storageAccount:
|
|
25
|
-
storageVault:
|
|
26
|
-
|
|
18
|
+
var S = async ({ program: e, mintPublicKey: t, mintAddressString: n, tokenAmount: r, stealthAddressStructure: i, recipientEncryptionKey: a, senderPublickey: o, originalDeployer: c, storageAccount: l, storageVault: u, merkleAccount: f, createBlockedUtxos: p }) => {
|
|
19
|
+
let m = new y(r.toString()), h = s(i), g = n === "11111111111111111111111111111111" ? null : t, v = n === "11111111111111111111111111111111" ? null : void 0, [b] = _([i], [a]), x = Buffer.from(b.slice(2), "hex"), { current: S, next: C } = await d(e, f, 1);
|
|
20
|
+
return e.methods.prooflessDeposit(m, h, x, p).accounts({
|
|
21
|
+
mint: g,
|
|
22
|
+
signer: o,
|
|
23
|
+
signerAta: v,
|
|
24
|
+
originalDeployer: c,
|
|
25
|
+
storageAccount: l,
|
|
26
|
+
storageVault: u,
|
|
27
|
+
merkleAccount: f,
|
|
28
|
+
rootBucketCurrent: S,
|
|
29
|
+
rootBucketNext: C ?? e.programId,
|
|
30
|
+
storageVaultAta: v
|
|
27
31
|
}).instruction();
|
|
28
|
-
},
|
|
29
|
-
let
|
|
30
|
-
if (!
|
|
31
|
-
let
|
|
32
|
-
if (!
|
|
33
|
-
let { hinkalIdl:
|
|
34
|
-
if (!
|
|
35
|
-
if (!
|
|
36
|
-
let
|
|
37
|
-
if (!
|
|
38
|
-
let
|
|
39
|
-
program:
|
|
40
|
-
mintPublicKey:
|
|
41
|
-
mintAddressString:
|
|
42
|
-
tokenAmount:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
32
|
+
}, C = async (o, s, d, f, h, g, _ = !1) => {
|
|
33
|
+
let y = g ?? o.getRecipientInfo();
|
|
34
|
+
if (!a(y)) throw Error(t.RECIPIENT_FORMAT_INCORRECT);
|
|
35
|
+
let C = m.getAddressFromSubAccount(s, h);
|
|
36
|
+
if (!C) throw Error("Public account address is not available");
|
|
37
|
+
let { hinkalIdl: w, hinkalAddress: T, originalDeployer: E } = e[s].contractData;
|
|
38
|
+
if (!w) throw Error("No IDL configured for Solana program on this network");
|
|
39
|
+
if (!E) throw Error("missing original deployer");
|
|
40
|
+
let D = o.getSolanaProgram(w), O = new v(E), k = new v(T), A = new v(C), { erc20TokenAddress: j } = d, { fetchRpcUrl: M } = e[s];
|
|
41
|
+
if (!M) throw Error("RPC URL not found for the specified chain ID");
|
|
42
|
+
let N = p(M), { mintPublicKey: P } = n(j), F = P.toString(), I = l(k, O), L = u(k, O), R = c(k, O), z = await S({
|
|
43
|
+
program: D,
|
|
44
|
+
mintPublicKey: P,
|
|
45
|
+
mintAddressString: F,
|
|
46
|
+
tokenAmount: f,
|
|
47
|
+
stealthAddressStructure: r(y),
|
|
48
|
+
recipientEncryptionKey: i(y),
|
|
49
|
+
senderPublickey: A,
|
|
50
|
+
originalDeployer: O,
|
|
51
|
+
storageAccount: I,
|
|
52
|
+
storageVault: L,
|
|
53
|
+
merkleAccount: R,
|
|
54
|
+
createBlockedUtxos: _
|
|
55
|
+
}), B = d.is2022Program ? b : x;
|
|
49
56
|
return {
|
|
50
|
-
connection:
|
|
51
|
-
senderAddress:
|
|
52
|
-
senderPublickey:
|
|
53
|
-
instructions: [
|
|
54
|
-
storageAccount:
|
|
55
|
-
programId:
|
|
57
|
+
connection: N,
|
|
58
|
+
senderAddress: C,
|
|
59
|
+
senderPublickey: A,
|
|
60
|
+
instructions: [z],
|
|
61
|
+
storageAccount: I,
|
|
62
|
+
programId: B
|
|
56
63
|
};
|
|
57
|
-
},
|
|
64
|
+
}, w = async (e, t, n, r, i, a = !1, s) => {
|
|
58
65
|
if (!r) throw Error("subAccount is required");
|
|
59
|
-
let
|
|
60
|
-
connection:
|
|
61
|
-
chainId:
|
|
66
|
+
let c = o([t]), [{ connection: l, senderPublickey: u, instructions: d }, p] = await Promise.all([C(e, c, t, n, r, i, a), e.getEthereumAddress()]), m = await h({
|
|
67
|
+
connection: l,
|
|
68
|
+
chainId: c,
|
|
62
69
|
subAccount: r,
|
|
63
70
|
payerPublicKey: u,
|
|
64
71
|
instructions: d
|
|
65
72
|
});
|
|
66
|
-
return
|
|
73
|
+
return g(f(s, c, [t.erc20TokenAddress], [n], p)), m;
|
|
67
74
|
};
|
|
68
75
|
//#endregion
|
|
69
|
-
export {
|
|
76
|
+
export { w as hinkalSolanaProxyShield };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../error-handling/error-codes.constants.cjs`),n=require(`../../types/external-action.types.cjs`),r=require(`../../functions/utils/token-check.utils.cjs`),i=require(`../../functions/pre-transaction/constructAdminData.cjs`),a=require(`../../functions/utils/create-provider.cjs`),o=require(`../AccountActions/AccountActions.cjs`),s=require(`../../functions/pre-transaction/sendV0Transaction.cjs`),c=require(`../../functions/pre-transaction/getFeeStructure.cjs`)
|
|
1
|
+
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../error-handling/error-codes.constants.cjs`),n=require(`../../types/external-action.types.cjs`),r=require(`../../functions/utils/token-check.utils.cjs`),i=require(`../../functions/pre-transaction/constructAdminData.cjs`),a=require(`../../functions/utils/create-provider.cjs`),o=require(`../AccountActions/AccountActions.cjs`),s=require(`../../functions/pre-transaction/sendV0Transaction.cjs`),c=require(`../../functions/pre-transaction/getFeeStructure.cjs`),l=require(`../../API/admin-calls.cjs`);require(`../../constants/index.cjs`);const u=require(`../../functions/pre-transaction/solanaTransfer.utils.cjs`);require(`../AccountActions/index.cjs`);let d=require(`@solana/web3.js`);var f=async(e,t)=>{let{addressLookupTableAccount:n,instructionLists:r}=JSON.parse(t).data,i=await Promise.all(n.map(async t=>{let n=await e.getAddressLookupTable(new d.PublicKey(t));if(!n.value)throw Error(`Failed to fetch lookup table: ${t}`);return n.value}));if(r.length===0)throw Error(`No instructions found`);return{instructions:r.map(e=>new d.TransactionInstruction({keys:e.accounts.map(e=>({pubkey:new d.PublicKey(e.pubkey),isSigner:e.isSigner,isWritable:e.isWritable})),programId:new d.PublicKey(e.programId),data:Buffer.from(e.data,`base64`)})),lookupTableAccounts:i}},p=async(e,t)=>{let n=d.VersionedTransaction.deserialize(Buffer.from(t,`base64`)),r=await Promise.all(n.message.addressTableLookups.map(async({accountKey:t})=>{let n=await e.getAddressLookupTable(t);if(!n.value)throw Error(`Failed to fetch lookup table: ${t.toBase58()}`);return n.value})),{instructions:i}=d.TransactionMessage.decompile(n.message,{addressLookupTableAccounts:r});return{instructions:i,lookupTableAccounts:r}},m=async(t,r,i,s)=>{let c=o.AccountActions.getAddressFromSubAccount(t,i);if(!c)throw Error(`Public account address is not available`);let{fetchRpcUrl:l}=e.networkRegistry[t];if(!l)throw Error(`RPC URL not found for the specified chain ID`);let u=a.createCustomSolanaConnection(l),m=new d.PublicKey(c),{instructions:h,lookupTableAccounts:g}=s===n.ExternalActionId.Lifi?await p(u,r):await f(u,r);return{connection:u,walletPublicKey:m,instructions:h,lookupTableAccounts:g}},h=async(e,a,o,f,p,h,g,_,v)=>{let y=r.validateAndGetChainId(a),b=h===n.ExternalActionId.Lifi,[{connection:x,walletPublicKey:S,instructions:C,lookupTableAccounts:w},T,E]=await Promise.all([m(y,f,p,h),b?Promise.resolve(null):e.getRandomRelay(y),e.getEthereumAddressByChain(y)]),D=C;if(!b){if(!T)throw Error(t.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let e=a[1],r=o[1]*(_??await c.getFeeStructure(y,g,a.map(e=>e.erc20TokenAddress),n.ExternalActionId.Emporium)).variableRate/10000n,{instructions:i}=await u.buildSolanaTransferInstructions(x,S,new d.PublicKey(T),e,r);D=[...C,...i]}let O=await s.sendProxyV0Transaction({connection:x,chainId:y,subAccount:p,payerPublicKey:S,instructions:D,lookupTableAccounts:w});return l.emitTxPublicData(i.constructAdminData(v,y,a.map(e=>e.erc20TokenAddress),o,E,a)),O};exports.hinkalSolanaProxySwap=h;
|
|
@@ -7,8 +7,8 @@ import { createCustomSolanaConnection as a } from "../../functions/utils/create-
|
|
|
7
7
|
import { AccountActions as o } from "../AccountActions/AccountActions.mjs";
|
|
8
8
|
import { sendProxyV0Transaction as s } from "../../functions/pre-transaction/sendV0Transaction.mjs";
|
|
9
9
|
import { getFeeStructure as c } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
10
|
-
import "../../constants/index.mjs";
|
|
11
10
|
import { emitTxPublicData as l } from "../../API/admin-calls.mjs";
|
|
11
|
+
import "../../constants/index.mjs";
|
|
12
12
|
import { buildSolanaTransferInstructions as u } from "../../functions/pre-transaction/solanaTransfer.utils.mjs";
|
|
13
13
|
import "../AccountActions/index.mjs";
|
|
14
14
|
import { PublicKey as d, TransactionInstruction as f, TransactionMessage as p, VersionedTransaction as m } from "@solana/web3.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../error-handling/error-codes.constants.cjs`),r=require(`../../functions/web3/etherFunctions.cjs`),i=require(`../crypto-keys/keys.cjs`),a=require(`../../functions/utils/time.utils.cjs`),o=require(`../../types/external-action.types.cjs`),s=require(`../../types/cache.types.cjs`);require(`../../types/index.cjs`);const c=require(`../../functions/utils/token-check.utils.cjs`),l=require(`../../functions/web3/events/getShieldedBalance.cjs`),u=require(`../../functions/pre-transaction/outputUtxoProcessing.cjs`),d=require(`../../functions/
|
|
1
|
+
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../error-handling/error-codes.constants.cjs`),r=require(`../../functions/web3/etherFunctions.cjs`),i=require(`../crypto-keys/keys.cjs`),a=require(`../../functions/utils/time.utils.cjs`),o=require(`../../types/external-action.types.cjs`),s=require(`../../types/cache.types.cjs`);require(`../../types/index.cjs`);const c=require(`../../functions/utils/token-check.utils.cjs`),l=require(`../../functions/web3/events/getShieldedBalance.cjs`),u=require(`../../functions/pre-transaction/outputUtxoProcessing.cjs`),d=require(`../../functions/pre-transaction/solana.cjs`),f=require(`../../functions/pre-transaction/constructAdminData.cjs`),p=require(`../../functions/snarkjs/constructTxEnclave.cjs`),m=require(`../../functions/pre-transaction/calculateSolanaNullifierCount.cjs`),h=require(`../../functions/pre-transaction/convert-okx-instructions.cjs`),g=require(`../../functions/pre-transaction/ensureAmountChanges.cjs`),_=require(`../../functions/pre-transaction/getFeeStructure.cjs`),v=require(`../../functions/web3/functionCalls/transactCallRelayer.cjs`),ee=require(`../../functions/snarkjs/constructSolanaZkProof.cjs`);let y=require(`@solana/web3.js`);var b=async(e,t,n,r)=>{let i=[...await l.addPaddingToUtxos(e,t,n,r,6)],o=a.getCurrentTimeInSeconds().toString(),s=[];for(let t=0;t<n.length;t+=1){let{outputUtxos:n}=u.outputUtxoProcessing(e.userKeys,i[t],r[t],o);s.push([n[0]])}return{inputUtxosArray:i,outputUtxosArray:s}},te=async(e,t,n,r,i,a,o,s,c,l,u,d,f,m)=>{let{jobId:h,signedMessageHash:g}=await p.prepareSolanaTxEnclaveCall(e,{chainId:t,mintAddresses:n,amountChanges:r,relayAddress:a,recipient:o,signer:a,functionName:`swap`,accounts:s,onChainCreation:i,relayerFee:c,variableRate:l,hinkalInstructions:u,remainingAccounts:d,swapperAccountSalt:f}),{R8:_,S:v}=e.userKeys.signEddsa(BigInt(g));return p.finalizeSolanaTxEnclaveCallRelay(h,{R8:_,S:v},t,{adminData:m})},x=async(a,l,u,p,x,S,C,w,T)=>{let E=c.validateAndGetChainId(l),D=new y.PublicKey(t.solanaNativeAddress),{hinkalAddress:O,originalDeployer:k}=e.networkRegistry[E].contractData;if(!k)throw Error(`No IDL configured for Solana program on this network`);let A=new y.PublicKey(k),j=new y.PublicKey(O),M=l.map(e=>e.erc20TokenAddress),{userKeys:ne,merkleTreeHinkalByChain:re}=a,ie=C??M[1];if(C&&C!==M[1])throw Error(`Solana swap fee token must match the output token`);let ae={mintFrom:M[0],mintTo:M[1],nullifierCount:await m.calculateSolanaNullifierCount(a,E,M,u),rootInsertCount:2},N=w??await _.getFeeStructure(E,ie,M,o.ExternalActionId.Okx,[],void 0,ae),P=u[1],oe=Number(a.cacheDevice.get(s.StorageKeys.SLIPPAGE_PERCENTAGE)??0),F=l[1],I=r.getAmountInToken(F,P),L=Number(I)*oe/100;u[1]-=r.getAmountInWei(F,L.toFixed(F.decimals));let R=P*BigInt(N.variableRate??0)/10000n+N.flatFee;if(u[1]-=R,u[1]<0)throw Error(n.transactionErrorCodes.LOW_OUTPUT_AMOUNT);let z=N.variableRate.toString(),[B,V]=await Promise.all([a.getRandomRelay(E,!0),a.getEthereumAddressByChain(E)]);if(!B)throw Error(n.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let H=d.getSwapperAccountPublicKeyFromSalt(j,A,p),{remainingAccounts:U,hinkalInstructions:W}=h.convertOKXToHinkalInstructions(x,H),G=d.getStorageAccountPublicKey(j,A),K=d.getStorageVaultPublicKey(j,A),se=l[0].erc20TokenAddress===`11111111111111111111111111111111`?null:new y.PublicKey(l[0].erc20TokenAddress),ce=l[1].erc20TokenAddress===`11111111111111111111111111111111`?null:new y.PublicKey(l[1].erc20TokenAddress),q={recipient:D.toString(),storageAccount:G.toString(),storageVault:K.toString(),swapperAccount:H.toString(),mintFrom:se?.toString()??null,mintTo:ce?.toString()??null,remainingAccounts:U.map(e=>({pubkey:e.pubkey.toString(),isSigner:e.isSigner,isWritable:e.isWritable})),addressLookupTableAccount:S},J=f.constructAdminData(T,E,M,u,V,l),Y=[!1,!0];if(a.generateProofRemotely){let e=W.map(e=>({accountIndexes:[...e.accountIndexes],data:[...e.data],programIndex:e.programIndex}));return te(a,E,M,u,Y,B,D.toString(),q,N.flatFee,N.variableRate,e,q.remainingAccounts,p,J)}let{inputUtxosArray:X,outputUtxosArray:Z}=await b(a,E,M,u),le=a.userKeys.getShieldedPrivateKey(),ue=i.UserKeys.findCorrectRandomization(r.randomBigInt(31),le),Q={tokenNumber:2,nullifierAmount:X[0].length,outputAmount:1};g.ensureAmountChanges(X,Z,u);let{proofAArr:de,proofBArr:fe,proofCArr:pe,publicInputsArr:me,commitmentValidationData:he,rootHashHinkalIndex:ge,encryptedOutputs:$,onChainEncryptedOutput:_e}=await ee.constructSolanaZkProof(re[E],ne,M,X,Z,ue,N.flatFee,N.variableRate,D.toString(),B,Q,Y,E,W,U,p);return v.solanaTransactCallRelayer({chainId:E,relayAddress:B,functionName:`swap`,args:{encryptedOutputs:$,onChainEncryptedOutput:_e,onChainCreation:Y,proofAArr:de,proofBArr:fe,proofCArr:pe,publicInputsArr:me,relayerFee:N.flatFee.toString(),variableRate:z,dimensions:Q,rootHashIndex:ge.toString(),hinkalInstructions:W.map(e=>({accountIndexes:[...e.accountIndexes],data:[...e.data],programIndex:e.programIndex}))},accounts:q,commitmentValidationData:he,adminData:J})};exports.hinkalSolanaSwap=x;
|