@hinkal/common 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -18
- package/common/src/API/API.cjs +1 -1
- package/common/src/API/API.d.ts +5 -5
- package/common/src/API/API.mjs +78 -78
- package/common/src/API/callRelayer.d.ts +3 -0
- package/common/src/API/enclaveUtxoCalls.cjs +1 -1
- package/common/src/API/enclaveUtxoCalls.d.ts +8 -7
- package/common/src/API/enclaveUtxoCalls.mjs +5 -3
- package/common/src/API/getOdosPriceForToken.cjs +1 -0
- package/common/src/API/getOdosPriceForToken.d.ts +1 -0
- package/common/src/API/getOdosPriceForToken.mjs +14 -0
- package/common/src/API/getWebsiteURL.d.ts +0 -1
- package/common/src/API/index.cjs +1 -1
- package/common/src/API/index.d.ts +0 -1
- package/common/src/API/index.mjs +1 -2
- package/common/src/API/rewardsUserCalls.cjs +1 -1
- package/common/src/API/rewardsUserCalls.d.ts +0 -2
- package/common/src/API/rewardsUserCalls.mjs +2 -3
- package/common/src/API/tenderly.api.cjs +1 -1
- package/common/src/API/tenderly.api.d.ts +5 -10
- package/common/src/API/tenderly.api.mjs +1 -1
- package/common/src/constants/addresses.constants.cjs +1 -1
- package/common/src/constants/addresses.constants.d.ts +4 -46
- package/common/src/constants/addresses.constants.mjs +19 -60
- package/common/src/constants/balance.constants.cjs +1 -0
- package/common/src/constants/balance.constants.d.ts +1 -0
- package/common/src/constants/balance.constants.mjs +4 -0
- package/common/src/constants/chains.constants.cjs +1 -1
- package/common/src/constants/chains.constants.d.ts +3 -1
- package/common/src/constants/chains.constants.mjs +117 -131
- package/common/src/constants/coingecko.constants.cjs +1 -1
- package/common/src/constants/coingecko.constants.d.ts +2 -0
- package/common/src/constants/coingecko.constants.mjs +1 -1
- package/common/src/constants/contracts.constants.cjs +1 -1
- package/common/src/constants/contracts.constants.d.ts +0 -109
- package/common/src/constants/contracts.constants.mjs +13 -22
- package/common/src/constants/deploy-data/deploy-data-arbMainnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-arbMainnet.json.mjs +1 -3
- package/common/src/constants/deploy-data/deploy-data-arcTestnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-arcTestnet.json.mjs +6 -6
- package/common/src/constants/deploy-data/deploy-data-base.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-base.json.mjs +1 -3
- package/common/src/constants/deploy-data/deploy-data-bnbMainnet.json.cjs +1 -0
- package/common/src/constants/deploy-data/deploy-data-bnbMainnet.json.mjs +10 -0
- package/common/src/constants/deploy-data/deploy-data-ethMainnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-ethMainnet.json.mjs +1 -3
- package/common/src/constants/deploy-data/deploy-data-localhost.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-localhost.json.mjs +0 -3
- package/common/src/constants/deploy-data/deploy-data-optimism.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-optimism.json.mjs +6 -8
- package/common/src/constants/deploy-data/deploy-data-optimismTest.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-optimismTest.json.mjs +1 -4
- package/common/src/constants/deploy-data/deploy-data-polygon.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-polygon.json.mjs +1 -3
- package/common/src/constants/deploy-data/deploy-data-sepoliaTestnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-sepoliaTestnet.json.mjs +0 -1
- package/common/src/constants/deploy-data/deploy-data-solana.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-solana.json.mjs +2 -2
- package/common/src/constants/deploy-data/deploy-data-tempo.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-tempo.json.mjs +6 -7
- package/common/src/constants/deploy-data/deploy-data-tronMainnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-tronMainnet.json.mjs +2 -4
- package/common/src/constants/deploy-data/deploy-data-tronNile.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-tronNile.json.mjs +2 -4
- package/common/src/constants/deploy-data/index.cjs +1 -1
- package/common/src/constants/deploy-data/index.d.ts +2 -1
- package/common/src/constants/deploy-data/index.mjs +16 -15
- package/common/src/constants/deploy-data/shared-deploy-data-solana.json.cjs +1 -1
- package/common/src/constants/deploy-data/shared-deploy-data-solana.json.mjs +1 -1
- package/common/src/constants/deploy-data/shared-deploy-data-tron.json.cjs +1 -1
- package/common/src/constants/deploy-data/shared-deploy-data-tron.json.mjs +2 -35
- package/common/src/constants/events.constants.cjs +1 -1
- package/common/src/constants/events.constants.mjs +3 -2
- package/common/src/constants/fees.constants.cjs +1 -1
- package/common/src/constants/fees.constants.mjs +2 -2
- package/common/src/constants/index.cjs +1 -1
- package/common/src/constants/index.d.ts +0 -1
- package/common/src/constants/index.mjs +1 -0
- package/common/src/constants/protocol.constants.cjs +2 -2
- package/common/src/constants/protocol.constants.d.ts +3 -1
- package/common/src/constants/protocol.constants.mjs +2 -2
- package/common/src/constants/server.constants.cjs +1 -1
- package/common/src/constants/server.constants.d.ts +1 -2
- package/common/src/constants/server.constants.mjs +1 -2
- package/common/src/constants/tokens.constants.cjs +1 -1
- package/common/src/constants/tokens.constants.mjs +1 -1
- package/common/src/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/common/src/data-structures/Hinkal/Hinkal.mjs +26 -22
- package/common/src/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
- package/common/src/data-structures/Hinkal/handleAutoDepositBack.d.ts +1 -1
- package/common/src/data-structures/Hinkal/handleAutoDepositBack.mjs +36 -35
- package/common/src/data-structures/Hinkal/hinkalActionReceive.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalActionReceive.mjs +3 -3
- package/common/src/data-structures/Hinkal/hinkalBridgePrivateToPrivate.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalBridgePrivateToPrivate.mjs +60 -58
- package/common/src/data-structures/Hinkal/hinkalClaimUtxo.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalClaimUtxo.mjs +42 -47
- package/common/src/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDeposit.d.ts +1 -0
- package/common/src/data-structures/Hinkal/hinkalDeposit.mjs +50 -116
- package/common/src/data-structures/Hinkal/hinkalDepositAndBridge.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDepositAndBridge.mjs +102 -92
- package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.d.ts +3 -2
- package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +104 -59
- package/common/src/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +4 -4
- package/common/src/data-structures/Hinkal/hinkalNearDepositAndBridge.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalNearDepositAndBridge.mjs +7 -3
- package/common/src/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalPrivateWallet.mjs +51 -39
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.d.ts +1 -2
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.mjs +53 -131
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.utils.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.utils.d.ts +1 -1
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.utils.mjs +29 -47
- package/common/src/data-structures/Hinkal/hinkalProxyToPrivate.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalProxyToPrivate.mjs +3 -3
- package/common/src/data-structures/Hinkal/hinkalSolanaClaimUtxo.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaClaimUtxo.mjs +70 -45
- package/common/src/data-structures/Hinkal/hinkalSolanaDeposit.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaDeposit.d.ts +2 -2
- package/common/src/data-structures/Hinkal/hinkalSolanaDeposit.mjs +47 -45
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.d.ts +8 -4
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +133 -81
- package/common/src/data-structures/Hinkal/hinkalSolanaProoflessDeposit.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaProoflessDeposit.d.ts +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaProoflessDeposit.mjs +16 -12
- package/common/src/data-structures/Hinkal/hinkalSolanaProxyShield.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaProxyShield.d.ts +2 -2
- package/common/src/data-structures/Hinkal/hinkalSolanaProxyShield.mjs +61 -54
- package/common/src/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaSwap.mjs +87 -51
- package/common/src/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaTransfer.d.ts +1 -0
- package/common/src/data-structures/Hinkal/hinkalSolanaTransfer.mjs +95 -50
- package/common/src/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +60 -34
- package/common/src/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSwap.mjs +29 -32
- package/common/src/data-structures/Hinkal/hinkalTransact.cjs +1 -0
- package/common/src/data-structures/Hinkal/hinkalTransact.d.ts +3 -0
- package/common/src/data-structures/Hinkal/hinkalTransact.mjs +90 -0
- package/common/src/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalTransfer.mjs +40 -45
- package/common/src/data-structures/Hinkal/hinkalTronDepositToSelf.cjs +1 -0
- package/common/src/data-structures/Hinkal/hinkalTronDepositToSelf.d.ts +8 -0
- package/common/src/data-structures/Hinkal/hinkalTronDepositToSelf.mjs +30 -0
- package/common/src/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalWithdraw.mjs +35 -45
- package/common/src/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +167 -95
- package/common/src/data-structures/Hinkal/prepareTronDepositToSelf.cjs +1 -0
- package/common/src/data-structures/Hinkal/prepareTronDepositToSelf.d.ts +27 -0
- package/common/src/data-structures/Hinkal/prepareTronDepositToSelf.mjs +31 -0
- package/common/src/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/common/src/data-structures/Hinkal/resetMerkleTrees.mjs +1 -0
- package/common/src/data-structures/IndexedDB/activity-db.cjs +1 -1
- package/common/src/data-structures/IndexedDB/activity-db.mjs +34 -34
- package/common/src/data-structures/IndexedDB/signatures-db.cjs +1 -1
- package/common/src/data-structures/IndexedDB/signatures-db.mjs +11 -11
- package/common/src/data-structures/TokenDBs/AlchemyPublicTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/AlchemyPublicTokensDB.mjs +11 -10
- package/common/src/data-structures/TokenDBs/ArcPublicTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/ArcPublicTokensDB.mjs +14 -14
- package/common/src/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/EventsPublicTokensDB.mjs +26 -26
- package/common/src/data-structures/TokenDBs/PrivateTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/PrivateTokensDB.mjs +15 -15
- package/common/src/data-structures/TokenDBs/TempoPublicTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/TempoPublicTokensDB.mjs +12 -16
- package/common/src/data-structures/TokenDBs/TronPublicTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/TronPublicTokensDB.d.ts +1 -0
- package/common/src/data-structures/TokenDBs/TronPublicTokensDB.mjs +8 -4
- package/common/src/data-structures/crypto-keys/decodeUTXO.cjs +1 -1
- package/common/src/data-structures/crypto-keys/decodeUTXO.d.ts +1 -0
- package/common/src/data-structures/crypto-keys/decodeUTXO.mjs +12 -12
- package/common/src/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
- package/common/src/data-structures/event-service/evm/BlockchainEventEmitter.mjs +12 -12
- package/common/src/data-structures/event-service/helpers/ClientEventHelper.cjs +1 -1
- package/common/src/data-structures/event-service/helpers/ClientEventHelper.mjs +6 -6
- package/common/src/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.cjs +1 -1
- package/common/src/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.mjs +27 -23
- package/common/src/data-structures/merkle-tree/MerkleTree.cjs +1 -1
- package/common/src/data-structures/merkle-tree/MerkleTree.d.ts +10 -0
- package/common/src/data-structures/merkle-tree/MerkleTree.mjs +9 -1
- package/common/src/data-structures/private-balances/HinkalPrivateBalanceController.cjs +1 -1
- package/common/src/data-structures/private-balances/HinkalPrivateBalanceController.d.ts +3 -0
- package/common/src/data-structures/private-balances/HinkalPrivateBalanceController.mjs +64 -54
- package/common/src/error-handling/error-codes.constants.cjs +1 -1
- package/common/src/error-handling/error-codes.constants.d.ts +6 -11
- package/common/src/error-handling/error-codes.constants.mjs +8 -13
- package/common/src/error-handling/get-error.message.cjs +1 -1
- package/common/src/error-handling/get-error.message.mjs +27 -14
- package/common/src/externalABIs/index.cjs +1 -1
- package/common/src/externalABIs/index.d.ts +1 -113
- package/common/src/externalABIs/index.mjs +2 -6
- package/common/src/functions/auto-deposit-back-helpers/select-gas-token.cjs +1 -1
- package/common/src/functions/auto-deposit-back-helpers/select-gas-token.mjs +8 -8
- package/common/src/functions/index.cjs +1 -1
- package/common/src/functions/index.d.ts +0 -1
- package/common/src/functions/index.mjs +12 -15
- package/common/src/functions/pre-transaction/calculateSolanaNullifierCount.cjs +1 -1
- package/common/src/functions/pre-transaction/calculateSolanaNullifierCount.mjs +39 -5
- package/common/src/functions/pre-transaction/getExternalSwapAddress.cjs +1 -1
- package/common/src/functions/pre-transaction/getExternalSwapAddress.mjs +2 -18
- package/common/src/functions/pre-transaction/getSolanaCalldataHash.cjs +1 -1
- package/common/src/functions/pre-transaction/getSolanaCalldataHash.d.ts +1 -1
- package/common/src/functions/pre-transaction/getSolanaCalldataHash.mjs +11 -10
- package/common/src/functions/pre-transaction/getVolatileTransferAmount.cjs +1 -1
- package/common/src/functions/pre-transaction/getVolatileTransferAmount.mjs +12 -12
- package/common/src/functions/pre-transaction/index.cjs +1 -1
- package/common/src/functions/pre-transaction/index.d.ts +1 -2
- package/common/src/functions/pre-transaction/index.mjs +1 -2
- package/common/src/functions/pre-transaction/outputUtxoProcessing.cjs +1 -1
- package/common/src/functions/pre-transaction/outputUtxoProcessing.d.ts +1 -1
- package/common/src/functions/pre-transaction/outputUtxoProcessing.mjs +7 -8
- package/common/src/functions/pre-transaction/solana.cjs +1 -1
- package/common/src/functions/pre-transaction/solana.d.ts +13 -0
- package/common/src/functions/pre-transaction/solana.mjs +46 -22
- package/common/src/functions/pre-transaction/store-proof.cjs +1 -1
- package/common/src/functions/pre-transaction/store-proof.d.ts +1 -1
- package/common/src/functions/pre-transaction/store-proof.mjs +1 -0
- package/common/src/functions/pre-transaction/waitForDepositedUtxosInMerkleTree.cjs +1 -1
- package/common/src/functions/pre-transaction/waitForDepositedUtxosInMerkleTree.mjs +1 -1
- package/common/src/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/common/src/functions/private-wallet/emporium.helpers.mjs +12 -13
- package/common/src/functions/private-wallet/emporium.swap.helpers.cjs +1 -1
- package/common/src/functions/private-wallet/emporium.swap.helpers.d.ts +0 -1
- package/common/src/functions/private-wallet/emporium.swap.helpers.mjs +38 -80
- package/common/src/functions/private-wallet/index.cjs +1 -1
- package/common/src/functions/private-wallet/index.d.ts +0 -1
- package/common/src/functions/private-wallet/index.mjs +0 -1
- package/common/src/functions/snarkjs/common.snarkjs.cjs +1 -1
- package/common/src/functions/snarkjs/common.snarkjs.d.ts +2 -2
- package/common/src/functions/snarkjs/common.snarkjs.mjs +89 -52
- package/common/src/functions/snarkjs/constant.cjs +1 -1
- package/common/src/functions/snarkjs/constant.d.ts +32 -0
- package/common/src/functions/snarkjs/constant.mjs +32 -0
- package/common/src/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
- package/common/src/functions/snarkjs/constructGeneralZkProof.d.ts +1 -1
- package/common/src/functions/snarkjs/constructGeneralZkProof.mjs +78 -65
- package/common/src/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/common/src/functions/snarkjs/constructSolanaZkProof.d.ts +4 -1
- package/common/src/functions/snarkjs/constructSolanaZkProof.mjs +44 -39
- package/common/src/functions/snarkjs/constructTxEnclave.cjs +1 -0
- package/common/src/functions/snarkjs/constructTxEnclave.d.ts +32 -0
- package/common/src/functions/snarkjs/constructTxEnclave.mjs +162 -0
- package/common/src/functions/snarkjs/fetchTronInsertionSiblings.cjs +1 -0
- package/common/src/functions/snarkjs/fetchTronInsertionSiblings.d.ts +7 -0
- package/common/src/functions/snarkjs/fetchTronInsertionSiblings.mjs +13 -0
- package/common/src/functions/snarkjs/generateCircomData.cjs +1 -1
- package/common/src/functions/snarkjs/generateCircomData.d.ts +1 -1
- package/common/src/functions/snarkjs/generateCircomData.mjs +33 -27
- package/common/src/functions/snarkjs/generateMainAndCommitmentZkProof.cjs +1 -1
- package/common/src/functions/snarkjs/generateMainAndCommitmentZkProof.d.ts +1 -1
- package/common/src/functions/snarkjs/generateMainAndCommitmentZkProof.mjs +7 -7
- package/common/src/functions/snarkjs/generateZkProof.cjs +1 -1
- package/common/src/functions/snarkjs/generateZkProof.d.ts +1 -1
- package/common/src/functions/snarkjs/generateZkProof.mjs +9 -16
- package/common/src/functions/snarkjs/signedMessageHash.cjs +1 -1
- package/common/src/functions/snarkjs/signedMessageHash.d.ts +11 -0
- package/common/src/functions/snarkjs/signedMessageHash.mjs +21 -3
- package/common/src/functions/snarkjs/verifySignedEnclaveResponse.cjs +1 -0
- package/common/src/functions/snarkjs/verifySignedEnclaveResponse.d.ts +1 -0
- package/common/src/functions/snarkjs/verifySignedEnclaveResponse.mjs +11 -0
- package/common/src/functions/utils/addresses.cjs +1 -1
- package/common/src/functions/utils/addresses.d.ts +1 -0
- package/common/src/functions/utils/addresses.mjs +6 -2
- package/common/src/functions/utils/buildClaimableDepositPlan.d.ts +2 -2
- package/common/src/functions/utils/convertIntegrationProviderToExternalActionId.cjs +1 -1
- package/common/src/functions/utils/convertIntegrationProviderToExternalActionId.mjs +1 -1
- package/common/src/functions/utils/deposit-claimable.utils.cjs +1 -1
- package/common/src/functions/utils/deposit-claimable.utils.d.ts +1 -1
- package/common/src/functions/utils/deposit-claimable.utils.mjs +3 -1
- package/common/src/functions/utils/enclave-utxo-storage.cjs +1 -1
- package/common/src/functions/utils/enclave-utxo-storage.mjs +1 -1
- package/common/src/functions/utils/fees.utils.cjs +1 -1
- package/common/src/functions/utils/fees.utils.mjs +31 -31
- package/common/src/functions/utils/formatter.d.ts +1 -0
- package/common/src/functions/utils/getUtxosFromReceipt.utils.cjs +1 -1
- package/common/src/functions/utils/getUtxosFromReceipt.utils.mjs +6 -6
- package/common/src/functions/utils/getUtxosFromReceiptSolana.cjs +1 -1
- package/common/src/functions/utils/getUtxosFromReceiptSolana.mjs +11 -10
- package/common/src/functions/utils/index.cjs +1 -1
- package/common/src/functions/utils/index.d.ts +2 -2
- package/common/src/functions/utils/index.mjs +11 -10
- package/common/src/functions/utils/process.utils.cjs +1 -1
- package/common/src/functions/utils/process.utils.d.ts +0 -1
- package/common/src/functions/utils/process.utils.mjs +2 -11
- package/common/src/functions/utils/publicBalance.utils.cjs +1 -1
- package/common/src/functions/utils/publicBalance.utils.mjs +2 -1
- package/common/src/functions/utils/transfer-claimable.utils.cjs +1 -1
- package/common/src/functions/utils/transfer-claimable.utils.mjs +2 -2
- package/common/src/functions/utils/tron.utils.cjs +1 -1
- package/common/src/functions/utils/tron.utils.d.ts +5 -14
- package/common/src/functions/utils/tron.utils.mjs +91 -127
- package/common/src/functions/utils/waasStamp.cjs +1 -0
- package/common/src/functions/utils/waasStamp.d.ts +5 -0
- package/common/src/functions/utils/waasStamp.mjs +2 -0
- package/common/src/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
- package/common/src/functions/web3/events/getInputUtxoAndBalance.d.ts +3 -8
- package/common/src/functions/web3/events/getInputUtxoAndBalance.mjs +44 -48
- package/common/src/functions/web3/events/getInputUtxosEnclave.cjs +1 -1
- package/common/src/functions/web3/events/getInputUtxosEnclave.d.ts +4 -3
- package/common/src/functions/web3/events/getInputUtxosEnclave.mjs +34 -25
- package/common/src/functions/web3/events/getShieldedBalance.cjs +1 -1
- package/common/src/functions/web3/events/getShieldedBalance.d.ts +1 -1
- package/common/src/functions/web3/events/getShieldedBalance.mjs +88 -76
- package/common/src/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
- package/common/src/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +9 -6
- package/common/src/functions/web3/functionCalls/approveToken.cjs +1 -1
- package/common/src/functions/web3/functionCalls/approveToken.mjs +12 -12
- package/common/src/functions/web3/functionCalls/submitProof.cjs +1 -0
- package/common/src/functions/web3/functionCalls/submitProof.d.ts +5 -0
- package/common/src/functions/web3/functionCalls/submitProof.mjs +26 -0
- package/common/src/functions/web3/functionCalls/transactCallDirectTron.cjs +1 -1
- package/common/src/functions/web3/functionCalls/transactCallDirectTron.d.ts +7 -3
- package/common/src/functions/web3/functionCalls/transactCallDirectTron.mjs +81 -87
- package/common/src/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/common/src/functions/web3/functionCalls/transactCallRelayer.d.ts +6 -11
- package/common/src/functions/web3/functionCalls/transactCallRelayer.mjs +4 -2
- package/common/src/functions/web3/functionCalls/waitForErc20Approvals.cjs +1 -1
- package/common/src/functions/web3/functionCalls/waitForErc20Approvals.mjs +6 -6
- package/common/src/functions/web3/getContractMetadata.cjs +1 -1
- package/common/src/functions/web3/getContractMetadata.mjs +1 -1
- package/common/src/functions/web3/getTokenHolder.cjs +1 -1
- package/common/src/functions/web3/getTokenHolder.mjs +3 -2
- package/common/src/functions/web3/index.cjs +1 -1
- package/common/src/functions/web3/index.d.ts +0 -3
- package/common/src/functions/web3/index.mjs +0 -3
- package/common/src/functions/web3/lifiAPI.cjs +1 -1
- package/common/src/functions/web3/lifiAPI.mjs +1 -1
- package/common/src/providers/TronProviderAdapter.cjs +1 -1
- package/common/src/providers/TronProviderAdapter.mjs +7 -1
- package/common/src/providers/WagmiProviderAdapter.cjs +1 -1
- package/common/src/providers/WagmiProviderAdapter.mjs +5 -5
- package/common/src/types/activities.types.cjs +1 -1
- package/common/src/types/activities.types.d.ts +0 -9
- package/common/src/types/activities.types.mjs +1 -1
- package/common/src/types/admin.types.cjs +1 -1
- package/common/src/types/admin.types.d.ts +3 -1
- package/common/src/types/admin.types.mjs +1 -1
- package/common/src/types/bridging-tx.types.d.ts +8 -0
- package/common/src/types/cache.types.cjs +1 -1
- package/common/src/types/cache.types.d.ts +2 -1
- package/common/src/types/cache.types.mjs +1 -1
- package/common/src/types/circom-data.types.d.ts +6 -0
- package/common/src/types/commitments.types.d.ts +2 -0
- package/common/src/types/dashboard-transaction.types.d.ts +3 -0
- package/common/src/types/ethereum-network.types.cjs +1 -1
- package/common/src/types/ethereum-network.types.d.ts +6 -15
- package/common/src/types/ethereum-network.types.mjs +1 -1
- package/common/src/types/external-action.types.cjs +1 -1
- package/common/src/types/external-action.types.d.ts +2 -5
- package/common/src/types/external-action.types.mjs +1 -1
- package/common/src/types/hinkal.types.cjs +1 -1
- package/common/src/types/hinkal.types.d.ts +4 -7
- package/common/src/types/hinkal.types.mjs +1 -1
- package/common/src/types/index.cjs +1 -1
- package/common/src/types/index.d.ts +2 -0
- package/common/src/types/index.mjs +1 -0
- package/common/src/types/near-intents.types.d.ts +1 -0
- package/common/src/types/offscreen.types.cjs +1 -1
- package/common/src/types/offscreen.types.d.ts +0 -1
- package/common/src/types/offscreen.types.mjs +1 -1
- package/common/src/types/pay-activities.types.d.ts +3 -0
- package/common/src/types/remote-proof.types.d.ts +0 -6
- package/common/src/types/remote-tx-build.types.d.ts +242 -0
- package/common/src/types/scheduled-transactions.types.d.ts +3 -0
- package/common/src/types/solana.types.d.ts +7 -0
- package/common/src/types/tenderly.api.types.d.ts +70 -0
- package/common/src/types/transact.types.cjs +1 -0
- package/common/src/types/transact.types.d.ts +53 -0
- package/common/src/types/transact.types.mjs +6 -0
- package/common/src/webworker/{logError-uy41lNp1.js → logError-CxZzSALU.js} +1 -1
- package/common/src/webworker/package.json +12 -12
- package/common/src/webworker/snarkjsWorker/snarkjsWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/snarkjsWorker/snarkjsWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/snarkjsWorkerNode.cjs +1 -1
- package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/utxoWorkerNode.cjs +1 -1
- package/common/src/webworker/viteWorkerURL.constant.cjs +3 -3
- package/common/src/webworker/viteWorkerURL.constant.mjs +3 -3
- package/common/src/webworker/workerProxy-swwPYw6e.js +1 -0
- package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/zkProofWorkerNode.cjs +1 -1
- package/index.cjs +1 -1
- package/index.mjs +1 -1
- package/internal/swapApi.cjs +1 -1
- package/internal/swapApi.d.ts +3 -3
- package/internal/swapApi.mjs +22 -25
- package/package.json +12 -12
- package/services/Hinkal.cjs +1 -1
- package/services/Hinkal.d.ts +3 -3
- package/services/Hinkal.mjs +7 -7
- package/types/IHinkal.d.ts +3 -3
- package/types/swap.types.d.ts +3 -20
- package/common/src/API/callOdosAPI.cjs +0 -1
- package/common/src/API/callOdosAPI.d.ts +0 -63
- package/common/src/API/callOdosAPI.mjs +0 -18
- package/common/src/API/callOneInchAPI.cjs +0 -1
- package/common/src/API/callOneInchAPI.d.ts +0 -24
- package/common/src/API/callOneInchAPI.mjs +0 -16
- package/common/src/constants/rewards.constants.d.ts +0 -2
- package/common/src/externalABIs/IQuoterV2.json.cjs +0 -1
- package/common/src/externalABIs/IQuoterV2.json.mjs +0 -203
- package/common/src/externalABIs/ISwapRouter.json.cjs +0 -1
- package/common/src/externalABIs/ISwapRouter.json.mjs +0 -537
- package/common/src/externalABIs/IUniswapV3Factory.json.cjs +0 -1
- package/common/src/externalABIs/IUniswapV3Factory.json.mjs +0 -188
- package/common/src/externalABIs/IUniswapV3Pool.json.cjs +0 -1
- package/common/src/externalABIs/IUniswapV3Pool.json.mjs +0 -938
- package/common/src/externalABIs/UniswapV2PoolAbi.json.cjs +0 -1
- package/common/src/externalABIs/UniswapV2PoolAbi.json.mjs +0 -78
- package/common/src/functions/pre-transaction/interaction-to-action.cjs +0 -1
- package/common/src/functions/pre-transaction/interaction-to-action.d.ts +0 -2
- package/common/src/functions/pre-transaction/interaction-to-action.mjs +0 -1
- package/common/src/functions/pre-transaction/recipientUtxoProcessing.cjs +0 -1
- package/common/src/functions/pre-transaction/recipientUtxoProcessing.d.ts +0 -3
- package/common/src/functions/pre-transaction/recipientUtxoProcessing.mjs +0 -30
- package/common/src/functions/private-wallet/opProducer.cjs +0 -1
- package/common/src/functions/private-wallet/opProducer.d.ts +0 -5
- package/common/src/functions/private-wallet/opProducer.mjs +0 -3
- package/common/src/functions/snarkjs/generateZkProofEnclave.cjs +0 -1
- package/common/src/functions/snarkjs/generateZkProofEnclave.d.ts +0 -5
- package/common/src/functions/snarkjs/generateZkProofEnclave.mjs +0 -27
- package/common/src/functions/utils/get-signature-header.cjs +0 -1
- package/common/src/functions/utils/get-signature-header.d.ts +0 -5
- package/common/src/functions/utils/get-signature-header.mjs +0 -4
- package/common/src/functions/web3/odosAPI.cjs +0 -1
- package/common/src/functions/web3/odosAPI.d.ts +0 -5
- package/common/src/functions/web3/odosAPI.mjs +0 -35
- package/common/src/functions/web3/oneInchAPI.cjs +0 -1
- package/common/src/functions/web3/oneInchAPI.d.ts +0 -5
- package/common/src/functions/web3/oneInchAPI.mjs +0 -44
- package/common/src/functions/web3/uniswapAPI.cjs +0 -1
- package/common/src/functions/web3/uniswapAPI.d.ts +0 -16
- package/common/src/functions/web3/uniswapAPI.mjs +0 -60
- package/common/src/webworker/workerProxy-MheXtWa4.js +0 -1
|
@@ -1,60 +1,56 @@
|
|
|
1
1
|
import { chainIds as e, networkRegistry as t } from "../../constants/chains.constants.mjs";
|
|
2
|
-
import { TRON_DEFAULT_FEE_LIMIT_SUN as n
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { ERC20ABI as c } from "../../externalABIs/index.mjs";
|
|
8
|
-
import { Logger as l } from "../../error-handling/logger.mjs";
|
|
9
|
-
import { ethers as u } from "ethers";
|
|
10
|
-
import { TronWeb as d } from "tronweb";
|
|
2
|
+
import { TRON_DEFAULT_FEE_LIMIT_SUN as n } from "../../constants/protocol.constants.mjs";
|
|
3
|
+
import { ENCLAVE_URL as r } from "../snarkjs/constant.mjs";
|
|
4
|
+
import { httpClient as i } from "../../data-structures/http/HttpClient.mjs";
|
|
5
|
+
import { ethers as a } from "ethers";
|
|
6
|
+
import { TronWeb as o } from "tronweb";
|
|
11
7
|
//#region libs/shared/common/src/functions/utils/tron.utils.ts
|
|
12
|
-
var
|
|
8
|
+
var s = 2000n, c = (e) => {
|
|
13
9
|
let t = e.trim(), n = t.startsWith("0x") ? t.slice(2) : t;
|
|
14
10
|
if (!/^[0-9a-fA-F]{64}$/.test(n)) throw Error("Tron private key must be 32 bytes (64 hex characters), with or without 0x prefix");
|
|
15
11
|
return n;
|
|
16
|
-
},
|
|
17
|
-
let r = t[e].fetchRpcUrl, i = n ?
|
|
12
|
+
}, l = (e, n) => {
|
|
13
|
+
let r = t[e].fetchRpcUrl, i = n ? c(n) : void 0, a = i ? new o({
|
|
18
14
|
fullHost: r,
|
|
19
15
|
privateKey: i
|
|
20
|
-
}) : new
|
|
16
|
+
}) : new o({ fullHost: r });
|
|
21
17
|
return n || a.setAddress("T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb"), a;
|
|
22
|
-
},
|
|
18
|
+
}, u = (e) => e?.startsWith("T") ? e : o.address.fromHex(e), d = (e) => e.startsWith("0x") ? u(e) : e, f = (e) => {
|
|
23
19
|
if (e.startsWith("0x")) return e;
|
|
24
20
|
if (e.startsWith("41")) return e.replace("41", "0x");
|
|
25
|
-
if (e.startsWith("T")) return
|
|
21
|
+
if (e.startsWith("T")) return f(o.address.toHex(e));
|
|
26
22
|
throw Error("Failed to convert address to hex format");
|
|
27
|
-
},
|
|
23
|
+
}, p = (t) => {
|
|
28
24
|
if (t === e.tronNile) return "https://nile.trongrid.io";
|
|
29
25
|
if (t === e.tronMainnet) return "https://api.trongrid.io";
|
|
30
26
|
throw Error(`Unsupported Tron chain for wallet RPC: ${t}`);
|
|
31
|
-
},
|
|
32
|
-
let r = new
|
|
27
|
+
}, m = (e, t) => e.map((e) => Array.isArray(e) ? m(e, t) : t(e)), h = (e, t, n) => {
|
|
28
|
+
let r = new a.Interface(e);
|
|
33
29
|
if (!r.getFunction(t)) throw Error(`${t} ABI is missing for Tron call data creation`);
|
|
34
|
-
let i =
|
|
30
|
+
let i = m(n, (e) => typeof e == "string" && e.startsWith("T") ? f(e) : e);
|
|
35
31
|
return r.encodeFunctionData(t, i);
|
|
36
|
-
},
|
|
32
|
+
}, g = (e, t, n) => e ? BigInt(Math.max((e[t] ?? 0) - (e[n] ?? 0), 0)) : 0n, _ = (e, t) => {
|
|
37
33
|
let n = e.find((e) => e.key === t);
|
|
38
34
|
if (!n || typeof n.value != "number") throw Error(`Missing Tron chain parameter: ${t}`);
|
|
39
35
|
return BigInt(n.value);
|
|
40
|
-
},
|
|
41
|
-
let t = `${
|
|
36
|
+
}, v = async (e) => {
|
|
37
|
+
let t = `${p(e)}/wallet/getchainparameters`, n = await i.post(t, {});
|
|
42
38
|
if (!n?.chainParameter?.length) throw Error("Failed to fetch Tron chain parameters from wallet RPC");
|
|
43
39
|
return n.chainParameter;
|
|
44
|
-
},
|
|
45
|
-
let n = `${
|
|
46
|
-
return await
|
|
47
|
-
address:
|
|
40
|
+
}, y = async (e, t) => {
|
|
41
|
+
let n = `${p(e)}/wallet/getaccountresource`, r = f(t), a = r.startsWith("0x") ? `41${r.slice(2)}` : r;
|
|
42
|
+
return await i.post(n, {
|
|
43
|
+
address: a,
|
|
48
44
|
visible: !1
|
|
49
45
|
});
|
|
50
|
-
},
|
|
51
|
-
let
|
|
46
|
+
}, b = async (e, t, r, i, a, o) => {
|
|
47
|
+
let c = {
|
|
52
48
|
input: a,
|
|
53
49
|
callValue: Number(o),
|
|
54
50
|
feeLimit: n
|
|
55
|
-
}, [
|
|
51
|
+
}, [l, u] = await Promise.all([e.transactionBuilder.estimateEnergy(r, "", c, [], i), e.transactionBuilder.triggerConstantContract(r, "", c, [], i)]), d = await v(t), f = _(d, "getEnergyFee"), p = _(d, "getTransactionFee"), m = await y(t, i), h = BigInt(l?.energy_required ?? u?.energy_used ?? 0), b = g(m, "EnergyLimit", "EnergyUsed"), x = (h > b ? h - b : 0n) * f, S = BigInt(Math.ceil((u?.transaction?.raw_data_hex?.length ?? 0) / 2)), C = g(m, "freeNetLimit", "freeNetUsed") + g(m, "NetLimit", "NetUsed"), w = x + (S > C ? S - C : 0n) * p, T = w + w * s / 10000n;
|
|
56
52
|
return T > BigInt(1e9) ? BigInt(n) : T;
|
|
57
|
-
},
|
|
53
|
+
}, x = (e) => {
|
|
58
54
|
let t = e[0].map(BigInt), n = e[1][0].map(BigInt), r = e[1][1].map(BigInt), i = e[2].map(BigInt), a = e[3].map(BigInt);
|
|
59
55
|
return {
|
|
60
56
|
a: t,
|
|
@@ -62,8 +58,8 @@ var f = 2000n, p = (e) => {
|
|
|
62
58
|
c: i,
|
|
63
59
|
publicSignals: a
|
|
64
60
|
};
|
|
65
|
-
},
|
|
66
|
-
let n =
|
|
61
|
+
}, S = (e, t) => {
|
|
62
|
+
let n = a.AbiCoder.defaultAbiCoder().encode([
|
|
67
63
|
"uint16",
|
|
68
64
|
"uint16",
|
|
69
65
|
"uint16",
|
|
@@ -74,106 +70,74 @@ var f = 2000n, p = (e) => {
|
|
|
74
70
|
e.outputAmount,
|
|
75
71
|
t
|
|
76
72
|
]);
|
|
77
|
-
return BigInt(
|
|
78
|
-
},
|
|
79
|
-
let
|
|
80
|
-
|
|
73
|
+
return BigInt(a.keccak256(n));
|
|
74
|
+
}, C = async (e, t, n, o, s, c, l) => {
|
|
75
|
+
let u = S(s, c), d = e.map(String), f = n.map(String), p = o.map(String), m = {
|
|
76
|
+
chainId: l,
|
|
77
|
+
a: d,
|
|
81
78
|
b: [t[0].map(String), t[1].map(String)],
|
|
82
|
-
c:
|
|
83
|
-
inputs:
|
|
84
|
-
verifier_id: String(
|
|
85
|
-
|
|
79
|
+
c: f,
|
|
80
|
+
inputs: p,
|
|
81
|
+
verifier_id: String(u),
|
|
82
|
+
tokenNumber: s.tokenNumber,
|
|
83
|
+
nullifierAmount: s.nullifierAmount,
|
|
84
|
+
outputAmount: s.outputAmount
|
|
85
|
+
}, h = await i.post(`${r}/sign-proof`, m), { v: g, r: _, s: v } = a.Signature.from(h.signature.trim());
|
|
86
86
|
return {
|
|
87
|
-
v:
|
|
88
|
-
r:
|
|
89
|
-
s:
|
|
87
|
+
v: g,
|
|
88
|
+
r: _,
|
|
89
|
+
s: v
|
|
90
90
|
};
|
|
91
|
-
},
|
|
92
|
-
e.
|
|
93
|
-
e.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
e.
|
|
103
|
-
e.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
e.
|
|
110
|
-
e.
|
|
111
|
-
e.
|
|
112
|
-
e.
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
e.
|
|
126
|
-
e.
|
|
127
|
-
e.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
]
|
|
91
|
+
}, w = (e) => {
|
|
92
|
+
if (e.newRootHash === void 0) throw Error("circomData.newRootHash is required for Tron transactions");
|
|
93
|
+
if (e.insertedLeafIndex === void 0) throw Error("circomData.insertedLeafIndex is required for Tron transactions");
|
|
94
|
+
return [
|
|
95
|
+
e.rootHashHinkal,
|
|
96
|
+
e.rootHashHinkalIndex,
|
|
97
|
+
e.erc20TokenAddresses,
|
|
98
|
+
e.amountChanges,
|
|
99
|
+
e.newRootHash,
|
|
100
|
+
e.inputNullifiers,
|
|
101
|
+
e.outCommitments,
|
|
102
|
+
e.encryptedOutputs,
|
|
103
|
+
e.slippageValues,
|
|
104
|
+
[
|
|
105
|
+
e.feeStructure.feeToken,
|
|
106
|
+
e.feeStructure.flatFee,
|
|
107
|
+
e.feeStructure.variableRate
|
|
108
|
+
],
|
|
109
|
+
e.timeStamp,
|
|
110
|
+
e.calldataHash,
|
|
111
|
+
e.emporiumMessage,
|
|
112
|
+
e.publicSignalCount,
|
|
113
|
+
e.relay,
|
|
114
|
+
[
|
|
115
|
+
e.externalActionData.externalAddress,
|
|
116
|
+
e.externalActionData.externalActionId,
|
|
117
|
+
e.externalActionData.externalActionMetadata
|
|
118
|
+
],
|
|
119
|
+
[
|
|
120
|
+
e.hookData.preHookContract,
|
|
121
|
+
e.hookData.postHookContract,
|
|
122
|
+
e.hookData.preHookMetadata,
|
|
123
|
+
e.hookData.postHookMetadata
|
|
124
|
+
],
|
|
125
|
+
e.originalSender,
|
|
126
|
+
e.extraData,
|
|
127
|
+
e.insertedLeafIndex,
|
|
128
|
+
e.createBlockedUtxos ?? !1
|
|
129
|
+
];
|
|
130
|
+
}, T = (e) => {
|
|
131
|
+
e[1] = [[e[1][0][1], e[1][0][0]], [e[1][1][1], e[1][1][0]]];
|
|
132
|
+
}, E = async (e, t, n, r, i, a = !0) => {
|
|
132
133
|
if (e) {
|
|
133
|
-
let { a: e, b:
|
|
134
|
-
v:
|
|
135
|
-
r:
|
|
136
|
-
s:
|
|
134
|
+
let { a: e, b: o, c: s, publicSignals: c } = x(t), l = await C(e, o, s, c, n, BigInt(r.externalActionData.externalActionId), i), u = {
|
|
135
|
+
v: l.v,
|
|
136
|
+
r: l.r,
|
|
137
|
+
s: l.s
|
|
137
138
|
};
|
|
138
|
-
return
|
|
139
|
-
}
|
|
140
|
-
}, j = (e, t) => {
|
|
141
|
-
let n = 0n, a = /* @__PURE__ */ new Map();
|
|
142
|
-
for (let o = 0; o < e.length; o += 1) if (i(e[o].erc20TokenAddress, r)) n += t[o];
|
|
143
|
-
else {
|
|
144
|
-
let n = h(e[o].erc20TokenAddress);
|
|
145
|
-
a.set(n, (a.get(n) ?? 0n) + t[o]);
|
|
146
|
-
}
|
|
147
|
-
return {
|
|
148
|
-
totalTrxValue: n,
|
|
149
|
-
tokensNeedingApproval: a
|
|
150
|
-
};
|
|
151
|
-
}, M = async (e, t, r, i, o, s) => {
|
|
152
|
-
let c = BigInt(await e.trx.getBalance(i)), u = BigInt(n);
|
|
153
|
-
try {
|
|
154
|
-
u = await T(e, t, r, i, o, s);
|
|
155
|
-
} catch (e) {
|
|
156
|
-
l.error("Error estimating Tron deposit fee", e);
|
|
157
|
-
}
|
|
158
|
-
if (c < s + u) throw Error(a.INSUFFICIENT_TRON_BALANCE_FOR_FEE);
|
|
159
|
-
}, N = async (e, t, r, i) => {
|
|
160
|
-
let a = Array.from(i.entries());
|
|
161
|
-
for (let i = 0; i < a.length; i += 1) {
|
|
162
|
-
let [o, s] = a[i], l = await e.contract(c, o).allowance(t, r).call({ from: t });
|
|
163
|
-
if (BigInt(String(l)) < s) {
|
|
164
|
-
let { transaction: i } = await e.transactionBuilder.triggerSmartContract(o, "approve(address,uint256)", { feeLimit: n }, [{
|
|
165
|
-
type: "address",
|
|
166
|
-
value: r
|
|
167
|
-
}, {
|
|
168
|
-
type: "uint256",
|
|
169
|
-
value: s.toString()
|
|
170
|
-
}], t), a = await e.trx.sign(i), c = await e.trx.sendRawTransaction(a);
|
|
171
|
-
if (!c.result) {
|
|
172
|
-
let e = c.code ?? "UNKNOWN", t = c.message ? Buffer.from(c.message, "hex").toString() : "no message";
|
|
173
|
-
throw Error(`Tron token approval failed: ${e} - ${t}`);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
139
|
+
return a && T(t), u;
|
|
176
140
|
}
|
|
177
141
|
};
|
|
178
142
|
//#endregion
|
|
179
|
-
export {
|
|
143
|
+
export { f as addressToHexFormat, w as circomDataToArray, h as createTronCallData, l as createTronWeb, b as estimateTronFeeSunWithPadding, u as evmHexToTronBase58Address, y as fetchTronAccountResources, v as fetchTronChainParameters, C as generateProofSignatureRemotely, g as getAvailableResource, _ as getChainParameterValue, p as getTronWalletRpcUrl, S as getVerifierId, c as normalizeTronPrivateKey, x as parseZkCalldata, E as reorderZkCallData, T as swapTronBCoordinate, d as toTronBase58IfHex };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../../_virtual/_rolldown/runtime.cjs`);require(`./enclaveSessionSigning.cjs`);let t=require(`tweetnacl`);t=e.__toESM(t);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { default as nacl } from 'tweetnacl';
|
|
2
|
+
export declare const HEADER_X_STAMP = "X-Stamp";
|
|
3
|
+
/** Ed25519 X-Stamp message: binds the action to the signed params. */
|
|
4
|
+
export declare const buildStampMessage: (binding: string, params: Record<string, unknown>) => string;
|
|
5
|
+
export declare const buildXStamp: (method: string, routePath: string, params: Record<string, unknown>, keypair: nacl.SignKeyPair) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../../constants/chains.constants.cjs`),t=require(`../../utils/caseInsensitive.utils.cjs`),n=require(`../../../data-structures/utxo/Utxo.cjs`),r=require(`../../utils/upToDateState.cjs`),i=require(`../../utils/cacheFunctions.cjs`),a=require(`../../utils/encodeTokenWithId.cjs`),o=require(`../../utils/solanaMint.utils.cjs`),s=require(`./getInputUtxosEnclave.cjs`),c=require(`../../utils/
|
|
1
|
+
require(`../../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../../constants/chains.constants.cjs`),t=require(`../../utils/caseInsensitive.utils.cjs`),n=require(`../../../data-structures/utxo/Utxo.cjs`),r=require(`../../utils/upToDateState.cjs`),i=require(`../../utils/cacheFunctions.cjs`),a=require(`../../utils/encodeTokenWithId.cjs`),o=require(`../../utils/solanaMint.utils.cjs`),s=require(`./getInputUtxosEnclave.cjs`),c=require(`../../utils/customEnclaveFunctionsRegister.cjs`),l=require(`../../utils/addresses.cjs`),u=require(`../../../API/scheduled-transactions-calls.cjs`),d=require(`../../utils/tron.utils.cjs`);var f=new(require(`async-mutex`)).Mutex,p=async(e,t)=>e.allowParallelBalanceLocalDecryption?t():f.runExclusive(t),m=e=>e?.[0]===0n&&e?.[1]===1n,h=async(e,t,n,a,o,s,c,l,u)=>p(e,async()=>{u+=1;let d=s.slice(u),{lastOutput:f,additionalEncryptedOutputs:p}=await e.utxoUtils.batchProcess(d,l,t,n),m=[...c,...p];return await r.checkAddressNotUpdated(e,a),i.setHinkalCache({lastOutput:f,encryptedOutputs:m},e,n,o),await e.utxoUtils.buildBatchProcess(m,t,n)}),g=async(e,t,n,r,a,o,c,l,u,d)=>{try{let{utxos:r,encryptedOutputs:o,lastOutput:c}=await s.getInputUtxosEnclave(n,t,d);return i.setHinkalCache({encryptedOutputs:o,lastOutput:c},e,n,a),r}catch{return h(e,t,n,r,a,o,c,l,u)}},_=e=>{if(Array.isArray(e))return e;if(e!==void 0)return[e]},v=async(e,t,n)=>await e.utxoUtils.batchFilterUtxosWithNullifier(t,n),y=(e,t,r,i,a,o,s)=>{for(e.sort((e,t)=>e.amount<=t.amount?1:-1);e.length<t||e.length>t&&e.length<6;)if(e.push(new n.Utxo({amount:0n,erc20TokenAddress:o,mintAddress:s,nullifyingKey:i,spendingPublicKey:a})),r)for(;e.length>6;)e.splice(e.length-1)},b=async({hinkal:e,chainId:t,passedShieldedPublicKey:n=void 0,ethAddress:a=void 0,resetCacheBefore:o=!1,useBlockedUtxos:s=!1})=>{let l=a??await e.getEthereumAddress(),u=n??e.userKeys.getShieldedPublicKey(),{userKeys:d}=e,f=e.encryptedOutputsByChain[t],p=e.nullifiersByChain[t],_=Array.from(f);o&&i.resetCache(e,t,u);let{encryptedOutputs:y,lastOutput:b}=i.getHinkalCache(e,t,u);await r.checkAddressNotUpdated(e,l);let x=b!==``,S=_.findIndex(e=>e.value===b),C=S>-1,w=!x&&S===-1,T=e.areMerkleTreeUpdatesDisabled(),E=c.getCustomUtxoDecryptor(),D=!T&&(C||!E&&w),O=!T&&!!E&&w,k=!D&&!O,A=[];D?A=await h(e,d,t,l,u,_,y,b,S):O&&E?A=await g(e,d,t,l,u,_,y,b,S,E):k&&(A=await e.utxoUtils.buildBatchProcess(y,d,t)),await r.checkAddressNotUpdated(e,l);let j=await v(e,A,p);return{inputUtxos:(s?j.filter(e=>e.isBlocked):j.filter(e=>!e.isBlocked)).filter(e=>!m(e.H0))}},x=async({hinkal:t,chainId:n,passedShieldedPublicKey:r=void 0,ethAddress:i=void 0,resetCacheBefore:a=!1})=>{let o=i??await t.getEthereumAddressByChain(n),s=l.hashEthereumAddress(e.isTronLike(n)?d.addressToHexFormat(o):o),{inputUtxos:c}=await b({hinkal:t,chainId:n,passedShieldedPublicKey:r,ethAddress:o,resetCacheBefore:a,useBlockedUtxos:!0});if(!c.length)return{inputUtxos:[]};let{indexes:f}=await u.getScheduledTransactionsNullifierIndexes({hashedEthereumAddress:s,nullifiers:c.map(e=>e.getNullifier())});return{inputUtxos:f.map(e=>c[e]).filter(e=>!!e)}},S=async({hinkal:n,tokenWithId:r,minInput:i=2,sliceIfMore6:s=!0,chainId:c,passedShieldedPrivateKey:l=void 0,passedShieldedPublicKey:u=void 0,ethAddress:d=void 0,resetCacheBefore:f=!1,ensuredTokensWithId:p,useBlockedUtxos:m=!1})=>{let h=l??n.userKeys.getShieldedPrivateKey(),g=n.userKeys.getSpendingKeyPair().pubSpendingBJJPoint,{inputUtxos:v}=m?await x({hinkal:n,chainId:c,ethAddress:d,passedShieldedPrivateKey:l,resetCacheBefore:f}):await b({hinkal:n,tokenWithId:r,minInput:i,sliceIfMore6:s,chainId:c,passedShieldedPrivateKey:l,passedShieldedPublicKey:u,ethAddress:d,resetCacheBefore:f}),S=_(r),C=new Map;v.forEach(e=>{let n=e.getTokenAddress(c);if(S&&!S.some(e=>t.caseInsensitiveEqual(e,n)))return;let r=a.normalizeTokenAddress(c,n),i=C.get(r)??[];C.set(r,[...i,e])}),p?.forEach(e=>{let t=a.normalizeTokenAddress(c,e);C.set(t,C.get(t)??[])});for(let[t,n]of C){let r=t,a=e.isSolanaLike(c),l=a?r:void 0;y(n,i,s,h,g,a?o.formatMintAddress(r).compressedAddress.toLowerCase():r.toLowerCase(),l)}return C};exports.getInputUtxoAndBalance=b,exports.getInputUtxoAndBalanceOfStuckUtxos=x,exports.getInputUtxoAndBalancePerToken=S;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { IHinkal } from '../../../data-structures/Hinkal/IHinkal';
|
|
2
|
-
import { UserKeys } from '../../../data-structures/crypto-keys/keys';
|
|
3
2
|
import { Utxo } from '../../../data-structures/utxo/Utxo';
|
|
4
|
-
import { EncryptedOutputWithSign } from '../../../types/commitments.types';
|
|
5
3
|
interface IGetInputUtxos {
|
|
6
4
|
hinkal: IHinkal;
|
|
7
5
|
chainId: number;
|
|
@@ -12,12 +10,9 @@ interface IGetInputUtxos {
|
|
|
12
10
|
passedShieldedPublicKey?: string;
|
|
13
11
|
ethAddress?: string;
|
|
14
12
|
resetCacheBefore?: boolean;
|
|
15
|
-
allowRemoteDecryption?: boolean;
|
|
16
13
|
ensuredTokensWithId?: string[];
|
|
17
14
|
useBlockedUtxos?: boolean;
|
|
18
15
|
}
|
|
19
|
-
export declare const getInputUtxosRemotely: (hinkal: IHinkal, userKeys: UserKeys, currentChainId: number, shieldedPublicKey: string) => Promise<Utxo[]>;
|
|
20
|
-
export declare const attemptGetInputUtxosRemotely: (hinkal: IHinkal, userKeys: UserKeys, currentChainId: number, ethereumAddress: string, shieldedPublicKey: string, hinkalOutputs: EncryptedOutputWithSign<boolean>[], cachedEncryptedOutputs: EncryptedOutputWithSign<boolean>[], lastOutput: string, lastOutputIndex: number) => Promise<Utxo[]>;
|
|
21
16
|
/**
|
|
22
17
|
*
|
|
23
18
|
* @param hinkal instance of the hinkal class
|
|
@@ -26,11 +21,11 @@ export declare const attemptGetInputUtxosRemotely: (hinkal: IHinkal, userKeys: U
|
|
|
26
21
|
* @param sliceIfMore6 max upper bound on input UTXOs controller
|
|
27
22
|
* @returns UTXOs for particular erc20 token address
|
|
28
23
|
*/
|
|
29
|
-
export declare const getInputUtxoAndBalance: ({ hinkal, chainId, passedShieldedPublicKey, ethAddress, resetCacheBefore,
|
|
24
|
+
export declare const getInputUtxoAndBalance: ({ hinkal, chainId, passedShieldedPublicKey, ethAddress, resetCacheBefore, useBlockedUtxos, }: IGetInputUtxos) => Promise<{
|
|
30
25
|
inputUtxos: Utxo[];
|
|
31
26
|
}>;
|
|
32
|
-
export declare const getInputUtxoAndBalanceOfStuckUtxos: ({ hinkal, chainId, passedShieldedPublicKey, ethAddress, resetCacheBefore,
|
|
27
|
+
export declare const getInputUtxoAndBalanceOfStuckUtxos: ({ hinkal, chainId, passedShieldedPublicKey, ethAddress, resetCacheBefore, }: IGetInputUtxos) => Promise<{
|
|
33
28
|
inputUtxos: Utxo[];
|
|
34
29
|
}>;
|
|
35
|
-
export declare const getInputUtxoAndBalancePerToken: ({ hinkal, tokenWithId, minInput, sliceIfMore6, chainId, passedShieldedPrivateKey, passedShieldedPublicKey, ethAddress, resetCacheBefore, ensuredTokensWithId,
|
|
30
|
+
export declare const getInputUtxoAndBalancePerToken: ({ hinkal, tokenWithId, minInput, sliceIfMore6, chainId, passedShieldedPrivateKey, passedShieldedPublicKey, ethAddress, resetCacheBefore, ensuredTokensWithId, useBlockedUtxos, }: IGetInputUtxos) => Promise<Map<string, Utxo[]>>;
|
|
36
31
|
export {};
|
|
@@ -6,29 +6,28 @@ import { getHinkalCache as a, resetCache as o, setHinkalCache as s } from "../..
|
|
|
6
6
|
import { normalizeTokenAddress as c } from "../../utils/encodeTokenWithId.mjs";
|
|
7
7
|
import { formatMintAddress as l } from "../../utils/solanaMint.utils.mjs";
|
|
8
8
|
import { getInputUtxosEnclave as u } from "./getInputUtxosEnclave.mjs";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
9
|
+
import { getCustomUtxoDecryptor as d } from "../../utils/customEnclaveFunctionsRegister.mjs";
|
|
10
|
+
import { hashEthereumAddress as f } from "../../utils/addresses.mjs";
|
|
11
|
+
import { getScheduledTransactionsNullifierIndexes as p } from "../../../API/scheduled-transactions-calls.mjs";
|
|
12
|
+
import { addressToHexFormat as m } from "../../utils/tron.utils.mjs";
|
|
13
|
+
import { Mutex as h } from "async-mutex";
|
|
13
14
|
//#region libs/shared/common/src/functions/web3/events/getInputUtxoAndBalance.ts
|
|
14
|
-
var
|
|
15
|
+
var g = new h(), _ = async (e, t) => e.allowParallelBalanceLocalDecryption ? t() : g.runExclusive(t), v = (e) => e?.[0] === 0n && e?.[1] === 1n, y = async (e, t, n, r, a, o, c, l, u) => _(e, async () => {
|
|
15
16
|
u += 1;
|
|
16
17
|
let d = o.slice(u), { lastOutput: f, additionalEncryptedOutputs: p } = await e.utxoUtils.batchProcess(d, l, t, n), m = [...c, ...p];
|
|
17
18
|
return await i(e, r), s({
|
|
18
19
|
lastOutput: f,
|
|
19
20
|
encryptedOutputs: m
|
|
20
21
|
}, e, n, a), await e.utxoUtils.buildBatchProcess(m, t, n);
|
|
21
|
-
}),
|
|
22
|
-
let { utxos: i, encryptedOutputs: a, lastOutput: o } = await u(e, n, t);
|
|
23
|
-
return s({
|
|
24
|
-
encryptedOutputs: a,
|
|
25
|
-
lastOutput: o
|
|
26
|
-
}, e, n, r), i;
|
|
27
|
-
}, b = async (e, t, n, r, i, a, o, s, c) => {
|
|
22
|
+
}), b = async (e, t, n, r, i, a, o, c, l, d) => {
|
|
28
23
|
try {
|
|
29
|
-
|
|
24
|
+
let { utxos: r, encryptedOutputs: a, lastOutput: o } = await u(n, t, d);
|
|
25
|
+
return s({
|
|
26
|
+
encryptedOutputs: a,
|
|
27
|
+
lastOutput: o
|
|
28
|
+
}, e, n, i), r;
|
|
30
29
|
} catch {
|
|
31
|
-
return
|
|
30
|
+
return y(e, t, n, r, i, a, o, c, l);
|
|
32
31
|
}
|
|
33
32
|
}, x = (e) => {
|
|
34
33
|
if (Array.isArray(e)) return e;
|
|
@@ -41,39 +40,37 @@ var h = new m(), g = async (e, t) => e.allowParallelBalanceLocalDecryption ? t()
|
|
|
41
40
|
nullifyingKey: i,
|
|
42
41
|
spendingPublicKey: a
|
|
43
42
|
})), n) for (; e.length > 6;) e.splice(e.length - 1);
|
|
44
|
-
}, w = async ({ hinkal: e, chainId: t, passedShieldedPublicKey: n = void 0, ethAddress: r = void 0, resetCacheBefore: s = !1,
|
|
45
|
-
let
|
|
46
|
-
s && o(e, t,
|
|
47
|
-
let { encryptedOutputs: g, lastOutput:
|
|
48
|
-
await i(e,
|
|
49
|
-
let x =
|
|
50
|
-
|
|
51
|
-
let
|
|
52
|
-
return { inputUtxos: (
|
|
53
|
-
}, T = async ({ hinkal: e, chainId: n, passedShieldedPublicKey: r = void 0, ethAddress: i = void 0, resetCacheBefore: a = !1
|
|
54
|
-
let
|
|
43
|
+
}, w = async ({ hinkal: e, chainId: t, passedShieldedPublicKey: n = void 0, ethAddress: r = void 0, resetCacheBefore: s = !1, useBlockedUtxos: c = !1 }) => {
|
|
44
|
+
let l = r ?? await e.getEthereumAddress(), u = n ?? e.userKeys.getShieldedPublicKey(), { userKeys: f } = e, p = e.encryptedOutputsByChain[t], m = e.nullifiersByChain[t], h = Array.from(p);
|
|
45
|
+
s && o(e, t, u);
|
|
46
|
+
let { encryptedOutputs: g, lastOutput: _ } = a(e, t, u);
|
|
47
|
+
await i(e, l);
|
|
48
|
+
let x = _ !== "", C = h.findIndex((e) => e.value === _), w = C > -1, T = !x && C === -1, E = e.areMerkleTreeUpdatesDisabled(), D = d(), O = !E && (w || !D && T), k = !E && !!D && T, A = !O && !k, j = [];
|
|
49
|
+
O ? j = await y(e, f, t, l, u, h, g, _, C) : k && D ? j = await b(e, f, t, l, u, h, g, _, C, D) : A && (j = await e.utxoUtils.buildBatchProcess(g, f, t)), await i(e, l);
|
|
50
|
+
let M = await S(e, j, m);
|
|
51
|
+
return { inputUtxos: (c ? M.filter((e) => e.isBlocked) : M.filter((e) => !e.isBlocked)).filter((e) => !v(e.H0)) };
|
|
52
|
+
}, T = async ({ hinkal: e, chainId: n, passedShieldedPublicKey: r = void 0, ethAddress: i = void 0, resetCacheBefore: a = !1 }) => {
|
|
53
|
+
let o = i ?? await e.getEthereumAddressByChain(n), s = f(t(n) ? m(o) : o), { inputUtxos: c } = await w({
|
|
55
54
|
hinkal: e,
|
|
56
55
|
chainId: n,
|
|
57
56
|
passedShieldedPublicKey: r,
|
|
58
|
-
ethAddress:
|
|
57
|
+
ethAddress: o,
|
|
59
58
|
resetCacheBefore: a,
|
|
60
|
-
allowRemoteDecryption: o,
|
|
61
59
|
useBlockedUtxos: !0
|
|
62
60
|
});
|
|
63
|
-
if (!
|
|
64
|
-
let { indexes:
|
|
65
|
-
hashedEthereumAddress:
|
|
66
|
-
nullifiers:
|
|
61
|
+
if (!c.length) return { inputUtxos: [] };
|
|
62
|
+
let { indexes: l } = await p({
|
|
63
|
+
hashedEthereumAddress: s,
|
|
64
|
+
nullifiers: c.map((e) => e.getNullifier())
|
|
67
65
|
});
|
|
68
|
-
return { inputUtxos:
|
|
69
|
-
}, E = async ({ hinkal: t, tokenWithId: r, minInput: i = 2, sliceIfMore6: a = !0, chainId: o, passedShieldedPrivateKey: s = void 0, passedShieldedPublicKey: u = void 0, ethAddress: d = void 0, resetCacheBefore: f = !1, ensuredTokensWithId: p,
|
|
70
|
-
let
|
|
66
|
+
return { inputUtxos: l.map((e) => c[e]).filter((e) => !!e) };
|
|
67
|
+
}, E = async ({ hinkal: t, tokenWithId: r, minInput: i = 2, sliceIfMore6: a = !0, chainId: o, passedShieldedPrivateKey: s = void 0, passedShieldedPublicKey: u = void 0, ethAddress: d = void 0, resetCacheBefore: f = !1, ensuredTokensWithId: p, useBlockedUtxos: m = !1 }) => {
|
|
68
|
+
let h = s ?? t.userKeys.getShieldedPrivateKey(), g = t.userKeys.getSpendingKeyPair().pubSpendingBJJPoint, { inputUtxos: _ } = m ? await T({
|
|
71
69
|
hinkal: t,
|
|
72
70
|
chainId: o,
|
|
73
71
|
ethAddress: d,
|
|
74
72
|
passedShieldedPrivateKey: s,
|
|
75
|
-
resetCacheBefore: f
|
|
76
|
-
allowRemoteDecryption: m
|
|
73
|
+
resetCacheBefore: f
|
|
77
74
|
}) : await w({
|
|
78
75
|
hinkal: t,
|
|
79
76
|
tokenWithId: r,
|
|
@@ -83,23 +80,22 @@ var h = new m(), g = async (e, t) => e.allowParallelBalanceLocalDecryption ? t()
|
|
|
83
80
|
passedShieldedPrivateKey: s,
|
|
84
81
|
passedShieldedPublicKey: u,
|
|
85
82
|
ethAddress: d,
|
|
86
|
-
resetCacheBefore: f
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
v.forEach((e) => {
|
|
83
|
+
resetCacheBefore: f
|
|
84
|
+
}), v = x(r), y = /* @__PURE__ */ new Map();
|
|
85
|
+
_.forEach((e) => {
|
|
90
86
|
let t = e.getTokenAddress(o);
|
|
91
|
-
if (
|
|
92
|
-
let r = c(o, t), i =
|
|
93
|
-
|
|
87
|
+
if (v && !v.some((e) => n(e, t))) return;
|
|
88
|
+
let r = c(o, t), i = y.get(r) ?? [];
|
|
89
|
+
y.set(r, [...i, e]);
|
|
94
90
|
}), p?.forEach((e) => {
|
|
95
91
|
let t = c(o, e);
|
|
96
|
-
|
|
92
|
+
y.set(t, y.get(t) ?? []);
|
|
97
93
|
});
|
|
98
|
-
for (let [t, n] of
|
|
94
|
+
for (let [t, n] of y) {
|
|
99
95
|
let r = t, s = e(o), c = s ? r : void 0;
|
|
100
|
-
C(n, i, a,
|
|
96
|
+
C(n, i, a, h, g, s ? l(r).compressedAddress.toLowerCase() : r.toLowerCase(), c);
|
|
101
97
|
}
|
|
102
|
-
return
|
|
98
|
+
return y;
|
|
103
99
|
};
|
|
104
100
|
//#endregion
|
|
105
|
-
export {
|
|
101
|
+
export { w as getInputUtxoAndBalance, T as getInputUtxoAndBalanceOfStuckUtxos, E as getInputUtxoAndBalancePerToken };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../../constants/chains.constants.cjs`),t=require(`../../../data-structures/crypto-keys/keys.cjs`),n=require(`../../../data-structures/utxo/Utxo.cjs`),r=require(`../../utils/
|
|
1
|
+
require(`../../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../../constants/chains.constants.cjs`),t=require(`../../../data-structures/crypto-keys/keys.cjs`),n=require(`../../../data-structures/utxo/Utxo.cjs`),r=require(`../../utils/encodeTokenWithId.cjs`),i=require(`../../utils/encryptInputForEnclave.cjs`),a=require(`../../utils/solanaMint.utils.cjs`),o=require(`../../utils/serialize-utxos.utils.cjs`);let s=require(`ethers`),c=require(`@solana/web3.js`);var l=e=>{if(!e)return;let t=s.ethers.getBytes(e);if(t.length!==32)return;let n=new c.PublicKey(t),r=n.toBase58(),{compressedAddress:i}=a.formatMintAddress(n);return{mintBase58:r,compressedAddress:i}},u=async(r,i,a)=>{let c=i.getShieldedPrivateKey(),{privateKey:u,publicKey:d}=t.UserKeys.getEncryptionKeyPair(c),f=i.getSpendingKeyPair().pubSpendingBJJPoint,p=s.ethers.solidityPacked([`uint256`,`uint256`,`uint256`],[d,u,c]),{utxos:m,lastOutput:h,encryptedOutputs:g}=await a(r,s.ethers.getBytes(p));return{utxos:m.map(t=>{let i=t;if(e.isSolanaLike(r)){let e=l(t.mintAddress);if(!e)throw Error(`Invalid mint address`);i={...i,erc20TokenAddress:e.compressedAddress,mintAddress:e.mintBase58}}return new n.Utxo({...o.deserializeUtxoConstructorParams(i),nullifyingKey:c,spendingPublicKey:f})}),encryptedOutputs:g,lastOutput:h}},d=(t,n)=>{if(e.isSolanaLike(t)){let e=l(n);if(!e)throw Error(`Invalid mint address in enclave balance: ${n}`);return r.normalizeTokenAddress(t,e.mintBase58)}return r.normalizeTokenAddress(t,n.startsWith(`0x`)?n:s.ethers.toBeHex(BigInt(n),20))},f=async(e,t,n,r=!1,a)=>{let{keyCiphertext:o,inputCiphertext:c}=await i.makeEnclaveHandshakeAndEncryptUint8Array(s.ethers.getBytes(s.ethers.solidityPacked([`uint256`],[n]))),{preConfirmedBalances:l}=await e.getAPI().getBalancesEnclaveCall(t,o,c,r,a),u=new Map;return l.forEach(({erc20TokenAddress:e,amount:n})=>{u.set(d(t,e),BigInt(n))}),u};exports.getInputUtxosEnclave=u,exports.getRemoteManagedTokenBalances=f;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { IHinkal } from '../../../data-structures/Hinkal/IHinkal';
|
|
2
2
|
import { Utxo } from '../../../data-structures/utxo/Utxo';
|
|
3
3
|
import { UserKeys } from '../../../data-structures/crypto-keys/keys';
|
|
4
|
-
import {
|
|
5
|
-
export declare const getInputUtxosEnclave: (
|
|
4
|
+
import { UtxoDecryptorFn } from '../../utils/customEnclaveFunctionsRegister';
|
|
5
|
+
export declare const getInputUtxosEnclave: (chainId: number, userKeys: UserKeys, decrypt: UtxoDecryptorFn) => Promise<{
|
|
6
6
|
utxos: Utxo[];
|
|
7
|
-
encryptedOutputs: EncryptedOutputWithSign<boolean>[];
|
|
7
|
+
encryptedOutputs: import('../../..').EncryptedOutputWithSign<boolean>[];
|
|
8
8
|
lastOutput: string;
|
|
9
9
|
}>;
|
|
10
|
+
export declare const getRemoteManagedTokenBalances: (hinkal: IHinkal, chainId: number, shieldedPrivateKey: string, useBlockedUtxos?: boolean, hashedEthereumAddress?: string) => Promise<Map<string, bigint>>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { isSolanaLike as e } from "../../../constants/chains.constants.mjs";
|
|
2
2
|
import { UserKeys as t } from "../../../data-structures/crypto-keys/keys.mjs";
|
|
3
3
|
import { Utxo as n } from "../../../data-structures/utxo/Utxo.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { normalizeTokenAddress as r } from "../../utils/encodeTokenWithId.mjs";
|
|
5
|
+
import { makeEnclaveHandshakeAndEncryptUint8Array as i } from "../../utils/encryptInputForEnclave.mjs";
|
|
6
|
+
import { formatMintAddress as a } from "../../utils/solanaMint.utils.mjs";
|
|
7
7
|
import { deserializeUtxoConstructorParams as o } from "../../utils/serialize-utxos.utils.mjs";
|
|
8
8
|
import { ethers as s } from "ethers";
|
|
9
9
|
import { PublicKey as c } from "@solana/web3.js";
|
|
@@ -12,45 +12,54 @@ var l = (e) => {
|
|
|
12
12
|
if (!e) return;
|
|
13
13
|
let t = s.getBytes(e);
|
|
14
14
|
if (t.length !== 32) return;
|
|
15
|
-
let n = new c(t), r = n.toBase58(), { compressedAddress:
|
|
15
|
+
let n = new c(t), r = n.toBase58(), { compressedAddress: i } = a(n);
|
|
16
16
|
return {
|
|
17
17
|
mintBase58: r,
|
|
18
|
-
compressedAddress:
|
|
18
|
+
compressedAddress: i
|
|
19
19
|
};
|
|
20
|
-
}, u = async (
|
|
21
|
-
let {
|
|
22
|
-
return e.getAPI().decryptUtxoEnclaveCall(t, i, a);
|
|
23
|
-
}, d = async (r, i, c) => {
|
|
24
|
-
let d = c.getShieldedPrivateKey(), { privateKey: f, publicKey: p } = t.getEncryptionKeyPair(d), m = c.getSpendingKeyPair().pubSpendingBJJPoint, h = s.solidityPacked([
|
|
20
|
+
}, u = async (r, i, a) => {
|
|
21
|
+
let c = i.getShieldedPrivateKey(), { privateKey: u, publicKey: d } = t.getEncryptionKeyPair(c), f = i.getSpendingKeyPair().pubSpendingBJJPoint, p = s.solidityPacked([
|
|
25
22
|
"uint256",
|
|
26
23
|
"uint256",
|
|
27
24
|
"uint256"
|
|
28
25
|
], [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
]),
|
|
26
|
+
d,
|
|
27
|
+
u,
|
|
28
|
+
c
|
|
29
|
+
]), { utxos: m, lastOutput: h, encryptedOutputs: g } = await a(r, s.getBytes(p));
|
|
33
30
|
return {
|
|
34
|
-
utxos:
|
|
35
|
-
let
|
|
36
|
-
if (e(
|
|
31
|
+
utxos: m.map((t) => {
|
|
32
|
+
let i = t;
|
|
33
|
+
if (e(r)) {
|
|
37
34
|
let e = l(t.mintAddress);
|
|
38
35
|
if (!e) throw Error("Invalid mint address");
|
|
39
|
-
|
|
40
|
-
...
|
|
36
|
+
i = {
|
|
37
|
+
...i,
|
|
41
38
|
erc20TokenAddress: e.compressedAddress,
|
|
42
39
|
mintAddress: e.mintBase58
|
|
43
40
|
};
|
|
44
41
|
}
|
|
45
42
|
return new n({
|
|
46
|
-
...o(
|
|
47
|
-
nullifyingKey:
|
|
48
|
-
spendingPublicKey:
|
|
43
|
+
...o(i),
|
|
44
|
+
nullifyingKey: c,
|
|
45
|
+
spendingPublicKey: f
|
|
49
46
|
});
|
|
50
47
|
}),
|
|
51
|
-
encryptedOutputs:
|
|
52
|
-
lastOutput:
|
|
48
|
+
encryptedOutputs: g,
|
|
49
|
+
lastOutput: h
|
|
53
50
|
};
|
|
51
|
+
}, d = (t, n) => {
|
|
52
|
+
if (e(t)) {
|
|
53
|
+
let e = l(n);
|
|
54
|
+
if (!e) throw Error(`Invalid mint address in enclave balance: ${n}`);
|
|
55
|
+
return r(t, e.mintBase58);
|
|
56
|
+
}
|
|
57
|
+
return r(t, n.startsWith("0x") ? n : s.toBeHex(BigInt(n), 20));
|
|
58
|
+
}, f = async (e, t, n, r = !1, a) => {
|
|
59
|
+
let { keyCiphertext: o, inputCiphertext: c } = await i(s.getBytes(s.solidityPacked(["uint256"], [n]))), { preConfirmedBalances: l } = await e.getAPI().getBalancesEnclaveCall(t, o, c, r, a), u = /* @__PURE__ */ new Map();
|
|
60
|
+
return l.forEach(({ erc20TokenAddress: e, amount: n }) => {
|
|
61
|
+
u.set(d(t, e), BigInt(n));
|
|
62
|
+
}), u;
|
|
54
63
|
};
|
|
55
64
|
//#endregion
|
|
56
|
-
export {
|
|
65
|
+
export { u as getInputUtxosEnclave, f as getRemoteManagedTokenBalances };
|