@hinkal/common 0.0.103 → 0.0.106
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/API.js +58 -0
- package/API/HinkalPointsCalls.js +38 -0
- package/API/callBeefyGraphAPI.js +37 -0
- package/API/callCurveAPI.js +156 -0
- package/API/callMonitor.js +30 -0
- package/API/callOdosAPI.js +44 -0
- package/API/callOneInchAPI.js +37 -0
- package/API/callRelayer.js +32 -0
- package/API/checkRisk.js +30 -0
- package/API/dataServerCalls.js +32 -0
- package/API/fetchCommitmentsCache.js +31 -0
- package/API/fetchNullifiers.js +30 -0
- package/API/getAxelarGasEstimate.js +37 -0
- package/API/getCoingeckoPrice.js +27 -0
- package/API/getConnextReceiveFee.js +30 -0
- package/API/getGasEstimates.js +38 -0
- package/API/getRelayerURL.js +32 -0
- package/API/getServerURL.js +67 -0
- package/API/getTokenPrice.js +41 -0
- package/API/kycCalls.js +32 -0
- package/API/passwordCalls.js +36 -0
- package/API/referralProgramCalls.js +58 -0
- package/API/relayCalls.js +30 -0
- package/API/restoreSnapshots.js +32 -0
- package/API/rewardsPointsCalls.js +40 -0
- package/API/userVerifyTransactions.js +45 -0
- package/README.md +134 -12
- package/assets/{snarkjsWorkerLogic-CatB8Hso.js → snarkjsWorkerLogic-Fv0M38Mc.js} +2 -2
- package/assets/{utxoWorkerLogic-DDqTe7hT.js → utxoWorkerLogic-CtFLQiAX.js} +2 -2
- package/assets/{zkProofWorkerLauncher-C-pvCm0b.js → zkProofWorkerLauncher-J3Ts5_Ba.js} +1 -1
- package/assets/{zkProofWorkerLogic-CLpRqNRx.js → zkProofWorkerLogic-CPNuu61R.js} +18 -19
- package/constants/assets.constants.js +16 -0
- package/constants/axelar.constants.js +55 -0
- package/constants/backend.constants.js +18 -0
- package/constants/beefy.registry.js +24 -0
- package/constants/chains.constants.js +204 -0
- package/constants/coingecko.constants.js +53 -0
- package/constants/contracts.constants.js +276 -0
- package/constants/crvCvx.registry.js +636 -0
- package/constants/crvDynamic.registry.js +24 -0
- package/constants/deploy-data/deploy-data-arbMainnet.json.js +7415 -0
- package/constants/deploy-data/deploy-data-avalanche.json.js +7411 -0
- package/constants/deploy-data/deploy-data-axelar1.json.js +4329 -0
- package/constants/deploy-data/deploy-data-axelar2.json.js +4329 -0
- package/constants/deploy-data/deploy-data-base.json.js +8425 -0
- package/constants/deploy-data/deploy-data-blast.json.js +9600 -0
- package/constants/deploy-data/deploy-data-bnbMainnet.json.js +6877 -0
- package/constants/deploy-data/deploy-data-ethMainnet.json.js +11427 -0
- package/constants/deploy-data/deploy-data-localhost.json.js +13283 -0
- package/constants/deploy-data/deploy-data-optimism.json.js +7417 -0
- package/constants/deploy-data/deploy-data-polygon.json.js +7439 -0
- package/constants/fees.constants.js +57 -0
- package/constants/kyc.constants.js +118 -0
- package/constants/lido.constants.js +13 -0
- package/constants/pendle.registry.js +253 -0
- package/constants/protocol.constants.js +26 -0
- package/constants/reorg-depths.constants.js +15 -0
- package/constants/rewards.constants.js +27 -0
- package/constants/server.constants.js +157 -0
- package/constants/token-data/ERC20Registry.js +85 -0
- package/constants/token-data/arbMainnetRegistry.json.js +946 -0
- package/constants/token-data/arbMainnetRegistryFixed.json.js +856 -0
- package/constants/token-data/avalancheRegistry.json.js +591 -0
- package/constants/token-data/avalancheRegistryFixed.json.js +591 -0
- package/constants/token-data/baseRegistry.json.js +490 -0
- package/constants/token-data/baseRegistryFixed.json.js +463 -0
- package/constants/token-data/blastRegistry.json.js +137 -0
- package/constants/token-data/blastRegistryFixed.json.js +137 -0
- package/constants/token-data/bnbMainnetRegistry.json.js +973 -0
- package/constants/token-data/bnbMainnetRegistryFixed.json.js +973 -0
- package/constants/token-data/coingeckoRegistry.json.js +115623 -0
- package/constants/token-data/ethMainnetRegistry.json.js +2700 -0
- package/constants/token-data/ethMainnetRegistryFixed.json.js +2251 -0
- package/constants/token-data/index.js +6 -0
- package/constants/token-data/localhostRegistry.json.js +2768 -0
- package/constants/token-data/optimismRegistry.json.js +1455 -0
- package/constants/token-data/optimismRegistryFixed.json.js +1392 -0
- package/constants/token-data/polygonRegistry.json.js +1327 -0
- package/constants/token-data/polygonRegistryFixed.json.js +1255 -0
- package/constants/token-data/popularTokens.constants.js +14 -0
- package/constants/token-data/tokenPricing.consts.js +8 -0
- package/constants/vite.constants.js +29 -0
- package/crypto/babyJub.js +15 -0
- package/crypto/poseidon.js +26 -0
- package/crypto/preProcessing.js +9 -0
- package/data-structures/Hinkal/Hinkal.js +299 -0
- package/data-structures/Hinkal/hinkalActionBeefy.js +101 -0
- package/data-structures/Hinkal/hinkalActionConvex.js +83 -0
- package/data-structures/Hinkal/hinkalActionCurve.js +112 -0
- package/data-structures/Hinkal/hinkalActionLidoEth.js +91 -0
- package/data-structures/Hinkal/hinkalActionPendle.js +140 -0
- package/data-structures/Hinkal/hinkalActionPendleLP.js +96 -0
- package/data-structures/Hinkal/hinkalActionStake.js +138 -0
- package/data-structures/Hinkal/hinkalActionVolatile.js +112 -0
- package/data-structures/Hinkal/hinkalDeposit.js +95 -0
- package/data-structures/Hinkal/hinkalGetZkMeProvider.js +47 -0
- package/data-structures/Hinkal/hinkalPrivateWallet.js +66 -0
- package/data-structures/Hinkal/hinkalSwap.js +98 -0
- package/data-structures/Hinkal/hinkalTransfer.js +5 -0
- package/data-structures/Hinkal/hinkalWithdraw.js +91 -0
- package/data-structures/Hinkal/resetMerkleTrees.js +49 -0
- package/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.js +83 -0
- package/data-structures/ValueCache/ValueCache.js +25 -0
- package/data-structures/crypto-keys/decodeUTXO.js +40 -0
- package/data-structures/crypto-keys/encryptDecryptUtxo.js +41 -0
- package/data-structures/crypto-keys/keyUtils.js +10 -0
- package/data-structures/crypto-keys/keys.js +90 -0
- package/data-structures/custom-token-registry/CustomTokenRegistry.js +33 -0
- package/data-structures/event-service/AbstractAccessTokenSnapshotService.js +131 -0
- package/data-structures/event-service/AbstractCommitmentsSnapshotService.js +132 -0
- package/data-structures/event-service/AbstractEventService.js +118 -0
- package/data-structures/event-service/AbstractNullifierSnapshotService.js +59 -0
- package/data-structures/event-service/AbstractSnapshotService.js +35 -0
- package/data-structures/merkle-tree/MerkleTree.js +177 -0
- package/data-structures/merkle-tree/MerkleTreeIncompleteError.js +8 -0
- package/data-structures/snapshot/ClientAccessTokenSnapshotService.js +48 -0
- package/data-structures/snapshot/ClientCommitmentsSnapshotService.js +47 -0
- package/data-structures/snapshot/ClientNullifierSnapshotService.js +44 -0
- package/data-structures/token-price-fetcher/TokenChecker.js +29 -0
- package/data-structures/token-price-fetcher/TokenPriceFetcher.js +218 -0
- package/data-structures/transactions-manager/TransactionsManager.js +194 -0
- package/data-structures/transactions-manager/history/getBeefyData.js +68 -0
- package/data-structures/transactions-manager/history/getConvexData.js +57 -0
- package/data-structures/transactions-manager/history/getCurveData.js +97 -0
- package/data-structures/transactions-manager/history/getDepositData.js +36 -0
- package/data-structures/transactions-manager/history/getLidoData.js +44 -0
- package/data-structures/transactions-manager/history/getPendleData.js +59 -0
- package/data-structures/transactions-manager/history/getSwapData.js +43 -0
- package/data-structures/transactions-manager/history/getTxDetails.js +74 -0
- package/data-structures/transactions-manager/history/getVolatileData.js +75 -0
- package/data-structures/transactions-manager/history/history.types.js +62 -0
- package/data-structures/transactions-manager/history/history.utils.js +8 -0
- package/data-structures/utxo/Utxo.js +134 -0
- package/data-structures/volatile-helper/VolatileHelper.js +181 -0
- package/error-handling/customErrors/ErrorWithAmount.js +9 -0
- package/error-handling/customErrors/FeeOverTransactionValueError.js +9 -0
- package/error-handling/customErrors/customErrors.helpers.js +21 -0
- package/error-handling/error-codes.constants.js +184 -0
- package/error-handling/get-error.message.js +53 -0
- package/error-handling/handleErrorRestore.js +35 -0
- package/error-handling/logError.js +7 -0
- package/error-handling/types.js +4 -0
- package/externalABIs/BUSD.js +519 -0
- package/externalABIs/BabPassport.json.js +24 -0
- package/externalABIs/BeefyRouterAbi.json.js +1022 -0
- package/externalABIs/BeefyStrategyAbi.json.js +1423 -0
- package/externalABIs/BeefyVaultAbi.json.js +570 -0
- package/externalABIs/BeefyZapAbi.json.js +208 -0
- package/externalABIs/BeefyZapOneInchAbi.json.js +340 -0
- package/externalABIs/ConvexBoosterAbi.json.js +674 -0
- package/externalABIs/ConvexBoosterAbiMainnet.json.js +1002 -0
- package/externalABIs/ConvexRewardPoolAbi.json.js +883 -0
- package/externalABIs/CurveReadingWrapperAbi.json.js +1422 -0
- package/externalABIs/CurveWrappedMainPool.json.js +1136 -0
- package/externalABIs/CurveZap.json.js +262 -0
- package/externalABIs/CvxCrvUtilities.json.js +264 -0
- package/externalABIs/DAI.js +334 -0
- package/externalABIs/ERC20.json.js +291 -0
- package/externalABIs/GalxePassport.json.js +41 -0
- package/externalABIs/IQuoterV2.json.js +205 -0
- package/externalABIs/ISwapRouter.json.js +568 -0
- package/externalABIs/IUniswapV3Factory.json.js +201 -0
- package/externalABIs/IUniswapV3Pool.json.js +999 -0
- package/externalABIs/LidoStEthAbi.json.js +1603 -0
- package/externalABIs/LidoStMaticAbi.json.js +1764 -0
- package/externalABIs/LidoStakeManagerAbi.json.js +2082 -0
- package/externalABIs/LidoWithdrawalQueueERC721Abi.json.js +2030 -0
- package/externalABIs/LidoWstEthAbi.json.js +480 -0
- package/externalABIs/OptimismGasPriceOracle.json.js +206 -0
- package/externalABIs/PendleRouterAbi.json.js +173 -0
- package/externalABIs/PoLidoNftAbi.json.js +701 -0
- package/externalABIs/SanctionsList.js +89 -0
- package/externalABIs/USDC.js +721 -0
- package/externalABIs/USDR.js +346 -0
- package/externalABIs/USDR3CRV.js +542 -0
- package/externalABIs/USDT.js +393 -0
- package/externalABIs/UniswapV2PoolAbi.json.js +80 -0
- package/externalABIs/WETH.js +156 -0
- package/externalABIs/amToken.js +350 -0
- package/externalABIs/transactionsProver.json.js +39 -0
- package/functions/kyc/authentoHelper.js +42 -0
- package/functions/kyc/passportHelper.js +39 -0
- package/functions/kyc/zkMeHelper.js +56 -0
- package/functions/pre-transaction/getFlatFees.js +203 -0
- package/functions/pre-transaction/interaction-to-action.js +57 -0
- package/functions/pre-transaction/outputUtxoProcessing.js +45 -0
- package/functions/pre-transaction/process-gas-estimates.js +57 -0
- package/functions/pre-transaction/processAmountChanges.js +229 -0
- package/functions/private-wallet/emporium.helpers.js +19 -0
- package/functions/private-wallet/opProducer.js +24 -0
- package/functions/protocols/convex.protocols.js +41 -0
- package/functions/protocols/curve.protocols.js +45 -0
- package/functions/protocols/pendle.helpers.js +108 -0
- package/functions/snarkjs/common.snarkjs.js +96 -0
- package/functions/snarkjs/constant.js +211 -0
- package/functions/snarkjs/constructEmporiumProof.js +105 -0
- package/functions/snarkjs/constructGeneralZkProof.js +129 -0
- package/functions/snarkjs/generateCircomData.js +60 -0
- package/functions/snarkjs/generateZkProof.js +18 -0
- package/functions/snarkjs/getZKFiles.js +30 -0
- package/functions/staking/index.js +40 -0
- package/functions/utils/amounts.utils.js +70 -0
- package/functions/utils/axelar.utils.js +38 -0
- package/functions/utils/cacheFunctions.js +67 -0
- package/functions/utils/caseInsensitive.utils.js +6 -0
- package/functions/utils/convertIntegrationProviderToExternalActionId.js +16 -0
- package/functions/utils/create-provider.js +5 -0
- package/functions/utils/enum.utils.js +14 -0
- package/functions/utils/erc20tokenFunctions.js +20 -0
- package/functions/utils/evmNetworkFunctions.js +29 -0
- package/functions/utils/external-action.utils.js +61 -0
- package/functions/utils/getDataFromTransaction.js +105 -0
- package/functions/utils/memoize.utils.js +14 -0
- package/functions/utils/nickname.utils.js +7 -0
- package/functions/utils/process.utils.js +4 -0
- package/functions/utils/reloadPage.js +4 -0
- package/functions/utils/requireEnv.js +7 -0
- package/functions/utils/resolve-sync.utils.js +22 -0
- package/functions/utils/serialize.utils.js +4 -0
- package/functions/utils/string.utils.js +14 -0
- package/functions/utils/time.utils.js +8 -0
- package/functions/utils/userAgent.js +15 -0
- package/functions/utils/volatile-patcher.utils.js +40 -0
- package/functions/web3/etherFunctions.js +41 -0
- package/functions/web3/events/balanceChangedHandler.js +10 -0
- package/functions/web3/events/getInputUtxoAndBalance.js +72 -0
- package/functions/web3/events/getShieldedBalance.js +107 -0
- package/functions/web3/events/web3RetrieveEvents.js +9 -0
- package/functions/web3/functionCalls/accessTokenCalls.js +48 -0
- package/functions/web3/functionCalls/approveToken.js +153 -0
- package/functions/web3/functionCalls/estimateGasRelayer.js +18 -0
- package/functions/web3/functionCalls/transactCallDirect.js +60 -0
- package/functions/web3/functionCalls/transactCallRelayer.js +42 -0
- package/functions/web3/odosAPI.js +65 -0
- package/functions/web3/oneInchAPI.js +61 -0
- package/functions/web3/runContractFunction.js +95 -0
- package/functions/web3/uniswapAPI.js +97 -0
- package/index.js +644 -0
- package/package.json +5 -4
- package/types/beefy.types.js +21 -0
- package/types/circom-data.types.js +22 -0
- package/types/curve.types.js +25 -0
- package/types/ethereum-network.types.js +4 -0
- package/types/external-action.types.js +4 -0
- package/types/hinkal.stake.types.js +4 -0
- package/types/hinkal.types.js +15 -0
- package/types/kyc.types.js +13 -0
- package/types/pendle.types.js +15 -0
- package/types/rewards.types.js +27 -0
- package/types/slippage.types.js +15 -0
- package/types/time.types.js +58 -0
- package/types/token.types.js +4 -0
- package/types/transactions.types.js +36 -0
- package/webworker/performTaskWithWorker.js +62 -0
- package/webworker/snarkjsWorker/snarkjsWorker.types.js +4 -0
- package/webworker/snarkjsWorker/snarkjsWorkerLogic.js +32 -0
- package/webworker/utxoWorker/utxoWorker.types.js +4 -0
- package/webworker/utxoWorker/utxoWorkerLogic.js +70 -0
- package/webworker/viteWorkerURL.constant.d.ts +3 -3
- package/webworker/worker.registry.js +4 -0
- package/webworker/workerFactory.d.ts +0 -1
- package/webworker/workerFactory.js +42 -0
- package/{workerProxy-BDj498Ht.mjs → webworker/workerProxy.js} +1 -1
- package/webworker/zkProofWorker/zkProofWorker.types.js +4 -0
- package/webworker/zkProofWorker/zkProofWorkerLogic.js +66 -0
- package/assets/viteWorkerURL.constant-DrIQXA2B.js +0 -11
- package/index-COLpGMpe.mjs +0 -398153
- package/index.mjs +0 -457
- package/snarkjsWorkerLogic-BpNWzeoy.mjs +0 -12086
- package/utxoWorkerLogic-DyerYrK3.mjs +0 -64
- package/viteWorkerURL.constant-DnU4hEv_.mjs +0 -9
- package/zkProofWorkerLogic-DN4QUc_a.mjs +0 -60
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import "../../constants/chains.constants.js";
|
|
2
|
+
import "../../types/circom-data.types.js";
|
|
3
|
+
import { ContractType as u } from "../../types/ethereum-network.types.js";
|
|
4
|
+
import { ExternalActionId as W } from "../../types/external-action.types.js";
|
|
5
|
+
import { VolatileAction as a } from "../../types/hinkal.types.js";
|
|
6
|
+
import "../../types/transactions.types.js";
|
|
7
|
+
import "../../types/curve.types.js";
|
|
8
|
+
import "ethers";
|
|
9
|
+
import { transactionErrorCodes as N } from "../../error-handling/error-codes.constants.js";
|
|
10
|
+
import { zeroAddress as y } from "../../constants/protocol.constants.js";
|
|
11
|
+
import "circomlibjs";
|
|
12
|
+
import "../crypto-keys/keys.js";
|
|
13
|
+
import "axios";
|
|
14
|
+
import "../crypto-keys/encryptDecryptUtxo.js";
|
|
15
|
+
import { addPaddingToUtxos as H } from "../../functions/web3/events/getShieldedBalance.js";
|
|
16
|
+
import { outputUtxoProcessing as L } from "../../functions/pre-transaction/outputUtxoProcessing.js";
|
|
17
|
+
import { constructZkProof as M } from "../../functions/snarkjs/constructGeneralZkProof.js";
|
|
18
|
+
import { estimateGasRelayer as P } from "../../functions/web3/functionCalls/estimateGasRelayer.js";
|
|
19
|
+
import { transactCallRelayer as b } from "../../functions/web3/functionCalls/transactCallRelayer.js";
|
|
20
|
+
import { transactCallDirect as C } from "../../functions/web3/functionCalls/transactCallDirect.js";
|
|
21
|
+
import "../../functions/utils/external-action.utils.js";
|
|
22
|
+
import { getERC20Token as z } from "../../functions/utils/erc20tokenFunctions.js";
|
|
23
|
+
import "../../functions/utils/convertIntegrationProviderToExternalActionId.js";
|
|
24
|
+
import "../../constants/coingecko.constants.js";
|
|
25
|
+
import "../../constants/vite.constants.js";
|
|
26
|
+
import { getFlatFees as K } from "../../functions/pre-transaction/getFlatFees.js";
|
|
27
|
+
import "../../functions/utils/userAgent.js";
|
|
28
|
+
import "../../constants/reorg-depths.constants.js";
|
|
29
|
+
import "../../constants/kyc.constants.js";
|
|
30
|
+
import "../../webworker/workerFactory.js";
|
|
31
|
+
import { VolatileHelper as D } from "../volatile-helper/VolatileHelper.js";
|
|
32
|
+
import "../custom-token-registry/CustomTokenRegistry.js";
|
|
33
|
+
import "libsodium-wrappers";
|
|
34
|
+
import "../../constants/contracts.constants.js";
|
|
35
|
+
import "../../constants/axelar.constants.js";
|
|
36
|
+
import "../../constants/rewards.constants.js";
|
|
37
|
+
const Rt = async (t, i, o, R, T) => {
|
|
38
|
+
const { action: r, isRelayerOff: n, recipientAddress: V, baseExternalActionId: I, baseExternalActionMetadata: F } = R, f = z(i[0], t.getCurrentChainId());
|
|
39
|
+
if (!f)
|
|
40
|
+
throw Error("Deposit Action: No Token Found");
|
|
41
|
+
const c = [...o], S = [...i];
|
|
42
|
+
let A = [], x = o.map(() => 0n);
|
|
43
|
+
({ erc20Addresses: i, amountChanges: o, onChainCreation: A } = await D.processVolatileData(
|
|
44
|
+
t.getCurrentChainId(),
|
|
45
|
+
r,
|
|
46
|
+
i,
|
|
47
|
+
o
|
|
48
|
+
)), console.log("pre-amounts", o);
|
|
49
|
+
const p = await D.getVolatileExternalData(
|
|
50
|
+
t,
|
|
51
|
+
r,
|
|
52
|
+
c,
|
|
53
|
+
V,
|
|
54
|
+
I,
|
|
55
|
+
F
|
|
56
|
+
);
|
|
57
|
+
if (!p)
|
|
58
|
+
throw Error("No External Action Data");
|
|
59
|
+
(r === a.Withdraw && !n || r === a.Swap) && ({ flatFees: x } = await K(
|
|
60
|
+
t.getCurrentChainId(),
|
|
61
|
+
S,
|
|
62
|
+
W.Volatile,
|
|
63
|
+
c,
|
|
64
|
+
r
|
|
65
|
+
), r === a.Swap && (o[1] = 0n), console.log("hinkalActionVolatile flatFees:", {
|
|
66
|
+
flatFees: x,
|
|
67
|
+
erc20Addresses: i,
|
|
68
|
+
amountChanges: o,
|
|
69
|
+
originalAmountChanges: c,
|
|
70
|
+
externalActionData: p
|
|
71
|
+
}));
|
|
72
|
+
const g = [...await H(t, i, o)], U = `swapperM${o.length.toString()}x${g[0].length}x1`, d = [];
|
|
73
|
+
for (let e = 0; e < i.length; e += 1) {
|
|
74
|
+
const { outputUtxos: w } = L(t.userKeys, g[e], o[e]);
|
|
75
|
+
d.push(w);
|
|
76
|
+
}
|
|
77
|
+
const E = r === a.Deposit || n ? y : await t.getRandomRelay();
|
|
78
|
+
if (!n && !E)
|
|
79
|
+
throw Error(N.RELAYER_NOT_AVAILABLE);
|
|
80
|
+
const { zkCallData: m, circomData: l, dimData: s } = await M(
|
|
81
|
+
t.merkleTreeHinkal,
|
|
82
|
+
t.merkleTreeAccessToken,
|
|
83
|
+
g,
|
|
84
|
+
d,
|
|
85
|
+
t.userKeys,
|
|
86
|
+
U,
|
|
87
|
+
p.externalActionId,
|
|
88
|
+
p.externalAddress,
|
|
89
|
+
p.externalActionMetadata,
|
|
90
|
+
n ? y : E,
|
|
91
|
+
t.getCurrentChainId(),
|
|
92
|
+
A,
|
|
93
|
+
x
|
|
94
|
+
);
|
|
95
|
+
if (console.log("after proof generation"), r === a.Deposit) {
|
|
96
|
+
const e = t.getContractWithSigner(u.VolatileVault), w = t.getContractWithSigner(u.HinkalWrapper);
|
|
97
|
+
return console.log("here", { contractToApprove: e }), await C(
|
|
98
|
+
t,
|
|
99
|
+
c[0],
|
|
100
|
+
f,
|
|
101
|
+
m,
|
|
102
|
+
l,
|
|
103
|
+
s,
|
|
104
|
+
e,
|
|
105
|
+
w
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
return r === a.Withdraw && n ? await C(t, o[0], f, m, l, s) : T ? await P(t, m, s, l) : await b(t.getCurrentChainId(), m, s, l);
|
|
109
|
+
};
|
|
110
|
+
export {
|
|
111
|
+
Rt as hinkalActionVolatile
|
|
112
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import "../../constants/chains.constants.js";
|
|
2
|
+
import "../../types/circom-data.types.js";
|
|
3
|
+
import "../../types/transactions.types.js";
|
|
4
|
+
import "../../types/curve.types.js";
|
|
5
|
+
import "ethers";
|
|
6
|
+
import { transactionErrorCodes as P } from "../../error-handling/error-codes.constants.js";
|
|
7
|
+
import { Utxo as A } from "../utxo/Utxo.js";
|
|
8
|
+
import "axios";
|
|
9
|
+
import "../crypto-keys/keys.js";
|
|
10
|
+
import "../crypto-keys/encryptDecryptUtxo.js";
|
|
11
|
+
import { zeroAddress as f } from "../../constants/protocol.constants.js";
|
|
12
|
+
import { addPaddingToUtxos as U } from "../../functions/web3/events/getShieldedBalance.js";
|
|
13
|
+
import { outputUtxoProcessing as z } from "../../functions/pre-transaction/outputUtxoProcessing.js";
|
|
14
|
+
import { constructZkProof as T } from "../../functions/snarkjs/constructGeneralZkProof.js";
|
|
15
|
+
import "../../webworker/workerFactory.js";
|
|
16
|
+
import "../../functions/utils/external-action.utils.js";
|
|
17
|
+
import { getERC20Token as C } from "../../functions/utils/erc20tokenFunctions.js";
|
|
18
|
+
import "../../functions/utils/convertIntegrationProviderToExternalActionId.js";
|
|
19
|
+
import "../../constants/coingecko.constants.js";
|
|
20
|
+
import "../../constants/vite.constants.js";
|
|
21
|
+
import "../../functions/utils/userAgent.js";
|
|
22
|
+
import { transactCallDirect as D } from "../../functions/web3/functionCalls/transactCallDirect.js";
|
|
23
|
+
import "circomlibjs";
|
|
24
|
+
import "../../constants/reorg-depths.constants.js";
|
|
25
|
+
import "../../constants/kyc.constants.js";
|
|
26
|
+
import "../volatile-helper/VolatileHelper.js";
|
|
27
|
+
import "../custom-token-registry/CustomTokenRegistry.js";
|
|
28
|
+
import "libsodium-wrappers";
|
|
29
|
+
import "../../constants/contracts.constants.js";
|
|
30
|
+
import "../../constants/axelar.constants.js";
|
|
31
|
+
import "../../constants/rewards.constants.js";
|
|
32
|
+
const mt = async (t, i, r) => {
|
|
33
|
+
const s = C(i[0], t.getCurrentChainId());
|
|
34
|
+
if (!s)
|
|
35
|
+
throw Error("Deposit Action: No Token Found");
|
|
36
|
+
const a = r[0], o = {
|
|
37
|
+
externalActionId: 0n,
|
|
38
|
+
externalAddress: await t.getEthereumAddress(),
|
|
39
|
+
externalActionMetadata: "0x00"
|
|
40
|
+
}, e = [...await U(t, i, r)], p = `swapperM${r.length.toString()}x${e[0].length}x1`, m = [];
|
|
41
|
+
for (let n = 0; n < i.length; n += 1) {
|
|
42
|
+
const { outputUtxos: x } = z(t.userKeys, e[n], r[n]);
|
|
43
|
+
m.push(x);
|
|
44
|
+
}
|
|
45
|
+
const { zkCallData: d, circomData: u, dimData: l } = await T(
|
|
46
|
+
t.merkleTreeHinkal,
|
|
47
|
+
t.merkleTreeAccessToken,
|
|
48
|
+
e,
|
|
49
|
+
m,
|
|
50
|
+
t.userKeys,
|
|
51
|
+
p,
|
|
52
|
+
o.externalActionId,
|
|
53
|
+
o.externalAddress,
|
|
54
|
+
o.externalActionMetadata,
|
|
55
|
+
f,
|
|
56
|
+
t.getCurrentChainId()
|
|
57
|
+
);
|
|
58
|
+
return console.log("after proof generation"), await D(t, a, s, d, u, l);
|
|
59
|
+
}, ct = async (t, i, r, s) => {
|
|
60
|
+
console.log({ recipinetInfo: s });
|
|
61
|
+
const [a, o, e] = s.split(","), p = !a || !o || !e, m = o?.substring(0, 2) !== "0x" || e?.substring(0, 2) !== "0x", d = e?.length !== 66 || o?.length > 66 || o?.length < 64, u = s?.includes('"');
|
|
62
|
+
if (p || m || d || u)
|
|
63
|
+
throw Error(P.RECIPIENT_FORMAT_INCORRECT);
|
|
64
|
+
const l = [BigInt(a)], y = [o], n = i.map((c) => [
|
|
65
|
+
new A({ amount: 0n, erc20TokenAddress: c, shieldedPrivateKey: t.userKeys.getShieldedPrivateKey() }),
|
|
66
|
+
new A({ amount: 0n, erc20TokenAddress: c, shieldedPrivateKey: t.userKeys.getShieldedPrivateKey() })
|
|
67
|
+
]), x = `swapperM${r.length.toString()}x${n[0].length}x1`, E = i.map((c, g) => [
|
|
68
|
+
new A({
|
|
69
|
+
amount: r[g],
|
|
70
|
+
erc20TokenAddress: c,
|
|
71
|
+
randomization: l[g],
|
|
72
|
+
stealthAddress: y[g],
|
|
73
|
+
encryptionKey: e
|
|
74
|
+
})
|
|
75
|
+
]), { zkCallData: K, circomData: h, dimData: I } = await T(
|
|
76
|
+
t.merkleTreeHinkal,
|
|
77
|
+
t.merkleTreeAccessToken,
|
|
78
|
+
n,
|
|
79
|
+
E,
|
|
80
|
+
t.userKeys,
|
|
81
|
+
x,
|
|
82
|
+
0n,
|
|
83
|
+
await t.getEthereumAddress(),
|
|
84
|
+
"0x00",
|
|
85
|
+
f,
|
|
86
|
+
t.getCurrentChainId()
|
|
87
|
+
), w = C(i[0], t.getCurrentChainId());
|
|
88
|
+
if (!w)
|
|
89
|
+
throw Error("Withdraw Action: No Token Found");
|
|
90
|
+
return await D(t, r[0], w, K, h, I);
|
|
91
|
+
};
|
|
92
|
+
export {
|
|
93
|
+
mt as hinkalDeposit,
|
|
94
|
+
ct as hinkalDepositForOther
|
|
95
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import "../../constants/chains.constants.js";
|
|
2
|
+
import "../../types/circom-data.types.js";
|
|
3
|
+
import "../../types/transactions.types.js";
|
|
4
|
+
import "../../types/curve.types.js";
|
|
5
|
+
import "ethers";
|
|
6
|
+
import "circomlibjs";
|
|
7
|
+
import "../crypto-keys/keys.js";
|
|
8
|
+
import "axios";
|
|
9
|
+
import "../crypto-keys/encryptDecryptUtxo.js";
|
|
10
|
+
import "../../functions/web3/events/getShieldedBalance.js";
|
|
11
|
+
import "../../webworker/workerFactory.js";
|
|
12
|
+
import "../../functions/utils/external-action.utils.js";
|
|
13
|
+
import "../custom-token-registry/CustomTokenRegistry.js";
|
|
14
|
+
import "../../functions/utils/convertIntegrationProviderToExternalActionId.js";
|
|
15
|
+
import "../../functions/utils/userAgent.js";
|
|
16
|
+
import "../../constants/reorg-depths.constants.js";
|
|
17
|
+
import "../../constants/kyc.constants.js";
|
|
18
|
+
import "../../constants/coingecko.constants.js";
|
|
19
|
+
import "../../constants/vite.constants.js";
|
|
20
|
+
import "../volatile-helper/VolatileHelper.js";
|
|
21
|
+
import "libsodium-wrappers";
|
|
22
|
+
import "../../constants/contracts.constants.js";
|
|
23
|
+
import "../../constants/axelar.constants.js";
|
|
24
|
+
import "../../constants/rewards.constants.js";
|
|
25
|
+
import { API as i } from "../../API/API.js";
|
|
26
|
+
const q = (e) => ({
|
|
27
|
+
async getAccessToken() {
|
|
28
|
+
const r = e.getCurrentChainId();
|
|
29
|
+
return i.getZkMeAccessToken(r);
|
|
30
|
+
},
|
|
31
|
+
async getUserAccounts() {
|
|
32
|
+
return [await e.getEthereumAddress()];
|
|
33
|
+
},
|
|
34
|
+
async delegateTransaction(r) {
|
|
35
|
+
const t = await e.getProviderAdapter(), o = {
|
|
36
|
+
...r,
|
|
37
|
+
chainId: Number(r.chainId),
|
|
38
|
+
type: r.type ? r.type : void 0,
|
|
39
|
+
maxPriorityFeePerGas: r.maxPriorityFeePerGas ? r.maxPriorityFeePerGas : void 0,
|
|
40
|
+
maxFeePerGas: r.maxFeePerGas ? r.maxFeePerGas : void 0
|
|
41
|
+
};
|
|
42
|
+
return (await t.sendTransaction(o)).hash;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
export {
|
|
46
|
+
q as getHinkalZkMeProvider
|
|
47
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { networkRegistry as A } from "../../constants/chains.constants.js";
|
|
2
|
+
import "../../types/circom-data.types.js";
|
|
3
|
+
import { ExternalActionId as g } from "../../types/external-action.types.js";
|
|
4
|
+
import "../../types/transactions.types.js";
|
|
5
|
+
import "../../types/curve.types.js";
|
|
6
|
+
import "ethers";
|
|
7
|
+
import { transactionErrorCodes as w } from "../../error-handling/error-codes.constants.js";
|
|
8
|
+
import "circomlibjs";
|
|
9
|
+
import "../crypto-keys/keys.js";
|
|
10
|
+
import "axios";
|
|
11
|
+
import "../crypto-keys/encryptDecryptUtxo.js";
|
|
12
|
+
import { addPaddingToUtxos as R } from "../../functions/web3/events/getShieldedBalance.js";
|
|
13
|
+
import { outputUtxoProcessing as U } from "../../functions/pre-transaction/outputUtxoProcessing.js";
|
|
14
|
+
import "../../webworker/workerFactory.js";
|
|
15
|
+
import "../../functions/utils/external-action.utils.js";
|
|
16
|
+
import "../custom-token-registry/CustomTokenRegistry.js";
|
|
17
|
+
import "../../functions/utils/convertIntegrationProviderToExternalActionId.js";
|
|
18
|
+
import "../../constants/coingecko.constants.js";
|
|
19
|
+
import "../../constants/vite.constants.js";
|
|
20
|
+
import { processAmountChanges as C } from "../../functions/pre-transaction/processAmountChanges.js";
|
|
21
|
+
import "../../functions/utils/userAgent.js";
|
|
22
|
+
import { estimateGasRelayer as I } from "../../functions/web3/functionCalls/estimateGasRelayer.js";
|
|
23
|
+
import { transactCallRelayer as P } from "../../functions/web3/functionCalls/transactCallRelayer.js";
|
|
24
|
+
import "../../constants/reorg-depths.constants.js";
|
|
25
|
+
import "../../constants/kyc.constants.js";
|
|
26
|
+
import "../volatile-helper/VolatileHelper.js";
|
|
27
|
+
import { constructEmporiumProof as T } from "../../functions/snarkjs/constructEmporiumProof.js";
|
|
28
|
+
import "libsodium-wrappers";
|
|
29
|
+
import "../../constants/contracts.constants.js";
|
|
30
|
+
import "../../constants/axelar.constants.js";
|
|
31
|
+
import "../../constants/rewards.constants.js";
|
|
32
|
+
const pt = async (t, i, o, u, d = [], l, E = !1) => {
|
|
33
|
+
const e = i.map((r) => 0n);
|
|
34
|
+
o = C({ erc20Addresses: i, amountChanges: o, flatFees: e, feeUnit: void 0, externalActionId: g.Emporium });
|
|
35
|
+
const m = [...await R(t, i, o)], p = [];
|
|
36
|
+
for (let r = 0; r < i.length; r += 1) {
|
|
37
|
+
const { outputUtxos: y } = U(t.userKeys, m[r], o[r]);
|
|
38
|
+
p.push(y);
|
|
39
|
+
}
|
|
40
|
+
const a = await t.getRandomRelay();
|
|
41
|
+
if (!a)
|
|
42
|
+
throw Error(w.RELAYER_NOT_AVAILABLE);
|
|
43
|
+
const { contractData: x } = A[t.getCurrentChainId()], s = x.emporiumAddress;
|
|
44
|
+
if (!s)
|
|
45
|
+
throw Error("No Emporium Address Provided");
|
|
46
|
+
const { zkCallData: n, circomData: c, dimData: f } = await T(
|
|
47
|
+
t.merkleTreeHinkal,
|
|
48
|
+
t.merkleTreeAccessToken,
|
|
49
|
+
m,
|
|
50
|
+
p,
|
|
51
|
+
t.userKeys,
|
|
52
|
+
o.length,
|
|
53
|
+
m[0].length,
|
|
54
|
+
s,
|
|
55
|
+
d,
|
|
56
|
+
a,
|
|
57
|
+
t.getCurrentChainId(),
|
|
58
|
+
u,
|
|
59
|
+
e,
|
|
60
|
+
l
|
|
61
|
+
);
|
|
62
|
+
return E ? await I(t, n, f, c) : await P(t.getCurrentChainId(), n, f, c);
|
|
63
|
+
};
|
|
64
|
+
export {
|
|
65
|
+
pt as hinkalPrivateWallet
|
|
66
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { networkRegistry as R } from "../../constants/chains.constants.js";
|
|
2
|
+
import "../../types/circom-data.types.js";
|
|
3
|
+
import { ExternalActionId as n } from "../../types/external-action.types.js";
|
|
4
|
+
import "../../types/transactions.types.js";
|
|
5
|
+
import "../../types/curve.types.js";
|
|
6
|
+
import "ethers";
|
|
7
|
+
import { transactionErrorCodes as I } from "../../error-handling/error-codes.constants.js";
|
|
8
|
+
import "circomlibjs";
|
|
9
|
+
import "../crypto-keys/keys.js";
|
|
10
|
+
import "axios";
|
|
11
|
+
import "../crypto-keys/encryptDecryptUtxo.js";
|
|
12
|
+
import { addPaddingToUtxos as U } from "../../functions/web3/events/getShieldedBalance.js";
|
|
13
|
+
import { outputUtxoProcessing as D } from "../../functions/pre-transaction/outputUtxoProcessing.js";
|
|
14
|
+
import { constructZkProof as T } from "../../functions/snarkjs/constructGeneralZkProof.js";
|
|
15
|
+
import { estimateGasRelayer as b } from "../../functions/web3/functionCalls/estimateGasRelayer.js";
|
|
16
|
+
import { transactCallRelayer as F } from "../../functions/web3/functionCalls/transactCallRelayer.js";
|
|
17
|
+
import "../../functions/utils/external-action.utils.js";
|
|
18
|
+
import "../custom-token-registry/CustomTokenRegistry.js";
|
|
19
|
+
import "../../functions/utils/convertIntegrationProviderToExternalActionId.js";
|
|
20
|
+
import "../../constants/coingecko.constants.js";
|
|
21
|
+
import "../../constants/vite.constants.js";
|
|
22
|
+
import { processAmountChanges as L } from "../../functions/pre-transaction/processAmountChanges.js";
|
|
23
|
+
import { getFlatFees as M } from "../../functions/pre-transaction/getFlatFees.js";
|
|
24
|
+
import "../../functions/utils/userAgent.js";
|
|
25
|
+
import "../../constants/reorg-depths.constants.js";
|
|
26
|
+
import "../../constants/kyc.constants.js";
|
|
27
|
+
import "../../webworker/workerFactory.js";
|
|
28
|
+
import "../volatile-helper/VolatileHelper.js";
|
|
29
|
+
import "libsodium-wrappers";
|
|
30
|
+
import "../../constants/contracts.constants.js";
|
|
31
|
+
import "../../constants/axelar.constants.js";
|
|
32
|
+
import "../../constants/rewards.constants.js";
|
|
33
|
+
const N = (t, o) => {
|
|
34
|
+
const { contractData: r } = R[t.getCurrentChainId()];
|
|
35
|
+
let e;
|
|
36
|
+
switch (o) {
|
|
37
|
+
case n.Uniswap:
|
|
38
|
+
e = r?.uniswapExternalActionAddress;
|
|
39
|
+
break;
|
|
40
|
+
case n.Odos:
|
|
41
|
+
e = r?.odosExternalActionInstanceAddress;
|
|
42
|
+
break;
|
|
43
|
+
case n.OneInch:
|
|
44
|
+
e = r?.oneInchExternalActionInstanceAddress;
|
|
45
|
+
break;
|
|
46
|
+
default:
|
|
47
|
+
e = r?.uniswapExternalActionAddress;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
if (!e)
|
|
51
|
+
throw new Error("No external Address set during swap");
|
|
52
|
+
return e;
|
|
53
|
+
}, dt = async (t, o, r, e, u, A = !1, x = !1) => {
|
|
54
|
+
const { flatFees: p, feeUnit: w } = await M(
|
|
55
|
+
t.getCurrentChainId(),
|
|
56
|
+
o,
|
|
57
|
+
e,
|
|
58
|
+
r
|
|
59
|
+
);
|
|
60
|
+
r = L({ erc20Addresses: o, amountChanges: r, flatFees: p, feeUnit: w, externalActionId: e });
|
|
61
|
+
const E = N(t, e), s = {
|
|
62
|
+
externalActionId: e,
|
|
63
|
+
externalAddress: E,
|
|
64
|
+
externalActionMetadata: u
|
|
65
|
+
}, i = [...await U(t, o, r)], g = `swapperM${r.length.toString()}x${i[0].length}x1`, y = [!1, !0], m = [];
|
|
66
|
+
for (let a = 0; a < o.length; a += 1) {
|
|
67
|
+
const { outputUtxos: C } = D(t.userKeys, i[a], r[a]);
|
|
68
|
+
m.push(C);
|
|
69
|
+
}
|
|
70
|
+
const c = await t.getRandomRelay();
|
|
71
|
+
if (!c)
|
|
72
|
+
throw Error(I.RELAYER_NOT_AVAILABLE);
|
|
73
|
+
const { zkCallData: d, circomData: l, dimData: f } = await T(
|
|
74
|
+
t.merkleTreeHinkal,
|
|
75
|
+
t.merkleTreeAccessToken,
|
|
76
|
+
i,
|
|
77
|
+
m,
|
|
78
|
+
t.userKeys,
|
|
79
|
+
g,
|
|
80
|
+
s.externalActionId,
|
|
81
|
+
s.externalAddress,
|
|
82
|
+
s.externalActionMetadata,
|
|
83
|
+
c,
|
|
84
|
+
t.getCurrentChainId(),
|
|
85
|
+
y,
|
|
86
|
+
p
|
|
87
|
+
);
|
|
88
|
+
return A ? await b(t, d, f, l) : await F(
|
|
89
|
+
t.getCurrentChainId(),
|
|
90
|
+
d,
|
|
91
|
+
f,
|
|
92
|
+
l,
|
|
93
|
+
x
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
export {
|
|
97
|
+
dt as hinkalSwap
|
|
98
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import "../../constants/chains.constants.js";
|
|
2
|
+
import "../../types/circom-data.types.js";
|
|
3
|
+
import { ExternalActionId as l } from "../../types/external-action.types.js";
|
|
4
|
+
import "../../types/transactions.types.js";
|
|
5
|
+
import "../../types/curve.types.js";
|
|
6
|
+
import "ethers";
|
|
7
|
+
import { transactionErrorCodes as T } from "../../error-handling/error-codes.constants.js";
|
|
8
|
+
import { zeroAddress as I } from "../../constants/protocol.constants.js";
|
|
9
|
+
import "circomlibjs";
|
|
10
|
+
import "../crypto-keys/keys.js";
|
|
11
|
+
import "axios";
|
|
12
|
+
import "../crypto-keys/encryptDecryptUtxo.js";
|
|
13
|
+
import { addPaddingToUtxos as y } from "../../functions/web3/events/getShieldedBalance.js";
|
|
14
|
+
import { outputUtxoProcessing as D } from "../../functions/pre-transaction/outputUtxoProcessing.js";
|
|
15
|
+
import { constructZkProof as U } from "../../functions/snarkjs/constructGeneralZkProof.js";
|
|
16
|
+
import { estimateGasRelayer as F } from "../../functions/web3/functionCalls/estimateGasRelayer.js";
|
|
17
|
+
import { transactCallRelayer as N } from "../../functions/web3/functionCalls/transactCallRelayer.js";
|
|
18
|
+
import { transactCallDirect as R } from "../../functions/web3/functionCalls/transactCallDirect.js";
|
|
19
|
+
import "../../functions/utils/external-action.utils.js";
|
|
20
|
+
import { getERC20Token as L } from "../../functions/utils/erc20tokenFunctions.js";
|
|
21
|
+
import "../../functions/utils/convertIntegrationProviderToExternalActionId.js";
|
|
22
|
+
import "../../constants/coingecko.constants.js";
|
|
23
|
+
import "../../constants/vite.constants.js";
|
|
24
|
+
import { processAmountChanges as M } from "../../functions/pre-transaction/processAmountChanges.js";
|
|
25
|
+
import { getFlatFees as P } from "../../functions/pre-transaction/getFlatFees.js";
|
|
26
|
+
import "../../functions/utils/userAgent.js";
|
|
27
|
+
import "../../constants/reorg-depths.constants.js";
|
|
28
|
+
import "../../constants/kyc.constants.js";
|
|
29
|
+
import "../../webworker/workerFactory.js";
|
|
30
|
+
import "../volatile-helper/VolatileHelper.js";
|
|
31
|
+
import "../custom-token-registry/CustomTokenRegistry.js";
|
|
32
|
+
import "libsodium-wrappers";
|
|
33
|
+
import "../../constants/contracts.constants.js";
|
|
34
|
+
import "../../constants/axelar.constants.js";
|
|
35
|
+
import "../../constants/rewards.constants.js";
|
|
36
|
+
const lt = async (t, i, r, u, e, A = !1) => {
|
|
37
|
+
const { flatFees: x, feeUnit: w } = await P(
|
|
38
|
+
t.getCurrentChainId(),
|
|
39
|
+
i,
|
|
40
|
+
l.Transact,
|
|
41
|
+
r
|
|
42
|
+
);
|
|
43
|
+
e || M({
|
|
44
|
+
erc20Addresses: i,
|
|
45
|
+
amountChanges: r,
|
|
46
|
+
flatFees: x,
|
|
47
|
+
feeUnit: w,
|
|
48
|
+
externalActionId: l.Transact
|
|
49
|
+
});
|
|
50
|
+
const a = L(i[0], t.getCurrentChainId());
|
|
51
|
+
if (!a)
|
|
52
|
+
throw Error("Deposit Action: No Token Found");
|
|
53
|
+
const n = {
|
|
54
|
+
externalActionId: 0n,
|
|
55
|
+
externalAddress: u,
|
|
56
|
+
externalActionMetadata: "0x00"
|
|
57
|
+
}, m = [...await y(t, i, r)], g = `swapperM${r.length.toString()}x${m[0].length}x1`, C = [!1], d = [];
|
|
58
|
+
for (let o = 0; o < i.length; o += 1) {
|
|
59
|
+
const { outputUtxos: E } = D(t.userKeys, m[o], r[o]);
|
|
60
|
+
d.push(E);
|
|
61
|
+
}
|
|
62
|
+
const f = await t.getRandomRelay();
|
|
63
|
+
if (!e && !f)
|
|
64
|
+
throw Error(T.RELAYER_NOT_AVAILABLE);
|
|
65
|
+
const { zkCallData: p, circomData: c, dimData: s } = await U(
|
|
66
|
+
t.merkleTreeHinkal,
|
|
67
|
+
t.merkleTreeAccessToken,
|
|
68
|
+
m,
|
|
69
|
+
d,
|
|
70
|
+
t.userKeys,
|
|
71
|
+
g,
|
|
72
|
+
n.externalActionId,
|
|
73
|
+
n.externalAddress,
|
|
74
|
+
n.externalActionMetadata,
|
|
75
|
+
e ? I : f,
|
|
76
|
+
t.getCurrentChainId(),
|
|
77
|
+
C,
|
|
78
|
+
x
|
|
79
|
+
);
|
|
80
|
+
if (A)
|
|
81
|
+
return await F(t, p, s, c);
|
|
82
|
+
if (e) {
|
|
83
|
+
if (!a)
|
|
84
|
+
throw Error("Withdraw Action: No Token Found");
|
|
85
|
+
return await R(t, r[0], a, p, c, s);
|
|
86
|
+
}
|
|
87
|
+
return await N(t.getCurrentChainId(), p, s, c);
|
|
88
|
+
};
|
|
89
|
+
export {
|
|
90
|
+
lt as hinkalWithdraw
|
|
91
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { networkRegistry as i } from "../../constants/chains.constants.js";
|
|
2
|
+
import "../../types/circom-data.types.js";
|
|
3
|
+
import { ContractType as r } from "../../types/ethereum-network.types.js";
|
|
4
|
+
import "../../types/transactions.types.js";
|
|
5
|
+
import "../../types/curve.types.js";
|
|
6
|
+
import "ethers";
|
|
7
|
+
import "circomlibjs";
|
|
8
|
+
import "../crypto-keys/keys.js";
|
|
9
|
+
import "axios";
|
|
10
|
+
import "../crypto-keys/encryptDecryptUtxo.js";
|
|
11
|
+
import "../../functions/web3/events/getShieldedBalance.js";
|
|
12
|
+
import "../../webworker/workerFactory.js";
|
|
13
|
+
import "../../functions/utils/external-action.utils.js";
|
|
14
|
+
import "../custom-token-registry/CustomTokenRegistry.js";
|
|
15
|
+
import "../../functions/utils/convertIntegrationProviderToExternalActionId.js";
|
|
16
|
+
import "../../constants/coingecko.constants.js";
|
|
17
|
+
import "../../constants/vite.constants.js";
|
|
18
|
+
import "../../functions/utils/userAgent.js";
|
|
19
|
+
import { ClientAccessTokenSnapshotService as m } from "../snapshot/ClientAccessTokenSnapshotService.js";
|
|
20
|
+
import { ClientCommitmentsSnapshotService as n } from "../snapshot/ClientCommitmentsSnapshotService.js";
|
|
21
|
+
import { ClientNullifierSnapshotService as c } from "../snapshot/ClientNullifierSnapshotService.js";
|
|
22
|
+
import "../../constants/kyc.constants.js";
|
|
23
|
+
import "../volatile-helper/VolatileHelper.js";
|
|
24
|
+
import "../../constants/reorg-depths.constants.js";
|
|
25
|
+
import { balanceChangedHandler as o } from "../../functions/web3/events/balanceChangedHandler.js";
|
|
26
|
+
import "libsodium-wrappers";
|
|
27
|
+
import "../../constants/contracts.constants.js";
|
|
28
|
+
import "../../constants/axelar.constants.js";
|
|
29
|
+
import "../../constants/rewards.constants.js";
|
|
30
|
+
const j = async (e) => {
|
|
31
|
+
const { maxPageSize: t } = i[e.getCurrentChainId()];
|
|
32
|
+
e.commitmentsSnapshotService?.intervalClear(), e.commitmentsSnapshotService = new n(
|
|
33
|
+
e.getContractWithFetcher(r.HinkalContract),
|
|
34
|
+
t
|
|
35
|
+
), e.nullifierSnapshotService?.intervalClear(), e.nullifierSnapshotService = new c(
|
|
36
|
+
e.getContractWithFetcher(r.HinkalContract),
|
|
37
|
+
t
|
|
38
|
+
), e.accessTokenSnapshotService?.intervalClear(), e.accessTokenSnapshotService = new m(
|
|
39
|
+
e.getContractWithFetcher(r.CrossChainAccessTokenContract),
|
|
40
|
+
t
|
|
41
|
+
), await Promise.all([
|
|
42
|
+
e.commitmentsSnapshotService.init(),
|
|
43
|
+
e.nullifierSnapshotService.init(),
|
|
44
|
+
e.accessTokenSnapshotService.init()
|
|
45
|
+
]), e.merkleTreeHinkal = e.commitmentsSnapshotService.merkleTree, e.merkleTreeAccessToken = e.accessTokenSnapshotService.merkleTree, e.nullifiers = e.nullifierSnapshotService.nullifiers, e.encryptedOutputs = e.commitmentsSnapshotService.encryptedOutputs, e.commitmentsSnapshotService.onNewEvent = o, e.nullifierSnapshotService.onNewEvent = o;
|
|
46
|
+
};
|
|
47
|
+
export {
|
|
48
|
+
j as resetMerkleTrees
|
|
49
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import "../../constants/chains.constants.js";
|
|
2
|
+
import "../../types/circom-data.types.js";
|
|
3
|
+
import "../../types/transactions.types.js";
|
|
4
|
+
import "../../types/curve.types.js";
|
|
5
|
+
import "ethers";
|
|
6
|
+
import { Utxo as p } from "../utxo/Utxo.js";
|
|
7
|
+
import "axios";
|
|
8
|
+
import "../crypto-keys/keys.js";
|
|
9
|
+
import "../crypto-keys/encryptDecryptUtxo.js";
|
|
10
|
+
import "../../functions/web3/events/getShieldedBalance.js";
|
|
11
|
+
import { performTaskWithWorker as n } from "../../webworker/performTaskWithWorker.js";
|
|
12
|
+
import { WorkerVariant as c } from "../../webworker/worker.registry.js";
|
|
13
|
+
import "../../functions/utils/external-action.utils.js";
|
|
14
|
+
import "../custom-token-registry/CustomTokenRegistry.js";
|
|
15
|
+
import "../../functions/utils/convertIntegrationProviderToExternalActionId.js";
|
|
16
|
+
import "../../functions/utils/userAgent.js";
|
|
17
|
+
import "circomlibjs";
|
|
18
|
+
import "../../constants/reorg-depths.constants.js";
|
|
19
|
+
import "../../constants/kyc.constants.js";
|
|
20
|
+
import "../../constants/coingecko.constants.js";
|
|
21
|
+
import "../../constants/vite.constants.js";
|
|
22
|
+
import "../volatile-helper/VolatileHelper.js";
|
|
23
|
+
import { UtxoWorkerActionType as m } from "../../webworker/utxoWorker/utxoWorker.types.js";
|
|
24
|
+
import "libsodium-wrappers";
|
|
25
|
+
import "../../constants/contracts.constants.js";
|
|
26
|
+
import "../../constants/axelar.constants.js";
|
|
27
|
+
import "../../constants/rewards.constants.js";
|
|
28
|
+
class l {
|
|
29
|
+
get NUM_WORKERS() {
|
|
30
|
+
return 5;
|
|
31
|
+
}
|
|
32
|
+
async createUtxoPromise(t) {
|
|
33
|
+
return await n({
|
|
34
|
+
type: c.UTXO,
|
|
35
|
+
payload: t
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async batchFilterUtxosWithNullifier(t, r) {
|
|
39
|
+
const e = this.sliceArrayIntoParts(t, this.NUM_WORKERS).map(
|
|
40
|
+
(s) => this.createUtxoPromise(
|
|
41
|
+
{
|
|
42
|
+
type: m.BATCH_FILTER_UTXOS_WITH_NULLIFIER,
|
|
43
|
+
data: {
|
|
44
|
+
utxos: s.map((i) => i.getConstructableParams()),
|
|
45
|
+
nullifiers: r
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
);
|
|
50
|
+
return (await Promise.all(e)).flat().map((s) => new p(s));
|
|
51
|
+
}
|
|
52
|
+
async buildBatchProcess(t, r) {
|
|
53
|
+
const e = this.sliceArrayIntoParts(t, this.NUM_WORKERS).map(
|
|
54
|
+
(i) => this.createUtxoPromise(
|
|
55
|
+
{ type: m.BUILD_UTXOS, data: { signature: r.getSignature(), encryptedOutputs: i } }
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
return (await Promise.all(e)).flat().map((i) => new p(i));
|
|
59
|
+
}
|
|
60
|
+
sliceArrayIntoParts(t, r) {
|
|
61
|
+
const o = Math.ceil(t.length / r);
|
|
62
|
+
return Array.from(
|
|
63
|
+
{ length: r },
|
|
64
|
+
(a, s) => t.slice(o * s, o * (s + 1))
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
async batchProcess(t, r, o) {
|
|
68
|
+
const e = {
|
|
69
|
+
type: m.DECIPHER_OUTPUTS,
|
|
70
|
+
data: {
|
|
71
|
+
encryptedOutputs: t,
|
|
72
|
+
lastOutput: r,
|
|
73
|
+
signature: o.getSignature()
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
return await this.createUtxoPromise(e);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const K = new l();
|
|
80
|
+
export {
|
|
81
|
+
l as MultiThreadedUtxoUtils,
|
|
82
|
+
K as multiThreadedUtxoUtils
|
|
83
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
class e {
|
|
2
|
+
constructor(t) {
|
|
3
|
+
this.timeoutInMs = t, this.setTimer();
|
|
4
|
+
}
|
|
5
|
+
timeoutInMs;
|
|
6
|
+
values = {};
|
|
7
|
+
setTimer() {
|
|
8
|
+
if (this.timeoutInMs > 0) {
|
|
9
|
+
const t = this;
|
|
10
|
+
setInterval(() => {
|
|
11
|
+
t.onTimeout();
|
|
12
|
+
}, this.timeoutInMs);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
// clear cache when times-up
|
|
16
|
+
onTimeout() {
|
|
17
|
+
this.clear();
|
|
18
|
+
}
|
|
19
|
+
clear() {
|
|
20
|
+
this.values = {};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
e as ValueCache
|
|
25
|
+
};
|