@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
|
@@ -5,7 +5,7 @@ import { UserKeys as S } from "../../data-structures/crypto-keys/keys.mjs";
|
|
|
5
5
|
import { encryptUtxo as y } from "../../data-structures/crypto-keys/encryptDecryptUtxo.mjs";
|
|
6
6
|
import { defaultHookData as O } from "../../types/circom-data.types.mjs";
|
|
7
7
|
import { getExternalActionIdHash as f } from "../utils/external-action.utils.mjs";
|
|
8
|
-
import { HinkalLogicAction as
|
|
8
|
+
import { HinkalLogicAction as g } from "../../types/hinkal.types.mjs";
|
|
9
9
|
import { calculateBigIntSum as T } from "../utils/amounts.utils.mjs";
|
|
10
10
|
import { getOriginalSender as R } from "./getOriginalSender.mjs";
|
|
11
11
|
const $ = (e, s) => e.map((t, r) => t.map((n) => s[r] ? "0" : n.getNullifier())), q = (e, s, t) => {
|
|
@@ -25,10 +25,10 @@ const $ = (e, s) => e.map((t, r) => t.map((n) => s[r] ? "0" : n.getNullifier()))
|
|
|
25
25
|
}
|
|
26
26
|
return r;
|
|
27
27
|
}, L = (e) => e.useApprovalUtxoData.reduce((s, t) => [...s, T(t.approvalChanges)], []), Q = (e, s) => {
|
|
28
|
-
const t = L(s), r = s.hinkalLogicAction, n = e.map((a, l) => r ===
|
|
29
|
-
return r ===
|
|
28
|
+
const t = L(s), r = s.hinkalLogicAction, n = e.map((a, l) => r === g.NONE || r === g.APPROVE ? a + t[l] >= 0n ? 0n : a + t[l] : a >= 0n ? 0n : a);
|
|
29
|
+
return r === g.RELEASE_BUFFER ? e.forEach((a, l) => {
|
|
30
30
|
n[l] = a > 0n ? -a : a;
|
|
31
|
-
}) : r ===
|
|
31
|
+
}) : r === g.EXECUTE && s.executeApprovalChanges.forEach((a, l) => {
|
|
32
32
|
n[l] = a + e[l] < 0n ? a + e[l] : 0n;
|
|
33
33
|
}), n;
|
|
34
34
|
}, Y = (e) => {
|
|
@@ -89,10 +89,10 @@ const $ = (e, s) => e.map((t, r) => t.map((n) => s[r] ? "0" : n.getNullifier()))
|
|
|
89
89
|
})
|
|
90
90
|
), t;
|
|
91
91
|
}
|
|
92
|
-
}, se = (e, s, t, r, n, a, l, i, m, H,
|
|
92
|
+
}, se = (e, s, t, r, n, a, l, i, m, C, H, d, u, k, b) => {
|
|
93
93
|
const h = Object.values(m || O), v = b ?? R(r ?? E, t);
|
|
94
94
|
if (e === "v1x0") {
|
|
95
|
-
const p = o.
|
|
95
|
+
const p = o.AbiCoder.defaultAbiCoder().encode(
|
|
96
96
|
[
|
|
97
97
|
"uint16",
|
|
98
98
|
"address",
|
|
@@ -114,9 +114,9 @@ const $ = (e, s) => e.map((t, r) => t.map((n) => s[r] ? "0" : n.getNullifier()))
|
|
|
114
114
|
i
|
|
115
115
|
]
|
|
116
116
|
);
|
|
117
|
-
return BigInt(o.
|
|
117
|
+
return BigInt(o.keccak256(p)) % c;
|
|
118
118
|
} else {
|
|
119
|
-
const p = o.
|
|
119
|
+
const p = o.AbiCoder.defaultAbiCoder().encode(
|
|
120
120
|
["uint16", "address", "address", "uint256", "bytes"],
|
|
121
121
|
[
|
|
122
122
|
s,
|
|
@@ -125,7 +125,7 @@ const $ = (e, s) => e.map((t, r) => t.map((n) => s[r] ? "0" : n.getNullifier()))
|
|
|
125
125
|
typeof n == "bigint" ? n : f(n),
|
|
126
126
|
a
|
|
127
127
|
]
|
|
128
|
-
), A = o.
|
|
128
|
+
), A = o.AbiCoder.defaultAbiCoder().encode(
|
|
129
129
|
[
|
|
130
130
|
"tuple(address, address, bytes, bytes)",
|
|
131
131
|
"bytes[][]",
|
|
@@ -139,21 +139,24 @@ const $ = (e, s) => e.map((t, r) => t.map((n) => s[r] ? "0" : n.getNullifier()))
|
|
|
139
139
|
[
|
|
140
140
|
h,
|
|
141
141
|
l,
|
|
142
|
-
[
|
|
143
|
-
H,
|
|
142
|
+
[u.feeToken, u.flatFee, u.variableRate],
|
|
144
143
|
C,
|
|
144
|
+
H,
|
|
145
145
|
[
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
146
|
+
d.hinkalLogicAction,
|
|
147
|
+
d.inHinkalAddress,
|
|
148
|
+
d.executeApprovalChanges,
|
|
149
|
+
d.doPreTxApproval,
|
|
150
|
+
d.useApprovalUtxoData
|
|
151
151
|
],
|
|
152
152
|
k,
|
|
153
153
|
v
|
|
154
154
|
]
|
|
155
|
-
), I = BigInt(o.
|
|
156
|
-
|
|
155
|
+
), I = BigInt(o.keccak256(p)), B = BigInt(o.keccak256(A)), V = o.AbiCoder.defaultAbiCoder().encode(
|
|
156
|
+
["uint256", "uint256"],
|
|
157
|
+
[I, B]
|
|
158
|
+
);
|
|
159
|
+
return BigInt(o.keccak256(V)) % c;
|
|
157
160
|
}
|
|
158
161
|
}, x = (e) => e.startsWith("swapperMO") || e.startsWith("swapperME") ? 2 : e.startsWith("swapperMW") ? 1 : (e.startsWith("swapperMHA"), 0), ne = (e, s, t, r, n, a) => {
|
|
159
162
|
if (e.startsWith("swapperMWMin0"))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../types/circom-data.types.cjs");require("../../types/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../types/circom-data.types.cjs");require("../../types/activities.types.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("../../error-handling/error-codes.constants.cjs");require("../../data-structures/crypto-keys/keys.cjs");const re=require("../../constants/chains.constants.cjs");require("../../constants/server.constants.cjs");require("../../constants/vite.constants.cjs");require("../../data-structures/http/HttpClient.cjs");require("axios");require("../../constants/token-data/index.cjs");require("../../API/getServerURL.cjs");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/save-depths.cjs");require("../../constants/reorg-depths.constants.cjs");require("../utils/mutexes.utils.cjs");require("@coral-xyz/anchor");const i=require("@solana/web3.js"),o=require("../pre-transaction/solana.cjs");require("@solana/spl-token");const ne=require("../utils/solanaMint.utils.cjs"),ae=require("./common.snarkjs.cjs"),oe=require("../../data-structures/Hinkal/hinkalCheckSolanaTokenRegistry.cjs"),ie=require("./generateZkProof.cjs"),ce=require("../../webworker/worker.registry.cjs"),se=require("../../webworker/performTaskWithWorker.cjs"),me=require("../../webworker/zkProofWorker/zkProofWorker.types.cjs"),ue=require("../pre-transaction/getSolanaCalldataHash.cjs"),le=require("./getMerkleTreeSiblingsAndRootHashes.cjs"),pe=async(g,k,S,d,c,f,s,r,n,P,b,h,y,T,a,A,m=re.chainIds.solanaLocalnet,C=!1,B=r.map(()=>!1),I=0n,w=[],K=[],H=!0)=>{const u="v1x1",_=new i.PublicKey(y),R=new i.PublicKey(T),W=c.getShieldedPrivateKey(),l=s.map(e=>ne.formatMintAddress(e)),Z=l.map(e=>e.mintAccountPart1),v=l.map(e=>e.mintAccountPart2),z=ue.getSolanaCalldataHash(a,_,R,A,b,h,w,K),M=`${a.tokenNumber}x${a.nullifierAmount}x${a.outputAmount}`,p=ae.calcAmountChanges(r,n),L=await oe.hinkalCheckSolanaTokenRegistry(f,new i.PublicKey(k),s,p),q=r.map(e=>e.map(t=>t.getConstructableParams())),{inCommitmentSiblings:N,inCommitmentSiblingSides:$,accessTokenSiblings:j,accessTokenSiblingSides:D,rootHashHinkal:V,rootHashAccessToken:E}=await le.getMerkleTreeSiblingsAndRootHashes(m,c,q,C,L,S,d,H),F=await se.performTaskWithWorker({type:ce.WorkerVariant.ZKProof,payload:{type:me.ZKProofWorkerActionType.BUILD_IN_NULLIFIERS,data:{inputUtxosSerialized:q,onChainCreation:B,proverVersion:u}}}),O={rootHashHinkal:V,shieldedPrivateKey:W,rootHashAccessToken:E,accessTokenSiblings:j,accessTokenSiblingSides:D,mintAccountPart1:Z,mintAccountPart2:v,inAmounts:r.map(e=>e.map(t=>t.amount)),inTimeStamps:r.map(e=>e.map(t=>t.timeStamp)),inRandomizations:r.map(e=>e.map(t=>t.randomization)),inNullifiers:F,inCommitmentSiblings:N,inCommitmentSiblingSides:$,outAmounts:n.map(e=>e.map(t=>t.amount.toString())),outTimeStamp:BigInt(n[0][0].timeStamp),outPublicKeys:n.map(e=>e.map(t=>t.getStealthAddress())),extraRandomization:P,amountChanges:p,outCommitments:n.map(e=>e.map(t=>t.amount===0n?0n:t.getCommitment())),calldataHash:z,swapperAccountSalt:I},{publicSignals:G,zkCallData:J}=await ie.generateZkProof(u,m,`basicSolana${M}`,O,g),[Q,X,Y]=J,x=Q.map(BigInt).map(o.encodeToByte32Array).flat(),U=X.flat().map(BigInt).map(o.encodeToByte32Array).flat(),ee=Y.map(BigInt).map(o.encodeToByte32Array).flat(),te=G.map(BigInt).map(o.encodeToByte32Array);return{proofAArr:x,proofBArr:U,proofCArr:ee,publicInputsArr:te}};exports.constructSolanaZkProof=pe;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import "../../types/circom-data.types.mjs";
|
|
2
|
-
import "../../types/transactions.types.mjs";
|
|
3
2
|
import "../../types/activities.types.mjs";
|
|
4
3
|
import "ethers";
|
|
5
4
|
import "circomlibjs-hinkal-fork";
|
|
@@ -22,8 +21,8 @@ import "@coral-xyz/anchor";
|
|
|
22
21
|
import { PublicKey as r } from "@solana/web3.js";
|
|
23
22
|
import { encodeToByte32Array as n } from "../pre-transaction/solana.mjs";
|
|
24
23
|
import "@solana/spl-token";
|
|
25
|
-
import { formatMintAddress as
|
|
26
|
-
import { calcAmountChanges as
|
|
24
|
+
import { formatMintAddress as at } from "../utils/solanaMint.utils.mjs";
|
|
25
|
+
import { calcAmountChanges as it } from "./common.snarkjs.mjs";
|
|
27
26
|
import { hinkalCheckSolanaTokenRegistry as nt } from "../../data-structures/Hinkal/hinkalCheckSolanaTokenRegistry.mjs";
|
|
28
27
|
import { generateZkProof as rt } from "./generateZkProof.mjs";
|
|
29
28
|
import { WorkerVariant as et } from "../../webworker/worker.registry.mjs";
|
|
@@ -31,9 +30,9 @@ import { performTaskWithWorker as pt } from "../../webworker/performTaskWithWork
|
|
|
31
30
|
import { ZKProofWorkerActionType as ct } from "../../webworker/zkProofWorker/zkProofWorker.types.mjs";
|
|
32
31
|
import { getSolanaCalldataHash as st } from "../pre-transaction/getSolanaCalldataHash.mjs";
|
|
33
32
|
import { getMerkleTreeSiblingsAndRootHashes as lt } from "./getMerkleTreeSiblingsAndRootHashes.mjs";
|
|
34
|
-
const
|
|
35
|
-
const s = "v1x1", v = new r(C), z = new r(I), L = e.getShieldedPrivateKey(), l = p.map((t) =>
|
|
36
|
-
|
|
33
|
+
const Ft = async (u, S, k, d, e, P, p, m, a, b, h, A, C, I, i, T, c = mt.solanaLocalnet, B = !1, w = m.map(() => !1), K = 0n, H = [], y = [], R = !0) => {
|
|
34
|
+
const s = "v1x1", v = new r(C), z = new r(I), L = e.getShieldedPrivateKey(), l = p.map((t) => at(t)), N = l.map((t) => t.mintAccountPart1), W = l.map((t) => t.mintAccountPart2), Z = st(
|
|
35
|
+
i,
|
|
37
36
|
v,
|
|
38
37
|
z,
|
|
39
38
|
T,
|
|
@@ -41,7 +40,7 @@ const jt = async (u, S, k, d, e, P, p, m, i, b, h, A, C, I, a, T, c = mt.solanaL
|
|
|
41
40
|
A,
|
|
42
41
|
H,
|
|
43
42
|
y
|
|
44
|
-
), $ = `${
|
|
43
|
+
), $ = `${i.tokenNumber}x${i.nullifierAmount}x${i.outputAmount}`, f = it(m, a), D = await nt(
|
|
45
44
|
P,
|
|
46
45
|
new r(S),
|
|
47
46
|
p,
|
|
@@ -82,12 +81,12 @@ const jt = async (u, S, k, d, e, P, p, m, i, b, h, A, C, I, a, T, c = mt.solanaL
|
|
|
82
81
|
inNullifiers: j,
|
|
83
82
|
inCommitmentSiblings: M,
|
|
84
83
|
inCommitmentSiblingSides: V,
|
|
85
|
-
outAmounts:
|
|
86
|
-
outTimeStamp: BigInt(
|
|
87
|
-
outPublicKeys:
|
|
84
|
+
outAmounts: a.map((t) => t.map((o) => o.amount.toString())),
|
|
85
|
+
outTimeStamp: BigInt(a[0][0].timeStamp),
|
|
86
|
+
outPublicKeys: a.map((t) => t.map((o) => o.getStealthAddress())),
|
|
88
87
|
extraRandomization: b,
|
|
89
88
|
amountChanges: f,
|
|
90
|
-
outCommitments:
|
|
89
|
+
outCommitments: a.map(
|
|
91
90
|
(t) => t.map((o) => o.amount === 0n ? 0n : o.getCommitment())
|
|
92
91
|
),
|
|
93
92
|
calldataHash: Z,
|
|
@@ -102,5 +101,5 @@ const jt = async (u, S, k, d, e, P, p, m, i, b, h, A, C, I, a, T, c = mt.solanaL
|
|
|
102
101
|
return { proofAArr: x, proofBArr: U, proofCArr: tt, publicInputsArr: ot };
|
|
103
102
|
};
|
|
104
103
|
export {
|
|
105
|
-
|
|
104
|
+
Ft as constructSolanaZkProof
|
|
106
105
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("ethers"),u=require("@solana/web3.js"),h=t=>{const[r,e,s,n,o]=t.split(","),c=!r||!e||!s||!n||!o,a=e?.substring(0,2)!=="0x"||s?.substring(0,2)!=="0x",d=s?.length!==66||e?.length>66||e?.length<64,l=t?.includes('"');return!(c||a||d||l)},g=t=>{const[r,e,,s,n]=t.split(",");return{extraRandomization:BigInt(r),stealthAddress:BigInt(e),H0:BigInt(s),H1:BigInt(n)}},b=t=>i.ethers.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("ethers"),u=require("@solana/web3.js"),h=t=>{const[r,e,s,n,o]=t.split(","),c=!r||!e||!s||!n||!o,a=e?.substring(0,2)!=="0x"||s?.substring(0,2)!=="0x",d=s?.length!==66||e?.length>66||e?.length<64,l=t?.includes('"');return!(c||a||d||l)},g=t=>{const[r,e,,s,n]=t.split(",");return{extraRandomization:BigInt(r),stealthAddress:BigInt(e),H0:BigInt(s),H1:BigInt(n)}},b=t=>i.ethers.keccak256(i.ethers.toUtf8Bytes(t.toLowerCase())),y=t=>{try{return new u.PublicKey(t).toBase58()===t}catch{return!1}};exports.constructStealthAddressStructure=g;exports.hashEthereumAddress=b;exports.isValidPrivateAddress=h;exports.isValidSolanaPublicKey=y;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { ethers as o } from "ethers";
|
|
2
2
|
import { PublicKey as u } from "@solana/web3.js";
|
|
3
3
|
const m = (t) => {
|
|
4
|
-
const [n,
|
|
5
|
-
return !(c || a ||
|
|
4
|
+
const [n, e, s, r, i] = t.split(","), c = !n || !e || !s || !r || !i, a = e?.substring(0, 2) !== "0x" || s?.substring(0, 2) !== "0x", d = s?.length !== 66 || e?.length > 66 || e?.length < 64, l = t?.includes('"');
|
|
5
|
+
return !(c || a || d || l);
|
|
6
6
|
}, y = (t) => {
|
|
7
|
-
const [n,
|
|
7
|
+
const [n, e, , s, r] = t.split(",");
|
|
8
8
|
return {
|
|
9
9
|
extraRandomization: BigInt(n),
|
|
10
|
-
stealthAddress: BigInt(
|
|
11
|
-
H0: BigInt(
|
|
10
|
+
stealthAddress: BigInt(e),
|
|
11
|
+
H0: BigInt(s),
|
|
12
12
|
H1: BigInt(r)
|
|
13
13
|
};
|
|
14
|
-
}, b = (t) => o.
|
|
14
|
+
}, b = (t) => o.keccak256(o.toUtf8Bytes(t.toLowerCase())), p = (t) => {
|
|
15
15
|
try {
|
|
16
16
|
return new u(t).toBase58() === t;
|
|
17
17
|
} catch {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("../../types/ethereum-network.types.cjs"),y=require("./getDataFromTransaction.cjs"),A=require("idb-keyval"),T=require("../../constants/chains.constants.cjs"),C={encryptedOutputs:[],lastOutput:""},o=(s,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("../../types/ethereum-network.types.cjs"),y=require("./getDataFromTransaction.cjs"),A=require("idb-keyval"),T=require("../../constants/chains.constants.cjs"),x=require("./getContractAddress.cjs"),C={encryptedOutputs:[],lastOutput:""},o=(s,e)=>{const t=s.substring(0,25),r=e.substring(0,25);return{shortPublicKey:t,shortHinkalAddress:r}},k=(s,e,t)=>`hinkalCache-${s}-${e}-${t}`,S=(s,e,t)=>{const{hinkalAddress:r}=T.networkRegistry[e].contractData;if(!e||!t||!r)throw Error("GetHinkalCache: incorrect arguments");const{shortPublicKey:n,shortHinkalAddress:a}=o(t,r);return JSON.parse(s.cacheDevice.get(k(e,n,a))??JSON.stringify(C))},p=(s,e,t,r)=>{const{hinkalAddress:n}=T.networkRegistry[t].contractData;if(!t||!r||!n)throw Error("SetHinkalCache: incorrect arguments");const{shortPublicKey:a,shortHinkalAddress:c}=o(r,n);e.cacheDevice.set(k(t,a,c),JSON.stringify(s))},f=(s,e,t)=>{p(C,s,e,t)},v=(s,e,t)=>`txsCache-${s}-${e}-${t}`,m=async(s,e,t,r,n,a)=>{if(!e||!t||!r)throw Error("saveTxsCache: incorrect arguments");const{shortPublicKey:c,shortHinkalAddress:i}=o(t,r),l=y.serializeDecodedTxs(s),h=v(e,c,i),g=JSON.stringify({serializedTxs:l,lastHash:n});try{await A.set(h,g)}catch{a.cacheDevice.set(h,g)}},w={serializedTxs:[],lastHash:""},O=async(s,e,t,r)=>{if(!s||!e||!t)throw Error("loadTxsCache: incorrect arguments");const{shortPublicKey:n,shortHinkalAddress:a}=o(e,t),c=v(s,n,a);let i;try{const d=await A.get(c);if(!d)throw new Error("Empty indexedDB cache");i=d}catch{i=r.cacheDevice.get(c)}const{serializedTxs:l,lastHash:h}=JSON.parse(i??JSON.stringify(w));return{decodedTxs:l.map(d=>y.deserializeDecodedTxs(d)),lastHash:h===""?void 0:h}},u=(s,e,t)=>`hinkalApprovalsCache-${s}-${e}-${t}`,D=(s,e,t,r)=>{const n=x.getContractAddress(e.getContract(H.ContractType.HinkalContract,void 0,t));if(!t||!r||!n)throw Error("SetHinkalCache: incorrect arguments");const{shortPublicKey:a,shortHinkalAddress:c}=o(r,n);e.cacheDevice.set(u(t,a,c),JSON.stringify(s))},N=(s,e,t)=>{const r=x.getContractAddress(s.getContract(H.ContractType.HinkalContract,void 0,e));if(!e||!t||!r)throw Error("GetHinkalCache: incorrect arguments");const{shortPublicKey:n,shortHinkalAddress:a}=o(t,r);return JSON.parse(s.cacheDevice.get(u(e,n,a))??JSON.stringify(C))},J=(s,e,t)=>{D({},s,e,t)};exports.getFilePath=k;exports.getHinkalCache=S;exports.getInHinkalAddressesCache=N;exports.getInHinkalAddressesFilePath=u;exports.loadTxsCache=O;exports.resetCache=f;exports.resetInHinkalAddressesCache=J;exports.saveTxsCache=m;exports.setHinkalCache=p;exports.setInHinkalAddressesCache=D;
|
|
@@ -11,7 +11,7 @@ export declare const setHinkalCache: (hinkalCache: HinkalCacheInterface, hinkal:
|
|
|
11
11
|
export declare const resetCache: (hinkal: IHinkal, chainId: number, shieldedPublicKey: string) => void;
|
|
12
12
|
export declare const saveTxsCache: (txs: DecodedTx[], chainId: number, shieldedPublicKey: string, hinkalAddress: string, lastHash: string, hinkal: IHinkal) => Promise<void>;
|
|
13
13
|
export declare const loadTxsCache: (chainId: number, shieldedPublicKey: string, hinkalAddress: string, hinkal: IHinkal) => Promise<{
|
|
14
|
-
decodedTxs: import("../../types/transactions.types").DecodedTxWithUtxos<bigint,
|
|
14
|
+
decodedTxs: import("../../types/transactions.types").DecodedTxWithUtxos<bigint, bigint>[];
|
|
15
15
|
lastHash: string | undefined;
|
|
16
16
|
}>;
|
|
17
17
|
export declare const getInHinkalAddressesFilePath: (chainId: number, shortPublicKey: string, shortHinkalAddress: string) => string;
|
|
@@ -1,82 +1,83 @@
|
|
|
1
|
-
import { ContractType as
|
|
2
|
-
import { serializeDecodedTxs as
|
|
3
|
-
import { set as x, get as
|
|
1
|
+
import { ContractType as k } from "../../types/ethereum-network.types.mjs";
|
|
2
|
+
import { serializeDecodedTxs as f, deserializeDecodedTxs as A } from "./getDataFromTransaction.mjs";
|
|
3
|
+
import { set as x, get as D } from "idb-keyval";
|
|
4
4
|
import { networkRegistry as H } from "../../constants/chains.constants.mjs";
|
|
5
|
-
|
|
5
|
+
import { getContractAddress as u } from "./getContractAddress.mjs";
|
|
6
|
+
const C = {
|
|
6
7
|
encryptedOutputs: [],
|
|
7
8
|
lastOutput: ""
|
|
8
|
-
}, a = (
|
|
9
|
-
const t =
|
|
10
|
-
return { shortPublicKey: t, shortHinkalAddress:
|
|
11
|
-
},
|
|
12
|
-
const { hinkalAddress:
|
|
13
|
-
if (!
|
|
9
|
+
}, a = (s, r) => {
|
|
10
|
+
const t = s.substring(0, 25), e = r.substring(0, 25);
|
|
11
|
+
return { shortPublicKey: t, shortHinkalAddress: e };
|
|
12
|
+
}, y = (s, r, t) => `hinkalCache-${s}-${r}-${t}`, E = (s, r, t) => {
|
|
13
|
+
const { hinkalAddress: e } = H[r].contractData;
|
|
14
|
+
if (!r || !t || !e)
|
|
14
15
|
throw Error("GetHinkalCache: incorrect arguments");
|
|
15
|
-
const { shortPublicKey: c, shortHinkalAddress: n } = a(t,
|
|
16
|
+
const { shortPublicKey: c, shortHinkalAddress: n } = a(t, e);
|
|
16
17
|
return JSON.parse(
|
|
17
|
-
|
|
18
|
+
s.cacheDevice.get(y(r, c, n)) ?? JSON.stringify(C)
|
|
18
19
|
);
|
|
19
|
-
},
|
|
20
|
+
}, S = (s, r, t, e) => {
|
|
20
21
|
const { hinkalAddress: c } = H[t].contractData;
|
|
21
|
-
if (!t || !
|
|
22
|
+
if (!t || !e || !c)
|
|
22
23
|
throw Error("SetHinkalCache: incorrect arguments");
|
|
23
|
-
const { shortPublicKey: n, shortHinkalAddress: o } = a(
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
if (!
|
|
24
|
+
const { shortPublicKey: n, shortHinkalAddress: o } = a(e, c);
|
|
25
|
+
r.cacheDevice.set(y(t, n, o), JSON.stringify(s));
|
|
26
|
+
}, z = (s, r, t) => {
|
|
27
|
+
S(C, s, r, t);
|
|
28
|
+
}, m = (s, r, t) => `txsCache-${s}-${r}-${t}`, b = async (s, r, t, e, c, n) => {
|
|
29
|
+
if (!r || !t || !e)
|
|
29
30
|
throw Error("saveTxsCache: incorrect arguments");
|
|
30
|
-
const { shortPublicKey: o, shortHinkalAddress: i } = a(t,
|
|
31
|
+
const { shortPublicKey: o, shortHinkalAddress: i } = a(t, e), d = f(s), h = m(r, o, i), g = JSON.stringify({ serializedTxs: d, lastHash: c });
|
|
31
32
|
try {
|
|
32
33
|
await x(h, g);
|
|
33
34
|
} catch {
|
|
34
35
|
n.cacheDevice.set(h, g);
|
|
35
36
|
}
|
|
36
|
-
},
|
|
37
|
-
if (!
|
|
37
|
+
}, T = { serializedTxs: [], lastHash: "" }, P = async (s, r, t, e) => {
|
|
38
|
+
if (!s || !r || !t)
|
|
38
39
|
throw Error("loadTxsCache: incorrect arguments");
|
|
39
|
-
const { shortPublicKey: c, shortHinkalAddress: n } = a(
|
|
40
|
+
const { shortPublicKey: c, shortHinkalAddress: n } = a(r, t), o = m(s, c, n);
|
|
40
41
|
let i;
|
|
41
42
|
try {
|
|
42
|
-
const
|
|
43
|
-
if (!
|
|
43
|
+
const l = await D(o);
|
|
44
|
+
if (!l)
|
|
44
45
|
throw new Error("Empty indexedDB cache");
|
|
45
|
-
i =
|
|
46
|
+
i = l;
|
|
46
47
|
} catch {
|
|
47
|
-
i =
|
|
48
|
+
i = e.cacheDevice.get(o);
|
|
48
49
|
}
|
|
49
|
-
const { serializedTxs:
|
|
50
|
-
return { decodedTxs:
|
|
51
|
-
},
|
|
52
|
-
const c =
|
|
53
|
-
if (!t || !
|
|
50
|
+
const { serializedTxs: d, lastHash: h } = JSON.parse(i ?? JSON.stringify(T));
|
|
51
|
+
return { decodedTxs: d.map((l) => A(l)), lastHash: h === "" ? void 0 : h };
|
|
52
|
+
}, p = (s, r, t) => `hinkalApprovalsCache-${s}-${r}-${t}`, v = (s, r, t, e) => {
|
|
53
|
+
const c = u(r.getContract(k.HinkalContract, void 0, t));
|
|
54
|
+
if (!t || !e || !c)
|
|
54
55
|
throw Error("SetHinkalCache: incorrect arguments");
|
|
55
|
-
const { shortPublicKey: n, shortHinkalAddress: o } = a(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
JSON.stringify(
|
|
56
|
+
const { shortPublicKey: n, shortHinkalAddress: o } = a(e, c);
|
|
57
|
+
r.cacheDevice.set(
|
|
58
|
+
p(t, n, o),
|
|
59
|
+
JSON.stringify(s)
|
|
59
60
|
);
|
|
60
|
-
},
|
|
61
|
-
const
|
|
62
|
-
if (!
|
|
61
|
+
}, K = (s, r, t) => {
|
|
62
|
+
const e = u(s.getContract(k.HinkalContract, void 0, r));
|
|
63
|
+
if (!r || !t || !e)
|
|
63
64
|
throw Error("GetHinkalCache: incorrect arguments");
|
|
64
|
-
const { shortPublicKey: c, shortHinkalAddress: n } = a(t,
|
|
65
|
+
const { shortPublicKey: c, shortHinkalAddress: n } = a(t, e);
|
|
65
66
|
return JSON.parse(
|
|
66
|
-
|
|
67
|
+
s.cacheDevice.get(p(r, c, n)) ?? JSON.stringify(C)
|
|
67
68
|
);
|
|
68
|
-
},
|
|
69
|
-
|
|
69
|
+
}, B = (s, r, t) => {
|
|
70
|
+
v({}, s, r, t);
|
|
70
71
|
};
|
|
71
72
|
export {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
y as getFilePath,
|
|
74
|
+
E as getHinkalCache,
|
|
75
|
+
K as getInHinkalAddressesCache,
|
|
76
|
+
p as getInHinkalAddressesFilePath,
|
|
77
|
+
P as loadTxsCache,
|
|
78
|
+
z as resetCache,
|
|
79
|
+
B as resetInHinkalAddressesCache,
|
|
80
|
+
b as saveTxsCache,
|
|
81
|
+
S as setHinkalCache,
|
|
82
|
+
v as setInHinkalAddressesCache
|
|
82
83
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("ethers"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("ethers"),p=require("../../constants/chains.constants.cjs"),d=(o,s,n)=>{const{hinkalAddress:c}=p.networkRegistry[n].contractData,t=e.ethers.getBytes(o),l=t.slice(0,20),a=t.slice(20,21),r=t.slice(21,37),i=t.slice(37),[u,y,v,B]=[l,r,a,i].map(m=>e.ethers.hexlify(m));return{from:BigInt(v)>0?s:c,to:u,value:BigInt(y),calldata:B}};exports.convertEmporiumOpToCallInfo=d;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ethers as e } from "ethers";
|
|
2
2
|
import { networkRegistry as f } from "../../constants/chains.constants.mjs";
|
|
3
|
-
const
|
|
4
|
-
const { hinkalAddress:
|
|
5
|
-
(
|
|
3
|
+
const g = (o, s, l) => {
|
|
4
|
+
const { hinkalAddress: n } = f[l].contractData, t = e.getBytes(o), a = t.slice(0, 20), c = t.slice(20, 21), r = t.slice(21, 37), i = t.slice(37), [m, y, B, p] = [a, r, c, i].map(
|
|
5
|
+
(v) => e.hexlify(v)
|
|
6
6
|
);
|
|
7
|
-
return { from: BigInt(
|
|
7
|
+
return { from: BigInt(B) > 0 ? s : n, to: m, value: BigInt(y), calldata: p };
|
|
8
8
|
};
|
|
9
9
|
export {
|
|
10
|
-
|
|
10
|
+
g as convertEmporiumOpToCallInfo
|
|
11
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../providers/CustomSolanaConnection.cjs"),n=require("../../providers/CustomEthersProvider.cjs"),o=require("ethers"),s=e=>new o.ethers.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../providers/CustomSolanaConnection.cjs"),n=require("../../providers/CustomEthersProvider.cjs"),o=require("ethers"),s=e=>new o.ethers.JsonRpcProvider(e),c=e=>{const r=new n.CustomEthersProvider(e);return new o.ethers.BrowserProvider(r)},i=(e,r="confirmed")=>new t.CustomSolanaConnection(e,r);exports.createCustomRpcProvider=c;exports.createCustomSolanaConnection=i;exports.createProvider=s;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CustomSolanaConnection } from '../../providers/CustomSolanaConnection';
|
|
2
2
|
import { Commitment, ConnectionConfig } from '@solana/web3.js';
|
|
3
3
|
import { ethers } from 'ethers';
|
|
4
|
-
export declare const createProvider: (rpcUrl: string) => ethers.
|
|
5
|
-
export declare const createCustomRpcProvider: (rpcUrl: string) => ethers.
|
|
4
|
+
export declare const createProvider: (rpcUrl: string) => ethers.JsonRpcProvider;
|
|
5
|
+
export declare const createCustomRpcProvider: (rpcUrl: string) => ethers.BrowserProvider;
|
|
6
6
|
export declare const createCustomSolanaConnection: (endpoint: string, commitmentOrConfig?: Commitment | ConnectionConfig) => CustomSolanaConnection;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CustomSolanaConnection as t } from "../../providers/CustomSolanaConnection.mjs";
|
|
2
2
|
import { CustomEthersProvider as n } from "../../providers/CustomEthersProvider.mjs";
|
|
3
3
|
import { ethers as e } from "ethers";
|
|
4
|
-
const m = (r) => new e.
|
|
4
|
+
const m = (r) => new e.JsonRpcProvider(r), u = (r) => {
|
|
5
5
|
const o = new n(r);
|
|
6
|
-
return new e.
|
|
7
|
-
},
|
|
6
|
+
return new e.BrowserProvider(o);
|
|
7
|
+
}, a = (r, o = "confirmed") => new t(r, o);
|
|
8
8
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
u as createCustomRpcProvider,
|
|
10
|
+
a as createCustomSolanaConnection,
|
|
11
11
|
m as createProvider
|
|
12
12
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("node-forge"),m=require("../snarkjs/constant.cjs"),a=require("ethers"),o=require("libsodium-wrappers"),h=require("../../data-structures/http/HttpClient.cjs");require("axios");function b(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("node-forge"),m=require("../snarkjs/constant.cjs"),a=require("ethers"),o=require("libsodium-wrappers"),h=require("../../data-structures/http/HttpClient.cjs");require("axios");function b(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const s=b(l),f=214,p=async()=>{const t=(await h.httpClient.get(`${m.ENCLAVE_EC2_URL}/handshake`)).public_key,n=s.util.decode64(t),r=s.asn1.fromDer(n);return s.pki.publicKeyFromAsn1(r)},i=e=>typeof e=="bigint"||typeof e=="number"?e.toString():e,y=e=>s.util.hexToBytes(e.replace("0x","")),E=e=>{const t=structuredClone(e);return Object.entries(t).forEach(([n,r])=>{t[n]=i(r),Array.isArray(r)&&(Array.isArray(r[0])?t[n]=r.map(c=>c.map(i)):t[n]=r.map(i))}),t},k=(e,t)=>{const n=a.ethers.hexlify(t).slice(2),r=y(n);if(r.length>f)throw new Error("too many bytes passed to assymetric_encrypt");const c=e.encrypt(r,"RSA-OAEP",{md:s.md.sha1.create(),mgf1:{md:s.md.sha1.create()},label:null});return s.util.encode64(c)},A=(e,t)=>{const n=o.randombytes_buf(o.crypto_secretbox_NONCEBYTES),r=o.crypto_secretbox_easy(t,n,e),c=a.ethers.hexlify(n)+a.ethers.hexlify(r).slice(2),d=y(c);return s.util.encode64(d)},u=(e,t)=>{const n=o.randombytes_buf(o.crypto_secretbox_KEYBYTES),r=k(t,n),c=A(n,e);return{keyCiphertext:r,inputCiphertext:c}},g=(e,t)=>{const n=E(e),r=JSON.stringify(n),c=new TextEncoder().encode(r);return u(c,t)},x=async e=>{const t=await p();return g(e,t)},_=async e=>{const t=await p();return u(e,t)};exports.makeEnclaveHandshakeAndEncryptInput=x;exports.makeEnclaveHandshakeAndEncryptUint8Array=_;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import * as s from "node-forge";
|
|
2
|
-
import { ENCLAVE_EC2_URL as
|
|
2
|
+
import { ENCLAVE_EC2_URL as u } from "../snarkjs/constant.mjs";
|
|
3
3
|
import { ethers as a } from "ethers";
|
|
4
4
|
import c from "libsodium-wrappers";
|
|
5
5
|
import { httpClient as h } from "../../data-structures/http/HttpClient.mjs";
|
|
6
6
|
import "axios";
|
|
7
|
-
const
|
|
8
|
-
const e = (await h.get(`${
|
|
7
|
+
const f = 214, p = async () => {
|
|
8
|
+
const e = (await h.get(`${u}/handshake`)).public_key, r = s.util.decode64(e), n = s.asn1.fromDer(r);
|
|
9
9
|
return s.pki.publicKeyFromAsn1(n);
|
|
10
|
-
}, i = (t) => typeof t == "bigint" || typeof t == "number" ? t.toString() : t, y = (t) => s.util.hexToBytes(t.replace("0x", "")),
|
|
10
|
+
}, i = (t) => typeof t == "bigint" || typeof t == "number" ? t.toString() : t, y = (t) => s.util.hexToBytes(t.replace("0x", "")), l = (t) => {
|
|
11
11
|
const e = structuredClone(t);
|
|
12
12
|
return Object.entries(e).forEach(([r, n]) => {
|
|
13
13
|
e[r] = i(n), Array.isArray(n) && (Array.isArray(n[0]) ? e[r] = n.map((o) => o.map(i)) : e[r] = n.map(i));
|
|
14
14
|
}), e;
|
|
15
15
|
}, E = (t, e) => {
|
|
16
|
-
const r = a.
|
|
17
|
-
if (n.length >
|
|
16
|
+
const r = a.hexlify(e).slice(2), n = y(r);
|
|
17
|
+
if (n.length > f)
|
|
18
18
|
throw new Error("too many bytes passed to assymetric_encrypt");
|
|
19
19
|
const o = t.encrypt(n, "RSA-OAEP", {
|
|
20
20
|
md: s.md.sha1.create(),
|
|
@@ -23,13 +23,13 @@ const l = 214, p = async () => {
|
|
|
23
23
|
});
|
|
24
24
|
return s.util.encode64(o);
|
|
25
25
|
}, b = (t, e) => {
|
|
26
|
-
const r = c.randombytes_buf(c.crypto_secretbox_NONCEBYTES), n = c.crypto_secretbox_easy(e, r, t), o = a.
|
|
27
|
-
return s.util.encode64(
|
|
26
|
+
const r = c.randombytes_buf(c.crypto_secretbox_NONCEBYTES), n = c.crypto_secretbox_easy(e, r, t), o = a.hexlify(r) + a.hexlify(n).slice(2), d = y(o);
|
|
27
|
+
return s.util.encode64(d);
|
|
28
28
|
}, m = (t, e) => {
|
|
29
29
|
const r = c.randombytes_buf(c.crypto_secretbox_KEYBYTES), n = E(e, r), o = b(r, t);
|
|
30
30
|
return { keyCiphertext: n, inputCiphertext: o };
|
|
31
31
|
}, x = (t, e) => {
|
|
32
|
-
const r =
|
|
32
|
+
const r = l(t), n = JSON.stringify(r), o = new TextEncoder().encode(n);
|
|
33
33
|
return m(o, e);
|
|
34
34
|
}, g = async (t) => {
|
|
35
35
|
const e = await p();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ethers as ethersV6 } from 'ethers
|
|
1
|
+
import { ethers as ethersV6 } from 'ethers';
|
|
2
2
|
import { RelayerTransaction } from '../../types/relayer.types';
|
|
3
3
|
import { Connection } from '@solana/web3.js';
|
|
4
4
|
export declare const convertV6ReceiptToRelayer: (v6Receipt: ethersV6.TransactionReceipt) => RelayerTransaction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("ethers"),i=require("../../constants/protocol.constants.cjs"),e=require("../../types/external-action.types.cjs"),n=t=>t===0n?0n:BigInt(o.ethers.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("ethers"),i=require("../../constants/protocol.constants.cjs"),e=require("../../types/external-action.types.cjs"),n=t=>t===0n?0n:BigInt(o.ethers.id(t))%i.CIRCOM_P,c=t=>BigInt(t)===0n?e.ExternalActionId.Transact:Object.values(e.ExternalActionId).find(r=>BigInt(t)===n(r));exports.getExternalActionIdFromNumber=c;exports.getExternalActionIdHash=n;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ethers as i } from "ethers";
|
|
2
2
|
import { CIRCOM_P as o } from "../../constants/protocol.constants.mjs";
|
|
3
3
|
import { ExternalActionId as r } from "../../types/external-action.types.mjs";
|
|
4
|
-
const e = (t) => t === 0n ? 0n : BigInt(i.
|
|
4
|
+
const e = (t) => t === 0n ? 0n : BigInt(i.id(t)) % o, a = (t) => BigInt(t) === 0n ? r.Transact : Object.values(r).find(
|
|
5
5
|
(n) => BigInt(t) === e(n)
|
|
6
6
|
);
|
|
7
7
|
export {
|
|
8
|
-
|
|
8
|
+
a as getExternalActionIdFromNumber,
|
|
9
9
|
e as getExternalActionIdHash
|
|
10
10
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=r=>{const{target:t}=r;if(typeof t!="string")throw new Error("ENS contract addresses not supported");return t};exports.getContractAddress=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=t=>({...t,utxosArray:t.utxosArray?.map(s=>({...s,amount:BigInt(s.amount)})),decodedInput:{...t.decodedInput,amountChanges:t.decodedInput.amountChanges.map(BigInt),flatFees:t.decodedInput.flatFees.map(BigInt),externalActionId:BigInt(t.decodedInput.externalActionId),stealthAddressStructure:{...t.decodedInput.stealthAddressStructure,extraRandomization:BigInt(t.decodedInput.stealthAddressStructure.extraRandomization),stealthAddress:BigInt(t.decodedInput.stealthAddressStructure.stealthAddress),H0:BigInt(t.decodedInput.stealthAddressStructure.H0),H1:BigInt(t.decodedInput.stealthAddressStructure.H1)}}}),d=t=>t.map(n=>{const{decodedInput:e}=n;return{...n,input:"",decodedInput:{...e,amountChanges:e.amountChanges.map(r=>r.toString()),flatFees:e.flatFees.map(r=>r.toString()),externalActionId:e.externalActionId.toString(),stealthAddressStructure:{...e.stealthAddressStructure,extraRandomization:String(e.stealthAddressStructure.extraRandomization),stealthAddress:String(e.stealthAddressStructure.stealthAddress),H0:String(e.stealthAddressStructure.H0),H1:String(e.stealthAddressStructure.H1)}}}});exports.deserializeDecodedTxs=a;exports.serializeDecodedTxs=d;
|
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
import { BigNumber, utils } from 'ethers';
|
|
2
1
|
import { DecodedTx, DecodedTxWithUtxos } from '../../types';
|
|
3
|
-
export declare const decodeTxInput: (iface: utils.Interface, input: string) => {
|
|
4
|
-
erc20TokenAddresses: string[];
|
|
5
|
-
amountChanges: BigNumber[];
|
|
6
|
-
flatFees: BigNumber[];
|
|
7
|
-
externalActionId: BigNumber;
|
|
8
|
-
externalActionMetadata: string;
|
|
9
|
-
encryptedOutputs: string[];
|
|
10
|
-
hookData: import('../../types/circom-data.types').HookDataType;
|
|
11
|
-
stealthAddressStructure: import('../../types/circom-data.types').StealthAddressStructure<bigint>;
|
|
12
|
-
};
|
|
13
2
|
export declare const deserializeDecodedTxs: (decodedTx: DecodedTxWithUtxos<string, string>) => DecodedTxWithUtxos;
|
|
14
3
|
export declare const serializeDecodedTxs: (decodedTxs: DecodedTx[]) => {
|
|
15
4
|
input: string;
|