@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,4 +1,4 @@
|
|
|
1
|
-
import { AbstractAccessTokenSnapshotService as
|
|
1
|
+
import { AbstractAccessTokenSnapshotService as i } from "../../event-service/evm/AbstractAccessTokenSnapshotService.mjs";
|
|
2
2
|
import "ethers";
|
|
3
3
|
import "circomlibjs-hinkal-fork";
|
|
4
4
|
import "libsodium-wrappers";
|
|
@@ -7,29 +7,31 @@ import "buffer";
|
|
|
7
7
|
import "../../../constants/vite.constants.mjs";
|
|
8
8
|
import "../../../error-handling/error-codes.constants.mjs";
|
|
9
9
|
import "../../../constants/save-depths.mjs";
|
|
10
|
+
import { getProviderFromContract as n } from "../../../functions/utils/getSignerFromContract.mjs";
|
|
10
11
|
import "../../../constants/reorg-depths.constants.mjs";
|
|
11
12
|
import "../../../functions/utils/mutexes.utils.mjs";
|
|
12
13
|
import "@coral-xyz/anchor";
|
|
13
14
|
import "../../../constants/chains.constants.mjs";
|
|
14
15
|
import "@solana/web3.js";
|
|
15
16
|
import "../../crypto-keys/keys.mjs";
|
|
16
|
-
import { SnapshotFetcherService as
|
|
17
|
-
|
|
17
|
+
import { SnapshotFetcherService as c } from "../SnapshotFetcherService.mjs";
|
|
18
|
+
import { getContractAddress as o } from "../../../functions/utils/getContractAddress.mjs";
|
|
19
|
+
class N extends i {
|
|
18
20
|
snapshotsService;
|
|
19
|
-
constructor(e,
|
|
20
|
-
super(e), this.snapshotsService =
|
|
21
|
+
constructor(e, r) {
|
|
22
|
+
super(e), this.snapshotsService = r;
|
|
21
23
|
}
|
|
22
24
|
async fetchSnapshot() {
|
|
23
|
-
const { contract: e } = this.blockchainEventEmitter, { chainId:
|
|
24
|
-
this.snapshotsService || (this.snapshotsService = new
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
25
|
+
const { contract: e } = this.blockchainEventEmitter, { chainId: r } = await n(e).getNetwork(), s = Number(r);
|
|
26
|
+
this.snapshotsService || (this.snapshotsService = new c(s, o(e)));
|
|
27
|
+
const t = await this.snapshotsService.getAccessTokens();
|
|
28
|
+
if (t.accessTokenContractAddress !== o(e) || t.chainId !== s)
|
|
27
29
|
throw Error("Commitment Snapshot: incorrect contract or chain id");
|
|
28
30
|
return {
|
|
29
|
-
latestBlockNumber:
|
|
30
|
-
merkleTree:
|
|
31
|
-
senderAddresses:
|
|
32
|
-
senderAddressIndexMap:
|
|
31
|
+
latestBlockNumber: t.latestBlockNumber,
|
|
32
|
+
merkleTree: t.merkleTree,
|
|
33
|
+
senderAddresses: t.senderAddresses,
|
|
34
|
+
senderAddressIndexMap: t.senderAddressIndexMap
|
|
33
35
|
};
|
|
34
36
|
}
|
|
35
37
|
persistSnapshot(e) {
|
|
@@ -37,5 +39,5 @@ class b extends r {
|
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
export {
|
|
40
|
-
|
|
42
|
+
N as ClientAccessTokenSnapshotService
|
|
41
43
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../../constants/vite.constants.cjs");require("../../../error-handling/error-codes.constants.cjs");require("../../../constants/save-depths.cjs");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../../functions/utils/getContractAddress.cjs"),o=require("../../../functions/utils/getSignerFromContract.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../../constants/vite.constants.cjs");require("../../../error-handling/error-codes.constants.cjs");require("../../../constants/save-depths.cjs");const i=require("../../event-service/evm/AbstractApprovalsSnapshotService.cjs");require("../../../constants/reorg-depths.constants.cjs");require("../../../functions/utils/mutexes.utils.cjs");require("@coral-xyz/anchor");require("../../../constants/chains.constants.cjs");require("@solana/web3.js");require("../../crypto-keys/keys.cjs");class n extends i.AbstractApprovalsSnapshotService{snapshotsService;constructor(r,t){super(r),this.snapshotsService=t}async fetchSnapshot(){const{contract:r}=this.blockchainEventEmitter,{chainId:t}=await o.getProviderFromContract(r).getNetwork(),s=Number(t),e=await this.snapshotsService.getApprovals();if(!e)return{latestBlockNumber:0,approvals:{},events:[]};if(e.hinkalAddress!==a.getContractAddress(r)||e.chainId!==s)throw Error("approvalsSnapshotData Snapshot: incorrect contract or chain id");return{latestBlockNumber:e.latestBlockNumber,approvals:e.approvals,events:e.events}}persistSnapshot(r){return Promise.resolve()}}exports.ClientApprovalsSnapshotService=n;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getContractAddress as a } from "../../../functions/utils/getContractAddress.mjs";
|
|
2
|
+
import { getProviderFromContract as e } from "../../../functions/utils/getSignerFromContract.mjs";
|
|
1
3
|
import "ethers";
|
|
2
4
|
import "circomlibjs-hinkal-fork";
|
|
3
5
|
import "libsodium-wrappers";
|
|
@@ -6,27 +8,27 @@ import "buffer";
|
|
|
6
8
|
import "../../../constants/vite.constants.mjs";
|
|
7
9
|
import "../../../error-handling/error-codes.constants.mjs";
|
|
8
10
|
import "../../../constants/save-depths.mjs";
|
|
9
|
-
import { AbstractApprovalsSnapshotService as
|
|
11
|
+
import { AbstractApprovalsSnapshotService as p } from "../../event-service/evm/AbstractApprovalsSnapshotService.mjs";
|
|
10
12
|
import "../../../constants/reorg-depths.constants.mjs";
|
|
11
13
|
import "../../../functions/utils/mutexes.utils.mjs";
|
|
12
14
|
import "@coral-xyz/anchor";
|
|
13
15
|
import "../../../constants/chains.constants.mjs";
|
|
14
16
|
import "@solana/web3.js";
|
|
15
17
|
import "../../crypto-keys/keys.mjs";
|
|
16
|
-
class
|
|
18
|
+
class B extends p {
|
|
17
19
|
snapshotsService;
|
|
18
20
|
constructor(r, o) {
|
|
19
21
|
super(r), this.snapshotsService = o;
|
|
20
22
|
}
|
|
21
23
|
async fetchSnapshot() {
|
|
22
|
-
const { contract: r } = this.blockchainEventEmitter, { chainId: o } = await r.
|
|
24
|
+
const { contract: r } = this.blockchainEventEmitter, { chainId: o } = await e(r).getNetwork(), s = Number(o), t = await this.snapshotsService.getApprovals();
|
|
23
25
|
if (!t)
|
|
24
26
|
return {
|
|
25
27
|
latestBlockNumber: 0,
|
|
26
28
|
approvals: {},
|
|
27
29
|
events: []
|
|
28
30
|
};
|
|
29
|
-
if (t.hinkalAddress !== r
|
|
31
|
+
if (t.hinkalAddress !== a(r) || t.chainId !== s)
|
|
30
32
|
throw Error("approvalsSnapshotData Snapshot: incorrect contract or chain id");
|
|
31
33
|
return {
|
|
32
34
|
latestBlockNumber: t.latestBlockNumber,
|
|
@@ -39,5 +41,5 @@ class f extends s {
|
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
export {
|
|
42
|
-
|
|
44
|
+
B as ClientApprovalsSnapshotService
|
|
43
45
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./customErrors/ErrorWithAmount.cjs"),f=require("./customErrors/FeeOverTransactionValueError.cjs"),C=require("./customErrors/customErrors.helpers.cjs"),a=require("./error-codes.constants.cjs"),r=require("./types.cjs");require("../types/circom-data.types.cjs");require("../types/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./customErrors/ErrorWithAmount.cjs"),f=require("./customErrors/FeeOverTransactionValueError.cjs"),C=require("./customErrors/customErrors.helpers.cjs"),a=require("./error-codes.constants.cjs"),r=require("./types.cjs");require("../types/circom-data.types.cjs");require("../types/activities.types.cjs");const t=require("../types/sandbox.types.cjs"),u=e=>{if(typeof e=="object"&&e!==null){if("response"in e&&typeof e.response=="object"&&e.response!==null&&"data"in e.response&&typeof e.response.data=="object"&&e.response.data!==null&&"message"in e.response.data&&typeof e.response.data.message=="string")return e.response.data.message;if("data"in e&&typeof e.data=="object"&&e.data!==null&&"message"in e.data&&typeof e.data.message=="string")return e.data.message;if("message"in e&&typeof e.message=="string")return e.message}if(e instanceof Error)return e.message;if(typeof e=="string")return e},S=e=>{switch(e){case r.ErrorCategory.DEPOSIT:return"Deposit failed";case r.ErrorCategory.SWAP:return"Swap failed";case r.ErrorCategory.BRIDGE:return"Bridge failed";case r.ErrorCategory.WITHDRAW:return"Send failed";case r.ErrorCategory.Fund:return"Unshield failed";case r.ErrorCategory.Receive:return"Shield failed";case r.ErrorCategory.DappTransaction:return"DApp transaction failed";case r.ErrorCategory.Approve:return"Approval failed";default:return a.transactionErrorCodes.UNKNOWN}},p=(e,n)=>{if(e instanceof f.FeeOverTransactionValueError)return C.getGenericFeeOverTransactionValueErrorMessage(e,n);if(e instanceof l.ErrorWithAmount){const{amount:i,message:o}=e;return`${o} ${i}`}const s=u(e);if(s){const i=s.toLowerCase(),o=Object.keys(a.transactionErrorCodes).find(c=>i===a.transactionErrorCodes[c].toLowerCase());if(o&&o in a.UserFriendlyErrorCodes)return a.UserFriendlyErrorCodes[o];const d=Object.entries(a.transactionErrorCodes).find(([c,g])=>i.includes(g.toLowerCase()));if(d)return a.UserFriendlyErrorCodes[d[0]]??d[1]}return n?S(n):a.transactionErrorCodes.UNKNOWN},y=(e,n)=>{let s;switch(n){case t.SandboxRequestType.Send:case t.SandboxRequestType.ProxySend:s=r.ErrorCategory.WITHDRAW;break;case t.SandboxRequestType.SwapTokens:case t.SandboxRequestType.ProxySwapTokens:s=r.ErrorCategory.SWAP;break;case t.SandboxRequestType.ReceiveFromShieldedAccount:s=r.ErrorCategory.Receive;break;case t.SandboxRequestType.Fund:s=r.ErrorCategory.Fund;break;case t.SandboxRequestType.ShieldTokens:s=r.ErrorCategory.DEPOSIT;break;case t.SandboxRequestType.FundApproveAndTransact:case t.SandboxRequestType.PrivateTransactionFromProxy:case t.SandboxRequestType.InsideTransact:s=r.ErrorCategory.DappTransaction;break;case t.SandboxRequestType.Approve:case t.SandboxRequestType.FundAndApprove:s=r.ErrorCategory.Approve;break;default:s=void 0;break}return p(e,s)};exports.extractMessage=u;exports.getErrorMessage=p;exports.getErrorMessageFromSandboxRequest=y;
|
|
@@ -4,7 +4,6 @@ import { getGenericFeeOverTransactionValueErrorMessage as g } from "./customErro
|
|
|
4
4
|
import { transactionErrorCodes as r, UserFriendlyErrorCodes as u } from "./error-codes.constants.mjs";
|
|
5
5
|
import { ErrorCategory as s } from "./types.mjs";
|
|
6
6
|
import "../types/circom-data.types.mjs";
|
|
7
|
-
import "../types/transactions.types.mjs";
|
|
8
7
|
import "../types/activities.types.mjs";
|
|
9
8
|
import { SandboxRequestType as n } from "../types/sandbox.types.mjs";
|
|
10
9
|
const A = (e) => {
|
|
@@ -60,7 +59,7 @@ const A = (e) => {
|
|
|
60
59
|
return u[c[0]] ?? c[1];
|
|
61
60
|
}
|
|
62
61
|
return a ? S(a) : r.UNKNOWN;
|
|
63
|
-
},
|
|
62
|
+
}, W = (e, a) => {
|
|
64
63
|
let t;
|
|
65
64
|
switch (a) {
|
|
66
65
|
case n.Send:
|
|
@@ -98,5 +97,5 @@ const A = (e) => {
|
|
|
98
97
|
export {
|
|
99
98
|
A as extractMessage,
|
|
100
99
|
T as getErrorMessage,
|
|
101
|
-
|
|
100
|
+
W as getErrorMessageFromSandboxRequest
|
|
102
101
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("ethers"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("ethers"),k=require("../../data-structures/Hinkal/hinkalGetZkMeProvider.cjs"),u=require("./openDefaultPassportWindow.cjs");async function l(e,a){if(e.origin==="https://widget.zk.me"){if(e.data.method==="getUserAccounts"){const t=await a.getUserAccounts();e.source?.postMessage({id:e.data.id,message:"ok",data:t},{targetOrigin:e.origin})}if(e.data.method==="getAccessToken"){const t=await a.getAccessToken();e.source?.postMessage({id:e.data.id,message:"ok",data:t},{targetOrigin:e.origin})}if(e.data.method==="delegateTransaction"){const t=e.data.params;if(a.delegateTransaction){const s=await a.delegateTransaction(t);e.source?.postMessage({id:e.data.id,message:"ok",data:s},{targetOrigin:e.origin})}}}}const m=async(e,a,n,t)=>{const s=k.getHinkalZkMeProvider(e),o=await s.getAccessToken(),i=e.getCurrentChainId(),c=g.ethers.toBeHex(i);window.addEventListener("message",d=>l(d,s));const r=`${n}?mchNo=${t.merchId}&name=HinkalProtocol&chainId=${c}&accessToken=${o}`;u.openDefaultPassportWindow(r,a,700,510)};exports.zkMeKycHandler=m;
|
|
@@ -41,12 +41,12 @@ async function u(t, a) {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
const
|
|
45
|
-
const s = m(t), o = await s.getAccessToken(), i = t.getCurrentChainId(), c = d.
|
|
44
|
+
const T = async (t, a, n, e) => {
|
|
45
|
+
const s = m(t), o = await s.getAccessToken(), i = t.getCurrentChainId(), c = d.toBeHex(i);
|
|
46
46
|
window.addEventListener("message", (g) => u(g, s));
|
|
47
47
|
const r = `${n}?mchNo=${e.merchId}&name=HinkalProtocol&chainId=${c}&accessToken=${o}`;
|
|
48
48
|
k(r, a, 700, 510);
|
|
49
49
|
};
|
|
50
50
|
export {
|
|
51
|
-
|
|
51
|
+
T as zkMeKycHandler
|
|
52
52
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../types/circom-data.types.cjs");const e=require("../../types/hinkal.types.cjs");require("../../types/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../types/circom-data.types.cjs");const e=require("../../types/hinkal.types.cjs");require("../../types/activities.types.cjs");const i=require("../utils/erc20tokenFunctions.cjs"),O=require("./process-gas-estimates.cjs"),A=require("./interaction-to-action.cjs"),l=async(o,s,c,I,C,k=[])=>{let t;const T=A.getInteractionFromAction(c);if(T===e.INTERACTION.NONE)throw Error("No interaction was choosen");let r;switch(T){case e.INTERACTION.WITHDRAW:t=i.getERC20Token(s[0],o);break;case e.INTERACTION.SWAP:t=i.getERC20Token(s[1],o);break;case e.INTERACTION.CLAIMING:t=i.getERC20Token(s[1],o);break;case e.INTERACTION.EMPORIUM:r=I.findIndex(R=>R>0n),t=i.getERC20Token(s[r],o);break}let n,N;const E=I.length;t&&({priceOfTransactionInToken:n,priceOfTransactionInUSD:N}=await O.processGasEstimates(o,t,c,E,void 0,k));const a=new Array(E).fill(0n);switch(T){case e.INTERACTION.WITHDRAW:a[0]=n||0n;break;case e.INTERACTION.SWAP:a[1]=n||0n;break;case e.INTERACTION.CLAIMING:a[1]=n||0n;break;case e.INTERACTION.EMPORIUM:r!==void 0&&r!==-1&&(a[r]=n||0n);break}return{flatFees:a,priceOfTransactionInToken:n,feeUnit:t,priceOfTransactionInUSD:N}};exports.getFlatFees=l;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import "../../types/circom-data.types.mjs";
|
|
2
2
|
import { INTERACTION as e } from "../../types/hinkal.types.mjs";
|
|
3
|
-
import "../../types/transactions.types.mjs";
|
|
4
3
|
import "../../types/activities.types.mjs";
|
|
5
4
|
import { getERC20Token as s } from "../utils/erc20tokenFunctions.mjs";
|
|
6
5
|
import { processGasEstimates as b } from "./process-gas-estimates.mjs";
|
|
7
6
|
import { getInteractionFromAction as l } from "./interaction-to-action.mjs";
|
|
8
|
-
const
|
|
7
|
+
const W = async (r, i, f, m, E, I = []) => {
|
|
9
8
|
let t;
|
|
10
9
|
const c = l(f);
|
|
11
10
|
if (c === e.NONE)
|
|
@@ -53,5 +52,5 @@ const F = async (r, i, f, m, E, I = []) => {
|
|
|
53
52
|
return { flatFees: a, priceOfTransactionInToken: o, feeUnit: t, priceOfTransactionInUSD: k };
|
|
54
53
|
};
|
|
55
54
|
export {
|
|
56
|
-
|
|
55
|
+
W as getFlatFees
|
|
57
56
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@coral-xyz/anchor"),N=require("ethers"),p=require("../../constants/protocol.constants.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@coral-xyz/anchor"),N=require("ethers"),p=require("../../constants/protocol.constants.cjs"),w=(o,r,a,s,c,d,l,u)=>{const y=new t.BN(c.toString()),i=new t.BN(d.toString()),b=s.reduce((n,e)=>[...n,...new t.BN(e.length).toArray("be",8),...e],[]),g=l.reduce((n,e)=>{const h=[...new t.BN(e.programIndex).toArray("be",1),...new t.BN(e.accountIndexes.length).toArray("be",8),...e.accountIndexes,...new t.BN(e.data.length).toArray("be",8),...e.data];return[...n,...h]},[]),B=u.reduce((n,e)=>[...n,e.isWritable?1:0,...e.pubkey.toBytes()],[]),A=[o.tokenNumber,o.nullifierAmount,o.outputAmount,...r.toBytes(),...a.toBytes(),...b,...y.toArray("be",8),...i.toArray("be",8),...g,...B];return BigInt(N.ethers.sha256(new Uint8Array(A)))%p.CIRCOM_P};exports.getSolanaCalldataHash=w;
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { BN as
|
|
2
|
-
import { ethers as
|
|
3
|
-
import { CIRCOM_P as
|
|
4
|
-
const x = (o, r, a, s, c, d,
|
|
5
|
-
const
|
|
6
|
-
(n,
|
|
1
|
+
import { BN as t } from "@coral-xyz/anchor";
|
|
2
|
+
import { ethers as w } from "ethers";
|
|
3
|
+
import { CIRCOM_P as B } from "../../constants/protocol.constants.mjs";
|
|
4
|
+
const x = (o, r, a, s, c, d, y, u) => {
|
|
5
|
+
const b = new t(c.toString()), i = new t(d.toString()), l = s.reduce(
|
|
6
|
+
(n, e) => [...n, ...new t(e.length).toArray("be", 8), ...e],
|
|
7
7
|
[]
|
|
8
|
-
), m =
|
|
9
|
-
const
|
|
10
|
-
...new e
|
|
11
|
-
...new e
|
|
12
|
-
...
|
|
13
|
-
...new e
|
|
14
|
-
...
|
|
8
|
+
), m = y.reduce((n, e) => {
|
|
9
|
+
const p = [
|
|
10
|
+
...new t(e.programIndex).toArray("be", 1),
|
|
11
|
+
...new t(e.accountIndexes.length).toArray("be", 8),
|
|
12
|
+
...e.accountIndexes,
|
|
13
|
+
...new t(e.data.length).toArray("be", 8),
|
|
14
|
+
...e.data
|
|
15
15
|
];
|
|
16
|
-
return [...n, ...
|
|
17
|
-
}, []),
|
|
18
|
-
(n,
|
|
16
|
+
return [...n, ...p];
|
|
17
|
+
}, []), A = u.reduce(
|
|
18
|
+
(n, e) => [...n, e.isWritable ? 1 : 0, ...e.pubkey.toBytes()],
|
|
19
19
|
[]
|
|
20
|
-
),
|
|
20
|
+
), g = [
|
|
21
21
|
o.tokenNumber,
|
|
22
22
|
o.nullifierAmount,
|
|
23
23
|
o.outputAmount,
|
|
24
24
|
...r.toBytes(),
|
|
25
25
|
...a.toBytes(),
|
|
26
|
-
...
|
|
27
|
-
...l.toArray("be", 8),
|
|
26
|
+
...l,
|
|
28
27
|
...b.toArray("be", 8),
|
|
28
|
+
...i.toArray("be", 8),
|
|
29
29
|
...m,
|
|
30
|
-
...
|
|
30
|
+
...A
|
|
31
31
|
];
|
|
32
|
-
return BigInt(
|
|
32
|
+
return BigInt(w.sha256(new Uint8Array(g))) % B;
|
|
33
33
|
};
|
|
34
34
|
export {
|
|
35
35
|
x as getSolanaCalldataHash
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../error-handling/error-codes.constants.cjs");require("ethers");require("../../types/circom-data.types.cjs");require("../../types/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../error-handling/error-codes.constants.cjs");require("ethers");require("../../types/circom-data.types.cjs");require("../../types/activities.types.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("../../data-structures/http/HttpClient.cjs");require("axios");require("../../constants/chains.constants.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/vite.constants.cjs");require("../../constants/save-depths.cjs");require("../../constants/reorg-depths.constants.cjs");require("../utils/mutexes.utils.cjs");require("@coral-xyz/anchor");const q=require("../../error-handling/logger.cjs");require("@solana/web3.js");require("../../data-structures/crypto-keys/keys.cjs");const c=require("../../API/is-tx-stateless.cjs"),f=require("../../data-structures/token-price-fetcher/TokenChecker.cjs"),d=async(s,a,n,o)=>{try{const r=a.map((e,t)=>{const i=n[t];return e&&f.TokenChecker.isPotentiallyVolatile(e)?{tokenAddress:e.erc20TokenAddress,amount:i.toString(),...o!==void 0?{targetAddress:o}:{},originalIndex:t}:null}).filter(e=>e!==null);if(r.length===0)return n;const l=await c.simulateVolatileTokenTransfer(s,r);return n.map((e,t)=>{const i=r.findIndex(u=>u.originalIndex===t);if(i!==-1&&l[i].success){const u=l[i].balanceDifference;return u?BigInt(u):e}return e})}catch(r){return q.Logger.error("Volatile transfer simulation failed:",r),n}};exports.modifyVolatileTokenAmountChanges=d;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "../../error-handling/error-codes.constants.mjs";
|
|
2
2
|
import "ethers";
|
|
3
3
|
import "../../types/circom-data.types.mjs";
|
|
4
|
-
import "../../types/transactions.types.mjs";
|
|
5
4
|
import "../../types/activities.types.mjs";
|
|
6
5
|
import "../../constants/server.constants.mjs";
|
|
7
6
|
import "../../API/getServerURL.mjs";
|
|
@@ -22,7 +21,7 @@ import "@solana/web3.js";
|
|
|
22
21
|
import "../../data-structures/crypto-keys/keys.mjs";
|
|
23
22
|
import { simulateVolatileTokenTransfer as c } from "../../API/is-tx-stateless.mjs";
|
|
24
23
|
import { TokenChecker as u } from "../../data-structures/token-price-fetcher/TokenChecker.mjs";
|
|
25
|
-
const
|
|
24
|
+
const z = async (l, s, i, m) => {
|
|
26
25
|
try {
|
|
27
26
|
const t = s.map((r, e) => {
|
|
28
27
|
const o = i[e];
|
|
@@ -49,5 +48,5 @@ const E = async (l, s, i, m) => {
|
|
|
49
48
|
}
|
|
50
49
|
};
|
|
51
50
|
export {
|
|
52
|
-
|
|
51
|
+
z as modifyVolatileTokenAmountChanges
|
|
53
52
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../types/circom-data.types.cjs");const e=require("../../types/external-action.types.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../types/circom-data.types.cjs");const e=require("../../types/external-action.types.cjs"),t=require("../../types/hinkal.types.cjs");require("../../types/activities.types.cjs");const n=r=>r===e.ExternalActionId.Transact?t.INTERACTION.WITHDRAW:[e.ExternalActionId.Uniswap,e.ExternalActionId.Odos,e.ExternalActionId.OneInch].includes(r)?t.INTERACTION.SWAP:r===e.ExternalActionId.Emporium?t.INTERACTION.EMPORIUM:t.INTERACTION.NONE;exports.getInteractionFromAction=n;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import "../../types/circom-data.types.mjs";
|
|
2
2
|
import { ExternalActionId as r } from "../../types/external-action.types.mjs";
|
|
3
3
|
import { INTERACTION as t } from "../../types/hinkal.types.mjs";
|
|
4
|
-
import "../../types/transactions.types.mjs";
|
|
5
4
|
import "../../types/activities.types.mjs";
|
|
6
|
-
const
|
|
5
|
+
const p = (o) => o === r.Transact ? t.WITHDRAW : [r.Uniswap, r.Odos, r.OneInch].includes(
|
|
7
6
|
o
|
|
8
7
|
) ? t.SWAP : o === r.Emporium ? t.EMPORIUM : t.NONE;
|
|
9
8
|
export {
|
|
10
|
-
|
|
9
|
+
p as getInteractionFromAction
|
|
11
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../../constants/protocol.constants.cjs"),y=require("../../types/ethereum-network.types.cjs");require("idb-keyval");const v=require("../../constants/chains.constants.cjs"),q=require("../utils/getContractAddress.cjs"),k=require("../utils/create-provider.cjs"),u=require("ethers");require("../../constants/token-data/index.cjs");require("../../error-handling/error-codes.constants.cjs");require("../utils/convertIntegrationProviderToExternalActionId.cjs");require("../../types/circom-data.types.cjs");require("../../types/activities.types.cjs");require("circomlibjs-hinkal-fork");const f=require("../../data-structures/crypto-keys/keys.cjs");require("../../constants/server.constants.cjs");require("../../constants/vite.constants.cjs");require("../../data-structures/http/HttpClient.cjs");require("axios");const h=require("../utils/caseInsensitive.utils.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 w=require("../../error-handling/logger.cjs");require("@solana/web3.js");require("@solana/spl-token");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");require("../utils/userAgent.cjs");const D=require("../utils/string.utils.cjs");require("multiformats");require("../../API/tenderly.api.cjs");const W=require("../utils/replaceAddressInCalldata.cjs"),g=({contract:e,func:t,args:n,callDataString:r,invokeWallet:s,value:i})=>{let o=new Uint8Array,c=r?u.ethers.getBytesCopy(r):new Uint8Array;if(typeof e=="object"){if(o=u.ethers.getBytesCopy(q.getContractAddress(e)),r?.length&&r?.length>0)throw Error("If function and args are providedm no calldata is needed");t&&n&&!r&&(c=u.ethers.getBytesCopy(e.interface.encodeFunctionData(t,n)))}else o=u.ethers.getBytesCopy(e);const a=u.ethers.getBytesCopy(new Uint8Array([s?1:0])),d=u.ethers.zeroPadValue(u.ethers.toBeHex(i??0n),16),p=u.ethers.concat([o,a,d,c]);return u.ethers.hexlify(p)},P=async(e,t,n,r,s,i)=>{const o=n?await f.UserKeys.signTypedDataFromPrivateKey(e,n,{name:"Emporium",version:"1.0.0",chainId:e,verifyingContract:t},{EmporiumSignature:[{name:"message",type:"uint256"}]},{message:s}):void 0,{v:c,r:a,s:d}=o?u.ethers.Signature.from(o):{v:0,r:u.ethers.ZeroHash,s:u.ethers.ZeroHash};return u.ethers.AbiCoder.defaultAbiCoder().encode(["tuple(uint8 v,bytes32 r, bytes32 s, uint256 message, address signerAddress, bytes[] ops)"],[{v:c,r:a,s:d,message:s??0n,signerAddress:i??l.zeroAddress,ops:r}])},A=(e,t,n,r)=>g(e?{contract:e,func:"transfer",args:[t,n],invokeWallet:r}:{contract:t,value:n,invokeWallet:r}),B=(e,t,n,r)=>{const s=e.getContractWithFetcher(y.ContractType.HinkalContract),i=q.getContractAddress(s);return t.map((o,c)=>{const a=h.caseInsensitiveEqual(o,l.zeroAddress)?void 0:e.getContractWithFetcher(y.ContractType.ERC20Contract,o);return A(a,r??i,n[c],!0)})},F=(e,t,n,r)=>g({contract:e,func:"approve",args:[t,n],invokeWallet:r}),O=(e,t,n)=>{const r=e.getSelectedNetwork()?.contractData.hinkalAddress;if(!r)throw Error("No Hinkal Address Provided to modifyDataForProxy");return D.replaceAllInstances(n,r.slice(2),t.slice(2))},T=(e,t,n)=>{if(!t)throw Error("No private key provided to modifyDataForProxy");const r=f.UserKeys.getSignerAddressFromPrivateKey(e.getCurrentChainId(),t);return O(e,r,n)},C=(e,t,n,r,s,i,o)=>{const c=[];for(let a=0;a<t.length;a+=1){const d=t[a],p=h.caseInsensitiveEqual(d,l.zeroAddress)?void 0:e.getContractWithFetcher(y.ContractType.ERC20Contract,d);c.push(A(p,i,n[a],!1))}if(o)for(let a=0;a<r.length;a+=1){const d=r[a];if(!h.caseInsensitiveEqual(d,l.zeroAddress)){const p=e.getContractWithFetcher(y.ContractType.ERC20Contract,d);c.push(F(p,o,s[a],!0))}}return c},z=(e,t,n,r,s,i,o,c,a,d)=>{const p=C(e,t,n,r,s,i,o);if(!!c&&!!a){const m=e.getContractWithFetcher(y.ContractType.HinkalContract);p.push(g({contract:c,callDataString:W.replaceAddressesInCalldata(a,q.getContractAddress(m),i),value:d,invokeWallet:!0}))}return p},x=(e,t,n,r,s,i,o)=>{const c=[],a=[r],d=[s];o.nativeFee>0n&&!h.caseInsensitiveEqual(r,l.zeroAddress)&&(a.push(l.zeroAddress),d.push(o.nativeFee));const E=C(e,a,d,[r],[i],t,n);c.push(...E);let m=o.nativeFee;return h.caseInsensitiveEqual(r,l.zeroAddress)&&(m+=i),c.push(g({contract:n,callDataString:o.calldata,value:m>0n?m:void 0,invokeWallet:!0})),c},U="0xef0100",I=async(e,t)=>{try{const{fetchRpcUrl:n}=v.networkRegistry[e];if(!n)throw new Error("RPC URL not found for the specified chain ID");const r=k.createCustomRpcProvider(n),s=await r.getCode(t);if(s==="0x"||!s)return{delegated:!1,implementation:void 0,nonce:void 0};if(s.toLowerCase().startsWith(U)&&s.length===48){const i=`0x${s.slice(8)}`,o=await r.getTransactionCount(t);return{delegated:!0,implementation:u.ethers.getAddress(i),nonce:o}}else throw Error("checkEOAWithDelegation: It is a contract")}catch(n){throw w.Logger.error("checkEOAWithDelegation error",{error:n}),n}},H=e=>{const{hinkalWalletAddress:t}=v.networkRegistry[e].contractData;if(!t||h.caseInsensitiveEqual(t,l.zeroAddress))throw Error("Hinkal Wallet Address is not set");return t},N=async(e,t)=>{if(e===v.chainIds.localhost||!t)return;const n=f.UserKeys.getSignerAddressFromPrivateKey(e,t),{delegated:r,implementation:s}=await I(e,n),i=H(e);if(!r||!h.caseInsensitiveEqual(s,i)){const o=await f.UserKeys.authorizeDelegation(e,t,i);return{v:o.signature.v.toString(),r:o.signature.r,s:o.signature.s,nonce:o.nonce.toString(),address:i,chainId:String(e)}}},R=e=>{if(!e)return;const{v:t,r:n,s:r,nonce:s,chainId:i,address:o}=e;return{signature:u.ethers.Signature.from({v:t,r:n,s:r}),nonce:BigInt(s),chainId:BigInt(i),address:o}};exports.checkEOAWithDelegation=I;exports.createApproveEmporiumOp=F;exports.createLifiBridgeOps=x;exports.createTransaferEmporiumOpsBatch=B;exports.createTransferToEmporiumOp=A;exports.emporiumOp=g;exports.encodeEmporiumMetadata=P;exports.generateFundAndApproveOps=C;exports.generateFundApproveAndTransactOps=z;exports.getAuthorizationDataIfNeeded=N;exports.modifyDataForProxy=O;exports.modifyDataForProxyWithPrivateKey=T;exports.recoverAuthorizationData=R;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { Contract, ContractTransaction, ethers } from 'ethers';
|
|
2
1
|
import { IHinkal } from '../../data-structures/Hinkal/IHinkal';
|
|
3
2
|
import { type AuthorizationData } from '../../types/hinkal.types';
|
|
4
|
-
import { ethers
|
|
3
|
+
import { ethers } from 'ethers';
|
|
5
4
|
import { BridgeQuote } from '../../types/bridging-tx.types';
|
|
6
|
-
export declare const emporiumOp:
|
|
7
|
-
contract:
|
|
8
|
-
func?:
|
|
9
|
-
args?:
|
|
5
|
+
export declare const emporiumOp: ({ contract, func, args, callDataString, invokeWallet, value, }: {
|
|
6
|
+
contract: ethers.BaseContract | string;
|
|
7
|
+
func?: string | undefined;
|
|
8
|
+
args?: unknown[] | undefined;
|
|
10
9
|
callDataString?: string | undefined;
|
|
11
10
|
invokeWallet?: boolean | undefined;
|
|
12
11
|
value?: bigint | undefined;
|
|
@@ -30,4 +29,4 @@ export declare const checkEOAWithDelegation: (chainId: number, eoaAddress: strin
|
|
|
30
29
|
nonce: number;
|
|
31
30
|
}>;
|
|
32
31
|
export declare const getAuthorizationDataIfNeeded: (chainId: number, privateKey: string | undefined) => Promise<AuthorizationData | undefined>;
|
|
33
|
-
export declare const recoverAuthorizationData: (authorizationData: AuthorizationData | undefined) =>
|
|
32
|
+
export declare const recoverAuthorizationData: (authorizationData: AuthorizationData | undefined) => ethers.Authorization | undefined;
|