@hinkal/common 0.3.12 → 0.3.14
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 +67 -4
- package/common/src/API/API.cjs +1 -1
- package/common/src/API/API.d.ts +3 -2
- package/common/src/API/API.mjs +92 -91
- package/common/src/API/admin-calls.cjs +1 -1
- package/common/src/API/admin-calls.d.ts +2 -1
- package/common/src/API/admin-calls.mjs +1 -0
- package/common/src/API/evm-token-assets.cjs +1 -0
- package/common/src/API/evm-token-assets.mjs +3 -0
- package/common/src/API/get-token-price-chart-data.cjs +1 -1
- package/common/src/API/get-token-price-chart-data.mjs +2 -2
- package/common/src/API/getTokenPrice.cjs +1 -1
- package/common/src/API/getTokenPrice.mjs +2 -2
- package/common/src/API/index.cjs +1 -1
- package/common/src/API/index.d.ts +2 -0
- package/common/src/API/index.mjs +2 -0
- package/common/src/API/privacy-score-calls.cjs +1 -1
- package/common/src/API/privacy-score-calls.mjs +2 -2
- package/common/src/API/receiveVaultCalls.cjs +1 -0
- package/common/src/API/receiveVaultCalls.d.ts +12 -0
- package/common/src/API/receiveVaultCalls.mjs +36 -0
- package/common/src/constants/chains.constants.cjs +1 -1
- package/common/src/constants/chains.constants.d.ts +2 -0
- package/common/src/constants/chains.constants.mjs +106 -93
- package/common/src/constants/coingecko.constants.cjs +1 -1
- package/common/src/constants/coingecko.constants.d.ts +2 -0
- package/common/src/constants/coingecko.constants.mjs +1 -1
- package/common/src/constants/contracts.constants.cjs +1 -1
- package/common/src/constants/contracts.constants.mjs +5 -1
- 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 -1
- package/common/src/constants/deploy-data/deploy-data-arcTestnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-arcTestnet.json.mjs +4 -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 -1
- 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 -1
- 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 -1
- package/common/src/constants/deploy-data/deploy-data-localhost.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-localhost.json.mjs +2 -1
- package/common/src/constants/deploy-data/deploy-data-optimism.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-optimism.json.mjs +2 -1
- package/common/src/constants/deploy-data/deploy-data-optimismTest.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-optimismTest.json.mjs +2 -1
- 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 -1
- package/common/src/constants/deploy-data/deploy-data-sepoliaTestnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-sepoliaTestnet.json.mjs +2 -1
- package/common/src/constants/deploy-data/deploy-data-solanaDevnet.json.cjs +1 -0
- package/common/src/constants/deploy-data/deploy-data-solanaDevnet.json.mjs +6 -0
- 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 -1
- package/common/src/constants/deploy-data/deploy-data-tronMainnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-tronMainnet.json.mjs +2 -1
- package/common/src/constants/deploy-data/deploy-data-tronNile.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-tronNile.json.mjs +2 -1
- package/common/src/constants/deploy-data/index.cjs +1 -1
- package/common/src/constants/deploy-data/index.d.ts +2 -1
- package/common/src/constants/deploy-data/index.mjs +7 -6
- 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 +2 -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/deploy-data/shared-deploy-data-tron.json.cjs +1 -1
- package/common/src/constants/deploy-data/shared-deploy-data-tron.json.mjs +3 -2
- package/common/src/constants/events.constants.d.ts +1 -0
- package/common/src/constants/index.cjs +1 -1
- package/common/src/constants/index.mjs +1 -1
- package/common/src/constants/protocol.constants.cjs +2 -2
- package/common/src/constants/protocol.constants.d.ts +4 -0
- package/common/src/constants/protocol.constants.mjs +2 -2
- package/common/src/constants/save-depths.cjs +1 -1
- package/common/src/constants/save-depths.d.ts +1 -0
- package/common/src/constants/save-depths.mjs +1 -0
- package/common/src/constants/server.constants.cjs +1 -1
- package/common/src/constants/server.constants.d.ts +13 -6
- package/common/src/constants/server.constants.mjs +13 -6
- package/common/src/constants/tokens.constants.cjs +1 -1
- package/common/src/constants/tokens.constants.mjs +1 -1
- package/common/src/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/common/src/data-structures/Hinkal/Hinkal.d.ts +8 -4
- package/common/src/data-structures/Hinkal/Hinkal.mjs +85 -73
- package/common/src/data-structures/Hinkal/IHinkal.d.ts +8 -4
- package/common/src/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
- package/common/src/data-structures/Hinkal/handleAutoDepositBack.mjs +14 -14
- package/common/src/data-structures/Hinkal/hinkalActionReceive.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalActionReceive.mjs +4 -4
- package/common/src/data-structures/Hinkal/hinkalBridgePrivateToPrivate.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalBridgePrivateToPrivate.mjs +24 -24
- package/common/src/data-structures/Hinkal/hinkalDepositAndBridge.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDepositAndBridge.mjs +72 -71
- package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +64 -61
- package/common/src/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalPrivateWallet.d.ts +1 -1
- package/common/src/data-structures/Hinkal/hinkalPrivateWallet.mjs +29 -29
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.d.ts +1 -1
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.mjs +22 -22
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.utils.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.utils.mjs +8 -8
- package/common/src/data-structures/Hinkal/hinkalProxySwap.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalProxySwap.mjs +6 -6
- package/common/src/data-structures/Hinkal/hinkalProxyToPrivate.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalProxyToPrivate.mjs +4 -4
- package/common/src/data-structures/Hinkal/hinkalReceiveVaultAccount.cjs +1 -0
- package/common/src/data-structures/Hinkal/hinkalReceiveVaultAccount.d.ts +3 -0
- package/common/src/data-structures/Hinkal/hinkalReceiveVaultAccount.mjs +12 -0
- package/common/src/data-structures/Hinkal/hinkalReceiveVaultCreate.cjs +1 -0
- package/common/src/data-structures/Hinkal/hinkalReceiveVaultCreate.d.ts +3 -0
- package/common/src/data-structures/Hinkal/hinkalReceiveVaultCreate.mjs +29 -0
- package/common/src/data-structures/Hinkal/hinkalReceiveVaultRecover.cjs +1 -0
- package/common/src/data-structures/Hinkal/hinkalReceiveVaultRecover.d.ts +5 -0
- package/common/src/data-structures/Hinkal/hinkalReceiveVaultRecover.mjs +66 -0
- package/common/src/data-structures/Hinkal/hinkalReceiveVaultSettle.cjs +1 -0
- package/common/src/data-structures/Hinkal/hinkalReceiveVaultSettle.d.ts +6 -0
- package/common/src/data-structures/Hinkal/hinkalReceiveVaultSettle.mjs +8 -0
- package/common/src/data-structures/Hinkal/hinkalSolanaDeposit.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaDeposit.d.ts +2 -2
- package/common/src/data-structures/Hinkal/hinkalSolanaDeposit.mjs +54 -62
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +72 -70
- package/common/src/data-structures/Hinkal/hinkalSolanaProxySend.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaProxySend.mjs +9 -9
- package/common/src/data-structures/Hinkal/hinkalSolanaProxyShield.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaProxyShield.mjs +20 -20
- package/common/src/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaProxySwap.d.ts +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +49 -47
- package/common/src/data-structures/Hinkal/hinkalSolanaReceiveVault.cjs +1 -0
- package/common/src/data-structures/Hinkal/hinkalSolanaReceiveVault.d.ts +5 -0
- package/common/src/data-structures/Hinkal/hinkalSolanaReceiveVault.mjs +60 -0
- package/common/src/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaTransfer.mjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalTransact.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalTransact.mjs +7 -6
- package/common/src/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalTransfer.mjs +4 -4
- package/common/src/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalWithdraw.mjs +35 -26
- package/common/src/data-structures/Hinkal/index.d.ts +5 -0
- package/common/src/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/common/src/data-structures/Hinkal/resetMerkleTrees.mjs +13 -13
- package/common/src/data-structures/TokenDBs/AlchemyPublicTokensDB.d.ts +0 -3
- package/common/src/data-structures/TokenDBs/EventsPublicTokensDB.d.ts +0 -1
- package/common/src/data-structures/TokenDBs/TronPublicTokensDB.d.ts +0 -2
- package/common/src/data-structures/crypto-keys/index.cjs +1 -1
- package/common/src/data-structures/crypto-keys/index.mjs +1 -1
- package/common/src/error-handling/error-codes.constants.cjs +1 -1
- package/common/src/error-handling/error-codes.constants.d.ts +6 -0
- package/common/src/error-handling/error-codes.constants.mjs +7 -2
- package/common/src/error-handling/get-error.message.cjs +1 -1
- package/common/src/error-handling/get-error.message.mjs +59 -49
- package/common/src/functions/index.cjs +1 -1
- package/common/src/functions/index.mjs +8 -3
- package/common/src/functions/pre-transaction/addressTableLookup.d.ts +1 -0
- package/common/src/functions/pre-transaction/build-proofless-deposit-fee.cjs +1 -0
- package/common/src/functions/pre-transaction/build-proofless-deposit-fee.d.ts +4 -0
- package/common/src/functions/pre-transaction/build-proofless-deposit-fee.mjs +3 -0
- package/common/src/functions/pre-transaction/calculateSolanaNullifierCount.cjs +1 -1
- package/common/src/functions/pre-transaction/calculateSolanaNullifierCount.mjs +7 -7
- package/common/src/functions/pre-transaction/constructAdminData.cjs +1 -1
- package/common/src/functions/pre-transaction/constructAdminData.mjs +4 -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 -0
- package/common/src/functions/pre-transaction/sendV0Transaction.cjs +1 -1
- package/common/src/functions/pre-transaction/sendV0Transaction.d.ts +1 -0
- package/common/src/functions/pre-transaction/sendV0Transaction.mjs +22 -2
- package/common/src/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/common/src/functions/private-wallet/emporium.helpers.mjs +15 -15
- package/common/src/functions/snarkjs/constructTxEnclaveVerify.cjs +1 -1
- package/common/src/functions/snarkjs/constructTxEnclaveVerify.mjs +2 -1
- package/common/src/functions/snarkjs/fetchOnChainRootHashes.cjs +1 -1
- package/common/src/functions/snarkjs/fetchOnChainRootHashes.mjs +6 -6
- package/common/src/functions/utils/abi.utils.cjs +1 -1
- package/common/src/functions/utils/abi.utils.mjs +4 -1
- package/common/src/functions/utils/addresses.cjs +1 -1
- package/common/src/functions/utils/addresses.d.ts +4 -0
- package/common/src/functions/utils/addresses.mjs +17 -17
- package/common/src/functions/utils/admin-dimensions.cjs +1 -0
- package/common/src/functions/utils/admin-dimensions.d.ts +4 -0
- package/common/src/functions/utils/admin-dimensions.mjs +206 -0
- package/common/src/functions/utils/create-provider.cjs +1 -1
- package/common/src/functions/utils/create-provider.mjs +5 -1
- package/common/src/functions/utils/encryptInputForEnclave.cjs +1 -1
- package/common/src/functions/utils/encryptInputForEnclave.d.ts +2 -1
- package/common/src/functions/utils/encryptInputForEnclave.mjs +1 -1
- package/common/src/functions/utils/erc20tokenFunctions.cjs +1 -1
- package/common/src/functions/utils/erc20tokenFunctions.mjs +11 -11
- 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 +31 -33
- package/common/src/functions/utils/gas-token.utils.cjs +1 -0
- package/common/src/functions/utils/gas-token.utils.d.ts +3 -0
- package/common/src/functions/utils/gas-token.utils.mjs +7 -0
- package/common/src/functions/utils/getSignerFromContract.cjs +1 -1
- package/common/src/functions/utils/getSignerFromContract.d.ts +1 -1
- package/common/src/functions/utils/getSignerFromContract.mjs +2 -2
- package/common/src/functions/utils/getUtxosFromReceipt.utils.cjs +1 -1
- package/common/src/functions/utils/getUtxosFromReceipt.utils.mjs +1 -1
- package/common/src/functions/utils/getUtxosFromReceiptSolana.cjs +1 -1
- package/common/src/functions/utils/getUtxosFromReceiptSolana.d.ts +9 -4
- package/common/src/functions/utils/getUtxosFromReceiptSolana.mjs +1 -1
- package/common/src/functions/utils/index.cjs +1 -1
- package/common/src/functions/utils/index.d.ts +5 -0
- package/common/src/functions/utils/index.mjs +7 -2
- package/common/src/functions/utils/isSigner.cjs +1 -0
- package/common/src/functions/utils/isSigner.d.ts +2 -0
- package/common/src/functions/utils/isSigner.mjs +7 -0
- package/common/src/functions/utils/publicBalance.utils.cjs +1 -1
- package/common/src/functions/utils/publicBalance.utils.mjs +7 -7
- package/common/src/functions/utils/receive-vault-account.utils.cjs +1 -0
- package/common/src/functions/utils/receive-vault-account.utils.d.ts +9 -0
- package/common/src/functions/utils/receive-vault-account.utils.mjs +24 -0
- package/common/src/functions/utils/receive-vault-scan.utils.cjs +1 -0
- package/common/src/functions/utils/receive-vault-scan.utils.d.ts +2 -0
- package/common/src/functions/utils/receive-vault-scan.utils.mjs +55 -0
- package/common/src/functions/utils/receive-vault-solana.utils.cjs +1 -0
- package/common/src/functions/utils/receive-vault-solana.utils.d.ts +8 -0
- package/common/src/functions/utils/receive-vault-solana.utils.mjs +45 -0
- package/common/src/functions/utils/receive-vault.utils.cjs +2 -0
- package/common/src/functions/utils/receive-vault.utils.d.ts +31 -0
- package/common/src/functions/utils/receive-vault.utils.mjs +166 -0
- package/common/src/functions/utils/string.utils.cjs +1 -1
- package/common/src/functions/utils/string.utils.mjs +12 -4
- package/common/src/functions/utils/temporary-wallet-recovery.utils.cjs +1 -1
- package/common/src/functions/utils/temporary-wallet-recovery.utils.mjs +1 -1
- package/common/src/functions/utils/token-check.utils.d.ts +1 -0
- package/common/src/functions/utils/transfer-claimable.utils.cjs +1 -1
- package/common/src/functions/utils/transfer-claimable.utils.mjs +1 -1
- package/common/src/functions/utils/wallet-token-discovery.utils.cjs +1 -0
- package/common/src/functions/utils/wallet-token-discovery.utils.d.ts +9 -0
- package/common/src/functions/utils/wallet-token-discovery.utils.mjs +30 -0
- package/common/src/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/common/src/functions/web3/functionCalls/transactCallDirect.mjs +11 -11
- package/common/src/functions/web3/getContractMetadata.cjs +1 -1
- package/common/src/functions/web3/getContractMetadata.mjs +6 -6
- package/common/src/functions/web3/index.cjs +1 -1
- package/common/src/functions/web3/index.mjs +1 -1
- package/common/src/types/admin.types.cjs +1 -1
- package/common/src/types/admin.types.d.ts +64 -9
- package/common/src/types/admin.types.mjs +10 -2
- package/common/src/types/connector.types.d.ts +1 -0
- package/common/src/types/ethereum-network.types.cjs +1 -1
- package/common/src/types/ethereum-network.types.d.ts +5 -1
- 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 +3 -1
- 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 -0
- package/common/src/types/index.mjs +1 -0
- package/common/src/types/receive-vault.types.cjs +1 -0
- package/common/src/types/receive-vault.types.d.ts +63 -0
- package/common/src/types/receive-vault.types.mjs +8 -0
- package/common/src/types/remote-tx-build.types.d.ts +5 -0
- package/common/src/webworker/{logError-cvFNxc-0.js → logError-C-ej_TX9.js} +1 -1
- package/common/src/webworker/package.json +10 -1
- package/common/src/webworker/snarkjsWorker/snarkjsWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/snarkjsWorker/snarkjsWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/snarkjsWorkerNode.cjs +1 -1
- package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/utxoWorkerNode.cjs +1 -1
- package/common/src/webworker/viteWorkerURL.constant.cjs +3 -3
- package/common/src/webworker/viteWorkerURL.constant.mjs +3 -3
- package/common/src/webworker/workerProxy-CE-rYA3W.js +1 -0
- package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/zkProofWorkerNode.cjs +1 -1
- package/index.cjs +1 -1
- package/index.mjs +3 -2
- package/internal/monitorConnectedAddress.cjs +1 -1
- package/internal/monitorConnectedAddress.d.ts +1 -1
- package/internal/monitorConnectedAddress.mjs +1 -3
- package/package.json +10 -1
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +1 -1
- package/providers/prepareSolanaHinkal.cjs +1 -1
- package/providers/prepareSolanaHinkal.mjs +1 -1
- package/providers/prepareTronHinkal.cjs +1 -1
- package/providers/prepareTronHinkal.mjs +1 -1
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +1 -1
- package/services/Hinkal.cjs +1 -1
- package/services/Hinkal.d.ts +7 -3
- package/services/Hinkal.mjs +74 -51
- package/types/IHinkal.d.ts +7 -2
- package/types/index.cjs +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.mjs +2 -0
- package/types/receive-vault.types.cjs +1 -0
- package/types/receive-vault.types.d.ts +14 -0
- package/types/receive-vault.types.mjs +2 -0
- package/common/src/API/getOdosPriceForToken.cjs +0 -1
- package/common/src/API/getOdosPriceForToken.d.ts +0 -1
- package/common/src/API/getOdosPriceForToken.mjs +0 -14
- package/common/src/webworker/workerProxy-BHzCZ9HT.js +0 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
import { Types as TronWebTypes } from 'tronweb';
|
|
3
|
+
import { ReceiveVaultRecord } from '../../types/receive-vault.types';
|
|
4
|
+
import { IHinkal } from './IHinkal';
|
|
5
|
+
export declare const hinkalReceiveVaultRecover: (hinkal: IHinkal, record: ReceiveVaultRecord, token: string, chainId: number, to: string, returnTxData?: boolean) => Promise<string | ethers.TransactionRequest | TronWebTypes.Transaction<TronWebTypes.TriggerSmartContract>>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { isSolanaLike as e, isTronLike as t, networkRegistry as n } from "../../constants/chains.constants.mjs";
|
|
2
|
+
import { TRON_DEFAULT_FEE_LIMIT_SUN as r } from "../../constants/protocol.constants.mjs";
|
|
3
|
+
import { addressToHexFormat as i, createTronCallData as a, evmHexToTronBase58Address as o } from "../../functions/utils/tron.utils.mjs";
|
|
4
|
+
import { ContractType as s } from "../../types/ethereum-network.types.mjs";
|
|
5
|
+
import { getReceiveVaultFactoryAddress as c, getReceiveVaultParams as l, receiveVaultNetworkOf as u, receiveVaultParamsToTuple as d, signReceiveVaultRecovery as f } from "../../functions/utils/receive-vault.utils.mjs";
|
|
6
|
+
import { hexToUtf8 as p } from "../../functions/utils/string.utils.mjs";
|
|
7
|
+
import { getErrorMessage as m } from "../../error-handling/get-error.message.mjs";
|
|
8
|
+
import { hinkalSolanaReceiveVaultRecover as h } from "./hinkalSolanaReceiveVault.mjs";
|
|
9
|
+
import { ethers as g } from "ethers";
|
|
10
|
+
//#region libs/shared/common/src/data-structures/Hinkal/hinkalReceiveVaultRecover.ts
|
|
11
|
+
var _ = {
|
|
12
|
+
NothingToSettle: "These funds have already been moved out of the receive address.",
|
|
13
|
+
RecoveryExpired: "The recovery request expired before it was confirmed. Please try again.",
|
|
14
|
+
BadRecoverySignature: "This wallet cannot recover these funds. Reconnect the account that generated the address.",
|
|
15
|
+
RecoveryAlreadyUsed: "This recovery was already submitted. Please try again."
|
|
16
|
+
}, v = (e) => {
|
|
17
|
+
let t = e?.revert?.name;
|
|
18
|
+
if (t && _[t]) return _[t];
|
|
19
|
+
let n = JSON.stringify(e ?? ""), r = Object.keys(_).find((e) => n.includes(g.id(`${e}()`).slice(2, 10)));
|
|
20
|
+
if (r) return _[r];
|
|
21
|
+
let i = e?.message;
|
|
22
|
+
return i && g.isHexString(`0x${i}`) ? p(i) : e?.shortMessage ?? m(e);
|
|
23
|
+
}, y = async (p, m, g, _, y, b = !1) => {
|
|
24
|
+
let x = c(_);
|
|
25
|
+
if (!x) throw Error(`receive vault: no factory on chain ${_}`);
|
|
26
|
+
if (m.network !== u(_)) throw Error("receive vault: network mismatch");
|
|
27
|
+
let S = BigInt(Math.floor(Date.now() / 1e3) + 900), C = await f(p.userKeys, m, g, _, y, S);
|
|
28
|
+
if (e(_)) {
|
|
29
|
+
let e = await p.getEthereumAddressByChain(_);
|
|
30
|
+
return h(p, _, l(p.userKeys, m), g, y, S, C, e, b);
|
|
31
|
+
}
|
|
32
|
+
let w = [
|
|
33
|
+
d(l(p.userKeys, m)),
|
|
34
|
+
i(g),
|
|
35
|
+
i(y),
|
|
36
|
+
S,
|
|
37
|
+
C
|
|
38
|
+
];
|
|
39
|
+
if (t(_)) {
|
|
40
|
+
let { receiveVaultFactoryABI: e } = n[_].contractData;
|
|
41
|
+
if (!e) throw Error(`receive vault: no factory ABI on chain ${_}`);
|
|
42
|
+
let t = p.getTronWeb(), i = o(x);
|
|
43
|
+
if (b) {
|
|
44
|
+
let { transaction: n } = await t.transactionBuilder.triggerSmartContract(i, "", {
|
|
45
|
+
feeLimit: r,
|
|
46
|
+
callValue: 0,
|
|
47
|
+
input: a(e, "recover", w)
|
|
48
|
+
}, [], await p.getEthereumAddressByChain(_));
|
|
49
|
+
return n;
|
|
50
|
+
}
|
|
51
|
+
let s = t.contract(e, i);
|
|
52
|
+
try {
|
|
53
|
+
return await s.recover(...w).send({ feeLimit: r });
|
|
54
|
+
} catch (e) {
|
|
55
|
+
throw Error(v(e));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
let T = p.getContractWithSigner(_, s.ReceiveVaultFactoryContract);
|
|
59
|
+
try {
|
|
60
|
+
return b ? T.recover.populateTransaction(...w) : (await T.recover(...w)).hash;
|
|
61
|
+
} catch (e) {
|
|
62
|
+
throw Error(v(e));
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
//#endregion
|
|
66
|
+
export { y as hinkalReceiveVaultRecover };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`../../functions/utils/tron.utils.cjs`),require(`../../functions/utils/receive-vault.utils.cjs`),require(`./hinkalTransact.cjs`);const e=require(`./hinkalProoflessDeposit.utils.cjs`);var t=(t,n)=>e.buildProoflessEncryptedOutputs([t.recipient],[n])[0];exports.buildReceiveVaultEncryptedOutput=t;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ReceiveVaultParams } from '../../types/receive-vault.types';
|
|
2
|
+
import { TransactProof } from '../../types/transact.types';
|
|
3
|
+
import { IHinkal } from './IHinkal';
|
|
4
|
+
export declare const buildReceiveVaultSettleProof: (hinkal: IHinkal, chainId: number, vaultAddress: string, params: ReceiveVaultParams, token: string, encryptionKey: string, depositAmount: bigint) => Promise<TransactProof>;
|
|
5
|
+
/** The encrypted note the settlement deposits on behalf of whoever paid the address. */
|
|
6
|
+
export declare const buildReceiveVaultEncryptedOutput: (params: ReceiveVaultParams, encryptionKey: string) => string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "../../functions/utils/tron.utils.mjs";
|
|
2
|
+
import "../../functions/utils/receive-vault.utils.mjs";
|
|
3
|
+
import "./hinkalTransact.mjs";
|
|
4
|
+
import { buildProoflessEncryptedOutputs as e } from "./hinkalProoflessDeposit.utils.mjs";
|
|
5
|
+
//#region libs/shared/common/src/data-structures/Hinkal/hinkalReceiveVaultSettle.ts
|
|
6
|
+
var t = (t, n) => e([t.recipient], [n])[0];
|
|
7
|
+
//#endregion
|
|
8
|
+
export { t as buildReceiveVaultEncryptedOutput };
|
|
@@ -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`),
|
|
1
|
+
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../constants/fees.constants.cjs`),r=require(`../../error-handling/error-codes.constants.cjs`),i=require(`../../functions/web3/etherFunctions.cjs`),a=require(`../crypto-keys/keys.cjs`),o=require(`../../functions/utils/solanaMint.utils.cjs`),s=require(`../../functions/utils/addresses.cjs`),c=require(`../../functions/utils/token-check.utils.cjs`),l=require(`../../functions/snarkjs/common.snarkjs.cjs`),u=require(`../../functions/pre-transaction/solana.cjs`),d=require(`../../functions/pre-transaction/constructAdminData.cjs`),f=require(`../../functions/pre-transaction/sendV0Transaction.cjs`),p=require(`../../API/admin-calls.cjs`),m=require(`../../functions/pre-transaction/solanaTransfer.utils.cjs`),h=require(`./hinkalProoflessDeposit.utils.cjs`);let g=require(`@solana/web3.js`),_=require(`@coral-xyz/anchor`);var v=(n,r)=>{let i=c.validateAndGetChainId([r]),a=r.erc20TokenAddress,{hinkalIdl:s,hinkalAddress:l,originalDeployer:d}=e.networkRegistry[i].contractData;if(!s)throw Error(`No IDL configured for Solana program on this network`);if(!d)throw Error(`missing original deployer`);let f=n.getSolanaProgram(s),p=n.getSolanaPublicKey(),{connection:m,wallet:h}=f.provider;if(!h)throw Error(`missing solana wallet`);let _=new g.PublicKey(d),v=new g.PublicKey(l),{mintPublicKey:y}=o.formatMintAddress(a),b=y.toString()===t.solanaNativeAddress;return{chainId:i,mintAddress:a,program:f,publicKey:p,connection:m,wallet:h,originalDeployer:_,mintPublicKey:y,mint:b?null:y,atasValue:b?null:void 0,storageAccount:u.getStorageAccountPublicKey(v,_),storageVault:u.getStorageVaultPublicKey(v,_),merkleAccount:u.getMerkleAccountPublicKey(v,_)}},y=async(e,t,n,r,i)=>{let a=n.map(e=>u.buildAnchorStealthAddressStructure(e)),o=h.buildProoflessEncryptedOutputs(n,r).map(e=>Buffer.from(e.slice(2),`hex`)),{current:s,next:c}=await u.resolveSolanaRootBuckets(e.program,e.merkleAccount,t.length);return e.program.methods.multiPaymentDeposit(t.map(e=>new _.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()},b=(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`);h.assertNoDuplicateStealthAddressStructures(t)},x=async(e,t,n,r,i,a=!1,o,s=!1)=>{b(n,r);let c=v(e,t),l=d.constructAdminData(o,c.chainId,Array(n.length).fill(c.mintAddress),n,await e.getEthereumAddress()),u=await y(c,n,r,i,a);if(s){let{blockhash:e}=await c.connection.getLatestBlockhash(),t=new g.Transaction().add(u);return t.recentBlockhash=e,t.feePayer=c.publicKey,Buffer.from(t.serialize({requireAllSignatures:!1})).toString(`base64`)}let m=await f.sendInstructions(c.connection,c.wallet,c.publicKey,[u]);return p.emitTxPublicData(l),m},S=async(e,t,n,r,i,a,o=!1,s,c=!1)=>{b(n,r);let l=v(e,t),u=await e.getRandomRelay(l.chainId,!1);if(!u)throw Error(`No relay available for chainId ${l.chainId}`);let{instructions:h}=await m.buildSolanaTransferInstructions(l.connection,l.publicKey,new g.PublicKey(u),t,a),_=await y(l,n,r,i,o),x=[...h,_];if(c){let{blockhash:e}=await l.connection.getLatestBlockhash(),t=new g.Transaction().add(...x);return t.recentBlockhash=e,t.feePayer=l.publicKey,Buffer.from(t.serialize({requireAllSignatures:!1})).toString(`base64`)}let S=d.constructAdminData(s,l.chainId,Array(n.length).fill(l.mintAddress),n,await e.getEthereumAddress()),C=await f.sendInstructions(l.connection,l.wallet,l.publicKey,x);return await p.emitTxPublicData(S),C},C=async(e,t,n,r=!1)=>{let o=e.userKeys.getShieldedPrivateKey(),s=l.calcStealthAddressStructure(a.UserKeys.findCorrectRandomization(i.randomBigInt(31),o),o,e.userKeys.getSpendingKeyPair().pubSpendingBJJPoint),c=a.UserKeys.getEncryptionKeyPair(o).publicKey;return x(e,n,[t],[s],[c],!1,void 0,r)},w=async(e,t,i,a,o=!1,c=0n,l)=>{if(!s.isValidPrivateAddress(a))throw Error(r.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);let u=s.constructStealthAddressStructure(a),d=s.getEncryptionKeyFromRecipientInfo(a),f=c>0n?t*c/n.BPS_DENOMINATOR:0n;return S(e,i,[t],[u],[d],f,!1,l,o)};exports.hinkalSolanaDeposit=C,exports.hinkalSolanaDepositForOther=w,exports.submitSolanaProoflessDeposit=x;
|
|
@@ -3,6 +3,6 @@ import { ERC20Token } from '../../types/token.types';
|
|
|
3
3
|
import { IHinkal } from './IHinkal';
|
|
4
4
|
import { AdminTransactionType } from '../../types/admin.types';
|
|
5
5
|
export declare const submitSolanaProoflessDeposit: (hinkal: IHinkal, token: ERC20Token, amounts: bigint[], stealthAddressStructures: StealthAddressStructure[], recipientEncryptionKeys: string[], createBlockedUtxos?: boolean, action?: AdminTransactionType, returnTxData?: boolean) => Promise<string>;
|
|
6
|
-
export declare const hinkalSolanaProoflessDepositWithPublicFee: (hinkal: IHinkal, token: ERC20Token, amounts: bigint[], stealthAddressStructures: StealthAddressStructure[], recipientEncryptionKeys: string[], feeAmount: bigint, createBlockedUtxos?: boolean, action?: AdminTransactionType) => Promise<string>;
|
|
6
|
+
export declare const hinkalSolanaProoflessDepositWithPublicFee: (hinkal: IHinkal, token: ERC20Token, amounts: bigint[], stealthAddressStructures: StealthAddressStructure[], recipientEncryptionKeys: string[], feeAmount: bigint, createBlockedUtxos?: boolean, action?: AdminTransactionType, returnTxData?: boolean) => Promise<string>;
|
|
7
7
|
export declare const hinkalSolanaDeposit: (hinkal: IHinkal, amount: bigint, token: ERC20Token, returnTxData?: boolean) => Promise<string>;
|
|
8
|
-
export declare const hinkalSolanaDepositForOther: (hinkal: IHinkal, amount: bigint, token: ERC20Token, recipientInfo: string, returnTxData?: boolean, action?: AdminTransactionType) => Promise<string>;
|
|
8
|
+
export declare const hinkalSolanaDepositForOther: (hinkal: IHinkal, amount: bigint, token: ERC20Token, recipientInfo: string, returnTxData?: boolean, variableRate?: bigint, action?: AdminTransactionType) => Promise<string>;
|
|
@@ -1,45 +1,46 @@
|
|
|
1
1
|
import { networkRegistry as e } from "../../constants/chains.constants.mjs";
|
|
2
2
|
import { solanaNativeAddress as t } from "../../constants/protocol.constants.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import "../../
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
3
|
+
import { BPS_DENOMINATOR as n } from "../../constants/fees.constants.mjs";
|
|
4
|
+
import { transactionErrorCodes as r } from "../../error-handling/error-codes.constants.mjs";
|
|
5
|
+
import { randomBigInt as i } from "../../functions/web3/etherFunctions.mjs";
|
|
6
|
+
import { UserKeys as a } from "../crypto-keys/keys.mjs";
|
|
7
|
+
import { formatMintAddress as o } from "../../functions/utils/solanaMint.utils.mjs";
|
|
8
|
+
import { constructStealthAddressStructure as s, getEncryptionKeyFromRecipientInfo as c, isValidPrivateAddress as l } from "../../functions/utils/addresses.mjs";
|
|
9
|
+
import { validateAndGetChainId as u } from "../../functions/utils/token-check.utils.mjs";
|
|
10
|
+
import { calcStealthAddressStructure as d } from "../../functions/snarkjs/common.snarkjs.mjs";
|
|
11
|
+
import { buildAnchorStealthAddressStructure as f, getMerkleAccountPublicKey as p, getStorageAccountPublicKey as m, getStorageVaultPublicKey as h, resolveSolanaRootBuckets as g } from "../../functions/pre-transaction/solana.mjs";
|
|
12
|
+
import { constructAdminData as _ } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
13
|
+
import { sendInstructions as v } from "../../functions/pre-transaction/sendV0Transaction.mjs";
|
|
14
|
+
import { emitTxPublicData as y } from "../../API/admin-calls.mjs";
|
|
15
|
+
import { buildSolanaTransferInstructions as b } from "../../functions/pre-transaction/solanaTransfer.utils.mjs";
|
|
16
|
+
import { assertNoDuplicateStealthAddressStructures as x, buildProoflessEncryptedOutputs as S } from "./hinkalProoflessDeposit.utils.mjs";
|
|
17
|
+
import { PublicKey as C, Transaction as w } from "@solana/web3.js";
|
|
17
18
|
import { BN as T } from "@coral-xyz/anchor";
|
|
18
19
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalSolanaDeposit.ts
|
|
19
20
|
var E = (n, r) => {
|
|
20
|
-
let i =
|
|
21
|
+
let i = u([r]), a = r.erc20TokenAddress, { hinkalIdl: s, hinkalAddress: c, originalDeployer: l } = e[i].contractData;
|
|
21
22
|
if (!s) throw Error("No IDL configured for Solana program on this network");
|
|
22
|
-
if (!
|
|
23
|
-
let d = n.getSolanaProgram(s),
|
|
23
|
+
if (!l) throw Error("missing original deployer");
|
|
24
|
+
let d = n.getSolanaProgram(s), f = n.getSolanaPublicKey(), { connection: g, wallet: _ } = d.provider;
|
|
24
25
|
if (!_) throw Error("missing solana wallet");
|
|
25
|
-
let v = new
|
|
26
|
+
let v = new C(l), y = new C(c), { mintPublicKey: b } = o(a), x = b.toString() === t;
|
|
26
27
|
return {
|
|
27
28
|
chainId: i,
|
|
28
|
-
mintAddress:
|
|
29
|
+
mintAddress: a,
|
|
29
30
|
program: d,
|
|
30
|
-
publicKey:
|
|
31
|
+
publicKey: f,
|
|
31
32
|
connection: g,
|
|
32
33
|
wallet: _,
|
|
33
34
|
originalDeployer: v,
|
|
34
35
|
mintPublicKey: b,
|
|
35
|
-
mint:
|
|
36
|
-
atasValue:
|
|
37
|
-
storageAccount:
|
|
38
|
-
storageVault:
|
|
39
|
-
merkleAccount:
|
|
36
|
+
mint: x ? null : b,
|
|
37
|
+
atasValue: x ? null : void 0,
|
|
38
|
+
storageAccount: m(y, v),
|
|
39
|
+
storageVault: h(y, v),
|
|
40
|
+
merkleAccount: p(y, v)
|
|
40
41
|
};
|
|
41
42
|
}, D = async (e, t, n, r, i) => {
|
|
42
|
-
let a = n.map((e) =>
|
|
43
|
+
let a = n.map((e) => f(e)), o = S(n, r).map((e) => Buffer.from(e.slice(2), "hex")), { current: s, next: c } = await g(e.program, e.merkleAccount, t.length);
|
|
43
44
|
return e.program.methods.multiPaymentDeposit(t.map((e) => new T(e.toString())), a, o, i).accounts({
|
|
44
45
|
mint: e.mint,
|
|
45
46
|
signer: e.publicKey,
|
|
@@ -52,47 +53,38 @@ var E = (n, r) => {
|
|
|
52
53
|
rootBucketNext: c ?? e.program.programId,
|
|
53
54
|
storageVaultAta: e.atasValue
|
|
54
55
|
}).instruction();
|
|
55
|
-
}, O =
|
|
56
|
-
for (let i = 0; i < 10; i += 1) {
|
|
57
|
-
let a = i === 9;
|
|
58
|
-
try {
|
|
59
|
-
let { blockhash: i, lastValidBlockHeight: a } = await e.getLatestBlockhash(), o = new w(new C({
|
|
60
|
-
payerKey: n,
|
|
61
|
-
recentBlockhash: i,
|
|
62
|
-
instructions: r
|
|
63
|
-
}).compileToV0Message()), s = await t.signTransaction(o), c = await e.sendTransaction(s);
|
|
64
|
-
return await e.confirmTransaction({
|
|
65
|
-
signature: c,
|
|
66
|
-
blockhash: i,
|
|
67
|
-
lastValidBlockHeight: a
|
|
68
|
-
}, "confirmed"), c;
|
|
69
|
-
} catch (e) {
|
|
70
|
-
if (_(e) && !a) continue;
|
|
71
|
-
throw e;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return "";
|
|
75
|
-
}, k = (e, t) => {
|
|
56
|
+
}, O = (e, t) => {
|
|
76
57
|
if (e.length === 0) throw Error("amounts must not be empty");
|
|
77
58
|
if (e.length !== t.length) throw Error("amounts and stealthAddressStructures length mismatch");
|
|
78
59
|
if (e.some((e) => e <= 0n)) throw Error("all amounts must be positive");
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
let c = E(e, t), l =
|
|
60
|
+
x(t);
|
|
61
|
+
}, k = async (e, t, n, r, i, a = !1, o, s = !1) => {
|
|
62
|
+
O(n, r);
|
|
63
|
+
let c = E(e, t), l = _(o, c.chainId, Array(n.length).fill(c.mintAddress), n, await e.getEthereumAddress()), u = await D(c, n, r, i, a);
|
|
83
64
|
if (s) {
|
|
84
|
-
let { blockhash: e } = await c.connection.getLatestBlockhash(), t = new
|
|
65
|
+
let { blockhash: e } = await c.connection.getLatestBlockhash(), t = new w().add(u);
|
|
85
66
|
return t.recentBlockhash = e, t.feePayer = c.publicKey, Buffer.from(t.serialize({ requireAllSignatures: !1 })).toString("base64");
|
|
86
67
|
}
|
|
87
|
-
let d = await
|
|
88
|
-
return
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
68
|
+
let d = await v(c.connection, c.wallet, c.publicKey, [u]);
|
|
69
|
+
return y(l), d;
|
|
70
|
+
}, A = async (e, t, n, r, i, a, o = !1, s, c = !1) => {
|
|
71
|
+
O(n, r);
|
|
72
|
+
let l = E(e, t), u = await e.getRandomRelay(l.chainId, !1);
|
|
73
|
+
if (!u) throw Error(`No relay available for chainId ${l.chainId}`);
|
|
74
|
+
let { instructions: d } = await b(l.connection, l.publicKey, new C(u), t, a), f = await D(l, n, r, i, o), p = [...d, f];
|
|
75
|
+
if (c) {
|
|
76
|
+
let { blockhash: e } = await l.connection.getLatestBlockhash(), t = new w().add(...p);
|
|
77
|
+
return t.recentBlockhash = e, t.feePayer = l.publicKey, Buffer.from(t.serialize({ requireAllSignatures: !1 })).toString("base64");
|
|
78
|
+
}
|
|
79
|
+
let m = _(s, l.chainId, Array(n.length).fill(l.mintAddress), n, await e.getEthereumAddress()), h = await v(l.connection, l.wallet, l.publicKey, p);
|
|
80
|
+
return await y(m), h;
|
|
81
|
+
}, j = async (e, t, n, r = !1) => {
|
|
82
|
+
let o = e.userKeys.getShieldedPrivateKey(), s = d(a.findCorrectRandomization(i(31), o), o, e.userKeys.getSpendingKeyPair().pubSpendingBJJPoint), c = a.getEncryptionKeyPair(o).publicKey;
|
|
83
|
+
return k(e, n, [t], [s], [c], !1, void 0, r);
|
|
84
|
+
}, M = async (e, t, i, a, o = !1, u = 0n, d) => {
|
|
85
|
+
if (!l(a)) throw Error(r.RECIPIENT_FORMAT_INCORRECT);
|
|
86
|
+
let f = s(a), p = c(a), m = u > 0n ? t * u / n : 0n;
|
|
87
|
+
return A(e, i, [t], [f], [p], m, !1, d, o);
|
|
96
88
|
};
|
|
97
89
|
//#endregion
|
|
98
|
-
export { j as hinkalSolanaDeposit, M as hinkalSolanaDepositForOther,
|
|
90
|
+
export { j as hinkalSolanaDeposit, M as hinkalSolanaDepositForOther, k as submitSolanaProoflessDeposit };
|
|
@@ -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/solana-transact.types.cjs`),d=require(`../../functions/utils/token-check.utils.cjs`),f=require(`../../functions/snarkjs/common.snarkjs.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/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/utils/erc20tokenFunctions.cjs`),p=require(`../../functions/snarkjs/common.snarkjs.cjs`),m=require(`../../functions/pre-transaction/solana.cjs`),h=require(`../../functions/pre-transaction/constructAdminData.cjs`),g=require(`../../functions/pre-transaction/getFeeStructure.cjs`),_=require(`../../functions/utils/fees.utils.cjs`),v=require(`../../functions/pre-transaction/speculativeUtxo.cjs`);require(`../../functions/pre-transaction/index.cjs`);const y=require(`../../functions/web3/functionCalls/transactCallRelayer.cjs`),b=require(`../../functions/utils/admin-dimensions.cjs`);require(`../../functions/web3/index.cjs`);const x=require(`./hinkalProoflessDeposit.utils.cjs`),S=require(`./hinkalSolanaTransact.cjs`);let C=require(`ethers`),w=require(`@solana/web3.js`),T=require(`@coral-xyz/anchor`);var E=(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 f=n.userKeys.getShieldedPrivateKey(),h=n.getSolanaProgram(l),g=n.getSolanaPublicKey(),_=new w.PublicKey(d),v=new w.PublicKey(u),{mintPublicKey:y}=s.formatMintAddress(o.erc20TokenAddress),b=y.toString(),x=m.getStorageAccountPublicKey(v,_),S=m.getStorageVaultPublicKey(v,_),C=m.getMerkleAccountPublicKey(v,_),T=c.map(()=>p.calcStealthAddressStructure(i.UserKeys.findCorrectRandomization(r.randomBigInt(31),f),f,n.userKeys.getSpendingKeyPair().pubSpendingBJJPoint)),E=T.map(e=>m.buildAnchorStealthAddressStructure(e)),D=i.UserKeys.getEncryptionKeyPair(f).publicKey,O=b===t.solanaNativeAddress;return{program:h,publicKey:g,originalDeployer:_,mint:O?null:y,atasValue:O?null:void 0,storageAccount:x,storageVault:S,merkleAccount:C,amounts:c,mintAddressString:b,stealthAddressStructures:T,anchorStealthStructures:E,ownEncryptionKey:D}},D=async(e,t)=>{let n=x.buildProoflessEncryptedOutputs(e.stealthAddressStructures,e.amounts.map(()=>e.ownEncryptionKey)).map(e=>Buffer.from(e.slice(2),`hex`)),{current:r,next:i}=await m.resolveSolanaRootBuckets(e.program,e.merkleAccount,e.amounts.length);return e.program.methods.multiPaymentDepositAt(e.amounts.map(e=>new T.BN(e.toString())),e.anchorStealthStructures,n,!0,t?new T.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})},O=async(r,i,c,l,d,p,m,g,y,x)=>{let C=c.erc20TokenAddress;if(l.length===0)throw Error(`userDepositedUtxos must not be empty`);let{originalDeployer:w}=e.networkRegistry[i].contractData;if(!w)throw Error(`missing data`);let T=await r.getRandomRelay(i,!0);if(!T)throw Error(n.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let E=a.getCurrentTimeInSeconds().toString(),D=r.generateProofRemotely?5:1,O=[];for(let e=0;e<l.length;e+=D){let n=l.slice(e,e+D),a=await Promise.all(n.map(async({recipientAddress:n,utxo:a},l)=>{let w=e+l,D={recipient:n,mint:C===`11111111111111111111111111111111`?void 0:C},O=await _.calculateModifiedFeeStructure(i,c,p[w],d),k=y?.tokenAddress?await f.getErc20TokenFromAPI(y.chainId??i,y.tokenAddress):void 0,A=b.resolveSwapPairTokens(m,[c],k),j=h.constructAdminData(m,i,[C],[p[w]],await r.getEthereumAddress(),A),{compressedAddress:M}=s.formatMintAddress(t.solanaNativeAddress),N=new o.Utxo({amount:0n,mintAddress:C,erc20TokenAddress:M,nullifyingKey:r.userKeys.getShieldedPrivateKey(),timeStamp:E,spendingPublicKey:r.userKeys.getSpendingKeyPair().pubSpendingBJJPoint}),{args:P,commitmentValidationData:F}=await S.hinkalSolanaTransact(r,{chainId:i,mintAddresses:[C],amountChanges:[-a.amount],relayAddress:T,recipient:n,signer:T,functionName:`transact`,accounts:D,relayerFee:O.flatFee,variableRate:O.variableRate,inputUtxos:[[a,N]],useBlockedUtxos:!0,speculative:x&&{pendingLeaves:x,inputUtxos:[[v.toSpeculativeUtxo(a)]]},submit:{mode:u.SolanaSubmitMode.ProofOnly}});return{relayAddress:T,functionName:`transact`,chainId:i,recipientAmount:p[w].toString(),args:P,accounts:D,adminData:j,commitmentValidationData:F,displayRecipient:g?.[w],destinationChainId:y?.chainId,destinationTokenAddress:y?.tokenAddress,destinationTokenAmount:y?.tokenAmounts?.[w]}}));O.push(...a)}return O},k=async(e,t,n,r,i,u,f,p,m,h,v)=>{let b=d.validateAndGetChainId([t]),x=t.erc20TokenAddress,S=c.hashEthereumAddress(await e.getEthereumAddressByChain(b)),w=m?c.hashString(m):void 0,T=u??await g.getFeeStructure(b,x,[x],l.ExternalActionId.Transact,[],25n,{mintTo:x,recipient:r[0],nullifierCount:1}),k=n.map(e=>e+_.calculateTotalFee(e,T)),A=E(e,b,t,k),j=a.getCurrentTimeInSeconds().toString(),{compressedAddress:M}=s.formatMintAddress(x),N=A.stealthAddressStructures.map((t,n)=>({recipientAddress:r[n],utxo:new o.Utxo({amount:k[n],timeStamp:j,nullifyingKey:e.userKeys.getShieldedPrivateKey(),mintAddress:x,erc20TokenAddress:M,stealthAddress:C.ethers.toBeHex(t.stealthAddress),H0:[t.H0x,t.H0y]})})),{connection:P,wallet:F}=A.program.provider,I=async()=>{let e=await(await D(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(),O(e,b,t,N,T,n,p,h,v,L)]);return{depositTxHash:R,scheduleId:await y.solanaTransactCallRelayerBatch(b,z,S,i,f,w,R)}};exports.hinkalSolanaDepositAndWithdraw=k;
|
|
@@ -10,28 +10,30 @@ import { hashEthereumAddress as c, hashString as l } from "../../functions/utils
|
|
|
10
10
|
import { ExternalActionId as u } from "../../types/external-action.types.mjs";
|
|
11
11
|
import { SolanaSubmitMode as d } from "../../types/solana-transact.types.mjs";
|
|
12
12
|
import { validateAndGetChainId as f } from "../../functions/utils/token-check.utils.mjs";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
13
|
+
import { getErc20TokenFromAPI as p } from "../../functions/utils/erc20tokenFunctions.mjs";
|
|
14
|
+
import { calcStealthAddressStructure as m } from "../../functions/snarkjs/common.snarkjs.mjs";
|
|
15
|
+
import { buildAnchorStealthAddressStructure as h, getMerkleAccountPublicKey as g, getStorageAccountPublicKey as _, getStorageVaultPublicKey as v, resolveSolanaRootBuckets as y } from "../../functions/pre-transaction/solana.mjs";
|
|
16
|
+
import { constructAdminData as b } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
17
|
+
import { getFeeStructure as x } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
18
|
+
import { calculateModifiedFeeStructure as S, calculateTotalFee as C } from "../../functions/utils/fees.utils.mjs";
|
|
19
|
+
import { toSpeculativeUtxo as w } from "../../functions/pre-transaction/speculativeUtxo.mjs";
|
|
18
20
|
import "../../functions/pre-transaction/index.mjs";
|
|
19
|
-
import { solanaTransactCallRelayerBatch as
|
|
20
|
-
import {
|
|
21
|
+
import { solanaTransactCallRelayerBatch as T } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
22
|
+
import { resolveSwapPairTokens as E } from "../../functions/utils/admin-dimensions.mjs";
|
|
21
23
|
import "../../functions/web3/index.mjs";
|
|
22
|
-
import { buildProoflessEncryptedOutputs as
|
|
23
|
-
import { hinkalSolanaTransact as
|
|
24
|
-
import { ethers as
|
|
25
|
-
import { PublicKey as
|
|
26
|
-
import { BN as
|
|
24
|
+
import { buildProoflessEncryptedOutputs as D } from "./hinkalProoflessDeposit.utils.mjs";
|
|
25
|
+
import { hinkalSolanaTransact as O } from "./hinkalSolanaTransact.mjs";
|
|
26
|
+
import { ethers as k } from "ethers";
|
|
27
|
+
import { PublicKey as A } from "@solana/web3.js";
|
|
28
|
+
import { BN as j } from "@coral-xyz/anchor";
|
|
27
29
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.ts
|
|
28
|
-
var
|
|
30
|
+
var M = (n, a, o, c) => {
|
|
29
31
|
let { hinkalIdl: l, hinkalAddress: u, originalDeployer: d } = e[a].contractData;
|
|
30
32
|
if (!l) throw Error("No IDL configured for Solana program on this network");
|
|
31
33
|
if (!d) throw Error("missing original deployer");
|
|
32
|
-
let f = n.userKeys.getShieldedPrivateKey(),
|
|
34
|
+
let f = n.userKeys.getShieldedPrivateKey(), p = n.getSolanaProgram(l), y = n.getSolanaPublicKey(), b = new A(d), x = new A(u), { mintPublicKey: S } = s(o.erc20TokenAddress), C = S.toString(), w = _(x, b), T = v(x, b), E = g(x, b), D = c.map(() => m(i.findCorrectRandomization(r(31), f), f, n.userKeys.getSpendingKeyPair().pubSpendingBJJPoint)), O = D.map((e) => h(e)), k = i.getEncryptionKeyPair(f).publicKey, j = C === t;
|
|
33
35
|
return {
|
|
34
|
-
program:
|
|
36
|
+
program: p,
|
|
35
37
|
publicKey: y,
|
|
36
38
|
originalDeployer: b,
|
|
37
39
|
mint: j ? null : S,
|
|
@@ -42,12 +44,12 @@ var A = (n, a, o, c) => {
|
|
|
42
44
|
amounts: c,
|
|
43
45
|
mintAddressString: C,
|
|
44
46
|
stealthAddressStructures: D,
|
|
45
|
-
anchorStealthStructures:
|
|
46
|
-
ownEncryptionKey:
|
|
47
|
+
anchorStealthStructures: O,
|
|
48
|
+
ownEncryptionKey: k
|
|
47
49
|
};
|
|
48
|
-
},
|
|
49
|
-
let n =
|
|
50
|
-
return e.program.methods.multiPaymentDepositAt(e.amounts.map((e) => new
|
|
50
|
+
}, N = async (e, t) => {
|
|
51
|
+
let n = D(e.stealthAddressStructures, e.amounts.map(() => e.ownEncryptionKey)).map((e) => Buffer.from(e.slice(2), "hex")), { current: r, next: i } = await y(e.program, e.merkleAccount, e.amounts.length);
|
|
52
|
+
return e.program.methods.multiPaymentDepositAt(e.amounts.map((e) => new j(e.toString())), e.anchorStealthStructures, n, !0, t ? new j(t) : null).accounts({
|
|
51
53
|
mint: e.mint,
|
|
52
54
|
signer: e.publicKey,
|
|
53
55
|
signerAta: e.atasValue,
|
|
@@ -59,87 +61,87 @@ var A = (n, a, o, c) => {
|
|
|
59
61
|
rootBucketNext: i ?? e.program.programId,
|
|
60
62
|
storageVaultAta: e.atasValue
|
|
61
63
|
});
|
|
62
|
-
},
|
|
63
|
-
let
|
|
64
|
+
}, P = async (r, i, c, l, u, f, m, h, g, _) => {
|
|
65
|
+
let v = c.erc20TokenAddress;
|
|
64
66
|
if (l.length === 0) throw Error("userDepositedUtxos must not be empty");
|
|
65
|
-
let { originalDeployer:
|
|
66
|
-
if (!
|
|
67
|
-
let
|
|
68
|
-
if (!
|
|
69
|
-
let
|
|
70
|
-
for (let e = 0; e < l.length; e +=
|
|
71
|
-
let n = l.slice(e, e +
|
|
72
|
-
let
|
|
67
|
+
let { originalDeployer: y } = e[i].contractData;
|
|
68
|
+
if (!y) throw Error("missing data");
|
|
69
|
+
let x = await r.getRandomRelay(i, !0);
|
|
70
|
+
if (!x) throw Error(n.RELAYER_NOT_AVAILABLE);
|
|
71
|
+
let C = a().toString(), T = r.generateProofRemotely ? 5 : 1, D = [];
|
|
72
|
+
for (let e = 0; e < l.length; e += T) {
|
|
73
|
+
let n = l.slice(e, e + T), a = await Promise.all(n.map(async ({ recipientAddress: n, utxo: a }, l) => {
|
|
74
|
+
let y = e + l, T = {
|
|
73
75
|
recipient: n,
|
|
74
|
-
mint:
|
|
75
|
-
},
|
|
76
|
+
mint: v === "11111111111111111111111111111111" ? void 0 : v
|
|
77
|
+
}, D = await S(i, c, f[y], u), k = g?.tokenAddress ? await p(g.chainId ?? i, g.tokenAddress) : void 0, A = E(m, [c], k), j = b(m, i, [v], [f[y]], await r.getEthereumAddress(), A), { compressedAddress: M } = s(t), N = new o({
|
|
76
78
|
amount: 0n,
|
|
77
|
-
mintAddress:
|
|
78
|
-
erc20TokenAddress:
|
|
79
|
+
mintAddress: v,
|
|
80
|
+
erc20TokenAddress: M,
|
|
79
81
|
nullifyingKey: r.userKeys.getShieldedPrivateKey(),
|
|
80
|
-
timeStamp:
|
|
82
|
+
timeStamp: C,
|
|
81
83
|
spendingPublicKey: r.userKeys.getSpendingKeyPair().pubSpendingBJJPoint
|
|
82
|
-
}), { args:
|
|
84
|
+
}), { args: P, commitmentValidationData: F } = await O(r, {
|
|
83
85
|
chainId: i,
|
|
84
|
-
mintAddresses: [
|
|
86
|
+
mintAddresses: [v],
|
|
85
87
|
amountChanges: [-a.amount],
|
|
86
|
-
relayAddress:
|
|
88
|
+
relayAddress: x,
|
|
87
89
|
recipient: n,
|
|
88
|
-
signer:
|
|
90
|
+
signer: x,
|
|
89
91
|
functionName: "transact",
|
|
90
|
-
accounts:
|
|
91
|
-
relayerFee:
|
|
92
|
-
variableRate:
|
|
93
|
-
inputUtxos: [[a,
|
|
92
|
+
accounts: T,
|
|
93
|
+
relayerFee: D.flatFee,
|
|
94
|
+
variableRate: D.variableRate,
|
|
95
|
+
inputUtxos: [[a, N]],
|
|
94
96
|
useBlockedUtxos: !0,
|
|
95
|
-
speculative:
|
|
96
|
-
pendingLeaves:
|
|
97
|
-
inputUtxos: [[
|
|
97
|
+
speculative: _ && {
|
|
98
|
+
pendingLeaves: _,
|
|
99
|
+
inputUtxos: [[w(a)]]
|
|
98
100
|
},
|
|
99
101
|
submit: { mode: d.ProofOnly }
|
|
100
102
|
});
|
|
101
103
|
return {
|
|
102
|
-
relayAddress:
|
|
104
|
+
relayAddress: x,
|
|
103
105
|
functionName: "transact",
|
|
104
106
|
chainId: i,
|
|
105
|
-
recipientAmount: f[
|
|
106
|
-
args:
|
|
107
|
-
accounts:
|
|
108
|
-
adminData:
|
|
109
|
-
commitmentValidationData:
|
|
110
|
-
displayRecipient:
|
|
111
|
-
destinationChainId:
|
|
112
|
-
destinationTokenAddress:
|
|
113
|
-
destinationTokenAmount:
|
|
107
|
+
recipientAmount: f[y].toString(),
|
|
108
|
+
args: P,
|
|
109
|
+
accounts: T,
|
|
110
|
+
adminData: j,
|
|
111
|
+
commitmentValidationData: F,
|
|
112
|
+
displayRecipient: h?.[y],
|
|
113
|
+
destinationChainId: g?.chainId,
|
|
114
|
+
destinationTokenAddress: g?.tokenAddress,
|
|
115
|
+
destinationTokenAmount: g?.tokenAmounts?.[y]
|
|
114
116
|
};
|
|
115
117
|
}));
|
|
116
|
-
|
|
118
|
+
D.push(...a);
|
|
117
119
|
}
|
|
118
|
-
return
|
|
119
|
-
},
|
|
120
|
-
let v = f([t]), y = t.erc20TokenAddress,
|
|
120
|
+
return D;
|
|
121
|
+
}, F = async (e, t, n, r, i, d, p, m, h, g, _) => {
|
|
122
|
+
let v = f([t]), y = t.erc20TokenAddress, b = c(await e.getEthereumAddressByChain(v)), S = h ? l(h) : void 0, w = d ?? await x(v, y, [y], u.Transact, [], 25n, {
|
|
121
123
|
mintTo: y,
|
|
122
124
|
recipient: r[0],
|
|
123
125
|
nullifierCount: 1
|
|
124
|
-
}), E = n.map((e) => e +
|
|
126
|
+
}), E = n.map((e) => e + C(e, w)), D = M(e, v, t, E), O = a().toString(), { compressedAddress: A } = s(y), j = D.stealthAddressStructures.map((t, n) => ({
|
|
125
127
|
recipientAddress: r[n],
|
|
126
128
|
utxo: new o({
|
|
127
129
|
amount: E[n],
|
|
128
|
-
timeStamp:
|
|
130
|
+
timeStamp: O,
|
|
129
131
|
nullifyingKey: e.userKeys.getShieldedPrivateKey(),
|
|
130
132
|
mintAddress: y,
|
|
131
|
-
erc20TokenAddress:
|
|
132
|
-
stealthAddress:
|
|
133
|
+
erc20TokenAddress: A,
|
|
134
|
+
stealthAddress: k.toBeHex(t.stealthAddress),
|
|
133
135
|
H0: [t.H0x, t.H0y]
|
|
134
136
|
})
|
|
135
|
-
})), { connection: F, wallet: I } =
|
|
136
|
-
let e = await (await
|
|
137
|
-
return e.recentBlockhash = (await F.getLatestBlockhash()).blockhash, e.feePayer =
|
|
138
|
-
}, R =
|
|
137
|
+
})), { connection: F, wallet: I } = D.program.provider, L = async () => {
|
|
138
|
+
let e = await (await N(D, O)).transaction();
|
|
139
|
+
return e.recentBlockhash = (await F.getLatestBlockhash()).blockhash, e.feePayer = D.publicKey, F.sendRawTransaction((await I.signTransaction(e)).serialize());
|
|
140
|
+
}, R = j.map(({ utxo: e }) => BigInt(e.getCommitment()).toString()), [z, B] = await Promise.all([L(), P(e, v, t, j, w, n, m, g, _, R)]);
|
|
139
141
|
return {
|
|
140
142
|
depositTxHash: z,
|
|
141
|
-
scheduleId: await
|
|
143
|
+
scheduleId: await T(v, B, b, i, p, S, z)
|
|
142
144
|
};
|
|
143
145
|
};
|
|
144
146
|
//#endregion
|
|
145
|
-
export {
|
|
147
|
+
export { F as hinkalSolanaDepositAndWithdraw };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../functions/utils/
|
|
1
|
+
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../functions/utils/create-provider.cjs`),n=require(`../../functions/utils/token-check.utils.cjs`),r=require(`../../functions/pre-transaction/constructAdminData.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(r,a,o,l)=>{let u=n.validateAndGetChainId([r]),d=i.AccountActions.getAddressFromSubAccount(u,o);if(!d)throw Error(`Public account address is not available`);let{rpcUrl:f}=e.networkRegistry[u],p=t.createCustomSolanaConnection(f),m=new c.PublicKey(d),{instructions:h,programId:g}=await s.buildSolanaTransferInstructions(p,m,new c.PublicKey(l),r,a);return{connection:p,chainId:u,senderAddress:d,senderPublickey:m,programId:g,instructions:h}},u=async(e,t,n,i,s,c)=>{let[{connection:u,chainId:d,senderPublickey:f,instructions:p},m]=await Promise.all([l(t,n,i,s),e.getEthereumAddress()]),h=await a.sendProxyV0Transaction({connection:u,chainId:d,subAccount:i,payerPublicKey:f,instructions:p});return o.emitTxPublicData(r.constructAdminData(c,d,[t.erc20TokenAddress],[n],m)),h};exports.hinkalSolanaProxySend=u;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { networkRegistry as e } from "../../constants/chains.constants.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { createCustomSolanaConnection as t } from "../../functions/utils/create-provider.mjs";
|
|
3
|
+
import { validateAndGetChainId as n } from "../../functions/utils/token-check.utils.mjs";
|
|
4
|
+
import { constructAdminData as r } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
5
5
|
import { AccountActions as i } from "../AccountActions/AccountActions.mjs";
|
|
6
6
|
import { sendProxyV0Transaction as a } from "../../functions/pre-transaction/sendV0Transaction.mjs";
|
|
7
7
|
import { emitTxPublicData as o } from "../../API/admin-calls.mjs";
|
|
8
8
|
import { buildSolanaTransferInstructions as s } from "../../functions/pre-transaction/solanaTransfer.utils.mjs";
|
|
9
9
|
import { PublicKey as c } from "@solana/web3.js";
|
|
10
10
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalSolanaProxySend.ts
|
|
11
|
-
var l = async (
|
|
12
|
-
let u =
|
|
11
|
+
var l = async (r, a, o, l) => {
|
|
12
|
+
let u = n([r]), d = i.getAddressFromSubAccount(u, o);
|
|
13
13
|
if (!d) throw Error("Public account address is not available");
|
|
14
|
-
let { rpcUrl: f } = e[u], p =
|
|
14
|
+
let { rpcUrl: f } = e[u], p = t(f), m = new c(d), { instructions: h, programId: g } = await s(p, m, new c(l), r, a);
|
|
15
15
|
return {
|
|
16
16
|
connection: p,
|
|
17
17
|
chainId: u,
|
|
@@ -20,15 +20,15 @@ var l = async (n, a, o, l) => {
|
|
|
20
20
|
programId: g,
|
|
21
21
|
instructions: h
|
|
22
22
|
};
|
|
23
|
-
}, u = async (e, t,
|
|
24
|
-
let [{ connection: u, chainId: d, senderPublickey: f, instructions: p }, m] = await Promise.all([l(t,
|
|
23
|
+
}, u = async (e, t, n, i, s, c) => {
|
|
24
|
+
let [{ connection: u, chainId: d, senderPublickey: f, instructions: p }, m] = await Promise.all([l(t, n, i, s), e.getEthereumAddress()]), h = await a({
|
|
25
25
|
connection: u,
|
|
26
26
|
chainId: d,
|
|
27
27
|
subAccount: i,
|
|
28
28
|
payerPublicKey: f,
|
|
29
29
|
instructions: p
|
|
30
30
|
});
|
|
31
|
-
return o(
|
|
31
|
+
return o(r(c, d, [t.erc20TokenAddress], [n], m)), h;
|
|
32
32
|
};
|
|
33
33
|
//#endregion
|
|
34
34
|
export { u as hinkalSolanaProxySend };
|
|
@@ -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/
|
|
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/create-provider.cjs`),a=require(`../../functions/utils/token-check.utils.cjs`),o=require(`../../functions/pre-transaction/solana.cjs`),s=require(`../../functions/pre-transaction/constructAdminData.cjs`),c=require(`../AccountActions/AccountActions.cjs`),l=require(`../../functions/pre-transaction/sendV0Transaction.cjs`),u=require(`../../functions/utils/fees.utils.cjs`),d=require(`../../functions/utils/solana-program.utils.cjs`),f=require(`../../API/admin-calls.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:a,senderPublickey:s,originalDeployer:c,storageAccount:l,storageVault:u,merkleAccount:d,rootBuckets:f,createBlockedUtxos:p})=>{let h=new g.BN(r.toString()),_=o.buildAnchorStealthAddressStructure(i),v=n===`11111111111111111111111111111111`?null:t,y=n===`11111111111111111111111111111111`?null:void 0,[b]=m.buildProoflessEncryptedOutputs([i],[a]),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:a,token:s,tokenAmount:c,senderAddress:l,recipientInfo:u,createBlockedUtxos:f=!1})=>{if(!r.isValidPrivateAddress(u))throw Error(t.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);let{hinkalIdl:p,hinkalAddress:m,originalDeployer:g}=e.networkRegistry[a].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[a],y=i.createCustomSolanaConnection(v),b=d.createReadOnlySolanaProgram(y,p),x=new h.PublicKey(g),S=new h.PublicKey(m),C=new h.PublicKey(l),{erc20TokenAddress:w}=s,{mintPublicKey:T}=n.formatMintAddress(w),E=T.toString(),D=o.getStorageAccountPublicKey(S,x),O=o.getStorageVaultPublicKey(S,x),k=o.getMerkleAccountPublicKey(S,x),A=r.constructStealthAddressStructure(u),j=r.getEncryptionKeyFromRecipientInfo(u),M=await o.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(s.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 d=c.AccountActions.getAddressFromSubAccount(n,a);if(!d)throw Error(`Public account address is not available`);let f=await v({chainId:n,token:r,tokenAmount:i,senderAddress:d,recipientInfo:o??e.getRecipientInfo(),createBlockedUtxos:s});if(l<=0n)return f;let m=await e.getRandomRelay(n,!1);if(!m)throw Error(t.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let{instructions:g}=await p.buildSolanaTransferInstructions(f.connection,f.senderPublickey,new h.PublicKey(m),r,u.calculateVariableFee(i,l));return{...f,instructions:[...g,...f.instructions]}},b=async(e,t,n,r,i,o=!1,c=0n,u)=>{if(!r)throw Error(`subAccount is required`);let d=a.validateAndGetChainId([t]),[{connection:p,senderPublickey:m,instructions:h},g]=await Promise.all([y(e,d,t,n,r,i,o,c),e.getEthereumAddress()]),_=await l.sendProxyV0Transaction({connection:p,chainId:d,subAccount:r,payerPublicKey:m,instructions:h});return f.emitTxPublicData(s.constructAdminData(u,d,[t.erc20TokenAddress],[n],g)),_};exports.hinkalSolanaProxyShield=b;
|