@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,32 +1,29 @@
|
|
|
1
|
-
import { ContractType as
|
|
2
|
-
const l = async (
|
|
3
|
-
const
|
|
4
|
-
if (!
|
|
1
|
+
import { ContractType as c } from "../../../types/ethereum-network.types.mjs";
|
|
2
|
+
const l = async (t, a) => {
|
|
3
|
+
const n = await t.getContractWithFetcher(c.HinkalContract).getInteractionApprovals.staticCall(a);
|
|
4
|
+
if (!n)
|
|
5
5
|
throw Error("getInteractionApprovals fail: no approved utxos fetched");
|
|
6
|
-
return
|
|
7
|
-
const
|
|
6
|
+
return n.map((r) => {
|
|
7
|
+
const o = r;
|
|
8
8
|
return {
|
|
9
|
-
amount:
|
|
10
|
-
inHinkalAddress:
|
|
11
|
-
tokenAddress:
|
|
9
|
+
amount: o.amount,
|
|
10
|
+
inHinkalAddress: o.inHinkalAddress,
|
|
11
|
+
tokenAddress: o.tokenAddress
|
|
12
12
|
};
|
|
13
13
|
});
|
|
14
|
-
}, p = async (
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
a
|
|
18
|
-
);
|
|
19
|
-
if (t === void 0)
|
|
14
|
+
}, p = async (t, a, e) => {
|
|
15
|
+
const n = t.getContractWithFetcher(c.HinkalContract), i = t.getContractWithFetcher(c.ERC20Contract, a), r = await n.getAddress(), o = await i.allowance.staticCall(r, e);
|
|
16
|
+
if (o === void 0)
|
|
20
17
|
throw Error("checkExistingApprovalFromHinkal Error, no allowance fetched");
|
|
21
|
-
return
|
|
22
|
-
},
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
18
|
+
return o;
|
|
19
|
+
}, d = async (t, a, e, n) => {
|
|
20
|
+
const r = await t.getContractWithFetcher(c.HinkalContract).getBufferEntry.staticCall(a, e, n);
|
|
21
|
+
if (r === void 0)
|
|
25
22
|
throw Error("getBufferEntry Fail: No amount fatched");
|
|
26
|
-
return
|
|
23
|
+
return r;
|
|
27
24
|
};
|
|
28
25
|
export {
|
|
29
26
|
p as checkExistingApprovalFromHinkal,
|
|
30
|
-
|
|
27
|
+
d as getBufferEntry,
|
|
31
28
|
l as getInteractionApprovals
|
|
32
29
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
|
-
export declare const recoverTransactionFromError: (provider: ethers.
|
|
2
|
+
export declare const recoverTransactionFromError: (provider: ethers.Provider, transactionHash: string, confirmations?: number) => Promise<ethers.TransactionResponse | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../../constants/protocol.constants.cjs"),I=require("../../../types/ethereum-network.types.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("ethers"),f=require("../../../constants/protocol.constants.cjs"),I=require("../../../types/ethereum-network.types.cjs"),S=require("../../utils/time.utils.cjs"),F=require("./approveTokensToHinkal.cjs"),N=require("./constructBatchCall.cjs"),_=require("./recoverTransactionFromError.cjs"),z=require("../../utils/getContractAddress.cjs"),G=async(r,d,l,s,p,A,q,x)=>{const n=Array.isArray(d)?d:[d],e=Array.isArray(l)?l:[l];if(n.length!==e.length)throw new Error("token and amount length mismatch");const w=r.getContractWithSigner(I.ContractType.HinkalContract),b=await r.getEthereumAddress(),v=q??w,a=x??w,m="transact",C=e.findIndex(({erc20TokenAddress:t})=>t===f.zeroAddress),k=e.some(({erc20TokenAddress:t})=>t!==f.zeroAddress),h=C===-1?0n:n[C],g=r.getProviderAdapter();if(k&&await g.supportsBatchCall?.()&&g.sendBatchCallsTransaction){const t=e.map(B=>B.erc20TokenAddress),i=await N.buildApproveAndTransactCalls(t,n,z.getContractAddress(v),a,s,A,p,h);return await g.sendBatchCallsTransaction(i)}await F.approveTokensToHinkal(r,v,e,n);const T={value:h>0n?BigInt(h).toString():void 0};let o;const y=[s[0],s[1],s[2],A,p,{...T,from:b}],{runner:c}=a;if(!(c instanceof E.ethers.AbstractSigner))throw new Error("expected signer");try{o=Number(await a[m].estimateGas(...y)),console.log({gasCosts:o}),console.log({signerAddress:await c.getAddress(),chainIdHinkal:r.getCurrentChainId(),ethersNetwork:await c.provider.getNetwork()})}catch(t){console.log("hinkalDeposit: gas estimation error",{err:t})}const H=o&&o>=0?Math.ceil(o*12/10):void 0;T.gasLimit=H,await S.waitLittle();let u;try{u=await a[m](...y)}catch(t){if(!t?.transactionHash)throw t;const i=await _.recoverTransactionFromError(c.provider,t.transactionHash);if(!i)throw t;u=i}return u};exports.transactCallDirect=G;
|
|
@@ -1,64 +1,68 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { ethers as k } from "ethers";
|
|
2
|
+
import { zeroAddress as T } from "../../../constants/protocol.constants.mjs";
|
|
3
|
+
import { ContractType as F } from "../../../types/ethereum-network.types.mjs";
|
|
4
|
+
import { waitLittle as N } from "../../utils/time.utils.mjs";
|
|
5
|
+
import { approveTokensToHinkal as S } from "./approveTokensToHinkal.mjs";
|
|
5
6
|
import { buildApproveAndTransactCalls as G } from "./constructBatchCall.mjs";
|
|
6
7
|
import { recoverTransactionFromError as L } from "./recoverTransactionFromError.mjs";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
import { getContractAddress as z } from "../../utils/getContractAddress.mjs";
|
|
9
|
+
const R = async (r, d, m, s, g, A, y, H) => {
|
|
10
|
+
const n = Array.isArray(d) ? d : [d], o = Array.isArray(m) ? m : [m];
|
|
11
|
+
if (n.length !== o.length)
|
|
10
12
|
throw new Error("token and amount length mismatch");
|
|
11
|
-
const
|
|
12
|
-
if (
|
|
13
|
-
const t =
|
|
13
|
+
const w = r.getContractWithSigner(F.HinkalContract), I = await r.getEthereumAddress(), f = y ?? w, a = H ?? w, v = "transact", C = o.findIndex(({ erc20TokenAddress: t }) => t === T), b = o.some(({ erc20TokenAddress: t }) => t !== T), l = C === -1 ? 0n : n[C], p = r.getProviderAdapter();
|
|
14
|
+
if (b && await p.supportsBatchCall?.() && p.sendBatchCallsTransaction) {
|
|
15
|
+
const t = o.map((E) => E.erc20TokenAddress), c = await G(
|
|
14
16
|
t,
|
|
15
17
|
n,
|
|
16
|
-
|
|
17
|
-
r,
|
|
18
|
+
z(f),
|
|
18
19
|
a,
|
|
20
|
+
s,
|
|
19
21
|
A,
|
|
20
22
|
g,
|
|
21
|
-
|
|
23
|
+
l
|
|
22
24
|
);
|
|
23
|
-
return await
|
|
25
|
+
return await p.sendBatchCallsTransaction(c);
|
|
24
26
|
}
|
|
25
|
-
await
|
|
27
|
+
await S(r, f, o, n);
|
|
26
28
|
const u = {
|
|
27
|
-
value:
|
|
29
|
+
value: l > 0n ? BigInt(l).toString() : void 0
|
|
28
30
|
};
|
|
29
31
|
let e;
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const x = [
|
|
33
|
+
s[0],
|
|
34
|
+
s[1],
|
|
35
|
+
s[2],
|
|
34
36
|
A,
|
|
35
37
|
g,
|
|
36
38
|
{ ...u, from: I }
|
|
37
|
-
];
|
|
39
|
+
], { runner: i } = a;
|
|
40
|
+
if (!(i instanceof k.AbstractSigner))
|
|
41
|
+
throw new Error("expected signer");
|
|
38
42
|
try {
|
|
39
|
-
e = (await
|
|
40
|
-
signerAddress: await
|
|
41
|
-
chainIdHinkal:
|
|
42
|
-
ethersNetwork: await
|
|
43
|
+
e = Number(await a[v].estimateGas(...x)), console.log({ gasCosts: e }), console.log({
|
|
44
|
+
signerAddress: await i.getAddress(),
|
|
45
|
+
chainIdHinkal: r.getCurrentChainId(),
|
|
46
|
+
ethersNetwork: await i.provider.getNetwork()
|
|
43
47
|
});
|
|
44
48
|
} catch (t) {
|
|
45
49
|
console.log("hinkalDeposit: gas estimation error", { err: t });
|
|
46
50
|
}
|
|
47
|
-
const
|
|
48
|
-
u.gasLimit =
|
|
49
|
-
let
|
|
51
|
+
const B = e && e >= 0 ? Math.ceil(e * 12 / 10) : void 0;
|
|
52
|
+
u.gasLimit = B, await N();
|
|
53
|
+
let h;
|
|
50
54
|
try {
|
|
51
|
-
|
|
55
|
+
h = await a[v](...x);
|
|
52
56
|
} catch (t) {
|
|
53
57
|
if (!t?.transactionHash)
|
|
54
58
|
throw t;
|
|
55
|
-
const
|
|
56
|
-
if (!
|
|
59
|
+
const c = await L(i.provider, t.transactionHash);
|
|
60
|
+
if (!c)
|
|
57
61
|
throw t;
|
|
58
|
-
|
|
62
|
+
h = c;
|
|
59
63
|
}
|
|
60
|
-
return
|
|
64
|
+
return h;
|
|
61
65
|
};
|
|
62
66
|
export {
|
|
63
|
-
|
|
67
|
+
R as transactCallDirect
|
|
64
68
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../../error-handling/error-codes.constants.cjs");require("ethers");const y=require("../../../error-handling/customErrors/ErrorWithTx.cjs");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");const y=require("../../../error-handling/customErrors/ErrorWithTx.cjs");require("../../../types/circom-data.types.cjs");require("../../../types/activities.types.cjs");const R=require("../../../constants/server.constants.cjs");require("../../../API/getServerURL.cjs");const C=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");require("@solana/web3.js");require("../../../data-structures/crypto-keys/keys.cjs");const l=require("../../../API/callRelayer.cjs"),q=require("../../snarkjs/common.snarkjs.cjs");require("node-forge");require("../../../constants/token-data/index.cjs");require("idb-keyval");require("../../utils/convertIntegrationProviderToExternalActionId.cjs");const w=require("../../../API/getRelayerURL.cjs");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");require("multiformats");require("../../../API/tenderly.api.cjs");const m=r=>{if(r.status==="success")return r.message;throw r.message&&r.error?new y.ErrorWithRelayerTransaction(r.error,r.message):new Error(r.error)},D=async(r,a,t,i,c,s,n,o)=>{const e=q.serializeCircomData(i),u=await l.callRelayerTransactAPI(r,{a:a[0],b:a[1],c:a[2],dimData:t,circomData:e,withPrivateMempool:c,withUniswapWorkAround:s,authorizationData:n,adminData:o});return m(u)},T=async(r,a)=>{const t=await C.httpClient.post(`${w.getRelayerURL(r)}${R.RELAYER_CONFIG.SOLANA_TRANSACT}`,a);return m(t)},h=r=>{if(r.status==="success")return r.message.scheduleId;throw new Error(r.error||"Batch transaction failed")},d=async(r,a,t,i,c)=>{const s=a.map(e=>q.serializeCircomData(e.circomData)),n={transactions:a.map((e,u)=>({a:e.zkCallData[0],b:e.zkCallData[1],c:e.zkCallData[2],dimData:e.dimData,circomData:s[u],withPrivateMempool:e.withPrivateMempool,withUniswapWorkAround:e.withUniswapWorkAround,authorizationData:e.authorizationData,adminData:e.adminData})),txCompletionTime:i,hashedEthereumAddress:t,ref:c},o=await l.callRelayerTransactBatchAPI(r,n);return h(o)},A=async(r,a,t,i,c)=>{const s={transactions:a,hashedEthereumAddress:t,txCompletionTime:i,ref:c},n=await l.callRelayerSolanaTransactBatchAPI(r,s);return h(n)};exports.solanaTransactCallRelayer=T;exports.solanaTransactCallRelayerBatch=A;exports.transactCallRelayer=D;exports.transactCallRelayerBatch=d;
|
|
@@ -2,7 +2,6 @@ import "../../../error-handling/error-codes.constants.mjs";
|
|
|
2
2
|
import "ethers";
|
|
3
3
|
import { ErrorWithRelayerTransaction as u } from "../../../error-handling/customErrors/ErrorWithTx.mjs";
|
|
4
4
|
import "../../../types/circom-data.types.mjs";
|
|
5
|
-
import "../../../types/transactions.types.mjs";
|
|
6
5
|
import "../../../types/activities.types.mjs";
|
|
7
6
|
import { RELAYER_CONFIG as w } from "../../../constants/server.constants.mjs";
|
|
8
7
|
import "../../../API/getServerURL.mjs";
|
|
@@ -40,12 +39,11 @@ import "../../../constants/events.constants.mjs";
|
|
|
40
39
|
import "../../utils/userAgent.mjs";
|
|
41
40
|
import "multiformats";
|
|
42
41
|
import "../../../API/tenderly.api.mjs";
|
|
43
|
-
import "ethers-v6h";
|
|
44
42
|
const l = (t) => {
|
|
45
43
|
if (t.status === "success")
|
|
46
44
|
return t.message;
|
|
47
45
|
throw t.message && t.error ? new u(t.error, t.message) : new Error(t.error);
|
|
48
|
-
},
|
|
46
|
+
}, st = async (t, a, o, i, m, s, c, p) => {
|
|
49
47
|
const r = e(i), n = await d(t, {
|
|
50
48
|
a: a[0],
|
|
51
49
|
b: a[1],
|
|
@@ -58,7 +56,7 @@ const l = (t) => {
|
|
|
58
56
|
adminData: p
|
|
59
57
|
});
|
|
60
58
|
return l(n);
|
|
61
|
-
},
|
|
59
|
+
}, pt = async (t, a) => {
|
|
62
60
|
const o = await D.post(
|
|
63
61
|
`${f(t)}${w.SOLANA_TRANSACT}`,
|
|
64
62
|
a
|
|
@@ -68,7 +66,7 @@ const l = (t) => {
|
|
|
68
66
|
if (t.status === "success")
|
|
69
67
|
return t.message.scheduleId;
|
|
70
68
|
throw new Error(t.error || "Batch transaction failed");
|
|
71
|
-
},
|
|
69
|
+
}, nt = async (t, a, o, i, m) => {
|
|
72
70
|
const s = a.map(
|
|
73
71
|
(r) => e(r.circomData)
|
|
74
72
|
), c = {
|
|
@@ -88,7 +86,7 @@ const l = (t) => {
|
|
|
88
86
|
ref: m
|
|
89
87
|
}, p = await y(t, c);
|
|
90
88
|
return h(p);
|
|
91
|
-
},
|
|
89
|
+
}, et = async (t, a, o, i, m) => {
|
|
92
90
|
const c = await A(t, {
|
|
93
91
|
transactions: a,
|
|
94
92
|
hashedEthereumAddress: o,
|
|
@@ -98,8 +96,8 @@ const l = (t) => {
|
|
|
98
96
|
return h(c);
|
|
99
97
|
};
|
|
100
98
|
export {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
99
|
+
pt as solanaTransactCallRelayer,
|
|
100
|
+
et as solanaTransactCallRelayerBatch,
|
|
101
|
+
st as transactCallRelayer,
|
|
102
|
+
nt as transactCallRelayerBatch
|
|
105
103
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../../constants/contracts.constants.cjs"),c=require("../../constants/chains.constants.cjs"),u=require("../../error-handling/error-codes.constants.cjs"),h=require("ethers"),f=require("../utils/create-provider.cjs"),s=(t,o)=>{const r=c.networkRegistry[o];if(!r)throw new Error(u.transactionErrorCodes.UNSUPPORTED_NETWORK);const e=d.contractMetadataMapping[t];if(!e)throw new Error(`Unsupported contractType: ${t}`);return e(r.contractData)},i=(t,o,r,e)=>{const n=s(t,o);if(!n.abi)throw new Error(`No ABI configured for contractType: ${t}`);if(n.address&&r)throw new Error(`Overriding address is not supported for contractType: ${t}`);const a=n.address??r;if(!a)throw new Error(`No contractAddress configured for contractType: ${t}`);return new h.ethers.Contract(a,n.abi,e)},w=(t,o,r=void 0)=>{const{fetchRpcUrl:e}=c.networkRegistry[t];if(!e)throw new Error("RPC URL not found for the specified chain ID");return i(o,t,r,f.createCustomRpcProvider(e))};exports.getContract=i;exports.getContractMetadata=s;exports.getContractWithFetcherByChainId=w;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ContractMetadata, ContractType } from '../../types/ethereum-network.types';
|
|
2
2
|
import { ethers } from 'ethers';
|
|
3
3
|
export declare const getContractMetadata: (contractType: ContractType, chainId: number) => ContractMetadata;
|
|
4
|
-
export declare const getContract: (contractType: ContractType, chainId: number, contractAddress?: string) => ethers.Contract;
|
|
4
|
+
export declare const getContract: (contractType: ContractType, chainId: number, contractAddress?: string, runner?: ethers.ContractRunner) => ethers.Contract;
|
|
5
5
|
export declare const getContractWithFetcherByChainId: (chainId: number, contractType: ContractType, contractAddress?: undefined) => ethers.Contract;
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { contractMetadataMapping as
|
|
2
|
-
import { networkRegistry as
|
|
3
|
-
import { transactionErrorCodes as
|
|
4
|
-
import { ethers as
|
|
5
|
-
import { createCustomRpcProvider as
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
if (!o)
|
|
9
|
-
throw new Error(i.UNSUPPORTED_NETWORK);
|
|
10
|
-
const t = c[r];
|
|
1
|
+
import { contractMetadataMapping as i } from "../../constants/contracts.constants.mjs";
|
|
2
|
+
import { networkRegistry as c } from "../../constants/chains.constants.mjs";
|
|
3
|
+
import { transactionErrorCodes as s } from "../../error-handling/error-codes.constants.mjs";
|
|
4
|
+
import { ethers as d } from "ethers";
|
|
5
|
+
import { createCustomRpcProvider as f } from "../utils/create-provider.mjs";
|
|
6
|
+
const p = (r, e) => {
|
|
7
|
+
const t = c[e];
|
|
11
8
|
if (!t)
|
|
9
|
+
throw new Error(s.UNSUPPORTED_NETWORK);
|
|
10
|
+
const o = i[r];
|
|
11
|
+
if (!o)
|
|
12
12
|
throw new Error(`Unsupported contractType: ${r}`);
|
|
13
|
-
return t
|
|
14
|
-
},
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
13
|
+
return o(t.contractData);
|
|
14
|
+
}, w = (r, e, t, o) => {
|
|
15
|
+
const n = p(r, e);
|
|
16
|
+
if (!n.abi)
|
|
17
17
|
throw new Error(`No ABI configured for contractType: ${r}`);
|
|
18
|
-
if (
|
|
18
|
+
if (n.address && t)
|
|
19
19
|
throw new Error(`Overriding address is not supported for contractType: ${r}`);
|
|
20
|
-
const
|
|
21
|
-
if (!
|
|
20
|
+
const a = n.address ?? t;
|
|
21
|
+
if (!a)
|
|
22
22
|
throw new Error(`No contractAddress configured for contractType: ${r}`);
|
|
23
|
-
return new
|
|
24
|
-
},
|
|
25
|
-
const { fetchRpcUrl:
|
|
26
|
-
if (!
|
|
23
|
+
return new d.Contract(a, n.abi, o);
|
|
24
|
+
}, E = (r, e, t = void 0) => {
|
|
25
|
+
const { fetchRpcUrl: o } = c[r];
|
|
26
|
+
if (!o)
|
|
27
27
|
throw new Error("RPC URL not found for the specified chain ID");
|
|
28
|
-
return
|
|
28
|
+
return w(e, r, t, f(o));
|
|
29
29
|
};
|
|
30
30
|
export {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
w as getContract,
|
|
32
|
+
p as getContractMetadata,
|
|
33
|
+
E as getContractWithFetcherByChainId
|
|
34
34
|
};
|
|
@@ -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("../../constants/protocol.constants.cjs"),n=require("../../types/ethereum-network.types.cjs"),a=require("../utils/getSignerFromContract.cjs"),i=async(o,t,e)=>{const r=o.getContractWithFetcher(n.ContractType.ERC20Contract,t);return t===c.zeroAddress?a.getProviderFromContract(r).getBalance(e):r.balanceOf(e)};exports.getPublicAddressBalance=i;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { zeroAddress as
|
|
2
|
-
import { ContractType as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { zeroAddress as e } from "../../constants/protocol.constants.mjs";
|
|
2
|
+
import { ContractType as n } from "../../types/ethereum-network.types.mjs";
|
|
3
|
+
import { getProviderFromContract as a } from "../utils/getSignerFromContract.mjs";
|
|
4
|
+
const f = async (c, r, t) => {
|
|
5
|
+
const o = c.getContractWithFetcher(n.ERC20Contract, r);
|
|
6
|
+
return r === e ? a(o).getBalance(t) : o.balanceOf(t);
|
|
6
7
|
};
|
|
7
8
|
export {
|
|
8
|
-
|
|
9
|
+
f as getPublicAddressBalance
|
|
9
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 c=require("ethers"),o=require("../../constants/chains.constants.cjs"),p=require("../../externalABIs/index.cjs"),u=require("../../data-structures/http/HttpClient.cjs");require("axios");require("idb-keyval");const k=require("../utils/create-provider.cjs");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");require("../../data-structures/crypto-keys/keys.cjs");require("../../constants/server.constants.cjs");require("../../constants/vite.constants.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");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");require("multiformats");require("../../API/tenderly.api.cjs");const a={[o.chainIds.base]:"base",[o.chainIds.optimism]:"optimism",[o.chainIds.arbMainnet]:"arbitrum",[o.chainIds.polygon]:"polygon",[o.chainIds.ethMainnet]:"eth"},m=async(e,r)=>{const i=`https://${a[e]}.blockscout.com/api?module=token&action=getTokenHolders&contractaddress=${r}&page=0&offset=10`,{result:q}=await u.httpClient.get(i),{fetchRpcUrl:n}=o.networkRegistry[e];if(!n)throw new Error("RPC URL not found for the specified chain ID");const l=k.createCustomRpcProvider(n),d=new c.ethers.Contract(r,p.ERC20ABI,l);for(const{address:s}of q){const h=await d.balanceOf(s);if(BigInt(h)!==0n)return s}},f=async(e,r)=>{const t=`https://api.routescan.io/v2/network/mainnet/evm/${e}/etherscan/api?module=token&action=tokenholderlist&contractaddress=${r}&page=1&offset=10&apikey=YourApiKeyToken`,{result:i}=await u.httpClient.get(t);return i.at(0)?.TokenHolderAddress},g=async(e,r)=>{try{if(!(e in a))throw new Error("Chain is not supported by blockscout");const t=await m(e,r);if(!t||!c.ethers.isAddress(t))throw new Error("Token holder not found in blockscout");return t}catch{return await f(e,r)}};exports.getTokenHolder=g;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { ethers as m } from "ethers";
|
|
2
|
-
import { chainIds as i, networkRegistry as
|
|
3
|
-
import { ERC20ABI as
|
|
2
|
+
import { chainIds as i, networkRegistry as f } from "../../constants/chains.constants.mjs";
|
|
3
|
+
import { ERC20ABI as h } from "../../externalABIs/index.mjs";
|
|
4
4
|
import { httpClient as a } from "../../data-structures/http/HttpClient.mjs";
|
|
5
5
|
import "axios";
|
|
6
6
|
import "idb-keyval";
|
|
7
|
-
import { createCustomRpcProvider as
|
|
7
|
+
import { createCustomRpcProvider as k } from "../utils/create-provider.mjs";
|
|
8
8
|
import "../../constants/token-data/index.mjs";
|
|
9
9
|
import "../../error-handling/error-codes.constants.mjs";
|
|
10
10
|
import "../utils/convertIntegrationProviderToExternalActionId.mjs";
|
|
11
11
|
import "../../types/circom-data.types.mjs";
|
|
12
|
-
import "../../types/transactions.types.mjs";
|
|
13
12
|
import "../../types/activities.types.mjs";
|
|
14
13
|
import "circomlibjs-hinkal-fork";
|
|
15
14
|
import "../../data-structures/crypto-keys/keys.mjs";
|
|
@@ -43,31 +42,33 @@ const c = {
|
|
|
43
42
|
[i.arbMainnet]: "arbitrum",
|
|
44
43
|
[i.polygon]: "polygon",
|
|
45
44
|
[i.ethMainnet]: "eth"
|
|
46
|
-
},
|
|
47
|
-
const e = `https://${c[o]}.blockscout.com/api?module=token&action=getTokenHolders&contractaddress=${t}&page=0&offset=10`, { result: s } = await a.get(e), { fetchRpcUrl: n } =
|
|
45
|
+
}, w = async (o, t) => {
|
|
46
|
+
const e = `https://${c[o]}.blockscout.com/api?module=token&action=getTokenHolders&contractaddress=${t}&page=0&offset=10`, { result: s } = await a.get(e), { fetchRpcUrl: n } = f[o];
|
|
48
47
|
if (!n)
|
|
49
48
|
throw new Error("RPC URL not found for the specified chain ID");
|
|
50
|
-
const l =
|
|
51
|
-
for (const { address: p } of s)
|
|
52
|
-
|
|
49
|
+
const l = k(n), u = new m.Contract(t, h, l);
|
|
50
|
+
for (const { address: p } of s) {
|
|
51
|
+
const d = await u.balanceOf(p);
|
|
52
|
+
if (BigInt(d) !== 0n)
|
|
53
53
|
return p;
|
|
54
|
-
}
|
|
54
|
+
}
|
|
55
|
+
}, g = async (o, t) => {
|
|
55
56
|
const r = `https://api.routescan.io/v2/network/mainnet/evm/${o}/etherscan/api?module=token&action=tokenholderlist&contractaddress=${t}&page=1&offset=10&apikey=YourApiKeyToken`, { result: e } = await a.get(
|
|
56
57
|
r
|
|
57
58
|
);
|
|
58
59
|
return e.at(0)?.TokenHolderAddress;
|
|
59
|
-
},
|
|
60
|
+
}, io = async (o, t) => {
|
|
60
61
|
try {
|
|
61
62
|
if (!(o in c))
|
|
62
63
|
throw new Error("Chain is not supported by blockscout");
|
|
63
|
-
const r = await
|
|
64
|
-
if (!r || !m.
|
|
64
|
+
const r = await w(o, t);
|
|
65
|
+
if (!r || !m.isAddress(r))
|
|
65
66
|
throw new Error("Token holder not found in blockscout");
|
|
66
67
|
return r;
|
|
67
68
|
} catch {
|
|
68
|
-
return await
|
|
69
|
+
return await g(o, t);
|
|
69
70
|
}
|
|
70
71
|
};
|
|
71
72
|
export {
|
|
72
|
-
|
|
73
|
+
io as getTokenHolder
|
|
73
74
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("../../API/callOdosAPI.cjs");require("../../constants/token-data/index.cjs");const u=require("../../constants/chains.constants.cjs"),a=require("../../constants/protocol.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/server.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/reorg-depths.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");const d=require("../../error-handling/error-codes.constants.cjs"),l=require("./etherFunctions.cjs");require("../../types/circom-data.types.cjs");require("../../types/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("../../API/callOdosAPI.cjs");require("../../constants/token-data/index.cjs");const u=require("../../constants/chains.constants.cjs"),a=require("../../constants/protocol.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/server.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/reorg-depths.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");const d=require("../../error-handling/error-codes.constants.cjs"),l=require("./etherFunctions.cjs");require("../../types/circom-data.types.cjs");require("../../types/activities.types.cjs");require("../../API/getServerURL.cjs");require("../../data-structures/http/HttpClient.cjs");require("axios");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/save-depths.cjs");require("../utils/mutexes.utils.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");require("../../data-structures/crypto-keys/keys.cjs");const A=async(r,e,t,i,n=.7)=>{try{const o={chainId:r!==31337?r:u.localhostNetwork,inputTokens:[{tokenAddress:e?.wrappedErc20TokenAddress??e.erc20TokenAddress,amount:l.getAmountInWei(e,i).toString()}],outputTokens:[{tokenAddress:t?.wrappedErc20TokenAddress??t.erc20TokenAddress,proportion:1}],userAddr:u.networkRegistry[r].contractData.odosExternalActionInstanceAddress||a.zeroAddress,slippageLimitPercent:n,disableRFQs:!0},{odosResponse:s,status:c}=await q.callOdosAPI(r,o);if(c!=="success")throw Error("Odos API Fetch Error");return{outSwapAmountValue:BigInt(s.outputTokens[0].amount),odosDataValue:s.transaction.data}}catch(o){throw console.log({error:o}),Error(d.transactionErrorCodes.NO_ODOS_PRICE)}};exports.getOdosPrice=A;
|
|
@@ -17,7 +17,6 @@ import "../../constants/events.constants.mjs";
|
|
|
17
17
|
import { transactionErrorCodes as u } from "../../error-handling/error-codes.constants.mjs";
|
|
18
18
|
import { getAmountInWei as A } from "./etherFunctions.mjs";
|
|
19
19
|
import "../../types/circom-data.types.mjs";
|
|
20
|
-
import "../../types/transactions.types.mjs";
|
|
21
20
|
import "../../types/activities.types.mjs";
|
|
22
21
|
import "../../API/getServerURL.mjs";
|
|
23
22
|
import "../../data-structures/http/HttpClient.mjs";
|
|
@@ -32,14 +31,14 @@ import "../utils/mutexes.utils.mjs";
|
|
|
32
31
|
import "@coral-xyz/anchor";
|
|
33
32
|
import "@solana/web3.js";
|
|
34
33
|
import "../../data-structures/crypto-keys/keys.mjs";
|
|
35
|
-
const
|
|
34
|
+
const M = async (r, o, s, i, p = 0.7) => {
|
|
36
35
|
try {
|
|
37
36
|
const t = {
|
|
38
37
|
chainId: r !== 31337 ? r : d,
|
|
39
38
|
inputTokens: [
|
|
40
39
|
{
|
|
41
40
|
tokenAddress: o?.wrappedErc20TokenAddress ?? o.erc20TokenAddress,
|
|
42
|
-
amount: A(o,
|
|
41
|
+
amount: A(o, i).toString()
|
|
43
42
|
}
|
|
44
43
|
],
|
|
45
44
|
outputTokens: [
|
|
@@ -52,20 +51,20 @@ const S = async (r, o, s, e, p = 0.7) => {
|
|
|
52
51
|
slippageLimitPercent: p,
|
|
53
52
|
disableRFQs: !0
|
|
54
53
|
// sometimes swap fails because of RFQs
|
|
55
|
-
}, { odosResponse:
|
|
54
|
+
}, { odosResponse: e, status: m } = await n(
|
|
56
55
|
r,
|
|
57
56
|
t
|
|
58
57
|
);
|
|
59
58
|
if (m !== "success")
|
|
60
59
|
throw Error("Odos API Fetch Error");
|
|
61
60
|
return {
|
|
62
|
-
outSwapAmountValue: BigInt(
|
|
63
|
-
odosDataValue:
|
|
61
|
+
outSwapAmountValue: BigInt(e.outputTokens[0].amount),
|
|
62
|
+
odosDataValue: e.transaction.data
|
|
64
63
|
};
|
|
65
64
|
} catch (t) {
|
|
66
65
|
throw console.log({ error: t }), Error(u.NO_ODOS_PRICE);
|
|
67
66
|
}
|
|
68
67
|
};
|
|
69
68
|
export {
|
|
70
|
-
|
|
69
|
+
M as getOdosPrice
|
|
71
70
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../API/callOneInchAPI.cjs");require("../../constants/token-data/index.cjs");require("../../constants/chains.constants.cjs");const e=require("../../constants/protocol.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/server.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/reorg-depths.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");const q=require("../../error-handling/error-codes.constants.cjs"),a=require("./etherFunctions.cjs");require("../../types/circom-data.types.cjs");const d=require("../../types/ethereum-network.types.cjs");require("../../types/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../API/callOneInchAPI.cjs");require("../../constants/token-data/index.cjs");require("../../constants/chains.constants.cjs");const e=require("../../constants/protocol.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/server.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/reorg-depths.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");const q=require("../../error-handling/error-codes.constants.cjs"),a=require("./etherFunctions.cjs");require("../../types/circom-data.types.cjs");const d=require("../../types/ethereum-network.types.cjs");require("../../types/activities.types.cjs");require("../../API/getServerURL.cjs");require("../../data-structures/http/HttpClient.cjs");require("axios");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/save-depths.cjs");require("../utils/mutexes.utils.cjs");require("@coral-xyz/anchor");const l=require("../../error-handling/logger.cjs");require("@solana/web3.js");require("../../data-structures/crypto-keys/keys.cjs");const A=require("./getContractMetadata.cjs"),I=async(s,t,n,i,u=.7)=>{try{const o={fromTokenAddress:t.erc20TokenAddress!==e.zeroAddress?t.erc20TokenAddress:e.oneInchZeroAddress,toTokenAddress:n.erc20TokenAddress!==e.zeroAddress?n.erc20TokenAddress:e.oneInchZeroAddress,fromAddress:e.zeroAddress,destReceiver:A.getContractMetadata(d.ContractType.OneInchExternalActionContract,s).address,amount:a.getAmountInWei(t,i),slippage:u,disableEstimate:!0,allowPartialFill:!1},r=await c.callOneInchAPI(s,o);if(!r||!r.tx)throw Error("OneInch API price fetch error");return{outSwapAmountValue:BigInt(r.toAmount),oneInchDataValue:r.tx.data}}catch(o){throw l.Logger.log({error:o}),Error(q.transactionErrorCodes.NO_ONEINCH_PRICE)}};exports.getOneInchPrice=I;
|
|
@@ -18,7 +18,6 @@ import { transactionErrorCodes as c } from "../../error-handling/error-codes.con
|
|
|
18
18
|
import { getAmountInWei as d } from "./etherFunctions.mjs";
|
|
19
19
|
import "../../types/circom-data.types.mjs";
|
|
20
20
|
import { ContractType as A } from "../../types/ethereum-network.types.mjs";
|
|
21
|
-
import "../../types/transactions.types.mjs";
|
|
22
21
|
import "../../types/activities.types.mjs";
|
|
23
22
|
import "../../API/getServerURL.mjs";
|
|
24
23
|
import "../../data-structures/http/HttpClient.mjs";
|
|
@@ -35,7 +34,7 @@ import { Logger as l } from "../../error-handling/logger.mjs";
|
|
|
35
34
|
import "@solana/web3.js";
|
|
36
35
|
import "../../data-structures/crypto-keys/keys.mjs";
|
|
37
36
|
import { getContractMetadata as f } from "./getContractMetadata.mjs";
|
|
38
|
-
const
|
|
37
|
+
const Y = async (m, o, i, s, n = 0.7) => {
|
|
39
38
|
try {
|
|
40
39
|
const t = {
|
|
41
40
|
fromTokenAddress: o.erc20TokenAddress !== e ? o.erc20TokenAddress : p,
|
|
@@ -65,5 +64,5 @@ const $ = async (m, o, i, s, n = 0.7) => {
|
|
|
65
64
|
}
|
|
66
65
|
};
|
|
67
66
|
export {
|
|
68
|
-
|
|
67
|
+
Y as getOneInchPrice
|
|
69
68
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("../../error-handling/error-codes.constants.cjs");require("ethers");const w=require("../../error-handling/get-error.message.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("../../data-structures/http/HttpClient.cjs");require("axios");require("../../constants/chains.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/activities.types.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");require("@solana/web3.js");require("../../data-structures/crypto-keys/keys.cjs");const P=5e4,f=1,m=11,d=15,g=async(e,t)=>{try{const r=await e.getFeeData(),i=t===0?m:d;return r.gasPrice?r.gasPrice*BigInt(i)/BigInt(10):void 0}catch(r){console.log("getGasPrice error: ",{err:r});return}},l=async({provider:e,contractFunction:t,args:r,gasPrice:i,gasLimit:s,nonce:o,confirmations:a,waitTime:n})=>{const c=await t(...r,{type:0,gasLimit:s,gasPrice:i,nonce:o});if(!c.hash)throw new Error("failed to confirm tx");const u=await e.waitForTransaction(c.hash,a??f,n??P);if(u===null)throw new Error("failed to confirm tx");return u},y=async({provider:e,contractFunction:t,args:r,gasLimit:i,nonce:s,confirmations:o})=>{try{const a=await g(e,0);return await l({provider:e,contractFunction:t,args:r,gasPrice:a,gasLimit:i,nonce:s,confirmations:o})}catch(a){const n=w.getErrorMessage(a);if(n===q.UserFriendlyErrorCodes.MAX_FEE_GAS_ERROR||n===q.transactionErrorCodes.TRANSACTION_TIMEOUT){console.log("Timeout Hit: Increase gas");const c=await g(e,1);return await l({provider:e,contractFunction:t,args:r,gasPrice:c,gasLimit:i,nonce:s,confirmations:o})}throw a}};exports.runContractFunction=y;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
2
|
interface IRunTransaction {
|
|
3
|
-
|
|
3
|
+
provider: ethers.Provider;
|
|
4
|
+
contractFunction: ethers.ContractMethod;
|
|
4
5
|
args: unknown[];
|
|
5
6
|
gasLimit?: number;
|
|
6
|
-
gasPrice?:
|
|
7
|
+
gasPrice?: bigint;
|
|
7
8
|
confirmations?: number;
|
|
8
9
|
waitTime?: number;
|
|
9
10
|
nonce?: number;
|
|
10
11
|
}
|
|
11
12
|
interface IRunContractFunction extends IRunTransaction {
|
|
12
|
-
provider: ethers.
|
|
13
|
+
provider: ethers.Provider;
|
|
13
14
|
}
|
|
14
|
-
export declare const runContractFunction: ({ provider, contractFunction, args, gasLimit, nonce, confirmations, }: IRunContractFunction) => Promise<ethers.
|
|
15
|
+
export declare const runContractFunction: ({ provider, contractFunction, args, gasLimit, nonce, confirmations, }: IRunContractFunction) => Promise<ethers.TransactionReceipt>;
|
|
15
16
|
export {};
|