@hinkal/common 0.0.113 → 0.0.115
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/assets/{snarkjsWorkerLauncher-fuD5h_j0.js → snarkjsWorkerLauncher-CaBCnle3.js} +283 -257
- package/assets/snarkjsWorkerLogic-BAbiO5gj.js +17935 -0
- package/assets/snarkjsWorkerLogic-wHJfYCfg.js +15636 -0
- package/assets/{utxoWorkerLogic-CtFLQiAX.js → utxoWorkerLogic-BGFm-Zl2.js} +2 -2
- package/assets/{zkProofWorkerLauncher-J3Ts5_Ba.js → zkProofWorkerLauncher-BteYxRBn.js} +1 -1
- package/assets/{zkProofWorkerLogic-CPNuu61R.js → zkProofWorkerLogic-DiLbAhAo.js} +8354 -8298
- package/common.mjs +644 -0
- package/common10.mjs +30 -0
- package/common100.mjs +156 -0
- package/common101.mjs +568 -0
- package/common102.mjs +1603 -0
- package/common103.mjs +1764 -0
- package/common104.mjs +2030 -0
- package/common105.mjs +701 -0
- package/common106.mjs +480 -0
- package/common107.mjs +2082 -0
- package/common108.mjs +39 -0
- package/common109.mjs +24 -0
- package/common11.mjs +30 -0
- package/common110.mjs +41 -0
- package/common111.mjs +206 -0
- package/common112.mjs +48 -0
- package/common113.mjs +39 -0
- package/common114.mjs +70 -0
- package/common115.mjs +67 -0
- package/common116.mjs +5 -0
- package/common117.mjs +61 -0
- package/common118.mjs +20 -0
- package/common119.mjs +7 -0
- package/common12.mjs +58 -0
- package/common120.mjs +22 -0
- package/common121.mjs +16 -0
- package/common122.mjs +57 -0
- package/common123.mjs +45 -0
- package/common124.mjs +57 -0
- package/common125.mjs +229 -0
- package/common126.mjs +203 -0
- package/common127.mjs +29 -0
- package/common128.mjs +38 -0
- package/common129.mjs +15 -0
- package/common13.mjs +156 -0
- package/common130.mjs +105 -0
- package/common131.mjs +4 -0
- package/common132.mjs +14 -0
- package/common133.mjs +7 -0
- package/common134.mjs +6 -0
- package/common135.mjs +8 -0
- package/common136.mjs +40 -0
- package/common137.mjs +41 -0
- package/common138.mjs +72 -0
- package/common139.mjs +107 -0
- package/common14.mjs +32 -0
- package/common140.mjs +9 -0
- package/common141.mjs +10 -0
- package/common142.mjs +97 -0
- package/common143.mjs +65 -0
- package/common144.mjs +61 -0
- package/common145.mjs +95 -0
- package/common146.mjs +129 -0
- package/common147.mjs +105 -0
- package/common148.mjs +96 -0
- package/common149.mjs +18 -0
- package/common15.mjs +16 -0
- package/common150.mjs +45 -0
- package/common151.mjs +41 -0
- package/common152.mjs +108 -0
- package/common153.mjs +40 -0
- package/common154.mjs +19 -0
- package/common155.mjs +24 -0
- package/common156.mjs +21 -0
- package/common157.mjs +22 -0
- package/common158.mjs +4 -0
- package/common159.mjs +4 -0
- package/common16.mjs +6 -0
- package/common160.mjs +15 -0
- package/common161.mjs +13 -0
- package/common162.mjs +4 -0
- package/common163.mjs +15 -0
- package/common164.mjs +36 -0
- package/common165.mjs +58 -0
- package/common166.mjs +27 -0
- package/common167.mjs +15 -0
- package/common168.mjs +25 -0
- package/common169.mjs +4 -0
- package/common17.mjs +6877 -0
- package/common170.mjs +85 -0
- package/common171.mjs +2251 -0
- package/common172.mjs +856 -0
- package/common173.mjs +973 -0
- package/common174.mjs +1255 -0
- package/common175.mjs +591 -0
- package/common176.mjs +1392 -0
- package/common177.mjs +463 -0
- package/common178.mjs +137 -0
- package/common179.mjs +2700 -0
- package/common18.mjs +7415 -0
- package/common180.mjs +946 -0
- package/common181.mjs +973 -0
- package/common182.mjs +1327 -0
- package/common183.mjs +591 -0
- package/common184.mjs +1455 -0
- package/common185.mjs +490 -0
- package/common186.mjs +137 -0
- package/common187.mjs +2768 -0
- package/common188.mjs +8 -0
- package/common189.mjs +14 -0
- package/common19.mjs +11427 -0
- package/common190.mjs +115623 -0
- package/common191.mjs +42 -0
- package/common192.mjs +1022 -0
- package/common193.mjs +1423 -0
- package/common194.mjs +208 -0
- package/common195.mjs +340 -0
- package/common196.mjs +674 -0
- package/common197.mjs +1002 -0
- package/common198.mjs +883 -0
- package/common199.mjs +262 -0
- package/common2.mjs +67 -0
- package/common20.mjs +7417 -0
- package/common200.mjs +264 -0
- package/common201.mjs +173 -0
- package/common202.mjs +999 -0
- package/common203.mjs +80 -0
- package/common204.mjs +56 -0
- package/common205.mjs +42 -0
- package/common206.mjs +14 -0
- package/common207.mjs +4 -0
- package/common208.mjs +62 -0
- package/common209.mjs +4 -0
- package/common21.mjs +7439 -0
- package/common210.mjs +4 -0
- package/common211.mjs +58 -0
- package/common212.mjs +40 -0
- package/common213.mjs +45 -0
- package/common214.mjs +36 -0
- package/common215.mjs +32 -0
- package/common216.mjs +44 -0
- package/common217.mjs +32 -0
- package/common218.mjs +38 -0
- package/common219.mjs +9 -0
- package/common22.mjs +7411 -0
- package/common220.mjs +32 -0
- package/common221.mjs +47 -0
- package/common222.mjs +14 -0
- package/common223.mjs +30 -0
- package/common224.mjs +91 -0
- package/common225.mjs +112 -0
- package/common226.mjs +96 -0
- package/common227.mjs +30 -0
- package/common228.mjs +138 -0
- package/common229.mjs +18 -0
- package/common23.mjs +8425 -0
- package/common230.mjs +42 -0
- package/common231.mjs +60 -0
- package/common232.mjs +48 -0
- package/common233.mjs +47 -0
- package/common234.mjs +44 -0
- package/common235.mjs +74 -0
- package/common236.mjs +4 -0
- package/common237.mjs +60 -0
- package/common238.mjs +4 -0
- package/common239.mjs +30 -0
- package/common24.mjs +9600 -0
- package/common240.mjs +4 -0
- package/common241.mjs +153 -0
- package/common242.mjs +31 -0
- package/common243.mjs +30 -0
- package/common244.mjs +68 -0
- package/common245.mjs +57 -0
- package/common246.mjs +97 -0
- package/common247.mjs +36 -0
- package/common248.mjs +43 -0
- package/common249.mjs +44 -0
- package/common25.mjs +13283 -0
- package/common250.mjs +59 -0
- package/common251.mjs +75 -0
- package/{snarkjsWorkerLogic-CVna_BW9.mjs → common252.mjs} +1 -1
- package/common253.mjs +66 -0
- package/common254.mjs +70 -0
- package/common255.mjs +211 -0
- package/common256.mjs +8 -0
- package/{workerProxy-BDj498Ht.mjs → common257.mjs} +1 -1
- package/common26.mjs +4329 -0
- package/common27.mjs +4329 -0
- package/common28.mjs +204 -0
- package/common29.mjs +57 -0
- package/common3.mjs +27 -0
- package/common30.mjs +276 -0
- package/common31.mjs +118 -0
- package/common32.mjs +157 -0
- package/common33.mjs +29 -0
- package/common34.mjs +26 -0
- package/common35.mjs +53 -0
- package/common36.mjs +55 -0
- package/common37.mjs +18 -0
- package/common38.mjs +636 -0
- package/common39.mjs +24 -0
- package/common4.mjs +37 -0
- package/common40.mjs +13 -0
- package/common41.mjs +27 -0
- package/common42.mjs +15 -0
- package/common43.mjs +24 -0
- package/common44.mjs +253 -0
- package/common45.mjs +26 -0
- package/common46.mjs +15 -0
- package/common47.mjs +9 -0
- package/common48.mjs +25 -0
- package/common49.mjs +40 -0
- package/common5.mjs +37 -0
- package/common50.mjs +41 -0
- package/common51.mjs +90 -0
- package/common52.mjs +10 -0
- package/common53.mjs +299 -0
- package/common54.mjs +101 -0
- package/common55.mjs +83 -0
- package/common56.mjs +112 -0
- package/common57.mjs +140 -0
- package/common58.mjs +95 -0
- package/common59.mjs +98 -0
- package/common6.mjs +32 -0
- package/common60.mjs +5 -0
- package/common61.mjs +91 -0
- package/common62.mjs +66 -0
- package/common63.mjs +49 -0
- package/common64.mjs +177 -0
- package/common65.mjs +8 -0
- package/common66.mjs +131 -0
- package/common67.mjs +132 -0
- package/common68.mjs +59 -0
- package/common69.mjs +35 -0
- package/common7.mjs +37 -0
- package/common70.mjs +118 -0
- package/common71.mjs +134 -0
- package/common72.mjs +33 -0
- package/common73.mjs +29 -0
- package/common74.mjs +218 -0
- package/common75.mjs +194 -0
- package/common76.mjs +62 -0
- package/common77.mjs +181 -0
- package/common78.mjs +83 -0
- package/common79.mjs +9 -0
- package/common8.mjs +38 -0
- package/common80.mjs +21 -0
- package/common81.mjs +184 -0
- package/common82.mjs +53 -0
- package/common83.mjs +35 -0
- package/common84.mjs +7 -0
- package/common85.mjs +4 -0
- package/common86.mjs +350 -0
- package/common87.mjs +570 -0
- package/common88.mjs +519 -0
- package/common89.mjs +1422 -0
- package/common9.mjs +41 -0
- package/common90.mjs +1136 -0
- package/common91.mjs +334 -0
- package/common92.mjs +291 -0
- package/common93.mjs +205 -0
- package/common94.mjs +201 -0
- package/common95.mjs +89 -0
- package/common96.mjs +721 -0
- package/common97.mjs +346 -0
- package/common98.mjs +542 -0
- package/common99.mjs +393 -0
- package/package.json +4 -4
- package/assets/snarkjsWorkerLogic-B6N4z_eM.js +0 -12136
- package/assets/snarkjsWorkerLogic-Fv0M38Mc.js +0 -12087
- package/index-DXElTGy9.mjs +0 -254449
- package/index.js +0 -457
- package/utxoWorkerLogic-B1Hh-bq4.mjs +0 -64
- package/zkProofWorkerLogic-D9rxuuiK.mjs +0 -60
package/common14.mjs
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { chainIds as i } from "./common28.mjs";
|
|
2
|
+
import "./common157.mjs";
|
|
3
|
+
import "./common164.mjs";
|
|
4
|
+
import "./common168.mjs";
|
|
5
|
+
import "ethers";
|
|
6
|
+
import "circomlibjs";
|
|
7
|
+
import "./common51.mjs";
|
|
8
|
+
import "axios";
|
|
9
|
+
import "./common50.mjs";
|
|
10
|
+
import "./common139.mjs";
|
|
11
|
+
import "./common191.mjs";
|
|
12
|
+
import "./common117.mjs";
|
|
13
|
+
import "./common72.mjs";
|
|
14
|
+
import "./common121.mjs";
|
|
15
|
+
import "./common35.mjs";
|
|
16
|
+
import { RELAYER_URLS as m, STAGING_RELAYER_URLS as p, PLAYGROUND_RELAYER_URLS as n } from "./common32.mjs";
|
|
17
|
+
import { deploymentMode as o, DEPLOYMENT_MODE as e } from "./common33.mjs";
|
|
18
|
+
import "./common129.mjs";
|
|
19
|
+
import "./common42.mjs";
|
|
20
|
+
import "./common31.mjs";
|
|
21
|
+
import "./common77.mjs";
|
|
22
|
+
import "libsodium-wrappers";
|
|
23
|
+
import "./common30.mjs";
|
|
24
|
+
import "./common36.mjs";
|
|
25
|
+
import "./common41.mjs";
|
|
26
|
+
const V = (r) => {
|
|
27
|
+
let t;
|
|
28
|
+
return o === e.DEVELOPMENT ? t = m : o === e.STAGING ? t = p : o === e.PLAYGROUND ? t = n : t = m, r === i.polygon ? t.polygon : r === i.arbMainnet ? t.arbMainnet : r === i.ethMainnet ? t.ethMainnet : r === i.bnbMainnet ? t.bnbMainnet : r === i.avalanche ? t.avalanche : r === i.optimism ? t.optimism : r === i.base ? t.base : r === i.blast ? t.blast : t.localhost;
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
V as getRelayerURL
|
|
32
|
+
};
|
package/common140.mjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const i = async (e, s, ...n) => {
|
|
2
|
+
if (!e.filters?.[s])
|
|
3
|
+
throw new Error("Contract Event not found");
|
|
4
|
+
return await e.queryFilter(e.filters?.[s](...n), 39561411);
|
|
5
|
+
}, o = async (e, s) => (await i(e, "NewTransaction")).map((t) => t.args[1] === s && BigInt(t.args[2]) >= 0n ? new Date(t.args[0] * 1e3) : /* @__PURE__ */ new Date(0)).filter((t) => t.getTime() !== 0);
|
|
6
|
+
export {
|
|
7
|
+
o as getDepositEvents,
|
|
8
|
+
i as retrieveEvents
|
|
9
|
+
};
|
package/common141.mjs
ADDED
package/common142.mjs
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { utils as w } from "ethers";
|
|
2
|
+
import { networkRegistry as p, getNonLocalhostChainId as A, chainIds as C } from "./common28.mjs";
|
|
3
|
+
import "./common157.mjs";
|
|
4
|
+
import { ContractType as d } from "./common158.mjs";
|
|
5
|
+
import "./common164.mjs";
|
|
6
|
+
import "./common168.mjs";
|
|
7
|
+
import { getAmountInWei as g } from "./common137.mjs";
|
|
8
|
+
import { zeroAddress as I } from "./common34.mjs";
|
|
9
|
+
import "circomlibjs";
|
|
10
|
+
import "./common51.mjs";
|
|
11
|
+
import { transactionErrorCodes as l } from "./common81.mjs";
|
|
12
|
+
import "axios";
|
|
13
|
+
import "./common50.mjs";
|
|
14
|
+
import "./common139.mjs";
|
|
15
|
+
import "./common191.mjs";
|
|
16
|
+
import "./common117.mjs";
|
|
17
|
+
import "./common72.mjs";
|
|
18
|
+
import "./common121.mjs";
|
|
19
|
+
import "./common35.mjs";
|
|
20
|
+
import { logError as h } from "./common84.mjs";
|
|
21
|
+
import "./common129.mjs";
|
|
22
|
+
import "./common42.mjs";
|
|
23
|
+
import "./common31.mjs";
|
|
24
|
+
import "./common77.mjs";
|
|
25
|
+
import "libsodium-wrappers";
|
|
26
|
+
import "./common33.mjs";
|
|
27
|
+
import "./common30.mjs";
|
|
28
|
+
import "./common36.mjs";
|
|
29
|
+
import "./common41.mjs";
|
|
30
|
+
const f = (r) => A(r) === C.blast, y = async (r, s, o, e) => {
|
|
31
|
+
const a = (await Promise.all(
|
|
32
|
+
[100, 500, 3e3, 1e4].map(async (t) => ({
|
|
33
|
+
poolAddress: await s.getPool(o, e, t),
|
|
34
|
+
fee: t
|
|
35
|
+
}))
|
|
36
|
+
)).filter(({ poolAddress: t }) => t !== I), n = await Promise.all(
|
|
37
|
+
a.map(async (t) => ({
|
|
38
|
+
poolAddress: t.poolAddress,
|
|
39
|
+
fee: t.fee,
|
|
40
|
+
token1Balance: (await r.balanceOf(t.poolAddress)).toBigInt()
|
|
41
|
+
}))
|
|
42
|
+
), c = n.map((t) => t.token1Balance).reduce((t, m) => m >= t ? m : t, 0n);
|
|
43
|
+
if (c === 0n)
|
|
44
|
+
throw new Error(l.UNISWAP_NOT_ENOUGH_LIQUIDITY);
|
|
45
|
+
return n.find((t) => t.token1Balance === c);
|
|
46
|
+
}, E = async (r, s, o, e, a) => {
|
|
47
|
+
try {
|
|
48
|
+
if (!p[r.getCurrentChainId()].quoterV2Address)
|
|
49
|
+
throw Error("No Quoter Contract Provided");
|
|
50
|
+
return (await r.getContractWithFetcher(
|
|
51
|
+
d.UniswapV3QuoterContract,
|
|
52
|
+
p[r.getCurrentChainId()].quoterV2Address
|
|
53
|
+
).callStatic.quoteExactInputSingle({
|
|
54
|
+
tokenIn: s.wrappedErc20TokenAddress ?? s.erc20TokenAddress,
|
|
55
|
+
tokenOut: o.wrappedErc20TokenAddress ?? o.erc20TokenAddress,
|
|
56
|
+
fee: e,
|
|
57
|
+
amountIn: a,
|
|
58
|
+
sqrtPriceLimitX96: 0
|
|
59
|
+
})).amountOut.toBigInt();
|
|
60
|
+
} catch (n) {
|
|
61
|
+
throw h(n), n;
|
|
62
|
+
}
|
|
63
|
+
}, P = async (r, s, o) => {
|
|
64
|
+
try {
|
|
65
|
+
const e = r.getCurrentChainId(), a = r.getContractWithFetcher(
|
|
66
|
+
d.UniswapV3FactoryContract,
|
|
67
|
+
p[e].uniswapV3FactoryAddress
|
|
68
|
+
), n = r.getContractWithFetcher(
|
|
69
|
+
d.ERC20Contract,
|
|
70
|
+
o.wrappedErc20TokenAddress ?? o.erc20TokenAddress
|
|
71
|
+
), { fee: i } = await y(
|
|
72
|
+
n,
|
|
73
|
+
a,
|
|
74
|
+
s.wrappedErc20TokenAddress ?? s.erc20TokenAddress,
|
|
75
|
+
o.wrappedErc20TokenAddress ?? o.erc20TokenAddress
|
|
76
|
+
);
|
|
77
|
+
return i;
|
|
78
|
+
} catch (e) {
|
|
79
|
+
throw console.log("Error in getUniswapFee", e), e;
|
|
80
|
+
}
|
|
81
|
+
}, $ = async (r, s, o, e) => {
|
|
82
|
+
try {
|
|
83
|
+
const a = r.getCurrentChainId();
|
|
84
|
+
if (!f(a) && (o.isVolatile || e.isVolatile))
|
|
85
|
+
throw new Error("Volatile tokens are not supported by uniswap");
|
|
86
|
+
const n = await P(r, o, e), i = w.defaultAbiCoder.encode(["uint24"], [n]), c = g(o, s);
|
|
87
|
+
return { tokenPrice: await E(r, o, e, n, c), poolFee: i };
|
|
88
|
+
} catch (a) {
|
|
89
|
+
throw console.log({ error: a }), Error(l.NO_UNISWAP_PRICE);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
export {
|
|
93
|
+
P as getUniswapFee,
|
|
94
|
+
$ as getUniswapPrice,
|
|
95
|
+
E as getUniswapPriceHelper,
|
|
96
|
+
y as searchPoolAndFee
|
|
97
|
+
};
|
package/common143.mjs
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { callOdosAPI as m } from "./common216.mjs";
|
|
2
|
+
import { localhostNetwork as n, networkRegistry as d } from "./common28.mjs";
|
|
3
|
+
import "./common157.mjs";
|
|
4
|
+
import "./common164.mjs";
|
|
5
|
+
import "./common168.mjs";
|
|
6
|
+
import { getAmountInWei as a } from "./common137.mjs";
|
|
7
|
+
import "ethers";
|
|
8
|
+
import { zeroAddress as c } from "./common34.mjs";
|
|
9
|
+
import "circomlibjs";
|
|
10
|
+
import "./common51.mjs";
|
|
11
|
+
import { transactionErrorCodes as u } from "./common81.mjs";
|
|
12
|
+
import "axios";
|
|
13
|
+
import "./common50.mjs";
|
|
14
|
+
import "./common139.mjs";
|
|
15
|
+
import "./common191.mjs";
|
|
16
|
+
import "./common117.mjs";
|
|
17
|
+
import "./common72.mjs";
|
|
18
|
+
import "./common121.mjs";
|
|
19
|
+
import "./common35.mjs";
|
|
20
|
+
import "./common33.mjs";
|
|
21
|
+
import "./common129.mjs";
|
|
22
|
+
import "./common42.mjs";
|
|
23
|
+
import "./common31.mjs";
|
|
24
|
+
import "./common77.mjs";
|
|
25
|
+
import "libsodium-wrappers";
|
|
26
|
+
import "./common30.mjs";
|
|
27
|
+
import "./common36.mjs";
|
|
28
|
+
import "./common41.mjs";
|
|
29
|
+
const q = async (r, t, e, i) => {
|
|
30
|
+
try {
|
|
31
|
+
const o = {
|
|
32
|
+
chainId: r.getCurrentChainId() !== 31337 ? r.getCurrentChainId() : n,
|
|
33
|
+
inputTokens: [
|
|
34
|
+
{
|
|
35
|
+
tokenAddress: t?.wrappedErc20TokenAddress ?? t.erc20TokenAddress,
|
|
36
|
+
amount: a(t, i).toString()
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
outputTokens: [
|
|
40
|
+
{
|
|
41
|
+
tokenAddress: e?.wrappedErc20TokenAddress ?? e.erc20TokenAddress,
|
|
42
|
+
proportion: 1
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
userAddr: d[r.getCurrentChainId()].contractData.odosExternalActionInstanceAddress || c,
|
|
46
|
+
slippageLimitPercent: 10,
|
|
47
|
+
disableRFQs: !0
|
|
48
|
+
// sometimes swap fails because of RFQs
|
|
49
|
+
}, { odosResponse: s, status: p } = await m(
|
|
50
|
+
r.getCurrentChainId(),
|
|
51
|
+
o
|
|
52
|
+
);
|
|
53
|
+
if (p !== "success")
|
|
54
|
+
throw Error("Odos API Fetch Error");
|
|
55
|
+
return {
|
|
56
|
+
outSwapAmountValue: BigInt(s.outputTokens[0].amount),
|
|
57
|
+
odosDataValue: s.transaction.data
|
|
58
|
+
};
|
|
59
|
+
} catch (o) {
|
|
60
|
+
throw console.log({ error: o }), Error(u.NO_ODOS_PRICE);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
export {
|
|
64
|
+
q as getOdosPrice
|
|
65
|
+
};
|
package/common144.mjs
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { callOneInchAPI as p } from "./common4.mjs";
|
|
2
|
+
import "./common28.mjs";
|
|
3
|
+
import "./common157.mjs";
|
|
4
|
+
import { ContractType as a } from "./common158.mjs";
|
|
5
|
+
import "./common164.mjs";
|
|
6
|
+
import "./common168.mjs";
|
|
7
|
+
import { getAmountInWei as c } from "./common137.mjs";
|
|
8
|
+
import "ethers";
|
|
9
|
+
import { zeroAddress as e, oneInchZeroAddress as s } from "./common34.mjs";
|
|
10
|
+
import "circomlibjs";
|
|
11
|
+
import "./common51.mjs";
|
|
12
|
+
import { transactionErrorCodes as d } from "./common81.mjs";
|
|
13
|
+
import "axios";
|
|
14
|
+
import "./common50.mjs";
|
|
15
|
+
import "./common139.mjs";
|
|
16
|
+
import "./common191.mjs";
|
|
17
|
+
import "./common117.mjs";
|
|
18
|
+
import "./common72.mjs";
|
|
19
|
+
import "./common121.mjs";
|
|
20
|
+
import "./common35.mjs";
|
|
21
|
+
import "./common33.mjs";
|
|
22
|
+
import "./common129.mjs";
|
|
23
|
+
import "./common42.mjs";
|
|
24
|
+
import "./common31.mjs";
|
|
25
|
+
import "./common77.mjs";
|
|
26
|
+
import "libsodium-wrappers";
|
|
27
|
+
import "./common30.mjs";
|
|
28
|
+
import "./common36.mjs";
|
|
29
|
+
import "./common41.mjs";
|
|
30
|
+
const W = async (i, t, m, n) => {
|
|
31
|
+
try {
|
|
32
|
+
const o = {
|
|
33
|
+
fromTokenAddress: t.erc20TokenAddress !== e ? t.erc20TokenAddress : s,
|
|
34
|
+
toTokenAddress: m.erc20TokenAddress !== e ? m.erc20TokenAddress : s,
|
|
35
|
+
fromAddress: e,
|
|
36
|
+
// we user zero address here because this paramater is not relevant to us, only destReceiver is
|
|
37
|
+
destReceiver: i.getContractMetadata(a.OneInchExternalActionContract).address,
|
|
38
|
+
amount: c(t, n),
|
|
39
|
+
slippage: 10,
|
|
40
|
+
disableEstimate: !0,
|
|
41
|
+
// disable gas estimation, we don't need it
|
|
42
|
+
// disable partial filling:
|
|
43
|
+
// if slippage tolerance isn't satisfied 1inch will try to swap less amount of input tokens
|
|
44
|
+
// and returning leftover tokens to fromAddress
|
|
45
|
+
// this is not what we want
|
|
46
|
+
allowPartialFill: !1
|
|
47
|
+
}, r = await p(i.getCurrentChainId(), o);
|
|
48
|
+
if (!r || !r.tx)
|
|
49
|
+
throw Error("OneInch API price fetch error");
|
|
50
|
+
return {
|
|
51
|
+
outSwapAmountValue: BigInt(r.toAmount),
|
|
52
|
+
oneInchDataValue: r.tx.data
|
|
53
|
+
// calldata to use
|
|
54
|
+
};
|
|
55
|
+
} catch (o) {
|
|
56
|
+
throw console.log({ error: o }), Error(d.NO_ONEINCH_PRICE);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
export {
|
|
60
|
+
W as getOneInchPrice
|
|
61
|
+
};
|
package/common145.mjs
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { UserFriendlyErrorCodes as g, transactionErrorCodes as u } from "./common81.mjs";
|
|
2
|
+
import "ethers";
|
|
3
|
+
import { getErrorMessage as l } from "./common82.mjs";
|
|
4
|
+
import "axios";
|
|
5
|
+
import "./common28.mjs";
|
|
6
|
+
import "./common157.mjs";
|
|
7
|
+
import "./common164.mjs";
|
|
8
|
+
import "./common168.mjs";
|
|
9
|
+
import "circomlibjs";
|
|
10
|
+
import "./common51.mjs";
|
|
11
|
+
import "./common50.mjs";
|
|
12
|
+
import "./common139.mjs";
|
|
13
|
+
import "./common191.mjs";
|
|
14
|
+
import "./common117.mjs";
|
|
15
|
+
import "./common72.mjs";
|
|
16
|
+
import "./common121.mjs";
|
|
17
|
+
import "./common35.mjs";
|
|
18
|
+
import "./common33.mjs";
|
|
19
|
+
import "./common129.mjs";
|
|
20
|
+
import "./common42.mjs";
|
|
21
|
+
import "./common31.mjs";
|
|
22
|
+
import "./common77.mjs";
|
|
23
|
+
import "libsodium-wrappers";
|
|
24
|
+
import "./common30.mjs";
|
|
25
|
+
import "./common36.mjs";
|
|
26
|
+
import "./common41.mjs";
|
|
27
|
+
const T = 5e4, w = 1, P = 11, d = 15, m = async (e, i) => {
|
|
28
|
+
try {
|
|
29
|
+
const t = await e.getFeeData(), a = i === 0 ? P : d, r = t.gasPrice?.mul(a).div(10) ?? void 0;
|
|
30
|
+
return console.log("getGasPrice , ", r?.toBigInt(), { gasPremiumType: i }), r;
|
|
31
|
+
} catch (t) {
|
|
32
|
+
console.log("getGasPrice error: ", { err: t });
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
}, E = (e, i, t) => new Promise((a, r) => {
|
|
36
|
+
const s = setTimeout(() => {
|
|
37
|
+
r(new Error(u.TRANSACTION_TIMEOUT));
|
|
38
|
+
}, t);
|
|
39
|
+
e.wait(i).then((o) => {
|
|
40
|
+
clearTimeout(s), a(o);
|
|
41
|
+
}).catch((o) => {
|
|
42
|
+
clearTimeout(s), r(o);
|
|
43
|
+
});
|
|
44
|
+
}), p = async ({
|
|
45
|
+
contractFunction: e,
|
|
46
|
+
args: i,
|
|
47
|
+
gasPrice: t,
|
|
48
|
+
gasLimit: a,
|
|
49
|
+
nonce: r,
|
|
50
|
+
confirmations: s,
|
|
51
|
+
waitTime: o
|
|
52
|
+
}) => {
|
|
53
|
+
const n = await e(...i, {
|
|
54
|
+
type: 0,
|
|
55
|
+
gasLimit: a,
|
|
56
|
+
gasPrice: t,
|
|
57
|
+
nonce: r
|
|
58
|
+
});
|
|
59
|
+
return console.log("runTransaction: ", n?.hash), await E(
|
|
60
|
+
n,
|
|
61
|
+
s ?? w,
|
|
62
|
+
o ?? T
|
|
63
|
+
);
|
|
64
|
+
}, K = async ({
|
|
65
|
+
provider: e,
|
|
66
|
+
contractFunction: i,
|
|
67
|
+
args: t,
|
|
68
|
+
gasLimit: a,
|
|
69
|
+
nonce: r,
|
|
70
|
+
confirmations: s
|
|
71
|
+
}) => {
|
|
72
|
+
try {
|
|
73
|
+
const o = await m(
|
|
74
|
+
e,
|
|
75
|
+
0
|
|
76
|
+
/* Initial */
|
|
77
|
+
);
|
|
78
|
+
return await p({ contractFunction: i, args: t, gasPrice: o, gasLimit: a, nonce: r, confirmations: s });
|
|
79
|
+
} catch (o) {
|
|
80
|
+
const n = l(o);
|
|
81
|
+
if (n === g.MAX_FEE_GAS_ERROR || n === u.TRANSACTION_TIMEOUT) {
|
|
82
|
+
console.log("Timeout Hit: Increase gas");
|
|
83
|
+
const c = await m(
|
|
84
|
+
e,
|
|
85
|
+
1
|
|
86
|
+
/* Secondary */
|
|
87
|
+
);
|
|
88
|
+
return await p({ contractFunction: i, args: t, gasPrice: c, gasLimit: a, nonce: r, confirmations: s });
|
|
89
|
+
}
|
|
90
|
+
throw o;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
export {
|
|
94
|
+
K as runContractFunction
|
|
95
|
+
};
|
package/common146.mjs
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { chainIds as J } from "./common28.mjs";
|
|
2
|
+
import "./common157.mjs";
|
|
3
|
+
import "./common164.mjs";
|
|
4
|
+
import "./common168.mjs";
|
|
5
|
+
import { HinkalStakeMode as c } from "./common169.mjs";
|
|
6
|
+
import { randomBigInt as V } from "./common137.mjs";
|
|
7
|
+
import { Utxo as j } from "./common71.mjs";
|
|
8
|
+
import "axios";
|
|
9
|
+
import "ethers";
|
|
10
|
+
import "./common51.mjs";
|
|
11
|
+
import "./common50.mjs";
|
|
12
|
+
import { zeroAddress as q } from "./common34.mjs";
|
|
13
|
+
import "./common139.mjs";
|
|
14
|
+
import { performTaskWithWorker as s } from "./common208.mjs";
|
|
15
|
+
import { WorkerVariant as l } from "./common209.mjs";
|
|
16
|
+
import { ZKProofWorkerActionType as S } from "./common236.mjs";
|
|
17
|
+
import { calcAmountChanges as F, calcEncryptedOutputs as Q, buildOutCommitments as X, calcPublicSignalCount as Y, createCallDataHash as $, calcStealthAddressStructure as U } from "./common148.mjs";
|
|
18
|
+
import { generateCircomData as x } from "./common237.mjs";
|
|
19
|
+
import { generateZkProof as oo } from "./common149.mjs";
|
|
20
|
+
import "circomlibjs";
|
|
21
|
+
import "./common117.mjs";
|
|
22
|
+
import "./common72.mjs";
|
|
23
|
+
import "./common121.mjs";
|
|
24
|
+
import "./common35.mjs";
|
|
25
|
+
import "./common33.mjs";
|
|
26
|
+
import "./common129.mjs";
|
|
27
|
+
import "./common42.mjs";
|
|
28
|
+
import "./common31.mjs";
|
|
29
|
+
import "./common77.mjs";
|
|
30
|
+
import "libsodium-wrappers";
|
|
31
|
+
import "./common30.mjs";
|
|
32
|
+
import "./common36.mjs";
|
|
33
|
+
import "./common41.mjs";
|
|
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
|
+
};
|
package/common147.mjs
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Utxo as $ } from "./common71.mjs";
|
|
2
|
+
import { zeroAddress as V } from "./common34.mjs";
|
|
3
|
+
import { chainIds as j } from "./common28.mjs";
|
|
4
|
+
import { ZKProofWorkerActionType as d } from "./common236.mjs";
|
|
5
|
+
import { performTaskWithWorker as p } from "./common208.mjs";
|
|
6
|
+
import { WorkerVariant as S } from "./common209.mjs";
|
|
7
|
+
import { calcAmountChanges as q, calcEncryptedOutputs as F, buildOutCommitments as Q, calcPublicSignalCount as X, createCallDataHash as Y, calcStealthAddressStructure as x } from "./common148.mjs";
|
|
8
|
+
import { randomBigInt as U } from "./common137.mjs";
|
|
9
|
+
import { encodeEmporiumMetadata as tt } from "./common154.mjs";
|
|
10
|
+
import { ExternalActionId as at } from "./common159.mjs";
|
|
11
|
+
import { defaultHookData as et } from "./common157.mjs";
|
|
12
|
+
import { generateCircomData as ot } from "./common237.mjs";
|
|
13
|
+
import { generateZkProof as rt } from "./common149.mjs";
|
|
14
|
+
const It = async (f, g, a, e, n, _, b, H, z, A = V, v = j.localhost, m = a.map(() => !1), h = a.map(() => 0n), i, mt, nt) => {
|
|
15
|
+
const u = f.getRootHash(), k = g.getRootHash(), I = a.map((t) => t.map((r) => r.getConstructableParams())), C = n.getSignature(), { accessTokenSiblings: L, accessTokenSiblingSides: O } = await p({
|
|
16
|
+
type: S.ZKProof,
|
|
17
|
+
payload: {
|
|
18
|
+
type: d.CALC_ACCESS_TOKEN_SIBLING_AND_SIDES,
|
|
19
|
+
data: {
|
|
20
|
+
userSignature: C,
|
|
21
|
+
merkleTreeAccessTokenSerialized: g.toJSON()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}), { inCommitmentSiblings: W, inCommitmentSiblingSides: K } = await p({
|
|
25
|
+
type: S.ZKProof,
|
|
26
|
+
payload: {
|
|
27
|
+
type: d.CALC_COMMITMENTS_SIBLING_AND_SIDES,
|
|
28
|
+
data: { inputUtxosSerialized: I, userSignature: C, merkleTreeSerialized: f.toJSON() }
|
|
29
|
+
}
|
|
30
|
+
}), M = q(a, e), l = F(e, !1), s = n.getShieldedPrivateKey(), y = $.findCorrectRandomization(U(31), s), R = await p({
|
|
31
|
+
type: S.ZKProof,
|
|
32
|
+
payload: {
|
|
33
|
+
type: d.BUILD_IN_NULLIFIERS,
|
|
34
|
+
data: { inputUtxosSerialized: I, onChainCreation: m }
|
|
35
|
+
}
|
|
36
|
+
}), c = a.map((t) => t[0].tokenId ?? 0), o = {
|
|
37
|
+
rootHashHinkal: u,
|
|
38
|
+
erc20TokenAddresses: a.map((t) => t[0].erc20TokenAddress),
|
|
39
|
+
tokenIds: c,
|
|
40
|
+
inNullifiers: R,
|
|
41
|
+
outTimeStamp: BigInt(e[0][0].timeStamp),
|
|
42
|
+
extraRandomization: y,
|
|
43
|
+
amountChanges: M,
|
|
44
|
+
outCommitments: Q(e, m).map((t) => t[0]),
|
|
45
|
+
rootHashAccessToken: k,
|
|
46
|
+
calldataHash: 0n,
|
|
47
|
+
shieldedPrivateKey: s,
|
|
48
|
+
hinkalWalletNonce: i ?? 0n,
|
|
49
|
+
accessTokenSiblings: L,
|
|
50
|
+
accessTokenSiblingSides: O,
|
|
51
|
+
onChainCreation: m,
|
|
52
|
+
outAmounts: e.map((t) => t[0].amount),
|
|
53
|
+
outPublicKeys: e.map((t) => t[0].getStealthAddress()),
|
|
54
|
+
inAmounts: a.map((t) => t.map((r) => r.amount.toString())),
|
|
55
|
+
inTimeStamps: a.map((t) => t.map((r) => r.timeStamp)),
|
|
56
|
+
inRandomizations: a.map((t) => t.map((r) => r.randomization)),
|
|
57
|
+
inCommitmentSiblings: W,
|
|
58
|
+
inCommitmentSiblingSides: K
|
|
59
|
+
}, w = i ? n.getWalletSalt(i) : void 0;
|
|
60
|
+
let N = H, T = at.Emporium, D = tt(z, w);
|
|
61
|
+
const E = `swapperMW${_}x${b}`, P = X(
|
|
62
|
+
E,
|
|
63
|
+
o.erc20TokenAddresses,
|
|
64
|
+
o.amountChanges,
|
|
65
|
+
o.inNullifiers,
|
|
66
|
+
o.outCommitments,
|
|
67
|
+
c.length
|
|
68
|
+
);
|
|
69
|
+
o.calldataHash = Y(
|
|
70
|
+
P,
|
|
71
|
+
A,
|
|
72
|
+
N,
|
|
73
|
+
T,
|
|
74
|
+
D,
|
|
75
|
+
l,
|
|
76
|
+
h,
|
|
77
|
+
void 0
|
|
78
|
+
);
|
|
79
|
+
const { zkCallData: B } = await rt(v, E, o), Z = x(y, s), G = await ot(
|
|
80
|
+
u,
|
|
81
|
+
k,
|
|
82
|
+
a,
|
|
83
|
+
e,
|
|
84
|
+
l,
|
|
85
|
+
h,
|
|
86
|
+
P,
|
|
87
|
+
T,
|
|
88
|
+
N,
|
|
89
|
+
D,
|
|
90
|
+
A,
|
|
91
|
+
o.calldataHash,
|
|
92
|
+
c,
|
|
93
|
+
Z,
|
|
94
|
+
m,
|
|
95
|
+
et
|
|
96
|
+
), J = {
|
|
97
|
+
tokenNumber: a.length,
|
|
98
|
+
nullifierAmount: a[0].length,
|
|
99
|
+
outputAmount: e[0].length
|
|
100
|
+
};
|
|
101
|
+
return { zkCallData: B, circomData: G, dimData: J, encryptedOutputs: l };
|
|
102
|
+
};
|
|
103
|
+
export {
|
|
104
|
+
It as constructEmporiumProof
|
|
105
|
+
};
|