@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,10 +1,11 @@
|
|
|
1
|
-
import { BN as
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { BN as o } from "@coral-xyz/anchor";
|
|
2
|
+
import { Buffer as t } from "buffer";
|
|
3
|
+
const g = (r) => {
|
|
4
|
+
if (r.length !== 32 || r.some((e) => !Number.isInteger(e) || e < 0 || e >= 256))
|
|
4
5
|
throw new Error("invalid bytes32 value");
|
|
5
|
-
return
|
|
6
|
-
},
|
|
6
|
+
return r.reduce((e, n) => e * 256n + BigInt(n), 0n);
|
|
7
|
+
}, c = (r) => [...new o(r.toString()).toArrayLike(t, "be", 32)];
|
|
7
8
|
export {
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
c as convertBigIntToBytes32,
|
|
10
|
+
g as convertBytes32ToBigInt
|
|
10
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../providers/CustomSolanaConnection.cjs"),s=require("../../providers/CustomEthersProvider.cjs"),o=require("ethers"),c=require("../../constants/chains.constants.cjs"),i=e=>new o.ethers.providers.JsonRpcProvider(e),u=e=>{const{fetchRpcUrl:r}=c.networkRegistry[e];if(!r)throw new Error("RPC URL not found for the specified chain ID");const t=new s.CustomEthersProvider(r);return new o.ethers.providers.Web3Provider(t)},a=(e,r="confirmed")=>new n.CustomSolanaConnection(e,r);exports.createCustomRpcProvider=u;exports.createCustomSolanaConnection=a;exports.createProvider=i;
|
|
@@ -2,5 +2,5 @@ import { CustomSolanaConnection } from '../../providers/CustomSolanaConnection';
|
|
|
2
2
|
import { Commitment, ConnectionConfig } from '@solana/web3.js';
|
|
3
3
|
import { ethers } from 'ethers';
|
|
4
4
|
export declare const createProvider: (rpcUrl: string) => ethers.providers.JsonRpcProvider;
|
|
5
|
-
export declare const createCustomRpcProvider: (
|
|
5
|
+
export declare const createCustomRpcProvider: (chainId: number) => ethers.providers.Web3Provider;
|
|
6
6
|
export declare const createCustomSolanaConnection: (endpoint: string, commitmentOrConfig?: Commitment | ConnectionConfig) => CustomSolanaConnection;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { CustomSolanaConnection as
|
|
2
|
-
import { CustomEthersProvider as
|
|
1
|
+
import { CustomSolanaConnection as n } from "../../providers/CustomSolanaConnection.mjs";
|
|
2
|
+
import { CustomEthersProvider as i } from "../../providers/CustomEthersProvider.mjs";
|
|
3
3
|
import { ethers as e } from "ethers";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import { networkRegistry as c } from "../../constants/chains.constants.mjs";
|
|
5
|
+
const f = (r) => new e.providers.JsonRpcProvider(r), u = (r) => {
|
|
6
|
+
const { fetchRpcUrl: o } = c[r];
|
|
7
|
+
if (!o)
|
|
8
|
+
throw new Error("RPC URL not found for the specified chain ID");
|
|
9
|
+
const t = new i(o);
|
|
10
|
+
return new e.providers.Web3Provider(t);
|
|
11
|
+
}, a = (r, o = "confirmed") => new n(r, o);
|
|
8
12
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
u as createCustomRpcProvider,
|
|
14
|
+
a as createCustomSolanaConnection,
|
|
15
|
+
f as createProvider
|
|
12
16
|
};
|
|
@@ -37,7 +37,6 @@ export * from './nftTokenFunctions';
|
|
|
37
37
|
export * from './inLogicMetadata';
|
|
38
38
|
export * from './networks.utils';
|
|
39
39
|
export * from './is-valid-url';
|
|
40
|
-
export * from './get-hinkal-approvals';
|
|
41
40
|
export * from './postToOffscreen';
|
|
42
41
|
export * from './get-signature-header';
|
|
43
42
|
export * from './solanaMint.utils';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("ethers"),v=require("@solana/web3.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("ethers"),v=require("@solana/web3.js"),s=require("../../crypto/preProcessing.cjs"),l=require("../../providers/EthersProviderAdapter.cjs"),n=require("../../constants/chains.constants.cjs"),i=require("./create-provider.cjs"),S=require("../../providers/SolanaProviderAdapter.cjs"),y=e=>{const r=i.createCustomRpcProvider(n.chainIds.ethMainnet);return new p.ethers.Wallet(e,r)},u=e=>{const r=i.createCustomRpcProvider(n.chainIds.ethMainnet);return new p.ethers.VoidSigner(e,r)},h=async(e,r)=>{await s.preProcessing();const t=l.default();t.initSigner?.(r),await e.initProviderAdapter(void 0,t),await e.initUserKeys()},o=async(e,r)=>{const t=l.default(),a=u(r);t.initSigner?.(a),await e.initProviderAdapter(void 0,t)},w=e=>{const r=e.userKeys.getDerivedSolanaPublicKey();return{publicKey:new v.PublicKey(r),signTransaction:()=>{throw new Error("Void wallet cannot sign transactions")},signAllTransactions:()=>{throw new Error("Void wallet cannot sign transactions")},signMessage:()=>{throw new Error("Void wallet cannot sign messages")}}},c=async(e,r)=>{const t=n.chainIds.solanaMainnet,a=n.networkRegistry[t].fetchRpcUrl;if(!a)throw new Error("RPC URL not found for the specified chain ID");const g=i.createCustomSolanaConnection(a),d=w(e),P=new S.SolanaProviderAdapter(g,t,d,r);await e.initProviderAdapter(d,P)},A=async(e,r,t)=>{await s.preProcessing(),await e.initUserKeysWithPassword(t);const a=e.userKeys.getDerivedSolanaPublicKey();await c(e,a),await o(e,r)},K=async(e,r)=>{await s.preProcessing(),await e.initUserKeysFromSeedPhrases(r);const t=e.userKeys.getDerivedSolanaPublicKey();await c(e,t);const a=e.userKeys.getDerivedEthereumAddress();await o(e,a)};exports.createSigner=y;exports.createVoidSigner=u;exports.createVoidSolanaWallet=w;exports.prepareEthersProviderAdapter=o;exports.prepareHinkal=h;exports.prepareHinkalFromSeedPhrases=K;exports.prepareHinkalWithSignature=A;exports.prepareSolanaProviderAdapter=c;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import { IHinkal } from '../../data-structures/Hinkal/IHinkal';
|
|
3
3
|
import { SolanaWallet } from '../../types/solana.types';
|
|
4
|
-
export declare const createSigner: (privateKey: string
|
|
5
|
-
export declare const createVoidSigner: (address: string
|
|
4
|
+
export declare const createSigner: (privateKey: string) => ethers.Wallet;
|
|
5
|
+
export declare const createVoidSigner: (address: string) => ethers.VoidSigner;
|
|
6
6
|
export declare const prepareHinkal: (hinkal: IHinkal, signer: ethers.Wallet) => Promise<void>;
|
|
7
|
-
export declare const prepareEthersProviderAdapter: (hinkal: IHinkal,
|
|
8
|
-
export declare const prepareHinkalWithSignature: (hinkal: IHinkal, address: string, chainId: number, signature: string) => Promise<void>;
|
|
7
|
+
export declare const prepareEthersProviderAdapter: (hinkal: IHinkal, ethereumAddress: string) => Promise<void>;
|
|
9
8
|
export declare const createVoidSolanaWallet: (hinkal: IHinkal) => SolanaWallet;
|
|
10
|
-
export declare const prepareSolanaProviderAdapter: (hinkal: IHinkal,
|
|
11
|
-
export declare const
|
|
12
|
-
export declare const
|
|
9
|
+
export declare const prepareSolanaProviderAdapter: (hinkal: IHinkal, ethereumAddress: string) => Promise<void>;
|
|
10
|
+
export declare const prepareHinkalWithSignature: (hinkal: IHinkal, ethereumAddress: string, signature: string) => Promise<void>;
|
|
11
|
+
export declare const prepareHinkalFromSeedPhrases: (hinkal: IHinkal, seedPhrases: string[]) => Promise<void>;
|
|
@@ -1,35 +1,27 @@
|
|
|
1
|
-
import { ethers as
|
|
2
|
-
import { PublicKey as
|
|
3
|
-
import { preProcessing as
|
|
4
|
-
import
|
|
5
|
-
import { networkRegistry as
|
|
6
|
-
import { createCustomRpcProvider as d, createCustomSolanaConnection as
|
|
7
|
-
import { SolanaProviderAdapter as
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
return new
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
e.initSigner?.(t), await r.initProviderAdapter(void 0, e), await r.initUserKeys();
|
|
24
|
-
}, h = async (r, t, e) => {
|
|
25
|
-
const o = p(), n = g(e, t);
|
|
26
|
-
o.initSigner?.(n), await r.initProviderAdapter(void 0, o);
|
|
27
|
-
}, W = async (r, t, e, o) => {
|
|
28
|
-
await a(), await h(r, e, t), await r.initUserKeysWithPassword(o);
|
|
29
|
-
}, v = (r) => {
|
|
30
|
-
const t = r.userKeys.getDerivedSolanaPublicKey();
|
|
1
|
+
import { ethers as s } from "ethers";
|
|
2
|
+
import { PublicKey as m } from "@solana/web3.js";
|
|
3
|
+
import { preProcessing as n } from "../../crypto/preProcessing.mjs";
|
|
4
|
+
import c from "../../providers/EthersProviderAdapter.mjs";
|
|
5
|
+
import { chainIds as a, networkRegistry as v } from "../../constants/chains.constants.mjs";
|
|
6
|
+
import { createCustomRpcProvider as d, createCustomSolanaConnection as u } from "./create-provider.mjs";
|
|
7
|
+
import { SolanaProviderAdapter as y } from "../../providers/SolanaProviderAdapter.mjs";
|
|
8
|
+
const V = (e) => {
|
|
9
|
+
const r = d(a.ethMainnet);
|
|
10
|
+
return new s.Wallet(e, r);
|
|
11
|
+
}, P = (e) => {
|
|
12
|
+
const r = d(a.ethMainnet);
|
|
13
|
+
return new s.VoidSigner(e, r);
|
|
14
|
+
}, D = async (e, r) => {
|
|
15
|
+
await n();
|
|
16
|
+
const t = c();
|
|
17
|
+
t.initSigner?.(r), await e.initProviderAdapter(void 0, t), await e.initUserKeys();
|
|
18
|
+
}, p = async (e, r) => {
|
|
19
|
+
const t = c(), o = P(r);
|
|
20
|
+
t.initSigner?.(o), await e.initProviderAdapter(void 0, t);
|
|
21
|
+
}, A = (e) => {
|
|
22
|
+
const r = e.userKeys.getDerivedSolanaPublicKey();
|
|
31
23
|
return {
|
|
32
|
-
publicKey: new
|
|
24
|
+
publicKey: new m(r),
|
|
33
25
|
signTransaction: () => {
|
|
34
26
|
throw new Error("Void wallet cannot sign transactions");
|
|
35
27
|
},
|
|
@@ -40,30 +32,30 @@ const K = (r, t) => {
|
|
|
40
32
|
throw new Error("Void wallet cannot sign messages");
|
|
41
33
|
}
|
|
42
34
|
};
|
|
43
|
-
},
|
|
44
|
-
const o =
|
|
45
|
-
if (!o)
|
|
46
|
-
throw new Error("RPC URL not found for the specified chain ID");
|
|
47
|
-
const n = w(o), i = v(r), f = new l(n, t, i, e);
|
|
48
|
-
await r.initProviderAdapter(i, f);
|
|
49
|
-
}, V = async (r, t, e) => {
|
|
50
|
-
await a();
|
|
51
|
-
const o = s[t].fetchRpcUrl;
|
|
35
|
+
}, w = async (e, r) => {
|
|
36
|
+
const t = a.solanaMainnet, o = v[t].fetchRpcUrl;
|
|
52
37
|
if (!o)
|
|
53
38
|
throw new Error("RPC URL not found for the specified chain ID");
|
|
54
|
-
const
|
|
55
|
-
await
|
|
56
|
-
},
|
|
57
|
-
await
|
|
39
|
+
const l = u(o), i = A(e), g = new y(l, t, i, r);
|
|
40
|
+
await e.initProviderAdapter(i, g);
|
|
41
|
+
}, R = async (e, r, t) => {
|
|
42
|
+
await n(), await e.initUserKeysWithPassword(t);
|
|
43
|
+
const o = e.userKeys.getDerivedSolanaPublicKey();
|
|
44
|
+
await w(e, o), await p(e, r);
|
|
45
|
+
}, W = async (e, r) => {
|
|
46
|
+
await n(), await e.initUserKeysFromSeedPhrases(r);
|
|
47
|
+
const t = e.userKeys.getDerivedSolanaPublicKey();
|
|
48
|
+
await w(e, t);
|
|
49
|
+
const o = e.userKeys.getDerivedEthereumAddress();
|
|
50
|
+
await p(e, o);
|
|
58
51
|
};
|
|
59
52
|
export {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
W as
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
m as prepareSolanaProviderAdapter
|
|
53
|
+
V as createSigner,
|
|
54
|
+
P as createVoidSigner,
|
|
55
|
+
A as createVoidSolanaWallet,
|
|
56
|
+
p as prepareEthersProviderAdapter,
|
|
57
|
+
D as prepareHinkal,
|
|
58
|
+
W as prepareHinkalFromSeedPhrases,
|
|
59
|
+
R as prepareHinkalWithSignature,
|
|
60
|
+
w as prepareSolanaProviderAdapter
|
|
69
61
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("ethers"),I=require("../../constants/chains.constants.cjs"),g=require("../../constants/protocol.constants.cjs"),B=require("./erc20tokenFunctions.cjs"),P=require("../../externalABIs/swapAbi.cjs"),m=require("../../error-handling/logger.cjs"),T=require("../../externalABIs/index.cjs"),y=require("./ipfs.cjs"),f=require("./create-provider.cjs"),h=require("../../data-structures/http/HttpClient.cjs");require("axios");const d=require("@solana/web3.js"),b=require("@solana/spl-token"),w=async(r,e,t)=>{try{const s=t.erc20TokenAddress;let a;const o=new p.ethers.Contract(t.erc20TokenAddress,P.ERC20ABI,r);s!==g.zeroAddress?a=await o?.balanceOf(e):a=await o.provider.getBalance(e);const c=a.toBigInt();return c<=0n?null:{token:t,balance:c}}catch{return null}},q=async(r,e)=>{const t=e.nftTokenType===g.TokenType.ERC721,s=new p.ethers.Contract(e.erc20TokenAddress,t?T.ERC721ABI:T.ERC1155ABI,r),{tokenIds:a}=e;if(!a?.length)return null;const o=await Promise.all(a.map(async c=>{try{const n=await s[t?"tokenURI":"uri"](c),l=n.startsWith("ipfs://")?y.getFormattedIpfsUrl(n,!1):n,u=t?l:l.replace("{id}",c);if(u){const i=await h.httpClient.get(u);return i?.image?.startsWith("ipfs://")&&(i.image=y.getFormattedIpfsUrl(i.image,!1)),{image:i.image,tokenId:Number(c),name:i.name}}return{tokenId:Number(c)}}catch{return{tokenId:Number(c)}}}));return{token:e,balance:a?.length?BigInt(a.length):0n,nfts:o}},k=async(r,e,t)=>{const s=t??B.getErc20TokensForChain(r),a=f.createCustomRpcProvider(r);return(await Promise.all(s.map(async c=>B.isNFTToken(c)?q(a,c):w(a,e,c)))).filter(c=>c!==null)},v=async(r,e,t)=>{try{const s=f.createCustomRpcProvider(r),a=new p.ethers.Contract(t,P.ERC20ABI,s);let o;return t!==g.zeroAddress?o=await a?.balanceOf(e):o=await s.getBalance(e),o.toBigInt()}catch{return m.Logger.error(`Failed to fetch public balance for address ${e}`),null}},E=async(r,e)=>{try{return await f.createCustomRpcProvider(r).getTransactionCount(e)}catch(t){return m.Logger.error(`Failed to fetch transaction count for address ${e} on chain ${r}`,t),null}},F=async(r,e,t)=>{const a=I.networkRegistry[r].fetchRpcUrl??"",o=f.createCustomSolanaConnection(a);return(await Promise.all(t.map(async n=>{if(B.isNFTToken(n))return{token:n,balance:1n,nfts:[{image:n.logoURI,tokenId:0,name:n.symbol}]};if(n.erc20TokenAddress===g.solanaNativeAddress){const A=BigInt(await o.getBalance(new d.PublicKey(e)));return{token:n,balance:A}}const l=new d.PublicKey(n.erc20TokenAddress),u=new d.PublicKey(e),i=await b.getAssociatedTokenAddress(l,u,!0,n.is2022Program?b.TOKEN_2022_PROGRAM_ID:b.TOKEN_PROGRAM_ID);if(!await o.getAccountInfo(i))return{token:n,balance:0n};const C=await o.getTokenAccountBalance(i),R=BigInt(C.value.amount);return{token:n,balance:R}}))).filter(n=>n.balance>0n)};exports.getPublicBalance=w;exports.getPublicBalanceByTokenAddress=v;exports.getPublicBalancesOfTokens=k;exports.getPublicTransactionCount=E;exports.getSolanaPublicBalances=F;
|
|
@@ -1,105 +1,100 @@
|
|
|
1
1
|
import { ethers as m } from "ethers";
|
|
2
|
-
import { networkRegistry as
|
|
3
|
-
import { zeroAddress as
|
|
4
|
-
import { getErc20TokensForChain as
|
|
2
|
+
import { networkRegistry as I } from "../../constants/chains.constants.mjs";
|
|
3
|
+
import { zeroAddress as d, solanaNativeAddress as R, TokenType as P } from "../../constants/protocol.constants.mjs";
|
|
4
|
+
import { getErc20TokensForChain as A, isNFTToken as b } from "./erc20tokenFunctions.mjs";
|
|
5
5
|
import { ERC20ABI as B } from "../../externalABIs/swapAbi.mjs";
|
|
6
|
-
import { Logger as
|
|
7
|
-
import { ERC721ABI as
|
|
6
|
+
import { Logger as w } from "../../error-handling/logger.mjs";
|
|
7
|
+
import { ERC721ABI as h, ERC1155ABI as v } from "../../externalABIs/index.mjs";
|
|
8
8
|
import { getFormattedIpfsUrl as p } from "./ipfs.mjs";
|
|
9
|
-
import {
|
|
10
|
-
import { httpClient as
|
|
9
|
+
import { createCustomRpcProvider as g, createCustomSolanaConnection as E } from "./create-provider.mjs";
|
|
10
|
+
import { httpClient as N } from "../../data-structures/http/HttpClient.mjs";
|
|
11
11
|
import "axios";
|
|
12
12
|
import { PublicKey as u } from "@solana/web3.js";
|
|
13
|
-
import { getAssociatedTokenAddress as k, TOKEN_2022_PROGRAM_ID as O, TOKEN_PROGRAM_ID as
|
|
14
|
-
const
|
|
15
|
-
const { fetchRpcUrl: t } = d[e];
|
|
16
|
-
if (!t)
|
|
17
|
-
throw new Error(`No RPC URL configured for chain ${e}`);
|
|
18
|
-
return N(t);
|
|
19
|
-
}, _ = async (e, t, n) => {
|
|
13
|
+
import { getAssociatedTokenAddress as k, TOKEN_2022_PROGRAM_ID as O, TOKEN_PROGRAM_ID as U } from "@solana/spl-token";
|
|
14
|
+
const F = async (c, t, n) => {
|
|
20
15
|
try {
|
|
21
16
|
const s = n.erc20TokenAddress;
|
|
22
|
-
let
|
|
23
|
-
const o = new m.Contract(n.erc20TokenAddress, B,
|
|
24
|
-
s !==
|
|
25
|
-
const
|
|
26
|
-
return
|
|
17
|
+
let e;
|
|
18
|
+
const o = new m.Contract(n.erc20TokenAddress, B, c);
|
|
19
|
+
s !== d ? e = await o?.balanceOf(t) : e = await o.provider.getBalance(t);
|
|
20
|
+
const r = e.toBigInt();
|
|
21
|
+
return r <= 0n ? null : { token: n, balance: r };
|
|
27
22
|
} catch {
|
|
28
23
|
return null;
|
|
29
24
|
}
|
|
30
|
-
},
|
|
31
|
-
const n = t.nftTokenType ===
|
|
32
|
-
if (!
|
|
25
|
+
}, _ = async (c, t) => {
|
|
26
|
+
const n = t.nftTokenType === P.ERC721, s = new m.Contract(t.erc20TokenAddress, n ? h : v, c), { tokenIds: e } = t;
|
|
27
|
+
if (!e?.length)
|
|
33
28
|
return null;
|
|
34
29
|
const o = await Promise.all(
|
|
35
|
-
|
|
30
|
+
e.map(async (r) => {
|
|
36
31
|
try {
|
|
37
|
-
const a = await s[n ? "tokenURI" : "uri"](
|
|
32
|
+
const a = await s[n ? "tokenURI" : "uri"](r), l = a.startsWith("ipfs://") ? p(a, !1) : a, f = n ? l : l.replace("{id}", r);
|
|
38
33
|
if (f) {
|
|
39
|
-
const i = await
|
|
40
|
-
return i?.image?.startsWith("ipfs://") && (i.image = p(i.image, !1)), { image: i.image, tokenId: Number(
|
|
34
|
+
const i = await N.get(f);
|
|
35
|
+
return i?.image?.startsWith("ipfs://") && (i.image = p(i.image, !1)), { image: i.image, tokenId: Number(r), name: i.name };
|
|
41
36
|
}
|
|
42
|
-
return { tokenId: Number(
|
|
37
|
+
return { tokenId: Number(r) };
|
|
43
38
|
} catch {
|
|
44
|
-
return { tokenId: Number(
|
|
39
|
+
return { tokenId: Number(r) };
|
|
45
40
|
}
|
|
46
41
|
})
|
|
47
42
|
);
|
|
48
43
|
return {
|
|
49
44
|
token: t,
|
|
50
|
-
balance:
|
|
45
|
+
balance: e?.length ? BigInt(e.length) : 0n,
|
|
51
46
|
nfts: o
|
|
52
47
|
};
|
|
53
|
-
},
|
|
54
|
-
const s = n ??
|
|
48
|
+
}, Q = async (c, t, n) => {
|
|
49
|
+
const s = n ?? A(c), e = g(c);
|
|
55
50
|
return (await Promise.all(
|
|
56
|
-
s.map(async (
|
|
57
|
-
)).filter((
|
|
58
|
-
},
|
|
51
|
+
s.map(async (r) => b(r) ? _(e, r) : F(e, t, r))
|
|
52
|
+
)).filter((r) => r !== null);
|
|
53
|
+
}, V = async (c, t, n) => {
|
|
59
54
|
try {
|
|
60
|
-
const s = g(
|
|
55
|
+
const s = g(c), e = new m.Contract(n, B, s);
|
|
61
56
|
let o;
|
|
62
|
-
return n !==
|
|
57
|
+
return n !== d ? o = await e?.balanceOf(t) : o = await s.getBalance(t), o.toBigInt();
|
|
63
58
|
} catch {
|
|
64
|
-
return
|
|
59
|
+
return w.error(`Failed to fetch public balance for address ${t}`), null;
|
|
65
60
|
}
|
|
66
|
-
},
|
|
61
|
+
}, X = async (c, t) => {
|
|
67
62
|
try {
|
|
68
|
-
return await g(
|
|
63
|
+
return await g(c).getTransactionCount(t);
|
|
69
64
|
} catch (n) {
|
|
70
|
-
return
|
|
65
|
+
return w.error(`Failed to fetch transaction count for address ${t} on chain ${c}`, n), null;
|
|
71
66
|
}
|
|
72
|
-
},
|
|
73
|
-
const
|
|
67
|
+
}, Y = async (c, t, n) => {
|
|
68
|
+
const e = I[c].fetchRpcUrl ?? "", o = E(e);
|
|
74
69
|
return (await Promise.all(
|
|
75
70
|
n.map(async (a) => {
|
|
76
|
-
if (
|
|
71
|
+
if (b(a))
|
|
77
72
|
return {
|
|
78
73
|
token: a,
|
|
79
74
|
balance: 1n,
|
|
80
75
|
nfts: [{ image: a.logoURI, tokenId: 0, name: a.symbol }]
|
|
81
76
|
};
|
|
82
|
-
if (a.erc20TokenAddress ===
|
|
83
|
-
const
|
|
84
|
-
return { token: a, balance:
|
|
77
|
+
if (a.erc20TokenAddress === R) {
|
|
78
|
+
const C = BigInt(await o.getBalance(new u(t)));
|
|
79
|
+
return { token: a, balance: C };
|
|
85
80
|
}
|
|
86
81
|
const l = new u(a.erc20TokenAddress), f = new u(t), i = await k(
|
|
87
82
|
l,
|
|
88
83
|
f,
|
|
89
84
|
!0,
|
|
90
|
-
a.is2022Program ? O :
|
|
85
|
+
a.is2022Program ? O : U
|
|
91
86
|
);
|
|
92
87
|
if (!await o.getAccountInfo(i))
|
|
93
88
|
return { token: a, balance: 0n };
|
|
94
|
-
const
|
|
95
|
-
return { token: a, balance:
|
|
89
|
+
const T = await o.getTokenAccountBalance(i), y = BigInt(T.value.amount);
|
|
90
|
+
return { token: a, balance: y };
|
|
96
91
|
})
|
|
97
92
|
)).filter((a) => a.balance > 0n);
|
|
98
93
|
};
|
|
99
94
|
export {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
95
|
+
F as getPublicBalance,
|
|
96
|
+
V as getPublicBalanceByTokenAddress,
|
|
97
|
+
Q as getPublicBalancesOfTokens,
|
|
98
|
+
X as getPublicTransactionCount,
|
|
99
|
+
Y as getSolanaPublicBalances
|
|
105
100
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../constants/server.constants.cjs"),r=require("../../API/getServerURL.cjs"),n=require("socket.io-client"),S=t=>{const o=`${r.SNAPSHOT_SERVER_URL.replace(e.SNAPSHOT_SERVER_URL_ENDPOINT,"")}${t}`;return n.io(o,{path:`${e.SNAPSHOT_SERVER_URL_ENDPOINT}/socket.io`})};exports.createSnapshotServerClientSocket=S;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createSnapshotServerClientSocket: (namespace: string) => import("socket.io-client").Socket<import("@socket.io/component-emitter").DefaultEventsMap, import("@socket.io/component-emitter").DefaultEventsMap>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SNAPSHOT_SERVER_URL_ENDPOINT as o } from "../../constants/server.constants.mjs";
|
|
2
|
+
import { SNAPSHOT_SERVER_URL as e } from "../../API/getServerURL.mjs";
|
|
3
|
+
import { io as n } from "socket.io-client";
|
|
4
|
+
const s = (t) => {
|
|
5
|
+
const r = `${e.replace(o, "")}${t}`;
|
|
6
|
+
return n(r, {
|
|
7
|
+
path: `${o}/socket.io`
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
s as createSnapshotServerClientSocket
|
|
12
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../constants/chains.constants.cjs");function i(t){return t?.toLowerCase().split(" ").map(e=>e.charAt(0).toUpperCase()+e.substring(1)).join(" ")}function o(t){return t.charAt(0).toUpperCase()+t.slice(1)}function c(t){return!t||t===null||Array.isArray(t)&&t.length===0?!0:Object.keys(t).length===0&&t.constructor===Object}const l=t=>{t.startsWith("0x")&&(t=t.slice(2));const e=[];for(let r=0;r<t.length;r+=2){const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../constants/chains.constants.cjs");function i(t){return t?.toLowerCase().split(" ").map(e=>e.charAt(0).toUpperCase()+e.substring(1)).join(" ")}function o(t){return t.charAt(0).toUpperCase()+t.slice(1)}function c(t){return!t||t===null||Array.isArray(t)&&t.length===0?!0:Object.keys(t).length===0&&t.constructor===Object}const l=t=>{t.startsWith("0x")&&(t=t.slice(2));const e=[];for(let r=0;r<t.length;r+=2){const n=parseInt(t.slice(r,r+2),16);e.push(n)}return new TextDecoder("utf-8").decode(new Uint8Array(e))},u=(t,e,s=!1)=>{const r=`${t}-${e}`;if(s){const{hinkalAddress:n}=a.networkRegistry[e].contractData;return`${r}-${n}`.toLowerCase()}return r.toLowerCase()},p=t=>{const[,e]=t.split("-");return Number(e)},f=t=>{const[e]=t.split("-");return e},d=(t,e,s)=>{if(!e||!s)throw Error("oldPart and newPart must be provided");return t.toLowerCase().split(e.toLowerCase()).join(s.toLowerCase())},g=t=>!t||t.trim().length===0?null:t.toLowerCase().replace(/\b\w/g,e=>e.toUpperCase()),y=t=>t?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t):!1;exports.capitalizeFirstLetter=o;exports.capitalizeName=g;exports.getAddressFromStateKey=f;exports.getChainIdFromStateKey=p;exports.getStateKey=u;exports.hexToUtf8=l;exports.isNullOrEmpty=c;exports.replaceAllInstances=d;exports.toTitleCase=i;exports.validateEmail=y;
|
|
@@ -9,6 +9,7 @@ export declare function isNullOrEmpty(obj: unknown): boolean;
|
|
|
9
9
|
export declare const hexToUtf8: (hex: string) => string;
|
|
10
10
|
export declare const getStateKey: (address: string, chainId: number, withHinkalContractAddress?: boolean) => string;
|
|
11
11
|
export declare const getChainIdFromStateKey: (stateKey: string) => number;
|
|
12
|
+
export declare const getAddressFromStateKey: (stateKey: string) => string;
|
|
12
13
|
export declare const replaceAllInstances: (text: string, oldPart: string, newPart: string) => string;
|
|
13
14
|
export declare const capitalizeName: (name: string | undefined | null) => string | null;
|
|
14
15
|
export declare const validateEmail: (email: string | undefined | null) => boolean;
|
|
@@ -12,33 +12,37 @@ const l = (t) => {
|
|
|
12
12
|
t.startsWith("0x") && (t = t.slice(2));
|
|
13
13
|
const e = [];
|
|
14
14
|
for (let r = 0; r < t.length; r += 2) {
|
|
15
|
-
const
|
|
16
|
-
e.push(
|
|
15
|
+
const n = parseInt(t.slice(r, r + 2), 16);
|
|
16
|
+
e.push(n);
|
|
17
17
|
}
|
|
18
18
|
return new TextDecoder("utf-8").decode(new Uint8Array(e));
|
|
19
|
-
},
|
|
19
|
+
}, p = (t, e, s = !1) => {
|
|
20
20
|
const r = `${t}-${e}`;
|
|
21
|
-
if (
|
|
22
|
-
const { hinkalAddress:
|
|
23
|
-
return `${r}-${
|
|
21
|
+
if (s) {
|
|
22
|
+
const { hinkalAddress: n } = o[e].contractData;
|
|
23
|
+
return `${r}-${n}`.toLowerCase();
|
|
24
24
|
}
|
|
25
25
|
return r.toLowerCase();
|
|
26
|
-
},
|
|
26
|
+
}, f = (t) => {
|
|
27
27
|
const [, e] = t.split("-");
|
|
28
28
|
return Number(e);
|
|
29
|
-
},
|
|
30
|
-
|
|
29
|
+
}, d = (t) => {
|
|
30
|
+
const [e] = t.split("-");
|
|
31
|
+
return e;
|
|
32
|
+
}, g = (t, e, s) => {
|
|
33
|
+
if (!e || !s)
|
|
31
34
|
throw Error("oldPart and newPart must be provided");
|
|
32
|
-
return t.toLowerCase().split(e.toLowerCase()).join(
|
|
33
|
-
}, w = (t) => !t || t.trim().length === 0 ? null : t.toLowerCase().replace(/\b\w/g, (e) => e.toUpperCase()),
|
|
35
|
+
return t.toLowerCase().split(e.toLowerCase()).join(s.toLowerCase());
|
|
36
|
+
}, w = (t) => !t || t.trim().length === 0 ? null : t.toLowerCase().replace(/\b\w/g, (e) => e.toUpperCase()), y = (t) => t ? /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t) : !1;
|
|
34
37
|
export {
|
|
35
38
|
c as capitalizeFirstLetter,
|
|
36
39
|
w as capitalizeName,
|
|
37
|
-
|
|
38
|
-
f as
|
|
40
|
+
d as getAddressFromStateKey,
|
|
41
|
+
f as getChainIdFromStateKey,
|
|
42
|
+
p as getStateKey,
|
|
39
43
|
l as hexToUtf8,
|
|
40
44
|
u as isNullOrEmpty,
|
|
41
45
|
g as replaceAllInstances,
|
|
42
46
|
a as toTitleCase,
|
|
43
|
-
|
|
47
|
+
y as validateEmail
|
|
44
48
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../web3/etherFunctions.cjs")
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../web3/etherFunctions.cjs"),i=(r,t,e,c,u)=>{try{return!e||!r?!0:c?u?+r*u<=+t:!0:n.getAmountInWei(e,r)<=n.getAmountInWei(e,t)}catch{return!0}};exports.hasEnoughBalance=i;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ERC20Token } from '../../types/token.types';
|
|
2
|
-
export declare
|
|
2
|
+
export declare const hasEnoughBalance: (tokenAmount: string, maxPossibleAmount: string, token: ERC20Token | undefined, isDollarMode: boolean, tokenPriceDollar: number | undefined) => boolean;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { getAmountInWei as f } from "../web3/etherFunctions.mjs";
|
|
2
|
-
|
|
2
|
+
const a = (r, u, t, c, e) => {
|
|
3
3
|
try {
|
|
4
|
-
return !
|
|
4
|
+
return !t || !r ? !0 : c ? e ? +r * e <= +u : !0 : f(t, r) <= f(t, u);
|
|
5
5
|
} catch {
|
|
6
6
|
return !0;
|
|
7
7
|
}
|
|
8
|
-
}
|
|
8
|
+
};
|
|
9
9
|
export {
|
|
10
|
-
|
|
10
|
+
a as hasEnoughBalance
|
|
11
11
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=async(t,e)=>{const a=typeof t=="string"?new TextEncoder().encode(t):t,n=await crypto.subtle.importKey("raw",a,{name:"HMAC",hash:"SHA-512"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,e);return new Uint8Array(r)};exports.hmacSha512=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const hmacSha512: (key: string | Uint8Array, data: Uint8Array) => Promise<Uint8Array>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const s = async (t, n) => {
|
|
2
|
+
const a = typeof t == "string" ? new TextEncoder().encode(t) : t, e = await crypto.subtle.importKey("raw", a, { name: "HMAC", hash: "SHA-512" }, !1, ["sign"]), r = await crypto.subtle.sign("HMAC", e, n);
|
|
3
|
+
return new Uint8Array(r);
|
|
4
|
+
};
|
|
5
|
+
export {
|
|
6
|
+
s as hmacSha512
|
|
7
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("../../utils/caseInsensitive.utils.cjs"),l=require("../../utils/cacheFunctions.cjs"),f=require("async-mutex"),m=require("../../utils/erc20tokenFunctions.cjs"),A=require("../../../data-structures/TokenDBs/PrivateTokensDB.cjs"),g=require("../../../constants/vite.constants.cjs"),y=new f.Mutex,x=(t,e,a)=>(t.forEach(s=>{s.inHinkalAddress===a&&e.push(s)}),e),v=(t,e,a=!1)=>{const{userKeys:s}=t;a&&l.resetInHinkalAddressesCache(t,e,s.getShieldedPublicKey());const{approvalsByChain:i}=t,n=l.getInHinkalAddressesCache(t,e,s.getShieldedPublicKey());let o=[];return i[e].forEach((p,u)=>{const r=n[u];let c;r?c=BigInt(r):(c=s.getInHinkalAddress(u),n[u]=c.toString()),o=x(p.map(d=>({...d,interactionAddress:u,chainId:e})),o,c)}),l.setInHinkalAddressesCache(n,t,e,s.getShieldedPublicKey()),o},T=(t,e,a,s)=>v(t,a,s).filter(n=>k.caseInsensitiveEqual(n.tokenAddress,e)).sort((n,o)=>n.amount===o.amount?0:n.amount>o.amount?-1:1),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("../../utils/caseInsensitive.utils.cjs"),l=require("../../utils/cacheFunctions.cjs"),f=require("async-mutex"),m=require("../../utils/erc20tokenFunctions.cjs"),A=require("../../../data-structures/TokenDBs/PrivateTokensDB.cjs"),g=require("../../../constants/vite.constants.cjs"),y=new f.Mutex,x=(t,e,a)=>(t.forEach(s=>{s.inHinkalAddress===a&&e.push(s)}),e),v=(t,e,a=!1)=>{const{userKeys:s}=t;a&&l.resetInHinkalAddressesCache(t,e,s.getShieldedPublicKey());const{approvalsByChain:i}=t,n=l.getInHinkalAddressesCache(t,e,s.getShieldedPublicKey());let o=[];return i[e].forEach((p,u)=>{const r=n[u];let c;r?c=BigInt(r):(c=s.getInHinkalAddress(u),n[u]=c.toString()),o=x(p.map(d=>({...d,interactionAddress:u,chainId:e})),o,c)}),l.setInHinkalAddressesCache(n,t,e,s.getShieldedPublicKey()),o},T=(t,e,a,s)=>v(t,a,s).filter(n=>k.caseInsensitiveEqual(n.tokenAddress,e)).sort((n,o)=>n.amount===o.amount?0:n.amount>o.amount?-1:1),B=async(t,e,a,s)=>{const i=await t.getEthereumAddressByChain(e);let n=[];const o=new Map;return await y.runExclusive(async()=>{const p=v(t,e,a);s&&g.isExtension&&await A.privateTokensDB.fetchAndUpdatePrivateTokens(p.map(r=>r.tokenAddress),e,i),n=(g.isExtension?await A.privateTokensDB.getPrivateTokens(e,i):m.getErc20TokensForChain(e)).map(r=>({token:r,balance:p.reduce((c,d)=>k.caseInsensitiveEqual(r.erc20TokenAddress,d.tokenAddress)?c+d.amount:c,0n),timestamp:"0",nfts:[]})),n.forEach(r=>{o.set(r.token.erc20TokenAddress.toLowerCase(),r)})}),o};exports.getApprovedBalance=B;exports.getApprovedUtxos=v;exports.getApprovedUtxosForToken=T;
|
|
@@ -4,37 +4,37 @@ import { Mutex as y } from "async-mutex";
|
|
|
4
4
|
import { getErc20TokensForChain as x } from "../../utils/erc20tokenFunctions.mjs";
|
|
5
5
|
import { privateTokensDB as m } from "../../../data-structures/TokenDBs/PrivateTokensDB.mjs";
|
|
6
6
|
import { isExtension as u } from "../../../constants/vite.constants.mjs";
|
|
7
|
-
const
|
|
7
|
+
const C = new y(), E = (t, e, a) => (t.forEach((s) => {
|
|
8
8
|
s.inHinkalAddress === a && e.push(s);
|
|
9
9
|
}), e), A = (t, e, a = !1) => {
|
|
10
10
|
const { userKeys: s } = t;
|
|
11
11
|
a && g(t, e, s.getShieldedPublicKey());
|
|
12
|
-
const { approvalsByChain:
|
|
12
|
+
const { approvalsByChain: i } = t, r = v(t, e, s.getShieldedPublicKey());
|
|
13
13
|
let n = [];
|
|
14
|
-
return
|
|
15
|
-
const o = r[
|
|
14
|
+
return i[e].forEach((l, d) => {
|
|
15
|
+
const o = r[d];
|
|
16
16
|
let p;
|
|
17
|
-
o ? p = BigInt(o) : (p = s.getInHinkalAddress(
|
|
18
|
-
|
|
19
|
-
(
|
|
17
|
+
o ? p = BigInt(o) : (p = s.getInHinkalAddress(d), r[d] = p.toString()), n = E(
|
|
18
|
+
l.map(
|
|
19
|
+
(c) => ({ ...c, interactionAddress: d, chainId: e })
|
|
20
20
|
),
|
|
21
21
|
n,
|
|
22
22
|
p
|
|
23
23
|
);
|
|
24
24
|
}), k(r, t, e, s.getShieldedPublicKey()), n;
|
|
25
25
|
}, K = (t, e, a, s) => A(t, a, s).filter((r) => f(r.tokenAddress, e)).sort((r, n) => r.amount === n.amount ? 0 : r.amount > n.amount ? -1 : 1), M = async (t, e, a, s) => {
|
|
26
|
-
const
|
|
26
|
+
const i = await t.getEthereumAddressByChain(e);
|
|
27
27
|
let r = [];
|
|
28
28
|
const n = /* @__PURE__ */ new Map();
|
|
29
|
-
return await
|
|
30
|
-
const
|
|
29
|
+
return await C.runExclusive(async () => {
|
|
30
|
+
const l = A(t, e, a);
|
|
31
31
|
s && u && await m.fetchAndUpdatePrivateTokens(
|
|
32
|
-
|
|
32
|
+
l.map((o) => o.tokenAddress),
|
|
33
33
|
e,
|
|
34
|
-
|
|
35
|
-
), r = (u ? await m.getPrivateTokens(e,
|
|
34
|
+
i
|
|
35
|
+
), r = (u ? await m.getPrivateTokens(e, i) : x(e)).map((o) => ({
|
|
36
36
|
token: o,
|
|
37
|
-
balance:
|
|
37
|
+
balance: l.reduce((p, c) => f(o.erc20TokenAddress, c.tokenAddress) ? p + c.amount : p, 0n),
|
|
38
38
|
timestamp: "0",
|
|
39
39
|
nfts: []
|
|
40
40
|
})), r.forEach((o) => {
|