@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 u=require("../../constants/chains.constants.cjs");require("../../types/circom-data.types.cjs");const S=require("../../types/ethereum-network.types.cjs");require("../../types/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../../constants/chains.constants.cjs");require("../../types/circom-data.types.cjs");const S=require("../../types/ethereum-network.types.cjs");require("../../types/activities.types.cjs");const h=require("../../types/balances.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");const m=require("../event-service/evm/BlockchainEventEmitter.cjs"),d=require("../event-service/solana/SolanaBlockchainEventEmitter.cjs"),q=require("@solana/web3.js");require("../crypto-keys/keys.cjs");const T=require("../../functions/web3/events/balanceChangedCustomHandler.cjs"),C=require("../snapshot/SnapshotFetcherService.cjs"),f=require("../snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.cjs"),w=require("../snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.cjs"),g=require("../snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.cjs"),E=require("../snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs"),y=require("../snapshot/evm-snapshots/ClientCommitmentsSnapshotService.cjs"),A=require("../snapshot/evm-snapshots/ClientNullifierSnapshotService.cjs"),F=require("../snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs"),P=require("../../functions/utils/create-provider.cjs"),I=require("../../functions/utils/getContractAddress.cjs"),b=async e=>{const o=e.getCurrentChainId(),{maxPageSize:s,fetchRpcUrl:p,contractData:l}=u.networkRegistry[e.getCurrentChainId()];e.commitmentsSnapshotService?.intervalClear(),e.nullifierSnapshotService?.intervalClear(),e.accessTokenSnapshotService?.intervalClear(),e.approvalsSnapshotService?.intervalClear();let t,i;if(u.isSolanaLike(o)){const r=l.hinkalAddress;if(!p||!r)throw new Error("Fetch RPC URL or Solana program ID is not set");const c=P.createCustomSolanaConnection(p),n=new q.PublicKey(r);t=new d.SolanaBlockchainEventEmitter(c,n,0,!1,s);const v=l.hinkalIdl;v&&t.setIdl(v);const a=new C.SnapshotFetcherService(o,r);e.commitmentsSnapshotService=new f.ClientSolanaCommitmentsSnapshotService(t,a),e.nullifierSnapshotService=new w.ClientSolanaNullifierSnapshotService(t,a),e.accessTokenSnapshotService=new g.ClientSolanaAccessTokenSnapshotService(t,a),e.approvalsSnapshotService=void 0}else{const r=e.getContractWithFetcher(S.ContractType.HinkalContract),c=e.getContractWithFetcher(S.ContractType.DepositOnChainUtxos);t=new m.BlockchainEventEmitter(r,0,!1,s,c),i=new m.BlockchainEventEmitter(e.getContractWithFetcher(S.ContractType.AccessTokenContract),0,!1,s);const n=new C.SnapshotFetcherService(o,I.getContractAddress(r));e.commitmentsSnapshotService=new y.ClientCommitmentsSnapshotService(t,n),e.nullifierSnapshotService=new A.ClientNullifierSnapshotService(t,n),e.accessTokenSnapshotService=new E.ClientAccessTokenSnapshotService(i,n),e.approvalsSnapshotService=new F.ClientApprovalsSnapshotService(t,n)}await Promise.all([e.commitmentsSnapshotService.init(),e.nullifierSnapshotService.init(),e.accessTokenSnapshotService.init(),e.approvalsSnapshotService?.init()]),await Promise.all([t.init(),i?.init()]),e.merkleTreeHinkal=e.commitmentsSnapshotService.merkleTree,e.merkleTreeAccessToken=e.accessTokenSnapshotService.merkleTree,e.nullifiers=e.nullifierSnapshotService.nullifiers,e.encryptedOutputs=e.commitmentsSnapshotService.encryptedOutputs,e.approvalsSnapshotService&&(e.approvals=e.approvalsSnapshotService.approvals),t.onEventsProcessed=r=>{r>0&&T.balanceChangedCustomHandler({updateType:h.PrivateBalanceUpdateType.FreshWithoutLoader,updateTokensListBefore:!0})}};exports.resetMerkleTrees=b;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { networkRegistry as C, isSolanaLike as h } from "../../constants/chains.constants.mjs";
|
|
2
2
|
import "../../types/circom-data.types.mjs";
|
|
3
3
|
import { ContractType as p } from "../../types/ethereum-network.types.mjs";
|
|
4
|
-
import "../../types/transactions.types.mjs";
|
|
5
4
|
import "../../types/activities.types.mjs";
|
|
6
5
|
import { PrivateBalanceUpdateType as u } from "../../types/balances.types.mjs";
|
|
7
6
|
import "ethers";
|
|
@@ -26,7 +25,8 @@ import { ClientCommitmentsSnapshotService as I } from "../snapshot/evm-snapshots
|
|
|
26
25
|
import { ClientNullifierSnapshotService as P } from "../snapshot/evm-snapshots/ClientNullifierSnapshotService.mjs";
|
|
27
26
|
import { ClientApprovalsSnapshotService as A } from "../snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs";
|
|
28
27
|
import { createCustomSolanaConnection as U } from "../../functions/utils/create-provider.mjs";
|
|
29
|
-
|
|
28
|
+
import { getContractAddress as x } from "../../functions/utils/getContractAddress.mjs";
|
|
29
|
+
const ne = async (e) => {
|
|
30
30
|
const n = e.getCurrentChainId(), { maxPageSize: i, fetchRpcUrl: m, contractData: S } = C[e.getCurrentChainId()];
|
|
31
31
|
e.commitmentsSnapshotService?.intervalClear(), e.nullifierSnapshotService?.intervalClear(), e.accessTokenSnapshotService?.intervalClear(), e.approvalsSnapshotService?.intervalClear();
|
|
32
32
|
let t, s;
|
|
@@ -34,21 +34,21 @@ const oe = async (e) => {
|
|
|
34
34
|
const r = S.hinkalAddress;
|
|
35
35
|
if (!m || !r)
|
|
36
36
|
throw new Error("Fetch RPC URL or Solana program ID is not set");
|
|
37
|
-
const
|
|
38
|
-
t = new d(
|
|
37
|
+
const c = U(m), o = new T(r);
|
|
38
|
+
t = new d(c, o, 0, !1, i);
|
|
39
39
|
const l = S.hinkalIdl;
|
|
40
40
|
l && t.setIdl(l);
|
|
41
|
-
const
|
|
42
|
-
e.commitmentsSnapshotService = new g(t,
|
|
41
|
+
const a = new f(n, r);
|
|
42
|
+
e.commitmentsSnapshotService = new g(t, a), e.nullifierSnapshotService = new E(t, a), e.accessTokenSnapshotService = new y(t, a), e.approvalsSnapshotService = void 0;
|
|
43
43
|
} else {
|
|
44
|
-
const r = e.getContractWithFetcher(p.HinkalContract),
|
|
45
|
-
t = new v(r, 0, !1, i,
|
|
44
|
+
const r = e.getContractWithFetcher(p.HinkalContract), c = e.getContractWithFetcher(p.DepositOnChainUtxos);
|
|
45
|
+
t = new v(r, 0, !1, i, c), s = new v(
|
|
46
46
|
e.getContractWithFetcher(p.AccessTokenContract),
|
|
47
47
|
0,
|
|
48
48
|
!1,
|
|
49
49
|
i
|
|
50
50
|
);
|
|
51
|
-
const o = new f(n, r
|
|
51
|
+
const o = new f(n, x(r));
|
|
52
52
|
e.commitmentsSnapshotService = new I(t, o), e.nullifierSnapshotService = new P(t, o), e.accessTokenSnapshotService = new F(s, o), e.approvalsSnapshotService = new A(t, o);
|
|
53
53
|
}
|
|
54
54
|
await Promise.all([
|
|
@@ -64,5 +64,5 @@ const oe = async (e) => {
|
|
|
64
64
|
};
|
|
65
65
|
};
|
|
66
66
|
export {
|
|
67
|
-
|
|
67
|
+
ne as resetMerkleTrees
|
|
68
68
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("idb-keyval");require("../../types/circom-data.types.cjs");const m=require("../../constants/protocol.constants.cjs"),y=require("../../types/activities.types.cjs"),g=require("../../types/cache.types.cjs");require("../../constants/token-data/index.cjs");const f=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");require("ethers");const k=require("../../functions/utils/amounts.utils.cjs");require("circomlibjs-hinkal-fork");require("../http/HttpClient.cjs");const P=require("../../error-handling/logger.cjs"),_=require("../../functions/utils/erc20tokenFunctions.cjs");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");const b=require("../../functions/web3/etherFunctions.cjs");require("../crypto-keys/keys.cjs");require("../../error-handling/error-codes.constants.cjs");require("axios");require("../../API/getServerURL.cjs");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/save-depths.cjs");require("../../functions/utils/mutexes.utils.cjs");require("@solana/spl-token");require("../../functions/utils/userAgent.cjs");require("multiformats");const C=require("../../API/API.cjs");require("../../API/tenderly.api.cjs");require("node-forge");require("../../functions/web3/events/getApprovedBalance.cjs");require("../../functions/web3/getTokenHolder.cjs");class N{generateTxId(){const e=new Date().getTime(),t=Math.random().toString(36).substring(2,15);return`tx_${e}_${t}`}async getTransactionRecord(){return await d.get(g.StorageKeys.TX_ACTIVITY)||{}}async saveTxRequest(e){const{from:t,to:r,gas:a,gasPrice:n,gasInDollar:o,value:s,chainId:u,status:i,txHash:q,activityType:c,tokensReceive:l,tokensSpend:p,tokensApprove:I,ownerPublicAddress:A,activityIcon:h,dappUrl:S,dappName:w,integrationProvider:D}=e,T=this.generateTxId(),x={id:T,from:t,to:r,gas:a,gasPrice:n,gasInDollar:o?.toString(),value:s,chainId:u,txHash:q,activityType:c,status:i??y.ActivityStatus.PENDING,timestamp:new Date,tokensReceive:l,tokensSpend:p,tokensApprove:I,ownerPublicAddress:A,activityIcon:h,dappUrl:S,dappName:w,integrationProvider:D};return await d.update(g.StorageKeys.TX_ACTIVITY,(v={})=>(v[T]=x,v)),T}async getTxRequest(e){return(await this.getTransactionRecord())[e]||null}async getAllTxRequests(e){const t=await this.getTransactionRecord();return Object.values(t).filter(r=>r.chainId===e).sort((r,a)=>new Date(a.timestamp).getTime()-new Date(r.timestamp).getTime())}async updateTxStatusAndHash(e,t,r,a,n,o,s,u){const i=await this.getTxRequest(e);if(!i)throw new Error("Transaction not found");const q=await this.getGasInDollar(s,u,i.chainId),c={...i,status:t,txHash:r,value:i.value??a,from:i.from??n,to:i.to??o,gas:s,gasPrice:u,gasInDollar:i.gasInDollar??q?.toString(),timestamp:new Date};return await d.update(g.StorageKeys.TX_ACTIVITY,(l={})=>(l[e]=c,l)),c}async updateActivity(e,t,r,a,n,o,s,u){try{await this.updateTxStatusAndHash(e,t,r,a,n,o,s,u)}catch(i){console.log("error in updating tx request",i)}}async removePendingTransactions(e){try{await d.update(g.StorageKeys.TX_ACTIVITY,(t={})=>(delete t[e],t))}catch(t){console.log("error in deleting tx requests",t)}}async updatePendingTransactions(e,t){try{if(!e.success){await this.updateActivity(t,y.ActivityStatus.FAILED,"erroredTx"in e?e.erroredTx?.transactionHash:void 0);return}if("tx"in e){const{tx:r}=e;await this.updateActivity(t,y.ActivityStatus.SUCCESSFUL,r.hash,(r.value??0n).toString(),r.from,r.to,r.gas??0n,r.gasPrice??0n)}}catch(r){console.log("error in updating pending transactions",r)}}getGasInDollar=async(e,t,r)=>{if(!(!e||!t))try{const a=f.isSolanaLike(r)?m.solanaNativeAddress:m.zeroAddress,n=_.getERC20Token(a,r);if(!n)return;const{prices:o}=await C.API.getTokenPrices(r,[n.erc20TokenAddress]),s=o[0];if(!s)return;const i=s*Number(b.getAmountInToken(n,t))*Number(e);return k.fixDecimalsAmount(i)}catch(a){P.Logger.error("Failed to calculate gas cost in dollars:",{chainId:r,error:a});return}}}const E=new N;exports.activityStorage=E;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { get as
|
|
2
|
-
import { BigNumber as T } from "ethers";
|
|
1
|
+
import { get as S, update as g } from "idb-keyval";
|
|
3
2
|
import "../../types/circom-data.types.mjs";
|
|
4
|
-
import { solanaNativeAddress as
|
|
5
|
-
import "../../types/
|
|
6
|
-
import { ActivityStatus as f } from "../../types/activities.types.mjs";
|
|
3
|
+
import { solanaNativeAddress as k, zeroAddress as P } from "../../constants/protocol.constants.mjs";
|
|
4
|
+
import { ActivityStatus as T } from "../../types/activities.types.mjs";
|
|
7
5
|
import { StorageKeys as l } from "../../types/cache.types.mjs";
|
|
8
6
|
import "../../constants/token-data/index.mjs";
|
|
9
|
-
import { isSolanaLike as
|
|
7
|
+
import { isSolanaLike as C } from "../../constants/chains.constants.mjs";
|
|
10
8
|
import "../../constants/contracts.constants.mjs";
|
|
11
9
|
import "../../constants/kyc.constants.mjs";
|
|
12
10
|
import "../../constants/server.constants.mjs";
|
|
@@ -21,13 +19,14 @@ import "../../constants/tasks.constants.mjs";
|
|
|
21
19
|
import "../../constants/events.constants.mjs";
|
|
22
20
|
import "@coral-xyz/anchor";
|
|
23
21
|
import "@solana/web3.js";
|
|
24
|
-
import
|
|
22
|
+
import "ethers";
|
|
23
|
+
import { fixDecimalsAmount as q } from "../../functions/utils/amounts.utils.mjs";
|
|
25
24
|
import "circomlibjs-hinkal-fork";
|
|
26
25
|
import "../http/HttpClient.mjs";
|
|
27
|
-
import { Logger as
|
|
26
|
+
import { Logger as N } from "../../error-handling/logger.mjs";
|
|
28
27
|
import { getERC20Token as _ } from "../../functions/utils/erc20tokenFunctions.mjs";
|
|
29
28
|
import "../../functions/utils/convertIntegrationProviderToExternalActionId.mjs";
|
|
30
|
-
import { getAmountInToken as
|
|
29
|
+
import { getAmountInToken as b } from "../../functions/web3/etherFunctions.mjs";
|
|
31
30
|
import "../crypto-keys/keys.mjs";
|
|
32
31
|
import "../../error-handling/error-codes.constants.mjs";
|
|
33
32
|
import "axios";
|
|
@@ -40,19 +39,18 @@ import "../../functions/utils/mutexes.utils.mjs";
|
|
|
40
39
|
import "@solana/spl-token";
|
|
41
40
|
import "../../functions/utils/userAgent.mjs";
|
|
42
41
|
import "multiformats";
|
|
43
|
-
import { API as
|
|
42
|
+
import { API as E } from "../../API/API.mjs";
|
|
44
43
|
import "../../API/tenderly.api.mjs";
|
|
45
44
|
import "node-forge";
|
|
46
45
|
import "../../functions/web3/events/getApprovedBalance.mjs";
|
|
47
46
|
import "../../functions/web3/getTokenHolder.mjs";
|
|
48
|
-
import "ethers-v6h";
|
|
49
47
|
class R {
|
|
50
48
|
generateTxId() {
|
|
51
49
|
const t = (/* @__PURE__ */ new Date()).getTime(), o = Math.random().toString(36).substring(2, 15);
|
|
52
50
|
return `tx_${t}_${o}`;
|
|
53
51
|
}
|
|
54
52
|
async getTransactionRecord() {
|
|
55
|
-
return await
|
|
53
|
+
return await S(l.TX_ACTIVITY) || {};
|
|
56
54
|
}
|
|
57
55
|
async saveTxRequest(t) {
|
|
58
56
|
const {
|
|
@@ -67,14 +65,14 @@ class R {
|
|
|
67
65
|
txHash: u,
|
|
68
66
|
activityType: c,
|
|
69
67
|
tokensReceive: p,
|
|
70
|
-
tokensSpend:
|
|
71
|
-
tokensApprove:
|
|
72
|
-
ownerPublicAddress:
|
|
73
|
-
activityIcon:
|
|
74
|
-
dappUrl:
|
|
75
|
-
dappName:
|
|
76
|
-
integrationProvider:
|
|
77
|
-
} = t, d = this.generateTxId(),
|
|
68
|
+
tokensSpend: I,
|
|
69
|
+
tokensApprove: f,
|
|
70
|
+
ownerPublicAddress: y,
|
|
71
|
+
activityIcon: w,
|
|
72
|
+
dappUrl: A,
|
|
73
|
+
dappName: h,
|
|
74
|
+
integrationProvider: x
|
|
75
|
+
} = t, d = this.generateTxId(), D = {
|
|
78
76
|
id: d,
|
|
79
77
|
from: o,
|
|
80
78
|
to: r,
|
|
@@ -85,18 +83,18 @@ class R {
|
|
|
85
83
|
chainId: m,
|
|
86
84
|
txHash: u,
|
|
87
85
|
activityType: c,
|
|
88
|
-
status: e ??
|
|
86
|
+
status: e ?? T.PENDING,
|
|
89
87
|
timestamp: /* @__PURE__ */ new Date(),
|
|
90
88
|
tokensReceive: p,
|
|
91
|
-
tokensSpend:
|
|
92
|
-
tokensApprove:
|
|
93
|
-
ownerPublicAddress:
|
|
94
|
-
activityIcon:
|
|
95
|
-
dappUrl:
|
|
96
|
-
dappName:
|
|
97
|
-
integrationProvider:
|
|
89
|
+
tokensSpend: I,
|
|
90
|
+
tokensApprove: f,
|
|
91
|
+
ownerPublicAddress: y,
|
|
92
|
+
activityIcon: w,
|
|
93
|
+
dappUrl: A,
|
|
94
|
+
dappName: h,
|
|
95
|
+
integrationProvider: x
|
|
98
96
|
};
|
|
99
|
-
return await g(l.TX_ACTIVITY, (
|
|
97
|
+
return await g(l.TX_ACTIVITY, (v = {}) => (v[d] = D, v)), d;
|
|
100
98
|
}
|
|
101
99
|
async getTxRequest(t) {
|
|
102
100
|
return (await this.getTransactionRecord())[t] || null;
|
|
@@ -142,7 +140,7 @@ class R {
|
|
|
142
140
|
if (!t.success) {
|
|
143
141
|
await this.updateActivity(
|
|
144
142
|
o,
|
|
145
|
-
|
|
143
|
+
T.FAILED,
|
|
146
144
|
"erroredTx" in t ? t.erroredTx?.transactionHash : void 0
|
|
147
145
|
);
|
|
148
146
|
return;
|
|
@@ -151,13 +149,13 @@ class R {
|
|
|
151
149
|
const { tx: r } = t;
|
|
152
150
|
await this.updateActivity(
|
|
153
151
|
o,
|
|
154
|
-
|
|
152
|
+
T.SUCCESSFUL,
|
|
155
153
|
r.hash,
|
|
156
|
-
|
|
154
|
+
(r.value ?? 0n).toString(),
|
|
157
155
|
r.from,
|
|
158
156
|
r.to,
|
|
159
|
-
|
|
160
|
-
|
|
157
|
+
r.gas ?? 0n,
|
|
158
|
+
r.gasPrice ?? 0n
|
|
161
159
|
);
|
|
162
160
|
}
|
|
163
161
|
} catch (r) {
|
|
@@ -167,21 +165,21 @@ class R {
|
|
|
167
165
|
getGasInDollar = async (t, o, r) => {
|
|
168
166
|
if (!(!t || !o))
|
|
169
167
|
try {
|
|
170
|
-
const i =
|
|
168
|
+
const i = C(r) ? k : P, a = _(i, r);
|
|
171
169
|
if (!a)
|
|
172
170
|
return;
|
|
173
|
-
const { prices: s } = await
|
|
171
|
+
const { prices: s } = await E.getTokenPrices(r, [a.erc20TokenAddress]), n = s[0];
|
|
174
172
|
if (!n)
|
|
175
173
|
return;
|
|
176
|
-
const e = n * Number(
|
|
177
|
-
return
|
|
174
|
+
const e = n * Number(b(a, o)) * Number(t);
|
|
175
|
+
return q(e);
|
|
178
176
|
} catch (i) {
|
|
179
|
-
|
|
177
|
+
N.error("Failed to calculate gas cost in dollars:", { chainId: r, error: i });
|
|
180
178
|
return;
|
|
181
179
|
}
|
|
182
180
|
};
|
|
183
181
|
}
|
|
184
|
-
const
|
|
182
|
+
const Ct = new R();
|
|
185
183
|
export {
|
|
186
|
-
|
|
184
|
+
Ct as activityStorage
|
|
187
185
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("idb-keyval");require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("idb-keyval");require("../../constants/chains.constants.cjs");require("@solana/web3.js");require("../http/HttpClient.cjs");const B=require("../../error-handling/logger.cjs");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("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/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");const o=require("../../functions/utils/string.utils.cjs");require("multiformats");require("../../API/tenderly.api.cjs");class y{balancesRecordLabel="walletsBalances";async getBalances(){return await c.get(this.balancesRecordLabel)}async getBalancesByWallet(r,a){const e=await this.getBalances();if(!e)return;const i=o.getStateKey(r,a);return e[i]}async setBalances(r,a,e,i){let n=[];if(!i)return await c.update(this.balancesRecordLabel,(t={})=>{const u=o.getStateKey(a,r);return{...t,[u]:e}}),e;if(i.length===0)return await this.getBalancesByWallet(a,r)??[];try{await c.update(this.balancesRecordLabel,(t={})=>{const u=o.getStateKey(a,r),s=this.createBalanceLookup(t[u]),q=this.createBalanceLookup(e);return i.forEach(({erc20TokenAddress:g})=>{const l=g.toLowerCase();l in q?s[l]=q[l]:delete s[l]}),n=Object.values(s),{...t,[u]:n}})}catch(t){B.Logger.error("Failed to update wallet balances:",t)}return n}createBalanceLookup(r=[]){return r.reduce((a,e)=>({...a,[e.token.erc20TokenAddress.toLowerCase()]:e}),{})}}const w=new y;exports.publicBalancesStorage=w;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { get as u, update as
|
|
2
|
-
import "ethers";
|
|
1
|
+
import { get as u, update as m } from "idb-keyval";
|
|
3
2
|
import "../../constants/chains.constants.mjs";
|
|
4
3
|
import "@solana/web3.js";
|
|
5
4
|
import "../http/HttpClient.mjs";
|
|
6
5
|
import { Logger as w } from "../../error-handling/logger.mjs";
|
|
6
|
+
import "ethers";
|
|
7
7
|
import "../../constants/token-data/index.mjs";
|
|
8
8
|
import "../../error-handling/error-codes.constants.mjs";
|
|
9
9
|
import "../../functions/utils/convertIntegrationProviderToExternalActionId.mjs";
|
|
10
10
|
import "../../types/circom-data.types.mjs";
|
|
11
|
-
import "../../types/transactions.types.mjs";
|
|
12
11
|
import "../../types/activities.types.mjs";
|
|
13
12
|
import "circomlibjs-hinkal-fork";
|
|
14
13
|
import "../crypto-keys/keys.mjs";
|
|
@@ -52,7 +51,7 @@ class g {
|
|
|
52
51
|
async setBalances(e, r, t, o) {
|
|
53
52
|
let l = [];
|
|
54
53
|
if (!o)
|
|
55
|
-
return await
|
|
54
|
+
return await m(this.balancesRecordLabel, (a = {}) => {
|
|
56
55
|
const i = c(r, e);
|
|
57
56
|
return {
|
|
58
57
|
...a,
|
|
@@ -62,11 +61,11 @@ class g {
|
|
|
62
61
|
if (o.length === 0)
|
|
63
62
|
return await this.getBalancesByWallet(r, e) ?? [];
|
|
64
63
|
try {
|
|
65
|
-
await
|
|
66
|
-
const i = c(r, e), n = this.createBalanceLookup(a[i]),
|
|
64
|
+
await m(this.balancesRecordLabel, (a = {}) => {
|
|
65
|
+
const i = c(r, e), n = this.createBalanceLookup(a[i]), s = this.createBalanceLookup(t);
|
|
67
66
|
return o.forEach(({ erc20TokenAddress: B }) => {
|
|
68
67
|
const p = B.toLowerCase();
|
|
69
|
-
p in
|
|
68
|
+
p in s ? n[p] = s[p] : delete n[p];
|
|
70
69
|
}), l = Object.values(n), {
|
|
71
70
|
...a,
|
|
72
71
|
[i]: l
|
|
@@ -87,7 +86,7 @@ class g {
|
|
|
87
86
|
);
|
|
88
87
|
}
|
|
89
88
|
}
|
|
90
|
-
const
|
|
89
|
+
const et = new g();
|
|
91
90
|
export {
|
|
92
|
-
|
|
91
|
+
et as publicBalancesStorage
|
|
93
92
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("idb-keyval"),q=require("../../error-handling/logger.cjs");require("../../types/circom-data.types.cjs");require("../../types/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("idb-keyval"),q=require("../../error-handling/logger.cjs");require("../../types/circom-data.types.cjs");require("../../types/activities.types.cjs");require("../../constants/chains.constants.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");require("ethers");require("circomlibjs-hinkal-fork");require("../../constants/kyc.constants.cjs");require("../http/HttpClient.cjs");require("../../constants/token-data/index.cjs");require("../../error-handling/error-codes.constants.cjs");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../crypto-keys/keys.cjs");require("../../constants/server.constants.cjs");require("../../constants/vite.constants.cjs");require("axios");const d=require("../../functions/utils/caseInsensitive.utils.cjs");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("@solana/spl-token");require("../../constants/contracts.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");require("node-forge");require("../../functions/web3/events/getApprovedBalance.cjs");require("../../functions/web3/getTokenHolder.cjs");class l{STORAGE_KEY="contacts";checkForDuplicate(o,e,r){if(o.find(({ethereumAddress:t,nickname:i})=>(t===e.ethereumAddress||i===e.nickname)&&t!==r)!==void 0)throw new Error("Duplicate Contact attribute")}async createContact(o,e){const r=o.toLowerCase();await s.update(this.STORAGE_KEY,c=>{const t=c??{},i=t[r]??[];return this.checkForDuplicate(i,e),i.push(e),t[r]=i,t})}async getContacts(o){try{const e=o.toLowerCase(),r=await s.get(this.STORAGE_KEY);return!r||!r[e]?[]:r[e]}catch(e){return q.Logger.error("Error while getting contacts:",e),[]}}async editContact(o,e,r){const c=o.toLowerCase();await s.update(this.STORAGE_KEY,t=>{const i=t??{},a=i[c];if(!i||!a)throw new Error("Contacts could not be fetched");this.checkForDuplicate(a,r,e);const n=a.findIndex(({ethereumAddress:u})=>d.caseInsensitiveEqual(u,e));if(n===-1)throw new Error("Contact to be edited was not found");return a[n]=r,i[c]=a,i})}async deleteContact(o,e){const r=o.toLowerCase();await s.update(this.STORAGE_KEY,c=>{const t=c??{},i=t[r];if(!t||!i)throw new Error("Contacts could not be fetched");const a=i.filter(({ethereumAddress:n})=>n!==e);return t[r]=a,t})}}const w=new l;exports.contactStorage=w;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { update as s, get as p } from "idb-keyval";
|
|
2
2
|
import { Logger as d } from "../../error-handling/logger.mjs";
|
|
3
3
|
import "../../types/circom-data.types.mjs";
|
|
4
|
-
import "../../types/transactions.types.mjs";
|
|
5
4
|
import "../../types/activities.types.mjs";
|
|
6
5
|
import "../../constants/chains.constants.mjs";
|
|
7
6
|
import "@coral-xyz/anchor";
|
|
@@ -40,35 +39,34 @@ import "../../API/tenderly.api.mjs";
|
|
|
40
39
|
import "node-forge";
|
|
41
40
|
import "../../functions/web3/events/getApprovedBalance.mjs";
|
|
42
41
|
import "../../functions/web3/getTokenHolder.mjs";
|
|
43
|
-
import "ethers-v6h";
|
|
44
42
|
class w {
|
|
45
43
|
STORAGE_KEY = "contacts";
|
|
46
|
-
checkForDuplicate(
|
|
47
|
-
if (
|
|
48
|
-
({ ethereumAddress: r, nickname:
|
|
44
|
+
checkForDuplicate(i, t, o) {
|
|
45
|
+
if (i.find(
|
|
46
|
+
({ ethereumAddress: r, nickname: e }) => (r === t.ethereumAddress || e === t.nickname) && r !== o
|
|
49
47
|
) !== void 0)
|
|
50
48
|
throw new Error("Duplicate Contact attribute");
|
|
51
49
|
}
|
|
52
|
-
async createContact(
|
|
53
|
-
const o =
|
|
50
|
+
async createContact(i, t) {
|
|
51
|
+
const o = i.toLowerCase();
|
|
54
52
|
await s(this.STORAGE_KEY, (c) => {
|
|
55
|
-
const r = c ?? {},
|
|
56
|
-
return this.checkForDuplicate(
|
|
53
|
+
const r = c ?? {}, e = r[o] ?? [];
|
|
54
|
+
return this.checkForDuplicate(e, t), e.push(t), r[o] = e, r;
|
|
57
55
|
});
|
|
58
56
|
}
|
|
59
|
-
async getContacts(
|
|
57
|
+
async getContacts(i) {
|
|
60
58
|
try {
|
|
61
|
-
const t =
|
|
59
|
+
const t = i.toLowerCase(), o = await p(this.STORAGE_KEY);
|
|
62
60
|
return !o || !o[t] ? [] : o[t];
|
|
63
61
|
} catch (t) {
|
|
64
62
|
return d.error("Error while getting contacts:", t), [];
|
|
65
63
|
}
|
|
66
64
|
}
|
|
67
|
-
async editContact(
|
|
68
|
-
const c =
|
|
65
|
+
async editContact(i, t, o) {
|
|
66
|
+
const c = i.toLowerCase();
|
|
69
67
|
await s(this.STORAGE_KEY, (r) => {
|
|
70
|
-
const
|
|
71
|
-
if (!
|
|
68
|
+
const e = r ?? {}, a = e[c];
|
|
69
|
+
if (!e || !a)
|
|
72
70
|
throw new Error("Contacts could not be fetched");
|
|
73
71
|
this.checkForDuplicate(a, o, t);
|
|
74
72
|
const n = a.findIndex(
|
|
@@ -76,23 +74,23 @@ class w {
|
|
|
76
74
|
);
|
|
77
75
|
if (n === -1)
|
|
78
76
|
throw new Error("Contact to be edited was not found");
|
|
79
|
-
return a[n] = o,
|
|
77
|
+
return a[n] = o, e[c] = a, e;
|
|
80
78
|
});
|
|
81
79
|
}
|
|
82
|
-
async deleteContact(
|
|
83
|
-
const o =
|
|
80
|
+
async deleteContact(i, t) {
|
|
81
|
+
const o = i.toLowerCase();
|
|
84
82
|
await s(this.STORAGE_KEY, (c) => {
|
|
85
|
-
const r = c ?? {},
|
|
86
|
-
if (!r || !
|
|
83
|
+
const r = c ?? {}, e = r[o];
|
|
84
|
+
if (!r || !e)
|
|
87
85
|
throw new Error("Contacts could not be fetched");
|
|
88
|
-
const a =
|
|
86
|
+
const a = e.filter(
|
|
89
87
|
({ ethereumAddress: n }) => n !== t
|
|
90
88
|
);
|
|
91
89
|
return r[o] = a, r;
|
|
92
90
|
});
|
|
93
91
|
}
|
|
94
92
|
}
|
|
95
|
-
const
|
|
93
|
+
const rt = new w();
|
|
96
94
|
export {
|
|
97
|
-
|
|
95
|
+
rt as contactStorage
|
|
98
96
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("idb-keyval");require("../../error-handling/error-codes.constants.cjs");require("ethers");require("../../types/circom-data.types.cjs");require("../../types/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("idb-keyval");require("../../error-handling/error-codes.constants.cjs");require("ethers");require("../../types/circom-data.types.cjs");require("../../types/activities.types.cjs");const a=require("../../types/cache.types.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("../http/HttpClient.cjs");require("axios");require("../../constants/chains.constants.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/vite.constants.cjs");require("../../constants/save-depths.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../functions/utils/mutexes.utils.cjs");require("@coral-xyz/anchor");const o=require("../../error-handling/logger.cjs");require("@solana/web3.js");require("../crypto-keys/keys.cjs");class q{generateMessageId(){const e=new Date().getTime(),r=Math.random().toString(36).substring(2,15);return`msg_${e}_${r}`}async saveSignedMessage(e,r,t,n,u,S){try{const s=this.generateMessageId(),g=await i.get(a.StorageKeys.SIGNED_MESSAGES)||{},c={chainId:e,messageText:r,messageType:t,subAccountAddress:n,signature:u,appMetaData:S};g[s]={timestamp:new Date().toISOString(),...c},await i.set(a.StorageKeys.SIGNED_MESSAGES,g)}catch(s){o.Logger.error("Failed to save signed message:",s,{chainId:e,messageType:t})}}async getAllSignedMessages(){try{const e=await i.get(a.StorageKeys.SIGNED_MESSAGES)||{};return Object.values(e).sort((r,t)=>new Date(t.timestamp).getTime()-new Date(r.timestamp).getTime())}catch(e){return o.Logger.error("Failed to retrieve signed messages:",e),[]}}}const d=new q;exports.signedMessagesStorage=d;
|
|
@@ -2,7 +2,6 @@ import { get as m, set as c } from "idb-keyval";
|
|
|
2
2
|
import "../../error-handling/error-codes.constants.mjs";
|
|
3
3
|
import "ethers";
|
|
4
4
|
import "../../types/circom-data.types.mjs";
|
|
5
|
-
import "../../types/transactions.types.mjs";
|
|
6
5
|
import "../../types/activities.types.mjs";
|
|
7
6
|
import { StorageKeys as s } from "../../types/cache.types.mjs";
|
|
8
7
|
import "../../constants/server.constants.mjs";
|
|
@@ -57,7 +56,7 @@ class d {
|
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
|
-
const
|
|
59
|
+
const k = new d();
|
|
61
60
|
export {
|
|
62
|
-
|
|
61
|
+
k as signedMessagesStorage
|
|
63
62
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("ethers"),k=require("idb-keyval"),_=require("../../API/API.cjs"),A=require("../../constants/chains.constants.cjs"),p=require("../../error-handling/logger.cjs"),f=require("../../functions/utils/caseInsensitive.utils.cjs"),T=require("../../types/cache.types.cjs"),d=require("../../functions/utils/string.utils.cjs"),C=require("../../constants/protocol.constants.cjs"),I=require("async-mutex"),S=require("../../functions/utils/erc20tokenFunctions.cjs"),K=require("./token-visibility-db.cjs");require("../../types/circom-data.types.cjs");require("../../types/activities.types.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");require("circomlibjs-hinkal-fork");require("../../constants/kyc.constants.cjs");const m=require("../../functions/utils/create-provider.cjs");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../../error-handling/error-codes.constants.cjs");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("@solana/spl-token");require("../../constants/token-data/index.cjs");require("../../constants/contracts.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");const x=require("../../constants/events.constants.cjs");require("../../functions/utils/userAgent.cjs");require("multiformats");require("../../API/tenderly.api.cjs");require("node-forge");require("../../functions/web3/events/getApprovedBalance.cjs");require("../../functions/web3/getTokenHolder.cjs");class P{fetchedTokens={};updateMutexes={};transferEventTopic=y.ethers.id("Transfer(address,address,uint256)");getMutex(t){return this.updateMutexes[t]||(this.updateMutexes[t]=new I.Mutex),this.updateMutexes[t]}async getPublicTokens(t,o){const r=d.getStateKey(o,t);return(await k.get(T.StorageKeys.EVENTS_PUBLIC_TOKENS))?.[r]||[]}getFetchedTokens(t,o){const r=d.getStateKey(o,t);return this.fetchedTokens[r]||[]}async fetchAndUpdatePublicTokens(t,o){const r=d.getStateKey(t,o);await this.getMutex(r).runExclusive(async()=>{try{const s=(await this.getPublicTokens(o,t)).map(a=>a.erc20TokenAddress),{toEvents:i,fromEvents:u,latestBlock:c}=await this.getEvents(t,o),g=[...i,...u],{erc20Tokens:l}=await this.fetchPublicTokens(g,o,s),B=await K.tokenVisibilityStorage.hideSpamsAndFetchHiddenTokensAddresses(o,l),w=l.filter(a=>!f.lowerCaseIncludes(B,a.erc20TokenAddress));await k.update(T.StorageKeys.EVENTS_PUBLIC_TOKENS,(a={})=>{const q=a[r]||[],b=q.map(h=>h.erc20TokenAddress),L=w.filter(h=>!f.lowerCaseIncludes(b,h.erc20TokenAddress));q.push(...L);const v=this.updateTokenIds(u,i,q),E={...a,[r]:v};return this.fetchedTokens=E,E}),c&&await this.updateLastProcessedBlock(o,t,c)}catch(e){p.Logger.error("public tokens db error",e)}})}async getLastProcessedBlock(t,o){const r=await k.get(T.StorageKeys.PUBLIC_TOKENS_LAST_PROCESSED_BLOCKS)||{},n=d.getStateKey(o,t);return r[n]||x.EVENTS_INITIAL_BLOCKS[t]}async updateLastProcessedBlock(t,o,r){await k.update(T.StorageKeys.PUBLIC_TOKENS_LAST_PROCESSED_BLOCKS,(n={})=>{const e=d.getStateKey(o,t);return{...n,[e]:r}})}async getEvents(t,o){try{const{fetchRpcUrl:r}=A.networkRegistry[o];if(!r)throw Error("No fetchRpcUrl in PublicTokensDB");const n=m.createCustomRpcProvider(r),e=await this.getLastProcessedBlock(o,t)+1,s=await n.getBlockNumber(),i=y.ethers.zeroPadValue(t.toLowerCase(),32),u={topics:[this.transferEventTopic,null,i],fromBlock:e,toBlock:s},c={topics:[this.transferEventTopic,i,null],fromBlock:e,toBlock:s},[g,l]=await Promise.all([n.getLogs(u),n.getLogs(c)]);return{toEvents:g,fromEvents:l,latestBlock:s}}catch(r){return p.Logger.error("Error fetching events:",r),{toEvents:[],fromEvents:[],latestBlock:void 0}}}updateTokenIds(t,o,r){const n=new Map;return r.forEach(e=>{if(S.isNFTToken(e)&&e.tokenIds){const s=e.erc20TokenAddress.toLowerCase();n.set(s,[...e.tokenIds])}}),o.forEach(e=>{if(e.topics.length<=3)return;const s=e.address.toLowerCase(),i=BigInt(e.topics[3]).toString();n.has(s)||n.set(s,[]),n.get(s)?.push(i)}),t.forEach(e=>{if(e.topics.length<=3)return;const s=e.address.toLowerCase(),i=n.get(s);if(i?.length){const u=BigInt(e.topics[3]).toString(),c=i.indexOf(u);c!==-1&&i.splice(c,1)}}),r.forEach(e=>{if(S.isNFTToken(e)){const s=e.erc20TokenAddress.toLowerCase(),i=n.get(s);e.tokenIds=i?.length&&i.length>0?i:void 0}}),r}async fetchPublicTokens(t,o,r){try{const n=[C.zeroAddress,...new Set(t.map(s=>s.address))].filter(s=>s&&!f.lowerCaseIncludes(r,s));return n.length?{erc20Tokens:(await _.API.tokensInfoCall(o,n)).filter(s=>!!s)}:{erc20Tokens:[]}}catch(n){return p.Logger.error("Error fetching public tokens:",n),{erc20Tokens:[]}}}}const N=new P;exports.EventsPublicTokensDB=P;exports.eventsPublicTokensDB=N;
|