@hinkal/common 0.2.22 → 0.2.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API/proxyAccountsCalls.cjs +1 -1
- package/API/proxyAccountsCalls.mjs +13 -13
- package/README.md +63 -267
- package/constants/activity.constants.cjs +1 -1
- package/constants/activity.constants.mjs +0 -1
- package/constants/addresses.constants.cjs +1 -1
- package/constants/addresses.constants.mjs +9 -10
- package/constants/contracts.constants.cjs +1 -1
- package/constants/contracts.constants.d.ts +3 -3
- package/constants/contracts.constants.mjs +29 -29
- package/constants/server.constants.cjs +1 -1
- package/constants/server.constants.mjs +28 -29
- package/constants/tasks.constants.cjs +1 -1
- package/constants/tasks.constants.mjs +4 -5
- package/crypto/poseidon.cjs +1 -1
- package/crypto/poseidon.mjs +10 -10
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.cjs +1 -1
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.mjs +24 -24
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.mjs +4 -5
- package/data-structures/Hinkal/IHinkal.d.ts +2 -2
- package/data-structures/Hinkal/hinkalApprove.cjs +1 -1
- package/data-structures/Hinkal/hinkalApprove.mjs +40 -40
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -1
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +7 -8
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +4 -5
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +2 -3
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +18 -19
- package/data-structures/Hinkal/hinkalDepostAndBridge.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepostAndBridge.mjs +3 -4
- package/data-structures/Hinkal/hinkalInsideTransact.cjs +1 -1
- package/data-structures/Hinkal/hinkalInsideTransact.mjs +14 -13
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +2 -3
- package/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalProoflessDeposit.mjs +27 -26
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +38 -39
- package/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaSwap.mjs +16 -17
- package/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaTransfer.mjs +24 -25
- package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +15 -16
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +2 -3
- package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalTransfer.mjs +2 -3
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +9 -10
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +8 -9
- package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.mjs +10 -10
- package/data-structures/IndexedDB/activity-db.cjs +1 -1
- package/data-structures/IndexedDB/activity-db.mjs +39 -41
- package/data-structures/IndexedDB/balances-db.cjs +1 -1
- package/data-structures/IndexedDB/balances-db.mjs +8 -9
- package/data-structures/IndexedDB/contact-db.cjs +1 -1
- package/data-structures/IndexedDB/contact-db.mjs +21 -23
- package/data-structures/IndexedDB/signatures-db.cjs +1 -1
- package/data-structures/IndexedDB/signatures-db.mjs +2 -3
- package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +34 -36
- package/data-structures/crypto-keys/decodeUTXO.cjs +1 -1
- package/data-structures/crypto-keys/decodeUTXO.mjs +45 -45
- package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
- package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +28 -27
- package/data-structures/crypto-keys/keys.cjs +1 -1
- package/data-structures/crypto-keys/keys.d.ts +2 -3
- package/data-structures/crypto-keys/keys.mjs +56 -57
- package/data-structures/event-service/evm/AbstractEventService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractEventService.mjs +14 -14
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.d.ts +2 -3
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.mjs +5 -4
- package/data-structures/event-service/evm/AbstractSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractSnapshotService.mjs +6 -3
- package/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.d.ts +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.mjs +22 -18
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.mjs +2 -2
- package/data-structures/presale/PresaleContractWrapper.cjs +1 -1
- package/data-structures/presale/PresaleContractWrapper.d.ts +3 -3
- package/data-structures/presale/PresaleContractWrapper.mjs +10 -10
- package/data-structures/provider-adapter/IProviderAdapter.d.ts +7 -7
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.mjs +16 -14
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +7 -5
- package/error-handling/get-error.message.cjs +1 -1
- package/error-handling/get-error.message.mjs +2 -3
- package/functions/kyc/zkMeHelper.cjs +1 -1
- package/functions/kyc/zkMeHelper.mjs +3 -3
- package/functions/pre-transaction/getFlatFees.cjs +1 -1
- package/functions/pre-transaction/getFlatFees.mjs +2 -3
- package/functions/pre-transaction/getSolanaCalldataHash.cjs +1 -1
- package/functions/pre-transaction/getSolanaCalldataHash.mjs +21 -21
- package/functions/pre-transaction/getVolatileTransferAmount.cjs +1 -1
- package/functions/pre-transaction/getVolatileTransferAmount.mjs +2 -3
- package/functions/pre-transaction/interaction-to-action.cjs +1 -1
- package/functions/pre-transaction/interaction-to-action.mjs +2 -3
- package/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.helpers.d.ts +6 -7
- package/functions/private-wallet/emporium.helpers.mjs +104 -105
- package/functions/private-wallet/emporium.swap.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.swap.helpers.mjs +44 -43
- package/functions/private-wallet/opProducer.cjs +1 -1
- package/functions/private-wallet/opProducer.mjs +1 -1
- package/functions/snarkjs/common.snarkjs.cjs +1 -1
- package/functions/snarkjs/common.snarkjs.mjs +21 -18
- package/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/functions/snarkjs/constructSolanaZkProof.mjs +11 -12
- package/functions/utils/addresses.cjs +1 -1
- package/functions/utils/addresses.mjs +6 -6
- package/functions/utils/cacheFunctions.cjs +1 -1
- package/functions/utils/cacheFunctions.d.ts +1 -1
- package/functions/utils/cacheFunctions.mjs +55 -54
- package/functions/utils/convertEmporiumOpToCallInfo.cjs +1 -1
- package/functions/utils/convertEmporiumOpToCallInfo.mjs +5 -5
- package/functions/utils/create-provider.cjs +1 -1
- package/functions/utils/create-provider.d.ts +2 -2
- package/functions/utils/create-provider.mjs +5 -5
- package/functions/utils/encryptInputForEnclave.cjs +1 -1
- package/functions/utils/encryptInputForEnclave.mjs +9 -9
- package/functions/utils/ethers-formatter.utils.d.ts +1 -1
- package/functions/utils/external-action.utils.cjs +1 -1
- package/functions/utils/external-action.utils.mjs +2 -2
- package/functions/utils/getContractAddress.cjs +1 -0
- package/functions/utils/getContractAddress.d.ts +2 -0
- package/functions/utils/getContractAddress.mjs +9 -0
- package/functions/utils/getDataFromTransaction.cjs +1 -1
- package/functions/utils/getDataFromTransaction.d.ts +0 -11
- package/functions/utils/getDataFromTransaction.mjs +26 -50
- package/functions/utils/getRecipientInfoFromUserKeys.cjs +1 -1
- package/functions/utils/getRecipientInfoFromUserKeys.mjs +1 -1
- package/functions/utils/getSignerFromContract.cjs +1 -0
- package/functions/utils/getSignerFromContract.d.ts +3 -0
- package/functions/utils/getSignerFromContract.mjs +16 -0
- package/functions/utils/getUtxosFromReceipt.utils.cjs +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.d.ts +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.mjs +15 -16
- package/functions/utils/inLogicMetadata.cjs +1 -1
- package/functions/utils/inLogicMetadata.mjs +2 -2
- package/functions/utils/nftTokenFunctions.cjs +1 -1
- package/functions/utils/nftTokenFunctions.mjs +2 -3
- package/functions/utils/publicBalance.utils.cjs +1 -1
- package/functions/utils/publicBalance.utils.d.ts +1 -1
- package/functions/utils/publicBalance.utils.mjs +42 -42
- package/functions/utils/rpc-int-encode.cjs +1 -1
- package/functions/utils/rpc-int-encode.d.ts +1 -2
- package/functions/utils/rpc-int-encode.mjs +3 -6
- package/functions/utils/solanaMint.utils.cjs +1 -1
- package/functions/utils/solanaMint.utils.mjs +6 -6
- package/functions/web3/EIP-712.cjs +1 -1
- package/functions/web3/EIP-712.d.ts +4 -4
- package/functions/web3/EIP-712.mjs +1 -1
- package/functions/web3/etherFunctions.cjs +1 -1
- package/functions/web3/etherFunctions.mjs +32 -29
- package/functions/web3/events/balanceChangedCustomHandler.cjs +1 -1
- package/functions/web3/events/balanceChangedCustomHandler.mjs +4 -5
- package/functions/web3/events/balanceChangedHandler.cjs +1 -1
- package/functions/web3/events/balanceChangedHandler.mjs +2 -3
- package/functions/web3/events/getApprovedBalance.cjs +1 -1
- package/functions/web3/events/getApprovedBalance.mjs +1 -1
- package/functions/web3/events/getInputUtxosEnclave.cjs +1 -1
- package/functions/web3/events/getInputUtxosEnclave.mjs +20 -20
- package/functions/web3/events/getTransactionLogEvents.cjs +1 -1
- package/functions/web3/events/getTransactionLogEvents.d.ts +3 -3
- package/functions/web3/events/getTransactionLogEvents.mjs +6 -5
- package/functions/web3/events/index.d.ts +0 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.d.ts +1 -2
- package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +4 -5
- package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
- package/functions/web3/functionCalls/accessTokenCalls.mjs +10 -11
- package/functions/web3/functionCalls/approveToken.cjs +1 -1
- package/functions/web3/functionCalls/approveToken.mjs +61 -58
- package/functions/web3/functionCalls/constructBatchCall.cjs +1 -1
- package/functions/web3/functionCalls/constructBatchCall.d.ts +2 -2
- package/functions/web3/functionCalls/constructBatchCall.mjs +10 -9
- package/functions/web3/functionCalls/estimateGasRelayer.cjs +1 -1
- package/functions/web3/functionCalls/estimateGasRelayer.mjs +1 -1
- package/functions/web3/functionCalls/inHinkalApprovalCalls.cjs +1 -1
- package/functions/web3/functionCalls/inHinkalApprovalCalls.mjs +18 -21
- package/functions/web3/functionCalls/recoverTransactionFromError.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +38 -34
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.mjs +8 -10
- package/functions/web3/getContractMetadata.cjs +1 -1
- package/functions/web3/getContractMetadata.d.ts +1 -1
- package/functions/web3/getContractMetadata.mjs +25 -25
- package/functions/web3/getPublicAddressBalance.cjs +1 -1
- package/functions/web3/getPublicAddressBalance.mjs +7 -6
- package/functions/web3/getTokenHolder.cjs +1 -1
- package/functions/web3/getTokenHolder.mjs +16 -15
- package/functions/web3/odosAPI.cjs +1 -1
- package/functions/web3/odosAPI.mjs +6 -7
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.mjs +2 -3
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.d.ts +6 -5
- package/functions/web3/runContractFunction.mjs +41 -45
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.d.ts +2 -2
- package/functions/web3/uniswapAPI.mjs +23 -24
- package/index.cjs +1 -1
- package/index.mjs +336 -340
- package/package.json +3 -4
- package/providers/CustomEthersProvider.d.ts +1 -1
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.d.ts +7 -7
- package/providers/EthersProviderAdapter.mjs +46 -44
- package/providers/SolanaProviderAdapter.d.ts +1 -1
- package/providers/WagmiProviderAdapter.cjs +1 -1
- package/providers/WagmiProviderAdapter.d.ts +5 -5
- package/providers/WagmiProviderAdapter.mjs +37 -33
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.d.ts +2 -2
- package/providers/prepareEthersHinkal.mjs +3 -5
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +3 -5
- package/types/activities.types.d.ts +2 -3
- package/types/big-intable.types.d.ts +3 -2
- package/types/ethereum-network.types.d.ts +10 -10
- package/types/transactions.types.cjs +1 -1
- package/types/transactions.types.d.ts +2 -3
- package/types/transactions.types.mjs +6 -7
- package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLogic.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLogic.mjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
- package/functions/web3/events/web3RetrieveEvents.cjs +0 -1
- package/functions/web3/events/web3RetrieveEvents.d.ts +0 -14
- package/functions/web3/events/web3RetrieveEvents.mjs +0 -9
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import "../../types/circom-data.types.mjs";
|
|
2
|
-
import { ExternalActionId as
|
|
2
|
+
import { ExternalActionId as ot } from "../../types/external-action.types.mjs";
|
|
3
3
|
import { solanaNativeAddress as A } from "../../constants/protocol.constants.mjs";
|
|
4
|
-
import "../../types/transactions.types.mjs";
|
|
5
4
|
import "../../types/activities.types.mjs";
|
|
6
|
-
import { StorageKeys as
|
|
5
|
+
import { StorageKeys as rt } from "../../types/cache.types.mjs";
|
|
7
6
|
import { addPaddingToUtxos as nt } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
8
7
|
import { outputUtxoProcessing as st } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
9
8
|
import { getCurrentTimeInSeconds as at } from "../../functions/utils/time.utils.mjs";
|
|
@@ -20,26 +19,26 @@ import { solanaTransactCallRelayer as wt } from "../../functions/web3/functionCa
|
|
|
20
19
|
import { transactionErrorCodes as Tt } from "../../error-handling/error-codes.constants.mjs";
|
|
21
20
|
import { shouldPatchAccessTokenMerkleTree as It } from "../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs";
|
|
22
21
|
import { ethers as Pt } from "ethers";
|
|
23
|
-
const
|
|
22
|
+
const Mt = async (e, r, o, f, E, x, K, R, h = !1) => {
|
|
24
23
|
if (h)
|
|
25
24
|
throw new Error("onlyGasEstimate is not supported for Solana swap");
|
|
26
25
|
const i = e.getCurrentChainId(), y = new a(A), { hinkalAddress: v, originalDeployer: c, hinkalIdl: S } = mt[i].contractData;
|
|
27
26
|
if (!c || !S)
|
|
28
27
|
throw new Error("No IDL configured for Solana program on this network");
|
|
29
|
-
const m = new a(c), u = new a(v), n =
|
|
28
|
+
const m = new a(c), u = new a(v), n = r.map((t) => t.erc20TokenAddress), { userKeys: w, merkleTreeAccessToken: F, merkleTreeHinkal: N } = e, D = e.getSolanaProgram(S), s = R ?? await it(i, K, n, ot.Transact), { patchAccessTokenMerkleTree: O, kycRequired: U, hasAccessToken: B } = await It(
|
|
30
29
|
e,
|
|
31
30
|
n,
|
|
32
|
-
|
|
31
|
+
o
|
|
33
32
|
);
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
const l = [...await nt(e, n,
|
|
33
|
+
o[1] -= s.flatFee;
|
|
34
|
+
const L = s.variableRate.toString(), C = Number(e.cacheDevice.get(rt.SLIPPAGE_PERCENTAGE) ?? 0), p = r[1], V = At(p, o[1]), G = Number(V) * C / 100;
|
|
35
|
+
o[1] -= ft(p, G.toFixed(p.decimals));
|
|
36
|
+
const l = [...await nt(e, n, o, 6)], W = at().toString(), _ = e.userKeys.getShieldedPrivateKey(), d = [];
|
|
38
37
|
for (let t = 0; t < n.length; t += 1) {
|
|
39
38
|
const { outputUtxos: et } = st(
|
|
40
39
|
e.userKeys,
|
|
41
40
|
l[t],
|
|
42
|
-
|
|
41
|
+
o[t],
|
|
43
42
|
W,
|
|
44
43
|
void 0,
|
|
45
44
|
!1
|
|
@@ -50,10 +49,10 @@ const qt = async (e, o, r, f, E, x, K, R, h = !1) => {
|
|
|
50
49
|
tokenNumber: 2,
|
|
51
50
|
nullifierAmount: l[0].length,
|
|
52
51
|
outputAmount: 1
|
|
53
|
-
}, H = [!1, !0].slice(0,
|
|
52
|
+
}, H = [!1, !0].slice(0, o.length), g = await e.getRandomRelay(!0);
|
|
54
53
|
if (!g)
|
|
55
54
|
throw Error(Tt.RELAYER_NOT_AVAILABLE);
|
|
56
|
-
const I = ct(d).map((t) => [...Pt.
|
|
55
|
+
const I = ct(d).map((t) => [...Pt.getBytes(t[0])]), P = ut(u, m, f), { remainingAccounts: b, hinkalInstructions: k } = St(E, P), { proofAArr: M, proofBArr: q, proofCArr: X, publicInputsArr: Y } = await dt(
|
|
57
56
|
e.generateProofRemotely,
|
|
58
57
|
c,
|
|
59
58
|
N,
|
|
@@ -76,7 +75,7 @@ const qt = async (e, o, r, f, E, x, K, R, h = !1) => {
|
|
|
76
75
|
f,
|
|
77
76
|
k,
|
|
78
77
|
b
|
|
79
|
-
), Z = pt(u, m), j = lt(u, m), J =
|
|
78
|
+
), Z = pt(u, m), j = lt(u, m), J = r[0].erc20TokenAddress !== A ? new a(r[0].erc20TokenAddress) : null, Q = r[1].erc20TokenAddress !== A ? new a(r[1].erc20TokenAddress) : null, $ = {
|
|
80
79
|
recipient: y.toString(),
|
|
81
80
|
storageAccount: Z.toString(),
|
|
82
81
|
storageVault: j.toString(),
|
|
@@ -96,7 +95,7 @@ const qt = async (e, o, r, f, E, x, K, R, h = !1) => {
|
|
|
96
95
|
proofCArr: X,
|
|
97
96
|
publicInputsArr: Y,
|
|
98
97
|
relayerFee: s.flatFee.toString(),
|
|
99
|
-
variableRate:
|
|
98
|
+
variableRate: L,
|
|
100
99
|
dimensions: T,
|
|
101
100
|
hinkalInstructions: k.map((t) => ({
|
|
102
101
|
accountIndexes: [...t.accountIndexes],
|
|
@@ -109,12 +108,12 @@ const qt = async (e, o, r, f, E, x, K, R, h = !1) => {
|
|
|
109
108
|
functionName: "swap",
|
|
110
109
|
args: tt,
|
|
111
110
|
accounts: $,
|
|
112
|
-
solanaAccessTokenData: !
|
|
111
|
+
solanaAccessTokenData: !B && U ? {
|
|
113
112
|
ethereumAddress: await e.getEthereumAddress(),
|
|
114
113
|
accessKey: w.getAccessKey()
|
|
115
114
|
} : void 0
|
|
116
115
|
});
|
|
117
116
|
};
|
|
118
117
|
export {
|
|
119
|
-
|
|
118
|
+
Mt as hinkalSolanaSwap
|
|
120
119
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../types/circom-data.types.cjs");const z=require("../../types/external-action.types.cjs"),c=require("../../constants/protocol.constants.cjs");require("../../types/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../types/circom-data.types.cjs");const z=require("../../types/external-action.types.cjs"),c=require("../../constants/protocol.constants.cjs");require("../../types/activities.types.cjs");const D=require("../../functions/web3/events/getShieldedBalance.cjs"),M=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),j=require("../../functions/utils/time.utils.cjs"),u=require("../../error-handling/error-codes.constants.cjs"),H=require("../../functions/pre-transaction/getFeeStructure.cjs"),Z=require("../../functions/snarkjs/common.snarkjs.cjs"),Y=require("../../functions/snarkjs/constructSolanaZkProof.cjs"),I=require("../utxo/Utxo.cjs"),G=require("../../functions/web3/etherFunctions.cjs"),J=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),Q=require("../../functions/utils/addresses.cjs"),W=require("../../constants/chains.constants.cjs"),X=require("ethers"),$=async(e,R,r,d,S,q,l=!1)=>{if(l)throw new Error("onlyGasEstimate is not supported for Solana transfer");if(!Q.isValidPrivateAddress(d))throw Error(u.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);const n=e.getCurrentChainId(),{originalDeployer:p,hinkalIdl:A}=W.networkRegistry[n].contractData;if(!p||!A)throw new Error("missing data");const{userKeys:_,merkleTreeAccessToken:w,merkleTreeHinkal:x}=e,t=R.map(i=>i.erc20TokenAddress);if(t.length>1)throw new Error("Solana Transfer: Only one mint address is supported");const N=q??await H.getFeeStructure(n,S,t,z.ExternalActionId.Transact),a=-r[0]*(10000n-c.HINKAL_PRIVATE_SEND_VARIABLE_RATE)/10000n;if(r[0]-=N.flatFee,a<=0n)throw Error(u.transactionErrorCodes.RECIPIENT_AMOUNT_INVALID);const m=-r[0]-a,o=(await D.addPaddingToUtxos(e,t,r,6))[0],y=j.getCurrentTimeInSeconds().toString(),{outputUtxos:P}=M.outputUtxoProcessing(e.userKeys,o,r[0],y,void 0,!1),f=P[0],[C,O,U]=d.split(","),g=new I.Utxo({amount:a,erc20TokenAddress:o[0].erc20TokenAddress,mintAddress:o[0].mintAddress,timeStamp:y,randomization:BigInt(C),stealthAddress:O,encryptionKey:U}),s=await e.getRandomRelay(!l);if(!s)throw Error(u.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const h=I.Utxo.findCorrectRandomization(G.randomBigInt(31),e.userKeys.getShieldedPrivateKey()),E={tokenNumber:t.length,nullifierAmount:o.length,outputAmount:2},k=e.getSolanaProgram(A),T=Z.calcEncryptedOutputs([[f,g]])[0].map(i=>Array.from(X.ethers.getBytes(i))),{proofAArr:v,proofBArr:B,proofCArr:F,publicInputsArr:K}=await Y.constructSolanaZkProof(e.generateProofRemotely,p,x,w,_,k,[t[0]],[o],[[f,g]],h,m,0n,c.solanaNativeAddress,s,E,T,n),L=t[0]===c.solanaNativeAddress,V={recipient:s,mint:L?void 0:t[0]},b={proofAArr:v,proofBArr:B,proofCArr:F,publicInputsArr:K,encryptedOutputs:T,relayerFee:m.toString(),dimensions:E};return J.solanaTransactCallRelayer(n,{relayAddress:s,functionName:"transfer",args:b,accounts:V})};exports.hinkalSolanaTransfer=$;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "../../types/circom-data.types.mjs";
|
|
2
2
|
import { ExternalActionId as b } from "../../types/external-action.types.mjs";
|
|
3
|
-
import { solanaNativeAddress as
|
|
4
|
-
import "../../types/transactions.types.mjs";
|
|
3
|
+
import { solanaNativeAddress as T, HINKAL_PRIVATE_SEND_VARIABLE_RATE as H } from "../../constants/protocol.constants.mjs";
|
|
5
4
|
import "../../types/activities.types.mjs";
|
|
6
5
|
import { addPaddingToUtxos as M } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
7
6
|
import { outputUtxoProcessing as Y } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
@@ -16,74 +15,74 @@ import { solanaTransactCallRelayer as Q } from "../../functions/web3/functionCal
|
|
|
16
15
|
import { isValidPrivateAddress as W } from "../../functions/utils/addresses.mjs";
|
|
17
16
|
import { networkRegistry as X } from "../../constants/chains.constants.mjs";
|
|
18
17
|
import { ethers as $ } from "ethers";
|
|
19
|
-
const
|
|
18
|
+
const Tt = async (t, R, o, c, w, S, d = !1) => {
|
|
20
19
|
if (d)
|
|
21
20
|
throw new Error("onlyGasEstimate is not supported for Solana transfer");
|
|
22
21
|
if (!W(c))
|
|
23
22
|
throw Error(m.RECIPIENT_FORMAT_INCORRECT);
|
|
24
|
-
const n =
|
|
23
|
+
const n = t.getCurrentChainId(), { originalDeployer: p, hinkalIdl: u } = X[n].contractData;
|
|
25
24
|
if (!p || !u)
|
|
26
25
|
throw new Error("missing data");
|
|
27
|
-
const { userKeys: N, merkleTreeAccessToken: x, merkleTreeHinkal: O } =
|
|
28
|
-
if (
|
|
26
|
+
const { userKeys: N, merkleTreeAccessToken: x, merkleTreeHinkal: O } = t, r = R.map((a) => a.erc20TokenAddress);
|
|
27
|
+
if (r.length > 1)
|
|
29
28
|
throw new Error("Solana Transfer: Only one mint address is supported");
|
|
30
|
-
const P = S ?? await j(n, w,
|
|
29
|
+
const P = S ?? await j(n, w, r, b.Transact), i = -o[0] * (10000n - H) / 10000n;
|
|
31
30
|
if (o[0] -= P.flatFee, i <= 0n)
|
|
32
31
|
throw Error(m.RECIPIENT_AMOUNT_INVALID);
|
|
33
|
-
const f = -o[0] - i, e = (await M(
|
|
34
|
-
|
|
32
|
+
const f = -o[0] - i, e = (await M(t, r, o, 6))[0], l = Z().toString(), { outputUtxos: _ } = Y(
|
|
33
|
+
t.userKeys,
|
|
35
34
|
e,
|
|
36
35
|
o[0],
|
|
37
36
|
l,
|
|
38
37
|
void 0,
|
|
39
38
|
!1
|
|
40
|
-
), A = _[0], [U, C,
|
|
39
|
+
), A = _[0], [U, C, B] = c.split(","), y = new I({
|
|
41
40
|
amount: i,
|
|
42
41
|
erc20TokenAddress: e[0].erc20TokenAddress,
|
|
43
42
|
mintAddress: e[0].mintAddress,
|
|
44
43
|
timeStamp: l,
|
|
45
44
|
randomization: BigInt(U),
|
|
46
45
|
stealthAddress: C,
|
|
47
|
-
encryptionKey:
|
|
48
|
-
}), s = await
|
|
46
|
+
encryptionKey: B
|
|
47
|
+
}), s = await t.getRandomRelay(!d);
|
|
49
48
|
if (!s)
|
|
50
49
|
throw Error(m.RELAYER_NOT_AVAILABLE);
|
|
51
|
-
const
|
|
52
|
-
tokenNumber:
|
|
50
|
+
const h = I.findCorrectRandomization(J(31), t.userKeys.getShieldedPrivateKey()), E = {
|
|
51
|
+
tokenNumber: r.length,
|
|
53
52
|
nullifierAmount: e.length,
|
|
54
53
|
outputAmount: 2
|
|
55
|
-
},
|
|
56
|
-
|
|
54
|
+
}, v = t.getSolanaProgram(u), g = q([[A, y]])[0].map((a) => Array.from($.getBytes(a))), { proofAArr: K, proofBArr: L, proofCArr: k, publicInputsArr: F } = await G(
|
|
55
|
+
t.generateProofRemotely,
|
|
57
56
|
p,
|
|
58
57
|
O,
|
|
59
58
|
x,
|
|
60
59
|
N,
|
|
61
|
-
|
|
62
|
-
[
|
|
60
|
+
v,
|
|
61
|
+
[r[0]],
|
|
63
62
|
[e],
|
|
64
63
|
[[A, y]],
|
|
65
|
-
|
|
64
|
+
h,
|
|
66
65
|
f,
|
|
67
66
|
0n,
|
|
68
|
-
|
|
67
|
+
T,
|
|
69
68
|
s,
|
|
70
69
|
E,
|
|
71
|
-
|
|
70
|
+
g,
|
|
72
71
|
n
|
|
73
|
-
), V =
|
|
72
|
+
), V = r[0] === T, z = {
|
|
74
73
|
recipient: s,
|
|
75
|
-
mint: V ? void 0 :
|
|
74
|
+
mint: V ? void 0 : r[0]
|
|
76
75
|
}, D = {
|
|
77
76
|
proofAArr: K,
|
|
78
77
|
proofBArr: L,
|
|
79
78
|
proofCArr: k,
|
|
80
79
|
publicInputsArr: F,
|
|
81
|
-
encryptedOutputs:
|
|
80
|
+
encryptedOutputs: g,
|
|
82
81
|
relayerFee: f.toString(),
|
|
83
82
|
dimensions: E
|
|
84
83
|
};
|
|
85
84
|
return Q(n, { relayAddress: s, functionName: "transfer", args: D, accounts: z });
|
|
86
85
|
};
|
|
87
86
|
export {
|
|
88
|
-
|
|
87
|
+
Tt as hinkalSolanaTransfer
|
|
89
88
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../types/circom-data.types.cjs");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../types/circom-data.types.cjs");const B=require("../../types/external-action.types.cjs"),C=require("../../constants/protocol.constants.cjs");require("../../types/activities.types.cjs");const K=require("../../functions/web3/events/getShieldedBalance.cjs"),b=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),N=require("../../functions/utils/time.utils.cjs"),M=require("../../error-handling/error-codes.constants.cjs"),D=require("../../functions/pre-transaction/getFeeStructure.cjs"),L=require("../../functions/snarkjs/common.snarkjs.cjs"),W=require("../../functions/snarkjs/constructSolanaZkProof.cjs"),j=require("../utxo/Utxo.cjs"),z=require("../../functions/web3/etherFunctions.cjs"),Z=require("../../functions/web3/functionCalls/transactCallRelayer.cjs");require("../../constants/token-data/index.cjs");const H=require("../../constants/chains.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/server.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");const V=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),Y=require("ethers"),G=async(e,r,t,i,g,f,u=!1)=>{if(u)throw new Error("onlyGasEstimate is not supported for Solana withdraw");const o=e.getCurrentChainId(),h=await e.getEthereumAddress(),{originalDeployer:l,hinkalIdl:d}=H.networkRegistry[o].contractData;if(!l||!d)throw new Error("missing data");const{userKeys:q,merkleTreeAccessToken:w,merkleTreeHinkal:S}=e,n=f??await D.getFeeStructure(o,g,r,B.ExternalActionId.Transact);t[0]-=n.flatFee;const{patchAccessTokenMerkleTree:m,kycRequired:A,hasAccessToken:T}=await V.shouldPatchAccessTokenMerkleTree(e,r,t);if(r.length>1)throw new Error("Solana Withdraw: Only one mint address is supported");const a=[...await K.addPaddingToUtxos(e,r,t,6)][0],k=N.getCurrentTimeInSeconds().toString(),{outputUtxos:s}=b.outputUtxoProcessing(e.userKeys,a,t[0],k,void 0,!1),c=await e.getRandomRelay(!u);if(!c)throw Error(M.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const R=j.Utxo.findCorrectRandomization(z.randomBigInt(31),e.userKeys.getShieldedPrivateKey()),p={tokenNumber:r.length,nullifierAmount:a.length,outputAmount:s.length},E=e.getSolanaProgram(d),P=L.calcEncryptedOutputs([s])[0][0],y=Array.from(Y.ethers.getBytes(P)),{proofAArr:x,proofBArr:v,proofCArr:I,publicInputsArr:_}=await W.constructSolanaZkProof(e.generateProofRemotely,l,S,w,q,E,[r[0]],[a],[s],R,n.flatFee,n.variableRate,i,c,p,[y],o,m),F=r[0]===C.solanaNativeAddress,O={recipient:i,mint:F?void 0:r[0]},U={proofAArr:x,proofBArr:v,proofCArr:I,publicInputsArr:_,encryptedOutputs:[y],relayerFee:n.flatFee.toString(),dimensions:p};return Z.solanaTransactCallRelayer(o,{relayAddress:c,functionName:"transact",args:U,accounts:O,solanaAccessTokenData:!T&&A?{ethereumAddress:h,accessKey:q.getAccessKey()}:void 0})};exports.hinkalSolanaWithdraw=G;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "../../types/circom-data.types.mjs";
|
|
2
|
-
import { ExternalActionId as
|
|
2
|
+
import { ExternalActionId as U } from "../../types/external-action.types.mjs";
|
|
3
3
|
import { solanaNativeAddress as C } from "../../constants/protocol.constants.mjs";
|
|
4
|
-
import "../../types/transactions.types.mjs";
|
|
5
4
|
import "../../types/activities.types.mjs";
|
|
6
5
|
import { addPaddingToUtxos as b } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
7
6
|
import { outputUtxoProcessing as D } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
@@ -29,13 +28,13 @@ import "../../constants/tasks.constants.mjs";
|
|
|
29
28
|
import "../../constants/events.constants.mjs";
|
|
30
29
|
import { shouldPatchAccessTokenMerkleTree as Z } from "../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs";
|
|
31
30
|
import { ethers as j } from "ethers";
|
|
32
|
-
const
|
|
31
|
+
const It = async (t, r, o, s, y, g, m = !1) => {
|
|
33
32
|
if (m)
|
|
34
33
|
throw new Error("onlyGasEstimate is not supported for Solana withdraw");
|
|
35
34
|
const e = t.getCurrentChainId(), w = await t.getEthereumAddress(), { originalDeployer: p, hinkalIdl: u } = Y[e].contractData;
|
|
36
35
|
if (!p || !u)
|
|
37
36
|
throw new Error("missing data");
|
|
38
|
-
const { userKeys: f, merkleTreeAccessToken: A, merkleTreeHinkal: T } = t, a = g ?? await M(e, y, r,
|
|
37
|
+
const { userKeys: f, merkleTreeAccessToken: A, merkleTreeHinkal: T } = t, a = g ?? await M(e, y, r, U.Transact);
|
|
39
38
|
o[0] -= a.flatFee;
|
|
40
39
|
const { patchAccessTokenMerkleTree: S, kycRequired: h, hasAccessToken: E } = await Z(
|
|
41
40
|
t,
|
|
@@ -44,9 +43,9 @@ const kt = async (t, r, o, s, y, g, m = !1) => {
|
|
|
44
43
|
);
|
|
45
44
|
if (r.length > 1)
|
|
46
45
|
throw new Error("Solana Withdraw: Only one mint address is supported");
|
|
47
|
-
const
|
|
46
|
+
const n = [...await b(t, r, o, 6)][0], R = L().toString(), { outputUtxos: i } = D(
|
|
48
47
|
t.userKeys,
|
|
49
|
-
|
|
48
|
+
n,
|
|
50
49
|
o[0],
|
|
51
50
|
R,
|
|
52
51
|
void 0,
|
|
@@ -56,9 +55,9 @@ const kt = async (t, r, o, s, y, g, m = !1) => {
|
|
|
56
55
|
throw Error(z.RELAYER_NOT_AVAILABLE);
|
|
57
56
|
const x = q.findCorrectRandomization(H(31), t.userKeys.getShieldedPrivateKey()), l = {
|
|
58
57
|
tokenNumber: r.length,
|
|
59
|
-
nullifierAmount:
|
|
60
|
-
outputAmount:
|
|
61
|
-
}, I = t.getSolanaProgram(u), k = W([
|
|
58
|
+
nullifierAmount: n.length,
|
|
59
|
+
outputAmount: i.length
|
|
60
|
+
}, I = t.getSolanaProgram(u), k = W([i])[0][0], d = Array.from(j.getBytes(k)), { proofAArr: v, proofBArr: P, proofCArr: K, publicInputsArr: O } = await _(
|
|
62
61
|
t.generateProofRemotely,
|
|
63
62
|
p,
|
|
64
63
|
T,
|
|
@@ -66,8 +65,8 @@ const kt = async (t, r, o, s, y, g, m = !1) => {
|
|
|
66
65
|
f,
|
|
67
66
|
I,
|
|
68
67
|
[r[0]],
|
|
69
|
-
[i],
|
|
70
68
|
[n],
|
|
69
|
+
[i],
|
|
71
70
|
x,
|
|
72
71
|
a.flatFee,
|
|
73
72
|
a.variableRate,
|
|
@@ -77,10 +76,10 @@ const kt = async (t, r, o, s, y, g, m = !1) => {
|
|
|
77
76
|
[d],
|
|
78
77
|
e,
|
|
79
78
|
S
|
|
80
|
-
),
|
|
79
|
+
), B = r[0] === C, F = {
|
|
81
80
|
recipient: s,
|
|
82
|
-
mint:
|
|
83
|
-
},
|
|
81
|
+
mint: B ? void 0 : r[0]
|
|
82
|
+
}, N = {
|
|
84
83
|
proofAArr: v,
|
|
85
84
|
proofBArr: P,
|
|
86
85
|
proofCArr: K,
|
|
@@ -92,8 +91,8 @@ const kt = async (t, r, o, s, y, g, m = !1) => {
|
|
|
92
91
|
return V(e, {
|
|
93
92
|
relayAddress: c,
|
|
94
93
|
functionName: "transact",
|
|
95
|
-
args:
|
|
96
|
-
accounts:
|
|
94
|
+
args: N,
|
|
95
|
+
accounts: F,
|
|
97
96
|
solanaAccessTokenData: !E && h ? {
|
|
98
97
|
ethereumAddress: w,
|
|
99
98
|
accessKey: f.getAccessKey()
|
|
@@ -101,5 +100,5 @@ const kt = async (t, r, o, s, y, g, m = !1) => {
|
|
|
101
100
|
});
|
|
102
101
|
};
|
|
103
102
|
export {
|
|
104
|
-
|
|
103
|
+
It as hinkalSolanaWithdraw
|
|
105
104
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("../../error-handling/error-codes.constants.cjs"),L=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),M=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),H=require("../../functions/web3/events/getShieldedBalance.cjs"),K=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),N=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),W=require("../../functions/pre-transaction/getFeeStructure.cjs"),B=require("../../functions/pre-transaction/merge-with-fee-structure.cjs"),b=require("../../types/external-action.types.cjs"),k=require("../../types/hinkal.types.cjs"),G=require("../../functions/pre-transaction/outputApprovalDataProcessing.cjs"),O=require("../../types/ethereum-network.types.cjs"),V=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),Z=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),$=require("../../functions/pre-transaction/getExternalSwapAddress.cjs"),j=require("../../functions/utils/time.utils.cjs"),z=require("../../constants/protocol.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("../../error-handling/error-codes.constants.cjs"),L=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),M=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),H=require("../../functions/web3/events/getShieldedBalance.cjs"),K=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),N=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),W=require("../../functions/pre-transaction/getFeeStructure.cjs"),B=require("../../functions/pre-transaction/merge-with-fee-structure.cjs"),b=require("../../types/external-action.types.cjs"),k=require("../../types/hinkal.types.cjs"),G=require("../../functions/pre-transaction/outputApprovalDataProcessing.cjs"),O=require("../../types/ethereum-network.types.cjs"),V=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),Z=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),$=require("../../functions/pre-transaction/getExternalSwapAddress.cjs"),j=require("../../functions/utils/time.utils.cjs"),z=require("../../constants/protocol.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/activities.types.cjs");require("../../constants/server.constants.cjs");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../http/HttpClient.cjs");require("axios");require("ethers");require("../../constants/token-data/index.cjs");require("../../API/getServerURL.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/save-depths.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../functions/utils/mutexes.utils.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");require("../crypto-keys/keys.cjs");const Y=require("../../functions/pre-transaction/constructAdminData.cjs");require("@solana/spl-token");const J=async(e,c,t,i,x,T,S,m,u=!1,w=!1)=>{const s=c.map(r=>r.erc20TokenAddress),d=await e.getEthereumAddress(),g=S??await W.getFeeStructure(e.getCurrentChainId(),T,s,b.ExternalActionId.Transact,void 0,z.HINKAL_SWAP_VARIABLE_RATE);B.mergeWithFeeStructure(e.getCurrentChainId(),s,t,g);const f=$.getExternalSwapAddress(e,i),o={externalActionId:i,externalAddress:f,externalActionMetadata:x},a=[...await H.addPaddingToUtxos(e,s,t)],v=`swapperM${t.length.toString()}x${a[0].length}x1`,D=[!1,!0,!1].slice(0,t.length),q=[],n=k.defaultHinkalLogicArgs(t.length,e.userKeys),R=j.getCurrentTimeInSeconds().toString();for(let r=0;r<s.length;r+=1){const{outputUtxos:U}=L.outputUtxoProcessing(e.userKeys,a[r],t[r],R,void 0,!1);q.push(U);const{useApprovalUtxoData:y}=G.outputApprovalDataProcessing(e,a[r],t[r]);y&&(n.useApprovalUtxoData[r]=y,n.doPreTxApproval=!0)}const l=await e.getRandomRelay(!u);if(!l)throw Error(F.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{patchAccessTokenMerkleTree:P,kycRequired:h,hasAccessToken:E}=await V.shouldPatchAccessTokenMerkleTree(e,s,t),I=await Z.getSignatureDataForTransact(e.getCurrentChainId(),d,e.userKeys,h,E),{zkCallData:p,circomData:A,dimData:C}=await M.constructZkProof("v1x1",e.merkleTreeHinkal,e.merkleTreeAccessToken,a,q,e.userKeys,v,o.externalActionId,o.externalAddress,o.externalActionMetadata,e.generateProofRemotely,l,e.getCurrentChainId(),D,void 0,void 0,P,n,void 0,g,e.getContractWithFetcher(O.ContractType.HinkalHelperContract),I);if(u)return await K.estimateGasRelayer(e,p,C,A);const _=Y.constructAdminData(m,e.getCurrentChainId(),s,t,d,c);return await N.transactCallRelayer(e.getCurrentChainId(),p,C,A,w,void 0,void 0,_)};exports.hinkalSwap=J;
|
|
@@ -16,7 +16,6 @@ import { getExternalSwapAddress as b } from "../../functions/pre-transaction/get
|
|
|
16
16
|
import { getCurrentTimeInSeconds as j } from "../../functions/utils/time.utils.mjs";
|
|
17
17
|
import { HINKAL_SWAP_VARIABLE_RATE as G } from "../../constants/protocol.constants.mjs";
|
|
18
18
|
import "../../types/circom-data.types.mjs";
|
|
19
|
-
import "../../types/transactions.types.mjs";
|
|
20
19
|
import "../../types/activities.types.mjs";
|
|
21
20
|
import "../../constants/server.constants.mjs";
|
|
22
21
|
import "../../constants/chains.constants.mjs";
|
|
@@ -38,7 +37,7 @@ import "@solana/web3.js";
|
|
|
38
37
|
import "../crypto-keys/keys.mjs";
|
|
39
38
|
import { constructAdminData as J } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
40
39
|
import "@solana/spl-token";
|
|
41
|
-
const
|
|
40
|
+
const Nt = async (t, m, e, p, l, T, y, w, c = !1, v = !1) => {
|
|
42
41
|
const o = m.map((r) => r.erc20TokenAddress), n = await t.getEthereumAddress(), d = y ?? await B(
|
|
43
42
|
t.getCurrentChainId(),
|
|
44
43
|
T,
|
|
@@ -125,5 +124,5 @@ const Wt = async (t, m, e, p, l, T, y, w, c = !1, v = !1) => {
|
|
|
125
124
|
);
|
|
126
125
|
};
|
|
127
126
|
export {
|
|
128
|
-
|
|
127
|
+
Nt as hinkalSwap
|
|
129
128
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../../error-handling/error-codes.constants.cjs"),N=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),F=require("../../functions/web3/events/getShieldedBalance.cjs"),M=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),U=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),L=require("../../functions/pre-transaction/getFeeStructure.cjs"),V=require("../../functions/pre-transaction/merge-with-fee-structure.cjs");require("../../types/circom-data.types.cjs");const k=require("../../types/ethereum-network.types.cjs"),H=require("../../types/external-action.types.cjs"),K=require("../../types/hinkal.types.cjs");require("../../types/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../../error-handling/error-codes.constants.cjs"),N=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),F=require("../../functions/web3/events/getShieldedBalance.cjs"),M=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),U=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),L=require("../../functions/pre-transaction/getFeeStructure.cjs"),V=require("../../functions/pre-transaction/merge-with-fee-structure.cjs");require("../../types/circom-data.types.cjs");const k=require("../../types/ethereum-network.types.cjs"),H=require("../../types/external-action.types.cjs"),K=require("../../types/hinkal.types.cjs");require("../../types/activities.types.cjs");const O=require("../../functions/pre-transaction/outputUtxoProcessing.cjs");require("../../constants/server.constants.cjs");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../http/HttpClient.cjs");require("axios");require("ethers");require("../../constants/token-data/index.cjs");const B=require("../../constants/protocol.constants.cjs"),G=require("../../functions/pre-transaction/outputApprovalDataProcessing.cjs"),W=require("../../functions/pre-transaction/getVolatileTransferAmount.cjs"),b=require("../../functions/pre-transaction/constructAdminData.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");require("circomlibjs-hinkal-fork");require("@solana/spl-token");require("../crypto-keys/keys.cjs");require("buffer");const Z=require("../../functions/utils/time.utils.cjs"),$=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),j=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),z=require("../../functions/utils/addresses.cjs"),Y=async(e,n,E,A,x,y,f,I=!1)=>{if(!z.isValidPrivateAddress(A))throw Error(d.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);const o=n.map(t=>t.erc20TokenAddress),r=await W.modifyVolatileTokenAmountChanges(e.getCurrentChainId(),n,E),l=-r[0]*(10000n-B.HINKAL_PRIVATE_SEND_VARIABLE_RATE)/10000n;if(l<=0n)throw Error(d.transactionErrorCodes.RECIPIENT_AMOUNT_INVALID);const g=y??await L.getFeeStructure(e.getCurrentChainId(),x,o,H.ExternalActionId.Transact);V.mergeWithFeeStructure(e.getCurrentChainId(),o,r,g);const a=e.getCurrentChainId();if(!n[0])throw Error("Transfer Action: No Token Found");const c=await e.getRandomRelay(),i={externalActionId:0n,externalAddress:c??await e.getEthereumAddress(),externalActionMetadata:"0x00"},s=[...await F.addPaddingToUtxos(e,o,r)],w=`swapperM${r.length}x${s[0].length}x2`,q=[],u=K.defaultHinkalLogicArgs(r.length,e.userKeys),R=Z.getCurrentTimeInSeconds().toString();for(let t=0;t<o.length;t+=1){const{outputUtxos:S}=O.outputUtxoProcessing(e.userKeys,s[t],r[t],R,void 0,!1,A,t===0?l:0n);q.push(S);const{useApprovalUtxoData:C}=G.outputApprovalDataProcessing(e,s[t],r[t]);C&&(u.useApprovalUtxoData[t]=C,u.doPreTxApproval=!0)}if(!c)throw Error(d.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{patchAccessTokenMerkleTree:h,kycRequired:v,hasAccessToken:D}=await $.shouldPatchAccessTokenMerkleTree(e,o,r),P=await j.getSignatureDataForTransact(a,await e.getEthereumAddress(),e.userKeys,v,D),{zkCallData:m,circomData:T,dimData:p}=await N.constructZkProof("v1x1",e.merkleTreeHinkal,e.merkleTreeAccessToken,s,q,e.userKeys,w,i.externalActionId,i.externalAddress,i.externalActionMetadata,e.generateProofRemotely,c,a,void 0,void 0,void 0,h,u,void 0,g,e.getContractWithFetcher(k.ContractType.HinkalHelperContract),P);if(I)return await M.estimateGasRelayer(e,m,p,T);const _=b.constructAdminData(f,a,o,r,await e.getEthereumAddress());return await U.transactCallRelayer(a,m,p,T,void 0,void 0,void 0,_)};exports.hinkalTransfer=Y;
|
|
@@ -9,7 +9,6 @@ import "../../types/circom-data.types.mjs";
|
|
|
9
9
|
import { ContractType as K } from "../../types/ethereum-network.types.mjs";
|
|
10
10
|
import { ExternalActionId as O } from "../../types/external-action.types.mjs";
|
|
11
11
|
import { defaultHinkalLogicArgs as B } from "../../types/hinkal.types.mjs";
|
|
12
|
-
import "../../types/transactions.types.mjs";
|
|
13
12
|
import "../../types/activities.types.mjs";
|
|
14
13
|
import { outputUtxoProcessing as W } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
15
14
|
import "../../constants/server.constants.mjs";
|
|
@@ -33,7 +32,7 @@ import { getCurrentTimeInSeconds as Y } from "../../functions/utils/time.utils.m
|
|
|
33
32
|
import { shouldPatchAccessTokenMerkleTree as Z } from "../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs";
|
|
34
33
|
import { getSignatureDataForTransact as b } from "../../functions/pre-transaction/getSignatureDataForTransact.mjs";
|
|
35
34
|
import { isValidPrivateAddress as j } from "../../functions/utils/addresses.mjs";
|
|
36
|
-
const
|
|
35
|
+
const St = async (t, i, E, d, C, I, w, R = !1) => {
|
|
37
36
|
if (!j(d))
|
|
38
37
|
throw Error(p.RECIPIENT_FORMAT_INCORRECT);
|
|
39
38
|
const e = i.map((r) => r.erc20TokenAddress), o = await z(
|
|
@@ -126,5 +125,5 @@ const Ut = async (t, i, E, d, C, I, w, R = !1) => {
|
|
|
126
125
|
);
|
|
127
126
|
};
|
|
128
127
|
export {
|
|
129
|
-
|
|
128
|
+
St as hinkalTransfer
|
|
130
129
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("../../constants/protocol.constants.cjs"),_=require("../../error-handling/error-codes.constants.cjs"),M=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),R=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),W=require("../../functions/web3/events/getShieldedBalance.cjs"),L=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),N=require("../../functions/web3/functionCalls/transactCallDirect.cjs"),H=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),K=require("../../types/external-action.types.cjs"),V=require("../../types/hinkal.types.cjs"),b=require("../../functions/pre-transaction/outputApprovalDataProcessing.cjs"),k=require("../../functions/pre-transaction/getFeeStructure.cjs"),z=require("../../functions/pre-transaction/merge-with-fee-structure.cjs");require("../../types/circom-data.types.cjs");const B=require("../../types/ethereum-network.types.cjs");require("../../types/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("../../constants/protocol.constants.cjs"),_=require("../../error-handling/error-codes.constants.cjs"),M=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),R=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),W=require("../../functions/web3/events/getShieldedBalance.cjs"),L=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),N=require("../../functions/web3/functionCalls/transactCallDirect.cjs"),H=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),K=require("../../types/external-action.types.cjs"),V=require("../../types/hinkal.types.cjs"),b=require("../../functions/pre-transaction/outputApprovalDataProcessing.cjs"),k=require("../../functions/pre-transaction/getFeeStructure.cjs"),z=require("../../functions/pre-transaction/merge-with-fee-structure.cjs");require("../../types/circom-data.types.cjs");const B=require("../../types/ethereum-network.types.cjs");require("../../types/activities.types.cjs");const G=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),Z=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs");require("../../constants/server.constants.cjs");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../http/HttpClient.cjs");require("axios");require("ethers");require("../../constants/token-data/index.cjs");const $=require("../../functions/pre-transaction/getVolatileTransferAmount.cjs"),j=require("../../functions/pre-transaction/constructAdminData.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");require("circomlibjs-hinkal-fork");require("@solana/spl-token");require("../crypto-keys/keys.cjs");require("buffer");const Y=require("../../functions/utils/time.utils.cjs"),J=async(e,n,C,T,a,w,y,D,q=!1)=>{const o=n.map(t=>t.erc20TokenAddress),r=await $.modifyVolatileTokenAmountChanges(e.getCurrentChainId(),n,C);let c;a||(c=y??await k.getFeeStructure(e.getCurrentChainId(),w,o,K.ExternalActionId.Transact),z.mergeWithFeeStructure(e.getCurrentChainId(),o,r,c));const i=n[0];if(!i)throw Error("Deposit Action: No Token Found");const u={externalActionId:0n,externalAddress:T,externalActionMetadata:"0x00"},s=[...await W.addPaddingToUtxos(e,o,r)],v=`swapperM${r.length.toString()}x${s[0].length}x1`,p=[],d=V.defaultHinkalLogicArgs(r.length,e.userKeys),h=Y.getCurrentTimeInSeconds().toString();for(let t=0;t<o.length;t+=1){const{outputUtxos:F}=M.outputUtxoProcessing(e.userKeys,s[t],r[t],h,void 0,!1);p.push(F);const{useApprovalUtxoData:x}=b.outputApprovalDataProcessing(e,s[t],r[t]);x&&(d.useApprovalUtxoData[t]=x,d.doPreTxApproval=!0)}const m=await e.getRandomRelay(!q);if(!a&&!m)throw Error(_.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{patchAccessTokenMerkleTree:S,kycRequired:E,hasAccessToken:I}=await Z.shouldPatchAccessTokenMerkleTree(e,o,r),P=await G.getSignatureDataForTransact(e.getCurrentChainId(),await e.getEthereumAddress(),e.userKeys,E,I),{zkCallData:g,circomData:l,dimData:A}=await R.constructZkProof("v1x1",e.merkleTreeHinkal,e.merkleTreeAccessToken,s,p,e.userKeys,v,u.externalActionId,u.externalAddress,u.externalActionMetadata,e.generateProofRemotely,a?U.zeroAddress:m,e.getCurrentChainId(),void 0,void 0,void 0,S,d,void 0,c,e.getContractWithFetcher(B.ContractType.HinkalHelperContract),P,a?await e.getEthereumAddress():void 0);if(q)return await L.estimateGasRelayer(e,g,A,l);if(a){if(!i)throw Error("Withdraw Action: No Token Found");return await N.transactCallDirect(e,r[0],i,g,l,A)}const f=j.constructAdminData(D,e.getCurrentChainId(),o,r,await e.getEthereumAddress());return await H.transactCallRelayer(e.getCurrentChainId(),g,A,l,void 0,void 0,void 0,f)};exports.hinkalWithdraw=J;
|
|
@@ -13,7 +13,6 @@ import { getFeeStructure as q } from "../../functions/pre-transaction/getFeeStru
|
|
|
13
13
|
import { mergeWithFeeStructure as B } from "../../functions/pre-transaction/merge-with-fee-structure.mjs";
|
|
14
14
|
import "../../types/circom-data.types.mjs";
|
|
15
15
|
import { ContractType as Y } from "../../types/ethereum-network.types.mjs";
|
|
16
|
-
import "../../types/transactions.types.mjs";
|
|
17
16
|
import "../../types/activities.types.mjs";
|
|
18
17
|
import { getSignatureDataForTransact as Z } from "../../functions/pre-transaction/getSignatureDataForTransact.mjs";
|
|
19
18
|
import { shouldPatchAccessTokenMerkleTree as b } from "../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs";
|
|
@@ -33,7 +32,7 @@ import "@solana/spl-token";
|
|
|
33
32
|
import "../crypto-keys/keys.mjs";
|
|
34
33
|
import "buffer";
|
|
35
34
|
import { getCurrentTimeInSeconds as J } from "../../functions/utils/time.utils.mjs";
|
|
36
|
-
const
|
|
35
|
+
const Lt = async (t, s, w, l, a, T, v, D, A = !1) => {
|
|
37
36
|
const e = s.map((r) => r.erc20TokenAddress), o = await j(
|
|
38
37
|
t.getCurrentChainId(),
|
|
39
38
|
s,
|
|
@@ -48,7 +47,7 @@ const Mt = async (t, s, w, l, a, T, v, D, A = !1) => {
|
|
|
48
47
|
externalActionId: 0n,
|
|
49
48
|
externalAddress: l,
|
|
50
49
|
externalActionMetadata: "0x00"
|
|
51
|
-
}, i = [...await N(t, e, o)], E = `swapperM${o.length.toString()}x${i[0].length}x1`, f = [],
|
|
50
|
+
}, i = [...await N(t, e, o)], E = `swapperM${o.length.toString()}x${i[0].length}x1`, f = [], d = _(o.length, t.userKeys), I = J().toString();
|
|
52
51
|
for (let r = 0; r < e.length; r += 1) {
|
|
53
52
|
const { outputUtxos: F } = H(
|
|
54
53
|
t.userKeys,
|
|
@@ -60,7 +59,7 @@ const Mt = async (t, s, w, l, a, T, v, D, A = !1) => {
|
|
|
60
59
|
);
|
|
61
60
|
f.push(F);
|
|
62
61
|
const { useApprovalUtxoData: C } = $(t, i[r], o[r]);
|
|
63
|
-
C && (
|
|
62
|
+
C && (d.useApprovalUtxoData[r] = C, d.doPreTxApproval = !0);
|
|
64
63
|
}
|
|
65
64
|
const x = await t.getRandomRelay(!A);
|
|
66
65
|
if (!a && !x)
|
|
@@ -75,7 +74,7 @@ const Mt = async (t, s, w, l, a, T, v, D, A = !1) => {
|
|
|
75
74
|
t.userKeys,
|
|
76
75
|
S,
|
|
77
76
|
h
|
|
78
|
-
), { zkCallData:
|
|
77
|
+
), { zkCallData: p, circomData: u, dimData: g } = await K(
|
|
79
78
|
"v1x1",
|
|
80
79
|
t.merkleTreeHinkal,
|
|
81
80
|
t.merkleTreeAccessToken,
|
|
@@ -93,7 +92,7 @@ const Mt = async (t, s, w, l, a, T, v, D, A = !1) => {
|
|
|
93
92
|
void 0,
|
|
94
93
|
void 0,
|
|
95
94
|
y,
|
|
96
|
-
|
|
95
|
+
d,
|
|
97
96
|
void 0,
|
|
98
97
|
n,
|
|
99
98
|
t.getContractWithFetcher(Y.HinkalHelperContract),
|
|
@@ -101,11 +100,11 @@ const Mt = async (t, s, w, l, a, T, v, D, A = !1) => {
|
|
|
101
100
|
a ? await t.getEthereumAddress() : void 0
|
|
102
101
|
);
|
|
103
102
|
if (A)
|
|
104
|
-
return await R(t,
|
|
103
|
+
return await R(t, p, g, u);
|
|
105
104
|
if (a) {
|
|
106
105
|
if (!m)
|
|
107
106
|
throw Error("Withdraw Action: No Token Found");
|
|
108
|
-
return await W(t, o[0], m,
|
|
107
|
+
return await W(t, o[0], m, p, u, g);
|
|
109
108
|
}
|
|
110
109
|
const U = G(
|
|
111
110
|
D,
|
|
@@ -116,7 +115,7 @@ const Mt = async (t, s, w, l, a, T, v, D, A = !1) => {
|
|
|
116
115
|
);
|
|
117
116
|
return await z(
|
|
118
117
|
t.getCurrentChainId(),
|
|
119
|
-
|
|
118
|
+
p,
|
|
120
119
|
g,
|
|
121
120
|
u,
|
|
122
121
|
void 0,
|
|
@@ -126,5 +125,5 @@ const Mt = async (t, s, w, l, a, T, v, D, A = !1) => {
|
|
|
126
125
|
);
|
|
127
126
|
};
|
|
128
127
|
export {
|
|
129
|
-
|
|
128
|
+
Lt as hinkalWithdraw
|
|
130
129
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("../../error-handling/error-codes.constants.cjs"),P=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),D=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),F=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),E=require("../../types/external-action.types.cjs"),M=require("../../types/hinkal.types.cjs"),R=require("../../functions/pre-transaction/outputApprovalDataProcessing.cjs"),_=require("../../functions/pre-transaction/getFeeStructure.cjs"),W=require("../../functions/pre-transaction/merge-with-fee-structure.cjs");require("../../types/circom-data.types.cjs");const B=require("../../types/ethereum-network.types.cjs")
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("../../error-handling/error-codes.constants.cjs"),P=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),D=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),F=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),E=require("../../types/external-action.types.cjs"),M=require("../../types/hinkal.types.cjs"),R=require("../../functions/pre-transaction/outputApprovalDataProcessing.cjs"),_=require("../../functions/pre-transaction/getFeeStructure.cjs"),W=require("../../functions/pre-transaction/merge-with-fee-structure.cjs");require("../../types/circom-data.types.cjs");const B=require("../../types/ethereum-network.types.cjs"),b=require("../../types/admin.types.cjs");require("../../types/activities.types.cjs");const K=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),L=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs");require("../../constants/server.constants.cjs");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../http/HttpClient.cjs");require("axios");const N=require("../../functions/utils/amounts.utils.cjs");require("ethers");require("../../constants/token-data/index.cjs");require("../../API/getServerURL.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/save-depths.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../functions/utils/mutexes.utils.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");require("../crypto-keys/keys.cjs");const H=require("../../functions/utils/time.utils.cjs"),$=require("../../functions/pre-transaction/constructAdminData.cjs");require("@solana/spl-token");const O=require("../../functions/web3/events/getInputUtxoAndBalance.cjs"),Z=require("../../functions/web3/events/getShieldedBalance.cjs"),j=require("../../functions/utils/encodeTokenWithId.cjs"),z=async(e,a,i,d)=>{const r=[a.erc20TokenAddress],l=a.erc20TokenAddress,c=await _.getFeeStructure(e.getCurrentChainId(),l,r,E.ExternalActionId.Transact),u=i-c.flatFee;if(u<=0n)throw new Error(`Insufficient balance to cover fee. Balance: ${i}, Fee: ${c.flatFee}`);const t=[-u];W.mergeWithFeeStructure(e.getCurrentChainId(),r,t,c);const o={externalActionId:0n,externalAddress:d,externalActionMetadata:"0x00"},s=[...await Z.addPaddingToUtxos(e,r,t,void 0,void 0,!1,!0)],T=`swapperM${t.length.toString()}x${s[0].length}x1`,A=M.defaultHinkalLogicArgs(t.length,e.userKeys),m=H.getCurrentTimeInSeconds().toString(),q=[];for(let n=0;n<r.length;n+=1){const{outputUtxos:k}=P.outputUtxoProcessing(e.userKeys,s[n],t[n],m,void 0,!1);q.push(k);const{useApprovalUtxoData:x}=R.outputApprovalDataProcessing(e,s[n],t[n]);x&&(A.useApprovalUtxoData[n]=x,A.doPreTxApproval=!0)}const p=await e.getRandomRelay(!0);if(!p)throw Error(U.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{patchAccessTokenMerkleTree:f,kycRequired:y,hasAccessToken:C}=await L.shouldPatchAccessTokenMerkleTree(e,r,t),w=await K.getSignatureDataForTransact(e.getCurrentChainId(),await e.getEthereumAddress(),e.userKeys,y,C),{zkCallData:I,circomData:h,dimData:v}=await D.constructZkProof("v1x1",e.merkleTreeHinkal,e.merkleTreeAccessToken,s,q,e.userKeys,T,o.externalActionId,o.externalAddress,o.externalActionMetadata,e.generateProofRemotely,p,e.getCurrentChainId(),void 0,void 0,void 0,f,A,void 0,c,e.getContractWithFetcher(B.ContractType.HinkalHelperContract),w,void 0,!1),S=$.constructAdminData(b.AdminTransactionType.WithdrawOnChainUtxos,e.getCurrentChainId(),r,t,await e.getEthereumAddress());return{tx:await F.transactCallRelayer(e.getCurrentChainId(),I,v,h,void 0,void 0,void 0,S),amountToRecipient:u}},G=async(e,a,i)=>{const d=[],r=e.getCurrentChainId(),l=j.encodeTokenWithId(r,{erc20TokenAddress:a.erc20TokenAddress,tokenId:0});for(;;){await e.resetMerkleTreesIfNecessary();const u=((await O.getInputUtxoAndBalancePerToken({hinkal:e,sliceIfMore6:!1,useBlockedUtxos:!0}))?.get(l)??[]).filter(o=>o.amount>0n).slice(0,6).sort((o,s)=>Number(s.amount-o.amount)),g=N.countTotalAmountInUtxos(u);if(!g)break;const{tx:t}=await z(e,a,g,i);d.push(t)}return d};exports.hinkalWithdrawStuckUtxos=G;
|
|
@@ -9,7 +9,6 @@ import { getFeeStructure as L } from "../../functions/pre-transaction/getFeeStru
|
|
|
9
9
|
import { mergeWithFeeStructure as W } from "../../functions/pre-transaction/merge-with-fee-structure.mjs";
|
|
10
10
|
import "../../types/circom-data.types.mjs";
|
|
11
11
|
import { ContractType as B } from "../../types/ethereum-network.types.mjs";
|
|
12
|
-
import "../../types/transactions.types.mjs";
|
|
13
12
|
import { AdminTransactionType as H } from "../../types/admin.types.mjs";
|
|
14
13
|
import "../../types/activities.types.mjs";
|
|
15
14
|
import { getSignatureDataForTransact as N } from "../../functions/pre-transaction/getSignatureDataForTransact.mjs";
|
|
@@ -40,9 +39,9 @@ import { getInputUtxoAndBalancePerToken as q } from "../../functions/web3/events
|
|
|
40
39
|
import { addPaddingToUtxos as z } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
41
40
|
import { encodeTokenWithId as V } from "../../functions/utils/encodeTokenWithId.mjs";
|
|
42
41
|
const Y = async (t, s, m, d) => {
|
|
43
|
-
const r = [s.erc20TokenAddress],
|
|
42
|
+
const r = [s.erc20TokenAddress], u = s.erc20TokenAddress, i = await L(
|
|
44
43
|
t.getCurrentChainId(),
|
|
45
|
-
|
|
44
|
+
u,
|
|
46
45
|
r,
|
|
47
46
|
F.Transact
|
|
48
47
|
), c = m - i.flatFee;
|
|
@@ -125,22 +124,22 @@ const Y = async (t, s, m, d) => {
|
|
|
125
124
|
void 0,
|
|
126
125
|
D
|
|
127
126
|
), amountToRecipient: c };
|
|
128
|
-
},
|
|
129
|
-
const d = [], r = t.getCurrentChainId(),
|
|
127
|
+
}, Lt = async (t, s, m) => {
|
|
128
|
+
const d = [], r = t.getCurrentChainId(), u = V(r, { erc20TokenAddress: s.erc20TokenAddress, tokenId: 0 });
|
|
130
129
|
for (; ; ) {
|
|
131
130
|
await t.resetMerkleTreesIfNecessary();
|
|
132
131
|
const c = ((await q({
|
|
133
132
|
hinkal: t,
|
|
134
133
|
sliceIfMore6: !1,
|
|
135
134
|
useBlockedUtxos: !0
|
|
136
|
-
}))?.get(
|
|
137
|
-
if (!
|
|
135
|
+
}))?.get(u) ?? []).filter((o) => o.amount > 0n).slice(0, 6).sort((o, n) => Number(n.amount - o.amount)), p = b(c);
|
|
136
|
+
if (!p)
|
|
138
137
|
break;
|
|
139
|
-
const { tx: e } = await Y(t, s,
|
|
138
|
+
const { tx: e } = await Y(t, s, p, m);
|
|
140
139
|
d.push(e);
|
|
141
140
|
}
|
|
142
141
|
return d;
|
|
143
142
|
};
|
|
144
143
|
export {
|
|
145
|
-
|
|
144
|
+
Lt as hinkalWithdrawStuckUtxos
|
|
146
145
|
};
|