@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.
Files changed (270) hide show
  1. package/assets/{snarkjsWorkerLauncher-fuD5h_j0.js → snarkjsWorkerLauncher-CaBCnle3.js} +283 -257
  2. package/assets/snarkjsWorkerLogic-BAbiO5gj.js +17935 -0
  3. package/assets/snarkjsWorkerLogic-wHJfYCfg.js +15636 -0
  4. package/assets/{utxoWorkerLogic-CtFLQiAX.js → utxoWorkerLogic-BGFm-Zl2.js} +2 -2
  5. package/assets/{zkProofWorkerLauncher-J3Ts5_Ba.js → zkProofWorkerLauncher-BteYxRBn.js} +1 -1
  6. package/assets/{zkProofWorkerLogic-CPNuu61R.js → zkProofWorkerLogic-DiLbAhAo.js} +8354 -8298
  7. package/common.mjs +644 -0
  8. package/common10.mjs +30 -0
  9. package/common100.mjs +156 -0
  10. package/common101.mjs +568 -0
  11. package/common102.mjs +1603 -0
  12. package/common103.mjs +1764 -0
  13. package/common104.mjs +2030 -0
  14. package/common105.mjs +701 -0
  15. package/common106.mjs +480 -0
  16. package/common107.mjs +2082 -0
  17. package/common108.mjs +39 -0
  18. package/common109.mjs +24 -0
  19. package/common11.mjs +30 -0
  20. package/common110.mjs +41 -0
  21. package/common111.mjs +206 -0
  22. package/common112.mjs +48 -0
  23. package/common113.mjs +39 -0
  24. package/common114.mjs +70 -0
  25. package/common115.mjs +67 -0
  26. package/common116.mjs +5 -0
  27. package/common117.mjs +61 -0
  28. package/common118.mjs +20 -0
  29. package/common119.mjs +7 -0
  30. package/common12.mjs +58 -0
  31. package/common120.mjs +22 -0
  32. package/common121.mjs +16 -0
  33. package/common122.mjs +57 -0
  34. package/common123.mjs +45 -0
  35. package/common124.mjs +57 -0
  36. package/common125.mjs +229 -0
  37. package/common126.mjs +203 -0
  38. package/common127.mjs +29 -0
  39. package/common128.mjs +38 -0
  40. package/common129.mjs +15 -0
  41. package/common13.mjs +156 -0
  42. package/common130.mjs +105 -0
  43. package/common131.mjs +4 -0
  44. package/common132.mjs +14 -0
  45. package/common133.mjs +7 -0
  46. package/common134.mjs +6 -0
  47. package/common135.mjs +8 -0
  48. package/common136.mjs +40 -0
  49. package/common137.mjs +41 -0
  50. package/common138.mjs +72 -0
  51. package/common139.mjs +107 -0
  52. package/common14.mjs +32 -0
  53. package/common140.mjs +9 -0
  54. package/common141.mjs +10 -0
  55. package/common142.mjs +97 -0
  56. package/common143.mjs +65 -0
  57. package/common144.mjs +61 -0
  58. package/common145.mjs +95 -0
  59. package/common146.mjs +129 -0
  60. package/common147.mjs +105 -0
  61. package/common148.mjs +96 -0
  62. package/common149.mjs +18 -0
  63. package/common15.mjs +16 -0
  64. package/common150.mjs +45 -0
  65. package/common151.mjs +41 -0
  66. package/common152.mjs +108 -0
  67. package/common153.mjs +40 -0
  68. package/common154.mjs +19 -0
  69. package/common155.mjs +24 -0
  70. package/common156.mjs +21 -0
  71. package/common157.mjs +22 -0
  72. package/common158.mjs +4 -0
  73. package/common159.mjs +4 -0
  74. package/common16.mjs +6 -0
  75. package/common160.mjs +15 -0
  76. package/common161.mjs +13 -0
  77. package/common162.mjs +4 -0
  78. package/common163.mjs +15 -0
  79. package/common164.mjs +36 -0
  80. package/common165.mjs +58 -0
  81. package/common166.mjs +27 -0
  82. package/common167.mjs +15 -0
  83. package/common168.mjs +25 -0
  84. package/common169.mjs +4 -0
  85. package/common17.mjs +6877 -0
  86. package/common170.mjs +85 -0
  87. package/common171.mjs +2251 -0
  88. package/common172.mjs +856 -0
  89. package/common173.mjs +973 -0
  90. package/common174.mjs +1255 -0
  91. package/common175.mjs +591 -0
  92. package/common176.mjs +1392 -0
  93. package/common177.mjs +463 -0
  94. package/common178.mjs +137 -0
  95. package/common179.mjs +2700 -0
  96. package/common18.mjs +7415 -0
  97. package/common180.mjs +946 -0
  98. package/common181.mjs +973 -0
  99. package/common182.mjs +1327 -0
  100. package/common183.mjs +591 -0
  101. package/common184.mjs +1455 -0
  102. package/common185.mjs +490 -0
  103. package/common186.mjs +137 -0
  104. package/common187.mjs +2768 -0
  105. package/common188.mjs +8 -0
  106. package/common189.mjs +14 -0
  107. package/common19.mjs +11427 -0
  108. package/common190.mjs +115623 -0
  109. package/common191.mjs +42 -0
  110. package/common192.mjs +1022 -0
  111. package/common193.mjs +1423 -0
  112. package/common194.mjs +208 -0
  113. package/common195.mjs +340 -0
  114. package/common196.mjs +674 -0
  115. package/common197.mjs +1002 -0
  116. package/common198.mjs +883 -0
  117. package/common199.mjs +262 -0
  118. package/common2.mjs +67 -0
  119. package/common20.mjs +7417 -0
  120. package/common200.mjs +264 -0
  121. package/common201.mjs +173 -0
  122. package/common202.mjs +999 -0
  123. package/common203.mjs +80 -0
  124. package/common204.mjs +56 -0
  125. package/common205.mjs +42 -0
  126. package/common206.mjs +14 -0
  127. package/common207.mjs +4 -0
  128. package/common208.mjs +62 -0
  129. package/common209.mjs +4 -0
  130. package/common21.mjs +7439 -0
  131. package/common210.mjs +4 -0
  132. package/common211.mjs +58 -0
  133. package/common212.mjs +40 -0
  134. package/common213.mjs +45 -0
  135. package/common214.mjs +36 -0
  136. package/common215.mjs +32 -0
  137. package/common216.mjs +44 -0
  138. package/common217.mjs +32 -0
  139. package/common218.mjs +38 -0
  140. package/common219.mjs +9 -0
  141. package/common22.mjs +7411 -0
  142. package/common220.mjs +32 -0
  143. package/common221.mjs +47 -0
  144. package/common222.mjs +14 -0
  145. package/common223.mjs +30 -0
  146. package/common224.mjs +91 -0
  147. package/common225.mjs +112 -0
  148. package/common226.mjs +96 -0
  149. package/common227.mjs +30 -0
  150. package/common228.mjs +138 -0
  151. package/common229.mjs +18 -0
  152. package/common23.mjs +8425 -0
  153. package/common230.mjs +42 -0
  154. package/common231.mjs +60 -0
  155. package/common232.mjs +48 -0
  156. package/common233.mjs +47 -0
  157. package/common234.mjs +44 -0
  158. package/common235.mjs +74 -0
  159. package/common236.mjs +4 -0
  160. package/common237.mjs +60 -0
  161. package/common238.mjs +4 -0
  162. package/common239.mjs +30 -0
  163. package/common24.mjs +9600 -0
  164. package/common240.mjs +4 -0
  165. package/common241.mjs +153 -0
  166. package/common242.mjs +31 -0
  167. package/common243.mjs +30 -0
  168. package/common244.mjs +68 -0
  169. package/common245.mjs +57 -0
  170. package/common246.mjs +97 -0
  171. package/common247.mjs +36 -0
  172. package/common248.mjs +43 -0
  173. package/common249.mjs +44 -0
  174. package/common25.mjs +13283 -0
  175. package/common250.mjs +59 -0
  176. package/common251.mjs +75 -0
  177. package/{snarkjsWorkerLogic-CVna_BW9.mjs → common252.mjs} +1 -1
  178. package/common253.mjs +66 -0
  179. package/common254.mjs +70 -0
  180. package/common255.mjs +211 -0
  181. package/common256.mjs +8 -0
  182. package/{workerProxy-BDj498Ht.mjs → common257.mjs} +1 -1
  183. package/common26.mjs +4329 -0
  184. package/common27.mjs +4329 -0
  185. package/common28.mjs +204 -0
  186. package/common29.mjs +57 -0
  187. package/common3.mjs +27 -0
  188. package/common30.mjs +276 -0
  189. package/common31.mjs +118 -0
  190. package/common32.mjs +157 -0
  191. package/common33.mjs +29 -0
  192. package/common34.mjs +26 -0
  193. package/common35.mjs +53 -0
  194. package/common36.mjs +55 -0
  195. package/common37.mjs +18 -0
  196. package/common38.mjs +636 -0
  197. package/common39.mjs +24 -0
  198. package/common4.mjs +37 -0
  199. package/common40.mjs +13 -0
  200. package/common41.mjs +27 -0
  201. package/common42.mjs +15 -0
  202. package/common43.mjs +24 -0
  203. package/common44.mjs +253 -0
  204. package/common45.mjs +26 -0
  205. package/common46.mjs +15 -0
  206. package/common47.mjs +9 -0
  207. package/common48.mjs +25 -0
  208. package/common49.mjs +40 -0
  209. package/common5.mjs +37 -0
  210. package/common50.mjs +41 -0
  211. package/common51.mjs +90 -0
  212. package/common52.mjs +10 -0
  213. package/common53.mjs +299 -0
  214. package/common54.mjs +101 -0
  215. package/common55.mjs +83 -0
  216. package/common56.mjs +112 -0
  217. package/common57.mjs +140 -0
  218. package/common58.mjs +95 -0
  219. package/common59.mjs +98 -0
  220. package/common6.mjs +32 -0
  221. package/common60.mjs +5 -0
  222. package/common61.mjs +91 -0
  223. package/common62.mjs +66 -0
  224. package/common63.mjs +49 -0
  225. package/common64.mjs +177 -0
  226. package/common65.mjs +8 -0
  227. package/common66.mjs +131 -0
  228. package/common67.mjs +132 -0
  229. package/common68.mjs +59 -0
  230. package/common69.mjs +35 -0
  231. package/common7.mjs +37 -0
  232. package/common70.mjs +118 -0
  233. package/common71.mjs +134 -0
  234. package/common72.mjs +33 -0
  235. package/common73.mjs +29 -0
  236. package/common74.mjs +218 -0
  237. package/common75.mjs +194 -0
  238. package/common76.mjs +62 -0
  239. package/common77.mjs +181 -0
  240. package/common78.mjs +83 -0
  241. package/common79.mjs +9 -0
  242. package/common8.mjs +38 -0
  243. package/common80.mjs +21 -0
  244. package/common81.mjs +184 -0
  245. package/common82.mjs +53 -0
  246. package/common83.mjs +35 -0
  247. package/common84.mjs +7 -0
  248. package/common85.mjs +4 -0
  249. package/common86.mjs +350 -0
  250. package/common87.mjs +570 -0
  251. package/common88.mjs +519 -0
  252. package/common89.mjs +1422 -0
  253. package/common9.mjs +41 -0
  254. package/common90.mjs +1136 -0
  255. package/common91.mjs +334 -0
  256. package/common92.mjs +291 -0
  257. package/common93.mjs +205 -0
  258. package/common94.mjs +201 -0
  259. package/common95.mjs +89 -0
  260. package/common96.mjs +721 -0
  261. package/common97.mjs +346 -0
  262. package/common98.mjs +542 -0
  263. package/common99.mjs +393 -0
  264. package/package.json +4 -4
  265. package/assets/snarkjsWorkerLogic-B6N4z_eM.js +0 -12136
  266. package/assets/snarkjsWorkerLogic-Fv0M38Mc.js +0 -12087
  267. package/index-DXElTGy9.mjs +0 -254449
  268. package/index.js +0 -457
  269. package/utxoWorkerLogic-B1Hh-bq4.mjs +0 -64
  270. package/zkProofWorkerLogic-D9rxuuiK.mjs +0 -60
package/common53.mjs ADDED
@@ -0,0 +1,299 @@
1
+ import "./common157.mjs";
2
+ import { ContractType as s } from "./common158.mjs";
3
+ import { EventType as c } from "./common160.mjs";
4
+ import "./common164.mjs";
5
+ import "./common168.mjs";
6
+ import { checkHinkalAccessToken as g, mintAccessToken as u, mintTokenCrossChain as k } from "./common112.mjs";
7
+ import { getShieldedBalance as A } from "./common139.mjs";
8
+ import { UserKeys as o } from "./common51.mjs";
9
+ import { hinkalActionBeefy as v } from "./common54.mjs";
10
+ import { hinkalActionConvex as y } from "./common55.mjs";
11
+ import { hinkalActionCurve as C } from "./common56.mjs";
12
+ import { hinkalActionPendle as f } from "./common57.mjs";
13
+ import { hinkalDeposit as w, hinkalDepositForOther as P } from "./common58.mjs";
14
+ import { hinkalSwap as T } from "./common59.mjs";
15
+ import { hinkalWithdraw as S } from "./common61.mjs";
16
+ import { resetMerkleTrees as E } from "./common63.mjs";
17
+ import { MerkleTree as h } from "./common64.mjs";
18
+ import { poseidonFunction as d } from "./common45.mjs";
19
+ import "circomlibjs";
20
+ import { networkRegistry as H } from "./common28.mjs";
21
+ import { transactionErrorCodes as p } from "./common81.mjs";
22
+ import "ethers";
23
+ import "axios";
24
+ import "./common50.mjs";
25
+ import { supportedPassportLinks as F } from "./common31.mjs";
26
+ import { monitor as I } from "./common223.mjs";
27
+ import { hinkalActionLido as R } from "./common224.mjs";
28
+ import "./common35.mjs";
29
+ import { getAxelarGasEstimate as L } from "./common7.mjs";
30
+ import { API as l } from "./common12.mjs";
31
+ import "./common33.mjs";
32
+ import { TransactionsManager as M } from "./common75.mjs";
33
+ import { hinkalActionVolatile as W } from "./common225.mjs";
34
+ import { hinkalActionPendleLP as N, hinkalGetPendleLPClaimableParams as K } from "./common226.mjs";
35
+ import { getConnextReceiveFee as O } from "./common227.mjs";
36
+ import { hinkalActionStake as x } from "./common228.mjs";
37
+ import { multiThreadedUtxoUtils as B } from "./common78.mjs";
38
+ import { hinkalPrivateWallet as U } from "./common62.mjs";
39
+ import "./common42.mjs";
40
+ import "./common72.mjs";
41
+ import "./common77.mjs";
42
+ import "./common117.mjs";
43
+ import "./common121.mjs";
44
+ import "./common129.mjs";
45
+ import { reloadPage as b } from "./common131.mjs";
46
+ import "./common191.mjs";
47
+ import "libsodium-wrappers";
48
+ import "./common30.mjs";
49
+ import "./common36.mjs";
50
+ import "./common41.mjs";
51
+ class Be {
52
+ providerAdapter;
53
+ userKeys;
54
+ signingMessage = "Login to Hinkal Protocol";
55
+ merkleTreeHinkal;
56
+ merkleTreeAccessToken;
57
+ nullifiers;
58
+ encryptedOutputs;
59
+ commitmentsSnapshotService;
60
+ nullifierSnapshotService;
61
+ accessTokenSnapshotService;
62
+ transactionsManager;
63
+ utxoUtils = B;
64
+ constructor() {
65
+ this.userKeys = new o(void 0), this.merkleTreeHinkal = h.create(d, 25n, 0n), this.merkleTreeAccessToken = h.create(d, 25n, 0n), this.nullifiers = /* @__PURE__ */ new Set(), this.encryptedOutputs = [], this.transactionsManager = new M();
66
+ }
67
+ async initProviderAdapter(e, t) {
68
+ await this.updateProviderAdapter(t);
69
+ const r = await this.connectAndPatchProvider(e);
70
+ await t.init(r), await this.setListeners();
71
+ }
72
+ async initUserKeys() {
73
+ this.userKeys = new o(await this.getProviderAdapter().signMessage(this.signingMessage));
74
+ }
75
+ async initUserKeysWithPassword(e) {
76
+ this.userKeys = new o(e);
77
+ }
78
+ async resetMerkle() {
79
+ this.isSelectedNetworkSupported() && await E(this);
80
+ }
81
+ getProviderAdapter() {
82
+ if (!this.providerAdapter)
83
+ throw new Error("ProviderAdapter is not initialized");
84
+ return this.providerAdapter;
85
+ }
86
+ async waitForTransaction(e, t = 1) {
87
+ return !!await this.providerAdapter?.waitForTransaction(e, t);
88
+ }
89
+ getContractMetadata(e, t) {
90
+ return this.getProviderAdapter().getContractMetadata(e, t);
91
+ }
92
+ getContract(e, t = void 0, r) {
93
+ return this.getProviderAdapter().getContract(e, t, r);
94
+ }
95
+ async signMessage(e) {
96
+ return await this.getProviderAdapter().signMessage(e);
97
+ }
98
+ async signTypedData(e, t, r) {
99
+ return await this.getProviderAdapter().signTypedData(e, t, r);
100
+ }
101
+ getContractWithSigner(e, t = "") {
102
+ return this.getProviderAdapter().getContractWithSigner(e, t);
103
+ }
104
+ getContractWithFetcher(e, t = "") {
105
+ return this.getProviderAdapter().getContractWithFetcher(e, t);
106
+ }
107
+ getContractWithFetcherForEthereum(e, t) {
108
+ return this.getProviderAdapter().getContractWithFetcherForEthereum(e, t);
109
+ }
110
+ isSelectedNetworkSupported() {
111
+ return !!H[this.getCurrentChainId()];
112
+ }
113
+ async switchNetwork(e) {
114
+ try {
115
+ await this.getProviderAdapter().switchNetwork(e);
116
+ } catch {
117
+ throw new Error(p.FAILED_TO_SWITCH_NETWORKS);
118
+ }
119
+ }
120
+ getCurrentChainId() {
121
+ const { chainId: e } = this.getProviderAdapter();
122
+ if (!e)
123
+ throw new Error("Illegal State: no chainId");
124
+ return e;
125
+ }
126
+ getSelectedNetwork() {
127
+ return this.providerAdapter?.getSelectedNetwork();
128
+ }
129
+ isPermitterAvailable() {
130
+ return this.getProviderAdapter().isPermitterAvailable();
131
+ }
132
+ async connectAndPatchProvider(e) {
133
+ return await this.getProviderAdapter().connectAndPatchProvider(e);
134
+ }
135
+ async disconnectFromConnector() {
136
+ await this.getProviderAdapter().disconnectFromConnector();
137
+ }
138
+ async updateProviderAdapter(e) {
139
+ try {
140
+ this.providerAdapter && this.providerAdapter.release(), this.providerAdapter = e;
141
+ } catch (t) {
142
+ throw console.error(t), Error("updateProviderAdapter failed, please try again.");
143
+ }
144
+ }
145
+ async setListeners() {
146
+ this.providerAdapter?.setChainEventListener({
147
+ onAccountChanged: () => {
148
+ this.onAccountChanged();
149
+ },
150
+ onChainChanged: (e) => {
151
+ this.onChainChanged(e);
152
+ }
153
+ });
154
+ }
155
+ async onAccountChanged() {
156
+ await this.getProviderAdapter().onAccountChanged(), document.dispatchEvent(new Event(c.AccountChanged));
157
+ }
158
+ async onChainChanged(e) {
159
+ e ? (await this.getProviderAdapter().onChainChanged(e), document.dispatchEvent(new Event(c.NetworkChange))) : (await this.disconnectFromConnector(), b());
160
+ }
161
+ async monitorConnectedAddress() {
162
+ I(await this.getEthereumAddress(), this.getCurrentChainId());
163
+ }
164
+ async getBalances() {
165
+ return A(this);
166
+ }
167
+ getSupportedPassportLinks() {
168
+ return F;
169
+ }
170
+ checkAccessToken() {
171
+ return g(this);
172
+ }
173
+ async getAxelarEstimate(e, t, r, i) {
174
+ return L(
175
+ e,
176
+ t,
177
+ r,
178
+ i,
179
+ this.userKeys.getAccessKey()
180
+ );
181
+ }
182
+ async getConnextReceiveFee(e, t) {
183
+ return O(this.getCurrentChainId(), e, t);
184
+ }
185
+ async mintHinkalAccessToken(e) {
186
+ return u(this, e);
187
+ }
188
+ async mintHinkalAccessTokenCrossChain(e, t) {
189
+ return k(this, e, t);
190
+ }
191
+ async getHinkalTreeRootHash() {
192
+ return this.getContractWithFetcher(s.HinkalContract).getRootHash();
193
+ }
194
+ async getAccessTokenTreeRootHash() {
195
+ return this.getContractWithFetcher(s.CrossChainAccessTokenContract).getRootHash();
196
+ }
197
+ async resetMerkleTreesIfNecessary() {
198
+ if (!this.isSelectedNetworkSupported())
199
+ throw new Error(p.UNSUPPORTED_NETWORK);
200
+ const [e, t] = await Promise.all([
201
+ this.getHinkalTreeRootHash(),
202
+ this.getAccessTokenTreeRootHash()
203
+ ]);
204
+ (e.toBigInt() !== this.merkleTreeHinkal.getRootHash() || t.toBigInt() !== this.merkleTreeAccessToken.getRootHash()) && await this.resetMerkle();
205
+ }
206
+ async getEventsFromHinkal() {
207
+ await Promise.all([
208
+ this.accessTokenSnapshotService?.retrieveEventsFromLatestBlock(),
209
+ this.commitmentsSnapshotService?.retrieveEventsFromLatestBlock(),
210
+ this.nullifierSnapshotService?.retrieveEventsFromLatestBlock()
211
+ ]);
212
+ }
213
+ getEthereumAddress() {
214
+ return this.getProviderAdapter().getAddress();
215
+ }
216
+ async getRandomRelay() {
217
+ return (await l.getIdleRelay(this.getCurrentChainId())).relay;
218
+ }
219
+ getGasPrice() {
220
+ if (!this.providerAdapter?.chainId)
221
+ throw new Error("Illegal State of providerAdapter in Hinkal: no chainId");
222
+ return this.providerAdapter.getGasPrice();
223
+ }
224
+ getAPI() {
225
+ return l;
226
+ }
227
+ async deposit(e, t) {
228
+ return w(this, e, t);
229
+ }
230
+ async depositForOther(e, t, r) {
231
+ return P(this, e, t, r);
232
+ }
233
+ // async transfer(token: ERC20Token, amount: bigint, recipientAddress: string): Promise<ethers.ContractTransaction> {
234
+ // return hinkalTransfer(this, token, amount, recipientAddress);
235
+ // }
236
+ async withdraw(e, t, r, i, n = !1) {
237
+ return S(this, e, t, r, i, n);
238
+ }
239
+ async swap(e, t, r, i, n = !1, a = !1) {
240
+ return T(
241
+ this,
242
+ e,
243
+ t,
244
+ r,
245
+ i,
246
+ n,
247
+ a
248
+ );
249
+ }
250
+ async actionCurve(e, t, r, i, n, a = !1) {
251
+ return C(this, e, t, r, i, n, a);
252
+ }
253
+ async actionConvex(e, t, r, i, n = !1) {
254
+ return y(this, e, t, r, i, n);
255
+ }
256
+ async actionBeefy(e, t, r, i, n, a, m = !1) {
257
+ return v(
258
+ this,
259
+ e,
260
+ t,
261
+ r,
262
+ i,
263
+ n,
264
+ a,
265
+ m
266
+ );
267
+ }
268
+ async actionLido(e, t, r, i, n, a = !1) {
269
+ return R(this, e, t, r, i, n, a);
270
+ }
271
+ async actionPendle(e, t, r, i, n = !1) {
272
+ return f(this, e, t, r, i, n);
273
+ }
274
+ async actionPendleLP(e, t, r, i, n = !1) {
275
+ return N(
276
+ this,
277
+ e,
278
+ t,
279
+ r,
280
+ i,
281
+ n
282
+ );
283
+ }
284
+ async actionVolatile(e, t, r, i = !1) {
285
+ return W(this, e, t, r, i);
286
+ }
287
+ async actionStake(e, t, r, i) {
288
+ return x(this, e, t, r, i);
289
+ }
290
+ async actionPrivateWallet(e, t, r, i = [], n, a = !1) {
291
+ return U(this, e, t, r, i, n, a);
292
+ }
293
+ async getPendleLPClaimableParams(e, t) {
294
+ return K(this, e, t);
295
+ }
296
+ }
297
+ export {
298
+ Be as Hinkal
299
+ };
package/common54.mjs ADDED
@@ -0,0 +1,101 @@
1
+ import { utils as p } from "ethers";
2
+ import { networkRegistry as N } from "./common28.mjs";
3
+ import "./common157.mjs";
4
+ import { ExternalActionId as m } from "./common159.mjs";
5
+ import { BeefyAction as I } from "./common160.mjs";
6
+ import "./common164.mjs";
7
+ import "./common168.mjs";
8
+ import { transactionErrorCodes as M } from "./common81.mjs";
9
+ import "circomlibjs";
10
+ import "./common51.mjs";
11
+ import "axios";
12
+ import "./common50.mjs";
13
+ import { addPaddingToUtxos as T } from "./common139.mjs";
14
+ import { outputUtxoProcessing as U } from "./common123.mjs";
15
+ import { constructZkProof as k } from "./common146.mjs";
16
+ import { estimateGasRelayer as F } from "./common229.mjs";
17
+ import { transactCallRelayer as L } from "./common230.mjs";
18
+ import "./common117.mjs";
19
+ import "./common72.mjs";
20
+ import "./common121.mjs";
21
+ import "./common35.mjs";
22
+ import "./common33.mjs";
23
+ import { processAmountChanges as O } from "./common125.mjs";
24
+ import { getFlatFees as P } from "./common126.mjs";
25
+ import "./common129.mjs";
26
+ import "./common42.mjs";
27
+ import "./common31.mjs";
28
+ import "./common191.mjs";
29
+ import "./common77.mjs";
30
+ import "libsodium-wrappers";
31
+ import "./common30.mjs";
32
+ import "./common36.mjs";
33
+ import "./common41.mjs";
34
+ const $ = (t, r, e, o, c, f) => {
35
+ let i;
36
+ return c === m.BeefyStake ? (i = p.defaultAbiCoder.encode(
37
+ ["uint8", "address", "uint256", "uint256"],
38
+ [Number(o), f, t[0][0].amount, t[0][0].timeStamp]
39
+ ), i) : (r.length === 1 ? i = p.defaultAbiCoder.encode(
40
+ ["uint8", "bytes", "bytes", "address"],
41
+ [Number(o), r[0], "0x00", e]
42
+ ) : r.length === 2 ? i = p.defaultAbiCoder.encode(
43
+ ["uint8", "bytes", "bytes", "address"],
44
+ [Number(o), r[0], r[1], e]
45
+ ) : i = p.defaultAbiCoder.encode(
46
+ ["uint8", "bytes", "bytes", "address"],
47
+ [Number(o), "0x00", "0x00", e]
48
+ ), i);
49
+ }, G = (t, r, e) => r === m.BeefyStake ? e === I.GetRewards ? [!1, !0] : [!1, !1, !0] : t.map((o) => o > 0n), Ct = async (t, r, e, o, c, f, i, E = !1) => {
50
+ const s = [...await T(t, r, e)], w = `swapper${i ? "MO" : "M"}${e.length.toString()}x${s[0].length}x1`, a = i ? m.BeefyStake : m.Beefy, { flatFees: u, feeUnit: b } = await P(
51
+ t.getCurrentChainId(),
52
+ r,
53
+ a,
54
+ e,
55
+ o
56
+ );
57
+ e = O({
58
+ erc20Addresses: r,
59
+ amountChanges: e,
60
+ flatFees: u,
61
+ feeUnit: b,
62
+ externalActionId: a,
63
+ action: o
64
+ });
65
+ const l = G(e, a, o);
66
+ console.log({ amountChanges: e, onChainCreation: l });
67
+ const d = [];
68
+ for (let n = 0; n < r.length; n += 1) {
69
+ const { outputUtxos: S } = U(t.userKeys, s[n], e[n]);
70
+ d.push(S);
71
+ }
72
+ const { contractData: x } = N[t.getCurrentChainId()], B = a === m.BeefyStake ? x.beefyStakeExternalActionInstanceAddress : x.beefyExternalActionInstanceAddress, R = $(
73
+ s,
74
+ c,
75
+ f,
76
+ o,
77
+ a,
78
+ i
79
+ ), y = await t.getRandomRelay();
80
+ if (!y)
81
+ throw Error(M.RELAYER_NOT_AVAILABLE);
82
+ const { zkCallData: g, circomData: C, dimData: A } = await k(
83
+ t.merkleTreeHinkal,
84
+ t.merkleTreeAccessToken,
85
+ s,
86
+ d,
87
+ t.userKeys,
88
+ w,
89
+ a,
90
+ B,
91
+ R,
92
+ y,
93
+ t.getCurrentChainId(),
94
+ l,
95
+ u
96
+ );
97
+ return E ? await F(t, g, A, C) : await L(t.getCurrentChainId(), g, A, C);
98
+ };
99
+ export {
100
+ Ct as hinkalActionBeefy
101
+ };
package/common55.mjs ADDED
@@ -0,0 +1,83 @@
1
+ import { utils as R } from "ethers";
2
+ import { getNonLocalhostChainId as U, networkRegistry as h, chainIds as d } from "./common28.mjs";
3
+ import "./common157.mjs";
4
+ import { ExternalActionId as P } from "./common159.mjs";
5
+ import { ConvexAction as g } from "./common160.mjs";
6
+ import "./common164.mjs";
7
+ import "./common168.mjs";
8
+ import { transactionErrorCodes as T } from "./common81.mjs";
9
+ import "circomlibjs";
10
+ import "./common51.mjs";
11
+ import "axios";
12
+ import "./common50.mjs";
13
+ import { addPaddingToUtxos as D } from "./common139.mjs";
14
+ import { outputUtxoProcessing as M } from "./common123.mjs";
15
+ import { constructZkProof as N } from "./common146.mjs";
16
+ import { estimateGasRelayer as O } from "./common229.mjs";
17
+ import { transactCallRelayer as S } from "./common230.mjs";
18
+ import "./common117.mjs";
19
+ import "./common72.mjs";
20
+ import "./common121.mjs";
21
+ import "./common35.mjs";
22
+ import "./common33.mjs";
23
+ import { processAmountChanges as F } from "./common125.mjs";
24
+ import { getFlatFees as b } from "./common126.mjs";
25
+ import "./common129.mjs";
26
+ import "./common42.mjs";
27
+ import "./common31.mjs";
28
+ import "./common191.mjs";
29
+ import "./common77.mjs";
30
+ import "libsodium-wrappers";
31
+ import "./common30.mjs";
32
+ import "./common36.mjs";
33
+ import "./common41.mjs";
34
+ const xt = async (t, i, o, C, n, x = !1) => {
35
+ const r = [...await D(t, i, o)], A = `swapperMO${o.length.toString()}x${r[0].length}x1`, s = U(t.getCurrentChainId());
36
+ console.log({ inputUtxosArray: r });
37
+ const a = P.Convex, { flatFees: c, feeUnit: I } = await b(
38
+ t.getCurrentChainId(),
39
+ i,
40
+ a,
41
+ o,
42
+ n
43
+ );
44
+ o = F({
45
+ erc20Addresses: i,
46
+ amountChanges: o,
47
+ flatFees: c,
48
+ feeUnit: I,
49
+ externalActionId: a,
50
+ action: n
51
+ }), console.log("new amount changes", { amountChanges: o });
52
+ const w = [g.StakeLP, g.UnStakeLP].includes(n) ? [!1, !1, ...s === d.ethMainnet ? [!0, !0] : [!0]] : [!1, ...s === d.ethMainnet ? [!0, !0] : [!0]], m = [];
53
+ for (let e = 0; e < i.length; e += 1) {
54
+ const { outputUtxos: L } = M(t.userKeys, r[e], o[e]);
55
+ m.push(L);
56
+ }
57
+ console.log({ outputUtxosArray: m });
58
+ const y = h[t.getCurrentChainId()].contractData.convexExternalActionInstanceAddress, E = R.defaultAbiCoder.encode(
59
+ ["uint8", "uint256", "uint256", "uint256"],
60
+ [Number(n), C, r[0][0].amount, r[0][0].timeStamp]
61
+ ), p = await t.getRandomRelay();
62
+ if (!p)
63
+ throw Error(T.RELAYER_NOT_AVAILABLE);
64
+ const { zkCallData: u, circomData: l, dimData: f } = await N(
65
+ t.merkleTreeHinkal,
66
+ t.merkleTreeAccessToken,
67
+ r,
68
+ m,
69
+ t.userKeys,
70
+ A,
71
+ a,
72
+ y,
73
+ E,
74
+ p,
75
+ t.getCurrentChainId(),
76
+ w,
77
+ c
78
+ );
79
+ return x ? await O(t, u, f, l) : await S(t.getCurrentChainId(), u, f, l);
80
+ };
81
+ export {
82
+ xt as hinkalActionConvex
83
+ };
package/common56.mjs ADDED
@@ -0,0 +1,112 @@
1
+ import { utils as V } from "ethers";
2
+ import { getNonLocalhostChainId as L, networkRegistry as U } from "./common28.mjs";
3
+ import "./common157.mjs";
4
+ import { ExternalActionId as i } from "./common159.mjs";
5
+ import { CurveAction as n } from "./common160.mjs";
6
+ import "./common164.mjs";
7
+ import "./common168.mjs";
8
+ import { transactionErrorCodes as h } from "./common81.mjs";
9
+ import { curveWithdrawGasTokenAddress as T } from "./common34.mjs";
10
+ import "circomlibjs";
11
+ import "./common51.mjs";
12
+ import "axios";
13
+ import "./common50.mjs";
14
+ import { addPaddingToUtxos as M } from "./common139.mjs";
15
+ import { outputUtxoProcessing as S } from "./common123.mjs";
16
+ import { constructZkProof as F } from "./common146.mjs";
17
+ import { estimateGasRelayer as W } from "./common229.mjs";
18
+ import { transactCallRelayer as k } from "./common230.mjs";
19
+ import "./common117.mjs";
20
+ import "./common72.mjs";
21
+ import "./common121.mjs";
22
+ import "./common35.mjs";
23
+ import "./common33.mjs";
24
+ import { processAmountChanges as G } from "./common125.mjs";
25
+ import { getFlatFees as N } from "./common126.mjs";
26
+ import "./common129.mjs";
27
+ import "./common42.mjs";
28
+ import "./common31.mjs";
29
+ import "./common191.mjs";
30
+ import "./common77.mjs";
31
+ import { getCRV as $ } from "./common150.mjs";
32
+ import "libsodium-wrappers";
33
+ import "./common30.mjs";
34
+ import "./common36.mjs";
35
+ import { getCalcTokenAmountWithDynamicArray as b } from "./common39.mjs";
36
+ import "./common41.mjs";
37
+ const O = (t, o, r, a) => o ? a ? i.CurveCRVRewards : i.CurveCRV : b(t).includes(r.toLowerCase()) ? i.CurveDynamic : i.Curve, P = (t, o) => {
38
+ const { contractData: r } = U[t.getCurrentChainId()];
39
+ switch (o) {
40
+ case i.Curve:
41
+ return r.curveExternalActionInstanceAddress;
42
+ case i.CurveDynamic:
43
+ return r.curveExternalActionDynamicInstanceAddress;
44
+ case i.CurveCRV:
45
+ return r.curveExternalActionInstanceAddress;
46
+ case i.CurveCRVRewards:
47
+ return r.curveStakeExternalActionInstanceAddress;
48
+ default:
49
+ return r.curveExternalActionInstanceAddress;
50
+ }
51
+ }, K = (t, o, r) => V.defaultAbiCoder.encode(
52
+ ["uint8", "address", "uint256", "uint256"],
53
+ [Number(t), o, r[0][0].amount, r[0][0].timeStamp]
54
+ ), _ = (t, o, r, a) => {
55
+ if ([n.Deposit, n.WithdrawInt, n.WithdrawUint].includes(a))
56
+ return t.map((e) => e > 0n);
57
+ if (a === n.WithdrawImbalance)
58
+ return t.map(() => !1);
59
+ if ([n.Stake, n.Unstake, n.GetCRV].includes(a)) {
60
+ let e = !1;
61
+ return o.map((p) => (p.toLowerCase() === $(r).toLowerCase() && (e = !0), e));
62
+ }
63
+ return t.map((e) => e > 0n);
64
+ }, Lt = async (t, o, r, a, e, p, I = !1) => {
65
+ const s = [...await M(t, o, r)];
66
+ let u = `swapperM${r.length.toString()}x${s[0].length}x1`;
67
+ const d = e === n.GetCRV || e === n.Stake || e === n.Unstake;
68
+ d && (u = `swapperMO${r.length.toString()}x${s[0].length}x1`);
69
+ const l = L(t.getCurrentChainId()), c = O(l, d, a, p), { flatFees: C, feeUnit: R } = await N(
70
+ t.getCurrentChainId(),
71
+ o,
72
+ c,
73
+ r,
74
+ e,
75
+ T?.current
76
+ );
77
+ r = G({
78
+ erc20Addresses: o,
79
+ amountChanges: r,
80
+ flatFees: C,
81
+ feeUnit: R,
82
+ externalActionId: c,
83
+ action: e
84
+ });
85
+ const y = _(r, o, l, e), f = [];
86
+ for (let m = 0; m < o.length; m += 1) {
87
+ const { outputUtxos: v } = S(t.userKeys, s[m], r[m]);
88
+ f.push(v);
89
+ }
90
+ const E = P(t, c), D = K(e, a, s), x = await t.getRandomRelay();
91
+ if (!x)
92
+ throw Error(h.RELAYER_NOT_AVAILABLE);
93
+ const { zkCallData: A, circomData: w, dimData: g } = await F(
94
+ t.merkleTreeHinkal,
95
+ t.merkleTreeAccessToken,
96
+ s,
97
+ f,
98
+ t.userKeys,
99
+ u,
100
+ c,
101
+ E,
102
+ D,
103
+ x,
104
+ t.getCurrentChainId(),
105
+ y,
106
+ C
107
+ );
108
+ return I ? await W(t, A, g, w) : await k(t.getCurrentChainId(), A, g, w);
109
+ };
110
+ export {
111
+ Lt as hinkalActionCurve
112
+ };