@hinkal/common 0.2.22 → 0.2.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API/proxyAccountsCalls.cjs +1 -1
- package/API/proxyAccountsCalls.mjs +13 -13
- package/README.md +63 -267
- package/constants/activity.constants.cjs +1 -1
- package/constants/activity.constants.mjs +0 -1
- package/constants/addresses.constants.cjs +1 -1
- package/constants/addresses.constants.mjs +9 -10
- package/constants/contracts.constants.cjs +1 -1
- package/constants/contracts.constants.d.ts +3 -3
- package/constants/contracts.constants.mjs +29 -29
- package/constants/server.constants.cjs +1 -1
- package/constants/server.constants.mjs +28 -29
- package/constants/tasks.constants.cjs +1 -1
- package/constants/tasks.constants.mjs +4 -5
- package/crypto/poseidon.cjs +1 -1
- package/crypto/poseidon.mjs +10 -10
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.cjs +1 -1
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.mjs +24 -24
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.mjs +4 -5
- package/data-structures/Hinkal/IHinkal.d.ts +2 -2
- package/data-structures/Hinkal/hinkalApprove.cjs +1 -1
- package/data-structures/Hinkal/hinkalApprove.mjs +40 -40
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -1
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +7 -8
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +4 -5
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +2 -3
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +18 -19
- package/data-structures/Hinkal/hinkalDepostAndBridge.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepostAndBridge.mjs +3 -4
- package/data-structures/Hinkal/hinkalInsideTransact.cjs +1 -1
- package/data-structures/Hinkal/hinkalInsideTransact.mjs +14 -13
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +2 -3
- package/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalProoflessDeposit.mjs +27 -26
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +38 -39
- package/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaSwap.mjs +16 -17
- package/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaTransfer.mjs +24 -25
- package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +15 -16
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +2 -3
- package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalTransfer.mjs +2 -3
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +9 -10
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +8 -9
- package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.mjs +10 -10
- package/data-structures/IndexedDB/activity-db.cjs +1 -1
- package/data-structures/IndexedDB/activity-db.mjs +39 -41
- package/data-structures/IndexedDB/balances-db.cjs +1 -1
- package/data-structures/IndexedDB/balances-db.mjs +8 -9
- package/data-structures/IndexedDB/contact-db.cjs +1 -1
- package/data-structures/IndexedDB/contact-db.mjs +21 -23
- package/data-structures/IndexedDB/signatures-db.cjs +1 -1
- package/data-structures/IndexedDB/signatures-db.mjs +2 -3
- package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +34 -36
- package/data-structures/crypto-keys/decodeUTXO.cjs +1 -1
- package/data-structures/crypto-keys/decodeUTXO.mjs +45 -45
- package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
- package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +28 -27
- package/data-structures/crypto-keys/keys.cjs +1 -1
- package/data-structures/crypto-keys/keys.d.ts +2 -3
- package/data-structures/crypto-keys/keys.mjs +56 -57
- package/data-structures/event-service/evm/AbstractEventService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractEventService.mjs +14 -14
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.d.ts +2 -3
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.mjs +5 -4
- package/data-structures/event-service/evm/AbstractSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractSnapshotService.mjs +6 -3
- package/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.d.ts +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.mjs +22 -18
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.mjs +2 -2
- package/data-structures/presale/PresaleContractWrapper.cjs +1 -1
- package/data-structures/presale/PresaleContractWrapper.d.ts +3 -3
- package/data-structures/presale/PresaleContractWrapper.mjs +10 -10
- package/data-structures/provider-adapter/IProviderAdapter.d.ts +7 -7
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.mjs +16 -14
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +7 -5
- package/error-handling/get-error.message.cjs +1 -1
- package/error-handling/get-error.message.mjs +2 -3
- package/functions/kyc/zkMeHelper.cjs +1 -1
- package/functions/kyc/zkMeHelper.mjs +3 -3
- package/functions/pre-transaction/getFlatFees.cjs +1 -1
- package/functions/pre-transaction/getFlatFees.mjs +2 -3
- package/functions/pre-transaction/getSolanaCalldataHash.cjs +1 -1
- package/functions/pre-transaction/getSolanaCalldataHash.mjs +21 -21
- package/functions/pre-transaction/getVolatileTransferAmount.cjs +1 -1
- package/functions/pre-transaction/getVolatileTransferAmount.mjs +2 -3
- package/functions/pre-transaction/interaction-to-action.cjs +1 -1
- package/functions/pre-transaction/interaction-to-action.mjs +2 -3
- package/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.helpers.d.ts +6 -7
- package/functions/private-wallet/emporium.helpers.mjs +104 -105
- package/functions/private-wallet/emporium.swap.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.swap.helpers.mjs +44 -43
- package/functions/private-wallet/opProducer.cjs +1 -1
- package/functions/private-wallet/opProducer.mjs +1 -1
- package/functions/snarkjs/common.snarkjs.cjs +1 -1
- package/functions/snarkjs/common.snarkjs.mjs +21 -18
- package/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/functions/snarkjs/constructSolanaZkProof.mjs +11 -12
- package/functions/utils/addresses.cjs +1 -1
- package/functions/utils/addresses.mjs +6 -6
- package/functions/utils/cacheFunctions.cjs +1 -1
- package/functions/utils/cacheFunctions.d.ts +1 -1
- package/functions/utils/cacheFunctions.mjs +55 -54
- package/functions/utils/convertEmporiumOpToCallInfo.cjs +1 -1
- package/functions/utils/convertEmporiumOpToCallInfo.mjs +5 -5
- package/functions/utils/create-provider.cjs +1 -1
- package/functions/utils/create-provider.d.ts +2 -2
- package/functions/utils/create-provider.mjs +5 -5
- package/functions/utils/encryptInputForEnclave.cjs +1 -1
- package/functions/utils/encryptInputForEnclave.mjs +9 -9
- package/functions/utils/ethers-formatter.utils.d.ts +1 -1
- package/functions/utils/external-action.utils.cjs +1 -1
- package/functions/utils/external-action.utils.mjs +2 -2
- package/functions/utils/getContractAddress.cjs +1 -0
- package/functions/utils/getContractAddress.d.ts +2 -0
- package/functions/utils/getContractAddress.mjs +9 -0
- package/functions/utils/getDataFromTransaction.cjs +1 -1
- package/functions/utils/getDataFromTransaction.d.ts +0 -11
- package/functions/utils/getDataFromTransaction.mjs +26 -50
- package/functions/utils/getRecipientInfoFromUserKeys.cjs +1 -1
- package/functions/utils/getRecipientInfoFromUserKeys.mjs +1 -1
- package/functions/utils/getSignerFromContract.cjs +1 -0
- package/functions/utils/getSignerFromContract.d.ts +3 -0
- package/functions/utils/getSignerFromContract.mjs +16 -0
- package/functions/utils/getUtxosFromReceipt.utils.cjs +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.d.ts +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.mjs +15 -16
- package/functions/utils/inLogicMetadata.cjs +1 -1
- package/functions/utils/inLogicMetadata.mjs +2 -2
- package/functions/utils/nftTokenFunctions.cjs +1 -1
- package/functions/utils/nftTokenFunctions.mjs +2 -3
- package/functions/utils/publicBalance.utils.cjs +1 -1
- package/functions/utils/publicBalance.utils.d.ts +1 -1
- package/functions/utils/publicBalance.utils.mjs +42 -42
- package/functions/utils/rpc-int-encode.cjs +1 -1
- package/functions/utils/rpc-int-encode.d.ts +1 -2
- package/functions/utils/rpc-int-encode.mjs +3 -6
- package/functions/utils/solanaMint.utils.cjs +1 -1
- package/functions/utils/solanaMint.utils.mjs +6 -6
- package/functions/web3/EIP-712.cjs +1 -1
- package/functions/web3/EIP-712.d.ts +4 -4
- package/functions/web3/EIP-712.mjs +1 -1
- package/functions/web3/etherFunctions.cjs +1 -1
- package/functions/web3/etherFunctions.mjs +32 -29
- package/functions/web3/events/balanceChangedCustomHandler.cjs +1 -1
- package/functions/web3/events/balanceChangedCustomHandler.mjs +4 -5
- package/functions/web3/events/balanceChangedHandler.cjs +1 -1
- package/functions/web3/events/balanceChangedHandler.mjs +2 -3
- package/functions/web3/events/getApprovedBalance.cjs +1 -1
- package/functions/web3/events/getApprovedBalance.mjs +1 -1
- package/functions/web3/events/getInputUtxosEnclave.cjs +1 -1
- package/functions/web3/events/getInputUtxosEnclave.mjs +20 -20
- package/functions/web3/events/getTransactionLogEvents.cjs +1 -1
- package/functions/web3/events/getTransactionLogEvents.d.ts +3 -3
- package/functions/web3/events/getTransactionLogEvents.mjs +6 -5
- package/functions/web3/events/index.d.ts +0 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.d.ts +1 -2
- package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +4 -5
- package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
- package/functions/web3/functionCalls/accessTokenCalls.mjs +10 -11
- package/functions/web3/functionCalls/approveToken.cjs +1 -1
- package/functions/web3/functionCalls/approveToken.mjs +61 -58
- package/functions/web3/functionCalls/constructBatchCall.cjs +1 -1
- package/functions/web3/functionCalls/constructBatchCall.d.ts +2 -2
- package/functions/web3/functionCalls/constructBatchCall.mjs +10 -9
- package/functions/web3/functionCalls/estimateGasRelayer.cjs +1 -1
- package/functions/web3/functionCalls/estimateGasRelayer.mjs +1 -1
- package/functions/web3/functionCalls/inHinkalApprovalCalls.cjs +1 -1
- package/functions/web3/functionCalls/inHinkalApprovalCalls.mjs +18 -21
- package/functions/web3/functionCalls/recoverTransactionFromError.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +38 -34
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.mjs +8 -10
- package/functions/web3/getContractMetadata.cjs +1 -1
- package/functions/web3/getContractMetadata.d.ts +1 -1
- package/functions/web3/getContractMetadata.mjs +25 -25
- package/functions/web3/getPublicAddressBalance.cjs +1 -1
- package/functions/web3/getPublicAddressBalance.mjs +7 -6
- package/functions/web3/getTokenHolder.cjs +1 -1
- package/functions/web3/getTokenHolder.mjs +16 -15
- package/functions/web3/odosAPI.cjs +1 -1
- package/functions/web3/odosAPI.mjs +6 -7
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.mjs +2 -3
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.d.ts +6 -5
- package/functions/web3/runContractFunction.mjs +41 -45
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.d.ts +2 -2
- package/functions/web3/uniswapAPI.mjs +23 -24
- package/index.cjs +1 -1
- package/index.mjs +336 -340
- package/package.json +3 -4
- package/providers/CustomEthersProvider.d.ts +1 -1
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.d.ts +7 -7
- package/providers/EthersProviderAdapter.mjs +46 -44
- package/providers/SolanaProviderAdapter.d.ts +1 -1
- package/providers/WagmiProviderAdapter.cjs +1 -1
- package/providers/WagmiProviderAdapter.d.ts +5 -5
- package/providers/WagmiProviderAdapter.mjs +37 -33
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.d.ts +2 -2
- package/providers/prepareEthersHinkal.mjs +3 -5
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +3 -5
- package/types/activities.types.d.ts +2 -3
- package/types/big-intable.types.d.ts +3 -2
- package/types/ethereum-network.types.d.ts +10 -10
- package/types/transactions.types.cjs +1 -1
- package/types/transactions.types.d.ts +2 -3
- package/types/transactions.types.mjs +6 -7
- package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLogic.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLogic.mjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
- package/functions/web3/events/web3RetrieveEvents.cjs +0 -1
- package/functions/web3/events/web3RetrieveEvents.d.ts +0 -14
- package/functions/web3/events/web3RetrieveEvents.mjs +0 -9
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { utils as p, BigNumber as w, ethers as C } from "ethers";
|
|
2
1
|
import { zeroAddress as u } from "../../constants/protocol.constants.mjs";
|
|
3
|
-
import { ContractType as
|
|
2
|
+
import { ContractType as g } from "../../types/ethereum-network.types.mjs";
|
|
4
3
|
import "idb-keyval";
|
|
5
|
-
import { networkRegistry as A, chainIds as
|
|
6
|
-
import {
|
|
4
|
+
import { networkRegistry as A, chainIds as w } from "../../constants/chains.constants.mjs";
|
|
5
|
+
import { getContractAddress as v } from "../utils/getContractAddress.mjs";
|
|
6
|
+
import { createCustomRpcProvider as W } from "../utils/create-provider.mjs";
|
|
7
|
+
import { ethers as p } from "ethers";
|
|
7
8
|
import "../../constants/token-data/index.mjs";
|
|
8
9
|
import "../../error-handling/error-codes.constants.mjs";
|
|
9
10
|
import "../utils/convertIntegrationProviderToExternalActionId.mjs";
|
|
10
11
|
import "../../types/circom-data.types.mjs";
|
|
11
|
-
import "../../types/transactions.types.mjs";
|
|
12
12
|
import "../../types/activities.types.mjs";
|
|
13
13
|
import "circomlibjs-hinkal-fork";
|
|
14
14
|
import { UserKeys as y } from "../../data-structures/crypto-keys/keys.mjs";
|
|
@@ -16,7 +16,7 @@ import "../../constants/server.constants.mjs";
|
|
|
16
16
|
import "../../constants/vite.constants.mjs";
|
|
17
17
|
import "../../data-structures/http/HttpClient.mjs";
|
|
18
18
|
import "axios";
|
|
19
|
-
import { caseInsensitiveEqual as
|
|
19
|
+
import { caseInsensitiveEqual as l } from "../utils/caseInsensitive.utils.mjs";
|
|
20
20
|
import "../../API/getServerURL.mjs";
|
|
21
21
|
import "libsodium-wrappers";
|
|
22
22
|
import "process";
|
|
@@ -25,7 +25,7 @@ import "../../constants/save-depths.mjs";
|
|
|
25
25
|
import "../../constants/reorg-depths.constants.mjs";
|
|
26
26
|
import "../utils/mutexes.utils.mjs";
|
|
27
27
|
import "@coral-xyz/anchor";
|
|
28
|
-
import { Logger as
|
|
28
|
+
import { Logger as k } from "../../error-handling/logger.mjs";
|
|
29
29
|
import "@solana/web3.js";
|
|
30
30
|
import "@solana/spl-token";
|
|
31
31
|
import "../../constants/contracts.constants.mjs";
|
|
@@ -38,161 +38,160 @@ import "../../constants/activity.constants.mjs";
|
|
|
38
38
|
import "../../constants/tasks.constants.mjs";
|
|
39
39
|
import "../../constants/events.constants.mjs";
|
|
40
40
|
import "../utils/userAgent.mjs";
|
|
41
|
-
import { replaceAllInstances as
|
|
41
|
+
import { replaceAllInstances as B } from "../utils/string.utils.mjs";
|
|
42
42
|
import "multiformats";
|
|
43
43
|
import "../../API/tenderly.api.mjs";
|
|
44
|
-
import { replaceAddressesInCalldata as
|
|
45
|
-
|
|
46
|
-
const g = ({
|
|
44
|
+
import { replaceAddressesInCalldata as D } from "../utils/replaceAddressInCalldata.mjs";
|
|
45
|
+
const h = ({
|
|
47
46
|
contract: t,
|
|
48
|
-
func:
|
|
47
|
+
func: e,
|
|
49
48
|
args: o,
|
|
50
|
-
callDataString:
|
|
49
|
+
callDataString: r,
|
|
51
50
|
invokeWallet: i,
|
|
52
51
|
value: a
|
|
53
52
|
}) => {
|
|
54
|
-
let n = new Uint8Array(),
|
|
55
|
-
if (typeof t == "object"
|
|
56
|
-
if (n = p.
|
|
53
|
+
let n = new Uint8Array(), c = r ? p.getBytesCopy(r) : new Uint8Array();
|
|
54
|
+
if (typeof t == "object") {
|
|
55
|
+
if (n = p.getBytesCopy(v(t)), r?.length && r?.length > 0)
|
|
57
56
|
throw Error("If function and args are providedm no calldata is needed");
|
|
58
|
-
|
|
57
|
+
e && o && !r && (c = p.getBytesCopy(t.interface.encodeFunctionData(e, o)));
|
|
59
58
|
} else
|
|
60
|
-
n = p.
|
|
61
|
-
const
|
|
59
|
+
n = p.getBytesCopy(t);
|
|
60
|
+
const s = p.getBytesCopy(new Uint8Array([i ? 1 : 0])), m = p.zeroPadValue(p.toBeHex(a ?? 0n), 16), d = p.concat([n, s, m, c]);
|
|
62
61
|
return p.hexlify(d);
|
|
63
|
-
},
|
|
62
|
+
}, wt = async (t, e, o, r, i, a) => {
|
|
64
63
|
const n = o ? await y.signTypedDataFromPrivateKey(
|
|
65
64
|
t,
|
|
66
65
|
o,
|
|
67
|
-
{ name: "Emporium", version: "1.0.0", chainId: t, verifyingContract:
|
|
66
|
+
{ name: "Emporium", version: "1.0.0", chainId: t, verifyingContract: e },
|
|
68
67
|
{ EmporiumSignature: [{ name: "message", type: "uint256" }] },
|
|
69
68
|
{ message: i }
|
|
70
|
-
) : void 0, { v:
|
|
71
|
-
return p.defaultAbiCoder.encode(
|
|
69
|
+
) : void 0, { v: c, r: s, s: m } = n ? p.Signature.from(n) : { v: 0, r: p.ZeroHash, s: p.ZeroHash };
|
|
70
|
+
return p.AbiCoder.defaultAbiCoder().encode(
|
|
72
71
|
["tuple(uint8 v,bytes32 r, bytes32 s, uint256 message, address signerAddress, bytes[] ops)"],
|
|
73
72
|
[
|
|
74
73
|
{
|
|
75
|
-
v:
|
|
76
|
-
r:
|
|
74
|
+
v: c,
|
|
75
|
+
r: s,
|
|
77
76
|
s: m,
|
|
78
77
|
message: i ?? 0n,
|
|
79
78
|
signerAddress: a ?? u,
|
|
80
|
-
ops:
|
|
79
|
+
ops: r
|
|
81
80
|
}
|
|
82
81
|
]
|
|
83
82
|
);
|
|
84
|
-
}, E = (t,
|
|
83
|
+
}, E = (t, e, o, r) => h(t ? {
|
|
85
84
|
contract: t,
|
|
86
85
|
func: "transfer",
|
|
87
|
-
args: [
|
|
88
|
-
invokeWallet:
|
|
89
|
-
} : { contract:
|
|
90
|
-
const i = t.getContractWithFetcher(
|
|
91
|
-
return
|
|
92
|
-
const s =
|
|
93
|
-
return E(s,
|
|
86
|
+
args: [e, o],
|
|
87
|
+
invokeWallet: r
|
|
88
|
+
} : { contract: e, value: o, invokeWallet: r }), Wt = (t, e, o, r) => {
|
|
89
|
+
const i = t.getContractWithFetcher(g.HinkalContract), a = v(i);
|
|
90
|
+
return e.map((n, c) => {
|
|
91
|
+
const s = l(n, u) ? void 0 : t.getContractWithFetcher(g.ERC20Contract, n);
|
|
92
|
+
return E(s, r ?? a, o[c], !0);
|
|
94
93
|
});
|
|
95
|
-
},
|
|
94
|
+
}, O = (t, e, o, r) => h({
|
|
96
95
|
contract: t,
|
|
97
96
|
func: "approve",
|
|
98
|
-
args: [
|
|
99
|
-
invokeWallet:
|
|
100
|
-
}),
|
|
101
|
-
const
|
|
102
|
-
if (!e)
|
|
103
|
-
throw Error("No Hinkal Address Provided to modifyDataForProxy");
|
|
104
|
-
return O(o, e.slice(2), r.slice(2));
|
|
105
|
-
}, Pt = (t, r, o) => {
|
|
97
|
+
args: [e, o],
|
|
98
|
+
invokeWallet: r
|
|
99
|
+
}), P = (t, e, o) => {
|
|
100
|
+
const r = t.getSelectedNetwork()?.contractData.hinkalAddress;
|
|
106
101
|
if (!r)
|
|
102
|
+
throw Error("No Hinkal Address Provided to modifyDataForProxy");
|
|
103
|
+
return B(o, r.slice(2), e.slice(2));
|
|
104
|
+
}, kt = (t, e, o) => {
|
|
105
|
+
if (!e)
|
|
107
106
|
throw Error("No private key provided to modifyDataForProxy");
|
|
108
|
-
const
|
|
109
|
-
return
|
|
110
|
-
}, F = (t,
|
|
111
|
-
const
|
|
112
|
-
for (let
|
|
113
|
-
const m =
|
|
114
|
-
|
|
107
|
+
const r = y.getSignerAddressFromPrivateKey(t.getCurrentChainId(), e);
|
|
108
|
+
return P(t, r, o);
|
|
109
|
+
}, F = (t, e, o, r, i, a, n) => {
|
|
110
|
+
const c = [];
|
|
111
|
+
for (let s = 0; s < e.length; s += 1) {
|
|
112
|
+
const m = e[s], d = l(m, u) ? void 0 : t.getContractWithFetcher(g.ERC20Contract, m);
|
|
113
|
+
c.push(E(d, a, o[s], !1));
|
|
115
114
|
}
|
|
116
115
|
if (n)
|
|
117
|
-
for (let
|
|
118
|
-
const m =
|
|
119
|
-
if (!
|
|
120
|
-
const d = t.getContractWithFetcher(
|
|
121
|
-
|
|
116
|
+
for (let s = 0; s < r.length; s += 1) {
|
|
117
|
+
const m = r[s];
|
|
118
|
+
if (!l(m, u)) {
|
|
119
|
+
const d = t.getContractWithFetcher(g.ERC20Contract, m);
|
|
120
|
+
c.push(O(d, n, i[s], !0));
|
|
122
121
|
}
|
|
123
122
|
}
|
|
124
|
-
return
|
|
125
|
-
},
|
|
123
|
+
return c;
|
|
124
|
+
}, Bt = (t, e, o, r, i, a, n, c, s, m) => {
|
|
126
125
|
const d = F(
|
|
127
126
|
t,
|
|
128
|
-
r,
|
|
129
|
-
o,
|
|
130
127
|
e,
|
|
128
|
+
o,
|
|
129
|
+
r,
|
|
131
130
|
i,
|
|
132
131
|
a,
|
|
133
132
|
n
|
|
134
133
|
);
|
|
135
|
-
if (!!
|
|
136
|
-
const
|
|
134
|
+
if (!!c && !!s) {
|
|
135
|
+
const f = t.getContractWithFetcher(g.HinkalContract);
|
|
137
136
|
d.push(
|
|
138
|
-
|
|
139
|
-
contract:
|
|
140
|
-
callDataString:
|
|
137
|
+
h({
|
|
138
|
+
contract: c,
|
|
139
|
+
callDataString: D(s, v(f), a),
|
|
141
140
|
value: m,
|
|
142
141
|
invokeWallet: !0
|
|
143
142
|
})
|
|
144
143
|
);
|
|
145
144
|
}
|
|
146
145
|
return d;
|
|
147
|
-
},
|
|
148
|
-
const
|
|
149
|
-
n.nativeFee > 0n && !
|
|
150
|
-
const
|
|
146
|
+
}, Dt = (t, e, o, r, i, a, n) => {
|
|
147
|
+
const c = [], s = [r], m = [i];
|
|
148
|
+
n.nativeFee > 0n && !l(r, u) && (s.push(u), m.push(n.nativeFee));
|
|
149
|
+
const C = F(
|
|
151
150
|
t,
|
|
152
|
-
|
|
151
|
+
s,
|
|
153
152
|
m,
|
|
154
|
-
[
|
|
153
|
+
[r],
|
|
155
154
|
[a],
|
|
156
|
-
|
|
155
|
+
e,
|
|
157
156
|
o
|
|
158
157
|
);
|
|
159
|
-
|
|
160
|
-
let
|
|
161
|
-
return
|
|
162
|
-
|
|
158
|
+
c.push(...C);
|
|
159
|
+
let f = n.nativeFee;
|
|
160
|
+
return l(r, u) && (f += a), c.push(
|
|
161
|
+
h({
|
|
163
162
|
contract: o,
|
|
164
163
|
callDataString: n.calldata,
|
|
165
|
-
value:
|
|
164
|
+
value: f > 0n ? f : void 0,
|
|
166
165
|
invokeWallet: !0
|
|
167
166
|
})
|
|
168
|
-
),
|
|
169
|
-
},
|
|
167
|
+
), c;
|
|
168
|
+
}, I = "0xef0100", x = async (t, e) => {
|
|
170
169
|
try {
|
|
171
170
|
const { fetchRpcUrl: o } = A[t];
|
|
172
171
|
if (!o)
|
|
173
172
|
throw new Error("RPC URL not found for the specified chain ID");
|
|
174
|
-
const
|
|
173
|
+
const r = W(o), i = await r.getCode(e);
|
|
175
174
|
if (i === "0x" || !i)
|
|
176
175
|
return { delegated: !1, implementation: void 0, nonce: void 0 };
|
|
177
|
-
if (i.toLowerCase().startsWith(
|
|
178
|
-
const a = `0x${i.slice(8)}`, n = await
|
|
176
|
+
if (i.toLowerCase().startsWith(I) && i.length === 48) {
|
|
177
|
+
const a = `0x${i.slice(8)}`, n = await r.getTransactionCount(e);
|
|
179
178
|
return { delegated: !0, implementation: p.getAddress(a), nonce: n };
|
|
180
179
|
} else
|
|
181
180
|
throw Error("checkEOAWithDelegation: It is a contract");
|
|
182
181
|
} catch (o) {
|
|
183
|
-
throw
|
|
182
|
+
throw k.error("checkEOAWithDelegation error", { error: o }), o;
|
|
184
183
|
}
|
|
185
|
-
},
|
|
186
|
-
const { hinkalWalletAddress:
|
|
187
|
-
if (!
|
|
184
|
+
}, H = (t) => {
|
|
185
|
+
const { hinkalWalletAddress: e } = A[t].contractData;
|
|
186
|
+
if (!e || l(e, u))
|
|
188
187
|
throw Error("Hinkal Wallet Address is not set");
|
|
189
|
-
return
|
|
190
|
-
},
|
|
191
|
-
if (t ===
|
|
188
|
+
return e;
|
|
189
|
+
}, Ot = async (t, e) => {
|
|
190
|
+
if (t === w.localhost || !e)
|
|
192
191
|
return;
|
|
193
|
-
const o = y.getSignerAddressFromPrivateKey(t,
|
|
194
|
-
if (!
|
|
195
|
-
const n = await y.authorizeDelegation(t,
|
|
192
|
+
const o = y.getSignerAddressFromPrivateKey(t, e), { delegated: r, implementation: i } = await x(t, o), a = H(t);
|
|
193
|
+
if (!r || !l(i, a)) {
|
|
194
|
+
const n = await y.authorizeDelegation(t, e, a);
|
|
196
195
|
return {
|
|
197
196
|
v: n.signature.v.toString(),
|
|
198
197
|
r: n.signature.r,
|
|
@@ -202,24 +201,24 @@ const g = ({
|
|
|
202
201
|
chainId: String(t)
|
|
203
202
|
};
|
|
204
203
|
}
|
|
205
|
-
},
|
|
204
|
+
}, Pt = (t) => {
|
|
206
205
|
if (!t)
|
|
207
206
|
return;
|
|
208
|
-
const { v:
|
|
209
|
-
return { signature:
|
|
207
|
+
const { v: e, r: o, s: r, nonce: i, chainId: a, address: n } = t;
|
|
208
|
+
return { signature: p.Signature.from({ v: e, r: o, s: r }), nonce: BigInt(i), chainId: BigInt(a), address: n };
|
|
210
209
|
};
|
|
211
210
|
export {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
211
|
+
x as checkEOAWithDelegation,
|
|
212
|
+
O as createApproveEmporiumOp,
|
|
213
|
+
Dt as createLifiBridgeOps,
|
|
214
|
+
Wt as createTransaferEmporiumOpsBatch,
|
|
216
215
|
E as createTransferToEmporiumOp,
|
|
217
|
-
|
|
218
|
-
|
|
216
|
+
h as emporiumOp,
|
|
217
|
+
wt as encodeEmporiumMetadata,
|
|
219
218
|
F as generateFundAndApproveOps,
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
219
|
+
Bt as generateFundApproveAndTransactOps,
|
|
220
|
+
Ot as getAuthorizationDataIfNeeded,
|
|
221
|
+
P as modifyDataForProxy,
|
|
222
|
+
kt as modifyDataForProxyWithPrivateKey,
|
|
223
|
+
Pt as recoverAuthorizationData
|
|
225
224
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("ethers"),E=require("./emporium.helpers.cjs"),_=require("../../constants/addresses.constants.cjs"),I=require("../../types/external-action.types.cjs"),h=require("../../types/ethereum-network.types.cjs"),x=require("../pre-transaction/getExternalSwapAddress.cjs"),B=require("../utils/string.utils.cjs"),C=require("../../constants/protocol.constants.cjs");require("../../constants/token-data/index.cjs");const N=require("../utils/caseInsensitive.utils.cjs"),U=require("../../error-handling/logger.cjs"),L=require("../utils/getContractAddress.cjs"),v=require("../../constants/token-data/ERC20Registry.cjs"),A=(e,n,c,a,t,s,o=!1)=>{const r=BigInt(s),m={tokenIn:n,tokenOut:a,fee:r,recipient:t,amountIn:c,amountOutMinimum:0,sqrtPriceLimitX96:0},f=["function exactInputSingle(tuple(address tokenIn,address tokenOut,uint24 fee,address recipient,uint256 amountIn,uint256 amountOutMinimum,uint160 sqrtPriceLimitX96)) external payable returns (uint256 amountOut)"],g=new F.ethers.Contract(e,f);return E.emporiumOp({contract:g,func:"exactInputSingle",args:[m],invokeWallet:o})},l=(e,n,c,a,t,s,o=!1)=>{const r=x.getExternalSwapAddress(e,n),m=B.replaceAllInstances(a,r.slice(2),t.slice(2));return E.emporiumOp({contract:c,callDataString:m,value:s,invokeWallet:o})},z=(e,n)=>{const a=v.getERC20Registry(n).find(t=>t.symbol==="USDT");return a?N.caseInsensitiveEqual(e,a.erc20TokenAddress):!1},q=async(e,n,c,a,t,s)=>{const o=L.getContractAddress(c);if(z(o,e.getCurrentChainId()))try{await c.allowance(a,t)>0n&&n.push(E.createApproveEmporiumOp(c,t,0n,s))}catch(r){U.Logger.error("Error in nullifyUsdtApprovalIfNeeded",r)}},T=async(e,n,c,a,t,s,o)=>{if(n!==C.zeroAddress){const r=_.SWAP_FEE_TAKER_ADDRESSES[e.getCurrentChainId()],m=e.getContractWithFetcher(h.ContractType.ERC20Contract,n),f=await m.balanceOf(c);await q(e,t,m,c,r,s),t.push(E.createApproveEmporiumOp(m,r,2n**256n-1n,s));const g=["function takeSwapFee(address token, uint256 beforeBalance, uint256 variableRate, address relay) external payable"],i=new F.ethers.Contract(r,g),w=a;t.push(E.emporiumOp({contract:i,func:"takeSwapFee",args:[n,f,C.HINKAL_SWAP_VARIABLE_RATE,w],invokeWallet:s}))}else{const r=a;t.push(E.emporiumOp({contract:r,value:o*C.HINKAL_SWAP_VARIABLE_RATE/10000n,invokeWallet:s}))}},K=async(e,n,c,a,t,s,o,r,m,f,g,i=!1)=>{const w=s<0n?-1n*s:s,b=e.getCurrentChainId(),u=[],O=_.NATIVE_TOKEN_WRAPPER_ADDRESSES[b];let d=!1,S;if(n===I.ExternalActionId.OneInch||n===I.ExternalActionId.Lifi){if(t!==C.zeroAddress){const y=e.getContractWithFetcher(h.ContractType.ERC20Contract,t);u.push(E.createApproveEmporiumOp(y,c,w,i))}let p=0n;t===C.zeroAddress&&(p+=w),o&&r===C.zeroAddress&&o<0n&&(p+=-1n*o);const R=p>0n?p:void 0;return S=l(e,n,c,a,f,R,i),u.push(S),(n===I.ExternalActionId.OneInch||m&&n===I.ExternalActionId.Lifi)&&r&&o!==void 0&&await T(e,r,f,g,u,i,o),u}if(!r||!o)throw Error("There should be output token for UniSwap and Odos");if(t===C.zeroAddress){const p=e.getContractWithFetcher(h.ContractType.ERC20Contract,O);u.push(E.emporiumOp({contract:p,func:"deposit",value:w,invokeWallet:i})),t=O}let D=0n;if(r===C.zeroAddress&&(r=O,d=!0,D=await e.getContractWithFetcher(h.ContractType.ERC20Contract,O).balanceOf(f)),t!==C.zeroAddress){const p=e.getContractWithFetcher(h.ContractType.ERC20Contract,t);await q(e,u,p,f,c,i),u.push(E.createApproveEmporiumOp(p,c,w,i))}if(n===I.ExternalActionId.Uniswap?S=A(c,t,w,r,f,a,i):S=l(e,n,c,a,f,void 0,i),u.push(S),await T(e,r,f,g,u,i,o),d){const p=_.WRAPPER_TOKEN_EXCHANGE_ADDRESSES[b],R=e.getContractWithFetcher(h.ContractType.ERC20Contract,O);u.push(E.createApproveEmporiumOp(R,p,2n**256n-1n,i));const y=["function withdrawBalanceDifference(uint256 beforeBalance) external"],P=new F.ethers.Contract(p,y);u.push(E.emporiumOp({contract:P,func:"withdrawBalanceDifference",args:[D],invokeWallet:i}))}return u};exports.createSwapToEmporiumOpForUniswap=A;exports.createSwapToEmporiumOpFromData=l;exports.createSwapToEmporiumOps=K;exports.nullifyUsdtApprovalIfNeeded=q;
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ethers as D } from "ethers";
|
|
2
2
|
import { emporiumOp as u, createApproveEmporiumOp as I } from "./emporium.helpers.mjs";
|
|
3
|
-
import { NATIVE_TOKEN_WRAPPER_ADDRESSES as
|
|
3
|
+
import { NATIVE_TOKEN_WRAPPER_ADDRESSES as K, WRAPPER_TOKEN_EXCHANGE_ADDRESSES as T, SWAP_FEE_TAKER_ADDRESSES as q } from "../../constants/addresses.constants.mjs";
|
|
4
4
|
import { ExternalActionId as O } from "../../types/external-action.types.mjs";
|
|
5
5
|
import { ContractType as g } from "../../types/ethereum-network.types.mjs";
|
|
6
|
-
import { getExternalSwapAddress as
|
|
7
|
-
import { replaceAllInstances as
|
|
6
|
+
import { getExternalSwapAddress as V } from "../pre-transaction/getExternalSwapAddress.mjs";
|
|
7
|
+
import { replaceAllInstances as X } from "../utils/string.utils.mjs";
|
|
8
8
|
import { zeroAddress as w, HINKAL_SWAP_VARIABLE_RATE as P } from "../../constants/protocol.constants.mjs";
|
|
9
9
|
import "../../constants/token-data/index.mjs";
|
|
10
|
-
import { caseInsensitiveEqual as
|
|
11
|
-
import { Logger as
|
|
10
|
+
import { caseInsensitiveEqual as H } from "../utils/caseInsensitive.utils.mjs";
|
|
11
|
+
import { Logger as M } from "../../error-handling/logger.mjs";
|
|
12
|
+
import { getContractAddress as l } from "../utils/getContractAddress.mjs";
|
|
12
13
|
import { getERC20Registry as v } from "../../constants/token-data/ERC20Registry.mjs";
|
|
13
|
-
const z = (t,
|
|
14
|
-
const r =
|
|
15
|
-
tokenIn:
|
|
14
|
+
const z = (t, c, a, e, n, i, o = !1) => {
|
|
15
|
+
const r = BigInt(i), C = {
|
|
16
|
+
tokenIn: c,
|
|
16
17
|
tokenOut: e,
|
|
17
18
|
fee: r,
|
|
18
19
|
recipient: n,
|
|
19
|
-
amountIn:
|
|
20
|
+
amountIn: a,
|
|
20
21
|
amountOutMinimum: 0,
|
|
21
22
|
sqrtPriceLimitX96: 0
|
|
22
23
|
}, m = [
|
|
@@ -28,33 +29,33 @@ const z = (t, a, c, e, n, i, o = !1) => {
|
|
|
28
29
|
args: [C],
|
|
29
30
|
invokeWallet: o
|
|
30
31
|
});
|
|
31
|
-
},
|
|
32
|
-
const r =
|
|
32
|
+
}, U = (t, c, a, e, n, i, o = !1) => {
|
|
33
|
+
const r = V(t, c), C = X(e, r.slice(2), n.slice(2));
|
|
33
34
|
return u({
|
|
34
|
-
contract:
|
|
35
|
+
contract: a,
|
|
35
36
|
callDataString: C,
|
|
36
37
|
value: i,
|
|
37
38
|
invokeWallet: o
|
|
38
39
|
});
|
|
39
|
-
}, G = (t,
|
|
40
|
-
const e = v(
|
|
41
|
-
return e ?
|
|
42
|
-
},
|
|
43
|
-
const o =
|
|
40
|
+
}, G = (t, c) => {
|
|
41
|
+
const e = v(c).find((n) => n.symbol === "USDT");
|
|
42
|
+
return e ? H(t, e.erc20TokenAddress) : !1;
|
|
43
|
+
}, N = async (t, c, a, e, n, i) => {
|
|
44
|
+
const o = l(a);
|
|
44
45
|
if (G(o, t.getCurrentChainId()))
|
|
45
46
|
try {
|
|
46
|
-
|
|
47
|
+
await a.allowance(e, n) > 0n && c.push(I(a, n, 0n, i));
|
|
47
48
|
} catch (r) {
|
|
48
|
-
|
|
49
|
+
M.error("Error in nullifyUsdtApprovalIfNeeded", r);
|
|
49
50
|
}
|
|
50
|
-
},
|
|
51
|
-
if (
|
|
52
|
-
const r =
|
|
53
|
-
await
|
|
51
|
+
}, L = async (t, c, a, e, n, i, o) => {
|
|
52
|
+
if (c !== w) {
|
|
53
|
+
const r = q[t.getCurrentChainId()], C = t.getContractWithFetcher(g.ERC20Contract, c), m = await C.balanceOf(a);
|
|
54
|
+
await N(
|
|
54
55
|
t,
|
|
55
56
|
n,
|
|
56
57
|
C,
|
|
57
|
-
|
|
58
|
+
a,
|
|
58
59
|
r,
|
|
59
60
|
i
|
|
60
61
|
), n.push(I(C, r, 2n ** 256n - 1n, i));
|
|
@@ -65,7 +66,7 @@ const z = (t, a, c, e, n, i, o = !1) => {
|
|
|
65
66
|
u({
|
|
66
67
|
contract: f,
|
|
67
68
|
func: "takeSwapFee",
|
|
68
|
-
args: [
|
|
69
|
+
args: [c, m, P, E],
|
|
69
70
|
invokeWallet: i
|
|
70
71
|
})
|
|
71
72
|
);
|
|
@@ -79,26 +80,26 @@ const z = (t, a, c, e, n, i, o = !1) => {
|
|
|
79
80
|
})
|
|
80
81
|
);
|
|
81
82
|
}
|
|
82
|
-
},
|
|
83
|
-
const E = i < 0n ? -1n * i : i, y = t.getCurrentChainId(), p = [], S =
|
|
83
|
+
}, ct = async (t, c, a, e, n, i, o, r, C, m, h, f = !1) => {
|
|
84
|
+
const E = i < 0n ? -1n * i : i, y = t.getCurrentChainId(), p = [], S = K[y];
|
|
84
85
|
let _ = !1, R;
|
|
85
|
-
if (
|
|
86
|
+
if (c === O.OneInch || c === O.Lifi) {
|
|
86
87
|
if (n !== w) {
|
|
87
88
|
const b = t.getContractWithFetcher(g.ERC20Contract, n);
|
|
88
|
-
p.push(I(b,
|
|
89
|
+
p.push(I(b, a, E, f));
|
|
89
90
|
}
|
|
90
91
|
let s = 0n;
|
|
91
92
|
n === w && (s += E), o && r === w && o < 0n && (s += -1n * o);
|
|
92
93
|
const F = s > 0n ? s : void 0;
|
|
93
|
-
return R =
|
|
94
|
+
return R = U(
|
|
94
95
|
t,
|
|
95
|
-
a,
|
|
96
96
|
c,
|
|
97
|
+
a,
|
|
97
98
|
e,
|
|
98
99
|
m,
|
|
99
100
|
F,
|
|
100
101
|
f
|
|
101
|
-
), p.push(R), (
|
|
102
|
+
), p.push(R), (c === O.OneInch || C && c === O.Lifi) && r && o !== void 0 && await L(t, r, m, h, p, f, o), p;
|
|
102
103
|
}
|
|
103
104
|
if (!r || !o)
|
|
104
105
|
throw Error("There should be output token for UniSwap and Odos");
|
|
@@ -116,26 +117,26 @@ const z = (t, a, c, e, n, i, o = !1) => {
|
|
|
116
117
|
let B = 0n;
|
|
117
118
|
if (r === w && (r = S, _ = !0, B = await t.getContractWithFetcher(g.ERC20Contract, S).balanceOf(m)), n !== w) {
|
|
118
119
|
const s = t.getContractWithFetcher(g.ERC20Contract, n);
|
|
119
|
-
await
|
|
120
|
+
await N(t, p, s, m, a, f), p.push(I(s, a, E, f));
|
|
120
121
|
}
|
|
121
|
-
if (
|
|
122
|
-
|
|
122
|
+
if (c === O.Uniswap ? R = z(
|
|
123
|
+
a,
|
|
123
124
|
n,
|
|
124
125
|
E,
|
|
125
126
|
r,
|
|
126
127
|
m,
|
|
127
128
|
e,
|
|
128
129
|
f
|
|
129
|
-
) : R =
|
|
130
|
+
) : R = U(
|
|
130
131
|
t,
|
|
131
|
-
a,
|
|
132
132
|
c,
|
|
133
|
+
a,
|
|
133
134
|
e,
|
|
134
135
|
m,
|
|
135
136
|
void 0,
|
|
136
137
|
f
|
|
137
|
-
), p.push(R), await
|
|
138
|
-
const s =
|
|
138
|
+
), p.push(R), await L(t, r, m, h, p, f, o), _) {
|
|
139
|
+
const s = T[y], F = t.getContractWithFetcher(g.ERC20Contract, S);
|
|
139
140
|
p.push(I(F, s, 2n ** 256n - 1n, f));
|
|
140
141
|
const b = ["function withdrawBalanceDifference(uint256 beforeBalance) external"], x = new D.Contract(s, b);
|
|
141
142
|
p.push(
|
|
@@ -151,7 +152,7 @@ const z = (t, a, c, e, n, i, o = !1) => {
|
|
|
151
152
|
};
|
|
152
153
|
export {
|
|
153
154
|
z as createSwapToEmporiumOpForUniswap,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
U as createSwapToEmporiumOpFromData,
|
|
156
|
+
ct as createSwapToEmporiumOps,
|
|
157
|
+
N as nullifyUsdtApprovalIfNeeded
|
|
157
158
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../externalABIs/index.cjs"),p=require("ethers"),d=require("./emporium.helpers.cjs");var o=(e=>(e[e.Erc20Token=0]="Erc20Token",e[e.Uniswap=1]="Uniswap",e))(o||{});const h=(e,c,n,i,s,a)=>{let r=
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../externalABIs/index.cjs"),p=require("ethers"),d=require("./emporium.helpers.cjs");var o=(e=>(e[e.Erc20Token=0]="Erc20Token",e[e.Uniswap=1]="Uniswap",e))(o||{});const h=(e,c,n,i,s,a)=>{let r=[];switch(e){case 0:r=t.ERC20ABI;break;case 1:r=t.ISwapRouterABI;break}if(!r)throw Error("No ABI match in produceOp");const u=new p.ethers.Contract(c,r);return d.emporiumOp({contract:u,func:n,args:i,invokeWallet:s,value:a})};exports.OpType=o;exports.produceOp=h;
|
|
@@ -3,7 +3,7 @@ import { ethers as p } from "ethers";
|
|
|
3
3
|
import { emporiumOp as u } from "./emporium.helpers.mjs";
|
|
4
4
|
var w = /* @__PURE__ */ ((r) => (r[r.Erc20Token = 0] = "Erc20Token", r[r.Uniswap = 1] = "Uniswap", r))(w || {});
|
|
5
5
|
const E = (r, t, e, c, a, n) => {
|
|
6
|
-
let o =
|
|
6
|
+
let o = [];
|
|
7
7
|
switch (r) {
|
|
8
8
|
case 0:
|
|
9
9
|
o = s;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("ethers"),d=require("../../constants/protocol.constants.cjs"),V=require("../../constants/conversion.constants.cjs"),S=require("../../data-structures/crypto-keys/keys.cjs"),E=require("../../data-structures/crypto-keys/encryptDecryptUtxo.cjs"),F=require("../../types/circom-data.types.cjs"),f=require("../utils/external-action.utils.cjs"),u=require("../../types/hinkal.types.cjs"),T=require("../utils/amounts.utils.cjs"),P=require("./getOriginalSender.cjs"),L=(e,s)=>e.map((t,a)=>t.map(n=>s[a]?"0":n.getNullifier())),R=(e,s,t)=>{let a=[];return e==="v1x0"?a=s.map((n,r)=>n.map(
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("ethers"),d=require("../../constants/protocol.constants.cjs"),V=require("../../constants/conversion.constants.cjs"),S=require("../../data-structures/crypto-keys/keys.cjs"),E=require("../../data-structures/crypto-keys/encryptDecryptUtxo.cjs"),F=require("../../types/circom-data.types.cjs"),f=require("../utils/external-action.utils.cjs"),u=require("../../types/hinkal.types.cjs"),T=require("../utils/amounts.utils.cjs"),P=require("./getOriginalSender.cjs"),L=(e,s)=>e.map((t,a)=>t.map(n=>s[a]?"0":n.getNullifier())),R=(e,s,t)=>{let a=[];return e==="v1x0"?a=s.map((n,r)=>n.map(i=>t[r]?"0":i.getCommitment())):a=s.map(n=>n.map(r=>r.amount===0n?"0":r.getCommitment())),a},_=(e,s,t=!1)=>{const a=[];for(let n=0;n<e.length;n+=1){let r=0n,i=0n;for(let l=0;l<e[n].length;l+=1)r+=e[n][l].amount;for(let l=0;l<s[n].length;l+=1)i+=s[n][l].amount;i-r<0?t?a.push(i-r):a.push(d.CIRCOM_P+(i-r)):a.push(i-r)}return a},q=e=>e.useApprovalUtxoData.reduce((s,t)=>[...s,T.calculateBigIntSum(t.approvalChanges)],[]),x=(e,s)=>{const t=q(s),a=s.hinkalLogicAction,n=e.map((r,i)=>a===u.HinkalLogicAction.NONE||a===u.HinkalLogicAction.APPROVE?r+t[i]>=0n?0n:r+t[i]:r>=0n?0n:r);return a===u.HinkalLogicAction.RELEASE_BUFFER?e.forEach((r,i)=>{n[i]=r>0n?-r:r}):a===u.HinkalLogicAction.EXECUTE&&s.executeApprovalChanges.forEach((r,i)=>{n[i]=r+e[i]<0n?r+e[i]:0n}),n},M=e=>{if(e.length===0)return[];const s=[[""]];for(let t=0;t<e.length;t+=1)t>0&&s.push([""]),e[t].forEach((a,n)=>{s[t][n]=`0x${Buffer.from(E.encryptUtxo(a)).toString("hex")}`});return s},z=(e,s)=>{const t=[];for(let n=0;n<e.length;n+=1){t.push([]);for(let r=0;r<e[n].length;r+=1)t[n][r]=s.getSiblingHashesForVerification(BigInt(e[n][r].getCommitment())).map(i=>i.toString())}const a=[];for(let n=0;n<e.length;n+=1){a.push([]);for(let r=0;r<e[n].length;r+=1)a[n][r]=s.getSiblingSides(BigInt(e[n][r].getCommitment())).map(i=>i.toString())}return{inCommitmentSiblings:t,inCommitmentSiblingSides:a}},C=(e,s)=>{const t=s.getSiblingHashesForVerification(BigInt(e)).map(n=>n.toString()),a=s.getSiblingSides(BigInt(e)).map(n=>n.toString());return{accessTokenSiblings:t,accessTokenSiblingSides:a}},W=(e,s)=>C(e.getAccessKey(),s),j=e=>{const s={...e};if(s.amountChanges=e.amountChanges.map(t=>t.toString()),s.calldataHash=e.calldataHash.toString(),s.rootHashAccessToken=e.rootHashAccessToken?.toString(),s.stealthAddressStructure.extraRandomization=e.stealthAddressStructure.extraRandomization.toString(),s.stealthAddressStructure.stealthAddress=e.stealthAddressStructure.stealthAddress.toString(),s.stealthAddressStructure.H0=e.stealthAddressStructure.H0.toString(),s.stealthAddressStructure.H1=e.stealthAddressStructure.H1.toString(),s.rootHashHinkal=e.rootHashHinkal?.toString(),s.externalActionId=e.externalActionId?.toString(),"flatFees"in e){const t=s;return t.flatFees=e.flatFees.map(a=>a.toString()),t}else{const t=s;return t.slippageValues=e.slippageValues.map(a=>a.toString()),t.hinkalLogicArgs.inHinkalAddress=e.hinkalLogicArgs.inHinkalAddress.toString(),t.hinkalLogicArgs.executeApprovalChanges=e.hinkalLogicArgs.executeApprovalChanges.map(a=>a.toString()),t.hinkalLogicArgs.useApprovalUtxoData=e.hinkalLogicArgs.useApprovalUtxoData.map(a=>({approvalChanges:a.approvalChanges.map(n=>n.toString()),externalApprovalAddresses:a.externalApprovalAddresses,conversionInHinkalAddress:a.conversionInHinkalAddress.map(n=>n.toString())})),t.feeStructure.flatFee=e.feeStructure.flatFee.toString(),t.feeStructure.variableRate=e.feeStructure.variableRate.toString(),t}},w=e=>{const s={...e};if(s.amountChanges=e.amountChanges.map(t=>BigInt(t)),s.calldataHash=BigInt(e.calldataHash),s.rootHashAccessToken=BigInt(e.rootHashAccessToken),s.rootHashHinkal=BigInt(e.rootHashHinkal),s.externalActionId=BigInt(e.externalActionId),"flatFees"in e){const t=s;return t.flatFees=e.flatFees.map(a=>BigInt(a)),t}else{const t=s;return t.feeStructure.flatFee=BigInt(e.feeStructure.flatFee),t.feeStructure.variableRate=BigInt(e.feeStructure.variableRate),t.slippageValues=e.slippageValues.map(a=>BigInt(a)),t.hinkalLogicArgs.executeApprovalChanges=e.hinkalLogicArgs.executeApprovalChanges.map(a=>BigInt(a)),t.hinkalLogicArgs.inHinkalAddress=BigInt(e.hinkalLogicArgs.inHinkalAddress),t.hinkalLogicArgs.useApprovalUtxoData=e.hinkalLogicArgs.useApprovalUtxoData.map(a=>({approvalChanges:a.approvalChanges.map(n=>BigInt(n)),externalApprovalAddresses:a.externalApprovalAddresses,conversionInHinkalAddress:a.conversionInHinkalAddress.map(n=>BigInt(n))})),t}},K=(e,s,t,a,n,r,i,l,H,k,b,c,g,m,v)=>{const h=Object.values(H||F.defaultHookData),I=v??P.getOriginalSender(a??d.zeroAddress,t);if(e==="v1x0"){const p=o.ethers.AbiCoder.defaultAbiCoder().encode(["uint16","address","address","uint256","bytes","tuple(address, address, bytes, bytes)","bytes[][]","uint256[]"],[s,t,a,typeof n=="bigint"?n:f.getExternalActionIdHash(n),r,h,i,l]);return BigInt(o.ethers.keccak256(p))%d.CIRCOM_P}else{const p=o.ethers.AbiCoder.defaultAbiCoder().encode(["uint16","address","address","uint256","bytes"],[s,t,a,typeof n=="bigint"?n:f.getExternalActionIdHash(n),r]),A=o.ethers.AbiCoder.defaultAbiCoder().encode(["tuple(address, address, bytes, bytes)","bytes[][]","tuple(address, uint256, uint256)","int256[]","bool[]","tuple(uint256, uint256,int256[],bool, tuple(int256[] approvalChanges, address[] externalApprovalAddresses, uint256[] conversionInHinkalAddress)[])","tuple(uint8 v, bytes32 r, bytes32 s, uint256 accessKey, uint256 nonce, address ethereumAddress)","address"],[h,i,[g.feeToken,g.flatFee,g.variableRate],k,b,[c.hinkalLogicAction,c.inHinkalAddress,c.executeApprovalChanges,c.doPreTxApproval,c.useApprovalUtxoData],m,I]),y=BigInt(o.ethers.keccak256(p)),B=BigInt(o.ethers.keccak256(A)),O=o.ethers.AbiCoder.defaultAbiCoder().encode(["uint256","uint256"],[y,B]);return BigInt(o.ethers.keccak256(O))%d.CIRCOM_P}},N=e=>e.startsWith("swapperMO")||e.startsWith("swapperME")?2:e.startsWith("swapperMW")?1:(e.startsWith("swapperMHA"),0),J=(e,s,t,a,n,r)=>{if(e.startsWith("swapperMWMin0"))return 4;const i=N(e);return 10+s.length+t.length+a.flat().length+n.flat().length+i+r+V.APPROVED_UTXO_CONVERSION_COUNT*s.length},U=(e,s)=>{const{h0:t,h1:a}=S.UserKeys.getStealthAddressCompressedPoints(e,s),n=BigInt(S.UserKeys.getStealthAddress(e,s));return{extraRandomization:e,H0:t,H1:a,stealthAddress:n}};exports.buildInNullifiers=L;exports.buildOutCommitments=R;exports.calcAccessTokenSiblingAndSidesFromAccessKey=C;exports.calcAccessTokenSiblingsAndSides=W;exports.calcAmountChanges=_;exports.calcCommitmentsSiblingAndSides=z;exports.calcEncryptedOutputs=M;exports.calcPublicSignalCount=J;exports.calcStealthAddressStructure=U;exports.createCallDataHash=K;exports.deserializeCircomData=w;exports.getSlippageValues=x;exports.serializeCircomData=j;
|