@hinkal/common 0.0.104 → 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 +116 -1
- 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-DbehuQxV.mjs +0 -398145
- package/index.mjs +0 -457
- package/snarkjsWorkerLogic-BpNWzeoy.mjs +0 -12086
- package/utxoWorkerLogic-D7NuHk_K.mjs +0 -64
- package/viteWorkerURL.constant-Bc7ufzqC.mjs +0 -9
- package/zkProofWorkerLogic-Bnalmuka.mjs +0 -60
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { chainIds as J } from "../../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 { HinkalStakeMode as c } from "../../types/hinkal.stake.types.js";
|
|
6
|
+
import { randomBigInt as V } from "../web3/etherFunctions.js";
|
|
7
|
+
import { Utxo as j } from "../../data-structures/utxo/Utxo.js";
|
|
8
|
+
import "axios";
|
|
9
|
+
import "ethers";
|
|
10
|
+
import "../../data-structures/crypto-keys/keys.js";
|
|
11
|
+
import "../../data-structures/crypto-keys/encryptDecryptUtxo.js";
|
|
12
|
+
import { zeroAddress as q } from "../../constants/protocol.constants.js";
|
|
13
|
+
import "../web3/events/getShieldedBalance.js";
|
|
14
|
+
import { performTaskWithWorker as s } from "../../webworker/performTaskWithWorker.js";
|
|
15
|
+
import { WorkerVariant as l } from "../../webworker/worker.registry.js";
|
|
16
|
+
import { ZKProofWorkerActionType as S } from "../../webworker/zkProofWorker/zkProofWorker.types.js";
|
|
17
|
+
import { calcAmountChanges as F, calcEncryptedOutputs as Q, buildOutCommitments as X, calcPublicSignalCount as Y, createCallDataHash as $, calcStealthAddressStructure as U } from "./common.snarkjs.js";
|
|
18
|
+
import { generateCircomData as x } from "./generateCircomData.js";
|
|
19
|
+
import { generateZkProof as oo } from "./generateZkProof.js";
|
|
20
|
+
import "circomlibjs";
|
|
21
|
+
import "../utils/external-action.utils.js";
|
|
22
|
+
import "../../data-structures/custom-token-registry/CustomTokenRegistry.js";
|
|
23
|
+
import "../utils/convertIntegrationProviderToExternalActionId.js";
|
|
24
|
+
import "../../constants/coingecko.constants.js";
|
|
25
|
+
import "../../constants/vite.constants.js";
|
|
26
|
+
import "../utils/userAgent.js";
|
|
27
|
+
import "../../constants/reorg-depths.constants.js";
|
|
28
|
+
import "../../constants/kyc.constants.js";
|
|
29
|
+
import "../../data-structures/volatile-helper/VolatileHelper.js";
|
|
30
|
+
import "libsodium-wrappers";
|
|
31
|
+
import "../../constants/contracts.constants.js";
|
|
32
|
+
import "../../constants/axelar.constants.js";
|
|
33
|
+
import "../../constants/rewards.constants.js";
|
|
34
|
+
const Lo = async (f, g, e, a, h, u, k, C, I, T = q, R = J.localhost, r = e.map(() => !1), y = e.map(() => 0n), b = void 0, m) => {
|
|
35
|
+
const N = f.getRootHash(), P = g.getRootHash(), D = e.map((o) => o.map((i) => i.getConstructableParams())), _ = h.getSignature(), { accessTokenSiblings: B, accessTokenSiblingSides: E } = await s({
|
|
36
|
+
type: l.ZKProof,
|
|
37
|
+
payload: {
|
|
38
|
+
type: S.CALC_ACCESS_TOKEN_SIBLING_AND_SIDES,
|
|
39
|
+
data: {
|
|
40
|
+
userSignature: _,
|
|
41
|
+
merkleTreeAccessTokenSerialized: g.toJSON()
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}), { inCommitmentSiblings: K, inCommitmentSiblingSides: L } = await s({
|
|
45
|
+
type: l.ZKProof,
|
|
46
|
+
payload: {
|
|
47
|
+
type: S.CALC_COMMITMENTS_SIBLING_AND_SIDES,
|
|
48
|
+
data: { inputUtxosSerialized: D, userSignature: _, merkleTreeSerialized: f.toJSON() }
|
|
49
|
+
}
|
|
50
|
+
}), O = F(e, a), d = Q(
|
|
51
|
+
a,
|
|
52
|
+
(m && m.mode !== c.Deposit) ?? !1
|
|
53
|
+
), p = h.getShieldedPrivateKey(), H = j.findCorrectRandomization(V(31), p), Z = await s({
|
|
54
|
+
type: l.ZKProof,
|
|
55
|
+
payload: {
|
|
56
|
+
type: S.BUILD_IN_NULLIFIERS,
|
|
57
|
+
data: { inputUtxosSerialized: D, onChainCreation: r }
|
|
58
|
+
}
|
|
59
|
+
}), t = {
|
|
60
|
+
rootHashHinkal: N,
|
|
61
|
+
shieldedPrivateKey: p,
|
|
62
|
+
erc20TokenAddresses: e.map((o) => o[0].erc20TokenAddress),
|
|
63
|
+
inAmounts: e.map((o) => o.map((i) => i.amount.toString())),
|
|
64
|
+
inTimeStamps: e.map((o) => o.map((i) => i.timeStamp)),
|
|
65
|
+
inRandomizations: e.map((o) => o.map((i) => i.randomization)),
|
|
66
|
+
inNullifiers: Z,
|
|
67
|
+
inCommitmentSiblings: K,
|
|
68
|
+
inCommitmentSiblingSides: L,
|
|
69
|
+
outAmounts: a.map((o) => o.map((i) => i.amount.toString())),
|
|
70
|
+
outTimeStamp: BigInt(a[0][0].timeStamp),
|
|
71
|
+
outPublicKeys: a.map((o) => o.map((i) => i.getStealthAddress())),
|
|
72
|
+
extraRandomization: H,
|
|
73
|
+
amountChanges: O,
|
|
74
|
+
outCommitments: X(a, r),
|
|
75
|
+
rootHashAccessToken: P,
|
|
76
|
+
accessTokenSiblings: B,
|
|
77
|
+
accessTokenSiblingSides: E,
|
|
78
|
+
calldataHash: 0n
|
|
79
|
+
};
|
|
80
|
+
m || (t.onChainCreation = r);
|
|
81
|
+
const n = e.map((o) => o[0].tokenId ?? 0), z = n.reduce((o, i) => o + i, 0) > 0 ? n.length : 0;
|
|
82
|
+
z > 0 && (t.tokenIds = n);
|
|
83
|
+
const A = Y(
|
|
84
|
+
u,
|
|
85
|
+
t.erc20TokenAddresses,
|
|
86
|
+
t.amountChanges,
|
|
87
|
+
t.inNullifiers,
|
|
88
|
+
t.outCommitments,
|
|
89
|
+
z
|
|
90
|
+
);
|
|
91
|
+
t.calldataHash = $(
|
|
92
|
+
A,
|
|
93
|
+
T,
|
|
94
|
+
C,
|
|
95
|
+
k,
|
|
96
|
+
I,
|
|
97
|
+
d,
|
|
98
|
+
y,
|
|
99
|
+
b
|
|
100
|
+
), m && (m.mode === c.Deposit && (t.mode = 0), m.mode === c.Stake && (t.mode = 1), m.mode === c.Unstake && (t.mode = 2), t.stakedTokenRecipient = m.stakedTokenRecipient, t.stakeBlinding = m.stakeBlinding, t.depositorAddress = m.depositorAddress);
|
|
101
|
+
const { zkCallData: w, publicSignals: W } = await oo(R, u, t);
|
|
102
|
+
console.log("publicSignals", W);
|
|
103
|
+
const v = U(H, p), M = await x(
|
|
104
|
+
N,
|
|
105
|
+
P,
|
|
106
|
+
e,
|
|
107
|
+
a,
|
|
108
|
+
d,
|
|
109
|
+
y,
|
|
110
|
+
A,
|
|
111
|
+
k,
|
|
112
|
+
C,
|
|
113
|
+
I,
|
|
114
|
+
T,
|
|
115
|
+
t.calldataHash,
|
|
116
|
+
n,
|
|
117
|
+
v,
|
|
118
|
+
r,
|
|
119
|
+
b
|
|
120
|
+
), G = {
|
|
121
|
+
tokenNumber: e.length,
|
|
122
|
+
nullifierAmount: e[0].length,
|
|
123
|
+
outputAmount: a[0].length
|
|
124
|
+
};
|
|
125
|
+
return { zkCallData: w, circomData: M, dimData: G, encryptedOutputs: d };
|
|
126
|
+
};
|
|
127
|
+
export {
|
|
128
|
+
Lo as constructZkProof
|
|
129
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import "../../constants/chains.constants.js";
|
|
2
|
+
import { defaultHookData as S } from "../../types/circom-data.types.js";
|
|
3
|
+
import "../../types/transactions.types.js";
|
|
4
|
+
import "../../types/curve.types.js";
|
|
5
|
+
import "ethers";
|
|
6
|
+
import { zeroAddress as h } from "../../constants/protocol.constants.js";
|
|
7
|
+
import "circomlibjs";
|
|
8
|
+
import "../../data-structures/crypto-keys/keys.js";
|
|
9
|
+
import "axios";
|
|
10
|
+
import "../../data-structures/crypto-keys/encryptDecryptUtxo.js";
|
|
11
|
+
import "../web3/events/getShieldedBalance.js";
|
|
12
|
+
import { performTaskWithWorker as C } from "../../webworker/performTaskWithWorker.js";
|
|
13
|
+
import { WorkerVariant as T } from "../../webworker/worker.registry.js";
|
|
14
|
+
import { ZKProofWorkerActionType as W } from "../../webworker/zkProofWorker/zkProofWorker.types.js";
|
|
15
|
+
import { calcAmountChanges as b, buildOutCommitments as L } from "./common.snarkjs.js";
|
|
16
|
+
import { getExternalActionIdHash as N } from "../utils/external-action.utils.js";
|
|
17
|
+
import "../../data-structures/custom-token-registry/CustomTokenRegistry.js";
|
|
18
|
+
import "../utils/convertIntegrationProviderToExternalActionId.js";
|
|
19
|
+
import "../../constants/coingecko.constants.js";
|
|
20
|
+
import "../../constants/vite.constants.js";
|
|
21
|
+
import "../utils/userAgent.js";
|
|
22
|
+
import "../../constants/reorg-depths.constants.js";
|
|
23
|
+
import "../../constants/kyc.constants.js";
|
|
24
|
+
import "../../data-structures/volatile-helper/VolatileHelper.js";
|
|
25
|
+
import "libsodium-wrappers";
|
|
26
|
+
import "../../constants/contracts.constants.js";
|
|
27
|
+
import "../../constants/axelar.constants.js";
|
|
28
|
+
import "../../constants/rewards.constants.js";
|
|
29
|
+
const ir = async (e, a, o, t, n, s, c, m, i, d, f, k, l, g, p, u) => {
|
|
30
|
+
const y = b(o, t, !0), A = o.map((r) => r.map((I) => I.getConstructableParams())), D = await C({
|
|
31
|
+
type: T.ZKProof,
|
|
32
|
+
payload: {
|
|
33
|
+
type: W.BUILD_IN_NULLIFIERS,
|
|
34
|
+
data: { inputUtxosSerialized: A, onChainCreation: p }
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
rootHashHinkal: e,
|
|
39
|
+
erc20TokenAddresses: o.map((r) => r[0].erc20TokenAddress),
|
|
40
|
+
tokenIds: l.map((r) => String(r)),
|
|
41
|
+
amountChanges: y,
|
|
42
|
+
inputNullifiers: D,
|
|
43
|
+
outCommitments: L(t, p),
|
|
44
|
+
encryptedOutputs: n,
|
|
45
|
+
flatFees: s,
|
|
46
|
+
timeStamp: t[0][0].timeStamp,
|
|
47
|
+
stealthAddressStructure: g,
|
|
48
|
+
rootHashAccessToken: a,
|
|
49
|
+
relay: f,
|
|
50
|
+
externalAddress: i === void 0 ? h : i,
|
|
51
|
+
externalActionMetadata: d,
|
|
52
|
+
externalActionId: typeof m == "bigint" ? 0n : N(m),
|
|
53
|
+
hookData: u || S,
|
|
54
|
+
publicSignalCount: c,
|
|
55
|
+
calldataHash: k
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
export {
|
|
59
|
+
ir as generateCircomData
|
|
60
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { performTaskWithWorker as p } from "../../webworker/performTaskWithWorker.js";
|
|
2
|
+
import { SnarkJSWorkerActionType as i } from "../../webworker/snarkjsWorker/snarkjsWorker.types.js";
|
|
3
|
+
import { WorkerVariant as c } from "../../webworker/worker.registry.js";
|
|
4
|
+
import { getZKeyFile as r, getWASMFile as g } from "./getZKFiles.js";
|
|
5
|
+
const S = async (o, t, e) => {
|
|
6
|
+
console.log("Zero Knowledge proof construction started, please wait...", r(t, o));
|
|
7
|
+
const a = g(t, o), n = r(t, o), { publicSignals: l, zkCallData: s } = await p({
|
|
8
|
+
type: c.SnarkJS,
|
|
9
|
+
payload: {
|
|
10
|
+
type: i.FULL_PROVE,
|
|
11
|
+
data: { input: e, chainId: o, wasmFilePath: a, zKeyFilePath: n }
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
return console.log("Zero Knowledge proof construction finished "), { zkCallData: s, publicSignals: l };
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
S as generateZkProof
|
|
18
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { chainIds as o } from "../../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 "../../data-structures/crypto-keys/keys.js";
|
|
8
|
+
import "axios";
|
|
9
|
+
import "../../data-structures/crypto-keys/encryptDecryptUtxo.js";
|
|
10
|
+
import "../web3/events/getShieldedBalance.js";
|
|
11
|
+
import "../../webworker/workerFactory.js";
|
|
12
|
+
import "../utils/external-action.utils.js";
|
|
13
|
+
import "../../data-structures/custom-token-registry/CustomTokenRegistry.js";
|
|
14
|
+
import "../utils/convertIntegrationProviderToExternalActionId.js";
|
|
15
|
+
import "../../constants/coingecko.constants.js";
|
|
16
|
+
import "../../constants/vite.constants.js";
|
|
17
|
+
import "../utils/userAgent.js";
|
|
18
|
+
import { prodVerifiers as t, localVerifiers as m } from "./constant.js";
|
|
19
|
+
import "../../constants/reorg-depths.constants.js";
|
|
20
|
+
import "../../constants/kyc.constants.js";
|
|
21
|
+
import "../../data-structures/volatile-helper/VolatileHelper.js";
|
|
22
|
+
import "libsodium-wrappers";
|
|
23
|
+
import "../../constants/contracts.constants.js";
|
|
24
|
+
import "../../constants/axelar.constants.js";
|
|
25
|
+
import "../../constants/rewards.constants.js";
|
|
26
|
+
const j = (r, i) => i === o.localhost ? m[`${r}Wasm`] : t(i)[`${r}Wasm`], q = (r, i) => i === o.localhost ? m[`${r}Zkey`] : t(i)[`${r}Zkey`];
|
|
27
|
+
export {
|
|
28
|
+
j as getWASMFile,
|
|
29
|
+
q as getZKeyFile
|
|
30
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ethers as i } from "ethers";
|
|
2
|
+
import { UserKeys as f } from "../../data-structures/crypto-keys/keys.js";
|
|
3
|
+
import s from "libsodium-wrappers";
|
|
4
|
+
import { poseidonHash as c } from "../../crypto/poseidon.js";
|
|
5
|
+
import "circomlibjs";
|
|
6
|
+
const S = (t, e, r) => {
|
|
7
|
+
const o = i.utils.defaultAbiCoder.encode(
|
|
8
|
+
["uint256", "address"],
|
|
9
|
+
[t, e]
|
|
10
|
+
), n = s.crypto_box_seal(o, i.utils.arrayify(r));
|
|
11
|
+
return `0x${Buffer.from(n).toString("hex")}`;
|
|
12
|
+
}, k = (t, e) => {
|
|
13
|
+
const r = Buffer.from(t.slice(2), "hex"), { publicKey: o, privateKey: n } = f.getEncryptionKeyPair(e.getShieldedPrivateKey());
|
|
14
|
+
try {
|
|
15
|
+
const a = s.crypto_box_seal_open(
|
|
16
|
+
r,
|
|
17
|
+
i.utils.arrayify(o),
|
|
18
|
+
i.utils.arrayify(n)
|
|
19
|
+
), d = Buffer.from(a).toString("utf-8"), [u, y] = i.utils.defaultAbiCoder.decode(
|
|
20
|
+
["uint256", "address"],
|
|
21
|
+
d
|
|
22
|
+
);
|
|
23
|
+
return { stakeBlinding: u.toBigInt(), stakedTokenRecipient: y };
|
|
24
|
+
} catch {
|
|
25
|
+
console.log("failed to decrypt");
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
}, B = (t, e, r, o, n, a) => BigInt(
|
|
29
|
+
c(...[t, e, r, o, n, a].map(BigInt))
|
|
30
|
+
), h = (t, e) => c(t, e), x = (t, e, r, o, n) => i.utils.defaultAbiCoder.encode(
|
|
31
|
+
["uint8", "uint256", "address", "bytes", "bytes"],
|
|
32
|
+
[t, e, r, o, n]
|
|
33
|
+
);
|
|
34
|
+
export {
|
|
35
|
+
h as calculateStakeNullifier,
|
|
36
|
+
B as createStakeCommitment,
|
|
37
|
+
k as decryptStake,
|
|
38
|
+
x as encodeHStakeMetadata,
|
|
39
|
+
S as encryptStake
|
|
40
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const s = (t) => t.reduce((n, e) => n + e, 0), u = (t) => t / 100, a = (t, n) => n * t / 10000n;
|
|
2
|
+
function d(t) {
|
|
3
|
+
return typeof t == "object" && "toBigInt" in t ? t.toBigInt() : BigInt(t);
|
|
4
|
+
}
|
|
5
|
+
const g = (t) => {
|
|
6
|
+
try {
|
|
7
|
+
return BigInt(t);
|
|
8
|
+
} catch {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
}, f = (t) => {
|
|
12
|
+
const n = Number(t);
|
|
13
|
+
return Number.isNaN(n) ? void 0 : n;
|
|
14
|
+
}, m = (t, n) => t ? parseInt(t, 10) : n;
|
|
15
|
+
function l() {
|
|
16
|
+
BigInt.prototype.toJSON = function() {
|
|
17
|
+
return this.toString();
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function p(...t) {
|
|
21
|
+
return t.reduce((n, e) => e > n ? e : n);
|
|
22
|
+
}
|
|
23
|
+
function I(t) {
|
|
24
|
+
return t === 0 ? 0 : t < 99999e-11 ? "< 0.000001" : +Number(t).toFixed(6);
|
|
25
|
+
}
|
|
26
|
+
const B = (t, n) => {
|
|
27
|
+
const e = t.toFixed(20), r = e.indexOf(".");
|
|
28
|
+
if (r === -1)
|
|
29
|
+
return e;
|
|
30
|
+
const o = r + n + 1;
|
|
31
|
+
return e.substring(0, o);
|
|
32
|
+
}, i = (t) => {
|
|
33
|
+
if (/^0+$/.test(t))
|
|
34
|
+
return "0";
|
|
35
|
+
if (/^0\.\d+$/.test(t))
|
|
36
|
+
return t;
|
|
37
|
+
const n = t.replace(/^0+/, "");
|
|
38
|
+
return n.startsWith(".") ? `0${n}` : n;
|
|
39
|
+
}, N = (t) => {
|
|
40
|
+
const n = t.split("."), e = n[0], r = n.length > 1 ? `.${n[1]}` : "";
|
|
41
|
+
return `${i(e).replace(/\B(?=(\d{3})+(?!\d))/g, ",")}${r}`;
|
|
42
|
+
}, P = (t) => {
|
|
43
|
+
const n = t.match(/^(\d+)(\.\d{1,18})?\d*$/);
|
|
44
|
+
if (n) {
|
|
45
|
+
const e = n[1], r = n[2] || "";
|
|
46
|
+
return `${e}${r}`;
|
|
47
|
+
}
|
|
48
|
+
return t;
|
|
49
|
+
}, $ = (t) => t < 0n ? -t : t, b = (t, n, e) => {
|
|
50
|
+
const r = t < n ? t : n;
|
|
51
|
+
return e ? r < e ? r : e : r;
|
|
52
|
+
};
|
|
53
|
+
export {
|
|
54
|
+
$ as absBigInt,
|
|
55
|
+
u as beepsToPercentage,
|
|
56
|
+
l as bigintApplySugar,
|
|
57
|
+
p as bigintMax,
|
|
58
|
+
a as calculateAmountUsingBeeps,
|
|
59
|
+
s as calculateSum,
|
|
60
|
+
I as fixDecimalsAmount,
|
|
61
|
+
B as getValueFirstNDigit,
|
|
62
|
+
b as minBigInt,
|
|
63
|
+
d as toBigInt,
|
|
64
|
+
g as toBigIntOrUndefined,
|
|
65
|
+
N as toCommaSeparatedNumberString,
|
|
66
|
+
m as toInt,
|
|
67
|
+
f as toNumberOrUndefined,
|
|
68
|
+
i as trimLeadingZeros,
|
|
69
|
+
P as truncateTo18DecimalPlaces
|
|
70
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
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 "../../data-structures/crypto-keys/keys.js";
|
|
8
|
+
import "axios";
|
|
9
|
+
import "../../data-structures/crypto-keys/encryptDecryptUtxo.js";
|
|
10
|
+
import "../web3/events/getShieldedBalance.js";
|
|
11
|
+
import "../../webworker/workerFactory.js";
|
|
12
|
+
import "./external-action.utils.js";
|
|
13
|
+
import "../../data-structures/custom-token-registry/CustomTokenRegistry.js";
|
|
14
|
+
import "./convertIntegrationProviderToExternalActionId.js";
|
|
15
|
+
import "../../constants/coingecko.constants.js";
|
|
16
|
+
import "../../constants/vite.constants.js";
|
|
17
|
+
import "./userAgent.js";
|
|
18
|
+
import "../../constants/reorg-depths.constants.js";
|
|
19
|
+
import "../../constants/kyc.constants.js";
|
|
20
|
+
import "../../data-structures/volatile-helper/VolatileHelper.js";
|
|
21
|
+
import "libsodium-wrappers";
|
|
22
|
+
import "../../constants/contracts.constants.js";
|
|
23
|
+
import { AxelarRegistry as p } from "../../constants/axelar.constants.js";
|
|
24
|
+
import "../../constants/rewards.constants.js";
|
|
25
|
+
const z = (i) => {
|
|
26
|
+
const r = p.find((m) => m.chainId === i.chainId);
|
|
27
|
+
if (!r)
|
|
28
|
+
return;
|
|
29
|
+
const { sourceChain: t, sourceAddress: o } = r;
|
|
30
|
+
return {
|
|
31
|
+
destinationChain: t,
|
|
32
|
+
destinationAddress: o,
|
|
33
|
+
messageFee: i.gasFeeInWei ?? 0n
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
z as getAxelarMigrationInfo
|
|
38
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import "ethers";
|
|
2
|
+
import "axios";
|
|
3
|
+
import "../../constants/chains.constants.js";
|
|
4
|
+
import "../../types/circom-data.types.js";
|
|
5
|
+
import "../../types/transactions.types.js";
|
|
6
|
+
import "../../types/curve.types.js";
|
|
7
|
+
import "circomlibjs";
|
|
8
|
+
import "../../data-structures/crypto-keys/keys.js";
|
|
9
|
+
import { serializeDecodedTxs as g, deserializeDecodedTxs as C } from "./getDataFromTransaction.js";
|
|
10
|
+
import "../web3/events/getShieldedBalance.js";
|
|
11
|
+
import "./external-action.utils.js";
|
|
12
|
+
import "../../data-structures/custom-token-registry/CustomTokenRegistry.js";
|
|
13
|
+
import "./convertIntegrationProviderToExternalActionId.js";
|
|
14
|
+
import "../../constants/coingecko.constants.js";
|
|
15
|
+
import { logError as p } from "../../error-handling/logError.js";
|
|
16
|
+
import "./userAgent.js";
|
|
17
|
+
import "../../data-structures/crypto-keys/encryptDecryptUtxo.js";
|
|
18
|
+
import "../../webworker/workerFactory.js";
|
|
19
|
+
import "../../constants/reorg-depths.constants.js";
|
|
20
|
+
import "../../constants/kyc.constants.js";
|
|
21
|
+
import "../../data-structures/volatile-helper/VolatileHelper.js";
|
|
22
|
+
import "libsodium-wrappers";
|
|
23
|
+
import "../../constants/vite.constants.js";
|
|
24
|
+
import "../../constants/contracts.constants.js";
|
|
25
|
+
import "../../constants/axelar.constants.js";
|
|
26
|
+
import "../../constants/rewards.constants.js";
|
|
27
|
+
const l = {
|
|
28
|
+
encryptedOutputs: [],
|
|
29
|
+
lastOutput: ""
|
|
30
|
+
}, c = (o, t) => {
|
|
31
|
+
const r = o.substring(0, 25), s = t.substring(0, 25);
|
|
32
|
+
return { shortPublicKey: r, shortHinkalAddress: s };
|
|
33
|
+
}, L = (o, t, r) => {
|
|
34
|
+
if (!o || !t || !r)
|
|
35
|
+
throw Error("GetHinkalCache: incorrect arguments");
|
|
36
|
+
const { shortPublicKey: s, shortHinkalAddress: e } = c(t, r);
|
|
37
|
+
return JSON.parse(
|
|
38
|
+
localStorage.getItem(`hinkalCache-${o}-${s}-${e}`) ?? JSON.stringify(l)
|
|
39
|
+
);
|
|
40
|
+
}, u = (o, t, r, s) => {
|
|
41
|
+
if (!t || !r || !s)
|
|
42
|
+
throw Error("SetHinkalCache: incorrect arguments");
|
|
43
|
+
const { shortPublicKey: e, shortHinkalAddress: a } = c(r, s);
|
|
44
|
+
localStorage.setItem(`hinkalCache-${t}-${e}-${a}`, JSON.stringify(o));
|
|
45
|
+
}, M = (o, t, r) => {
|
|
46
|
+
u(l, o, t, r);
|
|
47
|
+
}, Q = (o, t, r, s, e) => {
|
|
48
|
+
if (!t || !r || !s)
|
|
49
|
+
throw Error("saveTxsCache: incorrect arguments");
|
|
50
|
+
const { shortPublicKey: a, shortHinkalAddress: n } = c(r, s), i = g(o);
|
|
51
|
+
p("saveTxsCache before saving", { serializedTxs: i }), localStorage.setItem(
|
|
52
|
+
`txsCache-${t}-${a}-${n}`,
|
|
53
|
+
JSON.stringify({ serializedTxs: i, lastHash: e })
|
|
54
|
+
);
|
|
55
|
+
}, x = { serializedTxs: [], lastHash: "" }, R = (o, t, r) => {
|
|
56
|
+
if (!o || !t || !r)
|
|
57
|
+
throw Error("loadTxsCache: incorrect arguments");
|
|
58
|
+
const { shortPublicKey: s, shortHinkalAddress: e } = c(t, r), a = localStorage.getItem(`txsCache-${o}-${s}-${e}`), { serializedTxs: n, lastHash: i } = JSON.parse(a ?? JSON.stringify(x)), m = n.map((h) => C(h));
|
|
59
|
+
return p("loadTxsCache ", { decodedTxs: m, lastHash: i }), { decodedTxs: m, lastHash: i === "" ? void 0 : i };
|
|
60
|
+
};
|
|
61
|
+
export {
|
|
62
|
+
L as getHinkalCache,
|
|
63
|
+
R as loadTxsCache,
|
|
64
|
+
M as resetCache,
|
|
65
|
+
Q as saveTxsCache,
|
|
66
|
+
u as setHinkalCache
|
|
67
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const o = (e, s) => !e || !s ? !1 : e.toLowerCase() === s.toLowerCase(), r = (e, s) => e.some((t) => o(t, s)), a = (e, s) => e.some((t) => t.toLowerCase().startsWith(s.toLowerCase()));
|
|
2
|
+
export {
|
|
3
|
+
o as caseInsensitiveEqual,
|
|
4
|
+
r as lowerCaseIncludes,
|
|
5
|
+
a as lowerCaseStartsWith
|
|
6
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "../../types/circom-data.types.js";
|
|
2
|
+
import { ExternalActionId as r } from "../../types/external-action.types.js";
|
|
3
|
+
import { IntegrationProvider as o } from "../../types/hinkal.types.js";
|
|
4
|
+
import "../../types/transactions.types.js";
|
|
5
|
+
import "../../types/curve.types.js";
|
|
6
|
+
const t = {
|
|
7
|
+
[o.UNISWAP]: r.Uniswap,
|
|
8
|
+
[o.ODOS]: r.Odos,
|
|
9
|
+
[o.ONEINCH]: r.OneInch,
|
|
10
|
+
[o.PENDLE]: r.Pendle,
|
|
11
|
+
[o.ALL]: void 0,
|
|
12
|
+
[o.NONE]: void 0
|
|
13
|
+
}, p = (n) => t[n];
|
|
14
|
+
export {
|
|
15
|
+
p as convertIntegrationProviderToExternalActionId
|
|
16
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function e(r, n) {
|
|
2
|
+
return Object.values(r).includes(n);
|
|
3
|
+
}
|
|
4
|
+
function o(r, n, i = !1) {
|
|
5
|
+
if (e(r, n))
|
|
6
|
+
return n;
|
|
7
|
+
const t = `Value ${JSON.stringify(n)} is not a valid member of enum ${JSON.stringify(r)}.`;
|
|
8
|
+
if (i)
|
|
9
|
+
throw new Error(t);
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
e as isInEnum,
|
|
13
|
+
o as toEnumValue
|
|
14
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getERC20Registry as n } from "../../constants/token-data/ERC20Registry.js";
|
|
2
|
+
import { customTokenRegistry as i } from "../../data-structures/custom-token-registry/CustomTokenRegistry.js";
|
|
3
|
+
const T = (e, o) => {
|
|
4
|
+
const r = n(o), t = i.getCustomTokens(o);
|
|
5
|
+
return [...r, ...t].find((s) => e === void 0 ? !1 : s.erc20TokenAddress.toLowerCase() === e.toLowerCase());
|
|
6
|
+
}, g = (e, o) => {
|
|
7
|
+
const r = n(o), t = i.getCustomTokens(o);
|
|
8
|
+
return [...r, ...t].find((s) => e === void 0 ? !1 : s.symbol.toLowerCase() === e.toLowerCase());
|
|
9
|
+
}, c = (e, o) => {
|
|
10
|
+
const r = n(o);
|
|
11
|
+
if (e.hasHToken)
|
|
12
|
+
return r.find(
|
|
13
|
+
(t) => t.underlyingErc20TokenAddress?.toLowerCase() === e.erc20TokenAddress.toLowerCase() && t.isHToken
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
T as getERC20Token,
|
|
18
|
+
g as getERC20TokenBySymbol,
|
|
19
|
+
c as getHToken
|
|
20
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { networkRegistry as i, chainIdsByType as o } from "../../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 "../../data-structures/crypto-keys/keys.js";
|
|
8
|
+
import "axios";
|
|
9
|
+
import "../../data-structures/crypto-keys/encryptDecryptUtxo.js";
|
|
10
|
+
import "../web3/events/getShieldedBalance.js";
|
|
11
|
+
import "../../webworker/workerFactory.js";
|
|
12
|
+
import "./external-action.utils.js";
|
|
13
|
+
import "../../data-structures/custom-token-registry/CustomTokenRegistry.js";
|
|
14
|
+
import "./convertIntegrationProviderToExternalActionId.js";
|
|
15
|
+
import "../../constants/coingecko.constants.js";
|
|
16
|
+
import "../../constants/vite.constants.js";
|
|
17
|
+
import "./userAgent.js";
|
|
18
|
+
import "../../constants/reorg-depths.constants.js";
|
|
19
|
+
import "../../constants/kyc.constants.js";
|
|
20
|
+
import "../../data-structures/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
|
+
const B = (t) => i[t], R = (t) => Object.keys(o)[Object.values(o).findIndex((r) => r.includes(t.chainId))];
|
|
26
|
+
export {
|
|
27
|
+
B as getNetworkObject,
|
|
28
|
+
R as getNetworkType
|
|
29
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ethers as u } from "ethers";
|
|
2
|
+
import { CIRCOM_P as r } from "../../constants/protocol.constants.js";
|
|
3
|
+
import "../../types/circom-data.types.js";
|
|
4
|
+
import { ExternalActionId as t } from "../../types/external-action.types.js";
|
|
5
|
+
import "../../types/transactions.types.js";
|
|
6
|
+
import "../../types/curve.types.js";
|
|
7
|
+
import { toNumberOrUndefined as a } from "./amounts.utils.js";
|
|
8
|
+
const s = (n) => n === 0n ? 0n : BigInt(u.utils.id(n)) % r, g = (n) => BigInt(n) === 0n ? t.Transact : Object.values(t).find(
|
|
9
|
+
(e) => BigInt(n) === s(e)
|
|
10
|
+
), i = {
|
|
11
|
+
[t.Curve]: ["uint8", "address", "uint256", "uint256"],
|
|
12
|
+
[t.CurveDynamic]: ["uint8", "address", "uint256", "uint256"],
|
|
13
|
+
[t.CurveCRV]: ["uint8", "address", "uint256", "uint256"],
|
|
14
|
+
[t.CurveCRVRewards]: ["uint8", "address", "uint256", "uint256"],
|
|
15
|
+
[t.Convex]: ["uint8", "uint256", "uint256", "uint256"],
|
|
16
|
+
[t.Beefy]: ["uint8", "bytes", "bytes", "address"],
|
|
17
|
+
[t.BeefyStake]: ["uint8", "address", "uint256", "uint256"],
|
|
18
|
+
[t.Volatile]: ["uint256[]", "address", "uint256", "bytes", "uint8"],
|
|
19
|
+
[t.LidoETH]: ["uint8"],
|
|
20
|
+
[t.LidoMATIC]: ["uint8"],
|
|
21
|
+
[t.LidoETHNFT]: ["uint8"],
|
|
22
|
+
[t.LidoMATICNFT]: ["uint8"],
|
|
23
|
+
[t.Pendle]: ["uint8", "address", "uint256", "uint256", "address", "bool", "bytes"],
|
|
24
|
+
[t.PendleLP]: ["uint8", "address", "uint256", "uint256", "bytes"],
|
|
25
|
+
[t.Connext]: [
|
|
26
|
+
"bool",
|
|
27
|
+
"bool",
|
|
28
|
+
"uint32",
|
|
29
|
+
"uint256",
|
|
30
|
+
"uint256",
|
|
31
|
+
"uint256",
|
|
32
|
+
"uint256[2]",
|
|
33
|
+
"uint256[2][2]",
|
|
34
|
+
"uint256[2]"
|
|
35
|
+
]
|
|
36
|
+
}, c = {
|
|
37
|
+
[t.Pendle]: !0
|
|
38
|
+
}, d = {
|
|
39
|
+
[t.Volatile]: 4
|
|
40
|
+
}, y = (n, e) => {
|
|
41
|
+
if (c[n])
|
|
42
|
+
return a(e?.hookData?.preHookMetadata);
|
|
43
|
+
if (!i[n] || !e?.externalActionMetadata)
|
|
44
|
+
return;
|
|
45
|
+
let o = 0;
|
|
46
|
+
return d[n] && (o = d[n]), u.utils.defaultAbiCoder.decode(
|
|
47
|
+
i[n],
|
|
48
|
+
e.externalActionMetadata
|
|
49
|
+
)[o];
|
|
50
|
+
}, v = (n, e) => {
|
|
51
|
+
if (!e || !i[n])
|
|
52
|
+
throw Error("No externalActionMetadata");
|
|
53
|
+
return u.utils.defaultAbiCoder.decode(i[n], e);
|
|
54
|
+
}, E = (n) => BigInt(u.utils.keccak256(n)) % r;
|
|
55
|
+
export {
|
|
56
|
+
v as decodeMetadata,
|
|
57
|
+
y as getActionFromMetadata,
|
|
58
|
+
g as getExternalActionIdFromNumber,
|
|
59
|
+
s as getExternalActionIdHash,
|
|
60
|
+
E as getExternalMetadataHash
|
|
61
|
+
};
|