@hinkal/common 0.1.32 → 0.1.34
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/constants/deploy-data/deploy-data-localhost.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-localhost.json.mjs +4 -4
- package/constants/fees.constants.cjs +1 -1
- package/constants/fees.constants.mjs +22 -22
- package/constants/token-data/localhostRegistry.json.cjs +1 -1
- package/constants/token-data/localhostRegistry.json.mjs +18 -44
- package/crypto/babyJub.cjs +1 -1
- package/crypto/babyJub.mjs +4 -4
- package/crypto/poseidon.cjs +1 -1
- package/crypto/poseidon.mjs +12 -12
- package/crypto/preProcessing.cjs +1 -1
- package/crypto/preProcessing.mjs +5 -7
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +1 -0
- package/data-structures/Hinkal/Hinkal.mjs +16 -16
- package/data-structures/Hinkal/IHinkal.d.ts +2 -1
- package/data-structures/Hinkal/hinkalActionBeefy.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionBeefy.mjs +18 -20
- package/data-structures/Hinkal/hinkalActionConvex.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionConvex.mjs +18 -21
- package/data-structures/Hinkal/hinkalActionLidoEth.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionLidoEth.mjs +31 -31
- package/data-structures/Hinkal/hinkalActionPendle.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionPendle.mjs +77 -80
- package/data-structures/Hinkal/hinkalActionPendleLP.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionPendleLP.mjs +34 -34
- package/data-structures/Hinkal/hinkalActionStake.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionStake.mjs +49 -53
- package/data-structures/Hinkal/hinkalActionVolatile.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionVolatile.mjs +38 -44
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +27 -28
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +8 -11
- package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
- package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +9 -8
- package/data-structures/crypto-keys/keys.cjs +1 -1
- package/data-structures/crypto-keys/keys.mjs +7 -6
- package/data-structures/event-service/AbstractAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/event-service/AbstractAccessTokenSnapshotService.mjs +6 -9
- package/data-structures/event-service/AbstractCommitmentsSnapshotService.cjs +1 -4
- package/data-structures/event-service/AbstractCommitmentsSnapshotService.mjs +18 -26
- package/data-structures/snapshot/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientAccessTokenSnapshotService.mjs +9 -12
- package/data-structures/snapshot/ClientCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientCommitmentsSnapshotService.mjs +9 -12
- package/data-structures/snapshot/ClientNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientNullifierSnapshotService.mjs +3 -6
- package/data-structures/transactions-manager/TransactionsManager.cjs +1 -1
- package/data-structures/transactions-manager/TransactionsManager.mjs +67 -75
- package/data-structures/transactions-manager/history/getVolatileData.cjs +1 -1
- package/data-structures/transactions-manager/history/getVolatileData.mjs +13 -13
- package/data-structures/volatile-helper/VolatileHelper.cjs +1 -1
- package/data-structures/volatile-helper/VolatileHelper.mjs +60 -60
- package/error-handling/error-codes.constants.cjs +1 -1
- package/error-handling/error-codes.constants.d.ts +2 -0
- package/error-handling/error-codes.constants.mjs +2 -0
- package/functions/pre-transaction/getFlatFees.cjs +1 -1
- package/functions/pre-transaction/getFlatFees.mjs +42 -42
- package/functions/pre-transaction/outputUtxoProcessing.cjs +1 -1
- package/functions/pre-transaction/outputUtxoProcessing.mjs +5 -8
- package/functions/pre-transaction/process-gas-estimates.cjs +1 -1
- package/functions/pre-transaction/process-gas-estimates.mjs +17 -26
- package/functions/pre-transaction/processAmountChanges.cjs +1 -1
- package/functions/pre-transaction/processAmountChanges.mjs +10 -13
- package/functions/protocols/pendle.helpers.cjs +1 -1
- package/functions/protocols/pendle.helpers.mjs +37 -39
- package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
- package/functions/snarkjs/constructGeneralZkProof.mjs +35 -37
- package/functions/staking/index.cjs +1 -1
- package/functions/staking/index.mjs +22 -24
- package/functions/utils/cacheFunctions.cjs +1 -1
- package/functions/utils/cacheFunctions.mjs +27 -30
- package/functions/utils/index.d.ts +1 -0
- package/functions/utils/process.utils.cjs +1 -1
- package/functions/utils/process.utils.mjs +16 -2
- package/functions/utils/resolve-sync.utils.cjs +1 -1
- package/functions/utils/resolve-sync.utils.d.ts +0 -1
- package/functions/utils/resolve-sync.utils.mjs +3 -12
- package/functions/web3/events/getShieldedBalance.cjs +2 -2
- package/functions/web3/events/getShieldedBalance.mjs +25 -25
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +15 -15
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.mjs +2 -2
- package/functions/web3/odosAPI.cjs +1 -1
- package/functions/web3/odosAPI.mjs +11 -14
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.mjs +7 -10
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.mjs +35 -38
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.mjs +30 -33
- package/index.cjs +1 -1
- package/index.mjs +281 -277
- package/package.json +3 -5
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +5 -4
- package/providers/prepareWagmiv1Hinkal.cjs +1 -1
- package/providers/prepareWagmiv1Hinkal.mjs +5 -4
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLogic.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLogic.mjs +16 -17
- package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
|
@@ -2,43 +2,34 @@ import "../../constants/chains.constants.mjs";
|
|
|
2
2
|
import "../../constants/vite.constants.mjs";
|
|
3
3
|
import "axios";
|
|
4
4
|
import "../../constants/coingecko.constants.mjs";
|
|
5
|
-
import { getGasEstimates as
|
|
5
|
+
import { getGasEstimates as c } from "../../API/getGasEstimates.mjs";
|
|
6
6
|
import "ethers";
|
|
7
7
|
import "../../types/curve.types.mjs";
|
|
8
|
-
import { logError as
|
|
9
|
-
import { getValueFirstNDigit as
|
|
8
|
+
import { logError as f } from "../../error-handling/logError.mjs";
|
|
9
|
+
import { getValueFirstNDigit as T } from "../utils/amounts.utils.mjs";
|
|
10
10
|
import "../../constants/contracts.constants.mjs";
|
|
11
11
|
import "../../constants/kyc.constants.mjs";
|
|
12
12
|
import "../../constants/axelar.constants.mjs";
|
|
13
13
|
import "../../constants/rewards.constants.mjs";
|
|
14
14
|
import "../../constants/reorg-depths.constants.mjs";
|
|
15
|
-
import { getAmountInWei as
|
|
16
|
-
const
|
|
17
|
-
let
|
|
15
|
+
import { getAmountInWei as g } from "../web3/etherFunctions.mjs";
|
|
16
|
+
const F = async (i, r, e, m, s, p) => {
|
|
17
|
+
let o, t;
|
|
18
18
|
try {
|
|
19
|
-
({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} = await T(
|
|
19
|
+
({ priceOfTransactionInUSD: o, priceOfTransactionInToken: t } = await c(
|
|
20
|
+
i,
|
|
21
|
+
r.erc20TokenAddress,
|
|
22
|
+
e,
|
|
24
23
|
m,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
p,
|
|
28
|
-
n,
|
|
29
|
-
c
|
|
24
|
+
s,
|
|
25
|
+
p
|
|
30
26
|
));
|
|
31
|
-
} catch (
|
|
32
|
-
|
|
27
|
+
} catch (n) {
|
|
28
|
+
f("processGasEstimates error:", n);
|
|
33
29
|
}
|
|
34
|
-
const
|
|
35
|
-
return
|
|
36
|
-
status: i,
|
|
37
|
-
priceOfTransactionInUSD: o,
|
|
38
|
-
priceOfTransactionInTokenEstimate: r,
|
|
39
|
-
priceOfTransactionInToken: s
|
|
40
|
-
}), { priceOfTransactionInUSD: o, priceOfTransactionInToken: s };
|
|
30
|
+
const a = t ? g(r, T(t, r.decimals)) : void 0;
|
|
31
|
+
return { priceOfTransactionInUSD: o, priceOfTransactionInToken: a };
|
|
41
32
|
};
|
|
42
33
|
export {
|
|
43
|
-
|
|
34
|
+
F as processGasEstimates
|
|
44
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../constants/fees.constants.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../constants/fees.constants.cjs"),i=require("../../error-handling/customErrors/FeeOverTransactionValueError.cjs"),y=require("../utils/amounts.utils.cjs");require("ethers");require("axios");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");const O=require("../../types/beefy.types.cjs");require("../../types/circom-data.types.cjs");const e=require("../../types/hinkal.types.cjs"),c=require("../../types/slippage.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");require("../../constants/reorg-depths.constants.cjs");const _=require("./interaction-to-action.cjs"),N=(t,A,r)=>{const l=y.absBigInt(t)-A;if(A<0n)throw new i.FeeOverTransactionValueError({totalFeeWEI:l,feeUnit:r});return A},F=({erc20Addresses:t=[],amountChanges:A,flatFees:r,feeUnit:I,externalActionId:l,action:p,gasTokenAddress:b})=>{const d=_.getInteractionFromAction(l,p);if(d===e.INTERACTION.NONE)throw Error("No interaction was choosen");switch(d){case e.INTERACTION.WITHDRAW:{N(A[0],T.getAmountAfterRelayAndFlatFees(A[0],r[0],!0),I);break}case e.INTERACTION.SWAP:{A[1]=N(A[1],T.getAmountAfterRelayAndFlatFeesAndSlippage(A[1],r[1],c.SlippageType.Swap),I);break}case e.INTERACTION.CURVE_DEPOSIT:{const E=A.length-1;A[E]=N(A[E],T.getAmountAfterRelayAndFlatFeesAndSlippage(A[E],r[E],c.SlippageType.CurveDeposit),I);break}case e.INTERACTION.CURVE_WITHDRAW:r.forEach((E,R)=>{E>0n?A[R]=N(A[R],T.getAmountAfterRelayAndFlatFeesAndSlippage(A[R],E,c.SlippageType.CurveWithdraw),I):E===0n&&A[R]>0n&&R!==r.length-1&&(A[R]=T.getAmountAfterSlippage(A[R],c.SlippageType.CurveWithdraw))});break;case e.INTERACTION.CURVE_WITHDRAW_INBALANCED:break;case e.INTERACTION.STAKING:A[0]=N(A[0],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.UNSTAKING:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[0],r[0]),I);break;case e.INTERACTION.CLAIMING:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.BEEFY:{const E=O.isBeefyDeposit(p)?1:0;A[E]=N(A[E],T.getAmountAfterRelayAndFlatFeesAndSlippage(A[E],r[E],c.SlippageType.Beefy),I);break}case e.INTERACTION.BEEFY_STAKE:A[0]=N(A[0],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.BEEFY_UNSTAKE:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[0],r[0]),I);break;case e.INTERACTION.BEEFY_GET_REWARDS:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.LIDO_STAKE:A[0]=N(A[0],T.getAmountAfterRelayAndFlatFees(A[0],r[0]),I);break;case e.INTERACTION.LIDO_REQUEST:N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.LIDO_CLAIM:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.PENDLE_TRANSACT:A[0]<0n&&N(A[0],T.getAmountAfterRelayAndFlatFees(A[0],r[0],!0),I);break;case e.INTERACTION.PENDLE_YT_IN_SWAP:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.PENDLE_YT_OUT_SWAP:break;case e.INTERACTION.PENDLE_PT_SWAP:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.PENDLE_MINT:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.PENDLE_REDEEM:A[2]=N(A[2],T.getAmountAfterRelayAndFlatFees(A[2],r[2]),I);break;case e.INTERACTION.PENDLE_CLAIM:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.PENDLE_LP:{const E=A.findIndex(R=>R>0n);A[E]=N(A[E],T.getAmountAfterRelayAndFlatFeesAndSlippage(A[E],r[E],c.SlippageType.Pendle));break}case e.INTERACTION.PENDLE_LP_CLAIM:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break}return A};exports.processAmountChanges=F;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getAmountAfterRelayAndFlatFees as I, getAmountAfterRelayAndFlatFeesAndSlippage as N, getAmountAfterSlippage as
|
|
1
|
+
import { getAmountAfterRelayAndFlatFees as I, getAmountAfterRelayAndFlatFeesAndSlippage as N, getAmountAfterSlippage as i } from "../../constants/fees.constants.mjs";
|
|
2
2
|
import { FeeOverTransactionValueError as S } from "../../error-handling/customErrors/FeeOverTransactionValueError.mjs";
|
|
3
3
|
import { absBigInt as W } from "../utils/amounts.utils.mjs";
|
|
4
4
|
import "ethers";
|
|
@@ -11,10 +11,7 @@ import { INTERACTION as c } from "../../types/hinkal.types.mjs";
|
|
|
11
11
|
import { SlippageType as b } from "../../types/slippage.types.mjs";
|
|
12
12
|
import "../../types/transactions.types.mjs";
|
|
13
13
|
import "../../types/curve.types.mjs";
|
|
14
|
-
import "circomlibjs
|
|
15
|
-
import "libsodium-wrappers";
|
|
16
|
-
import "process";
|
|
17
|
-
import "buffer";
|
|
14
|
+
import "circomlibjs";
|
|
18
15
|
import "../../constants/reorg-depths.constants.mjs";
|
|
19
16
|
import { getInteractionFromAction as d } from "./interaction-to-action.mjs";
|
|
20
17
|
const p = (D, r, E) => {
|
|
@@ -25,19 +22,19 @@ const p = (D, r, E) => {
|
|
|
25
22
|
feeUnit: E
|
|
26
23
|
});
|
|
27
24
|
return r;
|
|
28
|
-
},
|
|
25
|
+
}, Z = ({
|
|
29
26
|
erc20Addresses: D = [],
|
|
30
27
|
amountChanges: r,
|
|
31
28
|
flatFees: E,
|
|
32
29
|
feeUnit: A,
|
|
33
30
|
externalActionId: T,
|
|
34
|
-
action:
|
|
31
|
+
action: P,
|
|
35
32
|
gasTokenAddress: w
|
|
36
33
|
}) => {
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
34
|
+
const L = d(T, P);
|
|
35
|
+
if (L === c.NONE)
|
|
39
36
|
throw Error("No interaction was choosen");
|
|
40
|
-
switch (
|
|
37
|
+
switch (L) {
|
|
41
38
|
case c.WITHDRAW: {
|
|
42
39
|
p(
|
|
43
40
|
r[0],
|
|
@@ -69,7 +66,7 @@ const p = (D, r, E) => {
|
|
|
69
66
|
r[_],
|
|
70
67
|
N(r[_], k, b.CurveWithdraw),
|
|
71
68
|
A
|
|
72
|
-
) : k === 0n && r[_] > 0n && _ !== E.length - 1 && (r[_] =
|
|
69
|
+
) : k === 0n && r[_] > 0n && _ !== E.length - 1 && (r[_] = i(r[_], b.CurveWithdraw));
|
|
73
70
|
});
|
|
74
71
|
break;
|
|
75
72
|
case c.CURVE_WITHDRAW_INBALANCED:
|
|
@@ -96,7 +93,7 @@ const p = (D, r, E) => {
|
|
|
96
93
|
);
|
|
97
94
|
break;
|
|
98
95
|
case c.BEEFY: {
|
|
99
|
-
const k = R(
|
|
96
|
+
const k = R(P) ? 1 : 0;
|
|
100
97
|
r[k] = p(
|
|
101
98
|
r[k],
|
|
102
99
|
N(
|
|
@@ -213,5 +210,5 @@ const p = (D, r, E) => {
|
|
|
213
210
|
return r;
|
|
214
211
|
};
|
|
215
212
|
export {
|
|
216
|
-
|
|
213
|
+
Z as processAmountChanges
|
|
217
214
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const o=require("../../constants/server.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const i=require("../utils/caseInsensitive.utils.cjs");require("../../types/circom-data.types.cjs");const s=require("../../types/hinkal.types.cjs");require("../../types/transactions.types.cjs");const n=require("../../types/pendle.types.cjs");require("../../types/curve.types.cjs");require("ethers");require("circomlibjs
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const o=require("../../constants/server.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const i=require("../utils/caseInsensitive.utils.cjs");require("../../types/circom-data.types.cjs");const s=require("../../types/hinkal.types.cjs");require("../../types/transactions.types.cjs");const n=require("../../types/pendle.types.cjs");require("../../types/curve.types.cjs");require("ethers");require("circomlibjs");require("../../data-structures/crypto-keys/keys.cjs");require("idb-keyval");require("../utils/external-action.utils.cjs");const c=require("../utils/erc20tokenFunctions.cjs");require("../utils/convertIntegrationProviderToExternalActionId.cjs");require("axios");require("../utils/userAgent.cjs");require("../../data-structures/custom-token-registry/CustomTokenRegistry.cjs");require("../../data-structures/volatile-helper/VolatileHelper.cjs");const T=require("../utils/enum.utils.cjs");function P(e){if(!e)return;const r=c.getERC20Token(e.address,e.chainId);if(!r?.isVolatile)return r}function w(e,r){if(!e||!r)return;let t;switch(r){case n.PendleAssetType.YT:t=e?.yt;break;case n.PendleAssetType.PT:t=e?.pt;break;case n.PendleAssetType.PENDLE_LP:t=e?.lp;break;case n.PendleAssetType.SY:t=e?.sy;break;default:t=void 0;break}return t}const F=(e,r,t)=>{if(i.caseInsensitiveEqual(e.yt.address,t.erc20TokenAddress))return n.PendleSwapType.SwapExactTokenForYt;if(i.caseInsensitiveEqual(e.pt.address,t.erc20TokenAddress))return n.PendleSwapType.SwapExactTokenForPt;if(i.caseInsensitiveEqual(e.yt.address,r.erc20TokenAddress))return n.PendleSwapType.SwapExactYtForToken;if(i.caseInsensitiveEqual(e.pt.address,r.erc20TokenAddress))return n.PendleSwapType.SwapExactPtForToken},q=e=>{let r;switch(e){case n.PendleSwapType.SwapExactTokenForYt:r=o.API_CONFIG.ROUTES.pendleSwapExactTokenForYT;break;case n.PendleSwapType.SwapExactTokenForPt:r=o.API_CONFIG.ROUTES.pendleSwapExactTokenForPt;break;case n.PendleSwapType.SwapExactYtForToken:r=o.API_CONFIG.ROUTES.pendleSwapExactYtForToken;break;case n.PendleSwapType.SwapExactPtForToken:r=o.API_CONFIG.ROUTES.pendleSwapExactPtForToken;break;default:throw new Error("Cant determine Pendle Swap Type Api Route")}return r},k=(e,r,t,a)=>{if(!T.isInEnum(s.PendleAction,e))throw new Error("getTokenIndexForPendleFlatFee: Invalid Pendle Action");if(a)return t.findIndex(d=>d.toLowerCase()===a?.toLowerCase());const l=r.findIndex(d=>d>0n),p=r.length-1;if(r[p]<=0n)throw new Error("getTokenIndexForPendleFlatFee: Last token in amountChange is not > 0");let u=l;return(e===s.PendleAction.Mint||e===s.PendleAction.Redeem||e===s.PendleAction.PoolRemove)&&(u=l),u};exports.determinePendleSwapType=F;exports.determinePendleSwapTypeApiRoute=q;exports.erc20TokenFromPendleAsset=P;exports.getAssetTypeFromPendleMarket=w;exports.getTokenIndexForPendleFlatFee=k;
|
|
@@ -11,97 +11,95 @@ import { caseInsensitiveEqual as i } from "../utils/caseInsensitive.utils.mjs";
|
|
|
11
11
|
import "../../types/circom-data.types.mjs";
|
|
12
12
|
import { PendleAction as p } from "../../types/hinkal.types.mjs";
|
|
13
13
|
import "../../types/transactions.types.mjs";
|
|
14
|
-
import { PendleAssetType as d, PendleSwapType as
|
|
14
|
+
import { PendleAssetType as d, PendleSwapType as o } from "../../types/pendle.types.mjs";
|
|
15
15
|
import "../../types/curve.types.mjs";
|
|
16
16
|
import "ethers";
|
|
17
|
-
import "circomlibjs
|
|
18
|
-
import "
|
|
17
|
+
import "circomlibjs";
|
|
18
|
+
import "../../data-structures/crypto-keys/keys.mjs";
|
|
19
19
|
import "idb-keyval";
|
|
20
20
|
import "../utils/external-action.utils.mjs";
|
|
21
21
|
import { getERC20Token as T } from "../utils/erc20tokenFunctions.mjs";
|
|
22
22
|
import "../utils/convertIntegrationProviderToExternalActionId.mjs";
|
|
23
23
|
import "axios";
|
|
24
|
-
import "process";
|
|
25
|
-
import "buffer";
|
|
26
24
|
import "../utils/userAgent.mjs";
|
|
27
25
|
import "../../data-structures/custom-token-registry/CustomTokenRegistry.mjs";
|
|
28
26
|
import "../../data-structures/volatile-helper/VolatileHelper.mjs";
|
|
29
|
-
import { isInEnum as
|
|
30
|
-
function
|
|
27
|
+
import { isInEnum as k } from "../utils/enum.utils.mjs";
|
|
28
|
+
function V(e) {
|
|
31
29
|
if (!e)
|
|
32
30
|
return;
|
|
33
31
|
const r = T(e.address, e.chainId);
|
|
34
32
|
if (!r?.isVolatile)
|
|
35
|
-
return r
|
|
33
|
+
return r;
|
|
36
34
|
}
|
|
37
|
-
function
|
|
35
|
+
function j(e, r) {
|
|
38
36
|
if (!e || !r)
|
|
39
37
|
return;
|
|
40
|
-
let
|
|
38
|
+
let t;
|
|
41
39
|
switch (r) {
|
|
42
40
|
case d.YT:
|
|
43
|
-
|
|
41
|
+
t = e?.yt;
|
|
44
42
|
break;
|
|
45
43
|
case d.PT:
|
|
46
|
-
|
|
44
|
+
t = e?.pt;
|
|
47
45
|
break;
|
|
48
46
|
case d.PENDLE_LP:
|
|
49
|
-
|
|
47
|
+
t = e?.lp;
|
|
50
48
|
break;
|
|
51
49
|
case d.SY:
|
|
52
|
-
|
|
50
|
+
t = e?.sy;
|
|
53
51
|
break;
|
|
54
52
|
default:
|
|
55
|
-
|
|
53
|
+
t = void 0;
|
|
56
54
|
break;
|
|
57
55
|
}
|
|
58
|
-
return
|
|
56
|
+
return t;
|
|
59
57
|
}
|
|
60
|
-
const
|
|
61
|
-
if (i(e.yt.address,
|
|
62
|
-
return
|
|
63
|
-
if (i(e.pt.address,
|
|
64
|
-
return
|
|
58
|
+
const z = (e, r, t) => {
|
|
59
|
+
if (i(e.yt.address, t.erc20TokenAddress))
|
|
60
|
+
return o.SwapExactTokenForYt;
|
|
61
|
+
if (i(e.pt.address, t.erc20TokenAddress))
|
|
62
|
+
return o.SwapExactTokenForPt;
|
|
65
63
|
if (i(e.yt.address, r.erc20TokenAddress))
|
|
66
|
-
return
|
|
64
|
+
return o.SwapExactYtForToken;
|
|
67
65
|
if (i(e.pt.address, r.erc20TokenAddress))
|
|
68
|
-
return
|
|
69
|
-
},
|
|
66
|
+
return o.SwapExactPtForToken;
|
|
67
|
+
}, H = (e) => {
|
|
70
68
|
let r;
|
|
71
69
|
switch (e) {
|
|
72
|
-
case
|
|
70
|
+
case o.SwapExactTokenForYt:
|
|
73
71
|
r = n.ROUTES.pendleSwapExactTokenForYT;
|
|
74
72
|
break;
|
|
75
|
-
case
|
|
73
|
+
case o.SwapExactTokenForPt:
|
|
76
74
|
r = n.ROUTES.pendleSwapExactTokenForPt;
|
|
77
75
|
break;
|
|
78
|
-
case
|
|
76
|
+
case o.SwapExactYtForToken:
|
|
79
77
|
r = n.ROUTES.pendleSwapExactYtForToken;
|
|
80
78
|
break;
|
|
81
|
-
case
|
|
79
|
+
case o.SwapExactPtForToken:
|
|
82
80
|
r = n.ROUTES.pendleSwapExactPtForToken;
|
|
83
81
|
break;
|
|
84
82
|
default:
|
|
85
83
|
throw new Error("Cant determine Pendle Swap Type Api Route");
|
|
86
84
|
}
|
|
87
85
|
return r;
|
|
88
|
-
},
|
|
89
|
-
if (!
|
|
86
|
+
}, J = (e, r, t, s) => {
|
|
87
|
+
if (!k(p, e))
|
|
90
88
|
throw new Error("getTokenIndexForPendleFlatFee: Invalid Pendle Action");
|
|
91
89
|
if (s)
|
|
92
|
-
return
|
|
90
|
+
return t.findIndex(
|
|
93
91
|
(a) => a.toLowerCase() === s?.toLowerCase()
|
|
94
92
|
);
|
|
95
|
-
const
|
|
93
|
+
const c = r.findIndex((a) => a > 0n), m = r.length - 1;
|
|
96
94
|
if (r[m] <= 0n)
|
|
97
95
|
throw new Error("getTokenIndexForPendleFlatFee: Last token in amountChange is not > 0");
|
|
98
|
-
let
|
|
99
|
-
return (e === p.Mint || e === p.Redeem || e === p.PoolRemove) && (
|
|
96
|
+
let l = c;
|
|
97
|
+
return (e === p.Mint || e === p.Redeem || e === p.PoolRemove) && (l = c), l;
|
|
100
98
|
};
|
|
101
99
|
export {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
100
|
+
z as determinePendleSwapType,
|
|
101
|
+
H as determinePendleSwapTypeApiRoute,
|
|
102
|
+
V as erc20TokenFromPendleAsset,
|
|
103
|
+
j as getAssetTypeFromPendleMarket,
|
|
104
|
+
J as getTokenIndexForPendleFlatFee
|
|
107
105
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("../../constants/chains.constants.cjs"),j=require("../../constants/protocol.constants.cjs"),G=require("../../data-structures/utxo/Utxo.cjs"),m=require("../../types/hinkal.stake.types.cjs"),k=require("../../webworker/performTaskWithWorker.cjs"),S=require("../../webworker/worker.registry.cjs"),p=require("../../webworker/zkProofWorker/zkProofWorker.types.cjs"),J=require("../web3/etherFunctions.cjs"),i=require("./common.snarkjs.cjs"),F=require("./generateCircomData.cjs"),Q=require("./generateZkProof.cjs"),X=async(u,f,a,r,h,g,y,T,C,P=j.zeroAddress,z=V.chainIds.localhost,s=a.map(()=>!1),_=a.map(()=>0n),I=void 0,n)=>{const W=u.getRootHash(),H=f.getRootHash(),b=a.map(e=>e.map(t=>t.getConstructableParams())),D=h.getSignature(),{accessTokenSiblings:Z,accessTokenSiblingSides:K}=await k.performTaskWithWorker({type:S.WorkerVariant.ZKProof,payload:{type:p.ZKProofWorkerActionType.CALC_ACCESS_TOKEN_SIBLING_AND_SIDES,data:{userSignature:D,merkleTreeAccessTokenSerialized:f.toJSON()}}}),{inCommitmentSiblings:O,inCommitmentSiblingSides:R}=await k.performTaskWithWorker({type:S.WorkerVariant.ZKProof,payload:{type:p.ZKProofWorkerActionType.CALC_COMMITMENTS_SIBLING_AND_SIDES,data:{inputUtxosSerialized:b,userSignature:D,merkleTreeSerialized:u.toJSON()}}}),B=i.calcAmountChanges(a,r),d=i.calcEncryptedOutputs(r,(n&&n.mode!==m.HinkalStakeMode.Deposit)??!1),l=h.getShieldedPrivateKey(),N=G.Utxo.findCorrectRandomization(J.randomBigInt(31),l),E=await k.performTaskWithWorker({type:S.WorkerVariant.ZKProof,payload:{type:p.ZKProofWorkerActionType.BUILD_IN_NULLIFIERS,data:{inputUtxosSerialized:b,onChainCreation:s}}}),o={rootHashHinkal:W,shieldedPrivateKey:l,erc20TokenAddresses:a.map(e=>e[0].erc20TokenAddress),inAmounts:a.map(e=>e.map(t=>t.amount.toString())),inTimeStamps:a.map(e=>e.map(t=>t.timeStamp)),inRandomizations:a.map(e=>e.map(t=>t.randomization)),inNullifiers:E,inCommitmentSiblings:O,inCommitmentSiblingSides:R,outAmounts:r.map(e=>e.map(t=>t.amount.toString())),outTimeStamp:BigInt(r[0][0].timeStamp),outPublicKeys:r.map(e=>e.map(t=>t.getStealthAddress())),extraRandomization:N,amountChanges:B,outCommitments:i.buildOutCommitments(r,s),rootHashAccessToken:H,accessTokenSiblings:Z,accessTokenSiblingSides:K,calldataHash:0n};n||(o.onChainCreation=s);const c=a.map(e=>e[0].tokenId??0),q=c.reduce((e,t)=>e+t,0)>0?c.length:0;q>0&&(o.tokenIds=c);const A=i.calcPublicSignalCount(g,o.erc20TokenAddresses,o.amountChanges,o.inNullifiers,o.outCommitments,q);o.calldataHash=i.createCallDataHash(A,P,T,y,C,d,_,I),n&&(n.mode===m.HinkalStakeMode.Deposit&&(o.mode=0),n.mode===m.HinkalStakeMode.Stake&&(o.mode=1),n.mode===m.HinkalStakeMode.Unstake&&(o.mode=2),o.stakedTokenRecipient=n.stakedTokenRecipient,o.stakeBlinding=n.stakeBlinding,o.depositorAddress=n.depositorAddress);const{zkCallData:L}=await Q.generateZkProof(z,g,o),M=i.calcStealthAddressStructure(N,l),w=await F.generateCircomData(W,H,a,r,d,_,A,y,T,C,P,o.calldataHash,c,M,s,I),v={tokenNumber:a.length,nullifierAmount:a[0].length,outputAmount:r[0].length};return{zkCallData:L,circomData:w,dimData:v,encryptedOutputs:d}};exports.constructZkProof=X;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { chainIds as
|
|
2
|
-
import { zeroAddress as
|
|
3
|
-
import { Utxo as
|
|
4
|
-
import { HinkalStakeMode as
|
|
1
|
+
import { chainIds as G } from "../../constants/chains.constants.mjs";
|
|
2
|
+
import { zeroAddress as J } from "../../constants/protocol.constants.mjs";
|
|
3
|
+
import { Utxo as V } from "../../data-structures/utxo/Utxo.mjs";
|
|
4
|
+
import { HinkalStakeMode as d } from "../../types/hinkal.stake.types.mjs";
|
|
5
5
|
import { performTaskWithWorker as l } from "../../webworker/performTaskWithWorker.mjs";
|
|
6
6
|
import { WorkerVariant as p } from "../../webworker/worker.registry.mjs";
|
|
7
7
|
import { ZKProofWorkerActionType as S } from "../../webworker/zkProofWorker/zkProofWorker.types.mjs";
|
|
8
|
-
import { randomBigInt as
|
|
9
|
-
import { calcAmountChanges as
|
|
10
|
-
import { generateCircomData as
|
|
11
|
-
import { generateZkProof as
|
|
12
|
-
const
|
|
13
|
-
const
|
|
8
|
+
import { randomBigInt as j } from "../web3/etherFunctions.mjs";
|
|
9
|
+
import { calcAmountChanges as q, calcEncryptedOutputs as F, buildOutCommitments as Q, calcPublicSignalCount as X, createCallDataHash as Y, calcStealthAddressStructure as $ } from "./common.snarkjs.mjs";
|
|
10
|
+
import { generateCircomData as U } from "./generateCircomData.mjs";
|
|
11
|
+
import { generateZkProof as x } from "./generateZkProof.mjs";
|
|
12
|
+
const po = async (f, g, a, n, h, k, u, C, I, T = J, R = G.localhost, m = a.map(() => !1), y = a.map(() => 0n), N = void 0, i) => {
|
|
13
|
+
const P = f.getRootHash(), D = g.getRootHash(), _ = a.map((o) => o.map((t) => t.getConstructableParams())), b = h.getSignature(), { accessTokenSiblings: B, accessTokenSiblingSides: E } = await l({
|
|
14
14
|
type: p.ZKProof,
|
|
15
15
|
payload: {
|
|
16
16
|
type: S.CALC_ACCESS_TOKEN_SIBLING_AND_SIDES,
|
|
17
17
|
data: {
|
|
18
|
-
userSignature:
|
|
18
|
+
userSignature: b,
|
|
19
19
|
merkleTreeAccessTokenSerialized: g.toJSON()
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -23,19 +23,19 @@ const So = async (f, g, a, n, h, u, k, C, I, T = V, R = J.localhost, m = a.map((
|
|
|
23
23
|
type: p.ZKProof,
|
|
24
24
|
payload: {
|
|
25
25
|
type: S.CALC_COMMITMENTS_SIBLING_AND_SIDES,
|
|
26
|
-
data: { inputUtxosSerialized:
|
|
26
|
+
data: { inputUtxosSerialized: _, userSignature: b, merkleTreeSerialized: f.toJSON() }
|
|
27
27
|
}
|
|
28
|
-
}), O =
|
|
28
|
+
}), O = q(a, n), c = F(
|
|
29
29
|
n,
|
|
30
|
-
(i && i.mode !==
|
|
31
|
-
), s = h.getShieldedPrivateKey(), H =
|
|
30
|
+
(i && i.mode !== d.Deposit) ?? !1
|
|
31
|
+
), s = h.getShieldedPrivateKey(), H = V.findCorrectRandomization(j(31), s), Z = await l({
|
|
32
32
|
type: p.ZKProof,
|
|
33
33
|
payload: {
|
|
34
34
|
type: S.BUILD_IN_NULLIFIERS,
|
|
35
|
-
data: { inputUtxosSerialized:
|
|
35
|
+
data: { inputUtxosSerialized: _, onChainCreation: m }
|
|
36
36
|
}
|
|
37
37
|
}), e = {
|
|
38
|
-
rootHashHinkal:
|
|
38
|
+
rootHashHinkal: P,
|
|
39
39
|
shieldedPrivateKey: s,
|
|
40
40
|
erc20TokenAddresses: a.map((o) => o[0].erc20TokenAddress),
|
|
41
41
|
inAmounts: a.map((o) => o.map((t) => t.amount.toString())),
|
|
@@ -49,8 +49,8 @@ const So = async (f, g, a, n, h, u, k, C, I, T = V, R = J.localhost, m = a.map((
|
|
|
49
49
|
outPublicKeys: n.map((o) => o.map((t) => t.getStealthAddress())),
|
|
50
50
|
extraRandomization: H,
|
|
51
51
|
amountChanges: O,
|
|
52
|
-
outCommitments:
|
|
53
|
-
rootHashAccessToken:
|
|
52
|
+
outCommitments: Q(n, m),
|
|
53
|
+
rootHashAccessToken: D,
|
|
54
54
|
accessTokenSiblings: B,
|
|
55
55
|
accessTokenSiblingSides: E,
|
|
56
56
|
calldataHash: 0n
|
|
@@ -58,50 +58,48 @@ const So = async (f, g, a, n, h, u, k, C, I, T = V, R = J.localhost, m = a.map((
|
|
|
58
58
|
i || (e.onChainCreation = m);
|
|
59
59
|
const r = a.map((o) => o[0].tokenId ?? 0), z = r.reduce((o, t) => o + t, 0) > 0 ? r.length : 0;
|
|
60
60
|
z > 0 && (e.tokenIds = r);
|
|
61
|
-
const A =
|
|
62
|
-
|
|
61
|
+
const A = X(
|
|
62
|
+
k,
|
|
63
63
|
e.erc20TokenAddresses,
|
|
64
64
|
e.amountChanges,
|
|
65
65
|
e.inNullifiers,
|
|
66
66
|
e.outCommitments,
|
|
67
67
|
z
|
|
68
68
|
);
|
|
69
|
-
e.calldataHash =
|
|
69
|
+
e.calldataHash = Y(
|
|
70
70
|
A,
|
|
71
71
|
T,
|
|
72
72
|
C,
|
|
73
|
-
|
|
73
|
+
u,
|
|
74
74
|
I,
|
|
75
|
-
|
|
75
|
+
c,
|
|
76
76
|
y,
|
|
77
|
-
|
|
78
|
-
), i && (i.mode ===
|
|
79
|
-
const { zkCallData: w
|
|
80
|
-
console.log("publicSignals", W);
|
|
81
|
-
const v = U(H, s), M = await x(
|
|
82
|
-
N,
|
|
77
|
+
N
|
|
78
|
+
), i && (i.mode === d.Deposit && (e.mode = 0), i.mode === d.Stake && (e.mode = 1), i.mode === d.Unstake && (e.mode = 2), e.stakedTokenRecipient = i.stakedTokenRecipient, e.stakeBlinding = i.stakeBlinding, e.depositorAddress = i.depositorAddress);
|
|
79
|
+
const { zkCallData: w } = await x(R, k, e), W = $(H, s), v = await U(
|
|
83
80
|
P,
|
|
81
|
+
D,
|
|
84
82
|
a,
|
|
85
83
|
n,
|
|
86
|
-
|
|
84
|
+
c,
|
|
87
85
|
y,
|
|
88
86
|
A,
|
|
89
|
-
|
|
87
|
+
u,
|
|
90
88
|
C,
|
|
91
89
|
I,
|
|
92
90
|
T,
|
|
93
91
|
e.calldataHash,
|
|
94
92
|
r,
|
|
95
|
-
|
|
93
|
+
W,
|
|
96
94
|
m,
|
|
97
|
-
|
|
98
|
-
),
|
|
95
|
+
N
|
|
96
|
+
), M = {
|
|
99
97
|
tokenNumber: a.length,
|
|
100
98
|
nullifierAmount: a[0].length,
|
|
101
99
|
outputAmount: n[0].length
|
|
102
100
|
};
|
|
103
|
-
return { zkCallData: w, circomData:
|
|
101
|
+
return { zkCallData: w, circomData: v, dimData: M, encryptedOutputs: c };
|
|
104
102
|
};
|
|
105
103
|
export {
|
|
106
|
-
|
|
104
|
+
po as constructZkProof
|
|
107
105
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("ethers"),y=require("../../data-structures/crypto-keys/keys.cjs"),s=require("libsodium-wrappers"),c=require("../../crypto/poseidon.cjs");require("circomlibjs");const f=(e,t,r)=>{const n=o.ethers.utils.defaultAbiCoder.encode(["uint256","address"],[e,t]),a=s.crypto_box_seal(n,o.ethers.utils.arrayify(r));return`0x${Buffer.from(a).toString("hex")}`},p=(e,t)=>{const r=Buffer.from(e.slice(2),"hex"),{publicKey:n,privateKey:a}=y.UserKeys.getEncryptionKeyPair(t.getShieldedPrivateKey());try{const i=s.crypto_box_seal_open(r,o.ethers.utils.arrayify(n),o.ethers.utils.arrayify(a)),d=Buffer.from(i).toString("utf-8"),[u,l]=o.ethers.utils.defaultAbiCoder.decode(["uint256","address"],d);return{stakeBlinding:u.toBigInt(),stakedTokenRecipient:l}}catch{console.log("failed to decrypt");return}},S=(e,t,r,n,a,i)=>BigInt(c.poseidonHash(...[e,t,r,n,a,i].map(BigInt))),k=(e,t)=>c.poseidonHash(e,t),g=(e,t,r,n,a)=>o.ethers.utils.defaultAbiCoder.encode(["uint8","uint256","address","bytes","bytes"],[e,t,r,n,a]);exports.calculateStakeNullifier=k;exports.createStakeCommitment=S;exports.decryptStake=p;exports.encodeHStakeMetadata=g;exports.encryptStake=f;
|
|
@@ -1,42 +1,40 @@
|
|
|
1
|
-
import { ethers as
|
|
2
|
-
import { UserKeys as
|
|
1
|
+
import { ethers as i } from "ethers";
|
|
2
|
+
import { UserKeys as f } from "../../data-structures/crypto-keys/keys.mjs";
|
|
3
3
|
import s from "libsodium-wrappers";
|
|
4
4
|
import { poseidonHash as c } from "../../crypto/poseidon.mjs";
|
|
5
|
-
import "circomlibjs
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const B = (t, e, r) => {
|
|
9
|
-
const o = n.utils.defaultAbiCoder.encode(
|
|
5
|
+
import "circomlibjs";
|
|
6
|
+
const S = (t, e, r) => {
|
|
7
|
+
const o = i.utils.defaultAbiCoder.encode(
|
|
10
8
|
["uint256", "address"],
|
|
11
9
|
[t, e]
|
|
12
|
-
),
|
|
13
|
-
return `0x${Buffer.from(
|
|
14
|
-
},
|
|
15
|
-
const r = Buffer.from(t.slice(2), "hex"), { publicKey: o, privateKey:
|
|
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());
|
|
16
14
|
try {
|
|
17
15
|
const a = s.crypto_box_seal_open(
|
|
18
16
|
r,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
), d = Buffer.from(a).toString("utf-8"), [u,
|
|
17
|
+
i.utils.arrayify(o),
|
|
18
|
+
i.utils.arrayify(n)
|
|
19
|
+
), d = Buffer.from(a).toString("utf-8"), [u, y] = i.utils.defaultAbiCoder.decode(
|
|
22
20
|
["uint256", "address"],
|
|
23
21
|
d
|
|
24
22
|
);
|
|
25
|
-
return { stakeBlinding: u.toBigInt(), stakedTokenRecipient:
|
|
23
|
+
return { stakeBlinding: u.toBigInt(), stakedTokenRecipient: y };
|
|
26
24
|
} catch {
|
|
27
25
|
console.log("failed to decrypt");
|
|
28
26
|
return;
|
|
29
27
|
}
|
|
30
|
-
},
|
|
31
|
-
c(...[t, e, r, o,
|
|
32
|
-
),
|
|
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(
|
|
33
31
|
["uint8", "uint256", "address", "bytes", "bytes"],
|
|
34
|
-
[t, e, r, o,
|
|
32
|
+
[t, e, r, o, n]
|
|
35
33
|
);
|
|
36
34
|
export {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
h as calculateStakeNullifier,
|
|
36
|
+
B as createStakeCommitment,
|
|
37
|
+
k as decryptStake,
|
|
38
|
+
x as encodeHStakeMetadata,
|
|
39
|
+
S as encryptStake
|
|
42
40
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("./getDataFromTransaction.cjs"),C=require("idb-keyval"),u={encryptedOutputs:[],lastOutput:""},l=(e,t)=>{const s=e.substring(0,25),r=t.substring(0,25);return{shortPublicKey:s,shortHinkalAddress:r}},d=new Map,x=(e,t,s)=>{if(!e||!t||!s)throw Error("GetHinkalCache: incorrect arguments");const{shortPublicKey:r,shortHinkalAddress:a}=l(t,s);return JSON.parse(typeof localStorage<"u"?localStorage.getItem(`hinkalCache-${e}-${r}-${a}`)??JSON.stringify(u):d.get(`hinkalCache-${e}-${r}-${a}`)??JSON.stringify(u))},S=(e,t,s,r)=>{if(!t||!s||!r)throw Error("SetHinkalCache: incorrect arguments");const{shortPublicKey:a,shortHinkalAddress:o}=l(s,r);typeof localStorage<"u"?localStorage.setItem(`hinkalCache-${t}-${a}-${o}`,JSON.stringify(e)):d.set(`hinkalCache-${t}-${a}-${o}`,JSON.stringify(e))},H=(e,t,s)=>{S(u,e,t,s)},f=(e,t,s)=>`txsCache-${e}-${t}-${s}`,T=async(e,t,s,r,a)=>{if(!t||!s||!r)throw Error("saveTxsCache: incorrect arguments");const{shortPublicKey:o,shortHinkalAddress:n}=l(s,r),h=y.serializeDecodedTxs(e),c=f(t,o,n),g=JSON.stringify({serializedTxs:h,lastHash:a});try{await C.set(c,g)}catch{localStorage.setItem(c,g)}},m={serializedTxs:[],lastHash:""},$=async(e,t,s)=>{if(!e||!t||!s)throw Error("loadTxsCache: incorrect arguments");const{shortPublicKey:r,shortHinkalAddress:a}=l(t,s),o=f(e,r,a);let n;try{const i=await C.get(o);if(!i)throw new Error("Empty indexedDB cache");n=i}catch{n=localStorage.getItem(o)}const{serializedTxs:h,lastHash:c}=JSON.parse(n??JSON.stringify(m));return{decodedTxs:h.map(i=>y.deserializeDecodedTxs(i)),lastHash:c===""?void 0:c}};exports.getHinkalCache=x;exports.loadTxsCache=$;exports.resetCache=H;exports.saveTxsCache=T;exports.setHinkalCache=S;
|