@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
|
@@ -7,107 +7,110 @@ import { addressToHexFormat as a, swapTronBCoordinate as o } from "../../functio
|
|
|
7
7
|
import { hashEthereumAddress as s, hashString as c } from "../../functions/utils/addresses.mjs";
|
|
8
8
|
import { ExternalActionId as l } from "../../types/external-action.types.mjs";
|
|
9
9
|
import { SubmitMode as u } from "../../types/transact.types.mjs";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
10
|
+
import { decryptUtxo as d } from "../crypto-keys/encryptDecryptUtxo.mjs";
|
|
11
|
+
import { validateAndGetChainId as f } from "../../functions/utils/token-check.utils.mjs";
|
|
12
|
+
import { getErc20TokenFromAPI as p } from "../../functions/utils/erc20tokenFunctions.mjs";
|
|
13
|
+
import { constructAdminData as m } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
14
|
+
import { getFeeStructure as h } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
15
|
+
import { calculateGrossUtxoAmounts as g } from "../../functions/utils/fees.utils.mjs";
|
|
16
|
+
import { toSpeculativeUtxo as _ } from "../../functions/pre-transaction/speculativeUtxo.mjs";
|
|
17
|
+
import { transactCallDirectTron as v } from "../../functions/web3/functionCalls/transactCallDirectTron.mjs";
|
|
18
|
+
import { transactCallRelayerBatch as y } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
19
|
+
import { hinkalTransact as b } from "./hinkalTransact.mjs";
|
|
20
|
+
import { resolveSwapPairTokens as x } from "../../functions/utils/admin-dimensions.mjs";
|
|
18
21
|
import "../../functions/index.mjs";
|
|
19
|
-
import { prepareDepositOnChainUtxos as
|
|
20
|
-
import { ethers as
|
|
22
|
+
import { prepareDepositOnChainUtxos as S, submitDepositOnChainUtxos as C } from "./hinkalDepositOnChainUtxos.mjs";
|
|
23
|
+
import { ethers as w } from "ethers";
|
|
21
24
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.ts
|
|
22
|
-
var
|
|
25
|
+
var T = async (e, o, s, c, l, d, f, h) => {
|
|
23
26
|
if (c.length === 0) throw Error("userDepositedUtxos must not be empty");
|
|
24
|
-
let g = s.erc20TokenAddress, [
|
|
25
|
-
if (!
|
|
26
|
-
let
|
|
27
|
-
for (let r = 0; r < c.length; r +=
|
|
28
|
-
let
|
|
29
|
-
let
|
|
27
|
+
let g = s.erc20TokenAddress, [v, y] = await Promise.all([e.getRandomRelay(o), e.getEthereumAddressByChain(o)]);
|
|
28
|
+
if (!v) throw Error(r.RELAYER_NOT_AVAILABLE);
|
|
29
|
+
let S = e.generateProofRemotely ? 5 : 1, C = [], w = a(y);
|
|
30
|
+
for (let r = 0; r < c.length; r += S) {
|
|
31
|
+
let y = c.slice(r, r + S), T = await Promise.all(y.map(async ({ recipientAddress: c, utxo: y }, S) => {
|
|
32
|
+
let C = r + S, T = a(c), E = n(y.erc20TokenAddress, g) ? y : i.createFrom(y, { erc20TokenAddress: g }), D = f?.tokenAddress ? await p(f.chainId ?? o, f.tokenAddress) : void 0, O = x(d, [s], D), k = m(d, o, [g], [-y.amount], w, O), { zkCallData: A, circomData: j, dimData: M, commitmentValidationData: N, tronProofSignature: P } = await b(e, {
|
|
30
33
|
chainId: o,
|
|
31
34
|
erc20Addresses: [g],
|
|
32
|
-
amountChanges: [-
|
|
33
|
-
externalAddress:
|
|
35
|
+
amountChanges: [-y.amount],
|
|
36
|
+
externalAddress: T,
|
|
34
37
|
feeStructure: l,
|
|
35
|
-
relay:
|
|
36
|
-
inputUtxos: [[
|
|
38
|
+
relay: v ?? t,
|
|
39
|
+
inputUtxos: [[E]],
|
|
37
40
|
useBlockedUtxos: !0,
|
|
38
|
-
speculative:
|
|
39
|
-
pendingLeaves:
|
|
40
|
-
inputUtxos: [[
|
|
41
|
+
speculative: h && {
|
|
42
|
+
pendingLeaves: h,
|
|
43
|
+
inputUtxos: [[_(E)]]
|
|
41
44
|
},
|
|
42
45
|
submit: { mode: u.ProofOnly },
|
|
43
46
|
skipLock: !0
|
|
44
47
|
});
|
|
45
48
|
return {
|
|
46
|
-
zkCallData:
|
|
47
|
-
dimData:
|
|
48
|
-
circomData:
|
|
49
|
-
commitmentValidationData:
|
|
50
|
-
adminData:
|
|
51
|
-
recipientAddress:
|
|
52
|
-
tronProofSignature:
|
|
49
|
+
zkCallData: A,
|
|
50
|
+
dimData: M,
|
|
51
|
+
circomData: j,
|
|
52
|
+
commitmentValidationData: N,
|
|
53
|
+
adminData: k,
|
|
54
|
+
recipientAddress: c,
|
|
55
|
+
tronProofSignature: P,
|
|
53
56
|
destinationChainId: f?.chainId,
|
|
54
57
|
destinationTokenAddress: f?.tokenAddress,
|
|
55
|
-
destinationTokenAmount: f?.tokenAmounts?.[
|
|
58
|
+
destinationTokenAmount: f?.tokenAmounts?.[C]
|
|
56
59
|
};
|
|
57
60
|
}));
|
|
58
|
-
|
|
61
|
+
C.push(...T);
|
|
59
62
|
}
|
|
60
|
-
return
|
|
61
|
-
},
|
|
62
|
-
let { chainId: a, hashedEthereumAddress: o, feeStructure: s, action: c, destination: l } = i, { txCompletionTime: u, ref: d, hashedDashboardAccountId: f, preEstimateGas: p } = i, m = n
|
|
63
|
+
return C;
|
|
64
|
+
}, E = async (e, t, n, r, i) => {
|
|
65
|
+
let { chainId: a, hashedEthereumAddress: o, feeStructure: s, action: c, destination: l } = i, { txCompletionTime: u, ref: d, hashedDashboardAccountId: f, preEstimateGas: p } = i, m = g(n, s), h = await S(e, a, [t], [m]), { depositedUtxos: _, pendingLeaves: v } = h, b = _[0].map((e, t) => ({
|
|
63
66
|
recipientAddress: r[t],
|
|
64
67
|
utxo: e
|
|
65
|
-
})), [
|
|
68
|
+
})), [x, w] = await Promise.all([C(e, h, p), T(e, a, t, b, s, c, l, v)]);
|
|
66
69
|
return {
|
|
67
|
-
depositTxHash:
|
|
68
|
-
scheduleId: await
|
|
70
|
+
depositTxHash: x,
|
|
71
|
+
scheduleId: await y(a, w, o, u, d, f, x)
|
|
69
72
|
};
|
|
70
|
-
},
|
|
71
|
-
let { chainId: a, ethereumAddress: s, hashedEthereumAddress: c, feeStructure: l, action:
|
|
73
|
+
}, D = async (e, t, n, r, i) => {
|
|
74
|
+
let { chainId: a, ethereumAddress: s, hashedEthereumAddress: c, feeStructure: l, action: f, destination: p } = i, { txCompletionTime: m, ref: h, hashedDashboardAccountId: _, preEstimateGas: x } = i, S = g(n, l), C = S.reduce((e, t) => e + t, 0n), E = await b(e, {
|
|
72
75
|
chainId: a,
|
|
73
76
|
erc20Addresses: [t.erc20TokenAddress],
|
|
74
|
-
amountChanges: [
|
|
77
|
+
amountChanges: [C],
|
|
75
78
|
externalAddress: s,
|
|
76
|
-
selfOutputAmounts:
|
|
79
|
+
selfOutputAmounts: S,
|
|
77
80
|
createBlockedUtxos: !0,
|
|
78
81
|
forceEmptyUtxos: !0,
|
|
79
82
|
submit: { mode: u.ProofOnly }
|
|
80
|
-
}),
|
|
81
|
-
if (!
|
|
82
|
-
let
|
|
83
|
+
}), D = E.circomData.encryptedOutputs?.[0];
|
|
84
|
+
if (!D || D.length !== S.length) throw Error("Deposit proof is missing encryptedOutputs for the deposited UTXOs");
|
|
85
|
+
let O = D.map((t, n) => ({
|
|
83
86
|
recipientAddress: r[n],
|
|
84
|
-
utxo:
|
|
85
|
-
})),
|
|
86
|
-
o(
|
|
87
|
-
let n = await
|
|
87
|
+
utxo: d(w.getBytes(t), e.userKeys)
|
|
88
|
+
})), k = E.circomData.outCommitments.flat().map((e) => BigInt(e)).filter((e) => e !== 0n).map((e) => e.toString()), [A, j] = await Promise.all([(async () => {
|
|
89
|
+
o(E.zkCallData);
|
|
90
|
+
let n = await v(e, a, C, t, E.zkCallData, E.circomData, E.dimData, void 0, void 0, x, E.tronProofSignature);
|
|
88
91
|
if (!n) throw Error("Deposit transaction hash not found");
|
|
89
92
|
return n;
|
|
90
|
-
})(),
|
|
93
|
+
})(), T(e, a, t, O, l, f, p, k)]);
|
|
91
94
|
return {
|
|
92
|
-
depositTxHash:
|
|
93
|
-
scheduleId: await
|
|
95
|
+
depositTxHash: A,
|
|
96
|
+
scheduleId: await y(a, j, c, m, h, _, A)
|
|
94
97
|
};
|
|
95
|
-
},
|
|
96
|
-
let v =
|
|
98
|
+
}, O = async (t, n, r, i, o, u, d, p, m, g = !0, _) => {
|
|
99
|
+
let v = f([n]), y = n.erc20TokenAddress, b = a(await t.getEthereumAddressByChain(v)), x = {
|
|
97
100
|
chainId: v,
|
|
98
101
|
ethereumAddress: b,
|
|
99
102
|
hashedEthereumAddress: s(b),
|
|
100
|
-
feeStructure: u ?? await
|
|
103
|
+
feeStructure: u ?? await h(v, y, [y], l.Transact, [], 25n),
|
|
101
104
|
txCompletionTime: o,
|
|
102
|
-
ref:
|
|
105
|
+
ref: d,
|
|
103
106
|
action: p,
|
|
104
|
-
hashedDashboardAccountId:
|
|
107
|
+
hashedDashboardAccountId: m ? c(m) : void 0,
|
|
105
108
|
preEstimateGas: g,
|
|
106
109
|
destination: _
|
|
107
110
|
};
|
|
108
|
-
if (!e(v)) return
|
|
111
|
+
if (!e(v)) return E(t, n, r, i, x);
|
|
109
112
|
if (r.length > 4) throw Error("Tron supports at most 4 recipients per deposit - no circuit emits more outputs");
|
|
110
|
-
return
|
|
113
|
+
return D(t, n, r, i, x);
|
|
111
114
|
};
|
|
112
115
|
//#endregion
|
|
113
|
-
export {
|
|
116
|
+
export { O as hinkalDepositAndWithdraw };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../functions/utils/caseInsensitive.utils.cjs`),n=require(`../../crypto/poseidon.cjs`),r=require(`../../error-handling/error-codes.constants.cjs`),i=require(`../../functions/web3/etherFunctions.cjs`),a=require(`../../functions/utils/addresses.cjs`),o=require(`../../types/external-action.types.cjs`),s=require(`../../types/
|
|
1
|
+
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../functions/utils/caseInsensitive.utils.cjs`),n=require(`../../crypto/poseidon.cjs`),r=require(`../../error-handling/error-codes.constants.cjs`),i=require(`../../functions/web3/etherFunctions.cjs`),a=require(`../../functions/utils/addresses.cjs`),o=require(`../../types/external-action.types.cjs`),s=require(`../../types/transact.types.cjs`);require(`../../error-handling/index.cjs`);const c=require(`../../functions/pre-transaction/constructAdminData.cjs`),l=require(`../AccountActions/AccountActions.cjs`),u=require(`../../functions/pre-transaction/getFeeStructure.cjs`);require(`../../functions/pre-transaction/index.cjs`);const d=require(`../../functions/private-wallet/emporium.helpers.cjs`),f=require(`./hinkalTransact.cjs`),p=require(`../../functions/utils/admin-dimensions.cjs`),m=require(`../../functions/utils/involves-permit2-op.cjs`),h=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`),g=require(`../../functions/pre-transaction/merge-with-fee-structure.cjs`),_=require(`../../functions/pre-transaction/merge-with-fee-structure-emporium.cjs`),v=require(`./handleAutoDepositBack.cjs`);var y=async(y,b,x,S,C,w,T,E,D,O,k,A=!1,j,M,N,P)=>{if(N&&!a.isValidPrivateAddress(N.recipientInfo))throw Error(r.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);if(T.length>0&&!E)throw Error(`Subaccount is required for private wallet transactions`);let F=x.map(e=>e.erc20TokenAddress),I=await y.getEthereumAddress(),L=E?l.AccountActions.getAddressFromSubAccount(b,E):void 0,{contractData:R}=e.networkRegistry[b],{emporiumAddress:z}=R;if(!z)throw Error(`No Emporium Address Provided`);let B=O??await u.getFeeStructure(b,D,F,o.ExternalActionId.Emporium,w.map(e=>h.convertEmporiumOpToCallInfo(e,L??``,b)));for(L?await _.mergeWithFeeStructureEmporium(y,b,L,w,F,S,B,T.find(e=>t.caseInsensitiveEqual(e.token.erc20TokenAddress,B.feeToken))?.amount??0n):await g.mergeWithFeeStructure(b,F,S,B);C.length<F.length;)C.push(!1);let V=k??await y.getRandomRelay(b,!0);if(!V)throw Error(r.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let H=E?l.AccountActions.getPrivateKeyFromSubAccount(b,E):void 0,U=e.getOnchainChainId(b),W=H?l.AccountActions.getSignerAddressFromPrivateKey(U,H):void 0,G=i.randomBigInt(31),K=y.generateProofRemotely?await d.encodeEmporiumMetadata(b,z,H,w,n.poseidonFunction(G),W,B.flatFee):void 0,q=await d.getAuthorizationDataIfNeeded(b,H),J=m.uniswapWorkaround(w),Y=p.resolveSwapPairTokens(M,T.map(({token:e})=>e),P),X=c.constructAdminData(M,b,T.map(e=>e.token.erc20TokenAddress),T.map(e=>e.amount),I,Y),Z,Q=await f.hinkalTransact(y,{chainId:b,erc20Addresses:F,amountChanges:S,externalAddress:z,externalActionId:o.ExternalActionId.Emporium,externalActionMetadata:K,onChainCreation:C,feeStructure:B,relay:V,messageSeed:G,recipientAddress:N?[N.recipientInfo]:void 0,recipientAmounts:N?[F.map(e=>t.caseInsensitiveEqual(e,N.token.erc20TokenAddress)?N.amount:0n)]:void 0,subAccountPrivateKey:H,emporiumOps:w,onTxSubmitLocally:e=>{Z=e},submit:{mode:s.SubmitMode.Relayer,adminData:X,authorizationData:q,withUniswapWorkAround:J}});return A&&E&&v.handleAutoDepositBack(y,b,L,E,B.feeToken,j,T,Z),Q};exports.hinkalPrivateWallet=y;
|
|
@@ -3,4 +3,4 @@ import { FeeStructure } from '../../types/hinkal.types';
|
|
|
3
3
|
import { ERC20Token, PrivateRecipientInfo, TokenChanges } from '../../types/token.types';
|
|
4
4
|
import { SubAccount } from '../../types/proxy.types';
|
|
5
5
|
import { AdminTransactionType } from '../../types/admin.types';
|
|
6
|
-
export declare const hinkalPrivateWallet: (hinkal: IHinkal, chainId: number, erc20Tokens: ERC20Token[], deltaChanges: bigint[], onChainCreation: boolean[], ops: string[], emporiumTokenChanges: TokenChanges<bigint>[], subAccount?: SubAccount, feeToken?: string, feeStructureOverride?: FeeStructure, relayOverride?: string, autoDepositBack?: boolean, maxGasInDollar?: string, action?: AdminTransactionType, privateRecipientInfo?: PrivateRecipientInfo) => Promise<string>;
|
|
6
|
+
export declare const hinkalPrivateWallet: (hinkal: IHinkal, chainId: number, erc20Tokens: ERC20Token[], deltaChanges: bigint[], onChainCreation: boolean[], ops: string[], emporiumTokenChanges: TokenChanges<bigint>[], subAccount?: SubAccount, feeToken?: string, feeStructureOverride?: FeeStructure, relayOverride?: string, autoDepositBack?: boolean, maxGasInDollar?: string, action?: AdminTransactionType, privateRecipientInfo?: PrivateRecipientInfo, bridgedToken?: ERC20Token) => Promise<string>;
|
|
@@ -5,56 +5,56 @@ import { transactionErrorCodes as i } from "../../error-handling/error-codes.con
|
|
|
5
5
|
import { randomBigInt as a } from "../../functions/web3/etherFunctions.mjs";
|
|
6
6
|
import { isValidPrivateAddress as o } from "../../functions/utils/addresses.mjs";
|
|
7
7
|
import { ExternalActionId as s } from "../../types/external-action.types.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import { SubmitMode as l } from "../../types/transact.types.mjs";
|
|
8
|
+
import { SubmitMode as c } from "../../types/transact.types.mjs";
|
|
10
9
|
import "../../error-handling/index.mjs";
|
|
11
|
-
import { constructAdminData as
|
|
12
|
-
import { AccountActions as
|
|
13
|
-
import { getFeeStructure as
|
|
10
|
+
import { constructAdminData as l } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
11
|
+
import { AccountActions as u } from "../AccountActions/AccountActions.mjs";
|
|
12
|
+
import { getFeeStructure as d } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
14
13
|
import "../../functions/pre-transaction/index.mjs";
|
|
15
|
-
import { encodeEmporiumMetadata as
|
|
16
|
-
import { hinkalTransact as
|
|
14
|
+
import { encodeEmporiumMetadata as f, getAuthorizationDataIfNeeded as p } from "../../functions/private-wallet/emporium.helpers.mjs";
|
|
15
|
+
import { hinkalTransact as m } from "./hinkalTransact.mjs";
|
|
16
|
+
import { resolveSwapPairTokens as h } from "../../functions/utils/admin-dimensions.mjs";
|
|
17
17
|
import { uniswapWorkaround as g } from "../../functions/utils/involves-permit2-op.mjs";
|
|
18
18
|
import { convertEmporiumOpToCallInfo as _ } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
|
|
19
19
|
import { mergeWithFeeStructure as v } from "../../functions/pre-transaction/merge-with-fee-structure.mjs";
|
|
20
20
|
import { mergeWithFeeStructureEmporium as y } from "../../functions/pre-transaction/merge-with-fee-structure-emporium.mjs";
|
|
21
21
|
import { handleAutoDepositBack as b } from "./handleAutoDepositBack.mjs";
|
|
22
22
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalPrivateWallet.ts
|
|
23
|
-
var x = async (x, S, C, w, T, E, D, O, k, A, j, M = !1, N, P, F) => {
|
|
23
|
+
var x = async (x, S, C, w, T, E, D, O, k, A, j, M = !1, N, P, F, I) => {
|
|
24
24
|
if (F && !o(F.recipientInfo)) throw Error(i.RECIPIENT_FORMAT_INCORRECT);
|
|
25
25
|
if (D.length > 0 && !O) throw Error("Subaccount is required for private wallet transactions");
|
|
26
|
-
let
|
|
27
|
-
if (!
|
|
28
|
-
let
|
|
29
|
-
for (
|
|
30
|
-
let
|
|
31
|
-
if (!
|
|
32
|
-
let
|
|
26
|
+
let L = C.map((e) => e.erc20TokenAddress), R = await x.getEthereumAddress(), z = O ? u.getAddressFromSubAccount(S, O) : void 0, { contractData: B } = t[S], { emporiumAddress: V } = B;
|
|
27
|
+
if (!V) throw Error("No Emporium Address Provided");
|
|
28
|
+
let H = A ?? await d(S, k, L, s.Emporium, E.map((e) => _(e, z ?? "", S)));
|
|
29
|
+
for (z ? await y(x, S, z, E, L, w, H, D.find((e) => n(e.token.erc20TokenAddress, H.feeToken))?.amount ?? 0n) : await v(S, L, w, H); T.length < L.length;) T.push(!1);
|
|
30
|
+
let U = j ?? await x.getRandomRelay(S, !0);
|
|
31
|
+
if (!U) throw Error(i.RELAYER_NOT_AVAILABLE);
|
|
32
|
+
let W = O ? u.getPrivateKeyFromSubAccount(S, O) : void 0, G = e(S), K = W ? u.getSignerAddressFromPrivateKey(G, W) : void 0, q = a(31), J = x.generateProofRemotely ? await f(S, V, W, E, r(q), K, H.flatFee) : void 0, Y = await p(S, W), X = g(E), Z = h(P, D.map(({ token: e }) => e), I), Q = l(P, S, D.map((e) => e.token.erc20TokenAddress), D.map((e) => e.amount), R, Z), $, ee = await m(x, {
|
|
33
33
|
chainId: S,
|
|
34
|
-
erc20Addresses:
|
|
34
|
+
erc20Addresses: L,
|
|
35
35
|
amountChanges: w,
|
|
36
|
-
externalAddress:
|
|
36
|
+
externalAddress: V,
|
|
37
37
|
externalActionId: s.Emporium,
|
|
38
|
-
externalActionMetadata:
|
|
38
|
+
externalActionMetadata: J,
|
|
39
39
|
onChainCreation: T,
|
|
40
|
-
feeStructure:
|
|
41
|
-
relay:
|
|
42
|
-
messageSeed:
|
|
40
|
+
feeStructure: H,
|
|
41
|
+
relay: U,
|
|
42
|
+
messageSeed: q,
|
|
43
43
|
recipientAddress: F ? [F.recipientInfo] : void 0,
|
|
44
|
-
recipientAmounts: F ? [
|
|
45
|
-
subAccountPrivateKey:
|
|
44
|
+
recipientAmounts: F ? [L.map((e) => n(e, F.token.erc20TokenAddress) ? F.amount : 0n)] : void 0,
|
|
45
|
+
subAccountPrivateKey: W,
|
|
46
46
|
emporiumOps: E,
|
|
47
47
|
onTxSubmitLocally: (e) => {
|
|
48
|
-
|
|
48
|
+
$ = e;
|
|
49
49
|
},
|
|
50
50
|
submit: {
|
|
51
|
-
mode:
|
|
52
|
-
adminData:
|
|
53
|
-
authorizationData:
|
|
54
|
-
withUniswapWorkAround:
|
|
51
|
+
mode: c.Relayer,
|
|
52
|
+
adminData: Q,
|
|
53
|
+
authorizationData: Y,
|
|
54
|
+
withUniswapWorkAround: X
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
|
-
return M && O && b(x, S,
|
|
57
|
+
return M && O && b(x, S, z, O, H.feeToken, N, D, $), ee;
|
|
58
58
|
};
|
|
59
59
|
//#endregion
|
|
60
60
|
export { x as hinkalPrivateWallet };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../types/hinkal.types.cjs`),r=require(`../../functions/utils/caseInsensitive.utils.cjs`),i=require(`../../types/ethereum-network.types.cjs`),a=require(`../../functions/utils/token-check.utils.cjs`),o=require(`../../functions/pre-transaction/constructAdminData.cjs`),s=require(`../../functions/utils/getContractAddress.cjs`),c=require(`../../functions/web3/functionCalls/constructBatchCall.cjs`),l=require(`../../functions/web3/functionCalls/waitForErc20Approvals.cjs`),u=require(`../../API/admin-calls.cjs`),d=require(`../../functions/utils/getRecipientInfoFromUserKeys.cjs`),f=require(`./hinkalProoflessDeposit.utils.cjs`);var p=async(p,m,h,g,_,v=!1,y=n.zeroProoflessFeeStructure,b=``,x,S=!1)=>{let
|
|
1
|
+
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../types/hinkal.types.cjs`),r=require(`../../functions/utils/caseInsensitive.utils.cjs`),i=require(`../../types/ethereum-network.types.cjs`),a=require(`../../functions/utils/token-check.utils.cjs`),o=require(`../../functions/pre-transaction/constructAdminData.cjs`),s=require(`../../functions/utils/getContractAddress.cjs`),c=require(`../../functions/web3/functionCalls/constructBatchCall.cjs`),l=require(`../../functions/web3/functionCalls/waitForErc20Approvals.cjs`),u=require(`../../API/admin-calls.cjs`),d=require(`../../functions/utils/getRecipientInfoFromUserKeys.cjs`),f=require(`./hinkalProoflessDeposit.utils.cjs`);var p=async(p,m,h,g,_,v=!1,y=n.zeroProoflessFeeStructure,b=``,x,S=!1,C=!1)=>{let w=a.validateAndGetChainId(m);if(e.isTronLike(w))throw Error(`Proofless deposit is not supported on Tron`);let T=await p.getEthereumAddressByChain(w),E=g??m.map(()=>d.getStealthAddressStructureFromUserKeys(p.userKeys));if(E.length!==m.length)throw Error(`Stealth address structures length must be equal to erc20 tokens length`);if(S||f.assertNoDuplicateStealthAddressStructures(E),g&&!_)throw Error(`recipientEncryptionKeysOverride is required whenever stealthAddressStructuresOverride is provided`);if(_&&_.length!==m.length)throw Error(`recipientEncryptionKeysOverride length must be equal to erc20 tokens length`);let D=f.buildProoflessEncryptedOutputs(E,_??f.getOwnRecipientEncryptionKeys(p.userKeys,m.length)),O=y.feeAmount>0n,k=O?p.getContractWithSigner(w,i.ContractType.HinkalWrapperContract):p.getContractWithSigner(w,i.ContractType.HinkalContract),A=O?[m.map(({erc20TokenAddress:e})=>e),h,E,D,v,y,b]:[m.map(({erc20TokenAddress:e})=>e),h,E,D,v,b],j=r.caseInsensitiveEqual(y.feeToken,t.zeroAddress),M=m.reduce((e,n,i)=>r.caseInsensitiveEqual(n.erc20TokenAddress,t.zeroAddress)?e+h[i]:e,0n)+(j?y.feeAmount:0n);if(C)return k.prooflessDeposit.populateTransaction(...A,{value:M>0n?M:void 0});let N=p.getProviderAdapter(w),P=f.aggregateAmountsForApproval(!j&&y.feeAmount>0n?[...m,{erc20TokenAddress:y.feeToken,chainId:w}]:m,!j&&y.feeAmount>0n?[...h,y.feeAmount]:h),F=P.filter(({token:e,balance:n})=>!r.caseInsensitiveEqual(e.erc20TokenAddress,t.zeroAddress)&&n>0n),I;if(F.length>0&&await N.supportsBatchCall?.(w)&&N.sendBatchCallsTransaction){let e=c.buildApproveAndProoflessDepositCalls(F.map(({token:e})=>e.erc20TokenAddress),F.map(({balance:e})=>e),s.getContractAddress(k),k,m.map(({erc20TokenAddress:e})=>e),h,E,D,v,O?y:void 0,b,M);I=await N.sendBatchCallsTransaction(w,e)}else{await f.approveTokens(p,w,s.getContractAddress(k),P);let e=await p.getEthereumAddressByChain(w),t=P.map(({token:e,balance:t})=>({tokenAddress:e.erc20TokenAddress,requiredAmount:t}));await l.waitForErc20Approvals(p,w,e,s.getContractAddress(k),t),I=await k.prooflessDeposit(...A,{value:M>0n?M:void 0})}let L=I.hash;return u.emitTxPublicData(o.constructAdminData(x,w,m.map(({erc20TokenAddress:e})=>e),h,T)),L};exports.hinkalProoflessDeposit=p;
|
|
@@ -4,4 +4,4 @@ import { IHinkal } from './IHinkal';
|
|
|
4
4
|
import { StealthAddressStructure } from '../../types/circom-data.types';
|
|
5
5
|
import { ProoflessFeeStructure } from '../../types/hinkal.types';
|
|
6
6
|
import { AdminTransactionType } from '../../types/admin.types';
|
|
7
|
-
export declare const hinkalProoflessDeposit: (hinkal: IHinkal, erc20Tokens: ERC20Token[], amountChanges: bigint[], stealthAddressStructuresOverride?: StealthAddressStructure[], recipientEncryptionKeysOverride?: string[], createBlockedUtxos?: boolean, feeStructure?: ProoflessFeeStructure, orderId?: string, action?: AdminTransactionType, returnTxData?: boolean) => Promise<string | ethers.TransactionRequest>;
|
|
7
|
+
export declare const hinkalProoflessDeposit: (hinkal: IHinkal, erc20Tokens: ERC20Token[], amountChanges: bigint[], stealthAddressStructuresOverride?: StealthAddressStructure[], recipientEncryptionKeysOverride?: string[], createBlockedUtxos?: boolean, feeStructure?: ProoflessFeeStructure, orderId?: string, action?: AdminTransactionType, skipDuplicateCheck?: boolean, returnTxData?: boolean) => Promise<string | ethers.TransactionRequest>;
|
|
@@ -12,47 +12,47 @@ import { emitTxPublicData as u } from "../../API/admin-calls.mjs";
|
|
|
12
12
|
import { getStealthAddressStructureFromUserKeys as d } from "../../functions/utils/getRecipientInfoFromUserKeys.mjs";
|
|
13
13
|
import { aggregateAmountsForApproval as f, approveTokens as p, assertNoDuplicateStealthAddressStructures as m, buildProoflessEncryptedOutputs as h, getOwnRecipientEncryptionKeys as g } from "./hinkalProoflessDeposit.utils.mjs";
|
|
14
14
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalProoflessDeposit.ts
|
|
15
|
-
var _ = async (_, v, y, b, x, S = !1, C = n, w = "", T, E = !1) => {
|
|
16
|
-
let
|
|
17
|
-
if (e(
|
|
18
|
-
let
|
|
19
|
-
if (
|
|
20
|
-
if (m(
|
|
15
|
+
var _ = async (_, v, y, b, x, S = !1, C = n, w = "", T, E = !1, D = !1) => {
|
|
16
|
+
let O = a(v);
|
|
17
|
+
if (e(O)) throw Error("Proofless deposit is not supported on Tron");
|
|
18
|
+
let k = await _.getEthereumAddressByChain(O), A = b ?? v.map(() => d(_.userKeys));
|
|
19
|
+
if (A.length !== v.length) throw Error("Stealth address structures length must be equal to erc20 tokens length");
|
|
20
|
+
if (E || m(A), b && !x) throw Error("recipientEncryptionKeysOverride is required whenever stealthAddressStructuresOverride is provided");
|
|
21
21
|
if (x && x.length !== v.length) throw Error("recipientEncryptionKeysOverride length must be equal to erc20 tokens length");
|
|
22
|
-
let
|
|
22
|
+
let j = h(A, x ?? g(_.userKeys, v.length)), M = C.feeAmount > 0n, N = M ? _.getContractWithSigner(O, i.HinkalWrapperContract) : _.getContractWithSigner(O, i.HinkalContract), P = M ? [
|
|
23
23
|
v.map(({ erc20TokenAddress: e }) => e),
|
|
24
24
|
y,
|
|
25
|
-
k,
|
|
26
25
|
A,
|
|
26
|
+
j,
|
|
27
27
|
S,
|
|
28
28
|
C,
|
|
29
29
|
w
|
|
30
30
|
] : [
|
|
31
31
|
v.map(({ erc20TokenAddress: e }) => e),
|
|
32
32
|
y,
|
|
33
|
-
k,
|
|
34
33
|
A,
|
|
34
|
+
j,
|
|
35
35
|
S,
|
|
36
36
|
w
|
|
37
|
-
],
|
|
38
|
-
if (
|
|
39
|
-
let
|
|
37
|
+
], F = r(C.feeToken, t), I = v.reduce((e, n, i) => r(n.erc20TokenAddress, t) ? e + y[i] : e, 0n) + (F ? C.feeAmount : 0n);
|
|
38
|
+
if (D) return N.prooflessDeposit.populateTransaction(...P, { value: I > 0n ? I : void 0 });
|
|
39
|
+
let L = _.getProviderAdapter(O), R = f(!F && C.feeAmount > 0n ? [...v, {
|
|
40
40
|
erc20TokenAddress: C.feeToken,
|
|
41
|
-
chainId:
|
|
42
|
-
}] : v, !
|
|
43
|
-
if (
|
|
44
|
-
let e = c(
|
|
45
|
-
|
|
41
|
+
chainId: O
|
|
42
|
+
}] : v, !F && C.feeAmount > 0n ? [...y, C.feeAmount] : y), z = R.filter(({ token: e, balance: n }) => !r(e.erc20TokenAddress, t) && n > 0n), B;
|
|
43
|
+
if (z.length > 0 && await L.supportsBatchCall?.(O) && L.sendBatchCallsTransaction) {
|
|
44
|
+
let e = c(z.map(({ token: e }) => e.erc20TokenAddress), z.map(({ balance: e }) => e), s(N), N, v.map(({ erc20TokenAddress: e }) => e), y, A, j, S, M ? C : void 0, w, I);
|
|
45
|
+
B = await L.sendBatchCallsTransaction(O, e);
|
|
46
46
|
} else {
|
|
47
|
-
await p(_,
|
|
48
|
-
let e = await _.getEthereumAddressByChain(
|
|
47
|
+
await p(_, O, s(N), R);
|
|
48
|
+
let e = await _.getEthereumAddressByChain(O), t = R.map(({ token: e, balance: t }) => ({
|
|
49
49
|
tokenAddress: e.erc20TokenAddress,
|
|
50
50
|
requiredAmount: t
|
|
51
51
|
}));
|
|
52
|
-
await l(_,
|
|
52
|
+
await l(_, O, e, s(N), t), B = await N.prooflessDeposit(...P, { value: I > 0n ? I : void 0 });
|
|
53
53
|
}
|
|
54
|
-
let
|
|
55
|
-
return u(o(T,
|
|
54
|
+
let V = B.hash;
|
|
55
|
+
return u(o(T, O, v.map(({ erc20TokenAddress: e }) => e), y, k)), V;
|
|
56
56
|
};
|
|
57
57
|
//#endregion
|
|
58
58
|
export { _ as hinkalProoflessDeposit };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../constants/protocol.constants.cjs`),t=require(`../../functions/utils/caseInsensitive.utils.cjs`),n=require(`../crypto-keys/keys.cjs`),r=require(`../../types/ethereum-network.types.cjs`),i=require(
|
|
1
|
+
const e=require(`../../constants/protocol.constants.cjs`),t=require(`../../functions/utils/caseInsensitive.utils.cjs`),n=require(`../crypto-keys/keys.cjs`),r=require(`../../types/ethereum-network.types.cjs`),i=require(`../crypto-keys/encryptDecryptUtxo.cjs`);require(`../../externalABIs/index.cjs`);const a=require(`../../functions/utils/token-check.utils.cjs`),o=require(`../../functions/utils/tx-confirmation.utils.cjs`);var s=(e,t)=>{if(e.length!==t.length)throw Error(`stealthAddressStructures and recipientEncryptionKeys must have equal length`);return e.map((e,n)=>{let r=t[n];if(!r)throw Error(`Missing encryptionKey for proofless deposit output ${n}: required so the enclave can attribute this UTXO to its owner`);return`0x${Buffer.from(i.encryptEncryptionKeyAndStealthAddress(r,e.stealthAddress)).toString(`hex`)}`})},c=(e,t)=>{let r=n.UserKeys.getEncryptionKeyPair(e.getShieldedPrivateKey()).publicKey;return Array.from({length:t},()=>r)},l=(e,t)=>{let n=[],r=0;for(let i=0;i<e.length;i+=1){let o=!1;for(let s=0;s<r;s+=1)if(a.isSameERC20Token(n[s].token,e[i])){n[s].balance+=t[i],o=!0;break}o||(n[r]={token:e[i],balance:t[i]},r+=1)}return n},u=async(n,i,a,s)=>{for(let c=0;c<s.length;c+=1)t.caseInsensitiveEqual(s[c].token.erc20TokenAddress,e.zeroAddress)||await o.waitForEthereumTransactionConfirmation(i,(await n.getContractWithSigner(i,r.ContractType.ERC20Contract,s[c].token.erc20TokenAddress).approve(a,s[c].balance)).hash)},d=e=>{let t=new Set;e.forEach(({H0x:e,stealthAddress:n})=>{let r=`${e.toString()}:${n.toString()}`;if(t.has(r))throw Error(`Duplicate randomization and stealth address pair detected in stealthAddressStructures`);t.add(r)})};exports.aggregateAmountsForApproval=l,exports.approveTokens=u,exports.assertNoDuplicateStealthAddressStructures=d,exports.buildProoflessEncryptedOutputs=s,exports.getOwnRecipientEncryptionKeys=c;
|
|
@@ -2,9 +2,9 @@ import { zeroAddress as e } from "../../constants/protocol.constants.mjs";
|
|
|
2
2
|
import { caseInsensitiveEqual as t } from "../../functions/utils/caseInsensitive.utils.mjs";
|
|
3
3
|
import { UserKeys as n } from "../crypto-keys/keys.mjs";
|
|
4
4
|
import { ContractType as r } from "../../types/ethereum-network.types.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import { encryptEncryptionKeyAndStealthAddress as a } from "../crypto-keys/encryptDecryptUtxo.mjs";
|
|
5
|
+
import { encryptEncryptionKeyAndStealthAddress as i } from "../crypto-keys/encryptDecryptUtxo.mjs";
|
|
7
6
|
import "../../externalABIs/index.mjs";
|
|
7
|
+
import { isSameERC20Token as a } from "../../functions/utils/token-check.utils.mjs";
|
|
8
8
|
import { waitForEthereumTransactionConfirmation as o } from "../../functions/utils/tx-confirmation.utils.mjs";
|
|
9
9
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalProoflessDeposit.utils.ts
|
|
10
10
|
var s = (e, t) => {
|
|
@@ -12,22 +12,22 @@ var s = (e, t) => {
|
|
|
12
12
|
return e.map((e, n) => {
|
|
13
13
|
let r = t[n];
|
|
14
14
|
if (!r) throw Error(`Missing encryptionKey for proofless deposit output ${n}: required so the enclave can attribute this UTXO to its owner`);
|
|
15
|
-
return `0x${Buffer.from(
|
|
15
|
+
return `0x${Buffer.from(i(r, e.stealthAddress)).toString("hex")}`;
|
|
16
16
|
});
|
|
17
17
|
}, c = (e, t) => {
|
|
18
18
|
let r = n.getEncryptionKeyPair(e.getShieldedPrivateKey()).publicKey;
|
|
19
19
|
return Array.from({ length: t }, () => r);
|
|
20
20
|
}, l = (e, t) => {
|
|
21
21
|
let n = [], r = 0;
|
|
22
|
-
for (let
|
|
22
|
+
for (let i = 0; i < e.length; i += 1) {
|
|
23
23
|
let o = !1;
|
|
24
|
-
for (let s = 0; s < r; s += 1) if (
|
|
25
|
-
n[s].balance += t[
|
|
24
|
+
for (let s = 0; s < r; s += 1) if (a(n[s].token, e[i])) {
|
|
25
|
+
n[s].balance += t[i], o = !0;
|
|
26
26
|
break;
|
|
27
27
|
}
|
|
28
28
|
o || (n[r] = {
|
|
29
|
-
token: e[
|
|
30
|
-
balance: t[
|
|
29
|
+
token: e[i],
|
|
30
|
+
balance: t[i]
|
|
31
31
|
}, r += 1);
|
|
32
32
|
}
|
|
33
33
|
return n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../../constants/protocol.constants.cjs`);const e=require(`../../error-handling/error-codes.constants.cjs`),t=require(`../../types/external-action.types.cjs`),n=require(`../../functions/utils/token-check.utils.cjs`),r=require(`../AccountActions/AccountActions.cjs`),i=require(`../../functions/pre-transaction/getFeeStructure.cjs`),a=require(`../../
|
|
1
|
+
require(`../../constants/protocol.constants.cjs`);const e=require(`../../error-handling/error-codes.constants.cjs`),t=require(`../../types/external-action.types.cjs`),n=require(`../../functions/utils/token-check.utils.cjs`),r=require(`../AccountActions/AccountActions.cjs`),i=require(`../../functions/pre-transaction/getFeeStructure.cjs`),a=require(`../../functions/utils/fees.utils.cjs`),o=require(`../../constants/addresses.constants.cjs`),s=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`),c=require(`../../functions/private-wallet/emporium.swap.helpers.cjs`);var l=async(l,u,d,f,p,m,h,g,_,v=!1,y,b,x,S)=>{if(!g)throw Error(`Fee token is required in hinkalProxySwap`);let C=n.validateAndGetChainId(u),w=r.AccountActions.getAddressFromSubAccount(C,h);if(!w)throw Error(`Public account address is not available`);let T=u.map(e=>e.erc20TokenAddress),E=await l.getRandomRelay(C,!0);if(!E)throw Error(e.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let D=await c.createSwapToEmporiumOps(l,C,f,o.SWAP_ROUTER_ADDRESSES[f][C],p,T[0],d[0],d[1],T[1],m,w,E,!0),O=_??await i.getFeeStructure(C,g,T,t.ExternalActionId.Emporium,D.map(e=>s.convertEmporiumOpToCallInfo(e,w,C)),35n),k=u.map((e,t)=>({token:e,amount:d[t]})),A=x&&S!==void 0?await a.calculateModifiedFeeStructure(C,x,S,O):O;return l.actionPrivateWallet(C,[],[],[],D,k,h,g,A,E,v,y,b,void 0,x)};exports.hinkalProxySwap=l;
|
|
@@ -4,9 +4,9 @@ import { ExternalActionId as t } from "../../types/external-action.types.mjs";
|
|
|
4
4
|
import { validateAndGetChainId as n } from "../../functions/utils/token-check.utils.mjs";
|
|
5
5
|
import { AccountActions as r } from "../AccountActions/AccountActions.mjs";
|
|
6
6
|
import { getFeeStructure as i } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { calculateModifiedFeeStructure as a } from "../../functions/utils/fees.utils.mjs";
|
|
8
|
+
import { SWAP_ROUTER_ADDRESSES as o } from "../../constants/addresses.constants.mjs";
|
|
9
|
+
import { convertEmporiumOpToCallInfo as s } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
|
|
10
10
|
import { createSwapToEmporiumOps as c } from "../../functions/private-wallet/emporium.swap.helpers.mjs";
|
|
11
11
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalProxySwap.ts
|
|
12
12
|
var l = async (l, u, d, f, p, m, h, g, _, v = !1, y, b, x, S) => {
|
|
@@ -15,11 +15,11 @@ var l = async (l, u, d, f, p, m, h, g, _, v = !1, y, b, x, S) => {
|
|
|
15
15
|
if (!w) throw Error("Public account address is not available");
|
|
16
16
|
let T = u.map((e) => e.erc20TokenAddress), E = await l.getRandomRelay(C, !0);
|
|
17
17
|
if (!E) throw Error(e.RELAYER_NOT_AVAILABLE);
|
|
18
|
-
let D = await c(l, C, f,
|
|
18
|
+
let D = await c(l, C, f, o[f][C], p, T[0], d[0], d[1], T[1], m, w, E, !0), O = _ ?? await i(C, g, T, t.Emporium, D.map((e) => s(e, w, C)), 35n), k = u.map((e, t) => ({
|
|
19
19
|
token: e,
|
|
20
20
|
amount: d[t]
|
|
21
|
-
})), A = x && S !== void 0 ? await
|
|
22
|
-
return l.actionPrivateWallet(C, [], [], [], D, k, h, g, A, E, v, y, b, void 0);
|
|
21
|
+
})), A = x && S !== void 0 ? await a(C, x, S, O) : O;
|
|
22
|
+
return l.actionPrivateWallet(C, [], [], [], D, k, h, g, A, E, v, y, b, void 0, x);
|
|
23
23
|
};
|
|
24
24
|
//#endregion
|
|
25
25
|
export { l as hinkalProxySwap };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../../constants/protocol.constants.cjs`);const e=require(`../../error-handling/error-codes.constants.cjs`),t=require(`../../functions/utils/addresses.cjs`),n=require(`../../types/external-action.types.cjs`),r=require(`../../functions/utils/token-check.utils.cjs`),i=require(`../../functions/pre-transaction/getVolatileTransferAmount.cjs`),a=require(`../AccountActions/AccountActions.cjs`),o=require(`../../functions/pre-transaction/getFeeStructure.cjs`),s=require(`../../functions/
|
|
1
|
+
require(`../../constants/protocol.constants.cjs`);const e=require(`../../error-handling/error-codes.constants.cjs`),t=require(`../../functions/utils/addresses.cjs`),n=require(`../../types/external-action.types.cjs`),r=require(`../../functions/utils/token-check.utils.cjs`),i=require(`../../functions/pre-transaction/getVolatileTransferAmount.cjs`),a=require(`../AccountActions/AccountActions.cjs`),o=require(`../../functions/pre-transaction/getFeeStructure.cjs`),s=require(`../../functions/utils/fees.utils.cjs`),c=require(`../../functions/private-wallet/emporium.helpers.cjs`),l=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`);var u=async(u,d,f,p,m,h,g,_)=>{if(!g)throw Error(`hinkalProxyToPrivate: subAccount should be provided`);if(!m)throw Error(`Fee token is required in hinkalProxyToPrivate`);if(!t.isValidPrivateAddress(p))throw Error(e.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);let v=r.validateAndGetChainId(d),y=a.AccountActions.getAddressFromSubAccount(v,g);if(!y)throw Error(`Public account address is not available`);let b=d.map(e=>e.erc20TokenAddress),x=await i.modifyVolatileTokenAmountChanges(v,d,f,y),S=c.createTransaferEmporiumOpsBatch(u,v,b,x),C=await s.calculateModifiedFeeStructureForTokens(v,d,x,h??await o.getFeeStructure(v,m,b,n.ExternalActionId.Emporium,S.map(e=>l.convertEmporiumOpToCallInfo(e,y,v)),25n)),w=d.map((e,t)=>({token:e,amount:-1n*x[t]}));return u.actionPrivateWallet(v,[d[0]],[0n],[!1],S,w,g,m,C,void 0,void 0,void 0,_,{recipientInfo:p,amount:x[0],token:d[0]})};exports.hinkalProxyToPrivate=u;
|
|
@@ -6,9 +6,9 @@ import { validateAndGetChainId as r } from "../../functions/utils/token-check.ut
|
|
|
6
6
|
import { modifyVolatileTokenAmountChanges as i } from "../../functions/pre-transaction/getVolatileTransferAmount.mjs";
|
|
7
7
|
import { AccountActions as a } from "../AccountActions/AccountActions.mjs";
|
|
8
8
|
import { getFeeStructure as o } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { calculateModifiedFeeStructureForTokens as s } from "../../functions/utils/fees.utils.mjs";
|
|
10
|
+
import { createTransaferEmporiumOpsBatch as c } from "../../functions/private-wallet/emporium.helpers.mjs";
|
|
11
|
+
import { convertEmporiumOpToCallInfo as l } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
|
|
12
12
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalProxyToPrivate.ts
|
|
13
13
|
var u = async (u, d, f, p, m, h, g, _) => {
|
|
14
14
|
if (!g) throw Error("hinkalProxyToPrivate: subAccount should be provided");
|
|
@@ -16,7 +16,7 @@ var u = async (u, d, f, p, m, h, g, _) => {
|
|
|
16
16
|
if (!t(p)) throw Error(e.RECIPIENT_FORMAT_INCORRECT);
|
|
17
17
|
let v = r(d), y = a.getAddressFromSubAccount(v, g);
|
|
18
18
|
if (!y) throw Error("Public account address is not available");
|
|
19
|
-
let b = d.map((e) => e.erc20TokenAddress), x = await i(v, d, f, y), S =
|
|
19
|
+
let b = d.map((e) => e.erc20TokenAddress), x = await i(v, d, f, y), S = c(u, v, b, x), C = await s(v, d, x, h ?? await o(v, m, b, n.Emporium, S.map((e) => l(e, y, v)), 25n)), w = d.map((e, t) => ({
|
|
20
20
|
token: e,
|
|
21
21
|
amount: -1n * x[t]
|
|
22
22
|
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../functions/utils/receive-vault-account.utils.cjs`),t=require(`../../functions/utils/receive-vault-scan.utils.cjs`);var n=async n=>{let{records:r,blocks:i}=await e.getReceiveVaultAccountSnapshot(n.userKeys);return{entries:[...r].sort((e,t)=>t.index-e.index),blockedFunds:await t.getReceiveVaultBlockedFunds(r,i)}};exports.hinkalGetReceiveVaultAccount=n;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getReceiveVaultAccountSnapshot as e } from "../../functions/utils/receive-vault-account.utils.mjs";
|
|
2
|
+
import { getReceiveVaultBlockedFunds as t } from "../../functions/utils/receive-vault-scan.utils.mjs";
|
|
3
|
+
//#region libs/shared/common/src/data-structures/Hinkal/hinkalReceiveVaultAccount.ts
|
|
4
|
+
var n = async (n) => {
|
|
5
|
+
let { records: r, blocks: i } = await e(n.userKeys);
|
|
6
|
+
return {
|
|
7
|
+
entries: [...r].sort((e, t) => t.index - e.index),
|
|
8
|
+
blockedFunds: await t(r, i)
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { n as hinkalGetReceiveVaultAccount };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../functions/utils/receive-vault.utils.cjs`),t=require(`../../API/receiveVaultCalls.cjs`),n=require(`../../functions/utils/receive-vault-account.utils.cjs`),r=require(`./hinkalReceiveVaultSettle.cjs`);var i=async(n,i,a,o)=>{let s=e.getReceiveVaultParams(n,o),c=r.buildReceiveVaultEncryptedOutput(s,i);return t.registerReceiveVault(o,s,i,a,c,await Promise.all(e.receiveVaultChainsForNetwork(o.network).map(async t=>({chainId:t,signature:await e.signReceiveVaultOutput(n,o,c,t)}))))},a=async(t,r,a,o)=>{let s=await e.buildReceiveVaultRecord(t,{index:await n.getReceiveVaultNextIndex(t,r),network:r,version:(await e.getReceiveVaultCurrentVersion(r)).toString()});return await i(t,a,o,s),s},o=(e,t)=>e.filter(e=>e.network===t).sort((e,t)=>t.index-e.index)[0],s=async(t,r,i=!1)=>{if(e.receiveVaultChainsForNetwork(r).length===0)throw Error(`receive vault: no factory for network ${r}`);let{userKeys:s}=t,c=e.getReceiveVaultEncryptionKey(s),l=e.getReceiveVaultAccountKey(s);if(!i){let{records:e}=await n.getReceiveVaultAccountSnapshot(s),t=o(e,r);if(t)return t}return a(s,r,c,l)};exports.hinkalReceiveVaultCreate=s;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ReceiveVaultNetwork, ReceiveVaultRecord } from '../../types/receive-vault.types';
|
|
2
|
+
import { IHinkal } from './IHinkal';
|
|
3
|
+
export declare const hinkalReceiveVaultCreate: (hinkal: IHinkal, network: ReceiveVaultNetwork, forceFresh?: boolean) => Promise<ReceiveVaultRecord>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { buildReceiveVaultRecord as e, getReceiveVaultAccountKey as t, getReceiveVaultCurrentVersion as n, getReceiveVaultEncryptionKey as r, getReceiveVaultParams as i, receiveVaultChainsForNetwork as a, signReceiveVaultOutput as o } from "../../functions/utils/receive-vault.utils.mjs";
|
|
2
|
+
import { registerReceiveVault as s } from "../../API/receiveVaultCalls.mjs";
|
|
3
|
+
import { getReceiveVaultAccountSnapshot as c, getReceiveVaultNextIndex as l } from "../../functions/utils/receive-vault-account.utils.mjs";
|
|
4
|
+
import { buildReceiveVaultEncryptedOutput as u } from "./hinkalReceiveVaultSettle.mjs";
|
|
5
|
+
//#region libs/shared/common/src/data-structures/Hinkal/hinkalReceiveVaultCreate.ts
|
|
6
|
+
var d = async (e, t, n, r) => {
|
|
7
|
+
let c = i(e, r), l = u(c, t);
|
|
8
|
+
return s(r, c, t, n, l, await Promise.all(a(r.network).map(async (t) => ({
|
|
9
|
+
chainId: t,
|
|
10
|
+
signature: await o(e, r, l, t)
|
|
11
|
+
}))));
|
|
12
|
+
}, f = async (t, r, i, a) => {
|
|
13
|
+
let o = await e(t, {
|
|
14
|
+
index: await l(t, r),
|
|
15
|
+
network: r,
|
|
16
|
+
version: (await n(r)).toString()
|
|
17
|
+
});
|
|
18
|
+
return await d(t, i, a, o), o;
|
|
19
|
+
}, p = (e, t) => e.filter((e) => e.network === t).sort((e, t) => t.index - e.index)[0], m = async (e, n, i = !1) => {
|
|
20
|
+
if (a(n).length === 0) throw Error(`receive vault: no factory for network ${n}`);
|
|
21
|
+
let { userKeys: o } = e, s = r(o), l = t(o);
|
|
22
|
+
if (!i) {
|
|
23
|
+
let { records: e } = await c(o), t = p(e, n);
|
|
24
|
+
if (t) return t;
|
|
25
|
+
}
|
|
26
|
+
return f(o, n, s, l);
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
export { m as hinkalReceiveVaultCreate };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../functions/utils/tron.utils.cjs`),r=require(`../../types/ethereum-network.types.cjs`),i=require(`../../functions/utils/receive-vault.utils.cjs`),a=require(`../../functions/utils/string.utils.cjs`),o=require(`../../error-handling/get-error.message.cjs`),s=require(`./hinkalSolanaReceiveVault.cjs`);let c=require(`ethers`);var l={NothingToSettle:`These funds have already been moved out of the receive address.`,RecoveryExpired:`The recovery request expired before it was confirmed. Please try again.`,BadRecoverySignature:`This wallet cannot recover these funds. Reconnect the account that generated the address.`,RecoveryAlreadyUsed:`This recovery was already submitted. Please try again.`},u=e=>{let t=e?.revert?.name;if(t&&l[t])return l[t];let n=JSON.stringify(e??``),r=Object.keys(l).find(e=>n.includes(c.ethers.id(`${e}()`).slice(2,10)));if(r)return l[r];let i=e?.message;return i&&c.ethers.isHexString(`0x${i}`)?a.hexToUtf8(i):e?.shortMessage??o.getErrorMessage(e)},d=async(a,o,c,l,d,f=!1)=>{let p=i.getReceiveVaultFactoryAddress(l);if(!p)throw Error(`receive vault: no factory on chain ${l}`);if(o.network!==i.receiveVaultNetworkOf(l))throw Error(`receive vault: network mismatch`);let m=BigInt(Math.floor(Date.now()/1e3)+900),h=await i.signReceiveVaultRecovery(a.userKeys,o,c,l,d,m);if(e.isSolanaLike(l)){let e=await a.getEthereumAddressByChain(l);return s.hinkalSolanaReceiveVaultRecover(a,l,i.getReceiveVaultParams(a.userKeys,o),c,d,m,h,e,f)}let g=[i.receiveVaultParamsToTuple(i.getReceiveVaultParams(a.userKeys,o)),n.addressToHexFormat(c),n.addressToHexFormat(d),m,h];if(e.isTronLike(l)){let{receiveVaultFactoryABI:r}=e.networkRegistry[l].contractData;if(!r)throw Error(`receive vault: no factory ABI on chain ${l}`);let i=a.getTronWeb(),o=n.evmHexToTronBase58Address(p);if(f){let{transaction:e}=await i.transactionBuilder.triggerSmartContract(o,``,{feeLimit:t.TRON_DEFAULT_FEE_LIMIT_SUN,callValue:0,input:n.createTronCallData(r,`recover`,g)},[],await a.getEthereumAddressByChain(l));return e}let s=i.contract(r,o);try{return await s.recover(...g).send({feeLimit:t.TRON_DEFAULT_FEE_LIMIT_SUN})}catch(e){throw Error(u(e))}}let _=a.getContractWithSigner(l,r.ContractType.ReceiveVaultFactoryContract);try{return f?_.recover.populateTransaction(...g):(await _.recover(...g)).hash}catch(e){throw Error(u(e))}};exports.hinkalReceiveVaultRecover=d;
|