@hinkal/common 0.3.6 → 0.3.8
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 +1 -0
- package/common/src/API/API.cjs +1 -1
- package/common/src/API/API.d.ts +6 -5
- package/common/src/API/API.mjs +75 -74
- package/common/src/API/admin-calls.cjs +1 -1
- package/common/src/API/admin-calls.d.ts +1 -1
- package/common/src/API/admin-calls.mjs +3 -1
- package/common/src/API/callLifiAPI.d.ts +1 -0
- package/common/src/API/callNearIntentsAPI.cjs +1 -1
- package/common/src/API/callNearIntentsAPI.mjs +2 -2
- package/common/src/API/callRelayer.cjs +1 -1
- package/common/src/API/callRelayer.d.ts +32 -1
- package/common/src/API/callRelayer.mjs +7 -1
- package/common/src/API/enclaveUtxoCalls.cjs +1 -1
- package/common/src/API/enclaveUtxoCalls.d.ts +16 -16
- package/common/src/API/enclaveUtxoCalls.mjs +3 -3
- package/common/src/API/evm-rpc-fallback.cjs +1 -0
- package/common/src/API/evm-rpc-fallback.d.ts +1 -0
- package/common/src/API/evm-rpc-fallback.mjs +17 -0
- package/common/src/API/evm-token-assets.cjs +1 -0
- package/common/src/API/evm-token-assets.d.ts +8 -0
- package/common/src/API/evm-token-assets.mjs +20 -0
- package/common/src/API/index.cjs +1 -1
- package/common/src/API/index.d.ts +1 -0
- package/common/src/API/index.mjs +1 -0
- package/common/src/API/route-config.cjs +1 -0
- package/common/src/API/route-config.d.ts +1 -0
- package/common/src/API/route-config.mjs +26 -0
- package/common/src/API/solana-nft-assets.cjs +1 -0
- package/common/src/API/solana-nft-assets.d.ts +1 -0
- package/common/src/API/solana-nft-assets.mjs +11 -0
- package/common/src/API/solana-priority-fee.cjs +1 -0
- package/common/src/API/solana-priority-fee.d.ts +3 -0
- package/common/src/API/solana-priority-fee.mjs +20 -0
- package/common/src/API/solana-rpc-fallback.cjs +1 -0
- package/common/src/API/solana-rpc-fallback.d.ts +1 -0
- package/common/src/API/solana-rpc-fallback.mjs +13 -0
- package/common/src/API/temporaryWalletCalls.cjs +1 -1
- package/common/src/API/temporaryWalletCalls.d.ts +0 -4
- package/common/src/API/temporaryWalletCalls.mjs +1 -5
- package/common/src/constants/balance.constants.d.ts +2 -0
- package/common/src/constants/bridging.constants.d.ts +1 -0
- package/common/src/constants/chains.constants.cjs +1 -1
- package/common/src/constants/chains.constants.d.ts +0 -3
- package/common/src/constants/chains.constants.mjs +33 -54
- package/common/src/constants/coingecko.constants.cjs +1 -1
- 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 +1 -0
- package/common/src/constants/contracts.constants.mjs +19 -15
- package/common/src/constants/deploy-data/deploy-data-arbMainnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-arbMainnet.json.mjs +3 -2
- package/common/src/constants/deploy-data/deploy-data-arcTestnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-arcTestnet.json.mjs +3 -2
- package/common/src/constants/deploy-data/deploy-data-base.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-base.json.mjs +3 -2
- package/common/src/constants/deploy-data/deploy-data-bnbMainnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-bnbMainnet.json.mjs +3 -2
- package/common/src/constants/deploy-data/deploy-data-ethMainnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-ethMainnet.json.mjs +3 -2
- package/common/src/constants/deploy-data/deploy-data-optimism.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-optimism.json.mjs +7 -6
- package/common/src/constants/deploy-data/deploy-data-polygon.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-polygon.json.mjs +3 -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 +3 -2
- package/common/src/constants/deploy-data/shared-deploy-data-evm.json.cjs +1 -1
- package/common/src/constants/deploy-data/shared-deploy-data-evm.json.mjs +18 -1
- 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/okx.constants.d.ts +1 -0
- package/common/src/constants/protocol.constants.cjs +2 -2
- package/common/src/constants/protocol.constants.d.ts +4 -1
- package/common/src/constants/protocol.constants.mjs +3 -8
- package/common/src/constants/server.constants.cjs +1 -1
- package/common/src/constants/server.constants.d.ts +7 -2
- package/common/src/constants/server.constants.mjs +8 -3
- package/common/src/constants/vite.constants.cjs +1 -1
- package/common/src/constants/vite.constants.mjs +5 -23
- package/common/src/data-structures/ApprovalDBs/EventsPublicApprovalsDB.d.ts +1 -2
- package/common/src/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/common/src/data-structures/Hinkal/Hinkal.d.ts +4 -4
- package/common/src/data-structures/Hinkal/Hinkal.mjs +39 -39
- package/common/src/data-structures/Hinkal/IHinkal.d.ts +4 -4
- package/common/src/data-structures/Hinkal/hinkalActionReceive.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalActionReceive.mjs +11 -9
- package/common/src/data-structures/Hinkal/hinkalBridgePrivateToPrivate.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalBridgePrivateToPrivate.d.ts +2 -1
- package/common/src/data-structures/Hinkal/hinkalBridgePrivateToPrivate.mjs +81 -90
- package/common/src/data-structures/Hinkal/hinkalClaimUtxo.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalClaimUtxo.d.ts +1 -1
- package/common/src/data-structures/Hinkal/hinkalClaimUtxo.mjs +3 -5
- package/common/src/data-structures/Hinkal/hinkalDepositAndBridge.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDepositAndBridge.mjs +100 -104
- package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.d.ts +1 -1
- package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +86 -93
- package/common/src/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDepositOnChainUtxos.d.ts +20 -7
- package/common/src/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +51 -39
- package/common/src/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalPrivateWallet.mjs +2 -2
- package/common/src/data-structures/Hinkal/hinkalProxyToPrivate.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalProxyToPrivate.mjs +15 -13
- package/common/src/data-structures/Hinkal/hinkalSolanaClaimUtxo.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaClaimUtxo.d.ts +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaClaimUtxo.mjs +3 -5
- package/common/src/data-structures/Hinkal/hinkalSolanaDeposit.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaDeposit.mjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.d.ts +2 -2
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +88 -121
- package/common/src/data-structures/Hinkal/hinkalSolanaProxySend.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaProxySend.mjs +1 -3
- package/common/src/data-structures/Hinkal/hinkalSolanaProxyShield.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaProxyShield.d.ts +24 -2
- package/common/src/data-structures/Hinkal/hinkalSolanaProxyShield.mjs +77 -58
- package/common/src/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +1 -3
- package/common/src/data-structures/Hinkal/hinkalSolanaSponsoredProxySend.d.ts +5 -0
- package/common/src/data-structures/Hinkal/hinkalSolanaSponsoredShield.cjs +1 -0
- package/common/src/data-structures/Hinkal/hinkalSolanaSponsoredShield.d.ts +8 -0
- package/common/src/data-structures/Hinkal/hinkalSolanaSponsoredShield.mjs +31 -0
- package/common/src/data-structures/Hinkal/hinkalSolanaTransact.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaTransact.mjs +44 -42
- package/common/src/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaWithdraw.d.ts +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +29 -24
- package/common/src/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSwap.d.ts +1 -1
- package/common/src/data-structures/Hinkal/hinkalSwap.mjs +27 -24
- package/common/src/data-structures/Hinkal/hinkalTransact.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalTransact.mjs +73 -56
- package/common/src/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalWithdraw.d.ts +1 -1
- package/common/src/data-structures/Hinkal/hinkalWithdraw.mjs +21 -18
- package/common/src/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +19 -18
- package/common/src/data-structures/Hinkal/index.d.ts +2 -0
- package/common/src/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/common/src/data-structures/Hinkal/resetMerkleTrees.mjs +2 -2
- package/common/src/data-structures/TokenDBs/AlchemyPublicTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/AlchemyPublicTokensDB.d.ts +0 -1
- package/common/src/data-structures/TokenDBs/AlchemyPublicTokensDB.mjs +55 -119
- package/common/src/data-structures/crypto-keys/decodeUTXO.cjs +1 -1
- package/common/src/data-structures/crypto-keys/decodeUTXO.mjs +11 -61
- package/common/src/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
- package/common/src/data-structures/event-service/evm/BlockchainEventEmitter.d.ts +2 -0
- package/common/src/data-structures/event-service/evm/BlockchainEventEmitter.mjs +41 -27
- package/common/src/data-structures/merkle-tree/MerkleTree.cjs +1 -1
- package/common/src/data-structures/merkle-tree/MerkleTree.d.ts +1 -0
- package/common/src/data-structures/merkle-tree/MerkleTree.mjs +3 -0
- package/common/src/error-handling/get-error.message.cjs +1 -1
- package/common/src/error-handling/get-error.message.mjs +1 -4
- package/common/src/functions/index.cjs +1 -1
- package/common/src/functions/index.mjs +9 -6
- package/common/src/functions/pre-transaction/calculateSolanaNullifierCount.cjs +1 -1
- package/common/src/functions/pre-transaction/calculateSolanaNullifierCount.mjs +2 -3
- package/common/src/functions/pre-transaction/index.cjs +1 -1
- package/common/src/functions/pre-transaction/index.d.ts +1 -0
- package/common/src/functions/pre-transaction/index.mjs +1 -1
- package/common/src/functions/pre-transaction/merge-with-fee-structure-emporium.cjs +1 -1
- package/common/src/functions/pre-transaction/merge-with-fee-structure-emporium.mjs +2 -2
- package/common/src/functions/pre-transaction/sendV0Transaction.cjs +2 -2
- package/common/src/functions/pre-transaction/sendV0Transaction.d.ts +5 -2
- package/common/src/functions/pre-transaction/sendV0Transaction.mjs +4 -4
- package/common/src/functions/pre-transaction/solanaTransfer.utils.cjs +1 -1
- package/common/src/functions/pre-transaction/solanaTransfer.utils.mjs +16 -15
- package/common/src/functions/pre-transaction/speculativeUtxo.cjs +1 -0
- package/common/src/functions/pre-transaction/speculativeUtxo.d.ts +9 -0
- package/common/src/functions/pre-transaction/speculativeUtxo.mjs +19 -0
- package/common/src/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/common/src/functions/private-wallet/emporium.helpers.d.ts +9 -2
- package/common/src/functions/private-wallet/emporium.helpers.mjs +93 -74
- package/common/src/functions/snarkjs/common.snarkjs.cjs +1 -1
- package/common/src/functions/snarkjs/common.snarkjs.d.ts +1 -0
- package/common/src/functions/snarkjs/common.snarkjs.mjs +36 -32
- package/common/src/functions/snarkjs/constant.cjs +1 -1
- package/common/src/functions/snarkjs/constant.d.ts +48 -0
- package/common/src/functions/snarkjs/constant.mjs +48 -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 +75 -71
- package/common/src/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/common/src/functions/snarkjs/constructSolanaZkProof.d.ts +1 -1
- package/common/src/functions/snarkjs/constructSolanaZkProof.mjs +27 -27
- package/common/src/functions/snarkjs/constructTxEnclave.cjs +1 -1
- package/common/src/functions/snarkjs/constructTxEnclave.mjs +8 -3
- package/common/src/functions/snarkjs/fetchOnChainRootHashes.cjs +1 -1
- package/common/src/functions/snarkjs/fetchOnChainRootHashes.mjs +10 -21
- package/common/src/functions/snarkjs/getMerkleTreeSiblingsAndRootHashes.cjs +1 -1
- package/common/src/functions/snarkjs/getMerkleTreeSiblingsAndRootHashes.d.ts +2 -2
- package/common/src/functions/snarkjs/getMerkleTreeSiblingsAndRootHashes.mjs +3 -3
- package/common/src/functions/snarkjs/signedMessageHash.cjs +1 -1
- package/common/src/functions/snarkjs/signedMessageHash.d.ts +4 -0
- package/common/src/functions/snarkjs/signedMessageHash.mjs +27 -18
- package/common/src/functions/utils/addresses.cjs +1 -1
- package/common/src/functions/utils/addresses.mjs +19 -12
- package/common/src/functions/utils/bridge-arrival.utils.cjs +1 -0
- package/common/src/functions/utils/bridge-arrival.utils.d.ts +1 -0
- package/common/src/functions/utils/bridge-arrival.utils.mjs +15 -0
- package/common/src/functions/utils/bridge-claimable-utxo.utils.cjs +1 -0
- package/common/src/functions/utils/bridge-claimable-utxo.utils.d.ts +19 -0
- package/common/src/functions/utils/bridge-claimable-utxo.utils.mjs +24 -0
- package/common/src/functions/utils/bridge-claimable.utils.d.ts +2 -3
- package/common/src/functions/utils/create-provider.cjs +1 -1
- package/common/src/functions/utils/create-provider.d.ts +9 -2
- package/common/src/functions/utils/create-provider.mjs +42 -9
- package/common/src/functions/utils/deposit-claimable.utils.cjs +1 -1
- package/common/src/functions/utils/deposit-claimable.utils.d.ts +2 -5
- package/common/src/functions/utils/deposit-claimable.utils.mjs +1 -6
- package/common/src/functions/utils/enclave-utxo-storage.cjs +1 -1
- package/common/src/functions/utils/enclave-utxo-storage.d.ts +4 -8
- package/common/src/functions/utils/enclave-utxo-storage.mjs +13 -2
- package/common/src/functions/utils/fees.utils.cjs +1 -1
- package/common/src/functions/utils/fees.utils.d.ts +2 -0
- package/common/src/functions/utils/fees.utils.mjs +15 -6
- package/common/src/functions/utils/getUtxosFromReceipt.utils.cjs +1 -1
- package/common/src/functions/utils/getUtxosFromReceipt.utils.d.ts +1 -1
- package/common/src/functions/utils/getUtxosFromReceipt.utils.mjs +5 -51
- package/common/src/functions/utils/getUtxosFromReceiptSolana.cjs +1 -1
- package/common/src/functions/utils/getUtxosFromReceiptSolana.mjs +7 -23
- package/common/src/functions/utils/index.cjs +1 -1
- package/common/src/functions/utils/index.d.ts +6 -0
- package/common/src/functions/utils/index.mjs +10 -4
- package/common/src/functions/utils/nearIntents.utils.cjs +1 -1
- package/common/src/functions/utils/nearIntents.utils.mjs +27 -13
- package/common/src/functions/utils/publicBalance.utils.cjs +1 -1
- package/common/src/functions/utils/publicBalance.utils.d.ts +0 -1
- package/common/src/functions/utils/publicBalance.utils.mjs +35 -22
- package/common/src/functions/utils/recovery-balance.utils.cjs +1 -0
- package/common/src/functions/utils/recovery-balance.utils.d.ts +2 -0
- package/common/src/functions/utils/recovery-balance.utils.mjs +1 -0
- package/common/src/functions/utils/solana-program.utils.cjs +1 -0
- package/common/src/functions/utils/solana-program.utils.d.ts +3 -0
- package/common/src/functions/utils/solana-program.utils.mjs +17 -0
- package/common/src/functions/utils/solana-sponsored.utils.cjs +1 -0
- package/common/src/functions/utils/solana-sponsored.utils.d.ts +22 -0
- package/common/src/functions/utils/solana-sponsored.utils.mjs +30 -0
- package/common/src/functions/utils/solanaMint.utils.cjs +1 -1
- package/common/src/functions/utils/solanaMint.utils.d.ts +7 -0
- package/common/src/functions/utils/solanaMint.utils.mjs +18 -8
- package/common/src/functions/utils/sponsored-shield.utils.cjs +1 -0
- package/common/src/functions/utils/sponsored-shield.utils.d.ts +3 -0
- package/common/src/functions/utils/sponsored-shield.utils.mjs +3 -0
- package/common/src/functions/utils/temp-wallet.utils.cjs +1 -1
- package/common/src/functions/utils/temp-wallet.utils.d.ts +5 -4
- package/common/src/functions/utils/temp-wallet.utils.mjs +35 -14
- package/common/src/functions/utils/transfer-claimable.utils.cjs +1 -1
- package/common/src/functions/utils/transfer-claimable.utils.d.ts +1 -2
- package/common/src/functions/utils/transfer-claimable.utils.mjs +2 -5
- package/common/src/functions/utils/tron.utils.cjs +1 -1
- package/common/src/functions/utils/tron.utils.d.ts +2 -2
- package/common/src/functions/utils/tron.utils.mjs +19 -18
- package/common/src/functions/utils/tronSimulation.utils.cjs +1 -1
- package/common/src/functions/utils/tronSimulation.utils.mjs +4 -6
- package/common/src/functions/utils/tx-confirmation.utils.cjs +1 -1
- package/common/src/functions/utils/tx-confirmation.utils.mjs +1 -1
- package/common/src/functions/web3/events/getInputUtxosEnclave.cjs +1 -1
- package/common/src/functions/web3/events/getInputUtxosEnclave.mjs +15 -25
- package/common/src/functions/web3/functionCalls/submitProof.cjs +1 -1
- package/common/src/functions/web3/functionCalls/submitProof.mjs +6 -6
- package/common/src/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/common/src/functions/web3/functionCalls/transactCallRelayer.d.ts +2 -2
- package/common/src/functions/web3/functionCalls/transactCallRelayer.mjs +8 -6
- package/common/src/functions/web3/getContractMetadata.cjs +1 -1
- package/common/src/functions/web3/getContractMetadata.mjs +1 -1
- package/common/src/functions/web3/getPublicAddressBalance.cjs +1 -1
- package/common/src/functions/web3/getPublicAddressBalance.d.ts +1 -2
- package/common/src/functions/web3/getPublicAddressBalance.mjs +6 -5
- package/common/src/functions/web3/index.cjs +1 -1
- package/common/src/functions/web3/index.d.ts +1 -1
- package/common/src/functions/web3/index.mjs +1 -1
- package/common/src/providers/SolanaProviderAdapter.cjs +1 -1
- package/common/src/providers/SolanaProviderAdapter.mjs +1 -2
- package/common/src/providers/WagmiProviderAdapter.cjs +1 -1
- package/common/src/providers/WagmiProviderAdapter.mjs +35 -38
- package/common/src/types/bridging-tx.types.d.ts +1 -4
- package/common/src/types/cache.types.cjs +1 -1
- package/common/src/types/cache.types.d.ts +0 -1
- package/common/src/types/cache.types.mjs +1 -1
- package/common/src/types/ethereum-network.types.cjs +1 -1
- package/common/src/types/ethereum-network.types.d.ts +9 -7
- 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 +1 -0
- package/common/src/types/external-action.types.mjs +1 -1
- package/common/src/types/index.cjs +1 -1
- package/common/src/types/index.d.ts +1 -1
- package/common/src/types/index.mjs +1 -1
- package/common/src/types/pay-activities.types.d.ts +3 -1
- package/common/src/types/remote-tx-build.types.d.ts +23 -0
- package/common/src/types/scheduled-transactions.types.d.ts +4 -12
- package/common/src/types/solana.types.cjs +1 -0
- package/common/src/types/solana.types.d.ts +5 -0
- package/common/src/types/solana.types.mjs +6 -0
- package/common/src/types/temp-wallet.types.d.ts +9 -0
- package/common/src/types/token.types.d.ts +1 -0
- package/common/src/webworker/logError-RKYfeI6h.js +2 -0
- package/common/src/webworker/package.json +20 -20
- 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 +28 -1
- package/common/src/webworker/viteWorkerURL.constant.mjs +27 -13
- package/common/src/webworker/workerProxy-COB7g4Qc.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/package.json +20 -20
- package/services/Hinkal.cjs +1 -1
- package/services/Hinkal.d.ts +2 -2
- package/services/Hinkal.mjs +3 -3
- package/types/IHinkal.d.ts +2 -2
- package/assets/snarkjsWorkerLauncher-SrStwJvX.js +0 -1
- package/assets/snarkjsWorkerLogic-DtIjisbE.js +0 -132
- package/assets/utxoWorkerLauncher-CIBeBAML.js +0 -1
- package/assets/utxoWorkerLogic-C8R4GSaf.js +0 -199
- package/assets/zkProofWorkerLauncher-DfwteloJ.js +0 -1
- package/assets/zkProofWorkerLogic-CY9y6rOV.js +0 -199
- package/common/src/API/deposit-and-withdraw-status-calls.cjs +0 -1
- package/common/src/API/deposit-and-withdraw-status-calls.d.ts +0 -21
- package/common/src/API/deposit-and-withdraw-status-calls.mjs +0 -13
- package/common/src/data-structures/Hinkal/hinkalTronDepositToSelf.cjs +0 -1
- package/common/src/data-structures/Hinkal/hinkalTronDepositToSelf.d.ts +0 -8
- package/common/src/data-structures/Hinkal/hinkalTronDepositToSelf.mjs +0 -30
- package/common/src/data-structures/Hinkal/prepareTronDepositToSelf.cjs +0 -1
- package/common/src/data-structures/Hinkal/prepareTronDepositToSelf.mjs +0 -31
- package/common/src/functions/pre-transaction/waitForDepositedUtxosInMerkleTree.cjs +0 -1
- package/common/src/functions/pre-transaction/waitForDepositedUtxosInMerkleTree.mjs +0 -29
- package/common/src/functions/utils/enum.utils.cjs +0 -1
- package/common/src/functions/utils/enum.utils.mjs +0 -12
- package/common/src/functions/web3/getSolanaPriorityFee.cjs +0 -1
- package/common/src/functions/web3/getSolanaPriorityFee.d.ts +0 -3
- package/common/src/functions/web3/getSolanaPriorityFee.mjs +0 -26
- package/common/src/types/scheduled-transactions.types.cjs +0 -1
- package/common/src/types/scheduled-transactions.types.mjs +0 -6
- package/common/src/webworker/logError-Dex6ch32.js +0 -2
- package/common/src/webworker/workerProxy-BuJUMCQ4.js +0 -1
|
@@ -4,117 +4,110 @@ import { caseInsensitiveEqual as n } from "../../functions/utils/caseInsensitive
|
|
|
4
4
|
import { transactionErrorCodes as r } from "../../error-handling/error-codes.constants.mjs";
|
|
5
5
|
import { Utxo as i } from "../utxo/Utxo.mjs";
|
|
6
6
|
import { hashEthereumAddress as a, hashString as o } from "../../functions/utils/addresses.mjs";
|
|
7
|
-
import { addressToHexFormat as s } from "../../functions/utils/tron.utils.mjs";
|
|
8
|
-
import { ExternalActionId as
|
|
9
|
-
import { DepositAndWithdrawPhase as l } from "../../types/scheduled-transactions.types.mjs";
|
|
7
|
+
import { addressToHexFormat as s, swapTronBCoordinate as c } from "../../functions/utils/tron.utils.mjs";
|
|
8
|
+
import { ExternalActionId as l } from "../../types/external-action.types.mjs";
|
|
10
9
|
import { SubmitMode as u } from "../../types/transact.types.mjs";
|
|
11
|
-
import "../../types/index.mjs";
|
|
12
10
|
import { validateAndGetChainId as d } from "../../functions/utils/token-check.utils.mjs";
|
|
13
11
|
import { decryptUtxo as f } from "../crypto-keys/encryptDecryptUtxo.mjs";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import { transactCallRelayerBatch as b } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
21
|
-
import { hinkalTransact as x } from "./hinkalTransact.mjs";
|
|
22
|
-
import { waitForEthereumTransactionConfirmation as S } from "../../functions/utils/tx-confirmation.utils.mjs";
|
|
23
|
-
import { safeUpdateDepositAndWithdrawStatus as C, updateDepositAndWithdrawStatus as w } from "../../API/deposit-and-withdraw-status-calls.mjs";
|
|
24
|
-
import { hinkalDepositOnChainUtxos as T } from "./hinkalDepositOnChainUtxos.mjs";
|
|
25
|
-
import { hinkalTronDepositToSelf as E } from "./hinkalTronDepositToSelf.mjs";
|
|
12
|
+
import { constructAdminData as p } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
13
|
+
import { getFeeStructure as m } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
14
|
+
import { toSpeculativeUtxo as h } from "../../functions/pre-transaction/speculativeUtxo.mjs";
|
|
15
|
+
import { transactCallDirectTron as g } from "../../functions/web3/functionCalls/transactCallDirectTron.mjs";
|
|
16
|
+
import { transactCallRelayerBatch as _ } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
17
|
+
import { hinkalTransact as v } from "./hinkalTransact.mjs";
|
|
26
18
|
import "../../functions/index.mjs";
|
|
27
|
-
import {
|
|
19
|
+
import { prepareDepositOnChainUtxos as y, submitDepositOnChainUtxos as b } from "./hinkalDepositOnChainUtxos.mjs";
|
|
20
|
+
import { ethers as x } from "ethers";
|
|
28
21
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.ts
|
|
29
|
-
var
|
|
30
|
-
let u = n.erc20TokenAddress, d = r.map((e) => e + a.flatFee), m = d.reduce((e, t) => e + t, 0n), _ = (await w({
|
|
31
|
-
chainId: t,
|
|
32
|
-
hashedEthereumAddress: o,
|
|
33
|
-
phase: l.BEFORE_DEPOSIT
|
|
34
|
-
})).id ?? void 0, { jobId: v, signedMessageHash: b } = await g(e, {
|
|
35
|
-
chainId: t,
|
|
36
|
-
erc20Addresses: [u],
|
|
37
|
-
amountChanges: [m],
|
|
38
|
-
externalAddress: s(await e.getEthereumAddressByChain(t)),
|
|
39
|
-
selfOutputAmounts: d,
|
|
40
|
-
createBlockedUtxos: !0
|
|
41
|
-
}), { R8: x, S: T } = e.userKeys.signEddsa(BigInt(b)), { zkCallData: E, circomData: O, dimData: k, tronProofSignature: A } = await h(v, {
|
|
42
|
-
R8: x,
|
|
43
|
-
S: T
|
|
44
|
-
}), j = p(O), M = await y(e, t, m, n, E, j, k, void 0, void 0, c, A);
|
|
45
|
-
await S(t, M), await C({
|
|
46
|
-
id: _,
|
|
47
|
-
chainId: t,
|
|
48
|
-
hashedEthereumAddress: o,
|
|
49
|
-
phase: l.AFTER_DEPOSIT,
|
|
50
|
-
depositTxHash: M
|
|
51
|
-
});
|
|
52
|
-
let N = j.encryptedOutputs?.[0];
|
|
53
|
-
if (!N || N.length !== d.length) throw Error("Enclave response missing encryptedOutputs for deposited UTXOs");
|
|
54
|
-
return {
|
|
55
|
-
userDepositedUtxos: N.map((t, n) => ({
|
|
56
|
-
recipientAddress: i[n],
|
|
57
|
-
utxo: f(D.getBytes(t), e.userKeys)
|
|
58
|
-
})),
|
|
59
|
-
statusId: _,
|
|
60
|
-
depositTxHash: M
|
|
61
|
-
};
|
|
62
|
-
}, k = async (e, a, o, c, d, f, p, h, g, _, v, y) => {
|
|
22
|
+
var S = async (e, a, o, c, l, d, f, m) => {
|
|
63
23
|
if (c.length === 0) throw Error("userDepositedUtxos must not be empty");
|
|
64
|
-
let
|
|
65
|
-
if (!
|
|
66
|
-
let
|
|
67
|
-
for (let r = 0; r < c.length; r +=
|
|
68
|
-
let o = c.slice(r, r +
|
|
69
|
-
let
|
|
24
|
+
let g = o.erc20TokenAddress, [_, y] = await Promise.all([e.getRandomRelay(a), e.getEthereumAddressByChain(a)]);
|
|
25
|
+
if (!_) throw Error(r.RELAYER_NOT_AVAILABLE);
|
|
26
|
+
let b = e.generateProofRemotely ? 5 : 1, x = [], S = s(y);
|
|
27
|
+
for (let r = 0; r < c.length; r += b) {
|
|
28
|
+
let o = c.slice(r, r + b), y = await Promise.all(o.map(async ({ recipientAddress: o, utxo: c }, y) => {
|
|
29
|
+
let b = r + y, x = s(o), C = n(c.erc20TokenAddress, g) ? c : i.createFrom(c, { erc20TokenAddress: g }), w = p(d, a, [g], [-c.amount], S), { zkCallData: T, circomData: E, dimData: D, commitmentValidationData: O, tronProofSignature: k } = await v(e, {
|
|
70
30
|
chainId: a,
|
|
71
|
-
erc20Addresses: [
|
|
31
|
+
erc20Addresses: [g],
|
|
72
32
|
amountChanges: [-c.amount],
|
|
73
|
-
externalAddress:
|
|
74
|
-
feeStructure:
|
|
75
|
-
relay:
|
|
76
|
-
inputUtxos: [[
|
|
33
|
+
externalAddress: x,
|
|
34
|
+
feeStructure: l,
|
|
35
|
+
relay: _ ?? t,
|
|
36
|
+
inputUtxos: [[C]],
|
|
77
37
|
useBlockedUtxos: !0,
|
|
38
|
+
speculative: m && {
|
|
39
|
+
pendingLeaves: m,
|
|
40
|
+
inputUtxos: [[h(C)]]
|
|
41
|
+
},
|
|
78
42
|
submit: { mode: u.ProofOnly },
|
|
79
43
|
skipLock: !0
|
|
80
44
|
});
|
|
81
45
|
return {
|
|
82
|
-
zkCallData:
|
|
83
|
-
dimData:
|
|
84
|
-
circomData:
|
|
85
|
-
commitmentValidationData:
|
|
86
|
-
adminData:
|
|
46
|
+
zkCallData: T,
|
|
47
|
+
dimData: D,
|
|
48
|
+
circomData: E,
|
|
49
|
+
commitmentValidationData: O,
|
|
50
|
+
adminData: w,
|
|
87
51
|
recipientAddress: o,
|
|
88
|
-
tronProofSignature:
|
|
89
|
-
destinationChainId:
|
|
90
|
-
destinationTokenAddress:
|
|
91
|
-
destinationTokenAmount:
|
|
52
|
+
tronProofSignature: k,
|
|
53
|
+
destinationChainId: f?.chainId,
|
|
54
|
+
destinationTokenAddress: f?.tokenAddress,
|
|
55
|
+
destinationTokenAmount: f?.tokenAmounts?.[b]
|
|
92
56
|
};
|
|
93
57
|
}));
|
|
94
|
-
|
|
58
|
+
x.push(...y);
|
|
95
59
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
60
|
+
return x;
|
|
61
|
+
}, C = async (e, t, n, r, i) => {
|
|
62
|
+
let { chainId: a, hashedEthereumAddress: o, feeStructure: s, action: c, destination: l } = i, { txCompletionTime: u, ref: d, hashedDashboardAccountId: f, preEstimateGas: p } = i, m = n.map((e) => e + s.flatFee), h = await y(e, a, [t], [m]), { depositedUtxos: g, pendingLeaves: v } = h, x = g[0].map((e, t) => ({
|
|
63
|
+
recipientAddress: r[t],
|
|
64
|
+
utxo: e
|
|
65
|
+
})), [C, w] = await Promise.all([b(e, h, p), S(e, a, t, x, s, c, l, v)]);
|
|
66
|
+
return {
|
|
67
|
+
depositTxHash: C,
|
|
68
|
+
scheduleId: await _(a, w, o, u, d, f, C)
|
|
69
|
+
};
|
|
70
|
+
}, w = async (e, t, n, r, i) => {
|
|
71
|
+
let { chainId: a, ethereumAddress: o, hashedEthereumAddress: s, feeStructure: l, action: d, destination: p } = i, { txCompletionTime: m, ref: h, hashedDashboardAccountId: y, preEstimateGas: b } = i, C = n.map((e) => e + l.flatFee), w = C.reduce((e, t) => e + t, 0n), T = await v(e, {
|
|
105
72
|
chainId: a,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
73
|
+
erc20Addresses: [t.erc20TokenAddress],
|
|
74
|
+
amountChanges: [w],
|
|
75
|
+
externalAddress: o,
|
|
76
|
+
selfOutputAmounts: C,
|
|
77
|
+
createBlockedUtxos: !0,
|
|
78
|
+
forceEmptyUtxos: !0,
|
|
79
|
+
submit: { mode: u.ProofOnly }
|
|
80
|
+
}), E = T.circomData.encryptedOutputs?.[0];
|
|
81
|
+
if (!E || E.length !== C.length) throw Error("Deposit proof is missing encryptedOutputs for the deposited UTXOs");
|
|
82
|
+
let D = E.map((t, n) => ({
|
|
83
|
+
recipientAddress: r[n],
|
|
84
|
+
utxo: f(x.getBytes(t), e.userKeys)
|
|
85
|
+
})), O = T.circomData.outCommitments.flat().map((e) => BigInt(e)).filter((e) => e !== 0n).map((e) => e.toString()), [k, A] = await Promise.all([(async () => {
|
|
86
|
+
c(T.zkCallData);
|
|
87
|
+
let n = await g(e, a, w, t, T.zkCallData, T.circomData, T.dimData, void 0, void 0, b, T.tronProofSignature);
|
|
88
|
+
if (!n) throw Error("Deposit transaction hash not found");
|
|
89
|
+
return n;
|
|
90
|
+
})(), S(e, a, t, D, l, d, p, O)]);
|
|
91
|
+
return {
|
|
92
|
+
depositTxHash: k,
|
|
93
|
+
scheduleId: await _(a, A, s, m, h, y, k)
|
|
94
|
+
};
|
|
95
|
+
}, T = async (t, n, r, i, c, u, f, p, h, g = !0, _) => {
|
|
96
|
+
let v = d([n]), y = n.erc20TokenAddress, b = s(await t.getEthereumAddressByChain(v)), x = {
|
|
97
|
+
chainId: v,
|
|
98
|
+
ethereumAddress: b,
|
|
99
|
+
hashedEthereumAddress: a(b),
|
|
100
|
+
feeStructure: u ?? await m(v, y, [y], l.Transact, [], 10n),
|
|
101
|
+
txCompletionTime: c,
|
|
102
|
+
ref: f,
|
|
103
|
+
action: p,
|
|
104
|
+
hashedDashboardAccountId: h ? o(h) : void 0,
|
|
105
|
+
preEstimateGas: g,
|
|
106
|
+
destination: _
|
|
117
107
|
};
|
|
108
|
+
if (!e(v)) return C(t, n, r, i, x);
|
|
109
|
+
if (r.length > 4) throw Error("Tron supports at most 4 recipients per deposit - no circuit emits more outputs");
|
|
110
|
+
return w(t, n, r, i, x);
|
|
118
111
|
};
|
|
119
112
|
//#endregion
|
|
120
|
-
export {
|
|
113
|
+
export { T as hinkalDepositAndWithdraw };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../utxo/Utxo.cjs`),t=require(`../../functions/utils/tron.utils.cjs`),n=require(`../../types/ethereum-network.types.cjs`),r=require(`../../types/external-action.types.cjs`),i=require(`../../types/transact.types.cjs`),a=require(`../../constants/contracts.constants.cjs`),o=require(`../../functions/web3/functionCalls/transactCallDirect.cjs`),s=require(`./hinkalTransact.cjs`);let c=require(`ethers`);var l=async(n,o,l,u)=>{if(l.length!==u.length)throw Error(`erc20Tokens and utxoAmounts length mismatch`);if(u.some(e=>e.length===0))throw Error(`every token must deposit at least one UTXO`);let d=a.getDepositOnChainUtxosAddress(o);if(!d)throw Error(`DepositOnChainUtxos action is not deployed on chain ${o}`);let f=l.map(({erc20TokenAddress:e})=>e),p=u.map(e=>e.reduce((e,t)=>e+t,0n)),m=c.ethers.AbiCoder.defaultAbiCoder().encode([`uint256[][]`],[u]),h=t.addressToHexFormat(await n.getEthereumAddressByChain(o)),g=await s.hinkalTransact(n,{chainId:o,erc20Addresses:f,amountChanges:f.map(()=>0n),externalAddress:d,externalActionId:r.ExternalActionId.DepositOnChainUtxos,externalActionMetadata:m,onChainCreation:f.map(()=>!0),originalSender:h,forceEmptyUtxos:!0,submit:{mode:i.SubmitMode.ProofOnly}}),{timeStamp:_,stealthAddressStructure:v}=g.circomData;if(!_)throw Error(`Deposit proof is missing the timestamp the on-chain UTXOs are stamped with`);let y=c.ethers.toBeHex(BigInt(v.stealthAddress)),b=n.userKeys.getShieldedPrivateKey(),x=0n,S=u.map((t,n)=>t.map(t=>{let r=new e.Utxo({amount:t,erc20TokenAddress:f[n],timeStamp:(BigInt(_)+x).toString(),nullifyingKey:b,stealthAddress:y,H0:[v.H0x,v.H0y],isBlocked:!0});return x+=1n,r}));return{chainId:o,erc20Tokens:l,externalAddress:d,depositProof:g,depositedUtxos:S,pendingLeaves:S.flat().map(e=>BigInt(e.getCommitment()).toString()),totalAmounts:p}},u=async(e,t,r=!0)=>{let{chainId:i,erc20Tokens:a,depositProof:s,totalAmounts:c}=t,{zkCallData:l,circomData:u,dimData:d}=s,f=await o.transactCallDirect(e,i,c,a,l,u,d,e.getContractWithSigner(i,n.ContractType.DepositOnChainUtxosContract),void 0,r);if(!f.hash)throw Error(`Deposit transaction hash not found`);return f.hash};exports.prepareDepositOnChainUtxos=l,exports.submitDepositOnChainUtxos=u;
|
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import { IHinkal } from './IHinkal';
|
|
2
|
-
import { ERC20Token
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import { ERC20Token } from '../../types';
|
|
3
|
+
import { TransactProof } from '../../types/transact.types';
|
|
4
|
+
import { Utxo } from '../utxo/Utxo';
|
|
5
|
+
export interface PreparedDepositOnChainUtxos {
|
|
6
|
+
chainId: number;
|
|
7
|
+
erc20Tokens: ERC20Token[];
|
|
8
|
+
externalAddress: string;
|
|
9
|
+
depositProof: TransactProof;
|
|
10
|
+
depositedUtxos: Utxo[][];
|
|
11
|
+
pendingLeaves: string[];
|
|
12
|
+
totalAmounts: bigint[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Builds a deposit that creates on-chain UTXOs through the DepositOnChainUtxos external
|
|
16
|
+
* action. The action stamps each UTXO with circomData.timeStamp instead of block.timestamp,
|
|
17
|
+
* so every commitment is known before the transaction is submitted and dependent proofs can
|
|
18
|
+
* be generated against a speculative Merkle tree while the deposit is still confirming.
|
|
19
|
+
*/
|
|
20
|
+
export declare const prepareDepositOnChainUtxos: (hinkal: IHinkal, chainId: number, erc20Tokens: ERC20Token[], utxoAmounts: bigint[][]) => Promise<PreparedDepositOnChainUtxos>;
|
|
21
|
+
export declare const submitDepositOnChainUtxos: (hinkal: IHinkal, prepared: PreparedDepositOnChainUtxos, preEstimateGas?: boolean) => Promise<string>;
|
|
@@ -1,44 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../../
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import { Utxo as e } from "../utxo/Utxo.mjs";
|
|
2
|
+
import { addressToHexFormat as t } from "../../functions/utils/tron.utils.mjs";
|
|
3
|
+
import { ContractType as n } from "../../types/ethereum-network.types.mjs";
|
|
4
|
+
import { ExternalActionId as r } from "../../types/external-action.types.mjs";
|
|
5
|
+
import { SubmitMode as i } from "../../types/transact.types.mjs";
|
|
6
|
+
import { getDepositOnChainUtxosAddress as a } from "../../constants/contracts.constants.mjs";
|
|
7
|
+
import { transactCallDirect as o } from "../../functions/web3/functionCalls/transactCallDirect.mjs";
|
|
8
|
+
import { hinkalTransact as s } from "./hinkalTransact.mjs";
|
|
9
|
+
import { ethers as c } from "ethers";
|
|
9
10
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalDepositOnChainUtxos.ts
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
let
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
11
|
+
var l = async (n, o, l, u) => {
|
|
12
|
+
if (l.length !== u.length) throw Error("erc20Tokens and utxoAmounts length mismatch");
|
|
13
|
+
if (u.some((e) => e.length === 0)) throw Error("every token must deposit at least one UTXO");
|
|
14
|
+
let d = a(o);
|
|
15
|
+
if (!d) throw Error(`DepositOnChainUtxos action is not deployed on chain ${o}`);
|
|
16
|
+
let f = l.map(({ erc20TokenAddress: e }) => e), p = u.map((e) => e.reduce((e, t) => e + t, 0n)), m = c.AbiCoder.defaultAbiCoder().encode(["uint256[][]"], [u]), h = t(await n.getEthereumAddressByChain(o)), g = await s(n, {
|
|
17
|
+
chainId: o,
|
|
18
|
+
erc20Addresses: f,
|
|
19
|
+
amountChanges: f.map(() => 0n),
|
|
20
|
+
externalAddress: d,
|
|
21
|
+
externalActionId: r.DepositOnChainUtxos,
|
|
22
|
+
externalActionMetadata: m,
|
|
23
|
+
onChainCreation: f.map(() => !0),
|
|
24
|
+
originalSender: h,
|
|
25
|
+
forceEmptyUtxos: !0,
|
|
26
|
+
submit: { mode: i.ProofOnly }
|
|
27
|
+
}), { timeStamp: _, stealthAddressStructure: v } = g.circomData;
|
|
28
|
+
if (!_) throw Error("Deposit proof is missing the timestamp the on-chain UTXOs are stamped with");
|
|
29
|
+
let y = c.toBeHex(BigInt(v.stealthAddress)), b = n.userKeys.getShieldedPrivateKey(), x = 0n, S = u.map((t, n) => t.map((t) => {
|
|
30
|
+
let r = new e({
|
|
31
|
+
amount: t,
|
|
32
|
+
erc20TokenAddress: f[n],
|
|
33
|
+
timeStamp: (BigInt(_) + x).toString(),
|
|
34
|
+
nullifyingKey: b,
|
|
35
|
+
stealthAddress: y,
|
|
36
|
+
H0: [v.H0x, v.H0y],
|
|
37
|
+
isBlocked: !0
|
|
34
38
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
return x += 1n, r;
|
|
40
|
+
}));
|
|
41
|
+
return {
|
|
42
|
+
chainId: o,
|
|
43
|
+
erc20Tokens: l,
|
|
44
|
+
externalAddress: d,
|
|
45
|
+
depositProof: g,
|
|
46
|
+
depositedUtxos: S,
|
|
47
|
+
pendingLeaves: S.flat().map((e) => BigInt(e.getCommitment()).toString()),
|
|
48
|
+
totalAmounts: p
|
|
41
49
|
};
|
|
50
|
+
}, u = async (e, t, r = !0) => {
|
|
51
|
+
let { chainId: i, erc20Tokens: a, depositProof: s, totalAmounts: c } = t, { zkCallData: l, circomData: u, dimData: d } = s, f = await o(e, i, c, a, l, u, d, e.getContractWithSigner(i, n.DepositOnChainUtxosContract), void 0, r);
|
|
52
|
+
if (!f.hash) throw Error("Deposit transaction hash not found");
|
|
53
|
+
return f.hash;
|
|
42
54
|
};
|
|
43
55
|
//#endregion
|
|
44
|
-
export {
|
|
56
|
+
export { l as prepareDepositOnChainUtxos, u as submitDepositOnChainUtxos };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../functions/utils/caseInsensitive.utils.cjs`),n=require(`../../crypto/poseidon.cjs`),r=require(`../../error-handling/error-codes.constants.cjs`),i=require(`../../functions/web3/etherFunctions.cjs`),a=require(`../../functions/utils/addresses.cjs`),o=require(`../../types/external-action.types.cjs`),s=require(`../../types/admin.types.cjs`),c=require(`../../types/transact.types.cjs`);require(`../../error-handling/index.cjs`);const l=require(`../../functions/pre-transaction/constructAdminData.cjs`),u=require(`../AccountActions/AccountActions.cjs`),d=require(`../../functions/pre-transaction/getFeeStructure.cjs`);require(`../../functions/pre-transaction/index.cjs`);const f=require(`../../functions/private-wallet/emporium.helpers.cjs`),p=require(`./hinkalTransact.cjs`),m=require(`../../functions/utils/involves-permit2-op.cjs`),h=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`),g=require(`../../functions/pre-transaction/merge-with-fee-structure.cjs`),_=require(`../../functions/pre-transaction/merge-with-fee-structure-emporium.cjs`),v=require(`./handleAutoDepositBack.cjs`);var y=async(y,b,x,S,C,w,T,E,D,O,k,A=!1,j,M,N)=>{if(N&&!a.isValidPrivateAddress(N.recipientInfo))throw Error(r.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);if(T.length>0&&!E)throw Error(`Subaccount is required for private wallet transactions`);let P=x.map(e=>e.erc20TokenAddress),F=await y.
|
|
1
|
+
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../functions/utils/caseInsensitive.utils.cjs`),n=require(`../../crypto/poseidon.cjs`),r=require(`../../error-handling/error-codes.constants.cjs`),i=require(`../../functions/web3/etherFunctions.cjs`),a=require(`../../functions/utils/addresses.cjs`),o=require(`../../types/external-action.types.cjs`),s=require(`../../types/admin.types.cjs`),c=require(`../../types/transact.types.cjs`);require(`../../error-handling/index.cjs`);const l=require(`../../functions/pre-transaction/constructAdminData.cjs`),u=require(`../AccountActions/AccountActions.cjs`),d=require(`../../functions/pre-transaction/getFeeStructure.cjs`);require(`../../functions/pre-transaction/index.cjs`);const f=require(`../../functions/private-wallet/emporium.helpers.cjs`),p=require(`./hinkalTransact.cjs`),m=require(`../../functions/utils/involves-permit2-op.cjs`),h=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`),g=require(`../../functions/pre-transaction/merge-with-fee-structure.cjs`),_=require(`../../functions/pre-transaction/merge-with-fee-structure-emporium.cjs`),v=require(`./handleAutoDepositBack.cjs`);var y=async(y,b,x,S,C,w,T,E,D,O,k,A=!1,j,M,N)=>{if(N&&!a.isValidPrivateAddress(N.recipientInfo))throw Error(r.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);if(T.length>0&&!E)throw Error(`Subaccount is required for private wallet transactions`);let P=x.map(e=>e.erc20TokenAddress),F=await y.getEthereumAddress(),I=E?u.AccountActions.getAddressFromSubAccount(b,E):void 0,{contractData:L}=e.networkRegistry[b],{emporiumAddress:R}=L;if(!R)throw Error(`No Emporium Address Provided`);let z=O??await d.getFeeStructure(b,D,P,o.ExternalActionId.Emporium,w.map(e=>h.convertEmporiumOpToCallInfo(e,I??``,b)));for(I?await _.mergeWithFeeStructureEmporium(y,b,I,w,P,S,z,T.find(e=>t.caseInsensitiveEqual(e.token.erc20TokenAddress,z.feeToken))?.amount??0n):await g.mergeWithFeeStructure(b,P,S,z);C.length<P.length;)C.push(!1);let B=k??await y.getRandomRelay(b,!0);if(!B)throw Error(r.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let V=E?u.AccountActions.getPrivateKeyFromSubAccount(b,E):void 0,H=e.getOnchainChainId(b),U=V?u.AccountActions.getSignerAddressFromPrivateKey(H,V):void 0,W=i.randomBigInt(31),G=y.generateProofRemotely?await f.encodeEmporiumMetadata(b,R,V,w,n.poseidonFunction(W),U,z.flatFee):void 0,K=await f.getAuthorizationDataIfNeeded(b,V),q=m.uniswapWorkaround(w),J=l.constructAdminData(M,b,T.map(e=>e.token.erc20TokenAddress),T.map(e=>e.amount),F,M===s.AdminTransactionType.PublicSwap?T.map(({token:e})=>e):void 0),Y,X=await p.hinkalTransact(y,{chainId:b,erc20Addresses:P,amountChanges:S,externalAddress:R,externalActionId:o.ExternalActionId.Emporium,externalActionMetadata:G,onChainCreation:C,feeStructure:z,relay:B,messageSeed:W,recipientAddress:N?[N.recipientInfo]:void 0,recipientAmounts:N?[P.map(e=>t.caseInsensitiveEqual(e,N.token.erc20TokenAddress)?N.amount:0n)]:void 0,subAccountPrivateKey:V,emporiumOps:w,onTxSubmitLocally:e=>{Y=e},submit:{mode:c.SubmitMode.Relayer,adminData:J,authorizationData:K,withUniswapWorkAround:q}});return A&&E&&v.handleAutoDepositBack(y,b,I,E,z.feeToken,j,T,Y),X};exports.hinkalPrivateWallet=y;
|
|
@@ -23,13 +23,13 @@ import { handleAutoDepositBack as b } from "./handleAutoDepositBack.mjs";
|
|
|
23
23
|
var x = async (x, S, C, w, T, E, D, O, k, A, j, M = !1, N, P, F) => {
|
|
24
24
|
if (F && !o(F.recipientInfo)) throw Error(i.RECIPIENT_FORMAT_INCORRECT);
|
|
25
25
|
if (D.length > 0 && !O) throw Error("Subaccount is required for private wallet transactions");
|
|
26
|
-
let I = C.map((e) => e.erc20TokenAddress), L = await x.
|
|
26
|
+
let I = C.map((e) => e.erc20TokenAddress), L = await x.getEthereumAddress(), R = O ? d.getAddressFromSubAccount(S, O) : void 0, { contractData: z } = t[S], { emporiumAddress: B } = z;
|
|
27
27
|
if (!B) throw Error("No Emporium Address Provided");
|
|
28
28
|
let V = A ?? await f(S, k, I, s.Emporium, E.map((e) => _(e, R ?? "", S)));
|
|
29
29
|
for (R ? await y(x, S, R, E, I, w, V, D.find((e) => n(e.token.erc20TokenAddress, V.feeToken))?.amount ?? 0n) : await v(S, I, w, V); T.length < I.length;) T.push(!1);
|
|
30
30
|
let H = j ?? await x.getRandomRelay(S, !0);
|
|
31
31
|
if (!H) throw Error(i.RELAYER_NOT_AVAILABLE);
|
|
32
|
-
let U = O ? d.getPrivateKeyFromSubAccount(S, O) : void 0, W = e(S), G = U ? d.getSignerAddressFromPrivateKey(W, U) : void 0, K = a(31), q = x.generateProofRemotely ? await p(S, B, U, E, r(K), G) : void 0, J = await m(S, U), Y = g(E), X = u(P, S, D.map((e) => e.token.erc20TokenAddress), D.map((e) => e.amount), L, P === c.PublicSwap ? D.map(({ token: e }) => e) : void 0), Z, Q = await h(x, {
|
|
32
|
+
let U = O ? d.getPrivateKeyFromSubAccount(S, O) : void 0, W = e(S), G = U ? d.getSignerAddressFromPrivateKey(W, U) : void 0, K = a(31), q = x.generateProofRemotely ? await p(S, B, U, E, r(K), G, V.flatFee) : void 0, J = await m(S, U), Y = g(E), X = u(P, S, D.map((e) => e.token.erc20TokenAddress), D.map((e) => e.amount), L, P === c.PublicSwap ? D.map(({ token: e }) => e) : void 0), Z, Q = await h(x, {
|
|
33
33
|
chainId: S,
|
|
34
34
|
erc20Addresses: I,
|
|
35
35
|
amountChanges: w,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../error-handling/error-codes.constants.cjs`),t=require(`../../functions/utils/addresses.cjs`),n=require(`../../types/external-action.types.cjs`),r=require(`../../functions/utils/token-check.utils.cjs`),i=require(`../../functions/pre-transaction/getVolatileTransferAmount.cjs`),a=require(`../AccountActions/AccountActions.cjs`),o=require(`../../functions/pre-transaction/getFeeStructure.cjs`),s=require(`../../functions/private-wallet/emporium.helpers.cjs`),c=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`);var
|
|
1
|
+
require(`../../constants/protocol.constants.cjs`);const e=require(`../../error-handling/error-codes.constants.cjs`),t=require(`../../functions/utils/addresses.cjs`),n=require(`../../types/external-action.types.cjs`),r=require(`../../functions/utils/token-check.utils.cjs`),i=require(`../../functions/pre-transaction/getVolatileTransferAmount.cjs`),a=require(`../AccountActions/AccountActions.cjs`),o=require(`../../functions/pre-transaction/getFeeStructure.cjs`),s=require(`../../functions/private-wallet/emporium.helpers.cjs`),c=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`),l=require(`../../functions/utils/fees.utils.cjs`);var u=async(u,d,f,p,m,h,g,_)=>{if(!g)throw Error(`hinkalProxyToPrivate: subAccount should be provided`);if(!m)throw Error(`Fee token is required in hinkalProxyToPrivate`);if(!t.isValidPrivateAddress(p))throw Error(e.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);let v=r.validateAndGetChainId(d),y=a.AccountActions.getAddressFromSubAccount(v,g);if(!y)throw Error(`Public account address is not available`);let b=d.map(e=>e.erc20TokenAddress),x=await i.modifyVolatileTokenAmountChanges(v,d,f,y),S=s.createTransaferEmporiumOpsBatch(u,v,b,x),C=await l.calculateModifiedFeeStructureForTokens(v,d,x,h??await o.getFeeStructure(v,m,b,n.ExternalActionId.Emporium,S.map(e=>c.convertEmporiumOpToCallInfo(e,y,v)),10n)),w=d.map((e,t)=>({token:e,amount:-1n*x[t]}));return u.actionPrivateWallet(v,[d[0]],[0n],[!1],S,w,g,m,C,void 0,void 0,void 0,_,{recipientInfo:p,amount:x[0],token:d[0]})};exports.hinkalProxyToPrivate=u;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "../../constants/protocol.constants.mjs";
|
|
1
2
|
import { transactionErrorCodes as e } from "../../error-handling/error-codes.constants.mjs";
|
|
2
3
|
import { isValidPrivateAddress as t } from "../../functions/utils/addresses.mjs";
|
|
3
4
|
import { ExternalActionId as n } from "../../types/external-action.types.mjs";
|
|
@@ -7,22 +8,23 @@ import { AccountActions as a } from "../AccountActions/AccountActions.mjs";
|
|
|
7
8
|
import { getFeeStructure as o } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
8
9
|
import { createTransaferEmporiumOpsBatch as s } from "../../functions/private-wallet/emporium.helpers.mjs";
|
|
9
10
|
import { convertEmporiumOpToCallInfo as c } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
|
|
11
|
+
import { calculateModifiedFeeStructureForTokens as l } from "../../functions/utils/fees.utils.mjs";
|
|
10
12
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalProxyToPrivate.ts
|
|
11
|
-
var
|
|
12
|
-
if (!
|
|
13
|
-
if (!
|
|
14
|
-
if (!t(
|
|
15
|
-
let
|
|
16
|
-
if (!
|
|
17
|
-
let
|
|
13
|
+
var u = async (u, d, f, p, m, h, g, _) => {
|
|
14
|
+
if (!g) throw Error("hinkalProxyToPrivate: subAccount should be provided");
|
|
15
|
+
if (!m) throw Error("Fee token is required in hinkalProxyToPrivate");
|
|
16
|
+
if (!t(p)) throw Error(e.RECIPIENT_FORMAT_INCORRECT);
|
|
17
|
+
let v = r(d), y = a.getAddressFromSubAccount(v, g);
|
|
18
|
+
if (!y) throw Error("Public account address is not available");
|
|
19
|
+
let b = d.map((e) => e.erc20TokenAddress), x = await i(v, d, f, y), S = s(u, v, b, x), C = await l(v, d, x, h ?? await o(v, m, b, n.Emporium, S.map((e) => c(e, y, v)), 10n)), w = d.map((e, t) => ({
|
|
18
20
|
token: e,
|
|
19
|
-
amount: -1n *
|
|
21
|
+
amount: -1n * x[t]
|
|
20
22
|
}));
|
|
21
|
-
return
|
|
22
|
-
recipientInfo:
|
|
23
|
-
amount:
|
|
24
|
-
token:
|
|
23
|
+
return u.actionPrivateWallet(v, [d[0]], [0n], [!1], S, w, g, m, C, void 0, void 0, void 0, _, {
|
|
24
|
+
recipientInfo: p,
|
|
25
|
+
amount: x[0],
|
|
26
|
+
token: d[0]
|
|
25
27
|
});
|
|
26
28
|
};
|
|
27
29
|
//#endregion
|
|
28
|
-
export {
|
|
30
|
+
export { u as hinkalProxyToPrivate };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../error-handling/error-codes.constants.cjs`),r=require(`../crypto-keys/keys.cjs`),i=require(`../utxo/Utxo.cjs`),a=require(`../../types/external-action.types.cjs`),o=require(`../../types/solana-transact.types.cjs`);require(`../../types/index.cjs`);const s=require(`../../functions/utils/token-check.utils.cjs`),c=require(`../../functions/pre-transaction/getFeeStructure.cjs`),l=require(`./hinkalSolanaTransact.cjs`);var u=async(u,d,f,p,m)=>{let h=s.validateAndGetChainId([d]),g=d.erc20TokenAddress;if(f.getTokenAddress(h)!==g)throw Error(`Off-chain UTXO token mismatch`);let _=
|
|
1
|
+
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../error-handling/error-codes.constants.cjs`),r=require(`../crypto-keys/keys.cjs`),i=require(`../utxo/Utxo.cjs`),a=require(`../../types/external-action.types.cjs`),o=require(`../../types/solana-transact.types.cjs`);require(`../../types/index.cjs`);const s=require(`../../functions/utils/token-check.utils.cjs`),c=require(`../../functions/pre-transaction/getFeeStructure.cjs`),l=require(`./hinkalSolanaTransact.cjs`);var u=async(u,d,f,p,m)=>{let h=s.validateAndGetChainId([d]),g=d.erc20TokenAddress;if(f.getTokenAddress(h)!==g)throw Error(`Off-chain UTXO token mismatch`);let _=new r.UserKeys(p),v=_.getShieldedPrivateKey();if(f.nullifyingKey&&BigInt(f.nullifyingKey)!==BigInt(v))throw Error(`Claimable UTXO key mismatch`);let{originalDeployer:y}=e.networkRegistry[h].contractData;if(!y)throw Error(`missing data`);let b=i.Utxo.createFrom(f,{nullifyingKey:v}),x=m??await c.getFeeStructure(h,g,[g],a.ExternalActionId.Transact,void 0,void 0,{mintTo:g,nullifierCount:1,rootInsertCount:2});if(x.feeToken!==g)throw Error(`Claim fee token mismatch: fee must be paid from claimed UTXO token`);let S=x.variableRate>0n?x.variableRate:t.HINKAL_PRIVATE_SEND_VARIABLE_RATE;if(b.amount<=x.flatFee)throw Error(n.transactionErrorCodes.INSUFFICIENT_FUNDS_TO_TRANSACT);let C=b.amount-x.flatFee,w=C*S/10000n,T=C-w;if(T<=0n)throw Error(n.transactionErrorCodes.RECIPIENT_AMOUNT_INVALID);let E=x.flatFee+w,D=u.getRecipientInfo(),[O,k,A,,,j]=D.split(`,`);if(!k||!A||!O||!j)throw Error(`Invalid recipient info`);let M=new i.Utxo({amount:0n,erc20TokenAddress:b.erc20TokenAddress,mintAddress:b.mintAddress,nullifyingKey:_.getShieldedPrivateKey(),spendingPublicKey:_.getSpendingKeyPair().pubSpendingBJJPoint}),N=await u.getRandomRelay(h,!0);if(!N)throw Error(n.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let P={recipient:N,mint:g===`11111111111111111111111111111111`?void 0:g};return l.hinkalSolanaTransact(u,{chainId:h,mintAddresses:[g],amountChanges:[-(T+E)],relayAddress:N,recipient:t.solanaNativeAddress,signer:N,functionName:`transfer`,accounts:P,relayerFee:E,recipientAddress:D,recipientAmounts:[T],inputUtxos:[[b,M]],userKeys:_,submit:{mode:o.SolanaSubmitMode.Relayer}})};exports.hinkalSolanaClaimUtxo=u;
|
|
@@ -2,4 +2,4 @@ import { ERC20Token } from '../../types';
|
|
|
2
2
|
import { FeeStructure } from '../../types/hinkal.types';
|
|
3
3
|
import { Utxo } from '../utxo/Utxo';
|
|
4
4
|
import { IHinkal } from './IHinkal';
|
|
5
|
-
export declare const hinkalSolanaClaimUtxo: (hinkal: IHinkal, erc20Token: ERC20Token, utxo: Utxo,
|
|
5
|
+
export declare const hinkalSolanaClaimUtxo: (hinkal: IHinkal, erc20Token: ERC20Token, utxo: Utxo, claimableSignature: string, feeStructureOverride?: FeeStructure) => Promise<string>;
|
|
@@ -13,13 +13,11 @@ import { hinkalSolanaTransact as u } from "./hinkalSolanaTransact.mjs";
|
|
|
13
13
|
var d = async (d, f, p, m, h) => {
|
|
14
14
|
let g = c([f]), _ = f.erc20TokenAddress;
|
|
15
15
|
if (p.getTokenAddress(g) !== _) throw Error("Off-chain UTXO token mismatch");
|
|
16
|
-
let v =
|
|
17
|
-
if (
|
|
18
|
-
let y = v.getShieldedPrivateKey();
|
|
19
|
-
if (p.nullifyingKey && p.nullifyingKey !== y) throw Error("Claimable UTXO key mismatch");
|
|
16
|
+
let v = new i(m), y = v.getShieldedPrivateKey();
|
|
17
|
+
if (p.nullifyingKey && BigInt(p.nullifyingKey) !== BigInt(y)) throw Error("Claimable UTXO key mismatch");
|
|
20
18
|
let { originalDeployer: b } = e[g].contractData;
|
|
21
19
|
if (!b) throw Error("missing data");
|
|
22
|
-
let x = a.createFrom(p, { nullifyingKey: y }), S =
|
|
20
|
+
let x = a.createFrom(p, { nullifyingKey: y }), S = h ?? await l(g, _, [_], o.Transact, void 0, void 0, {
|
|
23
21
|
mintTo: _,
|
|
24
22
|
nullifierCount: 1,
|
|
25
23
|
rootInsertCount: 2
|
|
@@ -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/solanaMint.utils.cjs`),o=require(`../../functions/utils/addresses.cjs`),s=require(`../../functions/utils/token-check.utils.cjs`),c=require(`../../functions/snarkjs/common.snarkjs.cjs`),l=require(`../../functions/pre-transaction/solana.cjs`),u=require(`../../functions/pre-transaction/constructAdminData.cjs`),d=require(`../../error-handling/retrySolanaError.cjs`),f=require(`../../API/admin-calls.cjs`)
|
|
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/solanaMint.utils.cjs`),o=require(`../../functions/utils/addresses.cjs`),s=require(`../../functions/utils/token-check.utils.cjs`),c=require(`../../functions/snarkjs/common.snarkjs.cjs`),l=require(`../../functions/pre-transaction/solana.cjs`),u=require(`../../functions/pre-transaction/constructAdminData.cjs`),d=require(`../../error-handling/retrySolanaError.cjs`),f=require(`../../API/admin-calls.cjs`);require(`../../functions/pre-transaction/solanaTransfer.utils.cjs`);const p=require(`./hinkalProoflessDeposit.utils.cjs`);let m=require(`@solana/web3.js`),h=require(`@coral-xyz/anchor`);var g=(n,r)=>{let i=s.validateAndGetChainId([r]),o=r.erc20TokenAddress,{hinkalIdl:c,hinkalAddress:u,originalDeployer:d}=e.networkRegistry[i].contractData;if(!c)throw Error(`No IDL configured for Solana program on this network`);if(!d)throw Error(`missing original deployer`);let f=n.getSolanaProgram(c),p=n.getSolanaPublicKey(),{connection:h,wallet:g}=f.provider;if(!g)throw Error(`missing solana wallet`);let _=new m.PublicKey(d),v=new m.PublicKey(u),{mintPublicKey:y}=a.formatMintAddress(o),b=y.toString()===t.solanaNativeAddress;return{chainId:i,mintAddress:o,program:f,publicKey:p,connection:h,wallet:g,originalDeployer:_,mintPublicKey:y,mint:b?null:y,atasValue:b?null:void 0,storageAccount:l.getStorageAccountPublicKey(v,_),storageVault:l.getStorageVaultPublicKey(v,_),merkleAccount:l.getMerkleAccountPublicKey(v,_)}},_=async(e,t,n,r,i)=>{let a=n.map(e=>l.buildAnchorStealthAddressStructure(e)),o=p.buildProoflessEncryptedOutputs(n,r).map(e=>Buffer.from(e.slice(2),`hex`)),{current:s,next:c}=await l.resolveSolanaRootBuckets(e.program,e.merkleAccount,t.length);return e.program.methods.multiPaymentDeposit(t.map(e=>new h.BN(e.toString())),a,o,i).accounts({mint:e.mint,signer:e.publicKey,signerAta:e.atasValue,originalDeployer:e.originalDeployer,storageAccount:e.storageAccount,storageVault:e.storageVault,merkleAccount:e.merkleAccount,rootBucketCurrent:s,rootBucketNext:c??e.program.programId,storageVaultAta:e.atasValue}).instruction()},v=async(e,t,n,r)=>{for(let i=0;i<10;i+=1){let a=i===9;try{let{blockhash:i,lastValidBlockHeight:a}=await e.getLatestBlockhash(),o=new m.VersionedTransaction(new m.TransactionMessage({payerKey:n,recentBlockhash:i,instructions:r}).compileToV0Message()),s=await t.signTransaction(o),c=await e.sendTransaction(s);return await e.confirmTransaction({signature:c,blockhash:i,lastValidBlockHeight:a},`confirmed`),c}catch(e){if(d.shouldRetryForSolanaError(e)&&!a)continue;throw e}}return``},y=(e,t)=>{if(e.length===0)throw Error(`amounts must not be empty`);if(e.length!==t.length)throw Error(`amounts and stealthAddressStructures length mismatch`);if(e.some(e=>e<=0n))throw Error(`all amounts must be positive`);p.assertNoDuplicateStealthAddressStructures(t)},b=async(e,t,n,r,i,a=!1,o,s=!1)=>{y(n,r);let c=g(e,t),l=u.constructAdminData(o,c.chainId,Array(n.length).fill(c.mintAddress),n,await e.getEthereumAddress()),d=await _(c,n,r,i,a);if(s){let{blockhash:e}=await c.connection.getLatestBlockhash(),t=new m.Transaction().add(d);return t.recentBlockhash=e,t.feePayer=c.publicKey,Buffer.from(t.serialize({requireAllSignatures:!1})).toString(`base64`)}let p=await v(c.connection,c.wallet,c.publicKey,[d]);return await f.emitTxPublicData(l),p},x=async(e,t,n,a=!1)=>{let o=e.userKeys.getShieldedPrivateKey(),s=c.calcStealthAddressStructure(i.UserKeys.findCorrectRandomization(r.randomBigInt(31),o),o,e.userKeys.getSpendingKeyPair().pubSpendingBJJPoint),l=i.UserKeys.getEncryptionKeyPair(o).publicKey;return b(e,n,[t],[s],[l],!1,void 0,a)},S=async(e,t,r,i,a=!1,s)=>{if(!o.isValidPrivateAddress(i))throw Error(n.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);let c=o.constructStealthAddressStructure(i),l=o.getEncryptionKeyFromRecipientInfo(i);return b(e,r,[t],[c],[l],!1,s,a)};exports.hinkalSolanaDeposit=x,exports.hinkalSolanaDepositForOther=S,exports.submitSolanaProoflessDeposit=b;
|
|
@@ -11,8 +11,8 @@ import { buildAnchorStealthAddressStructure as d, getMerkleAccountPublicKey as f
|
|
|
11
11
|
import { constructAdminData as g } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
12
12
|
import { shouldRetryForSolanaError as _ } from "../../error-handling/retrySolanaError.mjs";
|
|
13
13
|
import { emitTxPublicData as v } from "../../API/admin-calls.mjs";
|
|
14
|
-
import { assertNoDuplicateStealthAddressStructures as y, buildProoflessEncryptedOutputs as b } from "./hinkalProoflessDeposit.utils.mjs";
|
|
15
14
|
import "../../functions/pre-transaction/solanaTransfer.utils.mjs";
|
|
15
|
+
import { assertNoDuplicateStealthAddressStructures as y, buildProoflessEncryptedOutputs as b } from "./hinkalProoflessDeposit.utils.mjs";
|
|
16
16
|
import { PublicKey as x, Transaction as S, TransactionMessage as C, VersionedTransaction as w } from "@solana/web3.js";
|
|
17
17
|
import { BN as T } from "@coral-xyz/anchor";
|
|
18
18
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalSolanaDeposit.ts
|
|
@@ -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(`../utxo/Utxo.cjs`),s=require(`../../functions/utils/solanaMint.utils.cjs`),c=require(`../../functions/utils/addresses.cjs`),l=require(`../../types/external-action.types.cjs`),u=require(`../../types/
|
|
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(`../utxo/Utxo.cjs`),s=require(`../../functions/utils/solanaMint.utils.cjs`),c=require(`../../functions/utils/addresses.cjs`),l=require(`../../types/external-action.types.cjs`),u=require(`../../types/solana-transact.types.cjs`),d=require(`../../functions/utils/token-check.utils.cjs`),f=require(`../../functions/snarkjs/common.snarkjs.cjs`),p=require(`../../functions/pre-transaction/solana.cjs`),m=require(`../../functions/pre-transaction/constructAdminData.cjs`),h=require(`../../functions/pre-transaction/getFeeStructure.cjs`),g=require(`../../functions/pre-transaction/speculativeUtxo.cjs`);require(`../../functions/pre-transaction/index.cjs`);const _=require(`../../functions/web3/functionCalls/transactCallRelayer.cjs`),v=require(`../../functions/utils/fees.utils.cjs`);require(`../../functions/web3/index.cjs`);const y=require(`./hinkalProoflessDeposit.utils.cjs`),b=require(`./hinkalSolanaTransact.cjs`);let x=require(`ethers`),S=require(`@solana/web3.js`),C=require(`@coral-xyz/anchor`);var w=(n,a,o,c)=>{let{hinkalIdl:l,hinkalAddress:u,originalDeployer:d}=e.networkRegistry[a].contractData;if(!l)throw Error(`No IDL configured for Solana program on this network`);if(!d)throw Error(`missing original deployer`);let m=n.userKeys.getShieldedPrivateKey(),h=n.getSolanaProgram(l),g=n.getSolanaPublicKey(),_=new S.PublicKey(d),v=new S.PublicKey(u),{mintPublicKey:y}=s.formatMintAddress(o.erc20TokenAddress),b=y.toString(),x=p.getStorageAccountPublicKey(v,_),C=p.getStorageVaultPublicKey(v,_),w=p.getMerkleAccountPublicKey(v,_),T=c.map(()=>f.calcStealthAddressStructure(i.UserKeys.findCorrectRandomization(r.randomBigInt(31),m),m,n.userKeys.getSpendingKeyPair().pubSpendingBJJPoint)),E=T.map(e=>p.buildAnchorStealthAddressStructure(e)),D=i.UserKeys.getEncryptionKeyPair(m).publicKey,O=b===t.solanaNativeAddress;return{program:h,publicKey:g,originalDeployer:_,mint:O?null:y,atasValue:O?null:void 0,storageAccount:x,storageVault:C,merkleAccount:w,amounts:c,mintAddressString:b,stealthAddressStructures:T,anchorStealthStructures:E,ownEncryptionKey:D}},T=async(e,t)=>{let n=y.buildProoflessEncryptedOutputs(e.stealthAddressStructures,e.amounts.map(()=>e.ownEncryptionKey)).map(e=>Buffer.from(e.slice(2),`hex`)),{current:r,next:i}=await p.resolveSolanaRootBuckets(e.program,e.merkleAccount,e.amounts.length);return e.program.methods.multiPaymentDepositAt(e.amounts.map(e=>new C.BN(e.toString())),e.anchorStealthStructures,n,!0,t?new C.BN(t):null).accounts({mint:e.mint,signer:e.publicKey,signerAta:e.atasValue,originalDeployer:e.originalDeployer,storageAccount:e.storageAccount,storageVault:e.storageVault,merkleAccount:e.merkleAccount,rootBucketCurrent:r,rootBucketNext:i??e.program.programId,storageVaultAta:e.atasValue})},E=async(r,i,c,l,d,f,p,h,_,y)=>{let x=c.erc20TokenAddress;if(l.length===0)throw Error(`userDepositedUtxos must not be empty`);let{originalDeployer:S}=e.networkRegistry[i].contractData;if(!S)throw Error(`missing data`);let C=await r.getRandomRelay(i,!0);if(!C)throw Error(n.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let w=a.getCurrentTimeInSeconds().toString(),T=r.generateProofRemotely?5:1,E=[];for(let e=0;e<l.length;e+=T){let n=l.slice(e,e+T),a=await Promise.all(n.map(async({recipientAddress:n,utxo:a},l)=>{let S=e+l,T={recipient:n,mint:x===`11111111111111111111111111111111`?void 0:x},E=await v.calculateModifiedFeeStructure(i,c,f[S],d),D=m.constructAdminData(p,i,[x],[f[S]],await r.getEthereumAddress()),{compressedAddress:O}=s.formatMintAddress(t.solanaNativeAddress),k=new o.Utxo({amount:0n,mintAddress:x,erc20TokenAddress:O,nullifyingKey:r.userKeys.getShieldedPrivateKey(),timeStamp:w,spendingPublicKey:r.userKeys.getSpendingKeyPair().pubSpendingBJJPoint}),{args:A,commitmentValidationData:j}=await b.hinkalSolanaTransact(r,{chainId:i,mintAddresses:[x],amountChanges:[-a.amount],relayAddress:C,recipient:n,signer:C,functionName:`transact`,accounts:T,relayerFee:E.flatFee,variableRate:E.variableRate,inputUtxos:[[a,k]],useBlockedUtxos:!0,speculative:y&&{pendingLeaves:y,inputUtxos:[[g.toSpeculativeUtxo(a)]]},submit:{mode:u.SolanaSubmitMode.ProofOnly}});return{relayAddress:C,functionName:`transact`,chainId:i,recipientAmount:f[S].toString(),args:A,accounts:T,adminData:D,commitmentValidationData:j,displayRecipient:h?.[S],destinationChainId:_?.chainId,destinationTokenAddress:_?.tokenAddress,destinationTokenAmount:_?.tokenAmounts?.[S]}}));E.push(...a)}return E},D=async(e,t,n,r,i,u,f,p,m,g,y)=>{let b=d.validateAndGetChainId([t]),S=t.erc20TokenAddress,C=c.hashEthereumAddress(await e.getEthereumAddressByChain(b)),D=m?c.hashString(m):void 0,O=u??await h.getFeeStructure(b,S,[S],l.ExternalActionId.Transact,[],5n,{mintTo:S,recipient:r[0],nullifierCount:1}),k=n.map(e=>e+v.calculateTotalFee(e,O)),A=w(e,b,t,k),j=a.getCurrentTimeInSeconds().toString(),{compressedAddress:M}=s.formatMintAddress(S),N=A.stealthAddressStructures.map((t,n)=>({recipientAddress:r[n],utxo:new o.Utxo({amount:k[n],timeStamp:j,nullifyingKey:e.userKeys.getShieldedPrivateKey(),mintAddress:S,erc20TokenAddress:M,stealthAddress:x.ethers.toBeHex(t.stealthAddress),H0:[t.H0x,t.H0y]})})),{connection:P,wallet:F}=A.program.provider,I=async()=>{let e=await(await T(A,j)).transaction();return e.recentBlockhash=(await P.getLatestBlockhash()).blockhash,e.feePayer=A.publicKey,P.sendRawTransaction((await F.signTransaction(e)).serialize())},L=N.map(({utxo:e})=>BigInt(e.getCommitment()).toString()),[R,z]=await Promise.all([I(),E(e,b,t,N,O,n,p,g,y,L)]);return{depositTxHash:R,scheduleId:await _.solanaTransactCallRelayerBatch(b,z,C,i,f,D,R)}};exports.hinkalSolanaDepositAndWithdraw=D;
|
|
@@ -20,9 +20,9 @@ export declare const buildMultiPaymentDepositSetup: (hinkal: IHinkal, chainId: n
|
|
|
20
20
|
ownEncryptionKey: string;
|
|
21
21
|
};
|
|
22
22
|
export type MultiPaymentDepositSetup = ReturnType<typeof buildMultiPaymentDepositSetup>;
|
|
23
|
-
export declare const buildMultiPaymentDepositBuilder: (setup: MultiPaymentDepositSetup) => Promise<import('@coral-xyz/anchor/dist/cjs/program/namespace/methods').MethodsBuilder<import('@coral-xyz/anchor').Idl, import('@coral-xyz/anchor/dist/cjs/idl').IdlInstruction & {
|
|
23
|
+
export declare const buildMultiPaymentDepositBuilder: (setup: MultiPaymentDepositSetup, timeStamp?: string) => Promise<import('@coral-xyz/anchor/dist/cjs/program/namespace/methods').MethodsBuilder<import('@coral-xyz/anchor').Idl, import('@coral-xyz/anchor/dist/cjs/idl').IdlInstruction & {
|
|
24
24
|
name: string;
|
|
25
25
|
}, import('@coral-xyz/anchor/dist/cjs/idl').IdlInstructionAccountItem>>;
|
|
26
|
-
export declare const hinkalSolanaWithdrawBatch: (hinkal: IHinkal, chainId: number, token: ERC20Token, userDepositedUtxos: RecipientUtxo[], feeStructure: FeeStructure, hashedEthereumAddress: string, recipientAmounts: bigint[],
|
|
26
|
+
export declare const hinkalSolanaWithdrawBatch: (hinkal: IHinkal, chainId: number, token: ERC20Token, userDepositedUtxos: RecipientUtxo[], feeStructure: FeeStructure, hashedEthereumAddress: string, recipientAmounts: bigint[], txCompletionTime?: number, ref?: string, action?: AdminTransactionType, hashedDashboardAccountId?: string, displayRecipients?: string[], destination?: DestinationMetadata, pendingLeaves?: string[], dependsOnTxHash?: string) => Promise<string>;
|
|
27
27
|
export declare const hinkalSolanaDepositAndWithdraw: (hinkal: IHinkal, token: ERC20Token, recipientAmounts: bigint[], recipientAddresses: string[], txCompletionTime?: number, feeStructureOverride?: FeeStructure, // Should be passed fee for only one withdraw transaction, multiplication happening in this function
|
|
28
28
|
ref?: string, action?: AdminTransactionType, dashboardAccountId?: string, displayRecipients?: string[], destination?: DestinationMetadata) => Promise<DepositAndSendExtendedResult>;
|