@hinkal/common 0.2.22 → 0.2.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API/proxyAccountsCalls.cjs +1 -1
- package/API/proxyAccountsCalls.mjs +13 -13
- package/README.md +63 -267
- package/constants/activity.constants.cjs +1 -1
- package/constants/activity.constants.mjs +0 -1
- package/constants/addresses.constants.cjs +1 -1
- package/constants/addresses.constants.mjs +9 -10
- package/constants/contracts.constants.cjs +1 -1
- package/constants/contracts.constants.d.ts +3 -3
- package/constants/contracts.constants.mjs +29 -29
- package/constants/server.constants.cjs +1 -1
- package/constants/server.constants.mjs +28 -29
- package/constants/tasks.constants.cjs +1 -1
- package/constants/tasks.constants.mjs +4 -5
- package/crypto/poseidon.cjs +1 -1
- package/crypto/poseidon.mjs +10 -10
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.cjs +1 -1
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.mjs +24 -24
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.mjs +4 -5
- package/data-structures/Hinkal/IHinkal.d.ts +2 -2
- package/data-structures/Hinkal/hinkalApprove.cjs +1 -1
- package/data-structures/Hinkal/hinkalApprove.mjs +40 -40
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -1
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +7 -8
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +4 -5
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +27 -28
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.d.ts +1 -0
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +35 -36
- package/data-structures/Hinkal/hinkalDepostAndBridge.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepostAndBridge.mjs +86 -83
- package/data-structures/Hinkal/hinkalInsideTransact.cjs +1 -1
- package/data-structures/Hinkal/hinkalInsideTransact.mjs +14 -13
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +2 -3
- package/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalProoflessDeposit.mjs +27 -26
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +72 -73
- package/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaSwap.mjs +16 -17
- package/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaTransfer.mjs +24 -25
- package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +15 -16
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +2 -3
- package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalTransfer.mjs +2 -3
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +9 -10
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +8 -9
- package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.mjs +10 -10
- package/data-structures/IndexedDB/activity-db.cjs +1 -1
- package/data-structures/IndexedDB/activity-db.mjs +39 -41
- package/data-structures/IndexedDB/balances-db.cjs +1 -1
- package/data-structures/IndexedDB/balances-db.mjs +8 -9
- package/data-structures/IndexedDB/contact-db.cjs +1 -1
- package/data-structures/IndexedDB/contact-db.mjs +21 -23
- package/data-structures/IndexedDB/signatures-db.cjs +1 -1
- package/data-structures/IndexedDB/signatures-db.mjs +2 -3
- package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +34 -36
- package/data-structures/crypto-keys/decodeUTXO.cjs +1 -1
- package/data-structures/crypto-keys/decodeUTXO.mjs +45 -45
- package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
- package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +28 -27
- package/data-structures/crypto-keys/keys.cjs +1 -1
- package/data-structures/crypto-keys/keys.d.ts +2 -3
- package/data-structures/crypto-keys/keys.mjs +56 -57
- package/data-structures/event-service/evm/AbstractEventService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractEventService.mjs +14 -14
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.d.ts +2 -3
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.mjs +5 -4
- package/data-structures/event-service/evm/AbstractSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractSnapshotService.mjs +6 -3
- package/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.d.ts +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.mjs +22 -18
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.mjs +2 -2
- package/data-structures/presale/PresaleContractWrapper.cjs +1 -1
- package/data-structures/presale/PresaleContractWrapper.d.ts +3 -3
- package/data-structures/presale/PresaleContractWrapper.mjs +10 -10
- package/data-structures/provider-adapter/IProviderAdapter.d.ts +7 -7
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.mjs +16 -14
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +7 -5
- package/error-handling/get-error.message.cjs +1 -1
- package/error-handling/get-error.message.mjs +2 -3
- package/functions/kyc/zkMeHelper.cjs +1 -1
- package/functions/kyc/zkMeHelper.mjs +3 -3
- package/functions/pre-transaction/getFlatFees.cjs +1 -1
- package/functions/pre-transaction/getFlatFees.mjs +2 -3
- package/functions/pre-transaction/getSolanaCalldataHash.cjs +1 -1
- package/functions/pre-transaction/getSolanaCalldataHash.mjs +21 -21
- package/functions/pre-transaction/getVolatileTransferAmount.cjs +1 -1
- package/functions/pre-transaction/getVolatileTransferAmount.mjs +2 -3
- package/functions/pre-transaction/interaction-to-action.cjs +1 -1
- package/functions/pre-transaction/interaction-to-action.mjs +2 -3
- package/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.helpers.d.ts +6 -7
- package/functions/private-wallet/emporium.helpers.mjs +104 -105
- package/functions/private-wallet/emporium.swap.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.swap.helpers.mjs +44 -43
- package/functions/private-wallet/opProducer.cjs +1 -1
- package/functions/private-wallet/opProducer.mjs +1 -1
- package/functions/snarkjs/common.snarkjs.cjs +1 -1
- package/functions/snarkjs/common.snarkjs.mjs +21 -18
- package/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/functions/snarkjs/constructSolanaZkProof.mjs +11 -12
- package/functions/utils/addresses.cjs +1 -1
- package/functions/utils/addresses.mjs +6 -6
- package/functions/utils/cacheFunctions.cjs +1 -1
- package/functions/utils/cacheFunctions.d.ts +1 -1
- package/functions/utils/cacheFunctions.mjs +55 -54
- package/functions/utils/convertEmporiumOpToCallInfo.cjs +1 -1
- package/functions/utils/convertEmporiumOpToCallInfo.mjs +5 -5
- package/functions/utils/create-provider.cjs +1 -1
- package/functions/utils/create-provider.d.ts +2 -2
- package/functions/utils/create-provider.mjs +5 -5
- package/functions/utils/encryptInputForEnclave.cjs +1 -1
- package/functions/utils/encryptInputForEnclave.mjs +9 -9
- package/functions/utils/ethers-formatter.utils.d.ts +1 -1
- package/functions/utils/external-action.utils.cjs +1 -1
- package/functions/utils/external-action.utils.mjs +2 -2
- package/functions/utils/getContractAddress.cjs +1 -0
- package/functions/utils/getContractAddress.d.ts +2 -0
- package/functions/utils/getContractAddress.mjs +9 -0
- package/functions/utils/getDataFromTransaction.cjs +1 -1
- package/functions/utils/getDataFromTransaction.d.ts +0 -11
- package/functions/utils/getDataFromTransaction.mjs +26 -50
- package/functions/utils/getRecipientInfoFromUserKeys.cjs +1 -1
- package/functions/utils/getRecipientInfoFromUserKeys.mjs +1 -1
- package/functions/utils/getSignerFromContract.cjs +1 -0
- package/functions/utils/getSignerFromContract.d.ts +3 -0
- package/functions/utils/getSignerFromContract.mjs +16 -0
- package/functions/utils/getUtxosFromReceipt.utils.cjs +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.d.ts +1 -1
- package/functions/utils/getUtxosFromReceipt.utils.mjs +15 -16
- package/functions/utils/inLogicMetadata.cjs +1 -1
- package/functions/utils/inLogicMetadata.mjs +2 -2
- package/functions/utils/nftTokenFunctions.cjs +1 -1
- package/functions/utils/nftTokenFunctions.mjs +2 -3
- package/functions/utils/publicBalance.utils.cjs +1 -1
- package/functions/utils/publicBalance.utils.d.ts +1 -1
- package/functions/utils/publicBalance.utils.mjs +42 -42
- package/functions/utils/rpc-int-encode.cjs +1 -1
- package/functions/utils/rpc-int-encode.d.ts +1 -2
- package/functions/utils/rpc-int-encode.mjs +3 -6
- package/functions/utils/solanaMint.utils.cjs +1 -1
- package/functions/utils/solanaMint.utils.mjs +6 -6
- package/functions/web3/EIP-712.cjs +1 -1
- package/functions/web3/EIP-712.d.ts +4 -4
- package/functions/web3/EIP-712.mjs +1 -1
- package/functions/web3/etherFunctions.cjs +1 -1
- package/functions/web3/etherFunctions.mjs +32 -29
- package/functions/web3/events/balanceChangedCustomHandler.cjs +1 -1
- package/functions/web3/events/balanceChangedCustomHandler.mjs +4 -5
- package/functions/web3/events/balanceChangedHandler.cjs +1 -1
- package/functions/web3/events/balanceChangedHandler.mjs +2 -3
- package/functions/web3/events/getApprovedBalance.cjs +1 -1
- package/functions/web3/events/getApprovedBalance.mjs +1 -1
- package/functions/web3/events/getInputUtxosEnclave.cjs +1 -1
- package/functions/web3/events/getInputUtxosEnclave.mjs +20 -20
- package/functions/web3/events/getTransactionLogEvents.cjs +1 -1
- package/functions/web3/events/getTransactionLogEvents.d.ts +3 -3
- package/functions/web3/events/getTransactionLogEvents.mjs +6 -5
- package/functions/web3/events/index.d.ts +0 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.d.ts +1 -2
- package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +4 -5
- package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
- package/functions/web3/functionCalls/accessTokenCalls.mjs +10 -11
- package/functions/web3/functionCalls/approveToken.cjs +1 -1
- package/functions/web3/functionCalls/approveToken.mjs +61 -58
- package/functions/web3/functionCalls/constructBatchCall.cjs +1 -1
- package/functions/web3/functionCalls/constructBatchCall.d.ts +2 -2
- package/functions/web3/functionCalls/constructBatchCall.mjs +10 -9
- package/functions/web3/functionCalls/estimateGasRelayer.cjs +1 -1
- package/functions/web3/functionCalls/estimateGasRelayer.mjs +1 -1
- package/functions/web3/functionCalls/inHinkalApprovalCalls.cjs +1 -1
- package/functions/web3/functionCalls/inHinkalApprovalCalls.mjs +18 -21
- package/functions/web3/functionCalls/recoverTransactionFromError.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +38 -34
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.mjs +8 -10
- package/functions/web3/getContractMetadata.cjs +1 -1
- package/functions/web3/getContractMetadata.d.ts +1 -1
- package/functions/web3/getContractMetadata.mjs +25 -25
- package/functions/web3/getPublicAddressBalance.cjs +1 -1
- package/functions/web3/getPublicAddressBalance.mjs +7 -6
- package/functions/web3/getTokenHolder.cjs +1 -1
- package/functions/web3/getTokenHolder.mjs +16 -15
- package/functions/web3/odosAPI.cjs +1 -1
- package/functions/web3/odosAPI.mjs +6 -7
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.mjs +2 -3
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.d.ts +6 -5
- package/functions/web3/runContractFunction.mjs +41 -45
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.d.ts +2 -2
- package/functions/web3/uniswapAPI.mjs +23 -24
- package/index.cjs +1 -1
- package/index.mjs +336 -340
- package/package.json +3 -4
- package/providers/CustomEthersProvider.d.ts +1 -1
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.d.ts +7 -7
- package/providers/EthersProviderAdapter.mjs +46 -44
- package/providers/SolanaProviderAdapter.d.ts +1 -1
- package/providers/WagmiProviderAdapter.cjs +1 -1
- package/providers/WagmiProviderAdapter.d.ts +5 -5
- package/providers/WagmiProviderAdapter.mjs +37 -33
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.d.ts +2 -2
- package/providers/prepareEthersHinkal.mjs +3 -5
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +3 -5
- package/types/activities.types.d.ts +2 -3
- package/types/big-intable.types.d.ts +3 -2
- package/types/ethereum-network.types.d.ts +10 -10
- package/types/transactions.types.cjs +1 -1
- package/types/transactions.types.d.ts +2 -3
- package/types/transactions.types.mjs +6 -7
- package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLogic.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLogic.mjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
- package/functions/web3/events/web3RetrieveEvents.cjs +0 -1
- package/functions/web3/events/web3RetrieveEvents.d.ts +0 -14
- package/functions/web3/events/web3RetrieveEvents.mjs +0 -9
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { saveDepths as e } from "../../../constants/save-depths.mjs";
|
|
2
2
|
import { AbstractEventService as a } from "./AbstractEventService.mjs";
|
|
3
|
-
|
|
3
|
+
import { getProviderFromContract as o } from "../../../functions/utils/getSignerFromContract.mjs";
|
|
4
|
+
class n extends a {
|
|
4
5
|
savedLatestBlockNumber = 0;
|
|
5
6
|
chainId = 0;
|
|
6
7
|
constructor(t, s) {
|
|
7
8
|
super(t, s);
|
|
8
9
|
}
|
|
9
10
|
async init() {
|
|
10
|
-
await this.loadSnapshot()
|
|
11
|
+
await this.loadSnapshot();
|
|
12
|
+
const t = o(this.blockchainEventEmitter.contract);
|
|
13
|
+
this.chainId = Number((await t.getNetwork()).chainId);
|
|
11
14
|
}
|
|
12
15
|
async retrieveEventsFromLatestBlock() {
|
|
13
16
|
await this.blockchainEventEmitter.retrieveEvents(this.latestBlockNumber);
|
|
@@ -29,5 +32,5 @@ class c extends a {
|
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
export {
|
|
32
|
-
|
|
35
|
+
n as AbstractSnapshotService
|
|
33
36
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("ethers"),y=require("../../../constants/reorg-depths.constants.cjs"),h=require("../../../functions/utils/resolve-sync.utils.cjs"),f=require("../../../functions/utils/mutexes.utils.cjs"),d=require("../../../functions/utils/getSignerFromContract.cjs");class E{contract;depositOnChainUtxosContract;_latestBlockNumber;_initialBlockNumber;onEventsProcessed;eventProcessors=new Set;maxPageSize;isReady=!1;isServer;intervalId;inProgress;eventsFetchingMutex;constructor(e,r,u,s,i,a=f.balanceFetchingMutex){this.contract=e,this.depositOnChainUtxosContract=i,this._initialBlockNumber=r,this.maxPageSize=s,this.isServer=u,this.inProgress=!1,this.eventsFetchingMutex=a}get latestBlockNumber(){return this._latestBlockNumber??this._initialBlockNumber}syncFromAtMost(e){(this._latestBlockNumber===void 0||e<this._latestBlockNumber)&&(this._latestBlockNumber=e)}intervalClear(){this.isReady=!1,this.eventProcessors=new Set,clearInterval(this.intervalId)}async init(){if(this.isReady)throw new Error("Already initialized");this.isReady=!0,await this.retrieveEvents(this.latestBlockNumber+1),this.intervalId=setInterval(async()=>{await this.retrieveEvents(this.latestBlockNumber)},3500)}requireReady(){if(!this.isReady)throw new Error("Not ready")}addEventProcessorFunction(e){if(this.isReady)throw new Error("Can't add event processor after event emitter initialized");this.eventProcessors.add(e)}async getLastBlockNumberForEventRequest(){const e=await d.getProviderFromContract(this.contract).getBlockNumber();if(!this.isServer)return e;const{chainId:r}=await d.getProviderFromContract(this.contract).getNetwork();return Math.max(this.latestBlockNumber,e-y.blockReorgDepth[Number(r)]+1)}async retrieveEvents(e,r=!1){return this.requireReady(),await this.eventsFetchingMutex.runExclusive(async()=>{try{if(this.inProgress&&!r)return!1;this.inProgress=!0;let s=0;const i=await this.getLastBlockNumberForEventRequest();if(i<e)return this.inProgress=!1,!1;const a=h.getSequence(e,i,this.maxPageSize),o=[];if(await h.resolveSync(a.map(({from:t,to:n})=>async()=>{const c=(await this.contract.queryFilter("*",t,n)).filter(l=>l instanceof v.ethers.EventLog);o.push(...c)})),this.depositOnChainUtxosContract){const{depositOnChainUtxosContract:t}=this;await h.resolveSync(a.map(({from:n,to:c})=>async()=>{const l=(await t.queryFilter("*",n,c)).filter(g=>g instanceof v.ethers.EventLog);o.push(...l)}))}const m=await Promise.all([...this.eventProcessors].map(t=>t(o)));return this._latestBlockNumber=i,s+=m.reduce((t,n)=>t+n,0),this.onEventsProcessed?.(s),this.inProgress=!1,!0}catch(s){return console.log("retrieveEvents error:",{err:s}),this.inProgress=!1,!1}})}}exports.BlockchainEventEmitter=E;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import { Mutex } from 'async-mutex';
|
|
3
|
-
export type EventProcessorFunction = (events: ethers.
|
|
3
|
+
export type EventProcessorFunction = (events: ethers.EventLog[]) => Promise<number> | number;
|
|
4
4
|
export declare class BlockchainEventEmitter {
|
|
5
5
|
readonly contract: ethers.Contract;
|
|
6
6
|
readonly depositOnChainUtxosContract?: ethers.Contract;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { ethers as u } from "ethers";
|
|
2
|
+
import { blockReorgDepth as g } from "../../../constants/reorg-depths.constants.mjs";
|
|
3
|
+
import { getSequence as y, resolveSync as v } from "../../../functions/utils/resolve-sync.utils.mjs";
|
|
4
|
+
import { balanceFetchingMutex as E } from "../../../functions/utils/mutexes.utils.mjs";
|
|
5
|
+
import { getProviderFromContract as m } from "../../../functions/utils/getSignerFromContract.mjs";
|
|
6
|
+
class b {
|
|
5
7
|
contract;
|
|
6
8
|
depositOnChainUtxosContract;
|
|
7
9
|
_latestBlockNumber;
|
|
@@ -15,8 +17,8 @@ class w {
|
|
|
15
17
|
inProgress;
|
|
16
18
|
// to remove race conditions
|
|
17
19
|
eventsFetchingMutex;
|
|
18
|
-
constructor(t, r,
|
|
19
|
-
this.contract = t, this.depositOnChainUtxosContract = i, this._initialBlockNumber = r, this.maxPageSize = s, this.isServer =
|
|
20
|
+
constructor(t, r, h, s, i, n = E) {
|
|
21
|
+
this.contract = t, this.depositOnChainUtxosContract = i, this._initialBlockNumber = r, this.maxPageSize = s, this.isServer = h, this.inProgress = !1, this.eventsFetchingMutex = n;
|
|
20
22
|
}
|
|
21
23
|
get latestBlockNumber() {
|
|
22
24
|
return this._latestBlockNumber ?? this._initialBlockNumber;
|
|
@@ -44,11 +46,11 @@ class w {
|
|
|
44
46
|
this.eventProcessors.add(t);
|
|
45
47
|
}
|
|
46
48
|
async getLastBlockNumberForEventRequest() {
|
|
47
|
-
const t = await this.contract.
|
|
49
|
+
const t = await m(this.contract).getBlockNumber();
|
|
48
50
|
if (!this.isServer)
|
|
49
51
|
return t;
|
|
50
|
-
const { chainId: r } = await this.contract.
|
|
51
|
-
return Math.max(this.latestBlockNumber, t -
|
|
52
|
+
const { chainId: r } = await m(this.contract).getNetwork();
|
|
53
|
+
return Math.max(this.latestBlockNumber, t - g[Number(r)] + 1);
|
|
52
54
|
}
|
|
53
55
|
async retrieveEvents(t, r = !1) {
|
|
54
56
|
return this.requireReady(), await this.eventsFetchingMutex.runExclusive(async () => {
|
|
@@ -60,25 +62,27 @@ class w {
|
|
|
60
62
|
const i = await this.getLastBlockNumberForEventRequest();
|
|
61
63
|
if (i < t)
|
|
62
64
|
return this.inProgress = !1, !1;
|
|
63
|
-
const n =
|
|
64
|
-
if (await
|
|
65
|
+
const n = y(t, i, this.maxPageSize), o = [];
|
|
66
|
+
if (await v(
|
|
65
67
|
n.map(({ from: e, to: a }) => async () => {
|
|
66
|
-
const c = await this.contract.queryFilter("*", e, a)
|
|
68
|
+
const c = (await this.contract.queryFilter("*", e, a)).filter(
|
|
69
|
+
(l) => l instanceof u.EventLog
|
|
70
|
+
);
|
|
67
71
|
o.push(...c);
|
|
68
72
|
})
|
|
69
73
|
), this.depositOnChainUtxosContract) {
|
|
70
74
|
const { depositOnChainUtxosContract: e } = this;
|
|
71
|
-
await
|
|
75
|
+
await v(
|
|
72
76
|
n.map(({ from: a, to: c }) => async () => {
|
|
73
|
-
const
|
|
74
|
-
o.push(...
|
|
77
|
+
const l = (await e.queryFilter("*", a, c)).filter((f) => f instanceof u.EventLog);
|
|
78
|
+
o.push(...l);
|
|
75
79
|
})
|
|
76
80
|
);
|
|
77
81
|
}
|
|
78
|
-
const
|
|
82
|
+
const d = await Promise.all(
|
|
79
83
|
[...this.eventProcessors].map((e) => e(o))
|
|
80
84
|
);
|
|
81
|
-
return this._latestBlockNumber = i, s +=
|
|
85
|
+
return this._latestBlockNumber = i, s += d.reduce((e, a) => e + a, 0), this.onEventsProcessed?.(s), this.inProgress = !1, !0;
|
|
82
86
|
} catch (s) {
|
|
83
87
|
return console.log("retrieveEvents error:", { err: s }), this.inProgress = !1, !1;
|
|
84
88
|
}
|
|
@@ -86,5 +90,5 @@ class w {
|
|
|
86
90
|
}
|
|
87
91
|
}
|
|
88
92
|
export {
|
|
89
|
-
|
|
93
|
+
b as BlockchainEventEmitter
|
|
90
94
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("ethers"),i=require("../../../functions/utils/amounts.utils.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("ethers"),i=require("../../../functions/utils/amounts.utils.cjs"),s=require("./AbstractSolanaSnapshotService.cjs");class n extends s.AbstractSolanaSnapshotService{constructor(e){super(e,"Nullified")}_nullifiers;get nullifiers(){return this._nullifiers}serializeSnapshot(e){return{nullifiers:Array.from(e.payload.nullifiers).map(r=>r.toString()),latestBlockNumber:e.latestBlockNumber}}deserializeSnapshot(e){return{latestBlockNumber:e.latestBlockNumber??0,payload:{nullifiers:new Set(e.nullifiers??[])}}}acceptEvent(e,r){try{return this._nullifiers.has(e.nullifier)?!1:(this._nullifiers.add(e.nullifier),!0)}catch(l){return console.error(l),!1}}mapEvent(e){return{nullifier:t.ethers.toBeHex(i.advancedToBigInt(e.nullifier))}}getSnapshotPayload(){return{nullifiers:this._nullifiers}}populateSnapshot({payload:{nullifiers:e}}){this._nullifiers=e}}exports.AbstractSolanaNullifierSnapshotService=n;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ethers as i } from "ethers";
|
|
2
2
|
import { advancedToBigInt as t } from "../../../functions/utils/amounts.utils.mjs";
|
|
3
3
|
import { AbstractSolanaSnapshotService as n } from "./AbstractSolanaSnapshotService.mjs";
|
|
4
4
|
class f extends n {
|
|
@@ -32,7 +32,7 @@ class f extends n {
|
|
|
32
32
|
}
|
|
33
33
|
mapEvent(r) {
|
|
34
34
|
return {
|
|
35
|
-
nullifier: i.
|
|
35
|
+
nullifier: i.toBeHex(t(r.nullifier))
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
getSnapshotPayload() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../constants/presale.constants.cjs"),n=require("ethers");class o{contract;eventsFrom;constructor(t,e){const{address:r,eventsFrom:a}=s.presaleContractInfoByChain[e];this.contract=new n.ethers.Contract(r,s.presaleABI,t),this.eventsFrom=a}deposit(t,e,r){return this.contract.deposit(t.erc20TokenAddress,e,r)}withdraw(t,e){return this.contract.withdraw(t,e)}moveToNextStage(t){return this.contract.moveToNextStage(t||{})}async estimateMoveToNextStageGas(){return this.contract.moveToNextStage.estimateGas()}async getTotalDeposit(){return await this.contract.totalDeposit()}async getDeposits(t,e){return await this.contract.deposits(t,e.erc20TokenAddress)}async getTotalHINK(t){return await this.contract.totalHINK(t)}async getCurrentPresaleStageIndex(){const t=await this.contract.currentPresaleStageIndex();return Number(t)}async getCurrentMaxDepositAmount(){return await this.contract.currentMaxDepositAmount()}async currentPresaleStage(){const[t,e]=await this.contract.currentPresaleStage(),[r,a]=[t,e].map(BigInt);return{amountToRaise:r,priceMultiplier:a}}async calculateHINK(t){return await this.contract.calculateHINK(t)}async queryDeposits(){return this.contract.queryFilter(this.contract.filters.Deposit(),this.eventsFrom)}onEvent(t,e){this.contract.on(t,e)}}exports.PresaleContractWrapper=o;
|
|
@@ -3,7 +3,7 @@ import { ethers } from 'ethers';
|
|
|
3
3
|
export declare class PresaleContractWrapper {
|
|
4
4
|
contract: ethers.Contract;
|
|
5
5
|
eventsFrom: number;
|
|
6
|
-
constructor(signerOrProvider: ethers.Signer | ethers.
|
|
6
|
+
constructor(signerOrProvider: ethers.Signer | ethers.Provider, chainId: number);
|
|
7
7
|
deposit(token: ERC20Token, amount: bigint, minHINK: bigint): Promise<ethers.ContractTransaction>;
|
|
8
8
|
withdraw(token: string, amount: bigint): Promise<ethers.ContractTransaction>;
|
|
9
9
|
moveToNextStage(overrides?: ethers.Overrides): Promise<ethers.ContractTransaction>;
|
|
@@ -18,6 +18,6 @@ export declare class PresaleContractWrapper {
|
|
|
18
18
|
priceMultiplier: bigint;
|
|
19
19
|
}>;
|
|
20
20
|
calculateHINK(amount: bigint): Promise<bigint>;
|
|
21
|
-
queryDeposits(): Promise<ethers.
|
|
22
|
-
onEvent(eventName: string, handleEvent: ethers.
|
|
21
|
+
queryDeposits(): Promise<(ethers.Log | ethers.EventLog)[]>;
|
|
22
|
+
onEvent(eventName: string, handleEvent: ethers.Listener): void;
|
|
23
23
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { presaleContractInfoByChain as
|
|
2
|
-
import { ethers as
|
|
1
|
+
import { presaleContractInfoByChain as s, presaleABI as n } from "../../constants/presale.constants.mjs";
|
|
2
|
+
import { ethers as o } from "ethers";
|
|
3
3
|
class l {
|
|
4
4
|
contract;
|
|
5
5
|
eventsFrom;
|
|
6
6
|
constructor(t, e) {
|
|
7
|
-
const { address: r, eventsFrom: a } =
|
|
8
|
-
this.contract = new
|
|
7
|
+
const { address: r, eventsFrom: a } = s[e];
|
|
8
|
+
this.contract = new o.Contract(r, n, t), this.eventsFrom = a;
|
|
9
9
|
}
|
|
10
10
|
deposit(t, e, r) {
|
|
11
11
|
return this.contract.deposit(t.erc20TokenAddress, e, r);
|
|
@@ -17,30 +17,30 @@ class l {
|
|
|
17
17
|
return this.contract.moveToNextStage(t || {});
|
|
18
18
|
}
|
|
19
19
|
async estimateMoveToNextStageGas() {
|
|
20
|
-
return
|
|
20
|
+
return this.contract.moveToNextStage.estimateGas();
|
|
21
21
|
}
|
|
22
22
|
async getTotalDeposit() {
|
|
23
|
-
return
|
|
23
|
+
return await this.contract.totalDeposit();
|
|
24
24
|
}
|
|
25
25
|
async getDeposits(t, e) {
|
|
26
|
-
return
|
|
26
|
+
return await this.contract.deposits(t, e.erc20TokenAddress);
|
|
27
27
|
}
|
|
28
28
|
async getTotalHINK(t) {
|
|
29
|
-
return
|
|
29
|
+
return await this.contract.totalHINK(t);
|
|
30
30
|
}
|
|
31
31
|
async getCurrentPresaleStageIndex() {
|
|
32
32
|
const t = await this.contract.currentPresaleStageIndex();
|
|
33
33
|
return Number(t);
|
|
34
34
|
}
|
|
35
35
|
async getCurrentMaxDepositAmount() {
|
|
36
|
-
return
|
|
36
|
+
return await this.contract.currentMaxDepositAmount();
|
|
37
37
|
}
|
|
38
38
|
async currentPresaleStage() {
|
|
39
39
|
const [t, e] = await this.contract.currentPresaleStage(), [r, a] = [t, e].map(BigInt);
|
|
40
40
|
return { amountToRaise: r, priceMultiplier: a };
|
|
41
41
|
}
|
|
42
42
|
async calculateHINK(t) {
|
|
43
|
-
return
|
|
43
|
+
return await this.contract.calculateHINK(t);
|
|
44
44
|
}
|
|
45
45
|
async queryDeposits() {
|
|
46
46
|
return this.contract.queryFilter(this.contract.filters.Deposit(), this.eventsFrom);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ContractMetadata, ContractType, EthereumNetwork } from '../../types/ethereum-network.types';
|
|
2
|
-
import {
|
|
2
|
+
import { ethers } from 'ethers';
|
|
3
3
|
import { Call } from '../../types/eip5792.types';
|
|
4
4
|
export interface ChainEventListener {
|
|
5
5
|
onAccountChanged(): void;
|
|
@@ -8,7 +8,7 @@ export interface ChainEventListener {
|
|
|
8
8
|
export interface IProviderAdapter<ConnectorType = unknown> {
|
|
9
9
|
chainId: number | undefined;
|
|
10
10
|
initConnector(connector: ConnectorType): void;
|
|
11
|
-
initSigner?(signer: Signer): void;
|
|
11
|
+
initSigner?(signer: ethers.Signer): void;
|
|
12
12
|
init(chainId?: number): Promise<void>;
|
|
13
13
|
initConfig?(config?: any): Promise<void> | void;
|
|
14
14
|
connectToConnector(connector: ConnectorType): Promise<number>;
|
|
@@ -22,10 +22,10 @@ export interface IProviderAdapter<ConnectorType = unknown> {
|
|
|
22
22
|
release(): void;
|
|
23
23
|
getContractMetadata(contractType: ContractType, chainId?: number): ContractMetadata;
|
|
24
24
|
getContract(contractType: ContractType, contractAddress?: string, chainId?: number): ethers.Contract;
|
|
25
|
-
getContractWithSigner(contract: ContractType, contractAddress?: string): Contract;
|
|
26
|
-
getContractWithFetcher(contract: ContractType, contractAddress?: string): Contract;
|
|
27
|
-
getContractWithFetcherForEthereum(contract: ContractType, contractAddress?: string): Contract;
|
|
28
|
-
sendTransaction(tx: ethers.
|
|
25
|
+
getContractWithSigner(contract: ContractType, contractAddress?: string): ethers.Contract;
|
|
26
|
+
getContractWithFetcher(contract: ContractType, contractAddress?: string): ethers.Contract;
|
|
27
|
+
getContractWithFetcherForEthereum(contract: ContractType, contractAddress?: string): ethers.Contract;
|
|
28
|
+
sendTransaction(tx: ethers.TransactionRequest): Promise<ethers.TransactionResponse>;
|
|
29
29
|
switchNetwork(network: EthereumNetwork): Promise<unknown>;
|
|
30
30
|
switchAccount(signer: ethers.Signer): Promise<void>;
|
|
31
31
|
onAccountChanged(): Promise<unknown>;
|
|
@@ -33,6 +33,6 @@ export interface IProviderAdapter<ConnectorType = unknown> {
|
|
|
33
33
|
isPermitterAvailable(): boolean;
|
|
34
34
|
getGasPrice(): Promise<bigint>;
|
|
35
35
|
signTypedData(domain: ethers.TypedDataDomain, types: Record<string, ethers.TypedDataField[]>, value: Record<string, unknown>): Promise<string>;
|
|
36
|
-
sendBatchCallsTransaction?(calls: Call[]): Promise<ethers.
|
|
36
|
+
sendBatchCallsTransaction?(calls: Call[]): Promise<ethers.TransactionResponse>;
|
|
37
37
|
supportsBatchCall?(): Promise<boolean>;
|
|
38
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../event-service/evm/AbstractAccessTokenSnapshotService.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("../../../functions/utils/getSignerFromContract.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");const o=require("../SnapshotFetcherService.cjs"),n=require("../../../functions/utils/getContractAddress.cjs");class a extends c.AbstractAccessTokenSnapshotService{snapshotsService;constructor(e,s){super(e),this.snapshotsService=s}async fetchSnapshot(){const{contract:e}=this.blockchainEventEmitter,{chainId:s}=await i.getProviderFromContract(e).getNetwork(),t=Number(s);this.snapshotsService||(this.snapshotsService=new o.SnapshotFetcherService(t,n.getContractAddress(e)));const r=await this.snapshotsService.getAccessTokens();if(r.accessTokenContractAddress!==n.getContractAddress(e)||r.chainId!==t)throw Error("Commitment Snapshot: incorrect contract or chain id");return{latestBlockNumber:r.latestBlockNumber,merkleTree:r.merkleTree,senderAddresses:r.senderAddresses,senderAddressIndexMap:r.senderAddressIndexMap}}persistSnapshot(e){return Promise.resolve()}}exports.ClientAccessTokenSnapshotService=a;
|
|
@@ -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;
|