@hinkal/common 0.2.19 → 0.2.21
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/API.cjs +1 -1
- package/API/API.d.ts +6 -1
- package/API/API.mjs +48 -41
- package/API/enclaveCalls.cjs +1 -1
- package/API/enclaveCalls.mjs +5 -4
- package/API/index.d.ts +1 -0
- package/API/proxyAccountsCalls.cjs +1 -1
- package/API/proxyAccountsCalls.d.ts +7 -2
- package/API/proxyAccountsCalls.mjs +26 -20
- package/API/temporaryWalletCalls.cjs +1 -0
- package/API/temporaryWalletCalls.d.ts +13 -0
- package/API/temporaryWalletCalls.mjs +20 -0
- package/API/unspent-utxos-calls.cjs +1 -1
- package/API/unspent-utxos-calls.d.ts +1 -1
- package/API/unspent-utxos-calls.mjs +16 -14
- package/README.md +36 -13
- package/constants/chains.constants.cjs +1 -1
- package/constants/chains.constants.d.ts +1 -1
- package/constants/chains.constants.mjs +69 -51
- package/constants/deploy-data/deploy-data-solana.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-solana.json.mjs +28 -2
- package/constants/kyc.constants.cjs +1 -1
- package/constants/kyc.constants.mjs +39 -40
- package/constants/mediaUrls.constants.cjs +1 -1
- package/constants/mediaUrls.constants.d.ts +1 -0
- package/constants/mediaUrls.constants.mjs +2 -1
- package/constants/server.constants.cjs +1 -1
- package/constants/server.constants.d.ts +6 -1
- package/constants/server.constants.mjs +37 -32
- package/constants/token-data/polygonRegistry.json.cjs +1 -1
- package/constants/token-data/polygonRegistry.json.mjs +4 -4
- package/constants/token-data/polygonRegistryFixed.json.cjs +1 -1
- package/constants/token-data/polygonRegistryFixed.json.mjs +4 -4
- package/data-structures/AccountActions/AccountActions.cjs +1 -0
- package/data-structures/AccountActions/AccountActions.d.ts +18 -0
- package/data-structures/AccountActions/AccountActions.mjs +78 -0
- package/data-structures/AccountActions/index.d.ts +1 -0
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.cjs +1 -1
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.mjs +68 -71
- package/data-structures/BlockchainEvent/BlockchainEvent.cjs +1 -0
- package/data-structures/BlockchainEvent/BlockchainEvent.d.ts +14 -0
- package/data-structures/BlockchainEvent/BlockchainEvent.mjs +41 -0
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +14 -8
- package/data-structures/Hinkal/Hinkal.mjs +215 -179
- package/data-structures/Hinkal/IHinkal.d.ts +9 -6
- package/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.mjs +47 -48
- package/data-structures/Hinkal/hinkalActionReceive.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionReceive.mjs +25 -22
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -1
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +12 -12
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +63 -63
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +60 -147
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -0
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.d.ts +4 -0
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +103 -0
- package/data-structures/Hinkal/hinkalDepostAndBridge.cjs +1 -0
- package/data-structures/Hinkal/hinkalDepostAndBridge.d.ts +4 -0
- package/data-structures/Hinkal/hinkalDepostAndBridge.mjs +214 -0
- package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
- package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +4 -4
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.d.ts +2 -2
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +103 -99
- package/data-structures/Hinkal/hinkalProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxySwap.mjs +44 -41
- package/data-structures/Hinkal/hinkalProxyToPrivate.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxyToPrivate.mjs +31 -28
- package/data-structures/Hinkal/hinkalSignSubAccount.cjs +1 -1
- package/data-structures/Hinkal/hinkalSignSubAccount.mjs +16 -13
- package/data-structures/Hinkal/hinkalSolanaDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDeposit.mjs +34 -34
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +67 -65
- package/data-structures/Hinkal/hinkalSolanaProxySend.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySend.mjs +35 -32
- package/data-structures/Hinkal/hinkalSolanaProxyShield.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxyShield.mjs +59 -56
- package/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +35 -32
- package/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaSwap.mjs +10 -10
- package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +25 -25
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +34 -30
- package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalTransfer.mjs +43 -39
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +47 -43
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +50 -46
- package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.mjs +36 -34
- package/data-structures/IndexedDB/activity-db.cjs +1 -1
- package/data-structures/IndexedDB/activity-db.d.ts +1 -0
- package/data-structures/IndexedDB/activity-db.mjs +86 -70
- package/data-structures/IndexedDB/balances-db.cjs +1 -1
- package/data-structures/IndexedDB/balances-db.mjs +33 -30
- package/data-structures/IndexedDB/contact-db.cjs +1 -1
- package/data-structures/IndexedDB/contact-db.mjs +9 -6
- package/data-structures/PublicBalance/PublicBalanceWatcher.cjs +1 -0
- package/data-structures/PublicBalance/PublicBalanceWatcher.d.ts +20 -0
- package/data-structures/PublicBalance/PublicBalanceWatcher.mjs +124 -0
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.cjs +1 -0
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.d.ts +15 -0
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.mjs +64 -0
- package/data-structures/PublicBalance/index.d.ts +2 -0
- package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +77 -78
- package/data-structures/crypto-keys/keys.cjs +1 -1
- package/data-structures/crypto-keys/keys.d.ts +0 -11
- package/data-structures/crypto-keys/keys.mjs +47 -107
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.d.ts +3 -2
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.mjs +9 -9
- package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.d.ts +3 -2
- package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.mjs +5 -5
- package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.d.ts +3 -2
- package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.mjs +6 -6
- package/data-structures/event-service/evm/AbstractEventService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractEventService.d.ts +3 -2
- package/data-structures/event-service/evm/AbstractEventService.mjs +16 -19
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.d.ts +3 -3
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.mjs +6 -5
- package/data-structures/event-service/evm/AbstractSnapshotService.d.ts +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.d.ts +7 -4
- package/data-structures/event-service/evm/BlockchainEventEmitter.mjs +35 -34
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.cjs +1 -0
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.d.ts +11 -0
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.mjs +21 -0
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.cjs +1 -0
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.d.ts +6 -0
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.mjs +16 -0
- package/data-structures/event-service/helpers/ClientEventHelper.cjs +1 -0
- package/data-structures/event-service/helpers/ClientEventHelper.d.ts +11 -0
- package/data-structures/event-service/helpers/ClientEventHelper.mjs +26 -0
- package/data-structures/event-service/helpers/PollingEventHelper.cjs +1 -0
- package/data-structures/event-service/helpers/PollingEventHelper.d.ts +5 -0
- package/data-structures/event-service/helpers/PollingEventHelper.mjs +14 -0
- package/data-structures/event-service/index.d.ts +4 -0
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.d.ts +3 -2
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.mjs +6 -6
- package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.d.ts +4 -3
- package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.mjs +8 -8
- package/data-structures/event-service/solana/AbstractSolanaEventService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaEventService.d.ts +3 -10
- package/data-structures/event-service/solana/AbstractSolanaEventService.mjs +5 -5
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.d.ts +3 -2
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.mjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.d.ts +1 -1
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.cjs +1 -0
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.d.ts +11 -0
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.mjs +22 -0
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.cjs +1 -0
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.d.ts +6 -0
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.mjs +16 -0
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.d.ts +8 -14
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.mjs +68 -67
- package/data-structures/index.d.ts +3 -0
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.mjs +5 -2
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +5 -2
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.mjs +5 -2
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.mjs +5 -2
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.mjs +5 -2
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.mjs +5 -2
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.mjs +5 -2
- package/data-structures/utxo/Utxo.cjs +1 -1
- package/data-structures/utxo/Utxo.d.ts +1 -0
- package/data-structures/utxo/Utxo.mjs +18 -4
- package/error-handling/error-codes.constants.cjs +1 -1
- package/error-handling/error-codes.constants.mjs +2 -2
- package/functions/pre-transaction/getSolanaCalldataHash.cjs +1 -1
- package/functions/pre-transaction/getSolanaCalldataHash.mjs +22 -22
- package/functions/pre-transaction/sendV0Transaction.cjs +1 -1
- package/functions/pre-transaction/sendV0Transaction.mjs +53 -50
- package/functions/pre-transaction/solana.cjs +1 -1
- package/functions/pre-transaction/solana.mjs +93 -93
- package/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.helpers.d.ts +3 -2
- package/functions/private-wallet/emporium.helpers.mjs +118 -93
- package/functions/snarkjs/constructEmporiumProof.cjs +1 -1
- package/functions/snarkjs/constructEmporiumProof.d.ts +1 -2
- package/functions/snarkjs/constructEmporiumProof.mjs +89 -89
- package/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/functions/snarkjs/constructSolanaZkProof.mjs +6 -2
- package/functions/utils/bytes32.utils.cjs +1 -1
- package/functions/utils/bytes32.utils.mjs +8 -7
- package/functions/utils/create-provider.cjs +1 -1
- package/functions/utils/create-provider.d.ts +1 -1
- package/functions/utils/create-provider.mjs +13 -9
- package/functions/utils/index.d.ts +0 -1
- package/functions/utils/prepareHinkal.cjs +1 -1
- package/functions/utils/prepareHinkal.d.ts +6 -7
- package/functions/utils/prepareHinkal.mjs +45 -53
- package/functions/utils/publicBalance.utils.cjs +1 -1
- package/functions/utils/publicBalance.utils.mjs +49 -54
- package/functions/utils/socket.utils.cjs +1 -0
- package/functions/utils/socket.utils.d.ts +1 -0
- package/functions/utils/socket.utils.mjs +12 -0
- package/functions/utils/string.utils.cjs +1 -1
- package/functions/utils/string.utils.d.ts +1 -0
- package/functions/utils/string.utils.mjs +18 -14
- package/functions/utils/walletBalances.utils.cjs +1 -1
- package/functions/utils/walletBalances.utils.d.ts +1 -1
- package/functions/utils/walletBalances.utils.mjs +4 -4
- package/functions/web3/crypto.cjs +1 -0
- package/functions/web3/crypto.d.ts +1 -0
- package/functions/web3/crypto.mjs +7 -0
- package/functions/web3/events/getApprovedBalance.cjs +1 -1
- package/functions/web3/events/getApprovedBalance.mjs +14 -14
- package/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
- package/functions/web3/events/getInputUtxoAndBalance.mjs +61 -59
- package/functions/web3/events/getTransactionLogEvents.cjs +1 -1
- package/functions/web3/events/getTransactionLogEvents.mjs +32 -32
- package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +6 -3
- package/functions/web3/functionCalls/approveToken.cjs +1 -1
- package/functions/web3/functionCalls/approveToken.mjs +17 -17
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +16 -16
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.mjs +13 -11
- package/functions/web3/getContractMetadata.cjs +1 -1
- package/functions/web3/getContractMetadata.mjs +17 -22
- package/functions/web3/getTokenHolder.cjs +1 -1
- package/functions/web3/getTokenHolder.mjs +20 -20
- package/functions/web3/index.d.ts +1 -0
- package/index.cjs +1 -1
- package/index.mjs +913 -890
- package/package.json +3 -2
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.mjs +2 -5
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +11 -4
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +11 -4
- package/types/activities.types.d.ts +2 -0
- package/types/bridging-tx.types.d.ts +17 -0
- package/types/cache.types.cjs +1 -1
- package/types/cache.types.d.ts +5 -1
- package/types/cache.types.mjs +1 -1
- package/types/ethereum-network.types.d.ts +1 -0
- package/types/events.types.cjs +1 -0
- package/types/events.types.d.ts +9 -0
- package/types/events.types.mjs +5 -0
- package/types/index.d.ts +2 -0
- package/types/proxy.types.d.ts +11 -4
- package/types/sandbox.types.d.ts +2 -0
- package/types/solana.types.d.ts +8 -0
- package/types/token.types.d.ts +5 -0
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
- package/functions/kyc/authentoHelper.cjs +0 -1
- package/functions/kyc/authentoHelper.d.ts +0 -12
- package/functions/kyc/authentoHelper.mjs +0 -30
- package/functions/utils/get-hinkal-approvals.cjs +0 -1
- package/functions/utils/get-hinkal-approvals.d.ts +0 -3
- package/functions/utils/get-hinkal-approvals.mjs +0 -38
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("../../error-handling/error-codes.constants.cjs"),E=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("../../error-handling/error-codes.constants.cjs"),E=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),B=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),F=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),_=require("../../types/external-action.types.cjs"),R=require("../../types/hinkal.types.cjs"),M=require("../../functions/pre-transaction/outputApprovalDataProcessing.cjs"),W=require("../../functions/pre-transaction/getFeeStructure.cjs"),b=require("../../functions/pre-transaction/merge-with-fee-structure.cjs");require("../../types/circom-data.types.cjs");const K=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");const L=require("../../types/admin.types.cjs");require("../../types/activities.types.cjs");const H=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),N=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("../http/HttpClient.cjs");require("axios");require("../../constants/vite.constants.cjs");const $=require("../../functions/utils/amounts.utils.cjs");require("ethers");require("../../constants/token-data/index.cjs");require("../../constants/chains.constants.cjs");const O=require("../../functions/pre-transaction/constructAdminData.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");require("circomlibjs-hinkal-fork");require("@solana/spl-token");require("ethers-v6h");require("tweetnacl");require("bs58");require("buffer");require("../crypto-keys/keys.cjs");const G=require("../../functions/utils/time.utils.cjs"),Z=require("../../functions/web3/events/getInputUtxoAndBalance.cjs"),j=require("../../functions/web3/events/getShieldedBalance.cjs"),z=require("../../functions/utils/encodeTokenWithId.cjs"),V=require("../../API/unspent-utxos-calls.cjs"),Y=require("../../functions/utils/addresses.cjs"),I=require("../../functions/utils/token-check.utils.cjs"),J=async(t,e,A,d,n)=>{const s=[A.erc20TokenAddress],g=A.erc20TokenAddress,u=await W.getFeeStructure(e,g,s,_.ExternalActionId.Transact),q=d-u.flatFee;if(q<=0n)throw new Error(`Insufficient balance to cover fee. Balance: ${d}, Fee: ${u.flatFee}`);const r=[-q];b.mergeWithFeeStructure(e,s,r,u);const i={externalActionId:0n,externalAddress:n,externalActionMetadata:"0x00"},c=[...await j.addPaddingToUtxos(t,e,s,r,void 0,void 0,!1,!0)],o=`swapperM${r.length.toString()}x${c[0].length}x1`,l=R.defaultHinkalLogicArgs(r.length,t.userKeys),y=G.getCurrentTimeInSeconds().toString(),m=[];for(let a=0;a<s.length;a+=1){const{outputUtxos:P}=E.outputUtxoProcessing(t.userKeys,c[a],r[a],y,void 0,!1);m.push(P);const{useApprovalUtxoData:T}=M.outputApprovalDataProcessing(t,e,c[a],r[a]);T&&(l.useApprovalUtxoData[a]=T,l.doPreTxApproval=!0)}const x=await t.getRandomRelay(e,!0);if(!x)throw Error(D.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{patchAccessTokenMerkleTree:f,kycRequired:w,hasAccessToken:k}=await N.shouldPatchAccessTokenMerkleTree(t,e,s,r),h=await H.getSignatureDataForTransact(e,await t.getEthereumAddressByChain(e),t.userKeys,w,k),{zkCallData:v,circomData:U,dimData:C}=await B.constructZkProof("v1x1",t.merkleTreeHinkalByChain[e],t.merkleTreeAccessTokenByChain[e],c,m,t.userKeys,o,i.externalActionId,i.externalAddress,i.externalActionMetadata,t.generateProofRemotely,x,e,void 0,void 0,void 0,f,l,void 0,u,t.getContractWithFetcher(e,K.ContractType.HinkalHelperContract),h,void 0,!1),S=O.constructAdminData(L.AdminTransactionType.WithdrawOnChainUtxos,e,s,r,await t.getEthereumAddressByChain(e));return{tx:await F.transactCallRelayer(e,v,C,U,void 0,void 0,void 0,S),amountToRecipient:q}},Q=async(t,e,A)=>{const d=[],n=I.validateAndGetChainId([e]),s=z.encodeTokenWithId(n,{erc20TokenAddress:e.erc20TokenAddress,tokenId:0}),g=await t.getEthereumAddressByChain(n),u=Y.hashEthereumAddress(g);for(;;){const p=((await Z.getInputUtxoAndBalancePerToken({hinkal:t,sliceIfMore6:!1,useBlockedUtxos:!0,chainId:n}))?.get(s)??[]).filter(o=>o.amount>0n).slice(0,6).sort((o,l)=>Number(l.amount-o.amount)),r=$.countTotalAmountInUtxos(p);if(!r)break;const i=p.map(o=>o.nullifier).filter(o=>!!o),{tx:c}=await J(t,n,e,r,A);i.length>0&&await V.deleteUnspentUtxos(n,u,i),d.push(c)}return d};exports.hinkalWithdrawStuckUtxos=Q;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { transactionErrorCodes as P } from "../../error-handling/error-codes.constants.mjs";
|
|
2
|
-
import { outputUtxoProcessing as
|
|
3
|
-
import { constructZkProof as
|
|
4
|
-
import { transactCallRelayer as
|
|
2
|
+
import { outputUtxoProcessing as B } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
3
|
+
import { constructZkProof as R } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
4
|
+
import { transactCallRelayer as F } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
5
5
|
import { ExternalActionId as M } from "../../types/external-action.types.mjs";
|
|
6
6
|
import { defaultHinkalLogicArgs as K } from "../../types/hinkal.types.mjs";
|
|
7
7
|
import { outputApprovalDataProcessing as L } from "../../functions/pre-transaction/outputApprovalDataProcessing.mjs";
|
|
@@ -28,6 +28,10 @@ import "@coral-xyz/anchor";
|
|
|
28
28
|
import "@solana/web3.js";
|
|
29
29
|
import "circomlibjs-hinkal-fork";
|
|
30
30
|
import "@solana/spl-token";
|
|
31
|
+
import "ethers-v6h";
|
|
32
|
+
import "tweetnacl";
|
|
33
|
+
import "bs58";
|
|
34
|
+
import "buffer";
|
|
31
35
|
import "../crypto-keys/keys.mjs";
|
|
32
36
|
import { getCurrentTimeInSeconds as z } from "../../functions/utils/time.utils.mjs";
|
|
33
37
|
import { getInputUtxoAndBalancePerToken as G } from "../../functions/web3/events/getInputUtxoAndBalance.mjs";
|
|
@@ -35,10 +39,10 @@ import { addPaddingToUtxos as V } from "../../functions/web3/events/getShieldedB
|
|
|
35
39
|
import { encodeTokenWithId as Y } from "../../functions/utils/encodeTokenWithId.mjs";
|
|
36
40
|
import { deleteUnspentUtxos as Z } from "../../API/unspent-utxos-calls.mjs";
|
|
37
41
|
import { hashEthereumAddress as j } from "../../functions/utils/addresses.mjs";
|
|
38
|
-
import { validateAndGetChainId as
|
|
39
|
-
const
|
|
42
|
+
import { validateAndGetChainId as J } from "../../functions/utils/token-check.utils.mjs";
|
|
43
|
+
const Q = async (e, t, d, p, a) => {
|
|
40
44
|
const s = [d.erc20TokenAddress], f = d.erc20TokenAddress, i = await W(
|
|
41
|
-
|
|
45
|
+
t,
|
|
42
46
|
f,
|
|
43
47
|
s,
|
|
44
48
|
M.Transact
|
|
@@ -46,99 +50,99 @@ const J = async (t, e, d, p, n) => {
|
|
|
46
50
|
if (l <= 0n)
|
|
47
51
|
throw new Error(`Insufficient balance to cover fee. Balance: ${p}, Fee: ${i.flatFee}`);
|
|
48
52
|
const o = [-l];
|
|
49
|
-
H(
|
|
53
|
+
H(t, s, o, i);
|
|
50
54
|
const m = {
|
|
51
55
|
externalActionId: 0n,
|
|
52
|
-
externalAddress:
|
|
56
|
+
externalAddress: a,
|
|
53
57
|
externalActionMetadata: "0x00"
|
|
54
58
|
}, c = [
|
|
55
|
-
...await V(
|
|
56
|
-
], r = `swapperM${o.length.toString()}x${c[0].length}x1`, u = K(o.length,
|
|
57
|
-
for (let
|
|
58
|
-
const { outputUtxos: S } =
|
|
59
|
-
|
|
60
|
-
c[
|
|
61
|
-
o[
|
|
59
|
+
...await V(e, t, s, o, void 0, void 0, !1, !0)
|
|
60
|
+
], r = `swapperM${o.length.toString()}x${c[0].length}x1`, u = K(o.length, e.userKeys), w = z().toString(), x = [];
|
|
61
|
+
for (let n = 0; n < s.length; n += 1) {
|
|
62
|
+
const { outputUtxos: S } = B(
|
|
63
|
+
e.userKeys,
|
|
64
|
+
c[n],
|
|
65
|
+
o[n],
|
|
62
66
|
w,
|
|
63
67
|
void 0,
|
|
64
68
|
!1
|
|
65
69
|
);
|
|
66
70
|
x.push(S);
|
|
67
|
-
const { useApprovalUtxoData: T } = L(
|
|
68
|
-
T && (u.useApprovalUtxoData[
|
|
71
|
+
const { useApprovalUtxoData: T } = L(e, t, c[n], o[n]);
|
|
72
|
+
T && (u.useApprovalUtxoData[n] = T, u.doPreTxApproval = !0);
|
|
69
73
|
}
|
|
70
|
-
const g = await
|
|
74
|
+
const g = await e.getRandomRelay(t, !0);
|
|
71
75
|
if (!g)
|
|
72
76
|
throw Error(P.RELAYER_NOT_AVAILABLE);
|
|
73
|
-
const { patchAccessTokenMerkleTree:
|
|
74
|
-
t,
|
|
77
|
+
const { patchAccessTokenMerkleTree: y, kycRequired: v, hasAccessToken: U } = await O(
|
|
75
78
|
e,
|
|
79
|
+
t,
|
|
76
80
|
s,
|
|
77
81
|
o
|
|
78
|
-
),
|
|
79
|
-
|
|
80
|
-
await
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
), C = await N(
|
|
83
|
+
t,
|
|
84
|
+
await e.getEthereumAddressByChain(t),
|
|
85
|
+
e.userKeys,
|
|
86
|
+
v,
|
|
83
87
|
U
|
|
84
|
-
), { zkCallData:
|
|
88
|
+
), { zkCallData: k, circomData: h, dimData: E } = await R(
|
|
85
89
|
"v1x1",
|
|
86
|
-
|
|
87
|
-
|
|
90
|
+
e.merkleTreeHinkalByChain[t],
|
|
91
|
+
e.merkleTreeAccessTokenByChain[t],
|
|
88
92
|
c,
|
|
89
93
|
x,
|
|
90
|
-
|
|
94
|
+
e.userKeys,
|
|
91
95
|
r,
|
|
92
96
|
m.externalActionId,
|
|
93
97
|
m.externalAddress,
|
|
94
98
|
m.externalActionMetadata,
|
|
95
|
-
|
|
99
|
+
e.generateProofRemotely,
|
|
96
100
|
g,
|
|
97
|
-
|
|
101
|
+
t,
|
|
98
102
|
void 0,
|
|
99
103
|
void 0,
|
|
100
104
|
void 0,
|
|
101
|
-
|
|
105
|
+
y,
|
|
102
106
|
u,
|
|
103
107
|
void 0,
|
|
104
108
|
i,
|
|
105
|
-
|
|
106
|
-
|
|
109
|
+
e.getContractWithFetcher(t, $.HinkalHelperContract),
|
|
110
|
+
C,
|
|
107
111
|
void 0,
|
|
108
112
|
!1
|
|
109
113
|
), D = q(
|
|
110
114
|
b.WithdrawOnChainUtxos,
|
|
111
|
-
|
|
115
|
+
t,
|
|
112
116
|
s,
|
|
113
117
|
o,
|
|
114
|
-
await
|
|
118
|
+
await e.getEthereumAddressByChain(t)
|
|
115
119
|
);
|
|
116
|
-
return { tx: await
|
|
117
|
-
|
|
120
|
+
return { tx: await F(
|
|
121
|
+
t,
|
|
122
|
+
k,
|
|
118
123
|
E,
|
|
119
|
-
C,
|
|
120
124
|
h,
|
|
121
125
|
void 0,
|
|
122
126
|
void 0,
|
|
123
127
|
void 0,
|
|
124
128
|
D
|
|
125
129
|
), amountToRecipient: l };
|
|
126
|
-
},
|
|
127
|
-
const p = [],
|
|
130
|
+
}, Ot = async (e, t, d) => {
|
|
131
|
+
const p = [], a = J([t]), s = Y(a, { erc20TokenAddress: t.erc20TokenAddress, tokenId: 0 }), f = await e.getEthereumAddressByChain(a), i = j(f);
|
|
128
132
|
for (; ; ) {
|
|
129
133
|
const A = ((await G({
|
|
130
|
-
hinkal:
|
|
134
|
+
hinkal: e,
|
|
131
135
|
sliceIfMore6: !1,
|
|
132
136
|
useBlockedUtxos: !0,
|
|
133
|
-
chainId:
|
|
137
|
+
chainId: a
|
|
134
138
|
}))?.get(s) ?? []).filter((r) => r.amount > 0n).slice(0, 6).sort((r, u) => Number(u.amount - r.amount)), o = _(A);
|
|
135
139
|
if (!o)
|
|
136
140
|
break;
|
|
137
|
-
const m = A.map((r) => r.nullifier).filter((r) => !!r), { tx: c } = await
|
|
138
|
-
m.length > 0 && await Z(
|
|
141
|
+
const m = A.map((r) => r.nullifier).filter((r) => !!r), { tx: c } = await Q(e, a, t, o, d);
|
|
142
|
+
m.length > 0 && await Z(a, i, m), p.push(c);
|
|
139
143
|
}
|
|
140
144
|
return p;
|
|
141
145
|
};
|
|
142
146
|
export {
|
|
143
|
-
|
|
147
|
+
Ot as hinkalWithdrawStuckUtxos
|
|
144
148
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("../../constants/chains.constants.cjs");require("../../types/circom-data.types.cjs");const u=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");const P=require("../../types/balances.types.cjs"),T=require("../../types/events.types.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/vite.constants.cjs");require("../../error-handling/error-codes.constants.cjs");require("../../constants/save-depths.cjs");require("../../constants/reorg-depths.constants.cjs");const w=require("../event-service/evm/ClientBlockchainEventEmitter.cjs");require("@coral-xyz/anchor");const M=require("../event-service/solana/ClientSolanaBlockchainEventEmitter.cjs"),k=require("@solana/web3.js");require("../crypto-keys/keys.cjs");const A=require("../../functions/web3/events/balanceChangedCustomHandler.cjs"),f=require("../snapshot/SnapshotFetcherService.cjs"),x=require("../snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.cjs"),b=require("../snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.cjs"),_=require("../snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.cjs"),N=require("../snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs"),O=require("../snapshot/evm-snapshots/ClientCommitmentsSnapshotService.cjs"),R=require("../snapshot/evm-snapshots/ClientNullifierSnapshotService.cjs"),U=require("../snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs"),H=require("../../functions/utils/create-provider.cjs"),g=require("../../functions/utils/mutexes.utils.cjs"),L=async(t,E)=>{const m=E??t.getSupportedChains();m.forEach(e=>{t.commitmentsSnapshotServiceByChain[e]?.intervalClear(),t.nullifierSnapshotServiceByChain[e]?.intervalClear(),t.accessTokenSnapshotServiceByChain[e]?.intervalClear(),t.approvalsSnapshotServiceByChain[e]?.intervalClear()});const F=m.map(async e=>{const{maxPageSize:a,fetchRpcUrl:h,contractData:y}=q.networkRegistry[e];let r,c;if(q.isSolanaLike(e)){const n=y.hinkalAddress;if(!h||!n)throw new Error("Fetch RPC URL or Solana program ID is not set");const C=H.createCustomSolanaConnection(h),i=new k.PublicKey(n),s=g.getChainBalanceFetchingMutex(e);r=new M.ClientSolanaBlockchainEventEmitter(e,C,i,0,s,a);const B=y.hinkalIdl;B&&r.setIdl(B);const v=new f.SnapshotFetcherService(e,n);t.commitmentsSnapshotServiceByChain[e]=new x.ClientSolanaCommitmentsSnapshotService(r,v),t.nullifierSnapshotServiceByChain[e]=new b.ClientSolanaNullifierSnapshotService(r,v),t.accessTokenSnapshotServiceByChain[e]=new _.ClientSolanaAccessTokenSnapshotService(r,v),t.approvalsSnapshotServiceByChain[e]=void 0}else{const n=t.getContractWithFetcherByChainId(e,u.ContractType.HinkalContract),C=t.getContractWithFetcherByChainId(e,u.ContractType.DepositOnChainUtxos),i=g.getChainBalanceFetchingMutex(e);r=new w.ClientBlockchainEventEmitter(T.EventCategory.MainContractEvents,e,n,0,i,a,C),c=new w.ClientBlockchainEventEmitter(T.EventCategory.MainContractEvents,e,t.getContractWithFetcherByChainId(e,u.ContractType.AccessTokenContract),0,i,a);const s=new f.SnapshotFetcherService(e,n.address);t.commitmentsSnapshotServiceByChain[e]=new O.ClientCommitmentsSnapshotService(r,s),t.nullifierSnapshotServiceByChain[e]=new R.ClientNullifierSnapshotService(r,s),t.accessTokenSnapshotServiceByChain[e]=new N.ClientAccessTokenSnapshotService(c,s),t.approvalsSnapshotServiceByChain[e]=new U.ClientApprovalsSnapshotService(r,s)}const o=t.commitmentsSnapshotServiceByChain[e],l=t.nullifierSnapshotServiceByChain[e],S=t.accessTokenSnapshotServiceByChain[e],p=t.approvalsSnapshotServiceByChain[e];if(!o||!l||!S)throw new Error(`Missing snapshot service for chain ${e}`);await Promise.all([o.init(),l.init(),S.init(),p?.init()]),await Promise.all([r.init(),c?.init()]),t.merkleTreeHinkalByChain[e]=o.merkleTree,t.merkleTreeAccessTokenByChain[e]=S.merkleTree,t.nullifiersByChain[e]=l.nullifiers,t.encryptedOutputsByChain[e]=o.encryptedOutputs,p&&(t.approvalsByChain[e]=p.approvals),r.onEventsProcessed=n=>{n>0&&A.balanceChangedCustomHandler({updateType:P.PrivateBalanceUpdateType.FreshWithoutLoader,updateTokensListBefore:!0})}});await Promise.allSettled(F)};exports.resetMerkleTrees=L;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { networkRegistry as P, isSolanaLike as
|
|
1
|
+
import { networkRegistry as P, isSolanaLike as x } from "../../constants/chains.constants.mjs";
|
|
2
2
|
import "../../types/circom-data.types.mjs";
|
|
3
3
|
import { ContractType as v } from "../../types/ethereum-network.types.mjs";
|
|
4
4
|
import "../../types/transactions.types.mjs";
|
|
5
5
|
import "../../types/activities.types.mjs";
|
|
6
|
-
import { PrivateBalanceUpdateType as
|
|
6
|
+
import { PrivateBalanceUpdateType as M } from "../../types/balances.types.mjs";
|
|
7
|
+
import { EventCategory as u } from "../../types/events.types.mjs";
|
|
7
8
|
import "ethers";
|
|
8
9
|
import "circomlibjs-hinkal-fork";
|
|
9
10
|
import "libsodium-wrappers";
|
|
@@ -12,47 +13,48 @@ import "buffer";
|
|
|
12
13
|
import "../../constants/vite.constants.mjs";
|
|
13
14
|
import "../../error-handling/error-codes.constants.mjs";
|
|
14
15
|
import "../../constants/save-depths.mjs";
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
16
|
+
import "../../constants/reorg-depths.constants.mjs";
|
|
17
|
+
import { ClientBlockchainEventEmitter as w } from "../event-service/evm/ClientBlockchainEventEmitter.mjs";
|
|
18
|
+
import "@coral-xyz/anchor";
|
|
19
|
+
import { ClientSolanaBlockchainEventEmitter as A } from "../event-service/solana/ClientSolanaBlockchainEventEmitter.mjs";
|
|
17
20
|
import { PublicKey as R } from "@solana/web3.js";
|
|
18
21
|
import "../crypto-keys/keys.mjs";
|
|
19
22
|
import { balanceChangedCustomHandler as U } from "../../functions/web3/events/balanceChangedCustomHandler.mjs";
|
|
20
23
|
import { SnapshotFetcherService as T } from "../snapshot/SnapshotFetcherService.mjs";
|
|
21
|
-
import { ClientSolanaCommitmentsSnapshotService as
|
|
24
|
+
import { ClientSolanaCommitmentsSnapshotService as L } from "../snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.mjs";
|
|
22
25
|
import { ClientSolanaNullifierSnapshotService as O } from "../snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.mjs";
|
|
23
26
|
import { ClientSolanaAccessTokenSnapshotService as W } from "../snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.mjs";
|
|
24
27
|
import { ClientAccessTokenSnapshotService as D } from "../snapshot/evm-snapshots/ClientAccessTokenSnapshotService.mjs";
|
|
25
28
|
import { ClientCommitmentsSnapshotService as H } from "../snapshot/evm-snapshots/ClientCommitmentsSnapshotService.mjs";
|
|
26
|
-
import { ClientNullifierSnapshotService as
|
|
27
|
-
import { ClientApprovalsSnapshotService as
|
|
28
|
-
import { createCustomSolanaConnection as
|
|
29
|
-
import { getChainBalanceFetchingMutex as
|
|
30
|
-
const
|
|
31
|
-
const f =
|
|
29
|
+
import { ClientNullifierSnapshotService as b } from "../snapshot/evm-snapshots/ClientNullifierSnapshotService.mjs";
|
|
30
|
+
import { ClientApprovalsSnapshotService as k } from "../snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs";
|
|
31
|
+
import { createCustomSolanaConnection as K } from "../../functions/utils/create-provider.mjs";
|
|
32
|
+
import { getChainBalanceFetchingMutex as g } from "../../functions/utils/mutexes.utils.mjs";
|
|
33
|
+
const Be = async (t, E) => {
|
|
34
|
+
const f = E ?? t.getSupportedChains();
|
|
32
35
|
f.forEach((e) => {
|
|
33
36
|
t.commitmentsSnapshotServiceByChain[e]?.intervalClear(), t.nullifierSnapshotServiceByChain[e]?.intervalClear(), t.accessTokenSnapshotServiceByChain[e]?.intervalClear(), t.approvalsSnapshotServiceByChain[e]?.intervalClear();
|
|
34
37
|
});
|
|
35
|
-
const
|
|
38
|
+
const F = f.map(async (e) => {
|
|
36
39
|
const { maxPageSize: a, fetchRpcUrl: y, contractData: B } = P[e];
|
|
37
40
|
let o, p;
|
|
38
|
-
if (
|
|
41
|
+
if (x(e)) {
|
|
39
42
|
const r = B.hinkalAddress;
|
|
40
43
|
if (!y || !r)
|
|
41
44
|
throw new Error("Fetch RPC URL or Solana program ID is not set");
|
|
42
|
-
const l =
|
|
43
|
-
o = new
|
|
45
|
+
const l = K(y), s = new R(r), n = g(e);
|
|
46
|
+
o = new A(
|
|
44
47
|
e,
|
|
45
48
|
l,
|
|
46
|
-
|
|
49
|
+
s,
|
|
47
50
|
0,
|
|
48
|
-
!1,
|
|
49
51
|
n,
|
|
50
52
|
a
|
|
51
53
|
);
|
|
52
54
|
const h = B.hinkalIdl;
|
|
53
55
|
h && o.setIdl(h);
|
|
54
56
|
const C = new T(e, r);
|
|
55
|
-
t.commitmentsSnapshotServiceByChain[e] = new
|
|
57
|
+
t.commitmentsSnapshotServiceByChain[e] = new L(
|
|
56
58
|
o,
|
|
57
59
|
C
|
|
58
60
|
), t.nullifierSnapshotServiceByChain[e] = new O(
|
|
@@ -66,55 +68,55 @@ const ve = async (t, g) => {
|
|
|
66
68
|
const r = t.getContractWithFetcherByChainId(e, v.HinkalContract), l = t.getContractWithFetcherByChainId(
|
|
67
69
|
e,
|
|
68
70
|
v.DepositOnChainUtxos
|
|
69
|
-
),
|
|
70
|
-
o = new
|
|
71
|
+
), s = g(e);
|
|
72
|
+
o = new w(
|
|
73
|
+
u.MainContractEvents,
|
|
71
74
|
e,
|
|
72
75
|
r,
|
|
73
76
|
0,
|
|
74
|
-
|
|
75
|
-
i,
|
|
77
|
+
s,
|
|
76
78
|
a,
|
|
77
79
|
l
|
|
78
|
-
), p = new
|
|
80
|
+
), p = new w(
|
|
81
|
+
u.MainContractEvents,
|
|
79
82
|
e,
|
|
80
83
|
t.getContractWithFetcherByChainId(e, v.AccessTokenContract),
|
|
81
84
|
0,
|
|
82
|
-
|
|
83
|
-
i,
|
|
85
|
+
s,
|
|
84
86
|
a
|
|
85
87
|
);
|
|
86
88
|
const n = new T(e, r.address);
|
|
87
89
|
t.commitmentsSnapshotServiceByChain[e] = new H(
|
|
88
90
|
o,
|
|
89
91
|
n
|
|
90
|
-
), t.nullifierSnapshotServiceByChain[e] = new
|
|
92
|
+
), t.nullifierSnapshotServiceByChain[e] = new b(
|
|
91
93
|
o,
|
|
92
94
|
n
|
|
93
95
|
), t.accessTokenSnapshotServiceByChain[e] = new D(
|
|
94
96
|
p,
|
|
95
97
|
n
|
|
96
|
-
), t.approvalsSnapshotServiceByChain[e] = new
|
|
98
|
+
), t.approvalsSnapshotServiceByChain[e] = new k(
|
|
97
99
|
o,
|
|
98
100
|
n
|
|
99
101
|
);
|
|
100
102
|
}
|
|
101
|
-
const
|
|
102
|
-
if (!
|
|
103
|
+
const i = t.commitmentsSnapshotServiceByChain[e], m = t.nullifierSnapshotServiceByChain[e], c = t.accessTokenSnapshotServiceByChain[e], S = t.approvalsSnapshotServiceByChain[e];
|
|
104
|
+
if (!i || !m || !c)
|
|
103
105
|
throw new Error(`Missing snapshot service for chain ${e}`);
|
|
104
106
|
await Promise.all([
|
|
105
|
-
|
|
107
|
+
i.init(),
|
|
106
108
|
m.init(),
|
|
107
109
|
c.init(),
|
|
108
110
|
S?.init()
|
|
109
|
-
]), await Promise.all([o.init(), p?.init()]), t.merkleTreeHinkalByChain[e] =
|
|
111
|
+
]), await Promise.all([o.init(), p?.init()]), t.merkleTreeHinkalByChain[e] = i.merkleTree, t.merkleTreeAccessTokenByChain[e] = c.merkleTree, t.nullifiersByChain[e] = m.nullifiers, t.encryptedOutputsByChain[e] = i.encryptedOutputs, S && (t.approvalsByChain[e] = S.approvals), o.onEventsProcessed = (r) => {
|
|
110
112
|
r > 0 && U({
|
|
111
|
-
updateType:
|
|
113
|
+
updateType: M.FreshWithoutLoader,
|
|
112
114
|
updateTokensListBefore: !0
|
|
113
115
|
});
|
|
114
116
|
};
|
|
115
117
|
});
|
|
116
|
-
await Promise.allSettled(
|
|
118
|
+
await Promise.allSettled(F);
|
|
117
119
|
};
|
|
118
120
|
export {
|
|
119
|
-
|
|
121
|
+
Be as resetMerkleTrees
|
|
120
122
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("idb-keyval"),y=require("ethers");require("../../types/circom-data.types.cjs");const p=require("../../constants/protocol.constants.cjs");require("../../types/transactions.types.cjs");const m=require("../../types/activities.types.cjs"),g=require("../../types/cache.types.cjs");require("../../constants/token-data/index.cjs");const _=require("../../constants/chains.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/server.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/coingecko.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("@coral-xyz/anchor");require("@solana/web3.js");const b=require("../../functions/utils/amounts.utils.cjs");require("circomlibjs-hinkal-fork");require("../http/HttpClient.cjs");const N=require("../../error-handling/logger.cjs"),C=require("../../functions/utils/erc20tokenFunctions.cjs");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");const F=require("../../functions/web3/etherFunctions.cjs");require("../crypto-keys/keys.cjs");require("../../error-handling/error-codes.constants.cjs");require("../../API/getServerURL.cjs");require("axios");require("@solana/spl-token");require("ethers-v6h");require("tweetnacl");require("bs58");require("buffer");require("../../functions/utils/userAgent.cjs");require("libsodium-wrappers");require("multiformats");const H=require("../../API/API.cjs");require("async-mutex");require("process");require("../../providers/EthersProviderAdapter.cjs");require("../../functions/web3/events/getInputUtxoAndBalance.cjs");require("../../functions/web3/events/getApprovedBalance.cjs");require("../../functions/web3/getTokenHolder.cjs");require("node-forge");class E{generateTxId(){const e=new Date().getTime(),r=Math.random().toString(36).substring(2,15);return`tx_${e}_${r}`}async getTransactionRecord(){return await c.get(g.StorageKeys.TX_ACTIVITY)||{}}async saveTxRequest(e){const{from:r,to:t,gas:i,gasPrice:n,gasInDollar:s,extraNativeTokenFee:o,value:u,chainId:a,status:q,txHash:l,activityType:d,tokensReceive:h,tokensSpend:I,tokensApprove:A,ownerPublicAddress:w,activityIcon:S,dappUrl:x,dappName:f,integrationProvider:D,knownPartialSignature:k}=e,T=this.generateTxId(),P={id:T,from:r,to:t,gas:i,gasPrice:n,gasInDollar:s?.toString(),extraNativeTokenFee:o?.toString(),value:u,chainId:a,txHash:l,activityType:d,status:q??m.ActivityStatus.PENDING,timestamp:new Date,tokensReceive:h,tokensSpend:I,tokensApprove:A,ownerPublicAddress:w,activityIcon:S,dappUrl:x,dappName:f,integrationProvider:D,knownPartialSignature:k};return await c.update(g.StorageKeys.TX_ACTIVITY,(v={})=>(v[T]=P,v)),T}async getTxRequest(e){return(await this.getTransactionRecord())[e]||null}async getAllTxRequests(e){const r=await this.getTransactionRecord();return Object.values(r).filter(t=>t.chainId===e).sort((t,i)=>new Date(i.timestamp).getTime()-new Date(t.timestamp).getTime())}async updateTxHash(e,r){const t=await this.getTxRequest(e);if(!t)throw new Error("Activity not found");const i={...t,txHash:r};await c.update(g.StorageKeys.TX_ACTIVITY,(n={})=>(n[e]=i,n))}async updateTxStatusAndHash(e,r,t,i,n,s,o,u){const a=await this.getTxRequest(e);if(!a)throw new Error("Transaction not found");const q=await this.getGasInDollar(o,u,a.chainId),l={...a,status:r,txHash:t,value:a.value??i,from:a.from??n,to:a.to??s,gas:o,gasPrice:u,gasInDollar:a.gasInDollar??q?.toString(),timestamp:new Date};return await c.update(g.StorageKeys.TX_ACTIVITY,(d={})=>(d[e]=l,d)),l}async updateActivity(e,r,t,i,n,s,o,u){try{await this.updateTxStatusAndHash(e,r,t,i,n,s,o,u)}catch(a){console.log("error in updating tx request",a)}}async removePendingTransactions(e){try{await c.update(g.StorageKeys.TX_ACTIVITY,(r={})=>(delete r[e],r))}catch(r){console.log("error in deleting tx requests",r)}}async updatePendingTransactions(e,r){try{if(!e.success){await this.updateActivity(r,m.ActivityStatus.FAILED,"erroredTx"in e?e.erroredTx?.transactionHash:void 0);return}if("tx"in e){const{tx:t}=e;await this.updateActivity(r,m.ActivityStatus.SUCCESSFUL,t.hash,y.BigNumber.from(t.value??0n).toHexString(),t.from,t.to,y.BigNumber.from(t.gas??0n),y.BigNumber.from(t.gasPrice??0n))}}catch(t){console.log("error in updating pending transactions",t)}}getGasInDollar=async(e,r,t)=>{if(!(!e||!r))try{const i=_.isSolanaLike(t)?p.solanaNativeAddress:p.zeroAddress,n=C.getERC20Token(i,t);if(!n)return;const{prices:s}=await H.API.getTokenPrices(t,[n.erc20TokenAddress]),o=s[0];if(!o)return;const a=o*Number(F.getAmountInToken(n,r.toBigInt()))*Number(e.toBigInt());return b.fixDecimalsAmount(a)}catch(i){N.Logger.error("Failed to calculate gas cost in dollars:",{chainId:t,error:i});return}}}const K=new E;exports.activityStorage=K;
|
|
@@ -5,6 +5,7 @@ declare class ActivityStorage {
|
|
|
5
5
|
saveTxRequest(txRequest: ActivityAddRequest): Promise<string>;
|
|
6
6
|
getTxRequest(id: string): Promise<Activity>;
|
|
7
7
|
getAllTxRequests(chainId: number): Promise<Activity[]>;
|
|
8
|
+
updateTxHash(activityId: string, newTxHash: string): Promise<void>;
|
|
8
9
|
private updateTxStatusAndHash;
|
|
9
10
|
private updateActivity;
|
|
10
11
|
removePendingTransactions(pendingActivityId: string): Promise<void>;
|