@hinkal/common 0.2.19 → 0.2.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API/API.cjs +1 -1
- package/API/API.d.ts +6 -1
- package/API/API.mjs +48 -41
- package/API/enclaveCalls.cjs +1 -1
- package/API/enclaveCalls.mjs +5 -4
- package/API/index.d.ts +1 -0
- package/API/proxyAccountsCalls.cjs +1 -1
- package/API/proxyAccountsCalls.d.ts +7 -2
- package/API/proxyAccountsCalls.mjs +26 -20
- package/API/temporaryWalletCalls.cjs +1 -0
- package/API/temporaryWalletCalls.d.ts +13 -0
- package/API/temporaryWalletCalls.mjs +20 -0
- package/API/unspent-utxos-calls.cjs +1 -1
- package/API/unspent-utxos-calls.d.ts +1 -1
- package/API/unspent-utxos-calls.mjs +16 -14
- package/README.md +36 -13
- package/constants/chains.constants.cjs +1 -1
- package/constants/chains.constants.d.ts +1 -1
- package/constants/chains.constants.mjs +69 -51
- package/constants/deploy-data/deploy-data-solana.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-solana.json.mjs +28 -2
- package/constants/kyc.constants.cjs +1 -1
- package/constants/kyc.constants.mjs +39 -40
- package/constants/mediaUrls.constants.cjs +1 -1
- package/constants/mediaUrls.constants.d.ts +1 -0
- package/constants/mediaUrls.constants.mjs +2 -1
- package/constants/server.constants.cjs +1 -1
- package/constants/server.constants.d.ts +6 -1
- package/constants/server.constants.mjs +37 -32
- package/constants/token-data/polygonRegistry.json.cjs +1 -1
- package/constants/token-data/polygonRegistry.json.mjs +4 -4
- package/constants/token-data/polygonRegistryFixed.json.cjs +1 -1
- package/constants/token-data/polygonRegistryFixed.json.mjs +4 -4
- package/data-structures/AccountActions/AccountActions.cjs +1 -0
- package/data-structures/AccountActions/AccountActions.d.ts +18 -0
- package/data-structures/AccountActions/AccountActions.mjs +78 -0
- package/data-structures/AccountActions/index.d.ts +1 -0
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.cjs +1 -1
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.mjs +68 -71
- package/data-structures/BlockchainEvent/BlockchainEvent.cjs +1 -0
- package/data-structures/BlockchainEvent/BlockchainEvent.d.ts +14 -0
- package/data-structures/BlockchainEvent/BlockchainEvent.mjs +41 -0
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +14 -8
- package/data-structures/Hinkal/Hinkal.mjs +215 -179
- package/data-structures/Hinkal/IHinkal.d.ts +9 -6
- package/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.mjs +47 -48
- package/data-structures/Hinkal/hinkalActionReceive.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionReceive.mjs +25 -22
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -1
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +12 -12
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +63 -63
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +60 -147
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -0
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.d.ts +4 -0
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +103 -0
- package/data-structures/Hinkal/hinkalDepostAndBridge.cjs +1 -0
- package/data-structures/Hinkal/hinkalDepostAndBridge.d.ts +4 -0
- package/data-structures/Hinkal/hinkalDepostAndBridge.mjs +214 -0
- package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
- package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +4 -4
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.d.ts +2 -2
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +103 -99
- package/data-structures/Hinkal/hinkalProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxySwap.mjs +44 -41
- package/data-structures/Hinkal/hinkalProxyToPrivate.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxyToPrivate.mjs +31 -28
- package/data-structures/Hinkal/hinkalSignSubAccount.cjs +1 -1
- package/data-structures/Hinkal/hinkalSignSubAccount.mjs +16 -13
- package/data-structures/Hinkal/hinkalSolanaDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDeposit.mjs +34 -34
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +67 -65
- package/data-structures/Hinkal/hinkalSolanaProxySend.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySend.mjs +35 -32
- package/data-structures/Hinkal/hinkalSolanaProxyShield.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxyShield.mjs +59 -56
- package/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +35 -32
- package/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaSwap.mjs +10 -10
- package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +25 -25
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +34 -30
- package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalTransfer.mjs +43 -39
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +47 -43
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +50 -46
- package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.mjs +36 -34
- package/data-structures/IndexedDB/activity-db.cjs +1 -1
- package/data-structures/IndexedDB/activity-db.d.ts +1 -0
- package/data-structures/IndexedDB/activity-db.mjs +86 -70
- package/data-structures/IndexedDB/balances-db.cjs +1 -1
- package/data-structures/IndexedDB/balances-db.mjs +33 -30
- package/data-structures/IndexedDB/contact-db.cjs +1 -1
- package/data-structures/IndexedDB/contact-db.mjs +9 -6
- package/data-structures/PublicBalance/PublicBalanceWatcher.cjs +1 -0
- package/data-structures/PublicBalance/PublicBalanceWatcher.d.ts +20 -0
- package/data-structures/PublicBalance/PublicBalanceWatcher.mjs +124 -0
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.cjs +1 -0
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.d.ts +15 -0
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.mjs +64 -0
- package/data-structures/PublicBalance/index.d.ts +2 -0
- package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +77 -78
- package/data-structures/crypto-keys/keys.cjs +1 -1
- package/data-structures/crypto-keys/keys.d.ts +0 -11
- package/data-structures/crypto-keys/keys.mjs +47 -107
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.d.ts +3 -2
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.mjs +9 -9
- package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.d.ts +3 -2
- package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.mjs +5 -5
- package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.d.ts +3 -2
- package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.mjs +6 -6
- package/data-structures/event-service/evm/AbstractEventService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractEventService.d.ts +3 -2
- package/data-structures/event-service/evm/AbstractEventService.mjs +16 -19
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.d.ts +3 -3
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.mjs +6 -5
- package/data-structures/event-service/evm/AbstractSnapshotService.d.ts +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.d.ts +7 -4
- package/data-structures/event-service/evm/BlockchainEventEmitter.mjs +35 -34
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.cjs +1 -0
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.d.ts +11 -0
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.mjs +21 -0
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.cjs +1 -0
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.d.ts +6 -0
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.mjs +16 -0
- package/data-structures/event-service/helpers/ClientEventHelper.cjs +1 -0
- package/data-structures/event-service/helpers/ClientEventHelper.d.ts +11 -0
- package/data-structures/event-service/helpers/ClientEventHelper.mjs +26 -0
- package/data-structures/event-service/helpers/PollingEventHelper.cjs +1 -0
- package/data-structures/event-service/helpers/PollingEventHelper.d.ts +5 -0
- package/data-structures/event-service/helpers/PollingEventHelper.mjs +14 -0
- package/data-structures/event-service/index.d.ts +4 -0
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.d.ts +3 -2
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.mjs +6 -6
- package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.d.ts +4 -3
- package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.mjs +8 -8
- package/data-structures/event-service/solana/AbstractSolanaEventService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaEventService.d.ts +3 -10
- package/data-structures/event-service/solana/AbstractSolanaEventService.mjs +5 -5
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.d.ts +3 -2
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.mjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.d.ts +1 -1
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.cjs +1 -0
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.d.ts +11 -0
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.mjs +22 -0
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.cjs +1 -0
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.d.ts +6 -0
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.mjs +16 -0
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.d.ts +8 -14
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.mjs +68 -67
- package/data-structures/index.d.ts +3 -0
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.mjs +5 -2
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +5 -2
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.mjs +5 -2
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.mjs +5 -2
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.mjs +5 -2
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.mjs +5 -2
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.mjs +5 -2
- package/data-structures/utxo/Utxo.cjs +1 -1
- package/data-structures/utxo/Utxo.d.ts +1 -0
- package/data-structures/utxo/Utxo.mjs +18 -4
- package/error-handling/error-codes.constants.cjs +1 -1
- package/error-handling/error-codes.constants.mjs +2 -2
- package/functions/pre-transaction/getSolanaCalldataHash.cjs +1 -1
- package/functions/pre-transaction/getSolanaCalldataHash.mjs +22 -22
- package/functions/pre-transaction/sendV0Transaction.cjs +1 -1
- package/functions/pre-transaction/sendV0Transaction.mjs +53 -50
- package/functions/pre-transaction/solana.cjs +1 -1
- package/functions/pre-transaction/solana.mjs +93 -93
- package/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.helpers.d.ts +3 -2
- package/functions/private-wallet/emporium.helpers.mjs +118 -93
- package/functions/snarkjs/constructEmporiumProof.cjs +1 -1
- package/functions/snarkjs/constructEmporiumProof.d.ts +1 -2
- package/functions/snarkjs/constructEmporiumProof.mjs +89 -89
- package/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/functions/snarkjs/constructSolanaZkProof.mjs +6 -2
- package/functions/utils/bytes32.utils.cjs +1 -1
- package/functions/utils/bytes32.utils.mjs +8 -7
- package/functions/utils/create-provider.cjs +1 -1
- package/functions/utils/create-provider.d.ts +1 -1
- package/functions/utils/create-provider.mjs +13 -9
- package/functions/utils/index.d.ts +0 -1
- package/functions/utils/prepareHinkal.cjs +1 -1
- package/functions/utils/prepareHinkal.d.ts +6 -7
- package/functions/utils/prepareHinkal.mjs +45 -53
- package/functions/utils/publicBalance.utils.cjs +1 -1
- package/functions/utils/publicBalance.utils.mjs +49 -54
- package/functions/utils/socket.utils.cjs +1 -0
- package/functions/utils/socket.utils.d.ts +1 -0
- package/functions/utils/socket.utils.mjs +12 -0
- package/functions/utils/string.utils.cjs +1 -1
- package/functions/utils/string.utils.d.ts +1 -0
- package/functions/utils/string.utils.mjs +18 -14
- package/functions/utils/walletBalances.utils.cjs +1 -1
- package/functions/utils/walletBalances.utils.d.ts +1 -1
- package/functions/utils/walletBalances.utils.mjs +4 -4
- package/functions/web3/crypto.cjs +1 -0
- package/functions/web3/crypto.d.ts +1 -0
- package/functions/web3/crypto.mjs +7 -0
- package/functions/web3/events/getApprovedBalance.cjs +1 -1
- package/functions/web3/events/getApprovedBalance.mjs +14 -14
- package/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
- package/functions/web3/events/getInputUtxoAndBalance.mjs +61 -59
- package/functions/web3/events/getTransactionLogEvents.cjs +1 -1
- package/functions/web3/events/getTransactionLogEvents.mjs +32 -32
- package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +6 -3
- package/functions/web3/functionCalls/approveToken.cjs +1 -1
- package/functions/web3/functionCalls/approveToken.mjs +17 -17
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +16 -16
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.mjs +13 -11
- package/functions/web3/getContractMetadata.cjs +1 -1
- package/functions/web3/getContractMetadata.mjs +17 -22
- package/functions/web3/getTokenHolder.cjs +1 -1
- package/functions/web3/getTokenHolder.mjs +20 -20
- package/functions/web3/index.d.ts +1 -0
- package/index.cjs +1 -1
- package/index.mjs +913 -890
- package/package.json +3 -2
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.mjs +2 -5
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +11 -4
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +11 -4
- package/types/activities.types.d.ts +2 -0
- package/types/bridging-tx.types.d.ts +17 -0
- package/types/cache.types.cjs +1 -1
- package/types/cache.types.d.ts +5 -1
- package/types/cache.types.mjs +1 -1
- package/types/ethereum-network.types.d.ts +1 -0
- package/types/events.types.cjs +1 -0
- package/types/events.types.d.ts +9 -0
- package/types/events.types.mjs +5 -0
- package/types/index.d.ts +2 -0
- package/types/proxy.types.d.ts +11 -4
- package/types/sandbox.types.d.ts +2 -0
- package/types/solana.types.d.ts +8 -0
- package/types/token.types.d.ts +5 -0
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
- package/functions/kyc/authentoHelper.cjs +0 -1
- package/functions/kyc/authentoHelper.d.ts +0 -12
- package/functions/kyc/authentoHelper.mjs +0 -30
- package/functions/utils/get-hinkal-approvals.cjs +0 -1
- package/functions/utils/get-hinkal-approvals.d.ts +0 -3
- package/functions/utils/get-hinkal-approvals.mjs +0 -38
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("../../error-handling/error-codes.constants.cjs"),f=require("../../functions/utils/addresses.cjs"),C=require("../../functions/pre-transaction/getVolatileTransferAmount.cjs"),q=require("../../functions/private-wallet/emporium.helpers.cjs"),y=require("../../functions/pre-transaction/getFeeStructure.cjs"),g=require("../../types/external-action.types.cjs"),w=require("../../functions/utils/convertEmporiumOpToCallInfo.cjs"),T=require("../../functions/utils/token-check.utils.cjs"),I=require("../AccountActions/AccountActions.cjs"),O=async(s,r,l,c,o,m,n,p,A=!1)=>{if(!n)throw Error("hinkalProxyToPrivate: subAccount should be provided");if(!o)throw new Error("Fee token is required in hinkalProxyToPrivate");if(!f.isValidPrivateAddress(c))throw Error(P.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);const e=T.validateAndGetChainId(r),i=I.AccountActions.getAddressFromSubAccount(e,n);if(!i)throw Error("Public account address is not available");const u=r.map(t=>t.erc20TokenAddress),a=await C.modifyVolatileTokenAmountChanges(e,r,l,i),d=q.createTransaferEmporiumOpsBatch(s,e,u,a),h=m??await y.getFeeStructure(e,o,u,g.ExternalActionId.Emporium,d.map(t=>w.convertEmporiumOpToCallInfo(t,i,e))),v=r.map((t,E)=>({token:t,amount:-1n*a[E]}));return s.actionPrivateWallet(e,[r[0]],[0n],[!1],d,v,n,o,h,void 0,void 0,void 0,p,{recipientInfo:c,amount:a[0],token:r[0]},A)};exports.hinkalProxyToPrivate=O;
|
|
@@ -1,47 +1,50 @@
|
|
|
1
|
-
import { transactionErrorCodes as
|
|
2
|
-
import { isValidPrivateAddress as
|
|
3
|
-
import { modifyVolatileTokenAmountChanges as
|
|
1
|
+
import { transactionErrorCodes as E } from "../../error-handling/error-codes.constants.mjs";
|
|
2
|
+
import { isValidPrivateAddress as P } from "../../functions/utils/addresses.mjs";
|
|
3
|
+
import { modifyVolatileTokenAmountChanges as w } from "../../functions/pre-transaction/getVolatileTransferAmount.mjs";
|
|
4
4
|
import { createTransaferEmporiumOpsBatch as C } from "../../functions/private-wallet/emporium.helpers.mjs";
|
|
5
|
-
import { getFeeStructure as
|
|
6
|
-
import { ExternalActionId as
|
|
7
|
-
import { convertEmporiumOpToCallInfo as
|
|
8
|
-
import { UserKeys as x } from "../crypto-keys/keys.mjs";
|
|
5
|
+
import { getFeeStructure as I } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
6
|
+
import { ExternalActionId as x } from "../../types/external-action.types.mjs";
|
|
7
|
+
import { convertEmporiumOpToCallInfo as y } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
|
|
9
8
|
import { validateAndGetChainId as O } from "../../functions/utils/token-check.utils.mjs";
|
|
10
|
-
|
|
9
|
+
import { AccountActions as g } from "../AccountActions/AccountActions.mjs";
|
|
10
|
+
const B = async (n, r, l, s, a, p, i, u, f = !1) => {
|
|
11
11
|
if (!i)
|
|
12
12
|
throw Error("hinkalProxyToPrivate: subAccount should be provided");
|
|
13
|
-
if (!
|
|
13
|
+
if (!a)
|
|
14
14
|
throw new Error("Fee token is required in hinkalProxyToPrivate");
|
|
15
|
-
if (!
|
|
16
|
-
throw Error(
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
if (!P(s))
|
|
16
|
+
throw Error(E.RECIPIENT_FORMAT_INCORRECT);
|
|
17
|
+
const o = O(r), e = g.getAddressFromSubAccount(o, i);
|
|
18
|
+
if (!e)
|
|
19
|
+
throw Error("Public account address is not available");
|
|
20
|
+
const d = r.map((t) => t.erc20TokenAddress), m = await w(o, r, l, e), c = C(n, o, d, m), h = p ?? await I(
|
|
21
|
+
o,
|
|
20
22
|
a,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
d,
|
|
24
|
+
x.Emporium,
|
|
25
|
+
c.map((t) => y(t, e, o))
|
|
26
|
+
), v = r.map((t, A) => ({
|
|
24
27
|
token: t,
|
|
25
|
-
amount: -1n * m[
|
|
28
|
+
amount: -1n * m[A]
|
|
26
29
|
}));
|
|
27
30
|
return n.actionPrivateWallet(
|
|
28
|
-
|
|
29
|
-
[
|
|
31
|
+
o,
|
|
32
|
+
[r[0]],
|
|
30
33
|
[0n],
|
|
31
34
|
[!1],
|
|
32
|
-
|
|
33
|
-
h,
|
|
34
|
-
i,
|
|
35
|
-
e,
|
|
35
|
+
c,
|
|
36
36
|
v,
|
|
37
|
+
i,
|
|
38
|
+
a,
|
|
39
|
+
h,
|
|
37
40
|
void 0,
|
|
38
41
|
void 0,
|
|
39
42
|
void 0,
|
|
40
|
-
|
|
41
|
-
{ recipientInfo: s, amount: m[0], token:
|
|
42
|
-
|
|
43
|
+
u,
|
|
44
|
+
{ recipientInfo: s, amount: m[0], token: r[0] },
|
|
45
|
+
f
|
|
43
46
|
);
|
|
44
47
|
};
|
|
45
48
|
export {
|
|
46
|
-
|
|
49
|
+
B as hinkalProxyToPrivate
|
|
47
50
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../AccountActions/AccountActions.cjs"),a=async(e,n,t,c)=>{let i;const o=r.AccountActions.getPrivateKeyFromSubAccount(e,c);if(!o)throw Error("Private key is not available");if(t)i=await r.AccountActions.signTypedDataFromPrivateKey(e,o,t.domain,t.types,t.value);else{if(!n)throw Error("dataHash must be provided if typedData is not provided");i=await r.AccountActions.signMessageFromPrivateKey(e,o,n)}return i};exports.hinkalSignSubAccount=a;
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const
|
|
3
|
-
let
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { AccountActions as o } from "../AccountActions/AccountActions.mjs";
|
|
2
|
+
const u = async (t, a, r, n) => {
|
|
3
|
+
let e;
|
|
4
|
+
const i = o.getPrivateKeyFromSubAccount(t, n);
|
|
5
|
+
if (!i)
|
|
6
|
+
throw Error("Private key is not available");
|
|
7
|
+
if (r)
|
|
8
|
+
e = await o.signTypedDataFromPrivateKey(
|
|
9
|
+
t,
|
|
6
10
|
i,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
e.value
|
|
11
|
+
r.domain,
|
|
12
|
+
r.types,
|
|
13
|
+
r.value
|
|
11
14
|
);
|
|
12
15
|
else {
|
|
13
|
-
if (!
|
|
16
|
+
if (!a)
|
|
14
17
|
throw Error("dataHash must be provided if typedData is not provided");
|
|
15
|
-
|
|
18
|
+
e = await o.signMessageFromPrivateKey(t, i, a);
|
|
16
19
|
}
|
|
17
|
-
return
|
|
20
|
+
return e;
|
|
18
21
|
};
|
|
19
22
|
export {
|
|
20
|
-
|
|
23
|
+
u as hinkalSignSubAccount
|
|
21
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("../utxo/Utxo.cjs"),M=require("../../functions/utils/solanaMint.utils.cjs"),z=require("../../functions/web3/etherFunctions.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("../utxo/Utxo.cjs"),M=require("../../functions/utils/solanaMint.utils.cjs"),z=require("../../functions/web3/etherFunctions.cjs"),B=require("../../constants/chains.constants.cjs"),K=require("../../constants/protocol.constants.cjs"),d=require("@solana/web3.js"),N=require("../../functions/snarkjs/common.snarkjs.cjs"),G=require("@coral-xyz/anchor"),E=require("../../functions/utils/addresses.cjs"),H=require("../../error-handling/error-codes.constants.cjs"),i=require("../../functions/pre-transaction/solana.cjs");require("../../API/getServerURL.cjs");require("axios");require("../../constants/coingecko.constants.cjs");require("../../constants/server.constants.cjs");require("../http/HttpClient.cjs");const _=require("../../API/API.cjs");require("../../API/tenderly.api.cjs");require("../../constants/token-data/index.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/vite.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");const L=require("./hinkalCheckSolanaTokenRegistry.cjs"),O=require("../../functions/web3/signAndSendSerializedTransaction.cjs"),x=require("../../functions/utils/token-check.utils.cjs"),F=async(e,o,a,r)=>{const n=x.validateAndGetChainId([a]),c=a.erc20TokenAddress,{hinkalIdl:A,hinkalAddress:m,originalDeployer:g}=B.networkRegistry[n].contractData;if(!A)throw new Error("No IDL configured for Solana program on this network");if(!g)throw new Error("missing original deployer");const l=e.getSolanaProgram(A),D=e.getSolanaPublicKey(),t=new d.PublicKey(g),h=new d.PublicKey(m),{mintPublicKey:s}=M.formatMintAddress(c),u=s.toString(),S=i.getStorageAccountPublicKey(h,t),P=i.getStorageVaultPublicKey(h,t),f=i.getMerkleAccountPublicKey(h,t),p=i.buildAnchorStealthAddressStructure(r);if(await L.hinkalCheckSolanaTokenRegistry(l,new d.PublicKey(t),[c],[o])){const{serializedTransaction:q,blockhash:T,lastValidBlockHeight:I}=await _.API.generateProoflessDepositLimitless({amount:o.toString(),payer:e.getSolanaPublicKey().toBase58(),ethereumAddress:await e.getEthereumAddressByChain(n),mint:c,stealthAddressStructure:p,chainId:n}),{wallet:b}=l.provider;if(!b)throw new Error("missing wallet");return O.signAndSendSerializedTransaction(l.provider,q,T,I)}const k=i.getTokenLimitStorageAccountPublicKey(l.programId,t,s),v=u===K.solanaNativeAddress?null:s,w=u===K.solanaNativeAddress?null:void 0;return l.methods.prooflessDeposit(new G.BN(o.toString()),p).accounts({mint:v,signer:D,signerAta:w,originalDeployer:t,storageAccount:S,storageVault:P,merkleAccount:f,tokenLimitStorage:k,storageVaultAta:w,accessTokenOwner:null}).rpc()},$=async(e,o,a)=>{const r=e.userKeys.getShieldedPrivateKey(),n=V.Utxo.findCorrectRandomization(z.randomBigInt(31),r),c=N.calcStealthAddressStructure(n,r);return F(e,o,a,c)},J=async(e,o,a,r)=>{if(!E.isValidPrivateAddress(r))throw Error(H.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);const n=E.constructStealthAddressStructure(r);return F(e,o,a,n)},Q=async(e,o,a)=>{const r=x.validateAndGetChainId([a]),n=a.erc20TokenAddress,{hinkalIdl:c,hinkalAddress:A,originalDeployer:m}=B.networkRegistry[r].contractData;if(!c)throw new Error("No IDL configured for Solana program on this network");if(!m)throw new Error("missing original deployer");const g=e.userKeys.getShieldedPrivateKey(),l=V.Utxo.findCorrectRandomization(z.randomBigInt(31),g),D=N.calcStealthAddressStructure(l,g),t=e.getSolanaProgram(c),h=e.getSolanaPublicKey(),s=new d.PublicKey(m),u=new d.PublicKey(A),{mintPublicKey:S}=M.formatMintAddress(n),P=S.toString(),f=i.getStorageAccountPublicKey(u,s),p=i.getStorageVaultPublicKey(u,s),C=i.getMerkleAccountPublicKey(u,s),k=i.buildAnchorStealthAddressStructure(D),v=o.reduce((y,R)=>y+R,0n),w=await L.hinkalCheckSolanaTokenRegistry(t,new d.PublicKey(s),[n],[v]),q=o.map(y=>`${y}`);if(w){const{serializedTransaction:y,blockhash:R,lastValidBlockHeight:j}=await _.API.generateMultiPaymentDepositLimitless({amounts:q,payer:e.getSolanaPublicKey().toBase58(),ethereumAddress:await e.getEthereumAddressByChain(r),mint:n,stealthAddressStructure:k,chainId:r}),{wallet:U}=t.provider;if(!U)throw new Error("missing wallet");return O.signAndSendSerializedTransaction(t.provider,y,R,j)}const T=i.getTokenLimitStorageAccountPublicKey(t.programId,s,S),I=P===K.solanaNativeAddress?null:S,b=P===K.solanaNativeAddress?null:void 0;return t.methods.multiPaymentDeposit(q,k).accounts({mint:I,signer:h,signerAta:b,originalDeployer:s,storageAccount:f,storageVault:p,merkleAccount:C,tokenLimitStorage:T,storageVaultAta:b,accessTokenOwner:null}).rpc()};exports.hinkalSolanaDeposit=$;exports.hinkalSolanaDepositForOther=J;exports.hinkalSolanaMultiPaymentDeposit=Q;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Utxo as
|
|
2
|
-
import { formatMintAddress as
|
|
3
|
-
import { randomBigInt as
|
|
4
|
-
import { networkRegistry as
|
|
1
|
+
import { Utxo as C } from "../utxo/Utxo.mjs";
|
|
2
|
+
import { formatMintAddress as V } from "../../functions/utils/solanaMint.utils.mjs";
|
|
3
|
+
import { randomBigInt as B } from "../../functions/web3/etherFunctions.mjs";
|
|
4
|
+
import { networkRegistry as z } from "../../constants/chains.constants.mjs";
|
|
5
5
|
import { solanaNativeAddress as K } from "../../constants/protocol.constants.mjs";
|
|
6
6
|
import { PublicKey as d } from "@solana/web3.js";
|
|
7
|
-
import { calcStealthAddressStructure as
|
|
7
|
+
import { calcStealthAddressStructure as L } from "../../functions/snarkjs/common.snarkjs.mjs";
|
|
8
8
|
import { BN as J } from "@coral-xyz/anchor";
|
|
9
9
|
import { isValidPrivateAddress as Q, constructStealthAddressStructure as W } from "../../functions/utils/addresses.mjs";
|
|
10
10
|
import { transactionErrorCodes as X } from "../../error-handling/error-codes.constants.mjs";
|
|
@@ -30,85 +30,85 @@ import "../../constants/events.constants.mjs";
|
|
|
30
30
|
import { hinkalCheckSolanaTokenRegistry as H } from "./hinkalCheckSolanaTokenRegistry.mjs";
|
|
31
31
|
import { signAndSendSerializedTransaction as _ } from "../../functions/web3/signAndSendSerializedTransaction.mjs";
|
|
32
32
|
import { validateAndGetChainId as G } from "../../functions/utils/token-check.utils.mjs";
|
|
33
|
-
const U = async (t,
|
|
34
|
-
const
|
|
33
|
+
const U = async (t, n, s, o) => {
|
|
34
|
+
const e = G([s]), a = s.erc20TokenAddress, { hinkalIdl: h, hinkalAddress: S, originalDeployer: m } = z[e].contractData;
|
|
35
35
|
if (!h)
|
|
36
36
|
throw new Error("No IDL configured for Solana program on this network");
|
|
37
37
|
if (!m)
|
|
38
38
|
throw new Error("missing original deployer");
|
|
39
|
-
const c = t.getSolanaProgram(h), D = t.getSolanaPublicKey(), r = new d(m), u = new d(S), { mintPublicKey: i } =
|
|
39
|
+
const c = t.getSolanaProgram(h), D = t.getSolanaPublicKey(), r = new d(m), u = new d(S), { mintPublicKey: i } = V(a), l = i.toString(), g = N(u, r), y = M(u, r), b = O(u, r), A = x(o);
|
|
40
40
|
if (await H(
|
|
41
41
|
c,
|
|
42
42
|
new d(r),
|
|
43
43
|
[a],
|
|
44
|
-
[
|
|
44
|
+
[n]
|
|
45
45
|
)) {
|
|
46
46
|
const { serializedTransaction: P, blockhash: E, lastValidBlockHeight: I } = await F.generateProoflessDepositLimitless({
|
|
47
|
-
amount:
|
|
47
|
+
amount: n.toString(),
|
|
48
48
|
payer: t.getSolanaPublicKey().toBase58(),
|
|
49
|
-
ethereumAddress: await t.
|
|
49
|
+
ethereumAddress: await t.getEthereumAddressByChain(e),
|
|
50
50
|
mint: a,
|
|
51
|
-
stealthAddressStructure:
|
|
52
|
-
chainId:
|
|
51
|
+
stealthAddressStructure: A,
|
|
52
|
+
chainId: e
|
|
53
53
|
}), { wallet: k } = c.provider;
|
|
54
54
|
if (!k)
|
|
55
55
|
throw new Error("missing wallet");
|
|
56
56
|
return _(c.provider, P, E, I);
|
|
57
57
|
}
|
|
58
58
|
const w = q(c.programId, r, i), v = l === K ? null : i, f = l === K ? null : void 0;
|
|
59
|
-
return c.methods.prooflessDeposit(new J(
|
|
59
|
+
return c.methods.prooflessDeposit(new J(n.toString()), A).accounts({
|
|
60
60
|
mint: v,
|
|
61
61
|
signer: D,
|
|
62
62
|
signerAta: f,
|
|
63
63
|
originalDeployer: r,
|
|
64
64
|
storageAccount: g,
|
|
65
|
-
storageVault:
|
|
65
|
+
storageVault: y,
|
|
66
66
|
merkleAccount: b,
|
|
67
67
|
tokenLimitStorage: w,
|
|
68
68
|
storageVaultAta: f,
|
|
69
69
|
accessTokenOwner: null
|
|
70
70
|
}).rpc();
|
|
71
|
-
}, Tt = async (t,
|
|
72
|
-
const
|
|
73
|
-
return U(t,
|
|
74
|
-
},
|
|
75
|
-
if (!Q(
|
|
71
|
+
}, Tt = async (t, n, s) => {
|
|
72
|
+
const o = t.userKeys.getShieldedPrivateKey(), e = C.findCorrectRandomization(B(31), o), a = L(e, o);
|
|
73
|
+
return U(t, n, s, a);
|
|
74
|
+
}, Ct = async (t, n, s, o) => {
|
|
75
|
+
if (!Q(o))
|
|
76
76
|
throw Error(X.RECIPIENT_FORMAT_INCORRECT);
|
|
77
|
-
const
|
|
78
|
-
return U(t,
|
|
79
|
-
},
|
|
80
|
-
const
|
|
77
|
+
const e = W(o);
|
|
78
|
+
return U(t, n, s, e);
|
|
79
|
+
}, Vt = async (t, n, s) => {
|
|
80
|
+
const o = G([s]), e = s.erc20TokenAddress, { hinkalIdl: a, hinkalAddress: h, originalDeployer: S } = z[o].contractData;
|
|
81
81
|
if (!a)
|
|
82
82
|
throw new Error("No IDL configured for Solana program on this network");
|
|
83
83
|
if (!S)
|
|
84
84
|
throw new Error("missing original deployer");
|
|
85
|
-
const m = t.userKeys.getShieldedPrivateKey(), c =
|
|
85
|
+
const m = t.userKeys.getShieldedPrivateKey(), c = C.findCorrectRandomization(B(31), m), D = L(c, m), r = t.getSolanaProgram(a), u = t.getSolanaPublicKey(), i = new d(S), l = new d(h), { mintPublicKey: g } = V(e), y = g.toString(), b = N(l, i), A = M(l, i), T = O(l, i), w = x(D), v = n.reduce((p, R) => p + R, 0n), f = await H(
|
|
86
86
|
r,
|
|
87
87
|
new d(i),
|
|
88
|
-
[
|
|
88
|
+
[e],
|
|
89
89
|
[v]
|
|
90
|
-
), P =
|
|
90
|
+
), P = n.map((p) => `${p}`);
|
|
91
91
|
if (f) {
|
|
92
92
|
const { serializedTransaction: p, blockhash: R, lastValidBlockHeight: $ } = await F.generateMultiPaymentDepositLimitless({
|
|
93
93
|
amounts: P,
|
|
94
94
|
payer: t.getSolanaPublicKey().toBase58(),
|
|
95
|
-
ethereumAddress: await t.
|
|
96
|
-
mint:
|
|
95
|
+
ethereumAddress: await t.getEthereumAddressByChain(o),
|
|
96
|
+
mint: e,
|
|
97
97
|
stealthAddressStructure: w,
|
|
98
|
-
chainId:
|
|
98
|
+
chainId: o
|
|
99
99
|
}), { wallet: j } = r.provider;
|
|
100
100
|
if (!j)
|
|
101
101
|
throw new Error("missing wallet");
|
|
102
102
|
return _(r.provider, p, R, $);
|
|
103
103
|
}
|
|
104
|
-
const E = q(r.programId, i, g), I =
|
|
104
|
+
const E = q(r.programId, i, g), I = y === K ? null : g, k = y === K ? null : void 0;
|
|
105
105
|
return r.methods.multiPaymentDeposit(P, w).accounts({
|
|
106
106
|
mint: I,
|
|
107
107
|
signer: u,
|
|
108
108
|
signerAta: k,
|
|
109
109
|
originalDeployer: i,
|
|
110
110
|
storageAccount: b,
|
|
111
|
-
storageVault:
|
|
111
|
+
storageVault: A,
|
|
112
112
|
merkleAccount: T,
|
|
113
113
|
tokenLimitStorage: E,
|
|
114
114
|
storageVaultAta: k,
|
|
@@ -117,6 +117,6 @@ const U = async (t, o, s, e) => {
|
|
|
117
117
|
};
|
|
118
118
|
export {
|
|
119
119
|
Tt as hinkalSolanaDeposit,
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
Ct as hinkalSolanaDepositForOther,
|
|
121
|
+
Vt as hinkalSolanaMultiPaymentDeposit
|
|
122
122
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("../../functions/web3/etherFunctions.cjs");require("../../functions/web3/events/getInputUtxoAndBalance.cjs");require("../../constants/token-data/index.cjs");const B=require("../../constants/protocol.constants.cjs"),L=require("../../constants/chains.constants.cjs"),F=require("../utxo/Utxo.cjs"),W=require("../../error-handling/error-codes.constants.cjs");require("idb-keyval");const $=require("../../API/API.cjs");require("../../constants/vite.constants.cjs");const Z=require("../../functions/utils/token-check.utils.cjs");require("async-mutex");const M=require("../../functions/utils/solanaMint.utils.cjs");require("../../types/circom-data.types.cjs");const G=require("../../types/external-action.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");require("../../functions/web3/events/getApprovedBalance.cjs");const X=require("ethers"),z=require("@solana/web3.js");require("../http/HttpClient.cjs");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("axios");const Y=require("../../functions/utils/addresses.cjs"),x=require("../../functions/pre-transaction/solana.cjs");require("@solana/spl-token");require("ethers-v6h");require("tweetnacl");require("bs58");const J=require("@coral-xyz/anchor");require("buffer");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.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("../../functions/utils/userAgent.cjs");const Q=require("../../functions/utils/time.utils.cjs");require("circomlibjs-hinkal-fork");require("../crypto-keys/keys.cjs");require("libsodium-wrappers");require("multiformats");require("process");require("../../providers/EthersProviderAdapter.cjs");const ee=require("../../functions/utils/fees.utils.cjs");require("../../functions/web3/getTokenHolder.cjs");const te=require("../../functions/web3/signAndSendSerializedTransaction.cjs"),H=require("../../functions/snarkjs/common.snarkjs.cjs"),re=require("./hinkalCheckSolanaTokenRegistry.cjs"),oe=require("../../functions/utils/getUtxosFromReceiptSolana.cjs"),ne=require("../../functions/snarkjs/constructSolanaZkProof.cjs"),se=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),ie=require("../../functions/pre-transaction/getFeeStructure.cjs"),ae=async(e,t,p,l,d,A)=>{const i=p.erc20TokenAddress,n=l.map(r=>r+ee.calculateTotalFee(r,A)),{hinkalIdl:m,hinkalAddress:g,originalDeployer:h}=L.networkRegistry[t].contractData;if(!m)throw new Error("No IDL configured for Solana program on this network");if(!h)throw new Error("missing original deployer");const y=e.userKeys.getShieldedPrivateKey(),C=F.Utxo.findCorrectRandomization(I.randomBigInt(31),y),K=H.calcStealthAddressStructure(C,y),o=e.getSolanaProgram(m),V=e.getSolanaPublicKey(),s=new z.PublicKey(h),w=new z.PublicKey(g),{mintPublicKey:S}=M.formatMintAddress(i),f=S.toString(),U=x.getStorageAccountPublicKey(w,s),D=x.getStorageVaultPublicKey(w,s),R=x.getMerkleAccountPublicKey(w,s),P=x.buildAnchorStealthAddressStructure(K),k=n.reduce((r,a)=>r+a,0n),_=await re.hinkalCheckSolanaTokenRegistry(o,new z.PublicKey(s),[i],[k]),b=n.map(r=>`${r}`);let q="";if(_){const{serializedTransaction:r,blockhash:a,lastValidBlockHeight:c}=await $.API.generateMultiPaymentDepositLimitless({amounts:b,payer:e.getSolanaPublicKey().toBase58(),ethereumAddress:await e.getEthereumAddressByChain(t),mint:i,stealthAddressStructure:P,chainId:t}),{wallet:u}=o.provider;if(!u)throw new Error("missing wallet");q=await te.signAndSendSerializedTransaction(o.provider,r,a,c)}else{const r=x.getTokenLimitStorageAccountPublicKey(o.programId,s,S),a=f===B.solanaNativeAddress?null:S,c=f===B.solanaNativeAddress?null:void 0;q=await o.methods.multiPaymentDeposit(b.map(O=>new J.BN(O)),P).accounts({mint:a,signer:V,signerAta:c,originalDeployer:s,storageAccount:U,storageVault:D,merkleAccount:R,tokenLimitStorage:r,storageVaultAta:c,accessTokenOwner:null}).rpc();const u=await o.provider.connection.getLatestBlockhash();await o.provider.connection.confirmTransaction({blockhash:u.blockhash,lastValidBlockHeight:u.lastValidBlockHeight,signature:q},"confirmed")}const T=await o.provider.connection.getTransaction(q,{commitment:"confirmed",maxSupportedTransactionVersion:0});if(!T)throw new Error("Transaction missing");const N=oe.getUtxosFromReceiptSolana(T,o,e.userKeys),E=[],v=[...N];return d.forEach((r,a)=>{const c=n[a],u=v.find(j=>j.amount===c);if(!u)throw new Error(`Could not find newly created UTXO with amount ${c} for recipient ${r}.`);E.push({recipientAddress:r,utxo:u});const O=v.indexOf(u);v.splice(O,1)}),E},ce=async(e,t,p,l,d,A,i)=>{const n=p.erc20TokenAddress;if(l.length===0)throw new Error("userDepositedUtxos must not be empty");const{hinkalIdl:m,originalDeployer:g}=L.networkRegistry[t].contractData;if(!g||!m)throw new Error("missing data");const h=e.getSolanaProgram(m),y=await e.getRandomRelay(t,!0);if(!y)throw new Error(W.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const C=Q.getCurrentTimeInSeconds().toString(),K=e.generateProofRemotely?5:1,o=[];for(let s=0;s<l.length;s+=K){const w=l.slice(s,s+K),S=await Promise.all(w.map(async({recipientAddress:f,utxo:U})=>{const{compressedAddress:D}=M.formatMintAddress(B.solanaNativeAddress),R=new F.Utxo({amount:0n,mintAddress:n,erc20TokenAddress:D,shieldedPrivateKey:e.userKeys.getShieldedPrivateKey(),timeStamp:C,tokenId:0}),P=[U,R],k=[R],_=F.Utxo.findCorrectRandomization(I.randomBigInt(31),e.userKeys.getShieldedPrivateKey()),b={tokenNumber:1,nullifierAmount:P.length,outputAmount:k.length},q=H.calcEncryptedOutputs([k])[0][0],T=Array.from(X.ethers.utils.arrayify(q)),{proofAArr:N,proofBArr:E,proofCArr:v,publicInputsArr:r}=await ne.constructSolanaZkProof(e.generateProofRemotely,g,e.merkleTreeHinkalByChain[t],e.merkleTreeAccessTokenByChain[t],e.userKeys,h,[n],[P],[k],_,d.flatFee,d.variableRate,f,y,b,[T],t,void 0,void 0,void 0,void 0,void 0,!1),a=n===B.solanaNativeAddress,c={recipient:f,mint:a?void 0:n};return{relayAddress:y,functionName:"transact",chainId:t,args:{proofAArr:N,proofBArr:E,proofCArr:v,publicInputsArr:r,encryptedOutputs:[T],relayerFee:d.flatFee.toString(),dimensions:b},accounts:c}}));o.push(...S)}return await se.solanaTransactCallRelayerBatch(t,o,A,i)},ue=async(e,t,p,l,d,A)=>{const i=Z.validateAndGetChainId([t]),n=t.erc20TokenAddress,m=Y.hashEthereumAddress(await e.getEthereumAddressByChain(i)),g=A??await ie.getFeeStructure(i,n,[n],G.ExternalActionId.Transact,[],0n),h=await ae(e,i,t,p,l,g);return ce(e,i,t,h,g,m,d)};exports.hinkalSolanaDepositAndWithdraw=ue;
|
|
@@ -1,30 +1,36 @@
|
|
|
1
|
-
import { randomBigInt as
|
|
1
|
+
import { randomBigInt as I } from "../../functions/web3/etherFunctions.mjs";
|
|
2
|
+
import "../../functions/web3/events/getInputUtxoAndBalance.mjs";
|
|
3
|
+
import "../../constants/token-data/index.mjs";
|
|
4
|
+
import { solanaNativeAddress as R } from "../../constants/protocol.constants.mjs";
|
|
5
|
+
import { networkRegistry as H } from "../../constants/chains.constants.mjs";
|
|
2
6
|
import { Utxo as N } from "../utxo/Utxo.mjs";
|
|
3
7
|
import { transactionErrorCodes as W } from "../../error-handling/error-codes.constants.mjs";
|
|
4
|
-
import { ethers as _ } from "ethers";
|
|
5
8
|
import "idb-keyval";
|
|
6
|
-
import {
|
|
7
|
-
import "../crypto-keys/keys.mjs";
|
|
8
|
-
import "node-forge";
|
|
9
|
+
import { API as _ } from "../../API/API.mjs";
|
|
9
10
|
import "../../constants/vite.constants.mjs";
|
|
10
|
-
import "
|
|
11
|
-
import "../http/HttpClient.mjs";
|
|
12
|
-
import "axios";
|
|
13
|
-
import { formatMintAddress as M } from "../../functions/utils/solanaMint.utils.mjs";
|
|
14
|
-
import { PublicKey as L } from "@solana/web3.js";
|
|
15
|
-
import { hashEthereumAddress as q } from "../../functions/utils/addresses.mjs";
|
|
16
|
-
import "../../constants/server.constants.mjs";
|
|
17
|
-
import "../../API/getServerURL.mjs";
|
|
18
|
-
import "../../constants/token-data/index.mjs";
|
|
19
|
-
import { solanaNativeAddress as B } from "../../constants/protocol.constants.mjs";
|
|
20
|
-
import { API as G } from "../../API/API.mjs";
|
|
21
|
-
import { validateAndGetChainId as X } from "../../functions/utils/token-check.utils.mjs";
|
|
11
|
+
import { validateAndGetChainId as q } from "../../functions/utils/token-check.utils.mjs";
|
|
22
12
|
import "async-mutex";
|
|
13
|
+
import { formatMintAddress as M } from "../../functions/utils/solanaMint.utils.mjs";
|
|
23
14
|
import "../../types/circom-data.types.mjs";
|
|
24
|
-
import { ExternalActionId as
|
|
15
|
+
import { ExternalActionId as G } from "../../types/external-action.types.mjs";
|
|
25
16
|
import "../../types/transactions.types.mjs";
|
|
26
17
|
import "../../types/activities.types.mjs";
|
|
27
18
|
import "../../functions/web3/events/getApprovedBalance.mjs";
|
|
19
|
+
import { ethers as X } from "ethers";
|
|
20
|
+
import { PublicKey as L } from "@solana/web3.js";
|
|
21
|
+
import "../http/HttpClient.mjs";
|
|
22
|
+
import "../../functions/utils/convertIntegrationProviderToExternalActionId.mjs";
|
|
23
|
+
import "../../constants/server.constants.mjs";
|
|
24
|
+
import "../../API/getServerURL.mjs";
|
|
25
|
+
import "axios";
|
|
26
|
+
import { hashEthereumAddress as Y } from "../../functions/utils/addresses.mjs";
|
|
27
|
+
import { getStorageAccountPublicKey as Z, getStorageVaultPublicKey as j, getMerkleAccountPublicKey as J, buildAnchorStealthAddressStructure as Q, getTokenLimitStorageAccountPublicKey as tt } from "../../functions/pre-transaction/solana.mjs";
|
|
28
|
+
import "@solana/spl-token";
|
|
29
|
+
import "ethers-v6h";
|
|
30
|
+
import "tweetnacl";
|
|
31
|
+
import "bs58";
|
|
32
|
+
import { BN as ot } from "@coral-xyz/anchor";
|
|
33
|
+
import "buffer";
|
|
28
34
|
import "../../constants/contracts.constants.mjs";
|
|
29
35
|
import "../../constants/kyc.constants.mjs";
|
|
30
36
|
import "../../constants/coingecko.constants.mjs";
|
|
@@ -35,68 +41,64 @@ import "../../constants/presale.constants.mjs";
|
|
|
35
41
|
import "../../constants/activity.constants.mjs";
|
|
36
42
|
import "../../constants/tasks.constants.mjs";
|
|
37
43
|
import "../../constants/events.constants.mjs";
|
|
38
|
-
import "../../functions/utils/convertIntegrationProviderToExternalActionId.mjs";
|
|
39
|
-
import { getStorageAccountPublicKey as Z, getStorageVaultPublicKey as j, getMerkleAccountPublicKey as J, buildAnchorStealthAddressStructure as Q, getTokenLimitStorageAccountPublicKey as tt } from "../../functions/pre-transaction/solana.mjs";
|
|
40
|
-
import "@solana/spl-token";
|
|
41
|
-
import { BN as ot } from "@coral-xyz/anchor";
|
|
42
44
|
import "../../functions/utils/userAgent.mjs";
|
|
43
45
|
import { getCurrentTimeInSeconds as rt } from "../../functions/utils/time.utils.mjs";
|
|
44
46
|
import "circomlibjs-hinkal-fork";
|
|
47
|
+
import "../crypto-keys/keys.mjs";
|
|
48
|
+
import "libsodium-wrappers";
|
|
45
49
|
import "multiformats";
|
|
46
|
-
import "../../API/tenderly.api.mjs";
|
|
47
50
|
import "process";
|
|
48
|
-
import "buffer";
|
|
49
51
|
import "../../providers/EthersProviderAdapter.mjs";
|
|
50
52
|
import { calculateTotalFee as et } from "../../functions/utils/fees.utils.mjs";
|
|
51
53
|
import "../../functions/web3/getTokenHolder.mjs";
|
|
52
|
-
import { signAndSendSerializedTransaction as
|
|
53
|
-
import { calcStealthAddressStructure as
|
|
54
|
+
import { signAndSendSerializedTransaction as it } from "../../functions/web3/signAndSendSerializedTransaction.mjs";
|
|
55
|
+
import { calcStealthAddressStructure as nt, calcEncryptedOutputs as st } from "../../functions/snarkjs/common.snarkjs.mjs";
|
|
54
56
|
import { hinkalCheckSolanaTokenRegistry as at } from "./hinkalCheckSolanaTokenRegistry.mjs";
|
|
55
57
|
import { getUtxosFromReceiptSolana as ct } from "../../functions/utils/getUtxosFromReceiptSolana.mjs";
|
|
56
58
|
import { constructSolanaZkProof as mt } from "../../functions/snarkjs/constructSolanaZkProof.mjs";
|
|
57
59
|
import { solanaTransactCallRelayerBatch as lt } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
58
60
|
import { getFeeStructure as dt } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
59
|
-
const pt = async (t, o,
|
|
60
|
-
const s =
|
|
61
|
+
const pt = async (t, o, h, l, d, w) => {
|
|
62
|
+
const s = h.erc20TokenAddress, i = l.map((r) => r + et(r, w)), { hinkalIdl: p, hinkalAddress: u, originalDeployer: g } = H[o].contractData;
|
|
61
63
|
if (!p)
|
|
62
64
|
throw new Error("No IDL configured for Solana program on this network");
|
|
63
65
|
if (!g)
|
|
64
66
|
throw new Error("missing original deployer");
|
|
65
|
-
const f = t.userKeys.getShieldedPrivateKey(),
|
|
67
|
+
const f = t.userKeys.getShieldedPrivateKey(), C = N.findCorrectRandomization(I(31), f), E = nt(C, f), e = t.getSolanaProgram(p), F = t.getSolanaPublicKey(), n = new L(g), A = new L(u), { mintPublicKey: S } = M(s), P = S.toString(), D = Z(A, n), U = j(A, n), K = J(A, n), T = Q(E), v = i.reduce((r, c) => r + c, 0n), O = await at(
|
|
66
68
|
e,
|
|
67
|
-
new L(
|
|
69
|
+
new L(n),
|
|
68
70
|
[s],
|
|
69
71
|
[v]
|
|
70
|
-
), b =
|
|
71
|
-
let
|
|
72
|
+
), b = i.map((r) => `${r}`);
|
|
73
|
+
let y = "";
|
|
72
74
|
if (O) {
|
|
73
|
-
const { serializedTransaction: r, blockhash: c, lastValidBlockHeight: a } = await
|
|
75
|
+
const { serializedTransaction: r, blockhash: c, lastValidBlockHeight: a } = await _.generateMultiPaymentDepositLimitless({
|
|
74
76
|
amounts: b,
|
|
75
77
|
payer: t.getSolanaPublicKey().toBase58(),
|
|
76
|
-
ethereumAddress: await t.
|
|
78
|
+
ethereumAddress: await t.getEthereumAddressByChain(o),
|
|
77
79
|
mint: s,
|
|
78
80
|
stealthAddressStructure: T,
|
|
79
81
|
chainId: o
|
|
80
82
|
}), { wallet: m } = e.provider;
|
|
81
83
|
if (!m)
|
|
82
84
|
throw new Error("missing wallet");
|
|
83
|
-
|
|
85
|
+
y = await it(
|
|
84
86
|
e.provider,
|
|
85
87
|
r,
|
|
86
88
|
c,
|
|
87
89
|
a
|
|
88
90
|
);
|
|
89
91
|
} else {
|
|
90
|
-
const r = tt(e.programId,
|
|
91
|
-
|
|
92
|
+
const r = tt(e.programId, n, S), c = P === R ? null : S, a = P === R ? null : void 0;
|
|
93
|
+
y = await e.methods.multiPaymentDeposit(
|
|
92
94
|
b.map((z) => new ot(z)),
|
|
93
95
|
T
|
|
94
96
|
).accounts({
|
|
95
97
|
mint: c,
|
|
96
|
-
signer:
|
|
98
|
+
signer: F,
|
|
97
99
|
signerAta: a,
|
|
98
|
-
originalDeployer:
|
|
99
|
-
storageAccount:
|
|
100
|
+
originalDeployer: n,
|
|
101
|
+
storageAccount: D,
|
|
100
102
|
storageVault: U,
|
|
101
103
|
merkleAccount: K,
|
|
102
104
|
tokenLimitStorage: r,
|
|
@@ -108,31 +110,31 @@ const pt = async (t, o, y, l, d, w) => {
|
|
|
108
110
|
{
|
|
109
111
|
blockhash: m.blockhash,
|
|
110
112
|
lastValidBlockHeight: m.lastValidBlockHeight,
|
|
111
|
-
signature:
|
|
113
|
+
signature: y
|
|
112
114
|
},
|
|
113
115
|
"confirmed"
|
|
114
116
|
);
|
|
115
117
|
}
|
|
116
|
-
const x = await e.provider.connection.getTransaction(
|
|
118
|
+
const x = await e.provider.connection.getTransaction(y, {
|
|
117
119
|
commitment: "confirmed",
|
|
118
120
|
maxSupportedTransactionVersion: 0
|
|
119
121
|
});
|
|
120
122
|
if (!x)
|
|
121
123
|
throw new Error("Transaction missing");
|
|
122
|
-
const V = ct(x, e, t.userKeys),
|
|
124
|
+
const V = ct(x, e, t.userKeys), B = [], k = [...V];
|
|
123
125
|
return d.forEach((r, c) => {
|
|
124
|
-
const a =
|
|
126
|
+
const a = i[c], m = k.find(($) => $.amount === a);
|
|
125
127
|
if (!m)
|
|
126
128
|
throw new Error(`Could not find newly created UTXO with amount ${a} for recipient ${r}.`);
|
|
127
|
-
|
|
129
|
+
B.push({
|
|
128
130
|
recipientAddress: r,
|
|
129
131
|
utxo: m
|
|
130
132
|
});
|
|
131
133
|
const z = k.indexOf(m);
|
|
132
134
|
k.splice(z, 1);
|
|
133
|
-
}),
|
|
134
|
-
}, ut = async (t, o,
|
|
135
|
-
const
|
|
135
|
+
}), B;
|
|
136
|
+
}, ut = async (t, o, h, l, d, w, s) => {
|
|
137
|
+
const i = h.erc20TokenAddress;
|
|
136
138
|
if (l.length === 0)
|
|
137
139
|
throw new Error("userDepositedUtxos must not be empty");
|
|
138
140
|
const { hinkalIdl: p, originalDeployer: u } = H[o].contractData;
|
|
@@ -141,32 +143,32 @@ const pt = async (t, o, y, l, d, w) => {
|
|
|
141
143
|
const g = t.getSolanaProgram(p), f = await t.getRandomRelay(o, !0);
|
|
142
144
|
if (!f)
|
|
143
145
|
throw new Error(W.RELAYER_NOT_AVAILABLE);
|
|
144
|
-
const
|
|
145
|
-
for (let
|
|
146
|
-
const A = l.slice(
|
|
147
|
-
A.map(async ({ recipientAddress: P, utxo:
|
|
148
|
-
const { compressedAddress: U } = M(
|
|
146
|
+
const C = rt().toString(), E = t.generateProofRemotely ? 5 : 1, e = [];
|
|
147
|
+
for (let n = 0; n < l.length; n += E) {
|
|
148
|
+
const A = l.slice(n, n + E), S = await Promise.all(
|
|
149
|
+
A.map(async ({ recipientAddress: P, utxo: D }) => {
|
|
150
|
+
const { compressedAddress: U } = M(R), K = new N({
|
|
149
151
|
amount: 0n,
|
|
150
|
-
mintAddress:
|
|
152
|
+
mintAddress: i,
|
|
151
153
|
erc20TokenAddress: U,
|
|
152
154
|
shieldedPrivateKey: t.userKeys.getShieldedPrivateKey(),
|
|
153
|
-
timeStamp:
|
|
155
|
+
timeStamp: C,
|
|
154
156
|
tokenId: 0
|
|
155
|
-
}), T = [
|
|
156
|
-
|
|
157
|
+
}), T = [D, K], v = [K], O = N.findCorrectRandomization(
|
|
158
|
+
I(31),
|
|
157
159
|
t.userKeys.getShieldedPrivateKey()
|
|
158
160
|
), b = {
|
|
159
161
|
tokenNumber: 1,
|
|
160
162
|
nullifierAmount: T.length,
|
|
161
163
|
outputAmount: v.length
|
|
162
|
-
},
|
|
164
|
+
}, y = st([v])[0][0], x = Array.from(X.utils.arrayify(y)), { proofAArr: V, proofBArr: B, proofCArr: k, publicInputsArr: r } = await mt(
|
|
163
165
|
t.generateProofRemotely,
|
|
164
166
|
u,
|
|
165
167
|
t.merkleTreeHinkalByChain[o],
|
|
166
168
|
t.merkleTreeAccessTokenByChain[o],
|
|
167
169
|
t.userKeys,
|
|
168
170
|
g,
|
|
169
|
-
[
|
|
171
|
+
[i],
|
|
170
172
|
[T],
|
|
171
173
|
[v],
|
|
172
174
|
O,
|
|
@@ -185,7 +187,7 @@ const pt = async (t, o, y, l, d, w) => {
|
|
|
185
187
|
!1
|
|
186
188
|
), a = {
|
|
187
189
|
recipient: P,
|
|
188
|
-
mint:
|
|
190
|
+
mint: i === R ? void 0 : i
|
|
189
191
|
};
|
|
190
192
|
return {
|
|
191
193
|
relayAddress: f,
|
|
@@ -193,7 +195,7 @@ const pt = async (t, o, y, l, d, w) => {
|
|
|
193
195
|
chainId: o,
|
|
194
196
|
args: {
|
|
195
197
|
proofAArr: V,
|
|
196
|
-
proofBArr:
|
|
198
|
+
proofBArr: B,
|
|
197
199
|
proofCArr: k,
|
|
198
200
|
publicInputsArr: r,
|
|
199
201
|
encryptedOutputs: [x],
|
|
@@ -212,12 +214,12 @@ const pt = async (t, o, y, l, d, w) => {
|
|
|
212
214
|
w,
|
|
213
215
|
s
|
|
214
216
|
);
|
|
215
|
-
},
|
|
216
|
-
const s =
|
|
217
|
+
}, Po = async (t, o, h, l, d, w) => {
|
|
218
|
+
const s = q([o]), i = o.erc20TokenAddress, p = Y(await t.getEthereumAddressByChain(s)), u = w ?? await dt(s, i, [i], G.Transact, [], 0n), g = await pt(
|
|
217
219
|
t,
|
|
218
220
|
s,
|
|
219
221
|
o,
|
|
220
|
-
|
|
222
|
+
h,
|
|
221
223
|
l,
|
|
222
224
|
u
|
|
223
225
|
);
|
|
@@ -232,5 +234,5 @@ const pt = async (t, o, y, l, d, w) => {
|
|
|
232
234
|
);
|
|
233
235
|
};
|
|
234
236
|
export {
|
|
235
|
-
|
|
237
|
+
Po as hinkalSolanaDepositAndWithdraw
|
|
236
238
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@solana/web3.js"),P=require("../../constants/chains.constants.cjs"),y=require("../../functions/pre-transaction/sendV0Transaction.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@solana/web3.js"),P=require("../../constants/chains.constants.cjs"),y=require("../../functions/pre-transaction/sendV0Transaction.cjs"),b=require("../../functions/pre-transaction/solanaTransfer.utils.cjs"),f=require("../../functions/utils/create-provider.cjs"),h=require("../../functions/utils/token-check.utils.cjs"),w=require("../AccountActions/AccountActions.cjs"),S=async(r,a,o,t)=>{const n=h.validateAndGetChainId([r]),e=w.AccountActions.getAddressFromSubAccount(n,o);if(!e)throw Error("Public account address is not available");const{fetchRpcUrl:s}=P.networkRegistry[n];if(!s)throw new Error("RPC URL not found for the specified chain ID");const i=f.createCustomSolanaConnection(s),c=new u.PublicKey(e),{instructions:d,programId:l}=await b.buildSolanaTransferInstructions(i,c,new u.PublicKey(t),r,a);return{connection:i,chainId:n,senderAddress:e,senderPublickey:c,programId:l,instructions:d}},g=async(r,a,o,t,n=!1)=>{if(n)throw new Error("onlyGasEstimate is not supported for Solana proxy send");const{connection:e,chainId:s,senderAddress:i,senderPublickey:c,programId:d,instructions:l}=await S(r,a,o,t);return y.sendProxyV0Transaction({connection:e,chainId:s,subAccount:o,payerPublicKey:c,instructions:l,convertParams:{fromAddress:i,toAddress:t,programAddress:d.toString()}})},A=async(r,a,o,t)=>{const{connection:n,senderPublickey:e,instructions:s}=await S(r,a,o,t);return y.serializeProxyV0Transaction(n,e,s)};exports.getSolanaProxySendSerializedTransaction=A;exports.hinkalSolanaProxySend=g;
|