@hinkal/common 0.2.22 → 0.2.23
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/API/proxyAccountsCalls.cjs +1 -1
- package/API/proxyAccountsCalls.mjs +13 -13
- package/README.md +63 -267
- package/constants/activity.constants.cjs +1 -1
- package/constants/activity.constants.mjs +0 -1
- package/constants/addresses.constants.cjs +1 -1
- package/constants/addresses.constants.mjs +9 -10
- package/constants/contracts.constants.cjs +1 -1
- package/constants/contracts.constants.d.ts +3 -3
- package/constants/contracts.constants.mjs +29 -29
- package/constants/server.constants.cjs +1 -1
- package/constants/server.constants.mjs +28 -29
- package/constants/tasks.constants.cjs +1 -1
- package/constants/tasks.constants.mjs +4 -5
- package/crypto/poseidon.cjs +1 -1
- package/crypto/poseidon.mjs +10 -10
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.cjs +1 -1
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.mjs +24 -24
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.mjs +4 -5
- package/data-structures/Hinkal/IHinkal.d.ts +2 -2
- package/data-structures/Hinkal/hinkalApprove.cjs +1 -1
- package/data-structures/Hinkal/hinkalApprove.mjs +40 -40
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -1
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +7 -8
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +4 -5
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +2 -3
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +18 -19
- package/data-structures/Hinkal/hinkalDepostAndBridge.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepostAndBridge.mjs +3 -4
- package/data-structures/Hinkal/hinkalInsideTransact.cjs +1 -1
- package/data-structures/Hinkal/hinkalInsideTransact.mjs +14 -13
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +2 -3
- package/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalProoflessDeposit.mjs +27 -26
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +38 -39
- package/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaSwap.mjs +16 -17
- package/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaTransfer.mjs +24 -25
- package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +15 -16
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +2 -3
- package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalTransfer.mjs +2 -3
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +9 -10
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +8 -9
- package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.mjs +10 -10
- package/data-structures/IndexedDB/activity-db.cjs +1 -1
- package/data-structures/IndexedDB/activity-db.mjs +39 -41
- package/data-structures/IndexedDB/balances-db.cjs +1 -1
- package/data-structures/IndexedDB/balances-db.mjs +8 -9
- package/data-structures/IndexedDB/contact-db.cjs +1 -1
- package/data-structures/IndexedDB/contact-db.mjs +21 -23
- package/data-structures/IndexedDB/signatures-db.cjs +1 -1
- package/data-structures/IndexedDB/signatures-db.mjs +2 -3
- package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +34 -36
- package/data-structures/crypto-keys/decodeUTXO.cjs +1 -1
- package/data-structures/crypto-keys/decodeUTXO.mjs +45 -45
- package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
- package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +28 -27
- package/data-structures/crypto-keys/keys.cjs +1 -1
- package/data-structures/crypto-keys/keys.d.ts +2 -3
- package/data-structures/crypto-keys/keys.mjs +56 -57
- package/data-structures/event-service/evm/AbstractEventService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractEventService.mjs +14 -14
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.d.ts +2 -3
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.mjs +5 -4
- package/data-structures/event-service/evm/AbstractSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractSnapshotService.mjs +6 -3
- package/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.d.ts +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.mjs +22 -18
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.mjs +2 -2
- package/data-structures/presale/PresaleContractWrapper.cjs +1 -1
- package/data-structures/presale/PresaleContractWrapper.d.ts +3 -3
- package/data-structures/presale/PresaleContractWrapper.mjs +10 -10
- package/data-structures/provider-adapter/IProviderAdapter.d.ts +7 -7
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.mjs +16 -14
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +7 -5
- package/error-handling/get-error.message.cjs +1 -1
- package/error-handling/get-error.message.mjs +2 -3
- package/functions/kyc/zkMeHelper.cjs +1 -1
- package/functions/kyc/zkMeHelper.mjs +3 -3
- package/functions/pre-transaction/getFlatFees.cjs +1 -1
- package/functions/pre-transaction/getFlatFees.mjs +2 -3
- package/functions/pre-transaction/getSolanaCalldataHash.cjs +1 -1
- package/functions/pre-transaction/getSolanaCalldataHash.mjs +21 -21
- package/functions/pre-transaction/getVolatileTransferAmount.cjs +1 -1
- package/functions/pre-transaction/getVolatileTransferAmount.mjs +2 -3
- package/functions/pre-transaction/interaction-to-action.cjs +1 -1
- package/functions/pre-transaction/interaction-to-action.mjs +2 -3
- package/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.helpers.d.ts +6 -7
- package/functions/private-wallet/emporium.helpers.mjs +104 -105
- package/functions/private-wallet/emporium.swap.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.swap.helpers.mjs +44 -43
- package/functions/private-wallet/opProducer.cjs +1 -1
- package/functions/private-wallet/opProducer.mjs +1 -1
- package/functions/snarkjs/common.snarkjs.cjs +1 -1
- package/functions/snarkjs/common.snarkjs.mjs +21 -18
- package/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/functions/snarkjs/constructSolanaZkProof.mjs +11 -12
- package/functions/utils/addresses.cjs +1 -1
- package/functions/utils/addresses.mjs +6 -6
- package/functions/utils/cacheFunctions.cjs +1 -1
- package/functions/utils/cacheFunctions.d.ts +1 -1
- package/functions/utils/cacheFunctions.mjs +55 -54
- package/functions/utils/convertEmporiumOpToCallInfo.cjs +1 -1
- package/functions/utils/convertEmporiumOpToCallInfo.mjs +5 -5
- package/functions/utils/create-provider.cjs +1 -1
- package/functions/utils/create-provider.d.ts +2 -2
- package/functions/utils/create-provider.mjs +5 -5
- package/functions/utils/encryptInputForEnclave.cjs +1 -1
- package/functions/utils/encryptInputForEnclave.mjs +9 -9
- package/functions/utils/ethers-formatter.utils.d.ts +1 -1
- package/functions/utils/external-action.utils.cjs +1 -1
- package/functions/utils/external-action.utils.mjs +2 -2
- package/functions/utils/getContractAddress.cjs +1 -0
- package/functions/utils/getContractAddress.d.ts +2 -0
- package/functions/utils/getContractAddress.mjs +9 -0
- package/functions/utils/getDataFromTransaction.cjs +1 -1
- package/functions/utils/getDataFromTransaction.d.ts +0 -11
- package/functions/utils/getDataFromTransaction.mjs +26 -50
- package/functions/utils/getRecipientInfoFromUserKeys.cjs +1 -1
- package/functions/utils/getRecipientInfoFromUserKeys.mjs +1 -1
- package/functions/utils/getSignerFromContract.cjs +1 -0
- package/functions/utils/getSignerFromContract.d.ts +3 -0
- package/functions/utils/getSignerFromContract.mjs +16 -0
- package/functions/utils/getUtxosFromReceipt.utils.cjs +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.d.ts +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.mjs +15 -16
- package/functions/utils/inLogicMetadata.cjs +1 -1
- package/functions/utils/inLogicMetadata.mjs +2 -2
- package/functions/utils/nftTokenFunctions.cjs +1 -1
- package/functions/utils/nftTokenFunctions.mjs +2 -3
- package/functions/utils/publicBalance.utils.cjs +1 -1
- package/functions/utils/publicBalance.utils.d.ts +1 -1
- package/functions/utils/publicBalance.utils.mjs +42 -42
- package/functions/utils/rpc-int-encode.cjs +1 -1
- package/functions/utils/rpc-int-encode.d.ts +1 -2
- package/functions/utils/rpc-int-encode.mjs +3 -6
- package/functions/utils/solanaMint.utils.cjs +1 -1
- package/functions/utils/solanaMint.utils.mjs +6 -6
- package/functions/web3/EIP-712.cjs +1 -1
- package/functions/web3/EIP-712.d.ts +4 -4
- package/functions/web3/EIP-712.mjs +1 -1
- package/functions/web3/etherFunctions.cjs +1 -1
- package/functions/web3/etherFunctions.mjs +32 -29
- package/functions/web3/events/balanceChangedCustomHandler.cjs +1 -1
- package/functions/web3/events/balanceChangedCustomHandler.mjs +4 -5
- package/functions/web3/events/balanceChangedHandler.cjs +1 -1
- package/functions/web3/events/balanceChangedHandler.mjs +2 -3
- package/functions/web3/events/getApprovedBalance.cjs +1 -1
- package/functions/web3/events/getApprovedBalance.mjs +1 -1
- package/functions/web3/events/getInputUtxosEnclave.cjs +1 -1
- package/functions/web3/events/getInputUtxosEnclave.mjs +20 -20
- package/functions/web3/events/getTransactionLogEvents.cjs +1 -1
- package/functions/web3/events/getTransactionLogEvents.d.ts +3 -3
- package/functions/web3/events/getTransactionLogEvents.mjs +6 -5
- package/functions/web3/events/index.d.ts +0 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.d.ts +1 -2
- package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +4 -5
- package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
- package/functions/web3/functionCalls/accessTokenCalls.mjs +10 -11
- package/functions/web3/functionCalls/approveToken.cjs +1 -1
- package/functions/web3/functionCalls/approveToken.mjs +61 -58
- package/functions/web3/functionCalls/constructBatchCall.cjs +1 -1
- package/functions/web3/functionCalls/constructBatchCall.d.ts +2 -2
- package/functions/web3/functionCalls/constructBatchCall.mjs +10 -9
- package/functions/web3/functionCalls/estimateGasRelayer.cjs +1 -1
- package/functions/web3/functionCalls/estimateGasRelayer.mjs +1 -1
- package/functions/web3/functionCalls/inHinkalApprovalCalls.cjs +1 -1
- package/functions/web3/functionCalls/inHinkalApprovalCalls.mjs +18 -21
- package/functions/web3/functionCalls/recoverTransactionFromError.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +38 -34
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.mjs +8 -10
- package/functions/web3/getContractMetadata.cjs +1 -1
- package/functions/web3/getContractMetadata.d.ts +1 -1
- package/functions/web3/getContractMetadata.mjs +25 -25
- package/functions/web3/getPublicAddressBalance.cjs +1 -1
- package/functions/web3/getPublicAddressBalance.mjs +7 -6
- package/functions/web3/getTokenHolder.cjs +1 -1
- package/functions/web3/getTokenHolder.mjs +16 -15
- package/functions/web3/odosAPI.cjs +1 -1
- package/functions/web3/odosAPI.mjs +6 -7
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.mjs +2 -3
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.d.ts +6 -5
- package/functions/web3/runContractFunction.mjs +41 -45
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.d.ts +2 -2
- package/functions/web3/uniswapAPI.mjs +23 -24
- package/index.cjs +1 -1
- package/index.mjs +336 -340
- package/package.json +3 -4
- package/providers/CustomEthersProvider.d.ts +1 -1
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.d.ts +7 -7
- package/providers/EthersProviderAdapter.mjs +46 -44
- package/providers/SolanaProviderAdapter.d.ts +1 -1
- package/providers/WagmiProviderAdapter.cjs +1 -1
- package/providers/WagmiProviderAdapter.d.ts +5 -5
- package/providers/WagmiProviderAdapter.mjs +37 -33
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.d.ts +2 -2
- package/providers/prepareEthersHinkal.mjs +3 -5
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +3 -5
- package/types/activities.types.d.ts +2 -3
- package/types/big-intable.types.d.ts +3 -2
- package/types/ethereum-network.types.d.ts +10 -10
- package/types/transactions.types.cjs +1 -1
- package/types/transactions.types.d.ts +2 -3
- package/types/transactions.types.mjs +6 -7
- package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLogic.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLogic.mjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
- package/functions/web3/events/web3RetrieveEvents.cjs +0 -1
- package/functions/web3/events/web3RetrieveEvents.d.ts +0 -14
- package/functions/web3/events/web3RetrieveEvents.mjs +0 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../types/hinkal.types.cjs"),S=require("../../types/ethereum-network.types.cjs"),x=require("./hinkalCheckSolanaTokenRegistry.cjs"),m=require("../../functions/web3/functionCalls/accessTokenCalls.cjs"),W=require("../../functions/web3/events/getShieldedBalance.cjs"),A=require("../crypto-keys/keys.cjs"),I=require("./hinkalDeposit.cjs"),B=require("./hinkalDepositAndWithdraw.cjs"),w=require("./hinkalSolanaDeposit.cjs"),K=require("./hinkalSwap.cjs"),U=require("./hinkalWithdraw.cjs"),L=require("./hinkalWithdrawStuckUtxos.cjs"),N=require("./resetMerkleTrees.cjs"),M=require("../merkle-tree/MerkleTree.cjs");require("ethers");const R=require("../../error-handling/error-codes.constants.cjs"),F=require("../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const h=require("../../constants/chains.constants.cjs");require("../../API/getServerURL.cjs");require("axios");require("../../constants/coingecko.constants.cjs");require("../../constants/server.constants.cjs");require("../http/HttpClient.cjs");const _=require("../../constants/vite.constants.cjs"),P=require("../../API/API.cjs");require("../../constants/token-data/index.cjs");require("../../constants/contracts.constants.cjs");const O=require("../../constants/kyc.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");require("../../API/tenderly.api.cjs");const j=require("../../functions/utils/reloadPage.cjs"),z=require("../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs"),$=require("./hinkalPrivateWallet.cjs"),J=require("../../functions/utils/cacheFunctions.cjs"),Q=require("../../functions/utils/cacheDevice.utils.cjs"),V=require("../../functions/web3/getContractMetadata.cjs"),X=require("./hinkalGetRecipientInfo.cjs"),Y=require("./hinkalApprove.cjs"),Z=require("./hinkalInsideTransact.cjs"),v=require("../../functions/web3/events/getApprovedBalance.cjs"),C=require("../../functions/web3/functionCalls/inHinkalApprovalCalls.cjs"),G=require("./hinkalSignSubAccount.cjs"),ee=require("./hinkalCheckTokenRegistry.cjs"),te=require("./hinkalActionReceive.cjs"),re=require("./hinkalActionFundApproveAndTransact.cjs"),ie=require("../TokenDBs/PrivateTokensDB.cjs");require("idb-keyval");const ae=require("../../functions/utils/erc20tokenFunctions.cjs");require("multiformats");const g=require("@solana/web3.js");require("@solana/spl-token");require("async-mutex");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");const E=require("../../functions/pre-transaction/solana.cjs");require("@coral-xyz/anchor");require("../../functions/utils/userAgent.cjs");require("../../functions/utils/mutexes.utils.cjs");require("node-forge");require("../../functions/web3/getTokenHolder.cjs");const ne=require("../../functions/private-wallet/emporium.helpers.cjs"),se=require("./hinkalProoflessDeposit.cjs"),oe=require("./hinkalProxySwap.cjs"),ce=require("./hinkalMultiSend.cjs"),he=require("./hinkalTransfer.cjs"),le=require("./hinkalProxyToPrivate.cjs"),de=require("./hinkalSolanaDepositAndWithdraw.cjs"),pe=require("./hinkalSolanaWithdraw.cjs"),ue=require("./hinkalSolanaTransfer.cjs"),ge=require("./hinkalSolanaSwap.cjs"),ke=require("./hinkalSolanaProxySend.cjs"),ve=require("./hinkalSolanaProxySwap.cjs"),D=require("./hinkalSolanaProxyShield.cjs"),H=require("../../functions/web3/fetchSolanaMerkleTreeRootHash.cjs"),ye=require("./hinkalDepostAndBridge.cjs");class Se{providerAdapter;userKeys;signingMessage="Login to Hinkal Protocol";privateTransferSigningMessage="Login to Hinkal's Private Transfer App";merkleTreeHinkal;merkleTreeAccessToken;nullifiers;encryptedOutputs;approvals;commitmentsSnapshotService;nullifierSnapshotService;accessTokenSnapshotService;approvalsSnapshotService;utxoUtils;cacheDevice;generateProofRemotely;disableMerkleTreeUpdates;constructor(e){this.userKeys=new A.UserKeys(void 0),this.merkleTreeHinkal=M.MerkleTree.create(F.poseidonFunction,0n),this.merkleTreeAccessToken=M.MerkleTree.create(F.poseidonFunction,0n),this.nullifiers=new Set,this.encryptedOutputs=[],this.approvals=new Map,this.generateProofRemotely=e?.generateProofRemotely??!1,this.utxoUtils=new z.MultiThreadedUtxoUtils,this.cacheDevice=Q.createCacheDevice(e),this.disableMerkleTreeUpdates=e?.disableMerkleTreeUpdates??!1}async initProviderAdapter(e,t){await this.updateProviderAdapter(t),this.providerAdapter?.initConnector(e);const r=await this.connectAndPatchProvider(e);await t.init(r),await this.setListeners()}async initUserKeys(e=!1){const t=e?this.privateTransferSigningMessage:this.signingMessage;this.userKeys=new A.UserKeys(await this.getProviderAdapter().signMessage(t))}async initUserKeysWithPassword(e){this.userKeys=new A.UserKeys(e)}async resetMerkle(){this.disableMerkleTreeUpdates||this.isSelectedNetworkSupported()&&await N.resetMerkleTrees(this)}getProviderAdapter(){if(!this.providerAdapter)throw new Error("ProviderAdapter is not initialized");return this.providerAdapter}async waitForTransaction(e,t=1){return!!await this.providerAdapter?.waitForTransaction(e,t)}getContractMetadata(e,t){return this.getProviderAdapter().getContractMetadata(e,t)}getContract(e,t=void 0,r){return this.getProviderAdapter().getContract(e,t,r)}getContractWithFetcherByChainId(e,t,r=void 0){return V.getContractWithFetcherByChainId(e,t,r)}async signMessage(e){return await this.getProviderAdapter().signMessage(e)}async signTypedData(e,t,r){return await this.getProviderAdapter().signTypedData(e,t,r)}async signWithSubAccount(e,t,r){return G.hinkalSignSubAccount(this,e,t,r)}getContractWithSigner(e,t=""){return this.getProviderAdapter().getContractWithSigner(e,t)}getContractWithFetcher(e,t=""){return this.getProviderAdapter().getContractWithFetcher(e,t)}getContractWithFetcherForEthereum(e,t){return this.getProviderAdapter().getContractWithFetcherForEthereum(e,t)}isSelectedNetworkSupported(){return!!h.networkRegistry[this.getCurrentChainId()]}async switchNetwork(e){try{await this.getProviderAdapter().switchNetwork(e)}catch{throw new Error(R.transactionErrorCodes.FAILED_TO_SWITCH_NETWORKS)}}async switchAccount(e){await this.getProviderAdapter().switchAccount(e)}getCurrentChainId(){const{chainId:e}=this.getProviderAdapter();if(!e)throw new Error("Illegal State: no chainId");return e}getSelectedNetwork(){return this.providerAdapter?.getSelectedNetwork()}isPermitterAvailable(){return this.getProviderAdapter().isPermitterAvailable()}async connectAndPatchProvider(e){return await this.getProviderAdapter().connectAndPatchProvider(e)}async disconnectFromConnector(){await this.getProviderAdapter().disconnectFromConnector()}async updateProviderAdapter(e){try{this.providerAdapter&&this.providerAdapter.release(),this.providerAdapter=e}catch(t){throw console.error(t),Error("updateProviderAdapter failed, please try again.")}}async setListeners(){this.providerAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}})}async onAccountChanged(){await this.getProviderAdapter().onAccountChanged();const e=T.EventType.AccountChanged;typeof document<"u"?document?.dispatchEvent(new Event(e)):process?.emit("message",e,void 0)}async onChainChanged(e){if(e){await this.getProviderAdapter().onChainChanged(e);const t=T.EventType.NetworkChange;typeof document<"u"?document.dispatchEvent(new Event(t)):process?.emit("message",t,void 0)}else await this.disconnectFromConnector(),j.reloadPage()}async monitorConnectedAddress(){const e=this.getCurrentChainId();h.isSolanaLike(e)||await P.API.monitor(await this.getEthereumAddress(),e)}async getBalances(e,t,r,i,a=!1,n,s=!1){return W.getShieldedBalance(this,e,t,r,i,a,this.generateProofRemotely,n,s)}async getApprovedBalances(e=!1,t=!1){return v.getApprovedBalance(this,e,t)}async getTotalBalance(e,t,r,i=!1,a,n=!1){const s=e??this.getCurrentChainId(),o=r??await this.getEthereumAddress(),c=t??this.userKeys,l=await this.getBalances(s,c.getShieldedPrivateKey(),c.getShieldedPublicKey(),o,i,a,n),p=!h.isSolanaLike(s)&&!n?await this.getApprovedBalances(i,a):new Map,d=_.isExtension?await ie.privateTokensDB.getPrivateTokens(s,o):ae.getErc20TokensForChain(s),u=[];return d.forEach(k=>{const f=k.erc20TokenAddress.toLowerCase(),y=l.get(f),q=p.get(f),b={token:k,balance:(y?.balance??0n)+(q?.balance??0n),timestamp:y?.timestamp||q?.timestamp||"0",nfts:y?.nfts||[]};u.push(b)}),u}async getStuckShieldedBalances(e,t,r){return(await this.getTotalBalance(e,t,r,!1,!1,!0)).filter(a=>a.balance>0n)}getSupportedPassportLinks(){return O.supportedPassportLinks}checkAccessToken(){return m.checkHinkalAccessToken(this)}async mintHinkalAccessToken(e,t){return m.mintAccessToken(this,e,t)}async getHinkalTreeRootHash(){const e=this.getCurrentChainId();if(h.isSolanaLike(e)){const{hinkalIdl:r,hinkalAddress:i,originalDeployer:a}=h.networkRegistry[e].contractData;if(!r||!i||!a)throw new Error(`Missing Solana configuration for chain ${e}`);const n=new g.PublicKey(a),s=new g.PublicKey(i),o=E.getMerkleAccountPublicKey(s,n),c=this.getSolanaProgram(r);return H.fetchSolanaMerkleTreeRootHash(c,o)}return this.getContractWithFetcher(S.ContractType.HinkalContract).getRootHash()}async getAccessTokenTreeRootHash(){const e=this.getCurrentChainId();if(h.isSolanaLike(e)){const{hinkalIdl:r,hinkalAddress:i,originalDeployer:a}=h.networkRegistry[e].contractData;if(!r||!i||!a)throw new Error(`Missing Solana configuration for chain ${e}`);const n=new g.PublicKey(a),s=new g.PublicKey(i),o=E.getAccessTokenMerkleAccountPublicKey(s,n),c=this.getSolanaProgram(r);return H.fetchSolanaMerkleTreeRootHash(c,o)}return this.getContractWithFetcher(S.ContractType.AccessTokenContract).getRootHash()}async resetMerkleTreesIfNecessary(){if(!this.isSelectedNetworkSupported())throw new Error(R.transactionErrorCodes.UNSUPPORTED_NETWORK);const[e,t]=await Promise.all([this.getHinkalTreeRootHash(),this.getAccessTokenTreeRootHash()]);(e.toBigInt()!==this.merkleTreeHinkal.getRootHash()||t.toBigInt()!==this.merkleTreeAccessToken.getRootHash())&&(console.log("resetting merkle tree in resetMerkleTreesIfNecessary"),await this.resetMerkle())}async getEventsFromHinkal(){await Promise.all([this.accessTokenSnapshotService?.retrieveEventsFromLatestBlock(),this.commitmentsSnapshotService?.retrieveEventsFromLatestBlock(),this.nullifierSnapshotService?.retrieveEventsFromLatestBlock(),this.approvalsSnapshotService?.retrieveEventsFromLatestBlock()])}getEthereumAddress(){return this.getProviderAdapter().getAddress()}async getRandomRelay(e=!1){const t=this.getCurrentChainId();return(await P.API.getIdleRelay(t,e)).relay}getGasPrice(){if(!this.providerAdapter?.chainId)throw new Error("Illegal State of providerAdapter in Hinkal: no chainId");return this.providerAdapter.getGasPrice()}getAPI(){return P.API}resetCache(){J.resetCache(this,this.getCurrentChainId(),this.userKeys.getShieldedPublicKey())}snapshotsClearInterval(){this.commitmentsSnapshotService?.intervalClear(),this.accessTokenSnapshotService?.intervalClear(),this.nullifierSnapshotService?.intervalClear(),this.approvalsSnapshotService?.intervalClear()}checkTokenRegistry(e,t){const r=this.getCurrentChainId();if(h.isSolanaLike(r)){const{hinkalIdl:a,hinkalAddress:n,originalDeployer:s}=h.networkRegistry[r].contractData;if(!a||!n||!s)throw new Error("missing solana data");const o=this.getSolanaProgram(a),c=new g.PublicKey(s);return x.hinkalCheckSolanaTokenRegistry(o,c,e,t)}const i=this.getContractWithFetcher(S.ContractType.HinkalHelperContract);return ee.hinkalCheckTokenRegistry(i,e,t)}getRecipientInfo(){return X.getRecipientInfo(this)}async getInteractionApprovals(e){return await C.getInteractionApprovals(this,e)}getApprovedUtxos(e=!1){return v.getApprovedUtxos(this,e)}getApprovedUtxosForToken(e,t=!1){return v.getApprovedUtxosForToken(this,e,t)}getMyApprovalAmountForInteraction(e,t){return v.getMyApprovalAmountForInteraction(this,e,t)}async checkExistingApprovalFromHinkal(e,t){return await C.checkExistingApprovalFromHinkal(this,e,t)}async getBufferEntry(e,t,r){return C.getBufferEntry(this,e,t,r)}async deposit(e,t){return I.hinkalDeposit(this,e,t)}async depositForOther(e,t,r){return I.hinkalDepositForOther(this,e,t,r)}async depositAndWithdraw(e,t,r,i,a,n){return h.isSolanaLike(this.getCurrentChainId())?de.hinkalSolanaDepositAndWithdraw(this,e.erc20TokenAddress,t,r,i,a,n):B.hinkalDepositAndWithdraw(this,e,t,r,i,a,n)}async depositAndBridge(e,t,r,i,a){return ye.hinkalDepositAndBridge(this,e,t,r,i,a)}async prooflessDeposit(e,t,r){return se.hinkalProoflessDeposit(this,e,t,r)}getSolanaProgram(e){if(!this.providerAdapter)throw new Error("No provider adapter initialized");if(!("getSolanaProgram"in this.providerAdapter))throw new Error("Current provider adapter is not a Solana provider adapter");return this.providerAdapter.getSolanaProgram(e)}getSolanaPublicKey(){if(!this.providerAdapter)throw new Error("No provider adapter initialized");if(!("getSolanaPublicKey"in this.providerAdapter))throw new Error("Current provider adapter is not a Solana provider adapter");return this.providerAdapter.getSolanaPublicKey()}async depositSolana(e,t){return w.hinkalSolanaDeposit(this,e,t)}async depositSolanaForOther(e,t,r){return w.hinkalSolanaDepositForOther(this,e,t,r)}async solanaMultiPaymentDeposit(e,t){return w.hinkalSolanaMultiPaymentDeposit(this,e,t)}async transfer(e,t,r,i,a,n,s=!1){return h.isSolanaLike(this.getCurrentChainId())?ue.hinkalSolanaTransfer(this,e,t,r,i,a,s):he.hinkalTransfer(this,e,t,r,i,a,n,s)}async withdraw(e,t,r,i,a,n,s,o=!1){return h.isSolanaLike(this.getCurrentChainId())?pe.hinkalSolanaWithdraw(this,e.map(c=>c.erc20TokenAddress),t,r,a,n,o):U.hinkalWithdraw(this,e,t,r,i,a,n,s,o)}async withdrawStuckUtxos(e,t){return L.hinkalWithdrawStuckUtxos(this,e,t)}async swap(e,t,r,i,a,n,s,o=!1,c=!1){return h.isSolanaLike(this.getCurrentChainId())?this.swapSolana(e,t,i,a,n,o):K.hinkalSwap(this,e,t,r,i,a,n,s,o,c)}async swapSolana(e,t,r,i,a,n=!1){const s=JSON.parse(r),o=BigInt(s.swapperAccountSalt),{instructionLists:c,addressLookupTableAccount:l}=s.data;return ge.hinkalSolanaSwap(this,e,t,o,c,l,i,a,n)}async actionReceive(e,t,r,i,a,n,s=!1){if(!a)throw new Error("subAccount is required");return h.isSolanaLike(this.getCurrentChainId())?D.hinkalSolanaProxyShield(this,e[0],t[0],a,void 0,s):te.hinkalActionReceive(this,e,t,r,i,a,n,s)}async actionFundApproveAndTransact(e,t,r,i,a,n,s,o,c=!1,l,p,d){return re.hinkalActionFundApproveAndTransact(this,e,t,r,i,a,n,s,o,c,l,p,d)}async actionPrivateWallet(e,t,r,i,a,n,s,o,c,l=!1,p,d,u,k=!1){return $.hinkalPrivateWallet(this,e,t,r,i,a,n,s,o,c,l,p,d,u,k)}async approve(e,t,r,i,a,n=!1){return Y.hinkalApprove(this,e,t,r,i,a,n)}async hinkalInsideTransact(e,t,r,i,a,n,s,o,c,l=!1){return Z.hinkalInsideTransact(this,e,t,r,i,a,n,s,o,c,l)}async proxySwap(e,t,r,i,a,n,s,o,c=!1,l,p,d=!1){return h.isSolanaLike(this.getCurrentChainId())?ve.hinkalSolanaProxySwap(this,e,t,i,n,s,o,d):oe.hinkalProxySwap(this,e,t,r,i,a,n,s,o,c,l,p,d)}async proxyToPrivate(e,t,r,i,a,n,s,o=!1){return h.isSolanaLike(this.getCurrentChainId())?D.hinkalSolanaProxyShield(this,e[0],t[0],r,i,o):le.hinkalProxyToPrivate(this,e,t,i,a,n,r,s,o)}async proxySend(e,t,r,i,a,n,s,o=!1){if(h.isSolanaLike(this.getCurrentChainId()))return ke.hinkalSolanaProxySend(this,e[0],t[0],r,i,o);const c=ne.createTransaferEmporiumOpsBatch(this,e.map(d=>d.erc20TokenAddress),t,i),l=e.map((d,u)=>({token:d,amount:-1n*t[u]}));return await this.actionPrivateWallet([],[],[],c,l,r,a,n,void 0,void 0,void 0,s,void 0,o)}async multiSendPrivateRecipients(e,t,r){return ce.hinkalMultiSendPrivateRecipients(this,e,t,r)}areMerkleTreeUpdatesDisabled(){return this.disableMerkleTreeUpdates}updateMerkleTreeUpdates(e){this.disableMerkleTreeUpdates=e}}exports.Hinkal=Se;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../types/hinkal.types.cjs"),S=require("../../types/ethereum-network.types.cjs"),x=require("./hinkalCheckSolanaTokenRegistry.cjs"),m=require("../../functions/web3/functionCalls/accessTokenCalls.cjs"),W=require("../../functions/web3/events/getShieldedBalance.cjs"),A=require("../crypto-keys/keys.cjs"),I=require("./hinkalDeposit.cjs"),B=require("./hinkalDepositAndWithdraw.cjs"),w=require("./hinkalSolanaDeposit.cjs"),K=require("./hinkalSwap.cjs"),U=require("./hinkalWithdraw.cjs"),L=require("./hinkalWithdrawStuckUtxos.cjs"),N=require("./resetMerkleTrees.cjs"),M=require("../merkle-tree/MerkleTree.cjs");require("ethers");const R=require("../../error-handling/error-codes.constants.cjs"),F=require("../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const h=require("../../constants/chains.constants.cjs");require("../../API/getServerURL.cjs");require("axios");require("../../constants/coingecko.constants.cjs");require("../../constants/server.constants.cjs");require("../http/HttpClient.cjs");const _=require("../../constants/vite.constants.cjs"),P=require("../../API/API.cjs");require("../../constants/token-data/index.cjs");require("../../constants/contracts.constants.cjs");const O=require("../../constants/kyc.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");require("../../API/tenderly.api.cjs");const j=require("../../functions/utils/reloadPage.cjs"),z=require("../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs"),$=require("./hinkalPrivateWallet.cjs"),J=require("../../functions/utils/cacheFunctions.cjs"),Q=require("../../functions/utils/cacheDevice.utils.cjs"),V=require("../../functions/web3/getContractMetadata.cjs"),X=require("./hinkalGetRecipientInfo.cjs"),Y=require("./hinkalApprove.cjs"),Z=require("./hinkalInsideTransact.cjs"),v=require("../../functions/web3/events/getApprovedBalance.cjs"),C=require("../../functions/web3/functionCalls/inHinkalApprovalCalls.cjs"),G=require("./hinkalSignSubAccount.cjs"),ee=require("./hinkalCheckTokenRegistry.cjs"),te=require("./hinkalActionReceive.cjs"),re=require("./hinkalActionFundApproveAndTransact.cjs"),ie=require("../TokenDBs/PrivateTokensDB.cjs");require("idb-keyval");const ne=require("../../functions/utils/erc20tokenFunctions.cjs");require("multiformats");const g=require("@solana/web3.js");require("@solana/spl-token");require("async-mutex");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../../types/circom-data.types.cjs");require("../../types/activities.types.cjs");const E=require("../../functions/pre-transaction/solana.cjs");require("@coral-xyz/anchor");require("../../functions/utils/userAgent.cjs");require("../../functions/utils/mutexes.utils.cjs");require("node-forge");require("../../functions/web3/getTokenHolder.cjs");const ae=require("../../functions/private-wallet/emporium.helpers.cjs"),se=require("./hinkalProoflessDeposit.cjs"),oe=require("./hinkalProxySwap.cjs"),ce=require("./hinkalMultiSend.cjs"),he=require("./hinkalTransfer.cjs"),le=require("./hinkalProxyToPrivate.cjs"),de=require("./hinkalSolanaDepositAndWithdraw.cjs"),pe=require("./hinkalSolanaWithdraw.cjs"),ue=require("./hinkalSolanaTransfer.cjs"),ge=require("./hinkalSolanaSwap.cjs"),ke=require("./hinkalSolanaProxySend.cjs"),ve=require("./hinkalSolanaProxySwap.cjs"),D=require("./hinkalSolanaProxyShield.cjs"),H=require("../../functions/web3/fetchSolanaMerkleTreeRootHash.cjs"),ye=require("./hinkalDepostAndBridge.cjs");class Se{providerAdapter;userKeys;signingMessage="Login to Hinkal Protocol";privateTransferSigningMessage="Login to Hinkal's Private Transfer App";merkleTreeHinkal;merkleTreeAccessToken;nullifiers;encryptedOutputs;approvals;commitmentsSnapshotService;nullifierSnapshotService;accessTokenSnapshotService;approvalsSnapshotService;utxoUtils;cacheDevice;generateProofRemotely;disableMerkleTreeUpdates;constructor(e){this.userKeys=new A.UserKeys(void 0),this.merkleTreeHinkal=M.MerkleTree.create(F.poseidonFunction,0n),this.merkleTreeAccessToken=M.MerkleTree.create(F.poseidonFunction,0n),this.nullifiers=new Set,this.encryptedOutputs=[],this.approvals=new Map,this.generateProofRemotely=e?.generateProofRemotely??!0,this.utxoUtils=new z.MultiThreadedUtxoUtils,this.cacheDevice=Q.createCacheDevice(e),this.disableMerkleTreeUpdates=e?.disableMerkleTreeUpdates??!1}async initProviderAdapter(e,t){await this.updateProviderAdapter(t),this.providerAdapter?.initConnector(e);const r=await this.connectAndPatchProvider(e);await t.init(r),await this.setListeners()}async initUserKeys(e=!1){const t=e?this.privateTransferSigningMessage:this.signingMessage;this.userKeys=new A.UserKeys(await this.getProviderAdapter().signMessage(t))}async initUserKeysWithPassword(e){this.userKeys=new A.UserKeys(e)}async resetMerkle(){this.disableMerkleTreeUpdates||this.isSelectedNetworkSupported()&&await N.resetMerkleTrees(this)}getProviderAdapter(){if(!this.providerAdapter)throw new Error("ProviderAdapter is not initialized");return this.providerAdapter}async waitForTransaction(e,t=1){return!!await this.providerAdapter?.waitForTransaction(e,t)}getContractMetadata(e,t){return this.getProviderAdapter().getContractMetadata(e,t)}getContract(e,t=void 0,r){return this.getProviderAdapter().getContract(e,t,r)}getContractWithFetcherByChainId(e,t,r=void 0){return V.getContractWithFetcherByChainId(e,t,r)}async signMessage(e){return await this.getProviderAdapter().signMessage(e)}async signTypedData(e,t,r){return await this.getProviderAdapter().signTypedData(e,t,r)}async signWithSubAccount(e,t,r){return G.hinkalSignSubAccount(this,e,t,r)}getContractWithSigner(e,t=""){return this.getProviderAdapter().getContractWithSigner(e,t)}getContractWithFetcher(e,t=""){return this.getProviderAdapter().getContractWithFetcher(e,t)}getContractWithFetcherForEthereum(e,t){return this.getProviderAdapter().getContractWithFetcherForEthereum(e,t)}isSelectedNetworkSupported(){return!!h.networkRegistry[this.getCurrentChainId()]}async switchNetwork(e){try{await this.getProviderAdapter().switchNetwork(e)}catch{throw new Error(R.transactionErrorCodes.FAILED_TO_SWITCH_NETWORKS)}}async switchAccount(e){await this.getProviderAdapter().switchAccount(e)}getCurrentChainId(){const{chainId:e}=this.getProviderAdapter();if(!e)throw new Error("Illegal State: no chainId");return e}getSelectedNetwork(){return this.providerAdapter?.getSelectedNetwork()}isPermitterAvailable(){return this.getProviderAdapter().isPermitterAvailable()}async connectAndPatchProvider(e){return await this.getProviderAdapter().connectAndPatchProvider(e)}async disconnectFromConnector(){await this.getProviderAdapter().disconnectFromConnector()}async updateProviderAdapter(e){try{this.providerAdapter&&this.providerAdapter.release(),this.providerAdapter=e}catch(t){throw console.error(t),Error("updateProviderAdapter failed, please try again.")}}async setListeners(){this.providerAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}})}async onAccountChanged(){await this.getProviderAdapter().onAccountChanged();const e=T.EventType.AccountChanged;typeof document<"u"?document?.dispatchEvent(new Event(e)):process?.emit("message",e,void 0)}async onChainChanged(e){if(e){await this.getProviderAdapter().onChainChanged(e);const t=T.EventType.NetworkChange;typeof document<"u"?document.dispatchEvent(new Event(t)):process?.emit("message",t,void 0)}else await this.disconnectFromConnector(),j.reloadPage()}async monitorConnectedAddress(){const e=this.getCurrentChainId();h.isSolanaLike(e)||await P.API.monitor(await this.getEthereumAddress(),e)}async getBalances(e,t,r,i,n=!1,a,s=!1){return W.getShieldedBalance(this,e,t,r,i,n,this.generateProofRemotely,a,s)}async getApprovedBalances(e=!1,t=!1){return v.getApprovedBalance(this,e,t)}async getTotalBalance(e,t,r,i=!1,n,a=!1){const s=e??this.getCurrentChainId(),o=r??await this.getEthereumAddress(),c=t??this.userKeys,l=await this.getBalances(s,c.getShieldedPrivateKey(),c.getShieldedPublicKey(),o,i,n,a),p=!h.isSolanaLike(s)&&!a?await this.getApprovedBalances(i,n):new Map,d=_.isExtension?await ie.privateTokensDB.getPrivateTokens(s,o):ne.getErc20TokensForChain(s),u=[];return d.forEach(k=>{const f=k.erc20TokenAddress.toLowerCase(),y=l.get(f),q=p.get(f),b={token:k,balance:(y?.balance??0n)+(q?.balance??0n),timestamp:y?.timestamp||q?.timestamp||"0",nfts:y?.nfts||[]};u.push(b)}),u}async getStuckShieldedBalances(e,t,r){return(await this.getTotalBalance(e,t,r,!1,!1,!0)).filter(n=>n.balance>0n)}getSupportedPassportLinks(){return O.supportedPassportLinks}checkAccessToken(){return m.checkHinkalAccessToken(this)}async mintHinkalAccessToken(e,t){return m.mintAccessToken(this,e,t)}async getHinkalTreeRootHash(){const e=this.getCurrentChainId();if(h.isSolanaLike(e)){const{hinkalIdl:r,hinkalAddress:i,originalDeployer:n}=h.networkRegistry[e].contractData;if(!r||!i||!n)throw new Error(`Missing Solana configuration for chain ${e}`);const a=new g.PublicKey(n),s=new g.PublicKey(i),o=E.getMerkleAccountPublicKey(s,a),c=this.getSolanaProgram(r);return H.fetchSolanaMerkleTreeRootHash(c,o)}return this.getContractWithFetcher(S.ContractType.HinkalContract).getRootHash()}async getAccessTokenTreeRootHash(){const e=this.getCurrentChainId();if(h.isSolanaLike(e)){const{hinkalIdl:r,hinkalAddress:i,originalDeployer:n}=h.networkRegistry[e].contractData;if(!r||!i||!n)throw new Error(`Missing Solana configuration for chain ${e}`);const a=new g.PublicKey(n),s=new g.PublicKey(i),o=E.getAccessTokenMerkleAccountPublicKey(s,a),c=this.getSolanaProgram(r);return H.fetchSolanaMerkleTreeRootHash(c,o)}return this.getContractWithFetcher(S.ContractType.AccessTokenContract).getRootHash()}async resetMerkleTreesIfNecessary(){if(!this.isSelectedNetworkSupported())throw new Error(R.transactionErrorCodes.UNSUPPORTED_NETWORK);const[e,t]=await Promise.all([this.getHinkalTreeRootHash(),this.getAccessTokenTreeRootHash()]);(BigInt(e)!==this.merkleTreeHinkal.getRootHash()||BigInt(t)!==this.merkleTreeAccessToken.getRootHash())&&(console.log("resetting merkle tree in resetMerkleTreesIfNecessary"),await this.resetMerkle())}async getEventsFromHinkal(){await Promise.all([this.accessTokenSnapshotService?.retrieveEventsFromLatestBlock(),this.commitmentsSnapshotService?.retrieveEventsFromLatestBlock(),this.nullifierSnapshotService?.retrieveEventsFromLatestBlock(),this.approvalsSnapshotService?.retrieveEventsFromLatestBlock()])}getEthereumAddress(){return this.getProviderAdapter().getAddress()}async getRandomRelay(e=!1){const t=this.getCurrentChainId();return(await P.API.getIdleRelay(t,e)).relay}getGasPrice(){if(!this.providerAdapter?.chainId)throw new Error("Illegal State of providerAdapter in Hinkal: no chainId");return this.providerAdapter.getGasPrice()}getAPI(){return P.API}resetCache(){J.resetCache(this,this.getCurrentChainId(),this.userKeys.getShieldedPublicKey())}snapshotsClearInterval(){this.commitmentsSnapshotService?.intervalClear(),this.accessTokenSnapshotService?.intervalClear(),this.nullifierSnapshotService?.intervalClear(),this.approvalsSnapshotService?.intervalClear()}checkTokenRegistry(e,t){const r=this.getCurrentChainId();if(h.isSolanaLike(r)){const{hinkalIdl:n,hinkalAddress:a,originalDeployer:s}=h.networkRegistry[r].contractData;if(!n||!a||!s)throw new Error("missing solana data");const o=this.getSolanaProgram(n),c=new g.PublicKey(s);return x.hinkalCheckSolanaTokenRegistry(o,c,e,t)}const i=this.getContractWithFetcher(S.ContractType.HinkalHelperContract);return ee.hinkalCheckTokenRegistry(i,e,t)}getRecipientInfo(){return X.getRecipientInfo(this)}async getInteractionApprovals(e){return await C.getInteractionApprovals(this,e)}getApprovedUtxos(e=!1){return v.getApprovedUtxos(this,e)}getApprovedUtxosForToken(e,t=!1){return v.getApprovedUtxosForToken(this,e,t)}getMyApprovalAmountForInteraction(e,t){return v.getMyApprovalAmountForInteraction(this,e,t)}async checkExistingApprovalFromHinkal(e,t){return await C.checkExistingApprovalFromHinkal(this,e,t)}async getBufferEntry(e,t,r){return C.getBufferEntry(this,e,t,r)}async deposit(e,t){return I.hinkalDeposit(this,e,t)}async depositForOther(e,t,r){return I.hinkalDepositForOther(this,e,t,r)}async depositAndWithdraw(e,t,r,i,n,a){return h.isSolanaLike(this.getCurrentChainId())?de.hinkalSolanaDepositAndWithdraw(this,e.erc20TokenAddress,t,r,i,n,a):B.hinkalDepositAndWithdraw(this,e,t,r,i,n,a)}async depositAndBridge(e,t,r,i,n){return ye.hinkalDepositAndBridge(this,e,t,r,i,n)}async prooflessDeposit(e,t,r){return se.hinkalProoflessDeposit(this,e,t,r)}getSolanaProgram(e){if(!this.providerAdapter)throw new Error("No provider adapter initialized");if(!("getSolanaProgram"in this.providerAdapter))throw new Error("Current provider adapter is not a Solana provider adapter");return this.providerAdapter.getSolanaProgram(e)}getSolanaPublicKey(){if(!this.providerAdapter)throw new Error("No provider adapter initialized");if(!("getSolanaPublicKey"in this.providerAdapter))throw new Error("Current provider adapter is not a Solana provider adapter");return this.providerAdapter.getSolanaPublicKey()}async depositSolana(e,t){return w.hinkalSolanaDeposit(this,e,t)}async depositSolanaForOther(e,t,r){return w.hinkalSolanaDepositForOther(this,e,t,r)}async solanaMultiPaymentDeposit(e,t){return w.hinkalSolanaMultiPaymentDeposit(this,e,t)}async transfer(e,t,r,i,n,a,s=!1){return h.isSolanaLike(this.getCurrentChainId())?ue.hinkalSolanaTransfer(this,e,t,r,i,n,s):he.hinkalTransfer(this,e,t,r,i,n,a,s)}async withdraw(e,t,r,i,n,a,s,o=!1){return h.isSolanaLike(this.getCurrentChainId())?pe.hinkalSolanaWithdraw(this,e.map(c=>c.erc20TokenAddress),t,r,n,a,o):U.hinkalWithdraw(this,e,t,r,i,n,a,s,o)}async withdrawStuckUtxos(e,t){return L.hinkalWithdrawStuckUtxos(this,e,t)}async swap(e,t,r,i,n,a,s,o=!1,c=!1){return h.isSolanaLike(this.getCurrentChainId())?this.swapSolana(e,t,i,n,a,o):K.hinkalSwap(this,e,t,r,i,n,a,s,o,c)}async swapSolana(e,t,r,i,n,a=!1){const s=JSON.parse(r),o=BigInt(s.swapperAccountSalt),{instructionLists:c,addressLookupTableAccount:l}=s.data;return ge.hinkalSolanaSwap(this,e,t,o,c,l,i,n,a)}async actionReceive(e,t,r,i,n,a,s=!1){if(!n)throw new Error("subAccount is required");return h.isSolanaLike(this.getCurrentChainId())?D.hinkalSolanaProxyShield(this,e[0],t[0],n,void 0,s):te.hinkalActionReceive(this,e,t,r,i,n,a,s)}async actionFundApproveAndTransact(e,t,r,i,n,a,s,o,c=!1,l,p,d){return re.hinkalActionFundApproveAndTransact(this,e,t,r,i,n,a,s,o,c,l,p,d)}async actionPrivateWallet(e,t,r,i,n,a,s,o,c,l=!1,p,d,u,k=!1){return $.hinkalPrivateWallet(this,e,t,r,i,n,a,s,o,c,l,p,d,u,k)}async approve(e,t,r,i,n,a=!1){return Y.hinkalApprove(this,e,t,r,i,n,a)}async hinkalInsideTransact(e,t,r,i,n,a,s,o,c,l=!1){return Z.hinkalInsideTransact(this,e,t,r,i,n,a,s,o,c,l)}async proxySwap(e,t,r,i,n,a,s,o,c=!1,l,p,d=!1){return h.isSolanaLike(this.getCurrentChainId())?ve.hinkalSolanaProxySwap(this,e,t,i,a,s,o,d):oe.hinkalProxySwap(this,e,t,r,i,n,a,s,o,c,l,p,d)}async proxyToPrivate(e,t,r,i,n,a,s,o=!1){return h.isSolanaLike(this.getCurrentChainId())?D.hinkalSolanaProxyShield(this,e[0],t[0],r,i,o):le.hinkalProxyToPrivate(this,e,t,i,n,a,r,s,o)}async proxySend(e,t,r,i,n,a,s,o=!1){if(h.isSolanaLike(this.getCurrentChainId()))return ke.hinkalSolanaProxySend(this,e[0],t[0],r,i,o);const c=ae.createTransaferEmporiumOpsBatch(this,e.map(d=>d.erc20TokenAddress),t,i),l=e.map((d,u)=>({token:d,amount:-1n*t[u]}));return await this.actionPrivateWallet([],[],[],c,l,r,n,a,void 0,void 0,void 0,s,void 0,o)}async multiSendPrivateRecipients(e,t,r){return ce.hinkalMultiSendPrivateRecipients(this,e,t,r)}areMerkleTreeUpdatesDisabled(){return this.disableMerkleTreeUpdates}updateMerkleTreeUpdates(e){this.disableMerkleTreeUpdates=e}}exports.Hinkal=Se;
|
|
@@ -62,7 +62,6 @@ import "@solana/spl-token";
|
|
|
62
62
|
import "async-mutex";
|
|
63
63
|
import "../../functions/utils/convertIntegrationProviderToExternalActionId.mjs";
|
|
64
64
|
import "../../types/circom-data.types.mjs";
|
|
65
|
-
import "../../types/transactions.types.mjs";
|
|
66
65
|
import "../../types/activities.types.mjs";
|
|
67
66
|
import { getMerkleAccountPublicKey as ge, getAccessTokenMerkleAccountPublicKey as ue } from "../../functions/pre-transaction/solana.mjs";
|
|
68
67
|
import "@coral-xyz/anchor";
|
|
@@ -85,7 +84,7 @@ import { hinkalSolanaProxySwap as Ee } from "./hinkalSolanaProxySwap.mjs";
|
|
|
85
84
|
import { hinkalSolanaProxyShield as E } from "./hinkalSolanaProxyShield.mjs";
|
|
86
85
|
import { fetchSolanaMerkleTreeRootHash as F } from "../../functions/web3/fetchSolanaMerkleTreeRootHash.mjs";
|
|
87
86
|
import { hinkalDepositAndBridge as Fe } from "./hinkalDepostAndBridge.mjs";
|
|
88
|
-
class
|
|
87
|
+
class cr {
|
|
89
88
|
providerAdapter;
|
|
90
89
|
userKeys;
|
|
91
90
|
signingMessage = "Login to Hinkal Protocol";
|
|
@@ -104,7 +103,7 @@ class hr {
|
|
|
104
103
|
generateProofRemotely;
|
|
105
104
|
disableMerkleTreeUpdates;
|
|
106
105
|
constructor(e) {
|
|
107
|
-
this.userKeys = new y(void 0), this.merkleTreeHinkal = P.create(I, 0n), this.merkleTreeAccessToken = P.create(I, 0n), this.nullifiers = /* @__PURE__ */ new Set(), this.encryptedOutputs = [], this.approvals = /* @__PURE__ */ new Map(), this.generateProofRemotely = e?.generateProofRemotely ?? !
|
|
106
|
+
this.userKeys = new y(void 0), this.merkleTreeHinkal = P.create(I, 0n), this.merkleTreeAccessToken = P.create(I, 0n), this.nullifiers = /* @__PURE__ */ new Set(), this.encryptedOutputs = [], this.approvals = /* @__PURE__ */ new Map(), this.generateProofRemotely = e?.generateProofRemotely ?? !0, this.utxoUtils = new J(), this.cacheDevice = X(e), this.disableMerkleTreeUpdates = e?.disableMerkleTreeUpdates ?? !1;
|
|
108
107
|
}
|
|
109
108
|
async initProviderAdapter(e, t) {
|
|
110
109
|
await this.updateProviderAdapter(t), this.providerAdapter?.initConnector(e);
|
|
@@ -298,7 +297,7 @@ class hr {
|
|
|
298
297
|
this.getHinkalTreeRootHash(),
|
|
299
298
|
this.getAccessTokenTreeRootHash()
|
|
300
299
|
]);
|
|
301
|
-
(e
|
|
300
|
+
(BigInt(e) !== this.merkleTreeHinkal.getRootHash() || BigInt(t) !== this.merkleTreeAccessToken.getRootHash()) && (console.log("resetting merkle tree in resetMerkleTreesIfNecessary"), await this.resetMerkle());
|
|
302
301
|
}
|
|
303
302
|
async getEventsFromHinkal() {
|
|
304
303
|
await Promise.all([
|
|
@@ -646,5 +645,5 @@ class hr {
|
|
|
646
645
|
}
|
|
647
646
|
}
|
|
648
647
|
export {
|
|
649
|
-
|
|
648
|
+
cr as Hinkal
|
|
650
649
|
};
|
|
@@ -6,7 +6,7 @@ import { type IMultiThreadedUtxoUtils } from '../../types/IMultiThreadedUtxoUtil
|
|
|
6
6
|
import { RelayerTransaction } from '../../types/relayer.types';
|
|
7
7
|
import { SignatureData } from '../../types/crypto.types';
|
|
8
8
|
import { ERC20Token, PrivateRecipientInfo, TokenBalance, TokenChanges } from '../../types/token.types';
|
|
9
|
-
import {
|
|
9
|
+
import { ethers } from 'ethers';
|
|
10
10
|
import { type UserKeys } from '../crypto-keys/keys';
|
|
11
11
|
import { IProviderAdapter } from '../provider-adapter/IProviderAdapter';
|
|
12
12
|
import { ClientAccessTokenSnapshotService, ClientApprovalsSnapshotService, ClientCommitmentsSnapshotService, ClientNullifierSnapshotService, ClientSolanaAccessTokenSnapshotService, ClientSolanaCommitmentsSnapshotService, ClientSolanaNullifierSnapshotService } from '../snapshot';
|
|
@@ -96,7 +96,7 @@ export interface IHinkal<ConnectorType = unknown> {
|
|
|
96
96
|
monitorConnectedAddress(): Promise<void>;
|
|
97
97
|
getSelectedNetwork(): EthereumNetwork | undefined;
|
|
98
98
|
isPermitterAvailable(): boolean;
|
|
99
|
-
signMessage(message:
|
|
99
|
+
signMessage(message: string): Promise<string>;
|
|
100
100
|
signTypedData(domain: ethers.TypedDataDomain, types: Record<string, ethers.TypedDataField[]>, value: Record<string, unknown>): Promise<string>;
|
|
101
101
|
signWithSubAccount(messageToSign: string | undefined, typedData: TypedData | undefined, subAccount: SubAccount): Promise<string>;
|
|
102
102
|
actionFundApproveAndTransact(tokenChanges: TokenChanges<bigint>[], subAccount: SubAccount, spenderAddress?: string, to?: string, callDataString?: string, value?: bigint, feeToken?: string, feeStructureOverride?: FeeStructure, autoDepositBack?: boolean, maxGasInDollar?: string, action?: AdminTransactionType, onlyGasEstimate?: boolean): Promise<RelayerTransaction | bigint>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("../../error-handling/error-codes.constants.cjs"),N=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),W=require("../../functions/web3/events/getShieldedBalance.cjs"),K=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),V=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),y=require("../../types/external-action.types.cjs"),B=require("../../externalABIs/index.cjs"),D=require("ethers"),T=require("../../types/hinkal.types.cjs"),b=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),h=require("../../functions/pre-transaction/outputApprovalDataProcessing.cjs"),z=require("../../functions/pre-transaction/getFeeStructure.cjs"),G=require("../../functions/pre-transaction/merge-with-fee-structure.cjs"),q=require("../../types/ethereum-network.types.cjs"),X=require("../../constants/conversion.constants.cjs"),Z=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),$=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),j=require("../../functions/utils/time.utils.cjs"),Y=async(t,a,u,n,f,E,l=!1)=>{const p=D.ethers.getAddress(n),A=new D.ethers.Contract(a[0],B.ERC20ABI),P=t.userKeys.getInHinkalAddress(p),r=[t.getMyApprovalAmountForInteraction(n,a[0])-u],R=await t.getContractWithFetcher(q.ContractType.HinkalContract).getAddress(),w=await A.getAddress(),g=E??await z.getFeeStructure(t.getCurrentChainId(),f,a,y.ExternalActionId.Wallet,[0n,1n].map(e=>({to:w,from:R,value:0n,calldata:A.interface.encodeFunctionData("approve",[n,e])})));G.mergeWithFeeStructure(t.getCurrentChainId(),a,r,g);const o=[...await W.addPaddingToUtxos(t,a,r)],I=`swapperMHA${r.length.toString()}x${o[0].length}x1`,S=r.map(()=>!1),d=[],s={doPreTxApproval:!0,hinkalLogicAction:T.HinkalLogicAction.APPROVE,executeApprovalChanges:a.map(()=>0n),inHinkalAddress:P,useApprovalUtxoData:[]},{patchAccessTokenMerkleTree:U,kycRequired:F,hasAccessToken:_}=await Z.shouldPatchAccessTokenMerkleTree(t,a,r),O=await $.getSignatureDataForTransact(t.getCurrentChainId(),await t.getEthereumAddress(),t.userKeys,F,_),k=j.getCurrentTimeInSeconds().toString();for(let e=0;e<a.length;e+=1){if(e===0){const{useApprovalUtxoData:i,deltaAmountOverride:M}=h.outputApprovalDataProcessingForHinkalApprove(t,o[e],n,u,r[e]);r[e]=M,s.useApprovalUtxoData.push(i)}else{const{useApprovalUtxoData:i}=h.outputApprovalDataProcessing(t,o[e],r[e]);s.useApprovalUtxoData.push(i??T.defaultUseApprovalUTXOData(X.APPROVED_UTXO_CONVERSION_COUNT,0n))}const{outputUtxos:H}=b.outputUtxoProcessing(t.userKeys,o[e],r[e],k,void 0,!1);d.push(H)}const C=await t.getRandomRelay(!l);if(!C)throw Error(L.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const c={externalActionId:y.ExternalActionId.Wallet,externalAddress:p,externalActionMetadata:"0x"},{zkCallData:x,circomData:m,dimData:v}=await N.constructZkProof("v1x1",t.merkleTreeHinkal,t.merkleTreeAccessToken,o,d,t.userKeys,I,c.externalActionId,c.externalAddress,c.externalActionMetadata,t.generateProofRemotely,C,t.getCurrentChainId(),S,void 0,void 0,U,s,void 0,g,t.getContractWithFetcher(q.ContractType.HinkalHelperContract),O);return l?await K.estimateGasRelayer(t,x,v,m):await V.transactCallRelayer(t.getCurrentChainId(),x,v,m)};exports.hinkalApprove=Y;
|
|
@@ -1,114 +1,114 @@
|
|
|
1
|
-
import { transactionErrorCodes as
|
|
2
|
-
import { constructZkProof as
|
|
3
|
-
import { addPaddingToUtxos as
|
|
4
|
-
import { estimateGasRelayer as
|
|
5
|
-
import { transactCallRelayer as
|
|
1
|
+
import { transactionErrorCodes as N } from "../../error-handling/error-codes.constants.mjs";
|
|
2
|
+
import { constructZkProof as W } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
3
|
+
import { addPaddingToUtxos as _ } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
4
|
+
import { estimateGasRelayer as K } from "../../functions/web3/functionCalls/estimateGasRelayer.mjs";
|
|
5
|
+
import { transactCallRelayer as V } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
6
6
|
import { ExternalActionId as v } from "../../types/external-action.types.mjs";
|
|
7
|
-
import { ERC20ABI as
|
|
7
|
+
import { ERC20ABI as k } from "../../externalABIs/index.mjs";
|
|
8
8
|
import { ethers as D } from "ethers";
|
|
9
9
|
import { HinkalLogicAction as z, defaultUseApprovalUTXOData as B } from "../../types/hinkal.types.mjs";
|
|
10
10
|
import { outputUtxoProcessing as X } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
11
|
-
import { outputApprovalDataProcessingForHinkalApprove as $, outputApprovalDataProcessing as
|
|
12
|
-
import { getFeeStructure as
|
|
13
|
-
import { mergeWithFeeStructure as
|
|
11
|
+
import { outputApprovalDataProcessingForHinkalApprove as $, outputApprovalDataProcessing as q } from "../../functions/pre-transaction/outputApprovalDataProcessing.mjs";
|
|
12
|
+
import { getFeeStructure as Y } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
13
|
+
import { mergeWithFeeStructure as Z } from "../../functions/pre-transaction/merge-with-fee-structure.mjs";
|
|
14
14
|
import { ContractType as E } from "../../types/ethereum-network.types.mjs";
|
|
15
|
-
import { APPROVED_UTXO_CONVERSION_COUNT as
|
|
16
|
-
import { shouldPatchAccessTokenMerkleTree as
|
|
17
|
-
import { getSignatureDataForTransact as
|
|
18
|
-
import { getCurrentTimeInSeconds as
|
|
19
|
-
const
|
|
20
|
-
const u = D.
|
|
15
|
+
import { APPROVED_UTXO_CONVERSION_COUNT as b } from "../../constants/conversion.constants.mjs";
|
|
16
|
+
import { shouldPatchAccessTokenMerkleTree as j } from "../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs";
|
|
17
|
+
import { getSignatureDataForTransact as G } from "../../functions/pre-transaction/getSignatureDataForTransact.mjs";
|
|
18
|
+
import { getCurrentTimeInSeconds as J } from "../../functions/utils/time.utils.mjs";
|
|
19
|
+
const Et = async (t, r, p, n, T, w, m = !1) => {
|
|
20
|
+
const u = D.getAddress(n), l = new D.Contract(r[0], k), y = t.userKeys.getInHinkalAddress(u), e = [t.getMyApprovalAmountForInteraction(n, r[0]) - p], I = await t.getContractWithFetcher(E.HinkalContract).getAddress(), R = await l.getAddress(), A = w ?? await Y(
|
|
21
21
|
t.getCurrentChainId(),
|
|
22
22
|
T,
|
|
23
23
|
r,
|
|
24
24
|
v.Wallet,
|
|
25
25
|
// we don't need exact amounts, just need to result in the same amount of gas
|
|
26
26
|
[0n, 1n].map((o) => ({
|
|
27
|
-
to:
|
|
28
|
-
from:
|
|
27
|
+
to: R,
|
|
28
|
+
from: I,
|
|
29
29
|
value: 0n,
|
|
30
30
|
calldata: l.interface.encodeFunctionData("approve", [n, o])
|
|
31
31
|
}))
|
|
32
32
|
);
|
|
33
|
-
|
|
34
|
-
const a = [...await
|
|
33
|
+
Z(t.getCurrentChainId(), r, e, A);
|
|
34
|
+
const a = [...await _(t, r, e)], U = `swapperMHA${e.length.toString()}x${a[0].length}x1`, P = e.map(() => !1), g = [], s = {
|
|
35
35
|
doPreTxApproval: !0,
|
|
36
36
|
hinkalLogicAction: z.APPROVE,
|
|
37
37
|
executeApprovalChanges: r.map(() => 0n),
|
|
38
38
|
// this should not matter
|
|
39
|
-
inHinkalAddress:
|
|
39
|
+
inHinkalAddress: y,
|
|
40
40
|
// as well
|
|
41
41
|
useApprovalUtxoData: []
|
|
42
|
-
}, { patchAccessTokenMerkleTree:
|
|
42
|
+
}, { patchAccessTokenMerkleTree: h, kycRequired: H, hasAccessToken: O } = await j(
|
|
43
43
|
t,
|
|
44
44
|
r,
|
|
45
45
|
e
|
|
46
|
-
), S = await
|
|
46
|
+
), S = await G(
|
|
47
47
|
t.getCurrentChainId(),
|
|
48
48
|
await t.getEthereumAddress(),
|
|
49
49
|
t.userKeys,
|
|
50
50
|
H,
|
|
51
51
|
O
|
|
52
|
-
),
|
|
52
|
+
), F = J().toString();
|
|
53
53
|
for (let o = 0; o < r.length; o += 1) {
|
|
54
54
|
if (o === 0) {
|
|
55
|
-
const { useApprovalUtxoData: c, deltaAmountOverride:
|
|
55
|
+
const { useApprovalUtxoData: c, deltaAmountOverride: M } = $(
|
|
56
56
|
t,
|
|
57
57
|
a[o],
|
|
58
58
|
n,
|
|
59
59
|
p,
|
|
60
60
|
e[o]
|
|
61
61
|
);
|
|
62
|
-
e[o] =
|
|
62
|
+
e[o] = M, s.useApprovalUtxoData.push(c);
|
|
63
63
|
} else {
|
|
64
|
-
const { useApprovalUtxoData: c } =
|
|
64
|
+
const { useApprovalUtxoData: c } = q(t, a[o], e[o]);
|
|
65
65
|
s.useApprovalUtxoData.push(
|
|
66
|
-
c ?? B(
|
|
66
|
+
c ?? B(b, 0n)
|
|
67
67
|
);
|
|
68
68
|
}
|
|
69
|
-
const { outputUtxos:
|
|
69
|
+
const { outputUtxos: L } = X(
|
|
70
70
|
t.userKeys,
|
|
71
71
|
a[o],
|
|
72
72
|
e[o],
|
|
73
|
-
|
|
73
|
+
F,
|
|
74
74
|
void 0,
|
|
75
75
|
!1
|
|
76
76
|
);
|
|
77
|
-
g.push(
|
|
77
|
+
g.push(L);
|
|
78
78
|
}
|
|
79
|
-
const
|
|
80
|
-
if (!
|
|
81
|
-
throw Error(
|
|
79
|
+
const d = await t.getRandomRelay(!m);
|
|
80
|
+
if (!d)
|
|
81
|
+
throw Error(N.RELAYER_NOT_AVAILABLE);
|
|
82
82
|
const i = {
|
|
83
83
|
externalActionId: v.Wallet,
|
|
84
84
|
externalAddress: u,
|
|
85
85
|
externalActionMetadata: "0x"
|
|
86
|
-
}, { zkCallData:
|
|
86
|
+
}, { zkCallData: f, circomData: C, dimData: x } = await W(
|
|
87
87
|
"v1x1",
|
|
88
88
|
t.merkleTreeHinkal,
|
|
89
89
|
t.merkleTreeAccessToken,
|
|
90
90
|
a,
|
|
91
91
|
g,
|
|
92
92
|
t.userKeys,
|
|
93
|
-
|
|
93
|
+
U,
|
|
94
94
|
i.externalActionId,
|
|
95
95
|
i.externalAddress,
|
|
96
96
|
i.externalActionMetadata,
|
|
97
97
|
t.generateProofRemotely,
|
|
98
|
-
|
|
98
|
+
d,
|
|
99
99
|
t.getCurrentChainId(),
|
|
100
|
-
|
|
100
|
+
P,
|
|
101
101
|
void 0,
|
|
102
102
|
void 0,
|
|
103
|
-
|
|
103
|
+
h,
|
|
104
104
|
s,
|
|
105
105
|
void 0,
|
|
106
106
|
A,
|
|
107
107
|
t.getContractWithFetcher(E.HinkalHelperContract),
|
|
108
108
|
S
|
|
109
109
|
);
|
|
110
|
-
return m ? await
|
|
110
|
+
return m ? await K(t, f, x, C) : await V(t.getCurrentChainId(), f, x, C);
|
|
111
111
|
};
|
|
112
112
|
export {
|
|
113
|
-
|
|
113
|
+
Et as hinkalApprove
|
|
114
114
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("idb-keyval");const u=require("../../constants/chains.constants.cjs"),n=require("../../functions/utils/create-provider.cjs"),o=require("ethers");require("../../constants/token-data/index.cjs");require("../../error-handling/error-codes.constants.cjs");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../../types/circom-data.types.cjs");require("../../types/activities.types.cjs");require("circomlibjs-hinkal-fork");require("../crypto-keys/keys.cjs");require("../../constants/server.constants.cjs");require("../../constants/vite.constants.cjs");require("../http/HttpClient.cjs");require("axios");require("../../API/getServerURL.cjs");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/save-depths.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../functions/utils/mutexes.utils.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");require("@solana/spl-token");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");require("../../functions/utils/userAgent.cjs");require("multiformats");require("../../API/tenderly.api.cjs");const q=async(r,e,i)=>await r.checkTokenRegistry(e,i),a=r=>{const e=u.networkRegistry[r].contractData,{fetchRpcUrl:i}=u.networkRegistry[r];if(!i)throw new Error("RPC URL not found for the specified chain ID");const t=n.createCustomRpcProvider(i);if(!e.hinkalHelperAddress||!e.hinkalHelperABI)throw Error("hinkal helpercontract data not found");return new o.ethers.Contract(e.hinkalHelperAddress,e.hinkalHelperABI,t)};exports.createHinkalHelperFromData=a;exports.hinkalCheckTokenRegistry=q;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { ethers as m } from "ethers";
|
|
2
1
|
import "idb-keyval";
|
|
3
2
|
import { networkRegistry as p } from "../../constants/chains.constants.mjs";
|
|
4
|
-
import { createCustomRpcProvider as
|
|
3
|
+
import { createCustomRpcProvider as m } from "../../functions/utils/create-provider.mjs";
|
|
4
|
+
import { ethers as e } from "ethers";
|
|
5
5
|
import "../../constants/token-data/index.mjs";
|
|
6
6
|
import "../../error-handling/error-codes.constants.mjs";
|
|
7
7
|
import "../../functions/utils/convertIntegrationProviderToExternalActionId.mjs";
|
|
8
8
|
import "../../types/circom-data.types.mjs";
|
|
9
|
-
import "../../types/transactions.types.mjs";
|
|
10
9
|
import "../../types/activities.types.mjs";
|
|
11
10
|
import "circomlibjs-hinkal-fork";
|
|
12
11
|
import "../crypto-keys/keys.mjs";
|
|
@@ -36,16 +35,16 @@ import "../../constants/events.constants.mjs";
|
|
|
36
35
|
import "../../functions/utils/userAgent.mjs";
|
|
37
36
|
import "multiformats";
|
|
38
37
|
import "../../API/tenderly.api.mjs";
|
|
39
|
-
const
|
|
38
|
+
const O = async (t, r, o) => await t.checkTokenRegistry(r, o), Q = (t) => {
|
|
40
39
|
const r = p[t].contractData, { fetchRpcUrl: o } = p[t];
|
|
41
40
|
if (!o)
|
|
42
41
|
throw new Error("RPC URL not found for the specified chain ID");
|
|
43
|
-
const i =
|
|
42
|
+
const i = m(o);
|
|
44
43
|
if (!r.hinkalHelperAddress || !r.hinkalHelperABI)
|
|
45
44
|
throw Error("hinkal helpercontract data not found");
|
|
46
|
-
return new
|
|
45
|
+
return new e.Contract(r.hinkalHelperAddress, r.hinkalHelperABI, i);
|
|
47
46
|
};
|
|
48
47
|
export {
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
Q as createHinkalHelperFromData,
|
|
49
|
+
O as hinkalCheckTokenRegistry
|
|
51
50
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("../../constants/protocol.constants.cjs"),f=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),w=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),h=require("../../functions/web3/events/getShieldedBalance.cjs"),q=require("../../functions/web3/functionCalls/transactCallDirect.cjs"),C=require("../utxo/Utxo.cjs"),F=require("../../error-handling/error-codes.constants.cjs");require("../../types/circom-data.types.cjs");const I=require("../../types/ethereum-network.types.cjs")
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("../../constants/protocol.constants.cjs"),f=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),w=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),h=require("../../functions/web3/events/getShieldedBalance.cjs"),q=require("../../functions/web3/functionCalls/transactCallDirect.cjs"),C=require("../utxo/Utxo.cjs"),F=require("../../error-handling/error-codes.constants.cjs");require("../../types/circom-data.types.cjs");const I=require("../../types/ethereum-network.types.cjs"),M=require("../../types/admin.types.cjs");require("../../types/activities.types.cjs");const R=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),_=require("../../functions/utils/addresses.cjs"),z=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),H=require("../../functions/utils/time.utils.cjs"),S=require("../../API/admin-calls.cjs"),U=require("../../functions/pre-transaction/constructAdminData.cjs"),K=async(t,s,e)=>{const{patchAccessTokenMerkleTree:o,kycRequired:r,hasAccessToken:A}=await z.shouldPatchAccessTokenMerkleTree(t,s,e),c=void 0,l=await t.getEthereumAddress(),i=await R.getSignatureDataForTransact(t.getCurrentChainId(),l,t.userKeys,r,A),n={externalActionId:0n,externalAddress:await t.getEthereumAddress(),externalActionMetadata:"0x00"};return{signatureData:i,externalActionData:n,contractTransaction:c,contractToApprove:c,patchAccessTokenMerkleTree:o}},O=async(t,s,e)=>{const o=s.map(a=>a.erc20TokenAddress),{externalActionData:r,contractTransaction:A,contractToApprove:c,patchAccessTokenMerkleTree:l,signatureData:i}=await K(t,o,e),n=[...await h.addPaddingToUtxos(t,o,e)],p=`swapperM${e.length.toString()}x${n[0].length}x1`,d=[],T=H.getCurrentTimeInSeconds().toString();for(let a=0;a<o.length;a+=1){const{outputUtxos:v}=f.outputUtxoProcessing(t.userKeys,n[a],e[a],T);d.push(v)}const{zkCallData:m,circomData:x,dimData:g}=await w.constructZkProof("v1x1",t.merkleTreeHinkal,t.merkleTreeAccessToken,n,d,t.userKeys,p,r.externalActionId,r.externalAddress,r.externalActionMetadata,t.generateProofRemotely,P.zeroAddress,t.getCurrentChainId(),void 0,void 0,void 0,l,void 0,void 0,void 0,t.getContractWithFetcher(I.ContractType.HinkalHelperContract),i),y=await q.transactCallDirect(t,e,s,m,x,g,c,A),D=U.constructAdminData(M.AdminTransactionType.Onboarding,t.getCurrentChainId(),o,e,await t.getEthereumAddress());return S.emitTxPublicData(t.getCurrentChainId(),D),y},b=async(t,s,e,o)=>{const r=s.map(u=>u.erc20TokenAddress),[A,c,l]=o.split(",");if(!_.isValidPrivateAddress(o))throw Error(F.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);const i=r.map(u=>[new C.Utxo({amount:0n,erc20TokenAddress:u,shieldedPrivateKey:t.userKeys.getShieldedPrivateKey()}),new C.Utxo({amount:0n,erc20TokenAddress:u,shieldedPrivateKey:t.userKeys.getShieldedPrivateKey()})]),n=`swapperM${e.length.toString()}x${i[0].length}x1`,p=r.map((u,E)=>[new C.Utxo({amount:e[E],erc20TokenAddress:u,randomization:BigInt(A),stealthAddress:c,encryptionKey:l})]),{externalActionData:d,contractTransaction:T,contractToApprove:m,patchAccessTokenMerkleTree:x}=await K(t,r,e),{zkCallData:g,circomData:y,dimData:D}=await w.constructZkProof("v1x1",t.merkleTreeHinkal,t.merkleTreeAccessToken,i,p,t.userKeys,n,d.externalActionId,d.externalAddress,d.externalActionMetadata,t.generateProofRemotely,P.zeroAddress,t.getCurrentChainId(),void 0,void 0,void 0,x,void 0,void 0,void 0,t.getContractWithFetcher(I.ContractType.HinkalHelperContract)),a=await q.transactCallDirect(t,e,s,g,y,D,m,T),v=U.constructAdminData(M.AdminTransactionType.PaymentLink,t.getCurrentChainId(),r,e,await t.getEthereumAddress());return S.emitTxPublicData(t.getCurrentChainId(),v),a};exports.hinkalDeposit=O;exports.hinkalDepositForOther=b;
|
|
@@ -7,7 +7,6 @@ import { Utxo as w } from "../utxo/Utxo.mjs";
|
|
|
7
7
|
import { transactionErrorCodes as z } from "../../error-handling/error-codes.constants.mjs";
|
|
8
8
|
import "../../types/circom-data.types.mjs";
|
|
9
9
|
import { ContractType as I } from "../../types/ethereum-network.types.mjs";
|
|
10
|
-
import "../../types/transactions.types.mjs";
|
|
11
10
|
import { AdminTransactionType as K } from "../../types/admin.types.mjs";
|
|
12
11
|
import "../../types/activities.types.mjs";
|
|
13
12
|
import { getSignatureDataForTransact as F } from "../../functions/pre-transaction/getSignatureDataForTransact.mjs";
|
|
@@ -39,7 +38,7 @@ const S = async (t, s, e) => {
|
|
|
39
38
|
contractToApprove: c,
|
|
40
39
|
patchAccessTokenMerkleTree: o
|
|
41
40
|
};
|
|
42
|
-
},
|
|
41
|
+
}, et = async (t, s, e) => {
|
|
43
42
|
const o = s.map((a) => a.erc20TokenAddress), { externalActionData: r, contractTransaction: p, contractToApprove: c, patchAccessTokenMerkleTree: A, signatureData: i } = await S(t, o, e), n = [...await H(t, o, e)], u = `swapperM${e.length.toString()}x${n[0].length}x1`, d = [], x = $().toString();
|
|
44
43
|
for (let a = 0; a < o.length; a += 1) {
|
|
45
44
|
const { outputUtxos: f } = R(t.userKeys, n[a], e[a], x);
|
|
@@ -86,7 +85,7 @@ const S = async (t, s, e) => {
|
|
|
86
85
|
await t.getEthereumAddress()
|
|
87
86
|
);
|
|
88
87
|
return M(t.getCurrentChainId(), v), l;
|
|
89
|
-
},
|
|
88
|
+
}, rt = async (t, s, e, o) => {
|
|
90
89
|
const r = s.map((m) => m.erc20TokenAddress), [p, c, A] = o.split(",");
|
|
91
90
|
if (!N(o))
|
|
92
91
|
throw Error(z.RECIPIENT_FORMAT_INCORRECT);
|
|
@@ -142,6 +141,6 @@ const S = async (t, s, e) => {
|
|
|
142
141
|
return M(t.getCurrentChainId(), f), a;
|
|
143
142
|
};
|
|
144
143
|
export {
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
et as hinkalDeposit,
|
|
145
|
+
rt as hinkalDepositForOther
|
|
147
146
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("../../constants/protocol.constants.cjs"),F=require("../../error-handling/error-codes.constants.cjs"),O=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),K=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),L=require("../../types/external-action.types.cjs"),z=require("../utxo/Utxo.cjs");require("../../types/circom-data.types.cjs");const B=require("../../types/ethereum-network.types.cjs")
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("../../constants/protocol.constants.cjs"),F=require("../../error-handling/error-codes.constants.cjs"),O=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),K=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),L=require("../../types/external-action.types.cjs"),z=require("../utxo/Utxo.cjs");require("../../types/circom-data.types.cjs");const B=require("../../types/ethereum-network.types.cjs"),N=require("../../types/admin.types.cjs");require("../../types/activities.types.cjs");const D=require("../../types/scheduled-transactions.types.cjs"),Z=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),j=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),G=require("../../functions/utils/time.utils.cjs"),V=require("../../functions/pre-transaction/getFeeStructure.cjs"),Y=require("../../functions/utils/addresses.cjs"),$=require("./hinkalDepositOnChainUtxos.cjs"),J=require("../../functions/pre-transaction/constructAdminData.cjs"),q=require("../../API/deposit-and-withdraw-status-calls.cjs"),Q=async(e,t,r,h,s,c,A,i)=>{if(r.length===0)throw new Error("userDepositedUtxos must not be empty");const a=t.erc20TokenAddress,n=await e.getRandomRelay();if(!n)throw Error(F.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const o=await e.getEthereumAddress(),w=G.getCurrentTimeInSeconds().toString(),d=e.generateProofRemotely?5:1,p=[];for(let u=0;u<r.length;u+=d){const x=r.slice(u,u+d),S=await Promise.all(x.map(async({recipientAddress:I,utxo:l})=>{const E=[-l.amount],y=new z.Utxo({amount:0n,erc20TokenAddress:a,shieldedPrivateKey:e.userKeys.getShieldedPrivateKey(),timeStamp:w,tokenId:0}),T=[[l,y]],R=[[y]],P=`swapperM1x${T[0].length}x1`,m={externalActionId:0n,externalAddress:I,externalActionMetadata:"0x00"},{patchAccessTokenMerkleTree:_,kycRequired:f,hasAccessToken:U}=await j.shouldPatchAccessTokenMerkleTree(e,[a],E),W=await Z.getSignatureDataForTransact(e.getCurrentChainId(),o,e.userKeys,f,U),k=J.constructAdminData(N.AdminTransactionType.WithdrawOnChainUtxos,e.getCurrentChainId(),[a],[-l.amount],o),{zkCallData:v,circomData:H,dimData:M}=await O.constructZkProof("v1x1",e.merkleTreeHinkal,e.merkleTreeAccessToken,T,R,e.userKeys,P,m.externalActionId,m.externalAddress,m.externalActionMetadata,e.generateProofRemotely,n??b.zeroAddress,e.getCurrentChainId(),void 0,void 0,void 0,_,void 0,void 0,h,e.getContractWithFetcher(B.ContractType.HinkalHelperContract),W,void 0,!1);return{zkCallData:v,dimData:M,circomData:H,adminData:k}}));p.push(...S)}const C=e.getCurrentChainId();await q.safeUpdateDepositAndWithdrawStatus(C,{id:c,hashedEthereumAddress:s,phase:D.DepositAndWithdrawPhase.BEFORE_SCHEDULE_WITHDRAW});const g=await K.transactCallRelayerBatch(e.getCurrentChainId(),p,s,A,i);return await q.safeUpdateDepositAndWithdrawStatus(C,{id:c,hashedEthereumAddress:s,phase:D.DepositAndWithdrawPhase.AFTER_SCHEDULE_WITHDRAW,scheduleId:g}),g},X=async(e,t,r,h,s,c,A)=>{const i=t.erc20TokenAddress,a=e.getCurrentChainId(),n=Y.hashEthereumAddress(await e.getEthereumAddress()),o=c??await V.getFeeStructure(a,i,[i],L.ExternalActionId.Transact),{userDepositedUtxos:w,statusId:d}=await $.hinkalDepositOnChainUtxos(e,t,r,h,o,n);return Q(e,t,w,o,n,d,s,A)};exports.hinkalDepositAndWithdraw=X;
|
|
@@ -6,7 +6,6 @@ import { ExternalActionId as z } from "../../types/external-action.types.mjs";
|
|
|
6
6
|
import { Utxo as B } from "../utxo/Utxo.mjs";
|
|
7
7
|
import "../../types/circom-data.types.mjs";
|
|
8
8
|
import { ContractType as q } from "../../types/ethereum-network.types.mjs";
|
|
9
|
-
import "../../types/transactions.types.mjs";
|
|
10
9
|
import { AdminTransactionType as N } from "../../types/admin.types.mjs";
|
|
11
10
|
import "../../types/activities.types.mjs";
|
|
12
11
|
import { DepositAndWithdrawPhase as y } from "../../types/scheduled-transactions.types.mjs";
|
|
@@ -109,7 +108,7 @@ const Q = async (t, e, r, p, o, i, u, c) => {
|
|
|
109
108
|
phase: y.AFTER_SCHEDULE_WITHDRAW,
|
|
110
109
|
scheduleId: g
|
|
111
110
|
}), g;
|
|
112
|
-
},
|
|
111
|
+
}, gt = async (t, e, r, p, o, i, u) => {
|
|
113
112
|
const c = e.erc20TokenAddress, a = t.getCurrentChainId(), s = j(await t.getEthereumAddress()), n = i ?? await $(a, c, [c], z.Transact), { userDepositedUtxos: w, statusId: d } = await G(
|
|
114
113
|
t,
|
|
115
114
|
e,
|
|
@@ -130,5 +129,5 @@ const Q = async (t, e, r, p, o, i, u, c) => {
|
|
|
130
129
|
);
|
|
131
130
|
};
|
|
132
131
|
export {
|
|
133
|
-
|
|
132
|
+
gt as hinkalDepositAndWithdraw
|
|
134
133
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("ethers"),B=require("../../constants/protocol.constants.cjs"),j=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),G=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),N=require("../../functions/web3/events/getShieldedBalance.cjs"),X=require("../../functions/web3/functionCalls/transactCallDirect.cjs"),J=require("../../types/external-action.types.cjs");require("../../types/circom-data.types.cjs");const u=require("../../types/ethereum-network.types.cjs")
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("ethers"),B=require("../../constants/protocol.constants.cjs"),j=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),G=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),N=require("../../functions/web3/events/getShieldedBalance.cjs"),X=require("../../functions/web3/functionCalls/transactCallDirect.cjs"),J=require("../../types/external-action.types.cjs");require("../../types/circom-data.types.cjs");const u=require("../../types/ethereum-network.types.cjs"),L=require("../../types/admin.types.cjs");require("../../types/activities.types.cjs");const U=require("../../types/scheduled-transactions.types.cjs"),Q=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),V=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),Y=require("../../functions/utils/getUtxosFromReceipt.utils.cjs"),tt=require("../../functions/utils/fees.utils.cjs"),et=require("../../functions/pre-transaction/constructAdminData.cjs"),st=require("../../API/admin-calls.cjs"),y=require("../../API/deposit-and-withdraw-status-calls.cjs"),ot=async(t,p,f,P,O,l)=>{const h=p.erc20TokenAddress,x=await t.getEthereumAddress(),a=f.map(e=>e+tt.calculateTotalFee(e,O)),n=[h],i=[0n],S=[!0],{patchAccessTokenMerkleTree:W,kycRequired:v,hasAccessToken:E}=await V.shouldPatchAccessTokenMerkleTree(t,n,i),_=await Q.getSignatureDataForTransact(t.getCurrentChainId(),x,t.userKeys,v,E),o=[...await N.addPaddingToUtxos(t,n,i)],C=[];for(let e=0;e<o.length;e+=1){const{outputUtxos:s}=j.outputUtxoProcessing(t.userKeys,o[e],i[e]);C.push(s)}const A=a.reduce((e,s)=>e+s,0n),F=z.ethers.AbiCoder.defaultAbiCoder().encode(["uint256[]"],[a]),g=t.getContractWithSigner(u.ContractType.HinkalWrapper),D=t.getContractWithSigner(u.ContractType.DepositOnChainUtxos),{zkCallData:I,circomData:k,dimData:b}=await G.constructZkProof("v1x1",t.merkleTreeHinkal,t.merkleTreeAccessToken,o,C,t.userKeys,`swapperM1x${o[0].length}x1`,J.ExternalActionId.DepositOnChainUtxos,await D.getAddress(),F,t.generateProofRemotely,B.zeroAddress,t.getCurrentChainId(),S,void 0,void 0,W,void 0,void 0,void 0,t.getContractWithFetcher(u.ContractType.HinkalHelperContract),_,await g.getAddress(),!1),r=t.getCurrentChainId(),T=(await y.updateDepositAndWithdrawStatus(r,{hashedEthereumAddress:l,phase:U.DepositAndWithdrawPhase.BEFORE_DEPOSIT})).id??void 0,m=await X.transactCallDirect(t,A,p,I,k,b,D,g),R=await m.wait(),H=m.hash;await y.safeUpdateDepositAndWithdrawStatus(r,{id:T,hashedEthereumAddress:l,phase:U.DepositAndWithdrawPhase.AFTER_DEPOSIT,depositTxHash:H});const M=await Y.getUtxosFromReceipt(R,t,h),w=[],c=[...M];P.forEach((e,s)=>{const q=a[s],d=c.find($=>$.amount===q);if(!d)throw new Error(`Could not find newly created UTXO with amount ${q} for recipient ${e}.`);w.push({recipientAddress:e,utxo:d});const Z=c.indexOf(d);c.splice(Z,1)});const K=et.constructAdminData(L.AdminTransactionType.DepositOnChainUtxos,r,n,[A],x);return st.emitTxPublicData(r,K),{userDepositedUtxos:w,statusId:T}};exports.hinkalDepositOnChainUtxos=ot;
|
|
@@ -7,7 +7,6 @@ import { transactCallDirect as G } from "../../functions/web3/functionCalls/tran
|
|
|
7
7
|
import { ExternalActionId as J } from "../../types/external-action.types.mjs";
|
|
8
8
|
import "../../types/circom-data.types.mjs";
|
|
9
9
|
import { ContractType as p } from "../../types/ethereum-network.types.mjs";
|
|
10
|
-
import "../../types/transactions.types.mjs";
|
|
11
10
|
import { AdminTransactionType as L } from "../../types/admin.types.mjs";
|
|
12
11
|
import "../../types/activities.types.mjs";
|
|
13
12
|
import { DepositAndWithdrawPhase as U } from "../../types/scheduled-transactions.types.mjs";
|
|
@@ -18,7 +17,7 @@ import { calculateTotalFee as Y } from "../../functions/utils/fees.utils.mjs";
|
|
|
18
17
|
import { constructAdminData as tt } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
19
18
|
import { emitTxPublicData as ot } from "../../API/admin-calls.mjs";
|
|
20
19
|
import { updateDepositAndWithdrawStatus as et, safeUpdateDepositAndWithdrawStatus as rt } from "../../API/deposit-and-withdraw-status-calls.mjs";
|
|
21
|
-
const
|
|
20
|
+
const yt = async (t, m, y, O, E, u) => {
|
|
22
21
|
const f = m.erc20TokenAddress, x = await t.getEthereumAddress(), a = y.map((o) => o + Y(o, E)), i = [f], n = [0n], P = [!0], { patchAccessTokenMerkleTree: v, kycRequired: I, hasAccessToken: W } = await Q(
|
|
23
22
|
t,
|
|
24
23
|
i,
|
|
@@ -34,7 +33,7 @@ const Ot = async (t, m, y, O, E, u) => {
|
|
|
34
33
|
const { outputUtxos: e } = B(t.userKeys, r[o], n[o]);
|
|
35
34
|
C.push(e);
|
|
36
35
|
}
|
|
37
|
-
const
|
|
36
|
+
const A = a.reduce((o, e) => o + e, 0n), F = _.AbiCoder.defaultAbiCoder().encode(["uint256[]"], [a]), D = t.getContractWithSigner(p.HinkalWrapper), g = t.getContractWithSigner(p.DepositOnChainUtxos), {
|
|
38
37
|
zkCallData: H,
|
|
39
38
|
circomData: R,
|
|
40
39
|
dimData: b
|
|
@@ -47,7 +46,7 @@ const Ot = async (t, m, y, O, E, u) => {
|
|
|
47
46
|
t.userKeys,
|
|
48
47
|
`swapperM1x${r[0].length}x1`,
|
|
49
48
|
J.DepositOnChainUtxos,
|
|
50
|
-
|
|
49
|
+
await g.getAddress(),
|
|
51
50
|
F,
|
|
52
51
|
t.generateProofRemotely,
|
|
53
52
|
q,
|
|
@@ -61,33 +60,33 @@ const Ot = async (t, m, y, O, E, u) => {
|
|
|
61
60
|
void 0,
|
|
62
61
|
t.getContractWithFetcher(p.HinkalHelperContract),
|
|
63
62
|
S,
|
|
64
|
-
|
|
63
|
+
await D.getAddress(),
|
|
65
64
|
!1
|
|
66
|
-
), s = t.getCurrentChainId(),
|
|
65
|
+
), s = t.getCurrentChainId(), h = (await et(s, {
|
|
67
66
|
hashedEthereumAddress: u,
|
|
68
67
|
phase: U.BEFORE_DEPOSIT
|
|
69
|
-
})).id ?? void 0,
|
|
68
|
+
})).id ?? void 0, w = await G(
|
|
70
69
|
t,
|
|
71
|
-
|
|
70
|
+
A,
|
|
72
71
|
m,
|
|
73
72
|
H,
|
|
74
73
|
R,
|
|
75
74
|
b,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
), K = await
|
|
75
|
+
g,
|
|
76
|
+
D
|
|
77
|
+
), K = await w.wait(), M = w.hash;
|
|
79
78
|
await rt(s, {
|
|
80
|
-
id:
|
|
79
|
+
id: h,
|
|
81
80
|
hashedEthereumAddress: u,
|
|
82
81
|
phase: U.AFTER_DEPOSIT,
|
|
83
82
|
depositTxHash: M
|
|
84
83
|
});
|
|
85
|
-
const $ = V(K, t, f),
|
|
84
|
+
const $ = await V(K, t, f), T = [], c = [...$];
|
|
86
85
|
O.forEach((o, e) => {
|
|
87
|
-
const
|
|
86
|
+
const l = a[e], d = c.find((Z) => Z.amount === l);
|
|
88
87
|
if (!d)
|
|
89
|
-
throw new Error(`Could not find newly created UTXO with amount ${
|
|
90
|
-
|
|
88
|
+
throw new Error(`Could not find newly created UTXO with amount ${l} for recipient ${o}.`);
|
|
89
|
+
T.push({
|
|
91
90
|
recipientAddress: o,
|
|
92
91
|
utxo: d
|
|
93
92
|
});
|
|
@@ -98,11 +97,11 @@ const Ot = async (t, m, y, O, E, u) => {
|
|
|
98
97
|
L.DepositOnChainUtxos,
|
|
99
98
|
s,
|
|
100
99
|
i,
|
|
101
|
-
[
|
|
100
|
+
[A],
|
|
102
101
|
x
|
|
103
102
|
);
|
|
104
|
-
return ot(s, k), { userDepositedUtxos:
|
|
103
|
+
return ot(s, k), { userDepositedUtxos: T, statusId: h };
|
|
105
104
|
};
|
|
106
105
|
export {
|
|
107
|
-
|
|
106
|
+
yt as hinkalDepositOnChainUtxos
|
|
108
107
|
};
|