@hinkal/common 0.3.6 → 0.3.7
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
|
@@ -8,51 +8,46 @@ import { Utxo as o } from "../utxo/Utxo.mjs";
|
|
|
8
8
|
import { formatMintAddress as s } from "../../functions/utils/solanaMint.utils.mjs";
|
|
9
9
|
import { hashEthereumAddress as c, hashString as l } from "../../functions/utils/addresses.mjs";
|
|
10
10
|
import { ExternalActionId as u } from "../../types/external-action.types.mjs";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import "../../
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import { fetchSolanaTransaction as x } from "../../functions/pre-transaction/sendV0Transaction.mjs";
|
|
19
|
-
import { getFeeStructure as S } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
20
|
-
import { waitForDepositedUtxosInMerkleTree as C } from "../../functions/pre-transaction/waitForDepositedUtxosInMerkleTree.mjs";
|
|
11
|
+
import { SolanaSubmitMode as d } from "../../types/solana-transact.types.mjs";
|
|
12
|
+
import { validateAndGetChainId as f } from "../../functions/utils/token-check.utils.mjs";
|
|
13
|
+
import { calcStealthAddressStructure as p } from "../../functions/snarkjs/common.snarkjs.mjs";
|
|
14
|
+
import { buildAnchorStealthAddressStructure as m, getMerkleAccountPublicKey as h, getStorageAccountPublicKey as g, getStorageVaultPublicKey as _, resolveSolanaRootBuckets as v } from "../../functions/pre-transaction/solana.mjs";
|
|
15
|
+
import { constructAdminData as y } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
16
|
+
import { getFeeStructure as b } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
17
|
+
import { toSpeculativeUtxo as x } from "../../functions/pre-transaction/speculativeUtxo.mjs";
|
|
21
18
|
import "../../functions/pre-transaction/index.mjs";
|
|
22
|
-
import { solanaTransactCallRelayerBatch as
|
|
23
|
-
import {
|
|
24
|
-
import { safeUpdateDepositAndWithdrawStatus as E, updateDepositAndWithdrawStatus as D } from "../../API/deposit-and-withdraw-status-calls.mjs";
|
|
25
|
-
import { getOnChainUtxosFromReceiptSolana as O } from "../../functions/utils/getUtxosFromReceiptSolana.mjs";
|
|
26
|
-
import { calculateModifiedFeeStructure as k, calculateTotalFee as A } from "../../functions/utils/fees.utils.mjs";
|
|
19
|
+
import { solanaTransactCallRelayerBatch as S } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
20
|
+
import { calculateModifiedFeeStructure as C, calculateTotalFee as w } from "../../functions/utils/fees.utils.mjs";
|
|
27
21
|
import "../../functions/web3/index.mjs";
|
|
28
|
-
import "
|
|
29
|
-
import { hinkalSolanaTransact as
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
22
|
+
import { buildProoflessEncryptedOutputs as T } from "./hinkalProoflessDeposit.utils.mjs";
|
|
23
|
+
import { hinkalSolanaTransact as E } from "./hinkalSolanaTransact.mjs";
|
|
24
|
+
import { ethers as D } from "ethers";
|
|
25
|
+
import { PublicKey as O } from "@solana/web3.js";
|
|
26
|
+
import { BN as k } from "@coral-xyz/anchor";
|
|
32
27
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.ts
|
|
33
|
-
var
|
|
28
|
+
var A = (n, a, o, c) => {
|
|
34
29
|
let { hinkalIdl: l, hinkalAddress: u, originalDeployer: d } = e[a].contractData;
|
|
35
30
|
if (!l) throw Error("No IDL configured for Solana program on this network");
|
|
36
31
|
if (!d) throw Error("missing original deployer");
|
|
37
|
-
let f = n.userKeys.getShieldedPrivateKey(),
|
|
32
|
+
let f = n.userKeys.getShieldedPrivateKey(), v = n.getSolanaProgram(l), y = n.getSolanaPublicKey(), b = new O(d), x = new O(u), { mintPublicKey: S } = s(o.erc20TokenAddress), C = S.toString(), w = g(x, b), T = _(x, b), E = h(x, b), D = c.map(() => p(i.findCorrectRandomization(r(31), f), f, n.userKeys.getSpendingKeyPair().pubSpendingBJJPoint)), k = D.map((e) => m(e)), A = i.getEncryptionKeyPair(f).publicKey, j = C === t;
|
|
38
33
|
return {
|
|
39
|
-
program:
|
|
34
|
+
program: v,
|
|
40
35
|
publicKey: y,
|
|
41
36
|
originalDeployer: b,
|
|
42
|
-
mint:
|
|
43
|
-
atasValue:
|
|
37
|
+
mint: j ? null : S,
|
|
38
|
+
atasValue: j ? null : void 0,
|
|
44
39
|
storageAccount: w,
|
|
45
40
|
storageVault: T,
|
|
46
41
|
merkleAccount: E,
|
|
47
42
|
amounts: c,
|
|
48
43
|
mintAddressString: C,
|
|
49
44
|
stealthAddressStructures: D,
|
|
50
|
-
anchorStealthStructures:
|
|
51
|
-
ownEncryptionKey:
|
|
45
|
+
anchorStealthStructures: k,
|
|
46
|
+
ownEncryptionKey: A
|
|
52
47
|
};
|
|
53
|
-
},
|
|
54
|
-
let
|
|
55
|
-
return e.program.methods.
|
|
48
|
+
}, j = async (e, t) => {
|
|
49
|
+
let n = T(e.stealthAddressStructures, e.amounts.map(() => e.ownEncryptionKey)).map((e) => Buffer.from(e.slice(2), "hex")), { current: r, next: i } = await v(e.program, e.merkleAccount, e.amounts.length);
|
|
50
|
+
return e.program.methods.multiPaymentDepositAt(e.amounts.map((e) => new k(e.toString())), e.anchorStealthStructures, n, !0, t ? new k(t) : null).accounts({
|
|
56
51
|
mint: e.mint,
|
|
57
52
|
signer: e.publicKey,
|
|
58
53
|
signerAta: e.atasValue,
|
|
@@ -60,119 +55,91 @@ var P = (n, a, o, c) => {
|
|
|
60
55
|
storageAccount: e.storageAccount,
|
|
61
56
|
storageVault: e.storageVault,
|
|
62
57
|
merkleAccount: e.merkleAccount,
|
|
63
|
-
rootBucketCurrent:
|
|
64
|
-
rootBucketNext:
|
|
58
|
+
rootBucketCurrent: r,
|
|
59
|
+
rootBucketNext: i ?? e.program.programId,
|
|
65
60
|
storageVaultAta: e.atasValue
|
|
66
61
|
});
|
|
67
|
-
},
|
|
68
|
-
let
|
|
69
|
-
chainId: t,
|
|
70
|
-
hashedEthereumAddress: o,
|
|
71
|
-
phase: d.BEFORE_DEPOSIT
|
|
72
|
-
})).id ?? void 0, f = await (await F(l)).rpc(), p = await l.program.provider.connection.getLatestBlockhash();
|
|
73
|
-
await l.program.provider.connection.confirmTransaction({
|
|
74
|
-
blockhash: p.blockhash,
|
|
75
|
-
lastValidBlockHeight: p.lastValidBlockHeight,
|
|
76
|
-
signature: f
|
|
77
|
-
}, "finalized");
|
|
78
|
-
let m = await x(l.program.provider.connection, f, "finalized");
|
|
79
|
-
if (!m) throw Error("Transaction missing");
|
|
80
|
-
await E({
|
|
81
|
-
id: u,
|
|
82
|
-
chainId: t,
|
|
83
|
-
hashedEthereumAddress: o,
|
|
84
|
-
phase: d.AFTER_DEPOSIT,
|
|
85
|
-
depositTxHash: f
|
|
86
|
-
});
|
|
87
|
-
let { compressedAddress: h } = s(n.erc20TokenAddress), g = O(m, l.program, e.userKeys, h), _ = [], v = [...g];
|
|
88
|
-
return i.forEach((e, t) => {
|
|
89
|
-
let n = c[t], r = v.find((e) => e.amount === n);
|
|
90
|
-
if (!r) throw Error(`Could not find newly created UTXO with amount ${n} for recipient ${e}.`);
|
|
91
|
-
_.push({
|
|
92
|
-
recipientAddress: e,
|
|
93
|
-
utxo: r
|
|
94
|
-
}), v.splice(v.indexOf(r), 1);
|
|
95
|
-
}), {
|
|
96
|
-
userDepositedUtxos: _,
|
|
97
|
-
depositTxHash: f,
|
|
98
|
-
statusId: u
|
|
99
|
-
};
|
|
100
|
-
}, L = async (r, i, c, l, u, p, m, h, g, _, v, y, x, S) => {
|
|
101
|
-
let C = c.erc20TokenAddress;
|
|
62
|
+
}, M = async (r, i, c, l, u, f, p, m, h, g) => {
|
|
63
|
+
let _ = c.erc20TokenAddress;
|
|
102
64
|
if (l.length === 0) throw Error("userDepositedUtxos must not be empty");
|
|
103
|
-
let { originalDeployer:
|
|
104
|
-
if (!
|
|
105
|
-
let
|
|
106
|
-
if (!
|
|
107
|
-
let
|
|
108
|
-
for (let e = 0; e < l.length; e +=
|
|
109
|
-
let n = l.slice(e, e +
|
|
110
|
-
let
|
|
65
|
+
let { originalDeployer: v } = e[i].contractData;
|
|
66
|
+
if (!v) throw Error("missing data");
|
|
67
|
+
let b = await r.getRandomRelay(i, !0);
|
|
68
|
+
if (!b) throw Error(n.RELAYER_NOT_AVAILABLE);
|
|
69
|
+
let S = a().toString(), w = r.generateProofRemotely ? 5 : 1, T = [];
|
|
70
|
+
for (let e = 0; e < l.length; e += w) {
|
|
71
|
+
let n = l.slice(e, e + w), a = await Promise.all(n.map(async ({ recipientAddress: n, utxo: a }, l) => {
|
|
72
|
+
let v = e + l, w = {
|
|
111
73
|
recipient: n,
|
|
112
|
-
mint:
|
|
113
|
-
},
|
|
74
|
+
mint: _ === "11111111111111111111111111111111" ? void 0 : _
|
|
75
|
+
}, T = await C(i, c, f[v], u), D = y(p, i, [_], [f[v]], await r.getEthereumAddress()), { compressedAddress: O } = s(t), k = new o({
|
|
114
76
|
amount: 0n,
|
|
115
|
-
mintAddress:
|
|
116
|
-
erc20TokenAddress:
|
|
77
|
+
mintAddress: _,
|
|
78
|
+
erc20TokenAddress: O,
|
|
117
79
|
nullifyingKey: r.userKeys.getShieldedPrivateKey(),
|
|
118
|
-
timeStamp:
|
|
80
|
+
timeStamp: S,
|
|
119
81
|
spendingPublicKey: r.userKeys.getSpendingKeyPair().pubSpendingBJJPoint
|
|
120
|
-
}), { args:
|
|
82
|
+
}), { args: A, commitmentValidationData: j } = await E(r, {
|
|
121
83
|
chainId: i,
|
|
122
|
-
mintAddresses: [
|
|
84
|
+
mintAddresses: [_],
|
|
123
85
|
amountChanges: [-a.amount],
|
|
124
|
-
relayAddress:
|
|
86
|
+
relayAddress: b,
|
|
125
87
|
recipient: n,
|
|
126
|
-
signer:
|
|
88
|
+
signer: b,
|
|
127
89
|
functionName: "transact",
|
|
128
|
-
accounts:
|
|
129
|
-
relayerFee:
|
|
130
|
-
variableRate:
|
|
131
|
-
inputUtxos: [[a,
|
|
90
|
+
accounts: w,
|
|
91
|
+
relayerFee: T.flatFee,
|
|
92
|
+
variableRate: T.variableRate,
|
|
93
|
+
inputUtxos: [[a, k]],
|
|
132
94
|
useBlockedUtxos: !0,
|
|
133
|
-
|
|
95
|
+
speculative: g && {
|
|
96
|
+
pendingLeaves: g,
|
|
97
|
+
inputUtxos: [[x(a)]]
|
|
98
|
+
},
|
|
99
|
+
submit: { mode: d.ProofOnly }
|
|
134
100
|
});
|
|
135
101
|
return {
|
|
136
|
-
relayAddress:
|
|
102
|
+
relayAddress: b,
|
|
137
103
|
functionName: "transact",
|
|
138
104
|
chainId: i,
|
|
139
|
-
recipientAmount:
|
|
140
|
-
args:
|
|
141
|
-
accounts:
|
|
142
|
-
adminData:
|
|
143
|
-
commitmentValidationData:
|
|
144
|
-
displayRecipient:
|
|
145
|
-
destinationChainId:
|
|
146
|
-
destinationTokenAddress:
|
|
147
|
-
destinationTokenAmount:
|
|
105
|
+
recipientAmount: f[v].toString(),
|
|
106
|
+
args: A,
|
|
107
|
+
accounts: w,
|
|
108
|
+
adminData: D,
|
|
109
|
+
commitmentValidationData: j,
|
|
110
|
+
displayRecipient: m?.[v],
|
|
111
|
+
destinationChainId: h?.chainId,
|
|
112
|
+
destinationTokenAddress: h?.tokenAddress,
|
|
113
|
+
destinationTokenAmount: h?.tokenAmounts?.[v]
|
|
148
114
|
};
|
|
149
115
|
}));
|
|
150
|
-
|
|
116
|
+
T.push(...a);
|
|
151
117
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
phase: d.BEFORE_SCHEDULE_WITHDRAW
|
|
157
|
-
});
|
|
158
|
-
let N = await w(i, M, p, g, _, y);
|
|
159
|
-
return await E({
|
|
160
|
-
id: h,
|
|
161
|
-
chainId: i,
|
|
162
|
-
hashedEthereumAddress: p,
|
|
163
|
-
phase: d.AFTER_SCHEDULE_WITHDRAW,
|
|
164
|
-
scheduleId: N
|
|
165
|
-
}), N;
|
|
166
|
-
}, R = async (e, t, n, r, i, a, o, s, d, f, m) => {
|
|
167
|
-
let h = p([t]), g = t.erc20TokenAddress, _ = c(await e.getEthereumAddressByChain(h)), v = d ? l(d) : void 0, y = a ?? await S(h, g, [g], u.Transact, [], 5n, {
|
|
168
|
-
mintTo: g,
|
|
118
|
+
return T;
|
|
119
|
+
}, N = async (e, t, n, r, i, d, p, m, h, g, _) => {
|
|
120
|
+
let v = f([t]), y = t.erc20TokenAddress, x = c(await e.getEthereumAddressByChain(v)), C = h ? l(h) : void 0, T = d ?? await b(v, y, [y], u.Transact, [], 5n, {
|
|
121
|
+
mintTo: y,
|
|
169
122
|
recipient: r[0],
|
|
170
123
|
nullifierCount: 1
|
|
171
|
-
}),
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
124
|
+
}), E = n.map((e) => e + w(e, T)), O = A(e, v, t, E), k = a().toString(), { compressedAddress: N } = s(y), P = O.stealthAddressStructures.map((t, n) => ({
|
|
125
|
+
recipientAddress: r[n],
|
|
126
|
+
utxo: new o({
|
|
127
|
+
amount: E[n],
|
|
128
|
+
timeStamp: k,
|
|
129
|
+
nullifyingKey: e.userKeys.getShieldedPrivateKey(),
|
|
130
|
+
mintAddress: y,
|
|
131
|
+
erc20TokenAddress: N,
|
|
132
|
+
stealthAddress: D.toBeHex(t.stealthAddress),
|
|
133
|
+
H0: [t.H0x, t.H0y]
|
|
134
|
+
})
|
|
135
|
+
})), { connection: F, wallet: I } = O.program.provider, L = async () => {
|
|
136
|
+
let e = await (await j(O, k)).transaction();
|
|
137
|
+
return e.recentBlockhash = (await F.getLatestBlockhash()).blockhash, e.feePayer = O.publicKey, F.sendRawTransaction((await I.signTransaction(e)).serialize());
|
|
138
|
+
}, R = P.map(({ utxo: e }) => BigInt(e.getCommitment()).toString()), [z, B] = await Promise.all([L(), M(e, v, t, P, T, n, m, g, _, R)]);
|
|
139
|
+
return {
|
|
140
|
+
depositTxHash: z,
|
|
141
|
+
scheduleId: await S(v, B, x, i, p, C, z)
|
|
175
142
|
};
|
|
176
143
|
};
|
|
177
144
|
//#endregion
|
|
178
|
-
export {
|
|
145
|
+
export { N as hinkalSolanaDepositAndWithdraw };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../functions/utils/token-check.utils.cjs`),n=require(`../../functions/pre-transaction/constructAdminData.cjs`),r=require(`../../functions/utils/create-provider.cjs`),i=require(`../AccountActions/AccountActions.cjs`),a=require(`../../functions/pre-transaction/sendV0Transaction.cjs`),o=require(`../../API/admin-calls.cjs`),s=require(`../../functions/pre-transaction/solanaTransfer.utils.cjs`);let c=require(`@solana/web3.js`);var l=async(n,a,o,l)=>{let u=t.validateAndGetChainId([n]),d=i.AccountActions.getAddressFromSubAccount(u,o);if(!d)throw Error(`Public account address is not available`);let{
|
|
1
|
+
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../functions/utils/token-check.utils.cjs`),n=require(`../../functions/pre-transaction/constructAdminData.cjs`),r=require(`../../functions/utils/create-provider.cjs`),i=require(`../AccountActions/AccountActions.cjs`),a=require(`../../functions/pre-transaction/sendV0Transaction.cjs`),o=require(`../../API/admin-calls.cjs`),s=require(`../../functions/pre-transaction/solanaTransfer.utils.cjs`);let c=require(`@solana/web3.js`);var l=async(n,a,o,l)=>{let u=t.validateAndGetChainId([n]),d=i.AccountActions.getAddressFromSubAccount(u,o);if(!d)throw Error(`Public account address is not available`);let{rpcUrl:f}=e.networkRegistry[u],p=r.createCustomSolanaConnection(f),m=new c.PublicKey(d),{instructions:h,programId:g}=await s.buildSolanaTransferInstructions(p,m,new c.PublicKey(l),n,a);return{connection:p,chainId:u,senderAddress:d,senderPublickey:m,programId:g,instructions:h}},u=async(e,t,r,i,s,c)=>{let[{connection:u,chainId:d,senderPublickey:f,instructions:p},m]=await Promise.all([l(t,r,i,s),e.getEthereumAddress()]),h=await a.sendProxyV0Transaction({connection:u,chainId:d,subAccount:i,payerPublicKey:f,instructions:p});return o.emitTxPublicData(n.constructAdminData(c,d,[t.erc20TokenAddress],[r],m)),h};exports.hinkalSolanaProxySend=u;
|
|
@@ -11,9 +11,7 @@ import { PublicKey as c } from "@solana/web3.js";
|
|
|
11
11
|
var l = async (n, a, o, l) => {
|
|
12
12
|
let u = t([n]), d = i.getAddressFromSubAccount(u, o);
|
|
13
13
|
if (!d) throw Error("Public account address is not available");
|
|
14
|
-
let {
|
|
15
|
-
if (!f) throw Error("RPC URL not found for the specified chain ID");
|
|
16
|
-
let p = r(f), m = new c(d), { instructions: h, programId: g } = await s(p, m, new c(l), n, a);
|
|
14
|
+
let { rpcUrl: f } = e[u], p = r(f), m = new c(d), { instructions: h, programId: g } = await s(p, m, new c(l), n, a);
|
|
17
15
|
return {
|
|
18
16
|
connection: p,
|
|
19
17
|
chainId: u,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`);require(`../../constants/protocol.constants.cjs`);const t=require(`../../error-handling/error-codes.constants.cjs`),n=require(`../../functions/utils/solanaMint.utils.cjs`),r=require(`../../functions/utils/addresses.cjs`),i=require(`../../functions/utils/token-check.utils.cjs`),a=require(`../../functions/pre-transaction/solana.cjs`),o=require(`../../functions/pre-transaction/constructAdminData.cjs`),s=require(`../../functions/utils/create-provider.cjs`),c=require(`../AccountActions/AccountActions.cjs`),l=require(`../../functions/pre-transaction/sendV0Transaction.cjs`),u=require(`../../API/admin-calls.cjs`),
|
|
1
|
+
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`);require(`../../constants/protocol.constants.cjs`);const t=require(`../../error-handling/error-codes.constants.cjs`),n=require(`../../functions/utils/solanaMint.utils.cjs`),r=require(`../../functions/utils/addresses.cjs`),i=require(`../../functions/utils/token-check.utils.cjs`),a=require(`../../functions/pre-transaction/solana.cjs`),o=require(`../../functions/pre-transaction/constructAdminData.cjs`),s=require(`../../functions/utils/create-provider.cjs`),c=require(`../AccountActions/AccountActions.cjs`),l=require(`../../functions/pre-transaction/sendV0Transaction.cjs`),u=require(`../../functions/utils/solana-program.utils.cjs`),d=require(`../../API/admin-calls.cjs`),f=require(`../../functions/utils/fees.utils.cjs`),p=require(`../../functions/pre-transaction/solanaTransfer.utils.cjs`),m=require(`./hinkalProoflessDeposit.utils.cjs`);let h=require(`@solana/web3.js`),g=require(`@coral-xyz/anchor`);var _=async({program:e,mintPublicKey:t,mintAddressString:n,tokenAmount:r,stealthAddressStructure:i,recipientEncryptionKey:o,senderPublickey:s,originalDeployer:c,storageAccount:l,storageVault:u,merkleAccount:d,rootBuckets:f,createBlockedUtxos:p})=>{let h=new g.BN(r.toString()),_=a.buildAnchorStealthAddressStructure(i),v=n===`11111111111111111111111111111111`?null:t,y=n===`11111111111111111111111111111111`?null:void 0,[b]=m.buildProoflessEncryptedOutputs([i],[o]),x=Buffer.from(b.slice(2),`hex`),{current:S,next:C}=f;return e.methods.prooflessDeposit(h,_,x,p).accounts({mint:v,signer:s,signerAta:y,originalDeployer:c,storageAccount:l,storageVault:u,merkleAccount:d,rootBucketCurrent:S,rootBucketNext:C??e.programId,storageVaultAta:y}).instruction()},v=async({chainId:i,token:o,tokenAmount:c,senderAddress:l,recipientInfo:d,createBlockedUtxos:f=!1})=>{if(!r.isValidPrivateAddress(d))throw Error(t.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);let{hinkalIdl:p,hinkalAddress:m,originalDeployer:g}=e.networkRegistry[i].contractData;if(!p)throw Error(`No IDL configured for Solana program on this network`);if(!g)throw Error(`missing original deployer`);let{rpcUrl:v}=e.networkRegistry[i],y=s.createCustomSolanaConnection(v),b=u.createReadOnlySolanaProgram(y,p),x=new h.PublicKey(g),S=new h.PublicKey(m),C=new h.PublicKey(l),{erc20TokenAddress:w}=o,{mintPublicKey:T}=n.formatMintAddress(w),E=T.toString(),D=a.getStorageAccountPublicKey(S,x),O=a.getStorageVaultPublicKey(S,x),k=a.getMerkleAccountPublicKey(S,x),A=r.constructStealthAddressStructure(d),j=r.getEncryptionKeyFromRecipientInfo(d),M=await a.resolveSolanaRootBuckets(b,k,1),N=await _({program:b,mintPublicKey:T,mintAddressString:E,tokenAmount:c,stealthAddressStructure:A,recipientEncryptionKey:j,senderPublickey:C,originalDeployer:x,storageAccount:D,storageVault:O,merkleAccount:k,rootBuckets:M,createBlockedUtxos:f}),P=n.getSolanaTokenProgramId(o.is2022Program);return{connection:y,senderAddress:l,senderPublickey:C,instructions:[N],storageAccount:D,storageVault:O,rootBucketCurrent:M.current,programId:P}},y=async(e,n,r,i,a,o,s=!1,l=0n)=>{let u=c.AccountActions.getAddressFromSubAccount(n,a);if(!u)throw Error(`Public account address is not available`);let d=await v({chainId:n,token:r,tokenAmount:i,senderAddress:u,recipientInfo:o??e.getRecipientInfo(),createBlockedUtxos:s});if(l<=0n)return d;let m=await e.getRandomRelay(n,!1);if(!m)throw Error(t.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let{instructions:g}=await p.buildSolanaTransferInstructions(d.connection,d.senderPublickey,new h.PublicKey(m),r,f.calculateVariableFee(i,l));return{...d,instructions:[...g,...d.instructions]}},b=async(e,t,n,r,a,s=!1,c=0n,u)=>{if(!r)throw Error(`subAccount is required`);let f=i.validateAndGetChainId([t]),[{connection:p,senderPublickey:m,instructions:h},g]=await Promise.all([y(e,f,t,n,r,a,s,c),e.getEthereumAddress()]),_=await l.sendProxyV0Transaction({connection:p,chainId:f,subAccount:r,payerPublicKey:m,instructions:h});return d.emitTxPublicData(o.constructAdminData(u,f,[t.erc20TokenAddress],[n],g)),_};exports.hinkalSolanaProxyShield=b;
|
|
@@ -1,6 +1,28 @@
|
|
|
1
|
+
import { Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
1
2
|
import { ERC20Token } from '../../types/token.types';
|
|
2
3
|
import { IHinkal } from './IHinkal';
|
|
3
4
|
import { SubAccount } from '../../types/proxy.types';
|
|
4
5
|
import { AdminTransactionType } from '../../types/admin.types';
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
type SolanaProxyShieldContext = {
|
|
7
|
+
connection: Connection;
|
|
8
|
+
senderAddress: string;
|
|
9
|
+
senderPublickey: PublicKey;
|
|
10
|
+
instructions: TransactionInstruction[];
|
|
11
|
+
storageAccount: PublicKey;
|
|
12
|
+
storageVault: PublicKey;
|
|
13
|
+
rootBucketCurrent: PublicKey;
|
|
14
|
+
programId: PublicKey;
|
|
15
|
+
};
|
|
16
|
+
type BuildSolanaShieldContextParams = {
|
|
17
|
+
chainId: number;
|
|
18
|
+
token: ERC20Token;
|
|
19
|
+
tokenAmount: bigint;
|
|
20
|
+
senderAddress: string;
|
|
21
|
+
recipientInfo: string;
|
|
22
|
+
createBlockedUtxos?: boolean;
|
|
23
|
+
};
|
|
24
|
+
export declare const buildSolanaShieldContext: ({ chainId, token, tokenAmount, senderAddress, recipientInfo, createBlockedUtxos, }: BuildSolanaShieldContextParams) => Promise<SolanaProxyShieldContext>;
|
|
25
|
+
export declare const buildSolanaProxyShieldContext: (hinkal: IHinkal, chainId: number, token: ERC20Token, tokenAmount: bigint, subAccount: SubAccount, recipientInfo?: string, createBlockedUtxos?: boolean, variableRate?: bigint) => Promise<SolanaProxyShieldContext>;
|
|
26
|
+
export declare const hinkalSolanaProxyShield: (hinkal: IHinkal, token: ERC20Token, tokenAmount: bigint, subAccount: SubAccount, recipientInfo?: string, createBlockedUtxos?: boolean, variableRate?: bigint, action?: AdminTransactionType) => Promise<string>;
|
|
27
|
+
export declare const getSolanaProxyShieldSerializedTransaction: (hinkal: IHinkal, token: ERC20Token, tokenAmount: bigint, subAccount: SubAccount, recipientInfo?: string, createBlockedUtxos?: boolean, variableRate?: bigint) => Promise<string>;
|
|
28
|
+
export {};
|
|
@@ -1,76 +1,95 @@
|
|
|
1
1
|
import { networkRegistry as e } from "../../constants/chains.constants.mjs";
|
|
2
2
|
import "../../constants/protocol.constants.mjs";
|
|
3
3
|
import { transactionErrorCodes as t } from "../../error-handling/error-codes.constants.mjs";
|
|
4
|
-
import { formatMintAddress as n } from "../../functions/utils/solanaMint.utils.mjs";
|
|
5
|
-
import { constructStealthAddressStructure as
|
|
6
|
-
import { validateAndGetChainId as
|
|
7
|
-
import { buildAnchorStealthAddressStructure as
|
|
8
|
-
import { constructAdminData as
|
|
9
|
-
import { createCustomSolanaConnection as
|
|
10
|
-
import { AccountActions as
|
|
11
|
-
import { sendProxyV0Transaction as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
4
|
+
import { formatMintAddress as n, getSolanaTokenProgramId as r } from "../../functions/utils/solanaMint.utils.mjs";
|
|
5
|
+
import { constructStealthAddressStructure as i, getEncryptionKeyFromRecipientInfo as a, isValidPrivateAddress as o } from "../../functions/utils/addresses.mjs";
|
|
6
|
+
import { validateAndGetChainId as s } from "../../functions/utils/token-check.utils.mjs";
|
|
7
|
+
import { buildAnchorStealthAddressStructure as c, getMerkleAccountPublicKey as l, getStorageAccountPublicKey as u, getStorageVaultPublicKey as d, resolveSolanaRootBuckets as f } from "../../functions/pre-transaction/solana.mjs";
|
|
8
|
+
import { constructAdminData as p } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
9
|
+
import { createCustomSolanaConnection as m } from "../../functions/utils/create-provider.mjs";
|
|
10
|
+
import { AccountActions as h } from "../AccountActions/AccountActions.mjs";
|
|
11
|
+
import { sendProxyV0Transaction as g } from "../../functions/pre-transaction/sendV0Transaction.mjs";
|
|
12
|
+
import { createReadOnlySolanaProgram as _ } from "../../functions/utils/solana-program.utils.mjs";
|
|
13
|
+
import { emitTxPublicData as v } from "../../API/admin-calls.mjs";
|
|
14
|
+
import { calculateVariableFee as y } from "../../functions/utils/fees.utils.mjs";
|
|
15
|
+
import { buildSolanaTransferInstructions as b } from "../../functions/pre-transaction/solanaTransfer.utils.mjs";
|
|
16
|
+
import { buildProoflessEncryptedOutputs as x } from "./hinkalProoflessDeposit.utils.mjs";
|
|
17
|
+
import { PublicKey as S } from "@solana/web3.js";
|
|
18
|
+
import { BN as C } from "@coral-xyz/anchor";
|
|
17
19
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalSolanaProxyShield.ts
|
|
18
|
-
var
|
|
19
|
-
let m = new
|
|
20
|
-
return e.methods.prooflessDeposit(m, h,
|
|
20
|
+
var w = async ({ program: e, mintPublicKey: t, mintAddressString: n, tokenAmount: r, stealthAddressStructure: i, recipientEncryptionKey: a, senderPublickey: o, originalDeployer: s, storageAccount: l, storageVault: u, merkleAccount: d, rootBuckets: f, createBlockedUtxos: p }) => {
|
|
21
|
+
let m = new C(r.toString()), h = c(i), g = n === "11111111111111111111111111111111" ? null : t, _ = n === "11111111111111111111111111111111" ? null : void 0, [v] = x([i], [a]), y = Buffer.from(v.slice(2), "hex"), { current: b, next: S } = f;
|
|
22
|
+
return e.methods.prooflessDeposit(m, h, y, p).accounts({
|
|
21
23
|
mint: g,
|
|
22
24
|
signer: o,
|
|
23
|
-
signerAta:
|
|
24
|
-
originalDeployer:
|
|
25
|
+
signerAta: _,
|
|
26
|
+
originalDeployer: s,
|
|
25
27
|
storageAccount: l,
|
|
26
28
|
storageVault: u,
|
|
27
|
-
merkleAccount:
|
|
28
|
-
rootBucketCurrent:
|
|
29
|
-
rootBucketNext:
|
|
30
|
-
storageVaultAta:
|
|
29
|
+
merkleAccount: d,
|
|
30
|
+
rootBucketCurrent: b,
|
|
31
|
+
rootBucketNext: S ?? e.programId,
|
|
32
|
+
storageVaultAta: _
|
|
31
33
|
}).instruction();
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (!
|
|
37
|
-
let {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
storageVault: L,
|
|
53
|
-
merkleAccount: R,
|
|
54
|
-
createBlockedUtxos: _
|
|
55
|
-
}), B = d.is2022Program ? b : x;
|
|
34
|
+
}, T = async ({ chainId: s, token: c, tokenAmount: p, senderAddress: h, recipientInfo: g, createBlockedUtxos: v = !1 }) => {
|
|
35
|
+
if (!o(g)) throw Error(t.RECIPIENT_FORMAT_INCORRECT);
|
|
36
|
+
let { hinkalIdl: y, hinkalAddress: b, originalDeployer: x } = e[s].contractData;
|
|
37
|
+
if (!y) throw Error("No IDL configured for Solana program on this network");
|
|
38
|
+
if (!x) throw Error("missing original deployer");
|
|
39
|
+
let { rpcUrl: C } = e[s], T = m(C), E = _(T, y), D = new S(x), O = new S(b), k = new S(h), { erc20TokenAddress: A } = c, { mintPublicKey: j } = n(A), M = j.toString(), N = u(O, D), P = d(O, D), F = l(O, D), I = i(g), L = a(g), R = await f(E, F, 1), z = await w({
|
|
40
|
+
program: E,
|
|
41
|
+
mintPublicKey: j,
|
|
42
|
+
mintAddressString: M,
|
|
43
|
+
tokenAmount: p,
|
|
44
|
+
stealthAddressStructure: I,
|
|
45
|
+
recipientEncryptionKey: L,
|
|
46
|
+
senderPublickey: k,
|
|
47
|
+
originalDeployer: D,
|
|
48
|
+
storageAccount: N,
|
|
49
|
+
storageVault: P,
|
|
50
|
+
merkleAccount: F,
|
|
51
|
+
rootBuckets: R,
|
|
52
|
+
createBlockedUtxos: v
|
|
53
|
+
}), B = r(c.is2022Program);
|
|
56
54
|
return {
|
|
57
|
-
connection:
|
|
58
|
-
senderAddress:
|
|
59
|
-
senderPublickey:
|
|
55
|
+
connection: T,
|
|
56
|
+
senderAddress: h,
|
|
57
|
+
senderPublickey: k,
|
|
60
58
|
instructions: [z],
|
|
61
|
-
storageAccount:
|
|
59
|
+
storageAccount: N,
|
|
60
|
+
storageVault: P,
|
|
61
|
+
rootBucketCurrent: R.current,
|
|
62
62
|
programId: B
|
|
63
63
|
};
|
|
64
|
-
},
|
|
64
|
+
}, E = async (e, n, r, i, a, o, s = !1, c = 0n) => {
|
|
65
|
+
let l = h.getAddressFromSubAccount(n, a);
|
|
66
|
+
if (!l) throw Error("Public account address is not available");
|
|
67
|
+
let u = await T({
|
|
68
|
+
chainId: n,
|
|
69
|
+
token: r,
|
|
70
|
+
tokenAmount: i,
|
|
71
|
+
senderAddress: l,
|
|
72
|
+
recipientInfo: o ?? e.getRecipientInfo(),
|
|
73
|
+
createBlockedUtxos: s
|
|
74
|
+
});
|
|
75
|
+
if (c <= 0n) return u;
|
|
76
|
+
let d = await e.getRandomRelay(n, !1);
|
|
77
|
+
if (!d) throw Error(t.RELAYER_NOT_AVAILABLE);
|
|
78
|
+
let { instructions: f } = await b(u.connection, u.senderPublickey, new S(d), r, y(i, c));
|
|
79
|
+
return {
|
|
80
|
+
...u,
|
|
81
|
+
instructions: [...f, ...u.instructions]
|
|
82
|
+
};
|
|
83
|
+
}, D = async (e, t, n, r, i, a = !1, o = 0n, c) => {
|
|
65
84
|
if (!r) throw Error("subAccount is required");
|
|
66
|
-
let
|
|
67
|
-
connection:
|
|
68
|
-
chainId:
|
|
85
|
+
let l = s([t]), [{ connection: u, senderPublickey: d, instructions: f }, m] = await Promise.all([E(e, l, t, n, r, i, a, o), e.getEthereumAddress()]), h = await g({
|
|
86
|
+
connection: u,
|
|
87
|
+
chainId: l,
|
|
69
88
|
subAccount: r,
|
|
70
|
-
payerPublicKey:
|
|
71
|
-
instructions:
|
|
89
|
+
payerPublicKey: d,
|
|
90
|
+
instructions: f
|
|
72
91
|
});
|
|
73
|
-
return
|
|
92
|
+
return v(p(c, l, [t.erc20TokenAddress], [n], m)), h;
|
|
74
93
|
};
|
|
75
94
|
//#endregion
|
|
76
|
-
export {
|
|
95
|
+
export { D as hinkalSolanaProxyShield };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../error-handling/error-codes.constants.cjs`),n=require(`../../types/external-action.types.cjs`),r=require(`../../functions/utils/token-check.utils.cjs`),i=require(`../../functions/pre-transaction/constructAdminData.cjs`),a=require(`../../functions/utils/create-provider.cjs`),o=require(`../AccountActions/AccountActions.cjs`),s=require(`../../functions/pre-transaction/sendV0Transaction.cjs`),c=require(`../../functions/pre-transaction/getFeeStructure.cjs`),l=require(`../../API/admin-calls.cjs`);require(`../../constants/index.cjs`);const u=require(`../../functions/pre-transaction/solanaTransfer.utils.cjs`);require(`../AccountActions/index.cjs`);let d=require(`@solana/web3.js`);var f=async(e,t)=>{let{addressLookupTableAccount:n,instructionLists:r}=JSON.parse(t).data,i=await Promise.all(n.map(async t=>{let n=await e.getAddressLookupTable(new d.PublicKey(t));if(!n.value)throw Error(`Failed to fetch lookup table: ${t}`);return n.value}));if(r.length===0)throw Error(`No instructions found`);return{instructions:r.map(e=>new d.TransactionInstruction({keys:e.accounts.map(e=>({pubkey:new d.PublicKey(e.pubkey),isSigner:e.isSigner,isWritable:e.isWritable})),programId:new d.PublicKey(e.programId),data:Buffer.from(e.data,`base64`)})),lookupTableAccounts:i}},p=async(e,t)=>{let n=d.VersionedTransaction.deserialize(Buffer.from(t,`base64`)),r=await Promise.all(n.message.addressTableLookups.map(async({accountKey:t})=>{let n=await e.getAddressLookupTable(t);if(!n.value)throw Error(`Failed to fetch lookup table: ${t.toBase58()}`);return n.value})),{instructions:i}=d.TransactionMessage.decompile(n.message,{addressLookupTableAccounts:r});return{instructions:i,lookupTableAccounts:r}},m=async(t,r,i,s)=>{let c=o.AccountActions.getAddressFromSubAccount(t,i);if(!c)throw Error(`Public account address is not available`);let{
|
|
1
|
+
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../error-handling/error-codes.constants.cjs`),n=require(`../../types/external-action.types.cjs`),r=require(`../../functions/utils/token-check.utils.cjs`),i=require(`../../functions/pre-transaction/constructAdminData.cjs`),a=require(`../../functions/utils/create-provider.cjs`),o=require(`../AccountActions/AccountActions.cjs`),s=require(`../../functions/pre-transaction/sendV0Transaction.cjs`),c=require(`../../functions/pre-transaction/getFeeStructure.cjs`),l=require(`../../API/admin-calls.cjs`);require(`../../constants/index.cjs`);const u=require(`../../functions/pre-transaction/solanaTransfer.utils.cjs`);require(`../AccountActions/index.cjs`);let d=require(`@solana/web3.js`);var f=async(e,t)=>{let{addressLookupTableAccount:n,instructionLists:r}=JSON.parse(t).data,i=await Promise.all(n.map(async t=>{let n=await e.getAddressLookupTable(new d.PublicKey(t));if(!n.value)throw Error(`Failed to fetch lookup table: ${t}`);return n.value}));if(r.length===0)throw Error(`No instructions found`);return{instructions:r.map(e=>new d.TransactionInstruction({keys:e.accounts.map(e=>({pubkey:new d.PublicKey(e.pubkey),isSigner:e.isSigner,isWritable:e.isWritable})),programId:new d.PublicKey(e.programId),data:Buffer.from(e.data,`base64`)})),lookupTableAccounts:i}},p=async(e,t)=>{let n=d.VersionedTransaction.deserialize(Buffer.from(t,`base64`)),r=await Promise.all(n.message.addressTableLookups.map(async({accountKey:t})=>{let n=await e.getAddressLookupTable(t);if(!n.value)throw Error(`Failed to fetch lookup table: ${t.toBase58()}`);return n.value})),{instructions:i}=d.TransactionMessage.decompile(n.message,{addressLookupTableAccounts:r});return{instructions:i,lookupTableAccounts:r}},m=async(t,r,i,s)=>{let c=o.AccountActions.getAddressFromSubAccount(t,i);if(!c)throw Error(`Public account address is not available`);let{rpcUrl:l}=e.networkRegistry[t],u=a.createCustomSolanaConnection(l),m=new d.PublicKey(c),{instructions:h,lookupTableAccounts:g}=s===n.ExternalActionId.Lifi?await p(u,r):await f(u,r);return{connection:u,walletPublicKey:m,instructions:h,lookupTableAccounts:g}},h=async(e,a,o,f,p,h,g,_,v)=>{let y=r.validateAndGetChainId(a),b=h===n.ExternalActionId.Lifi,[{connection:x,walletPublicKey:S,instructions:C,lookupTableAccounts:w},T,E]=await Promise.all([m(y,f,p,h),b?Promise.resolve(null):e.getRandomRelay(y),e.getEthereumAddressByChain(y)]),D=C;if(!b){if(!T)throw Error(t.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let e=a[1],r=o[1]*(_??await c.getFeeStructure(y,g,a.map(e=>e.erc20TokenAddress),n.ExternalActionId.Emporium)).variableRate/10000n,{instructions:i}=await u.buildSolanaTransferInstructions(x,S,new d.PublicKey(T),e,r);D=[...C,...i]}let O=await s.sendProxyV0Transaction({connection:x,chainId:y,subAccount:p,payerPublicKey:S,instructions:D,lookupTableAccounts:w});return l.emitTxPublicData(i.constructAdminData(v,y,a.map(e=>e.erc20TokenAddress),o,E,a)),O};exports.hinkalSolanaProxySwap=h;
|
|
@@ -45,9 +45,7 @@ var h = async (e, t) => {
|
|
|
45
45
|
}, _ = async (t, r, i, s) => {
|
|
46
46
|
let c = o.getAddressFromSubAccount(t, i);
|
|
47
47
|
if (!c) throw Error("Public account address is not available");
|
|
48
|
-
let {
|
|
49
|
-
if (!l) throw Error("RPC URL not found for the specified chain ID");
|
|
50
|
-
let u = a(l), f = new d(c), { instructions: p, lookupTableAccounts: m } = s === n.Lifi ? await g(u, r) : await h(u, r);
|
|
48
|
+
let { rpcUrl: l } = e[t], u = a(l), f = new d(c), { instructions: p, lookupTableAccounts: m } = s === n.Lifi ? await g(u, r) : await h(u, r);
|
|
51
49
|
return {
|
|
52
50
|
connection: u,
|
|
53
51
|
walletPublicKey: f,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AdminTransactionType } from '../../types/admin.types';
|
|
2
|
+
import { SubAccount } from '../../types/proxy.types';
|
|
3
|
+
import { ERC20Token } from '../../types/token.types';
|
|
4
|
+
import { IHinkal } from './IHinkal';
|
|
5
|
+
export declare const hinkalSolanaSponsoredProxySend: (hinkal: IHinkal, token: ERC20Token, tempSubAccount: SubAccount, landedAmount: bigint, recipientAddress: string, action?: AdminTransactionType) => Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../types/solana.types.cjs`),t=require(`../../functions/utils/token-check.utils.cjs`),n=require(`../../functions/pre-transaction/constructAdminData.cjs`),r=require(`../AccountActions/AccountActions.cjs`),i=require(`../../API/admin-calls.cjs`),a=require(`../../functions/utils/solana-sponsored.utils.cjs`);var o=async(o,s,c,l,u,d)=>{let f=t.validateAndGetChainId([s]),p=r.AccountActions.getAddressFromSubAccount(f,c);if(!p)throw Error(`Missing temp wallet address for bridge shield`);let m=await o.getRandomRelay(f,!0);if(!m)throw Error(`No Solana relayer available for bridge shield`);let{txHash:h,feeWei:g}=await a.sendSolanaSponsoredTx({chainId:f,tempSubAccount:c,intent:{kind:e.SolanaSponsoredTxKind.Shield,tokenAddress:s.erc20TokenAddress,amount:l.toString(),senderAddress:p,relayAddress:m,recipientInfo:u}}),_=l-g;return i.emitTxPublicData(n.constructAdminData(d,f,[s.erc20TokenAddress],[_],p)),{txHash:h,shieldedAmount:_}};exports.hinkalSolanaSponsoredShield=o;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AdminTransactionType } from '../../types/admin.types';
|
|
2
|
+
import { SubAccount } from '../../types/proxy.types';
|
|
3
|
+
import { ERC20Token } from '../../types/token.types';
|
|
4
|
+
import { IHinkal } from './IHinkal';
|
|
5
|
+
export declare const hinkalSolanaSponsoredShield: (hinkal: IHinkal, token: ERC20Token, tempSubAccount: SubAccount, landedAmount: bigint, recipientInfo: string, action?: AdminTransactionType) => Promise<{
|
|
6
|
+
txHash: string;
|
|
7
|
+
shieldedAmount: bigint;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SolanaSponsoredTxKind as e } from "../../types/solana.types.mjs";
|
|
2
|
+
import { validateAndGetChainId as t } from "../../functions/utils/token-check.utils.mjs";
|
|
3
|
+
import { constructAdminData as n } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
4
|
+
import { AccountActions as r } from "../AccountActions/AccountActions.mjs";
|
|
5
|
+
import { emitTxPublicData as i } from "../../API/admin-calls.mjs";
|
|
6
|
+
import { sendSolanaSponsoredTx as a } from "../../functions/utils/solana-sponsored.utils.mjs";
|
|
7
|
+
//#region libs/shared/common/src/data-structures/Hinkal/hinkalSolanaSponsoredShield.ts
|
|
8
|
+
var o = async (o, s, c, l, u, d) => {
|
|
9
|
+
let f = t([s]), p = r.getAddressFromSubAccount(f, c);
|
|
10
|
+
if (!p) throw Error("Missing temp wallet address for bridge shield");
|
|
11
|
+
let m = await o.getRandomRelay(f, !0);
|
|
12
|
+
if (!m) throw Error("No Solana relayer available for bridge shield");
|
|
13
|
+
let { txHash: h, feeWei: g } = await a({
|
|
14
|
+
chainId: f,
|
|
15
|
+
tempSubAccount: c,
|
|
16
|
+
intent: {
|
|
17
|
+
kind: e.Shield,
|
|
18
|
+
tokenAddress: s.erc20TokenAddress,
|
|
19
|
+
amount: l.toString(),
|
|
20
|
+
senderAddress: p,
|
|
21
|
+
relayAddress: m,
|
|
22
|
+
recipientInfo: u
|
|
23
|
+
}
|
|
24
|
+
}), _ = l - g;
|
|
25
|
+
return i(n(d, f, [s.erc20TokenAddress], [_], p)), {
|
|
26
|
+
txHash: h,
|
|
27
|
+
shieldedAmount: _
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
export { o as hinkalSolanaSponsoredShield };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../types/solana-transact.types.cjs`),t=require(`../../functions/web3/events/getShieldedBalance.cjs`),n=require(`../../functions/pre-transaction/outputUtxoProcessing.cjs`),r=require(`../../functions/snarkjs/common.snarkjs.cjs`),i=require(`../../functions/snarkjs/constructTxEnclave.cjs`),a=require(`../../functions/web3/functionCalls/transactCallRelayer.cjs`),
|
|
1
|
+
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../types/solana-transact.types.cjs`),t=require(`../../functions/web3/events/getShieldedBalance.cjs`),n=require(`../../functions/pre-transaction/outputUtxoProcessing.cjs`),r=require(`../../functions/snarkjs/common.snarkjs.cjs`),i=require(`../../functions/snarkjs/constructTxEnclave.cjs`),a=require(`../../functions/pre-transaction/speculativeUtxo.cjs`),o=require(`../../functions/web3/functionCalls/transactCallRelayer.cjs`),s=require(`../../functions/snarkjs/constructSolanaZkProof.cjs`);let c=require(`ethers`),l=require(`@solana/web3.js`);var u=(e=[])=>e.map(({accountIndexes:e,data:t,programIndex:n})=>({accountIndexes:Buffer.from(e),data:Buffer.from(t),programIndex:n})),d=(e=[])=>e.map(({pubkey:e,isSigner:t,isWritable:n})=>({pubkey:new l.PublicKey(e),isSigner:t,isWritable:n})),f=async(e,n)=>{let{inputUtxos:r,chainId:i,mintAddresses:a,amountChanges:o,useBlockedUtxos:s}=n;return r||[...await t.addPaddingToUtxos(e,i,a,o,void 0,void 0,s)]},p=(e,t,r)=>{let{amountChanges:i,recipientAddress:a,recipientAmounts:o}=e;return n.buildOutputUtxos(t,r,i,a===void 0?void 0:[a],a===void 0?void 0:[o??[]])},m=async(e,t,n)=>{let{chainId:i,mintAddresses:o,relayAddress:l,recipient:m,relayerFee:h,variableRate:g,functionName:_,hinkalInstructions:v,remainingAccounts:y,swapperAccountSalt:b,onChainCreation:x,speculative:S}=t,C=await f(e,t),w=p(t,n,C),T=e.merkleTreeHinkalByChain[i],E=S?a.speculativeMerkleTree(T,C,S.pendingLeaves):T,D={tokenNumber:o.length,nullifierAmount:C[0].length,outputAmount:w[0].length},{proofAArr:O,proofBArr:k,proofCArr:A,publicInputsArr:j,commitmentValidationData:M,rootHashHinkalIndex:N,encryptedOutputs:P,onChainEncryptedOutput:F}=await s.constructSolanaZkProof(E,n,o,C,w,h??0n,g??0n,m,l,D,x,i,u(v),d(y),b,E!==T);return{args:{proofAArr:O,proofBArr:k,proofCArr:A,publicInputsArr:j,encryptedOutputs:P,relayerFee:(h??0n).toString(),..._===`swap`?{variableRate:(g??0n).toString(),onChainEncryptedOutput:F,onChainCreation:x??[],hinkalInstructions:v??[]}:{},dimensions:D,rootHashIndex:N.toString()},commitmentValidationData:M,notes:{inputNullifiers:C.flat().filter(e=>e.amount>0n).map(e=>e.getNullifier()),outCommitments:r.buildOutCommitments(w).flat(),encryptedOutputs:P.map(e=>c.ethers.hexlify(new Uint8Array(e)))}}},h=async(e,t,n)=>{let{inputUtxos:r}=t,{jobId:a,signedMessageHash:o}=await i.prepareSolanaTxEnclaveCall(e,{chainId:t.chainId,mintAddresses:t.mintAddresses,amountChanges:t.amountChanges,relayAddress:t.relayAddress,recipient:t.recipient,signer:t.signer,functionName:t.functionName,accounts:t.accounts,onChainCreation:t.onChainCreation,relayerFee:t.relayerFee,variableRate:t.variableRate,swapperAccountSalt:t.swapperAccountSalt,hinkalInstructions:t.hinkalInstructions,remainingAccounts:t.remainingAccounts,recipientAddress:t.recipientAddress,recipientAmounts:t.recipientAmounts,recipientAmount:t.recipientAmount,displayRecipient:t.displayRecipient,useBlockedUtxos:t.useBlockedUtxos,messageSeed:t.messageSeed,inputCommitments:t.speculative?void 0:i.collectInputCommitments(r),speculative:t.speculative},n),{R8:s,S:c}=n.signEddsa(BigInt(o));return{jobId:a,eddsaSignature:{R8:s,S:c}}},g=(t,n)=>{let{chainId:r,relayAddress:i,functionName:a,accounts:s,submit:c}=t;if(c.mode!==e.SolanaSubmitMode.Relayer)throw Error(`hinkalSolanaTransact: relayer submit expected`);return o.solanaTransactCallRelayer({chainId:r,relayAddress:i,functionName:a,args:n.args,accounts:s,commitmentValidationData:n.commitmentValidationData,adminData:c.adminData})},_=async(t,n)=>{if(t.submit.mode!==e.SolanaSubmitMode.Relayer)return n;let r=await g(t,n);return n.notes&&t.onTxSubmitLocally?.(n.notes),r},v=async(t,n)=>{if(n.userKeys&&!n.inputUtxos)throw Error(`hinkalSolanaTransact: userKeys requires explicit inputUtxos`);let r=n.userKeys??t.userKeys,{chainId:a,submit:o}=n;if(t.generateProofRemotely){let{jobId:s,eddsaSignature:c}=await h(t,n,r);if(o.mode===e.SolanaSubmitMode.Relayer)return i.finalizeSolanaTxEnclaveCallRelay(s,c,a,{adminData:o.adminData});let{solanaArgs:l,commitmentValidationData:u}=await i.finalizeSolanaTxEnclaveCall(s,c);return _(n,{args:l,commitmentValidationData:u})}return _(n,await m(t,n,r))};exports.hinkalSolanaTransact=v;
|