@hinkal/common 0.2.22 → 0.2.24
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 +27 -28
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.d.ts +1 -0
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +35 -36
- package/data-structures/Hinkal/hinkalDepostAndBridge.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepostAndBridge.mjs +86 -83
- 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 +72 -73
- 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
|
@@ -4,4 +4,5 @@ import { FeeStructure } from '../../types/hinkal.types';
|
|
|
4
4
|
export declare const hinkalDepositOnChainUtxos: (hinkal: IHinkal, erc20Token: ERC20Token, recipientAmounts: bigint[], recipientAddresses: string[], feeStructure: FeeStructure, hashedEthereumAddress: string) => Promise<{
|
|
5
5
|
userDepositedUtxos: RecipientUtxo[];
|
|
6
6
|
statusId?: string | undefined;
|
|
7
|
+
depositTxHash: string;
|
|
7
8
|
}>;
|
|
@@ -7,10 +7,9 @@ import { transactCallDirect as G } from "../../functions/web3/functionCalls/tran
|
|
|
7
7
|
import { ExternalActionId as J } from "../../types/external-action.types.mjs";
|
|
8
8
|
import "../../types/circom-data.types.mjs";
|
|
9
9
|
import { ContractType as p } from "../../types/ethereum-network.types.mjs";
|
|
10
|
-
import "../../types/transactions.types.mjs";
|
|
11
10
|
import { AdminTransactionType as L } from "../../types/admin.types.mjs";
|
|
12
11
|
import "../../types/activities.types.mjs";
|
|
13
|
-
import { DepositAndWithdrawPhase as
|
|
12
|
+
import { DepositAndWithdrawPhase as y } from "../../types/scheduled-transactions.types.mjs";
|
|
14
13
|
import { getSignatureDataForTransact as N } from "../../functions/pre-transaction/getSignatureDataForTransact.mjs";
|
|
15
14
|
import { shouldPatchAccessTokenMerkleTree as Q } from "../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs";
|
|
16
15
|
import { getUtxosFromReceipt as V } from "../../functions/utils/getUtxosFromReceipt.utils.mjs";
|
|
@@ -18,26 +17,26 @@ import { calculateTotalFee as Y } from "../../functions/utils/fees.utils.mjs";
|
|
|
18
17
|
import { constructAdminData as tt } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
19
18
|
import { emitTxPublicData as ot } from "../../API/admin-calls.mjs";
|
|
20
19
|
import { updateDepositAndWithdrawStatus as et, safeUpdateDepositAndWithdrawStatus as rt } from "../../API/deposit-and-withdraw-status-calls.mjs";
|
|
21
|
-
const
|
|
22
|
-
const f = m.erc20TokenAddress, x = await t.getEthereumAddress(), a =
|
|
20
|
+
const yt = async (t, m, O, E, P, u) => {
|
|
21
|
+
const f = m.erc20TokenAddress, x = await t.getEthereumAddress(), a = O.map((o) => o + Y(o, P)), i = [f], n = [0n], v = [!0], { patchAccessTokenMerkleTree: I, kycRequired: W, hasAccessToken: S } = await Q(
|
|
23
22
|
t,
|
|
24
23
|
i,
|
|
25
24
|
n
|
|
26
|
-
),
|
|
25
|
+
), F = await N(
|
|
27
26
|
t.getCurrentChainId(),
|
|
28
27
|
x,
|
|
29
28
|
t.userKeys,
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
W,
|
|
30
|
+
S
|
|
32
31
|
), r = [...await j(t, i, n)], C = [];
|
|
33
32
|
for (let o = 0; o < r.length; o += 1) {
|
|
34
33
|
const { outputUtxos: e } = B(t.userKeys, r[o], n[o]);
|
|
35
34
|
C.push(e);
|
|
36
35
|
}
|
|
37
|
-
const
|
|
38
|
-
zkCallData:
|
|
39
|
-
circomData:
|
|
40
|
-
dimData:
|
|
36
|
+
const A = a.reduce((o, e) => o + e, 0n), H = _.AbiCoder.defaultAbiCoder().encode(["uint256[]"], [a]), D = t.getContractWithSigner(p.HinkalWrapper), g = t.getContractWithSigner(p.DepositOnChainUtxos), {
|
|
37
|
+
zkCallData: R,
|
|
38
|
+
circomData: b,
|
|
39
|
+
dimData: K
|
|
41
40
|
} = await X(
|
|
42
41
|
"v1x1",
|
|
43
42
|
t.merkleTreeHinkal,
|
|
@@ -47,47 +46,47 @@ const Ot = async (t, m, y, O, E, u) => {
|
|
|
47
46
|
t.userKeys,
|
|
48
47
|
`swapperM1x${r[0].length}x1`,
|
|
49
48
|
J.DepositOnChainUtxos,
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
await g.getAddress(),
|
|
50
|
+
H,
|
|
52
51
|
t.generateProofRemotely,
|
|
53
52
|
q,
|
|
54
53
|
t.getCurrentChainId(),
|
|
55
|
-
|
|
54
|
+
v,
|
|
56
55
|
void 0,
|
|
57
56
|
void 0,
|
|
58
|
-
|
|
57
|
+
I,
|
|
59
58
|
void 0,
|
|
60
59
|
void 0,
|
|
61
60
|
void 0,
|
|
62
61
|
t.getContractWithFetcher(p.HinkalHelperContract),
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
F,
|
|
63
|
+
await D.getAddress(),
|
|
65
64
|
!1
|
|
66
|
-
), s = t.getCurrentChainId(),
|
|
65
|
+
), s = t.getCurrentChainId(), h = (await et(s, {
|
|
67
66
|
hashedEthereumAddress: u,
|
|
68
|
-
phase:
|
|
69
|
-
})).id ?? void 0,
|
|
67
|
+
phase: y.BEFORE_DEPOSIT
|
|
68
|
+
})).id ?? void 0, w = await G(
|
|
70
69
|
t,
|
|
71
|
-
|
|
70
|
+
A,
|
|
72
71
|
m,
|
|
73
|
-
H,
|
|
74
72
|
R,
|
|
75
73
|
b,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
K,
|
|
75
|
+
g,
|
|
76
|
+
D
|
|
77
|
+
), M = await w.wait(), T = w.hash;
|
|
79
78
|
await rt(s, {
|
|
80
|
-
id:
|
|
79
|
+
id: h,
|
|
81
80
|
hashedEthereumAddress: u,
|
|
82
|
-
phase:
|
|
83
|
-
depositTxHash:
|
|
81
|
+
phase: y.AFTER_DEPOSIT,
|
|
82
|
+
depositTxHash: T
|
|
84
83
|
});
|
|
85
|
-
const $ = V(
|
|
86
|
-
|
|
87
|
-
const
|
|
84
|
+
const $ = await V(M, t, f), l = [], c = [...$];
|
|
85
|
+
E.forEach((o, e) => {
|
|
86
|
+
const U = a[e], d = c.find((Z) => Z.amount === U);
|
|
88
87
|
if (!d)
|
|
89
|
-
throw new Error(`Could not find newly created UTXO with amount ${
|
|
90
|
-
|
|
88
|
+
throw new Error(`Could not find newly created UTXO with amount ${U} for recipient ${o}.`);
|
|
89
|
+
l.push({
|
|
91
90
|
recipientAddress: o,
|
|
92
91
|
utxo: d
|
|
93
92
|
});
|
|
@@ -98,11 +97,11 @@ const Ot = async (t, m, y, O, E, u) => {
|
|
|
98
97
|
L.DepositOnChainUtxos,
|
|
99
98
|
s,
|
|
100
99
|
i,
|
|
101
|
-
[
|
|
100
|
+
[A],
|
|
102
101
|
x
|
|
103
102
|
);
|
|
104
|
-
return ot(s, k), { userDepositedUtxos:
|
|
103
|
+
return ot(s, k), { userDepositedUtxos: l, statusId: h, depositTxHash: T };
|
|
105
104
|
};
|
|
106
105
|
export {
|
|
107
|
-
|
|
106
|
+
yt as hinkalDepositOnChainUtxos
|
|
108
107
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../../constants/protocol.constants.cjs"),X=require("../../error-handling/error-codes.constants.cjs"),ee=require("../../functions/snarkjs/constructEmporiumProof.cjs"),te=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../../constants/protocol.constants.cjs"),X=require("../../error-handling/error-codes.constants.cjs"),ee=require("../../functions/snarkjs/constructEmporiumProof.cjs"),te=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),x=require("../../types/external-action.types.cjs"),W=require("../utxo/Utxo.cjs");require("../../types/circom-data.types.cjs");const re=require("../../types/ethereum-network.types.cjs");require("../../types/activities.types.cjs");const b=require("../../types/scheduled-transactions.types.cjs"),se=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),oe=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),ne=require("../../functions/utils/time.utils.cjs"),ie=require("../../functions/pre-transaction/getFeeStructure.cjs"),ae=require("../../functions/utils/addresses.cjs"),ce=require("../../constants/chains.constants.cjs"),N=require("../../constants/addresses.constants.cjs");require("idb-keyval");require("@solana/web3.js");require("../http/HttpClient.cjs");require("../../constants/vite.constants.cjs");require("ethers");const ue=require("../../functions/utils/erc20tokenFunctions.cjs");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../../constants/server.constants.cjs");require("axios");const K=require("../../functions/utils/caseInsensitive.utils.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("../crypto-keys/keys.cjs");require("@solana/spl-token");require("../../constants/token-data/index.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/coingecko.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 de=require("../../functions/utils/convertEmporiumOpToCallInfo.cjs");require("multiformats");const le=require("../../API/API.cjs");require("../../API/tenderly.api.cjs");const z=require("./hinkalDepositOnChainUtxos.cjs"),B=require("../../functions/private-wallet/emporium.helpers.cjs"),L=require("../../API/deposit-and-withdraw-status-calls.cjs"),pe=async(e,q,o,v,i,E,d,l)=>{if(o.length===0)throw new Error("No recipients to bridge");const n=q.erc20TokenAddress,r=e.getCurrentChainId(),{contractData:a}=ce.networkRegistry[r],{emporiumAddress:T}=a;if(!T)throw Error("No Emporium Address");const D=N.SWAP_ROUTER_ADDRESSES[x.ExternalActionId.Lifi][r];if(!D)throw new Error(`LIFI not configured for chain ${r}`);const A=await e.getRandomRelay();if(!A)throw Error(X.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const C=await e.getEthereumAddress(),m=ne.getCurrentTimeInSeconds().toString(),f=e.generateProofRemotely?5:1,w=[];for(let c=0;c<o.length;c+=f){const R=o.slice(c,c+f),t=await Promise.all(R.map(async({utxo:s,nativeUtxo:u,bridgeAmount:h,quote:U,temporarySubAccount:S})=>{await le.API.addTemporaryWalletNonce(r,i,S.index);const H=U.nativeFee>0n&&!K.caseInsensitiveEqual(n,p.zeroAddress),g=[n],_=[-s.amount],k=[!1],F=new W.Utxo({amount:0n,erc20TokenAddress:n,shieldedPrivateKey:e.userKeys.getShieldedPrivateKey(),timeStamp:m,tokenId:0}),I=[[s,F]],P=[[F]];if(H&&u){const O=new W.Utxo({amount:0n,erc20TokenAddress:p.zeroAddress,shieldedPrivateKey:e.userKeys.getShieldedPrivateKey(),timeStamp:m,tokenId:0});g.push(p.zeroAddress),_.push(-u.amount),k.push(!1),I.push([u,O]),P.push([O])}const M=B.createLifiBridgeOps(e,S.ethAddress,D,n,s.amount,h,U),{patchAccessTokenMerkleTree:j,kycRequired:V,hasAccessToken:Y}=await oe.shouldPatchAccessTokenMerkleTree(e,g,_),Z=await se.getSignatureDataForTransact(r,C,e.userKeys,V,Y),{zkCallData:$,circomData:G,dimData:J,authorizationData:Q}=await ee.constructEmporiumProof("v1x1",e.merkleTreeHinkal,e.merkleTreeAccessToken,g,g.map(()=>0),I,P,e.userKeys,g.length,I[0].length,T,M,e.generateProofRemotely,A??p.zeroAddress,r,k,void 0,S.privateKey,void 0,j,void 0,v,e.getContractWithFetcher(re.ContractType.HinkalHelperContract),Z,void 0,!1);return{zkCallData:$,dimData:J,circomData:G,authorizationData:Q}}));w.push(...t)}await L.safeUpdateDepositAndWithdrawStatus(r,{id:E,hashedEthereumAddress:i,phase:b.DepositAndWithdrawPhase.BEFORE_SCHEDULE_WITHDRAW});const y=await te.transactCallRelayerBatch(r,w,i,d,l);return await L.safeUpdateDepositAndWithdrawStatus(r,{id:E,hashedEthereumAddress:i,phase:b.DepositAndWithdrawPhase.AFTER_SCHEDULE_WITHDRAW,scheduleId:y}),y},qe=async(e,q,o,v,i,E)=>{const d=q.erc20TokenAddress,l=e.getCurrentChainId(),n=ae.hashEthereumAddress(await e.getEthereumAddress()),r=N.SWAP_ROUTER_ADDRESSES[x.ExternalActionId.Lifi][l];if(!r)throw Error("LIFI router not configured");let a;if(i)a=i;else{const t=o[0],u=B.createLifiBridgeOps(e,t.temporarySubAccount.ethAddress,r,d,t.bridgeAmount,t.bridgeAmount,t.quote).map(h=>de.convertEmporiumOpToCallInfo(h,t.temporarySubAccount.ethAddress,l));a=await ie.getFeeStructure(l,d,[d],x.ExternalActionId.Emporium,u)}const T={feeToken:a.feeToken,flatFee:0n,variableRate:0n},A=o.reduce((t,s)=>t+s.quote.nativeFee,0n)>0n&&!K.caseInsensitiveEqual(d,p.zeroAddress),C=o.map(t=>t.bridgeAmount),m=o.map(t=>t.recipientAddress),{userDepositedUtxos:f,statusId:w,depositTxHash:y}=await z.hinkalDepositOnChainUtxos(e,q,C,m,a,n);let c=[];if(A){const t=ue.getERC20Token(p.zeroAddress,l);if(!t)throw Error("No native token");const s=o.map(h=>h.quote.nativeFee),{userDepositedUtxos:u}=await z.hinkalDepositOnChainUtxos(e,t,s,m,T,n);c=u}const R=o.map((t,s)=>({...t,utxo:f[s].utxo,nativeUtxo:A?c[s]?.utxo:void 0}));return await pe(e,q,R,a,n,w,v,E),y};exports.hinkalDepositAndBridge=qe;
|
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
import { zeroAddress as
|
|
1
|
+
import { zeroAddress as u } from "../../constants/protocol.constants.mjs";
|
|
2
2
|
import { transactionErrorCodes as X } from "../../error-handling/error-codes.constants.mjs";
|
|
3
3
|
import { constructEmporiumProof as tt } from "../../functions/snarkjs/constructEmporiumProof.mjs";
|
|
4
4
|
import { transactCallRelayerBatch as et } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
5
5
|
import { ExternalActionId as S } from "../../types/external-action.types.mjs";
|
|
6
|
-
import { Utxo as
|
|
6
|
+
import { Utxo as N } from "../utxo/Utxo.mjs";
|
|
7
7
|
import "../../types/circom-data.types.mjs";
|
|
8
8
|
import { ContractType as ot } from "../../types/ethereum-network.types.mjs";
|
|
9
|
-
import "../../types/transactions.types.mjs";
|
|
10
9
|
import "../../types/activities.types.mjs";
|
|
11
|
-
import { DepositAndWithdrawPhase as
|
|
10
|
+
import { DepositAndWithdrawPhase as W } from "../../types/scheduled-transactions.types.mjs";
|
|
12
11
|
import { getSignatureDataForTransact as rt } from "../../functions/pre-transaction/getSignatureDataForTransact.mjs";
|
|
13
12
|
import { shouldPatchAccessTokenMerkleTree as st } from "../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs";
|
|
14
13
|
import { getCurrentTimeInSeconds as it } from "../../functions/utils/time.utils.mjs";
|
|
15
|
-
import { getFeeStructure as
|
|
16
|
-
import { hashEthereumAddress as
|
|
14
|
+
import { getFeeStructure as at } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
15
|
+
import { hashEthereumAddress as nt } from "../../functions/utils/addresses.mjs";
|
|
17
16
|
import { networkRegistry as mt } from "../../constants/chains.constants.mjs";
|
|
18
|
-
import { SWAP_ROUTER_ADDRESSES as
|
|
19
|
-
import "ethers";
|
|
17
|
+
import { SWAP_ROUTER_ADDRESSES as O } from "../../constants/addresses.constants.mjs";
|
|
20
18
|
import "idb-keyval";
|
|
21
19
|
import "@solana/web3.js";
|
|
22
20
|
import "../http/HttpClient.mjs";
|
|
23
21
|
import "../../constants/vite.constants.mjs";
|
|
22
|
+
import "ethers";
|
|
24
23
|
import { getERC20Token as pt } from "../../functions/utils/erc20tokenFunctions.mjs";
|
|
25
24
|
import "../../functions/utils/convertIntegrationProviderToExternalActionId.mjs";
|
|
26
25
|
import "../../constants/server.constants.mjs";
|
|
27
26
|
import "axios";
|
|
28
|
-
import { caseInsensitiveEqual as
|
|
27
|
+
import { caseInsensitiveEqual as z } from "../../functions/utils/caseInsensitive.utils.mjs";
|
|
29
28
|
import "../../API/getServerURL.mjs";
|
|
30
29
|
import "circomlibjs-hinkal-fork";
|
|
31
30
|
import "libsodium-wrappers";
|
|
@@ -51,55 +50,55 @@ import { convertEmporiumOpToCallInfo as ct } from "../../functions/utils/convert
|
|
|
51
50
|
import "multiformats";
|
|
52
51
|
import { API as dt } from "../../API/API.mjs";
|
|
53
52
|
import "../../API/tenderly.api.mjs";
|
|
54
|
-
import { hinkalDepositOnChainUtxos as
|
|
55
|
-
import { createLifiBridgeOps as
|
|
53
|
+
import { hinkalDepositOnChainUtxos as H } from "./hinkalDepositOnChainUtxos.mjs";
|
|
54
|
+
import { createLifiBridgeOps as B } from "../../functions/private-wallet/emporium.helpers.mjs";
|
|
56
55
|
import { safeUpdateDepositAndWithdrawStatus as _ } from "../../API/deposit-and-withdraw-status-calls.mjs";
|
|
57
|
-
const ut = async (t,
|
|
58
|
-
if (
|
|
56
|
+
const ut = async (t, f, s, R, a, T, c, d) => {
|
|
57
|
+
if (s.length === 0)
|
|
59
58
|
throw new Error("No recipients to bridge");
|
|
60
|
-
const i =
|
|
59
|
+
const i = f.erc20TokenAddress, o = t.getCurrentChainId(), { contractData: n } = mt[o], { emporiumAddress: w } = n;
|
|
61
60
|
if (!w)
|
|
62
61
|
throw Error("No Emporium Address");
|
|
63
|
-
const C =
|
|
62
|
+
const C = O[S.Lifi][o];
|
|
64
63
|
if (!C)
|
|
65
64
|
throw new Error(`LIFI not configured for chain ${o}`);
|
|
66
|
-
const
|
|
67
|
-
if (!
|
|
65
|
+
const A = await t.getRandomRelay();
|
|
66
|
+
if (!A)
|
|
68
67
|
throw Error(X.RELAYER_NOT_AVAILABLE);
|
|
69
|
-
const D = await t.getEthereumAddress(),
|
|
70
|
-
for (let
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
await dt.addTemporaryWalletNonce(o,
|
|
74
|
-
const q =
|
|
68
|
+
const D = await t.getEthereumAddress(), l = it().toString(), E = t.generateProofRemotely ? 5 : 1, v = [];
|
|
69
|
+
for (let m = 0; m < s.length; m += E) {
|
|
70
|
+
const I = s.slice(m, m + E), e = await Promise.all(
|
|
71
|
+
I.map(async ({ utxo: r, nativeUtxo: p, bridgeAmount: h, quote: U, temporarySubAccount: x }) => {
|
|
72
|
+
await dt.addTemporaryWalletNonce(o, a, x.index);
|
|
73
|
+
const q = U.nativeFee > 0n && !z(i, u), g = [i], k = [-r.amount], P = [!1], L = new N({
|
|
75
74
|
amount: 0n,
|
|
76
75
|
erc20TokenAddress: i,
|
|
77
76
|
shieldedPrivateKey: t.userKeys.getShieldedPrivateKey(),
|
|
78
|
-
timeStamp:
|
|
77
|
+
timeStamp: l,
|
|
79
78
|
tokenId: 0
|
|
80
|
-
}), F = [[
|
|
79
|
+
}), F = [[r, L]], b = [[L]];
|
|
81
80
|
if (q && p) {
|
|
82
|
-
const
|
|
81
|
+
const K = new N({
|
|
83
82
|
amount: 0n,
|
|
84
|
-
erc20TokenAddress:
|
|
83
|
+
erc20TokenAddress: u,
|
|
85
84
|
shieldedPrivateKey: t.userKeys.getShieldedPrivateKey(),
|
|
86
|
-
timeStamp:
|
|
85
|
+
timeStamp: l,
|
|
87
86
|
tokenId: 0
|
|
88
87
|
});
|
|
89
|
-
|
|
88
|
+
g.push(u), k.push(-p.amount), P.push(!1), F.push([p, K]), b.push([K]);
|
|
90
89
|
}
|
|
91
|
-
const M =
|
|
90
|
+
const M = B(
|
|
92
91
|
t,
|
|
93
|
-
|
|
92
|
+
x.ethAddress,
|
|
94
93
|
C,
|
|
95
94
|
i,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
r.amount,
|
|
96
|
+
h,
|
|
97
|
+
U
|
|
99
98
|
), { patchAccessTokenMerkleTree: V, kycRequired: Y, hasAccessToken: Z } = await st(
|
|
100
99
|
t,
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
g,
|
|
101
|
+
k
|
|
103
102
|
), $ = await rt(
|
|
104
103
|
o,
|
|
105
104
|
D,
|
|
@@ -110,21 +109,21 @@ const ut = async (t, A, r, R, n, T, c, d) => {
|
|
|
110
109
|
"v1x1",
|
|
111
110
|
t.merkleTreeHinkal,
|
|
112
111
|
t.merkleTreeAccessToken,
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
g,
|
|
113
|
+
g.map(() => 0),
|
|
115
114
|
F,
|
|
116
|
-
|
|
115
|
+
b,
|
|
117
116
|
t.userKeys,
|
|
118
|
-
|
|
117
|
+
g.length,
|
|
119
118
|
F[0].length,
|
|
120
119
|
w,
|
|
121
120
|
M,
|
|
122
121
|
t.generateProofRemotely,
|
|
123
|
-
|
|
122
|
+
A ?? u,
|
|
124
123
|
o,
|
|
125
|
-
|
|
124
|
+
P,
|
|
126
125
|
void 0,
|
|
127
|
-
|
|
126
|
+
x.privateKey,
|
|
128
127
|
void 0,
|
|
129
128
|
V,
|
|
130
129
|
void 0,
|
|
@@ -137,35 +136,35 @@ const ut = async (t, A, r, R, n, T, c, d) => {
|
|
|
137
136
|
return { zkCallData: j, dimData: J, circomData: G, authorizationData: Q };
|
|
138
137
|
})
|
|
139
138
|
);
|
|
140
|
-
|
|
139
|
+
v.push(...e);
|
|
141
140
|
}
|
|
142
141
|
await _(o, {
|
|
143
142
|
id: T,
|
|
144
|
-
hashedEthereumAddress:
|
|
145
|
-
phase:
|
|
143
|
+
hashedEthereumAddress: a,
|
|
144
|
+
phase: W.BEFORE_SCHEDULE_WITHDRAW
|
|
146
145
|
});
|
|
147
|
-
const
|
|
146
|
+
const y = await et(
|
|
148
147
|
o,
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
v,
|
|
149
|
+
a,
|
|
151
150
|
c,
|
|
152
151
|
d
|
|
153
152
|
);
|
|
154
153
|
return await _(o, {
|
|
155
154
|
id: T,
|
|
156
|
-
hashedEthereumAddress:
|
|
157
|
-
phase:
|
|
158
|
-
scheduleId:
|
|
159
|
-
}),
|
|
160
|
-
},
|
|
161
|
-
const c =
|
|
155
|
+
hashedEthereumAddress: a,
|
|
156
|
+
phase: W.AFTER_SCHEDULE_WITHDRAW,
|
|
157
|
+
scheduleId: y
|
|
158
|
+
}), y;
|
|
159
|
+
}, Ae = async (t, f, s, R, a, T) => {
|
|
160
|
+
const c = f.erc20TokenAddress, d = t.getCurrentChainId(), i = nt(await t.getEthereumAddress()), o = O[S.Lifi][d];
|
|
162
161
|
if (!o)
|
|
163
162
|
throw Error("LIFI router not configured");
|
|
164
|
-
let
|
|
165
|
-
if (
|
|
166
|
-
|
|
163
|
+
let n;
|
|
164
|
+
if (a)
|
|
165
|
+
n = a;
|
|
167
166
|
else {
|
|
168
|
-
const e =
|
|
167
|
+
const e = s[0], p = B(
|
|
169
168
|
t,
|
|
170
169
|
e.temporarySubAccount.ethAddress,
|
|
171
170
|
o,
|
|
@@ -174,53 +173,57 @@ const ut = async (t, A, r, R, n, T, c, d) => {
|
|
|
174
173
|
e.bridgeAmount,
|
|
175
174
|
e.quote
|
|
176
175
|
).map(
|
|
177
|
-
(
|
|
176
|
+
(h) => ct(h, e.temporarySubAccount.ethAddress, d)
|
|
178
177
|
);
|
|
179
|
-
|
|
178
|
+
n = await at(d, c, [c], S.Emporium, p);
|
|
180
179
|
}
|
|
181
180
|
const w = {
|
|
182
|
-
feeToken:
|
|
181
|
+
feeToken: n.feeToken,
|
|
183
182
|
flatFee: 0n,
|
|
184
183
|
variableRate: 0n
|
|
185
|
-
},
|
|
184
|
+
}, A = s.reduce((e, r) => e + r.quote.nativeFee, 0n) > 0n && !z(c, u), D = s.map((e) => e.bridgeAmount), l = s.map((e) => e.recipientAddress), {
|
|
185
|
+
userDepositedUtxos: E,
|
|
186
|
+
statusId: v,
|
|
187
|
+
depositTxHash: y
|
|
188
|
+
} = await H(
|
|
186
189
|
t,
|
|
187
|
-
|
|
190
|
+
f,
|
|
188
191
|
D,
|
|
189
|
-
|
|
190
|
-
|
|
192
|
+
l,
|
|
193
|
+
n,
|
|
191
194
|
i
|
|
192
195
|
);
|
|
193
|
-
let
|
|
194
|
-
if (
|
|
195
|
-
const e = pt(
|
|
196
|
+
let m = [];
|
|
197
|
+
if (A) {
|
|
198
|
+
const e = pt(u, d);
|
|
196
199
|
if (!e)
|
|
197
200
|
throw Error("No native token");
|
|
198
|
-
const
|
|
201
|
+
const r = s.map((h) => h.quote.nativeFee), { userDepositedUtxos: p } = await H(
|
|
199
202
|
t,
|
|
200
203
|
e,
|
|
201
|
-
|
|
202
|
-
|
|
204
|
+
r,
|
|
205
|
+
l,
|
|
203
206
|
w,
|
|
204
207
|
i
|
|
205
208
|
);
|
|
206
|
-
|
|
209
|
+
m = p;
|
|
207
210
|
}
|
|
208
|
-
const
|
|
211
|
+
const I = s.map((e, r) => ({
|
|
209
212
|
...e,
|
|
210
|
-
utxo:
|
|
211
|
-
nativeUtxo:
|
|
213
|
+
utxo: E[r].utxo,
|
|
214
|
+
nativeUtxo: A ? m[r]?.utxo : void 0
|
|
212
215
|
}));
|
|
213
|
-
return ut(
|
|
216
|
+
return await ut(
|
|
214
217
|
t,
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
+
f,
|
|
219
|
+
I,
|
|
220
|
+
n,
|
|
218
221
|
i,
|
|
219
|
-
|
|
222
|
+
v,
|
|
220
223
|
R,
|
|
221
224
|
T
|
|
222
|
-
);
|
|
225
|
+
), y;
|
|
223
226
|
};
|
|
224
227
|
export {
|
|
225
|
-
|
|
228
|
+
Ae as hinkalDepositAndBridge
|
|
226
229
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("../../error-handling/error-codes.constants.cjs"),K=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),V=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),X=require("../../functions/web3/events/getShieldedBalance.cjs"),z=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),G=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("../../error-handling/error-codes.constants.cjs"),K=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),V=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),X=require("../../functions/web3/events/getShieldedBalance.cjs"),z=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),G=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),C=require("../../types/external-action.types.cjs"),P=require("../../types/hinkal.types.cjs"),f=require("../../functions/utils/amounts.utils.cjs"),Z=require("../../functions/pre-transaction/outputApprovalDataProcessing.cjs"),$=require("../../constants/conversion.constants.cjs"),j=require("../../constants/protocol.constants.cjs"),Y=require("../../functions/pre-transaction/merge-with-fee-structure.cjs"),J=require("../../functions/pre-transaction/getFeeStructure.cjs"),w=require("../../types/ethereum-network.types.cjs"),v=require("../../error-handling/logger.cjs"),Q=require("../../functions/utils/involves-permit2-op.cjs"),tt=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),et=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),rt=require("../../functions/utils/inLogicMetadata.cjs"),ot=require("../../functions/utils/time.utils.cjs"),nt=require("../../functions/pre-transaction/constructAdminData.cjs"),at=require("../../functions/utils/getContractAddress.cjs"),ct=async(t,o,r,n,a,g,E,S,U,_,l=!1)=>{const R=rt.encodeParsedInLogicMetadata(E),i={externalActionId:C.ExternalActionId.Wallet,externalAddress:a,externalActionMetadata:R},k=t.getContractWithFetcher(w.ContractType.HinkalContract),u=o.findIndex(e=>e===j.zeroAddress),L=u!==-1&&r[u]<0n?-r[u]:0n,A=U??await J.getFeeStructure(t.getCurrentChainId(),S,o,C.ExternalActionId.Wallet,[{from:at.getContractAddress(k),to:a,value:L,calldata:g}]);Y.mergeWithFeeStructure(t.getCurrentChainId(),o,r,A),n=[...n],n.length<r.length&&n.push(0n);const c=[...await X.addPaddingToUtxos(t,o,r)],M=`swapperMHA${r.length.toString()}x${c[0].length}x1`,p=r.map(e=>!(e<0n)),m=[],s={inHinkalAddress:t.userKeys.getInHinkalAddress(a),executeApprovalChanges:n,hinkalLogicAction:P.HinkalLogicAction.EXECUTE,doPreTxApproval:!1,useApprovalUtxoData:[]},O=ot.getCurrentTimeInSeconds().toString();for(let e=0;e<o.length;e+=1){const y=p[e]?0n:-(f.absBigInt(r[e])-f.absBigInt(n[e])),{outputUtxos:b}=K.outputUtxoProcessing(t.userKeys,c[e],y,O,void 0,!1);m.push(b);const{useApprovalUtxoData:D}=Z.outputApprovalDataProcessing(t,c[e],y,a);s.useApprovalUtxoData.push(D??P.defaultUseApprovalUTXOData($.APPROVED_UTXO_CONVERSION_COUNT,0n)),D&&(s.doPreTxApproval=!0)}const T=await t.getRandomRelay(!l);if(!T)throw Error(B.transactionErrorCodes.RELAYER_NOT_AVAILABLE);v.Logger.log("hinkaInAction",{hinkalLogicArgs:s,deltaChanges:r,approvalChanges:n});const{patchAccessTokenMerkleTree:F,kycRequired:H,hasAccessToken:W}=await et.shouldPatchAccessTokenMerkleTree(t,o,r),h=await tt.getSignatureDataForTransact(t.getCurrentChainId(),await t.getEthereumAddress(),t.userKeys,H,W),{zkCallData:q,circomData:d,dimData:x}=await V.constructZkProof("v1x1",t.merkleTreeHinkal,t.merkleTreeAccessToken,c,m,t.userKeys,M,i.externalActionId,i.externalAddress,i.externalActionMetadata,t.generateProofRemotely,T,t.getCurrentChainId(),p,void 0,void 0,F,s,void 0,A,t.getContractWithFetcher(w.ContractType.HinkalHelperContract),h),I=Q.uniswapWorkaround([g]);if(v.Logger.log("hinkalInAction circomData",{circomData:d,withUniswapWorkAround:I}),l)return await z.estimateGasRelayer(t,q,x,d);const N=nt.constructAdminData(_,t.getCurrentChainId(),o,r,await t.getEthereumAddress());return await G.transactCallRelayer(t.getCurrentChainId(),q,x,d,I,void 0,void 0,N)};exports.hinkalInsideTransact=ct;
|
|
@@ -4,29 +4,30 @@ import { constructZkProof as B } from "../../functions/snarkjs/constructGeneralZ
|
|
|
4
4
|
import { addPaddingToUtxos as $ } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
5
5
|
import { estimateGasRelayer as b } from "../../functions/web3/functionCalls/estimateGasRelayer.mjs";
|
|
6
6
|
import { transactCallRelayer as q } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
7
|
-
import { ExternalActionId as
|
|
7
|
+
import { ExternalActionId as C } from "../../types/external-action.types.mjs";
|
|
8
8
|
import { HinkalLogicAction as Y, defaultUseApprovalUTXOData as Z } from "../../types/hinkal.types.mjs";
|
|
9
|
-
import { absBigInt as
|
|
9
|
+
import { absBigInt as E } from "../../functions/utils/amounts.utils.mjs";
|
|
10
10
|
import { outputApprovalDataProcessing as h } from "../../functions/pre-transaction/outputApprovalDataProcessing.mjs";
|
|
11
11
|
import { APPROVED_UTXO_CONVERSION_COUNT as j } from "../../constants/conversion.constants.mjs";
|
|
12
12
|
import { zeroAddress as G } from "../../constants/protocol.constants.mjs";
|
|
13
13
|
import { mergeWithFeeStructure as J } from "../../functions/pre-transaction/merge-with-fee-structure.mjs";
|
|
14
14
|
import { getFeeStructure as Q } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
15
|
-
import { ContractType as
|
|
16
|
-
import { Logger as
|
|
15
|
+
import { ContractType as U } from "../../types/ethereum-network.types.mjs";
|
|
16
|
+
import { Logger as y } from "../../error-handling/logger.mjs";
|
|
17
17
|
import { uniswapWorkaround as tt } from "../../functions/utils/involves-permit2-op.mjs";
|
|
18
18
|
import { getSignatureDataForTransact as ot } from "../../functions/pre-transaction/getSignatureDataForTransact.mjs";
|
|
19
19
|
import { shouldPatchAccessTokenMerkleTree as rt } from "../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs";
|
|
20
20
|
import { encodeParsedInLogicMetadata as et } from "../../functions/utils/inLogicMetadata.mjs";
|
|
21
21
|
import { getCurrentTimeInSeconds as at } from "../../functions/utils/time.utils.mjs";
|
|
22
22
|
import { constructAdminData as nt } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
23
|
-
|
|
23
|
+
import { getContractAddress as it } from "../../functions/utils/getContractAddress.mjs";
|
|
24
|
+
const Lt = async (t, e, r, a, n, p, P, v, R, S, f = !1) => {
|
|
24
25
|
const H = et(P), m = {
|
|
25
|
-
externalActionId:
|
|
26
|
+
externalActionId: C.Wallet,
|
|
26
27
|
externalAddress: n,
|
|
27
28
|
externalActionMetadata: H
|
|
28
|
-
}, L = t.getContractWithFetcher(
|
|
29
|
-
{ from: L
|
|
29
|
+
}, L = t.getContractWithFetcher(U.HinkalContract), s = e.findIndex((o) => o === G), O = s !== -1 && r[s] < 0n ? -r[s] : 0n, d = R ?? await Q(t.getCurrentChainId(), v, e, C.Wallet, [
|
|
30
|
+
{ from: it(L), to: n, value: O, calldata: p }
|
|
30
31
|
]);
|
|
31
32
|
J(t.getCurrentChainId(), e, r, d), a = [...a], a.length < r.length && a.push(0n);
|
|
32
33
|
const i = [...await $(t, e, r)], W = `swapperMHA${r.length.toString()}x${i[0].length}x1`, A = r.map((o) => !(o < 0n)), g = [], c = {
|
|
@@ -37,7 +38,7 @@ const St = async (t, e, r, a, n, p, P, v, R, S, f = !1) => {
|
|
|
37
38
|
useApprovalUtxoData: []
|
|
38
39
|
}, M = at().toString();
|
|
39
40
|
for (let o = 0; o < e.length; o += 1) {
|
|
40
|
-
const D = A[o] ? 0n : -(
|
|
41
|
+
const D = A[o] ? 0n : -(E(r[o]) - E(a[o])), { outputUtxos: V } = z(
|
|
41
42
|
t.userKeys,
|
|
42
43
|
i[o],
|
|
43
44
|
D,
|
|
@@ -59,7 +60,7 @@ const St = async (t, e, r, a, n, p, P, v, R, S, f = !1) => {
|
|
|
59
60
|
const x = await t.getRandomRelay(!f);
|
|
60
61
|
if (!x)
|
|
61
62
|
throw Error(X.RELAYER_NOT_AVAILABLE);
|
|
62
|
-
|
|
63
|
+
y.log("hinkaInAction", { hinkalLogicArgs: c, deltaChanges: r, approvalChanges: a });
|
|
63
64
|
const { patchAccessTokenMerkleTree: F, kycRequired: N, hasAccessToken: _ } = await rt(
|
|
64
65
|
t,
|
|
65
66
|
e,
|
|
@@ -91,10 +92,10 @@ const St = async (t, e, r, a, n, p, P, v, R, S, f = !1) => {
|
|
|
91
92
|
c,
|
|
92
93
|
void 0,
|
|
93
94
|
d,
|
|
94
|
-
t.getContractWithFetcher(
|
|
95
|
+
t.getContractWithFetcher(U.HinkalHelperContract),
|
|
95
96
|
k
|
|
96
97
|
), T = tt([p]);
|
|
97
|
-
if (
|
|
98
|
+
if (y.log("hinkalInAction circomData", { circomData: u, withUniswapWorkAround: T }), f)
|
|
98
99
|
return await b(t, l, I, u);
|
|
99
100
|
const K = nt(
|
|
100
101
|
S,
|
|
@@ -115,5 +116,5 @@ const St = async (t, e, r, a, n, p, P, v, R, S, f = !1) => {
|
|
|
115
116
|
);
|
|
116
117
|
};
|
|
117
118
|
export {
|
|
118
|
-
|
|
119
|
+
Lt as hinkalInsideTransact
|
|
119
120
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("../../constants/chains.constants.cjs"),I=require("../../error-handling/error-codes.constants.cjs");require("ethers");require("../../types/circom-data.types.cjs");const V=require("../../types/ethereum-network.types.cjs"),b=require("../../types/external-action.types.cjs"),j=require("../../types/hinkal.types.cjs")
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("../../constants/chains.constants.cjs"),I=require("../../error-handling/error-codes.constants.cjs");require("ethers");require("../../types/circom-data.types.cjs");const V=require("../../types/ethereum-network.types.cjs"),b=require("../../types/external-action.types.cjs"),j=require("../../types/hinkal.types.cjs"),S=require("../../types/admin.types.cjs");require("../../types/activities.types.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("../http/HttpClient.cjs");require("axios");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/vite.constants.cjs");require("../../constants/save-depths.cjs");const G=require("../../functions/utils/caseInsensitive.utils.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../functions/utils/mutexes.utils.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");const Y=require("../crypto-keys/keys.cjs"),J=require("../../functions/utils/time.utils.cjs"),Q=require("../../functions/snarkjs/constructEmporiumProof.cjs"),X=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),Z=require("../../functions/web3/events/getShieldedBalance.cjs"),$=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),ee=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),re=require("../../functions/utils/involves-permit2-op.cjs"),te=require("../../functions/pre-transaction/outputApprovalDataProcessing.cjs"),oe=require("../../functions/utils/convertEmporiumOpToCallInfo.cjs"),se=require("../../functions/pre-transaction/getFeeStructure.cjs"),ie=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),ae=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),ne=require("../../functions/pre-transaction/merge-with-fee-structure-emporium.cjs"),ue=require("./handleAutoDepositBack.cjs");require("../../constants/token-data/index.cjs");const ce=require("../../functions/pre-transaction/constructAdminData.cjs");require("@solana/spl-token");const de=require("../../functions/pre-transaction/recipientUtxoProcessing.cjs"),pe=require("../../functions/utils/addresses.cjs"),qe=async(e,t,o,l,n,s,m,R,U,_,F=!1,C,g,u,v=!1)=>{if(u&&!pe.isValidPrivateAddress(u.recipientInfo))throw Error(I.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);const c=e.getCurrentChainId(),d=Y.UserKeys.getSignerAddressFromPrivateKey(c,m.privateKey),{contractData:K}=z.networkRegistry[c],{emporiumAddress:p}=K;if(!p)throw Error("No Emporium Address Provided");const q=U??await se.getFeeStructure(c,R,t,b.ExternalActionId.Emporium,n.map(r=>oe.convertEmporiumOpToCallInfo(r,d??"",c))),k=s.find(r=>G.caseInsensitiveEqual(r.token.erc20TokenAddress,q.feeToken))?.amount??0n;for(d&&await ne.mergeWithFeeStructureEmporium(e,d,n,t,o,q,k);l.length<t.length;)l.push(!1);const i=[...await Z.addPaddingToUtxos(e,t,o)],A=[],a=j.defaultHinkalLogicArgs(o.length,e.userKeys),f=J.getCurrentTimeInSeconds().toString();for(let r=0;r<t.length;r+=1){const{outputUtxos:B}=X.outputUtxoProcessing(e.userKeys,i[r],o[r],f,void 0,!1);A.push(B);const{useApprovalUtxoData:x}=te.outputApprovalDataProcessing(e,i[r],o[r]);x&&(a.doPreTxApproval=!0,a.useApprovalUtxoData[r]=x,a.interactionAddress=p,a.inHinkalAddress=e.userKeys.getInHinkalAddress(p))}u&&de.recipientUtxoProcessing(u,A,o,f);const E=_??await e.getRandomRelay(!v);if(!E)throw Error(I.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{patchAccessTokenMerkleTree:O,kycRequired:W,hasAccessToken:h}=await ie.shouldPatchAccessTokenMerkleTree(e,t,o),H=await ae.getSignatureDataForTransact(e.getCurrentChainId(),await e.getEthereumAddress(),e.userKeys,W,h),{zkCallData:w,circomData:y,dimData:P,authorizationData:D}=await Q.constructEmporiumProof("v1x1",e.merkleTreeHinkal,e.merkleTreeAccessToken,t,t.map(()=>0),i,A,e.userKeys,o.length,i.length>0?i[0].length:0,p,n,e.generateProofRemotely,E,e.getCurrentChainId(),l,void 0,m.privateKey,a,O,void 0,q,e.getContractWithFetcher(V.ContractType.HinkalHelperContract),H),L=re.uniswapWorkaround(n);if(v)return await $.estimateGasRelayer(e,w,P,y,D);const T=g===S.AdminTransactionType.FundApproveAndTransact,M=ce.constructAdminData(g,e.getCurrentChainId(),s.map(r=>r.token.erc20TokenAddress),s.map(r=>r.amount),await e.getEthereumAddress(),g===S.AdminTransactionType.PublicSwap?s.map(({token:r})=>r):void 0,T?o:void 0,T?t:void 0,T?s:void 0),N=await ee.transactCallRelayer(e.getCurrentChainId(),w,P,y,!1,L,D,M);return F&&ue.handleAutoDepositBack(e,d,m,q.feeToken,C,s,y),N};exports.hinkalPrivateWallet=qe;
|
|
@@ -5,7 +5,6 @@ import "../../types/circom-data.types.mjs";
|
|
|
5
5
|
import { ContractType as Y } from "../../types/ethereum-network.types.mjs";
|
|
6
6
|
import { ExternalActionId as j } from "../../types/external-action.types.mjs";
|
|
7
7
|
import { defaultHinkalLogicArgs as G } from "../../types/hinkal.types.mjs";
|
|
8
|
-
import "../../types/transactions.types.mjs";
|
|
9
8
|
import { AdminTransactionType as U } from "../../types/admin.types.mjs";
|
|
10
9
|
import "../../types/activities.types.mjs";
|
|
11
10
|
import "../../constants/server.constants.mjs";
|
|
@@ -43,7 +42,7 @@ import { constructAdminData as nt } from "../../functions/pre-transaction/constr
|
|
|
43
42
|
import "@solana/spl-token";
|
|
44
43
|
import { recipientUtxoProcessing as ct } from "../../functions/pre-transaction/recipientUtxoProcessing.mjs";
|
|
45
44
|
import { isValidPrivateAddress as ut } from "../../functions/utils/addresses.mjs";
|
|
46
|
-
const
|
|
45
|
+
const or = async (t, o, e, d, p, i, A, K, S, F, H = !1, C, g, s, y = !1) => {
|
|
47
46
|
if (s && !ut(s.recipientInfo))
|
|
48
47
|
throw Error(R.RECIPIENT_FORMAT_INCORRECT);
|
|
49
48
|
const n = t.getCurrentChainId(), c = Q.getSignerAddressFromPrivateKey(n, A.privateKey), { contractData: L } = k[n], { emporiumAddress: u } = L;
|
|
@@ -157,5 +156,5 @@ const er = async (t, o, e, d, p, i, A, K, S, F, H = !1, C, g, s, y = !1) => {
|
|
|
157
156
|
), B;
|
|
158
157
|
};
|
|
159
158
|
export {
|
|
160
|
-
|
|
159
|
+
or as hinkalPrivateWallet
|
|
161
160
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../functions/snarkjs/common.snarkjs.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../functions/snarkjs/common.snarkjs.cjs"),A=require("../../functions/web3/etherFunctions.cjs"),l=require("../../types/ethereum-network.types.cjs"),C=require("../utxo/Utxo.cjs"),h=require("../../constants/protocol.constants.cjs"),g=require("../../functions/utils/caseInsensitive.utils.cjs"),k=require("../../functions/utils/getContractAddress.cjs"),q=(n,e)=>{const r=[];let o=0;for(let s=0;s<n.length;s+=1){let a=!1;for(let t=0;t<o;t+=1)if(g.caseInsensitiveEqual(r[t].token.erc20TokenAddress,n[s].erc20TokenAddress)){r[t].balance+=e[s],a=!0;break}a||(r[o]={token:n[s],balance:e[s]},o+=1)}return r},y=async(n,e,r)=>{const o=q(e,r),s=n.getContractWithSigner(l.ContractType.HinkalContract),a=k.getContractAddress(s);for(let t=0;t<o.length;t+=1)g.caseInsensitiveEqual(o[t].token.erc20TokenAddress,h.zeroAddress)||await(await n.getContractWithSigner(l.ContractType.ERC20Contract,o[t].token.erc20TokenAddress).approve(a,o[t].balance)).wait()},v=async(n,e,r,o)=>{const s=n.getContractWithSigner(l.ContractType.HinkalContract),a=n.userKeys.getShieldedPrivateKey(),t=C.Utxo.findCorrectRandomization(A.randomBigInt(31),a),c=o??Array(e.length).fill(f.calcStealthAddressStructure(t,a));if(c.length!==e.length)throw new Error("Stealth address structures length must be equal to erc20 tokens length");await y(n,e,r);const d=e.findIndex(i=>i.erc20TokenAddress===h.zeroAddress),p=r[d]??0n,u=await s.prooflessDeposit(e.map(({erc20TokenAddress:i})=>i),r,e.map(()=>0n),c,{value:p});return await u.wait(),u};exports.hinkalProoflessDeposit=v;
|