@pufferfinance/puffer-sdk 1.23.1 → 1.24.1

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 (136) hide show
  1. package/dist/api/puffer-client-helpers.cjs +1 -1
  2. package/dist/api/puffer-client-helpers.cjs.map +1 -1
  3. package/dist/api/puffer-client-helpers.js +3 -3
  4. package/dist/api/puffer-client-helpers.js.map +1 -1
  5. package/dist/api/puffer-client.cjs +1 -1
  6. package/dist/api/puffer-client.js +2 -2
  7. package/dist/ccip-FdkpGaX4.cjs +2 -0
  8. package/dist/ccip-FdkpGaX4.cjs.map +1 -0
  9. package/dist/{ccip-CiQCCFUl.js → ccip-w5ez1DCx.js} +43 -39
  10. package/dist/ccip-w5ez1DCx.js.map +1 -0
  11. package/dist/chains/constants.cjs +1 -1
  12. package/dist/chains/constants.d.ts +2 -1
  13. package/dist/chains/constants.js +1 -1
  14. package/dist/{constants-BaHwPdbi.js → constants-BweLzNUt.js} +690 -616
  15. package/dist/constants-BweLzNUt.js.map +1 -0
  16. package/dist/constants-JN89aXws.cjs +9 -0
  17. package/dist/constants-JN89aXws.cjs.map +1 -0
  18. package/dist/contracts/addresses.cjs +1 -1
  19. package/dist/contracts/addresses.js +1 -1
  20. package/dist/contracts/handlers/carrot-staking-handler.cjs +1 -1
  21. package/dist/contracts/handlers/carrot-staking-handler.d.ts +368 -352
  22. package/dist/contracts/handlers/carrot-staking-handler.js +2 -2
  23. package/dist/contracts/handlers/concrete-vault-handler.cjs +1 -1
  24. package/dist/contracts/handlers/concrete-vault-handler.d.ts +368 -352
  25. package/dist/contracts/handlers/concrete-vault-handler.js +2 -2
  26. package/dist/contracts/handlers/distributor-handler.cjs +1 -1
  27. package/dist/contracts/handlers/distributor-handler.d.ts +368 -352
  28. package/dist/contracts/handlers/distributor-handler.js +2 -2
  29. package/dist/contracts/handlers/erc20-permit-handler.cjs +1 -1
  30. package/dist/contracts/handlers/erc20-permit-handler.cjs.map +1 -1
  31. package/dist/contracts/handlers/erc20-permit-handler.d.ts +368 -352
  32. package/dist/contracts/handlers/erc20-permit-handler.js +3 -3
  33. package/dist/contracts/handlers/erc20-permit-handler.js.map +1 -1
  34. package/dist/contracts/handlers/guardian-module-handler.cjs +1 -1
  35. package/dist/contracts/handlers/guardian-module-handler.d.ts +368 -352
  36. package/dist/contracts/handlers/guardian-module-handler.js +2 -2
  37. package/dist/contracts/handlers/institutional-access-manager-handler.cjs +1 -1
  38. package/dist/contracts/handlers/institutional-access-manager-handler.d.ts +368 -352
  39. package/dist/contracts/handlers/institutional-access-manager-handler.js +3 -3
  40. package/dist/contracts/handlers/institutional-vault-handler.cjs +1 -1
  41. package/dist/contracts/handlers/institutional-vault-handler.d.ts +368 -352
  42. package/dist/contracts/handlers/institutional-vault-handler.js +2 -2
  43. package/dist/contracts/handlers/l1-reward-manager-handler.cjs +1 -1
  44. package/dist/contracts/handlers/l1-reward-manager-handler.d.ts +368 -352
  45. package/dist/contracts/handlers/l1-reward-manager-handler.js +2 -2
  46. package/dist/contracts/handlers/l2-reward-manager-handler.cjs +1 -1
  47. package/dist/contracts/handlers/l2-reward-manager-handler.d.ts +368 -352
  48. package/dist/contracts/handlers/l2-reward-manager-handler.js +2 -2
  49. package/dist/contracts/handlers/mtw-carrot-handler.cjs +1 -1
  50. package/dist/contracts/handlers/mtw-carrot-handler.d.ts +368 -352
  51. package/dist/contracts/handlers/mtw-carrot-handler.js +2 -2
  52. package/dist/contracts/handlers/nucleus-accountant-handler.cjs +1 -1
  53. package/dist/contracts/handlers/nucleus-accountant-handler.d.ts +368 -352
  54. package/dist/contracts/handlers/nucleus-accountant-handler.js +1 -1
  55. package/dist/contracts/handlers/nucleus-atomic-queue-handler.cjs +1 -1
  56. package/dist/contracts/handlers/nucleus-atomic-queue-handler.d.ts +368 -352
  57. package/dist/contracts/handlers/nucleus-atomic-queue-handler.js +2 -2
  58. package/dist/contracts/handlers/nucleus-boring-vault-handler.cjs +1 -1
  59. package/dist/contracts/handlers/nucleus-boring-vault-handler.d.ts +368 -352
  60. package/dist/contracts/handlers/nucleus-boring-vault-handler.js +2 -2
  61. package/dist/contracts/handlers/nucleus-teller-handler.cjs +1 -1
  62. package/dist/contracts/handlers/nucleus-teller-handler.d.ts +368 -352
  63. package/dist/contracts/handlers/nucleus-teller-handler.js +2 -2
  64. package/dist/contracts/handlers/puf-locker-handler.cjs +1 -1
  65. package/dist/contracts/handlers/puf-locker-handler.d.ts +368 -352
  66. package/dist/contracts/handlers/puf-locker-handler.js +2 -2
  67. package/dist/contracts/handlers/puffer-depositor-handler.cjs +1 -1
  68. package/dist/contracts/handlers/puffer-depositor-handler.d.ts +368 -352
  69. package/dist/contracts/handlers/puffer-depositor-handler.js +2 -2
  70. package/dist/contracts/handlers/puffer-l2-depositor-handler.cjs +1 -1
  71. package/dist/contracts/handlers/puffer-l2-depositor-handler.d.ts +368 -352
  72. package/dist/contracts/handlers/puffer-l2-depositor-handler.js +2 -2
  73. package/dist/contracts/handlers/puffer-oracle-v2-handler.cjs +1 -1
  74. package/dist/contracts/handlers/puffer-oracle-v2-handler.d.ts +368 -352
  75. package/dist/contracts/handlers/puffer-oracle-v2-handler.js +2 -2
  76. package/dist/contracts/handlers/puffer-protocol-handler.cjs +1 -1
  77. package/dist/contracts/handlers/puffer-protocol-handler.d.ts +368 -352
  78. package/dist/contracts/handlers/puffer-protocol-handler.js +2 -2
  79. package/dist/contracts/handlers/puffer-vault-handler.cjs +1 -1
  80. package/dist/contracts/handlers/puffer-vault-handler.d.ts +368 -352
  81. package/dist/contracts/handlers/puffer-vault-handler.js +2 -2
  82. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.cjs +1 -1
  83. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.d.ts +368 -352
  84. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.js +2 -2
  85. package/dist/contracts/handlers/validator-ticket-handler.cjs +1 -1
  86. package/dist/contracts/handlers/validator-ticket-handler.d.ts +368 -352
  87. package/dist/contracts/handlers/validator-ticket-handler.js +2 -2
  88. package/dist/contracts/tokens.cjs +1 -1
  89. package/dist/contracts/tokens.cjs.map +1 -1
  90. package/dist/contracts/tokens.js +7 -6
  91. package/dist/contracts/tokens.js.map +1 -1
  92. package/dist/contracts/vaults-addresses.cjs +1 -1
  93. package/dist/contracts/vaults-addresses.js +1 -1
  94. package/dist/createWalletClient-CYva1_XM.js +3262 -0
  95. package/dist/createWalletClient-CYva1_XM.js.map +1 -0
  96. package/dist/createWalletClient-LeyDLKOH.cjs +5 -0
  97. package/dist/createWalletClient-LeyDLKOH.cjs.map +1 -0
  98. package/dist/{getContract-DGV8J5xI.js → getContract-BES7gSby.js} +2 -2
  99. package/dist/getContract-BES7gSby.js.map +1 -0
  100. package/dist/{getContract-RNLlK54b.cjs → getContract-F-fd_vf7.cjs} +2 -2
  101. package/dist/{getContract-DGV8J5xI.js.map → getContract-F-fd_vf7.cjs.map} +1 -1
  102. package/dist/localBatchGatewayRequest-CCdxn5t3.js +90 -0
  103. package/dist/localBatchGatewayRequest-CCdxn5t3.js.map +1 -0
  104. package/dist/localBatchGatewayRequest-DCWU6kQW.cjs +2 -0
  105. package/dist/localBatchGatewayRequest-DCWU6kQW.cjs.map +1 -0
  106. package/dist/main.cjs +1 -1
  107. package/dist/main.js +1 -1
  108. package/dist/secp256k1-DGP4Y7VW.js +1291 -0
  109. package/dist/secp256k1-DGP4Y7VW.js.map +1 -0
  110. package/dist/secp256k1-QOxLqUEc.cjs +2 -0
  111. package/dist/secp256k1-QOxLqUEc.cjs.map +1 -0
  112. package/dist/utils/version.cjs +1 -1
  113. package/dist/utils/version.js +1 -1
  114. package/dist/writeContract-Cqc9vxbU.cjs +36 -0
  115. package/dist/writeContract-Cqc9vxbU.cjs.map +1 -0
  116. package/dist/{writeContract-BU3yK-Xj.js → writeContract-QAArm5iD.js} +1894 -1361
  117. package/dist/writeContract-QAArm5iD.js.map +1 -0
  118. package/package.json +2 -2
  119. package/dist/ccip-CiQCCFUl.js.map +0 -1
  120. package/dist/ccip-DIWF4nDh.cjs +0 -2
  121. package/dist/ccip-DIWF4nDh.cjs.map +0 -1
  122. package/dist/constants-BaHwPdbi.js.map +0 -1
  123. package/dist/constants-c-vATmlG.cjs +0 -9
  124. package/dist/constants-c-vATmlG.cjs.map +0 -1
  125. package/dist/createWalletClient-D74YRepQ.js +0 -3290
  126. package/dist/createWalletClient-D74YRepQ.js.map +0 -1
  127. package/dist/createWalletClient-DKSH6l9_.cjs +0 -6
  128. package/dist/createWalletClient-DKSH6l9_.cjs.map +0 -1
  129. package/dist/getContract-RNLlK54b.cjs.map +0 -1
  130. package/dist/secp256k1-B-LxKJrQ.js +0 -1340
  131. package/dist/secp256k1-B-LxKJrQ.js.map +0 -1
  132. package/dist/secp256k1-CC-cv1vD.cjs +0 -2
  133. package/dist/secp256k1-CC-cv1vD.cjs.map +0 -1
  134. package/dist/writeContract-BU3yK-Xj.js.map +0 -1
  135. package/dist/writeContract-CKqv1dsa.cjs +0 -32
  136. package/dist/writeContract-CKqv1dsa.cjs.map +0 -1
@@ -1,3290 +0,0 @@
1
- import { p as nt, n as zr, o as Fr, I as Dr, g as T, r as H, q as V, m as qr, M as ie, h as D, H as te, t as Or, U as ve, S as st, C as at, P as ot, u as it, v as ct, J as ut, L as Ee, T as ft, R as dt, x as lt, y as Ae, z as Te, A as pt, B as ht, D as mt, E as gt, F as bt, G as _r, K as Mr, N as yt, O as jr, Q as ae, V as X, W as wt, X as kt, Y as he, Z as vt, _ as Lr, $ as qe, a0 as Oe, a1 as Hr, a2 as Ur, a3 as _e, a4 as St, a5 as Gr, l as Me, a6 as Vr, a7 as Wr, a8 as Jr, a9 as me, aa as Ie, ab as Zr, ac as Bt, ad as zt, ae as Kr, af as Qr, ag as Pe, ah as Xr, ai as xt, aj as Ft, ak as Yr, k as Dt, j as qt, al as en, am as tn, an as Q, ao as ge, ap as rn, aq as Z, ar as nn, as as sn, at as an, au as on, av as je, aw as Ot, ax as Le, w as cn, s as un, ay as _t, az as Mt, aA as fn, aB as dn, aC as ln, aD as pn, a as hn, aE as He, aF as mn, aG as gn, e as bn, c as yn, aH as jt, aI as Ue, aJ as wn, d as vn } from "./writeContract-BU3yK-Xj.js";
2
- import { B as F, n as B, af as xn, v as le, i as Lt, b as ne, a as En, m as O, s as re, c as Ge, t as W, z as An, A as Ht, a9 as pe, o as Tn, I as In, l as Re, ag as Pn, x as Rn, F as Ut, ah as Gt, ai as Cn, aj as Vt, ak as $n, a2 as Nn, _ as kn, al as Sn, h as se, am as Bn, an as Wt, ao as zn, J as Fn } from "./constants-BaHwPdbi.js";
3
- import { secp256k1 as Dn } from "./secp256k1-B-LxKJrQ.js";
4
- function Et(e) {
5
- let t;
6
- if (typeof e == "string")
7
- t = nt(e);
8
- else {
9
- const r = zr(e), n = e.length;
10
- for (let s = 0; s < n; s++) {
11
- const a = e[s];
12
- if (!Fr(a)) {
13
- t = nt(a, r);
14
- break;
15
- }
16
- }
17
- }
18
- if (!t)
19
- throw new Dr({ signature: e });
20
- return t;
21
- }
22
- class qn extends F {
23
- constructor({ address: t }) {
24
- super(`No EIP-712 domain found on contract "${t}".`, {
25
- metaMessages: [
26
- "Ensure that:",
27
- `- The contract is deployed at the address "${t}".`,
28
- "- `eip712Domain()` function exists on the contract.",
29
- "- `eip712Domain()` function matches signature to ERC-5267 specification."
30
- ],
31
- name: "Eip712DomainNotFoundError"
32
- });
33
- }
34
- }
35
- async function On(e, t) {
36
- const { address: r, factory: n, factoryData: s } = t;
37
- try {
38
- const [a, o, c, u, i, d, f] = await T(e, H, "readContract")({
39
- abi: _n,
40
- address: r,
41
- functionName: "eip712Domain",
42
- factory: n,
43
- factoryData: s
44
- });
45
- return {
46
- domain: {
47
- name: o,
48
- version: c,
49
- chainId: Number(u),
50
- verifyingContract: i,
51
- salt: d
52
- },
53
- extensions: f,
54
- fields: a
55
- };
56
- } catch (a) {
57
- const o = a;
58
- throw o.name === "ContractFunctionExecutionError" && o.cause.name === "ContractFunctionZeroDataError" ? new qn({ address: r }) : o;
59
- }
60
- }
61
- const _n = [
62
- {
63
- inputs: [],
64
- name: "eip712Domain",
65
- outputs: [
66
- { name: "fields", type: "bytes1" },
67
- { name: "name", type: "string" },
68
- { name: "version", type: "string" },
69
- { name: "chainId", type: "uint256" },
70
- { name: "verifyingContract", type: "address" },
71
- { name: "salt", type: "bytes32" },
72
- { name: "extensions", type: "uint256[]" }
73
- ],
74
- stateMutability: "view",
75
- type: "function"
76
- }
77
- ];
78
- async function Mn(e, { chain: t }) {
79
- const { id: r, name: n, nativeCurrency: s, rpcUrls: a, blockExplorers: o } = t;
80
- await e.request({
81
- method: "wallet_addEthereumChain",
82
- params: [
83
- {
84
- chainId: B(r),
85
- chainName: n,
86
- nativeCurrency: s,
87
- rpcUrls: a.default.http,
88
- blockExplorerUrls: o ? Object.values(o).map(({ url: c }) => c) : void 0
89
- }
90
- ]
91
- }, { dedupe: !0, retryCount: 0 });
92
- }
93
- const Ce = 256;
94
- let ce = Ce, ue;
95
- function Jt(e = 11) {
96
- if (!ue || ce + e > Ce * 2) {
97
- ue = "", ce = 0;
98
- for (let t = 0; t < Ce; t++)
99
- ue += (256 + Math.random() * 256 | 0).toString(16).substring(1);
100
- }
101
- return ue.substring(ce, ce++ + e);
102
- }
103
- function Zt(e) {
104
- const { batch: t, cacheTime: r = e.pollingInterval ?? 4e3, ccipRead: n, key: s = "base", name: a = "Base Client", pollingInterval: o = 4e3, type: c = "base" } = e, u = e.chain, i = e.account ? V(e.account) : void 0, { config: d, request: f, value: l } = e.transport({
105
- chain: u,
106
- pollingInterval: o
107
- }), p = { ...d, ...l }, m = {
108
- account: i,
109
- batch: t,
110
- cacheTime: r,
111
- ccipRead: n,
112
- chain: u,
113
- key: s,
114
- name: a,
115
- pollingInterval: o,
116
- request: f,
117
- transport: p,
118
- type: c,
119
- uid: Jt()
120
- };
121
- function g(v) {
122
- return (h) => {
123
- const b = h(v);
124
- for (const x in m)
125
- delete b[x];
126
- const y = { ...v, ...b };
127
- return Object.assign(y, { extend: g(y) });
128
- };
129
- }
130
- return Object.assign(m, { extend: g(m) });
131
- }
132
- const fe = /* @__PURE__ */ new xn(8192);
133
- function jn(e, { enabled: t = !0, id: r }) {
134
- if (!t || !r)
135
- return e();
136
- if (fe.get(r))
137
- return fe.get(r);
138
- const n = e().finally(() => fe.delete(r));
139
- return fe.set(r, n), n;
140
- }
141
- function $e(e, { delay: t = 100, retryCount: r = 2, shouldRetry: n = () => !0 } = {}) {
142
- return new Promise((s, a) => {
143
- const o = async ({ count: c = 0 } = {}) => {
144
- const u = async ({ error: i }) => {
145
- const d = typeof t == "function" ? t({ count: c, error: i }) : t;
146
- d && await qr(d), o({ count: c + 1 });
147
- };
148
- try {
149
- const i = await e();
150
- s(i);
151
- } catch (i) {
152
- if (c < r && await n({ count: c, error: i }))
153
- return u({ error: i });
154
- a(i);
155
- }
156
- };
157
- o();
158
- });
159
- }
160
- function Ln(e, t = {}) {
161
- return async (r, n = {}) => {
162
- var f;
163
- const { dedupe: s = !1, methods: a, retryDelay: o = 150, retryCount: c = 3, uid: u } = {
164
- ...t,
165
- ...n
166
- }, { method: i } = r;
167
- if ((f = a == null ? void 0 : a.exclude) != null && f.includes(i))
168
- throw new ie(new Error("method not supported"), {
169
- method: i
170
- });
171
- if (a != null && a.include && !a.include.includes(i))
172
- throw new ie(new Error("method not supported"), {
173
- method: i
174
- });
175
- const d = s ? le(`${u}.${D(r)}`) : void 0;
176
- return jn(() => $e(async () => {
177
- try {
178
- return await e(r);
179
- } catch (l) {
180
- const p = l;
181
- switch (p.code) {
182
- // -32700
183
- case gt.code:
184
- throw new gt(p);
185
- // -32600
186
- case mt.code:
187
- throw new mt(p);
188
- // -32601
189
- case ht.code:
190
- throw new ht(p, { method: r.method });
191
- // -32602
192
- case pt.code:
193
- throw new pt(p);
194
- // -32603
195
- case Te.code:
196
- throw new Te(p);
197
- // -32000
198
- case Ae.code:
199
- throw new Ae(p);
200
- // -32001
201
- case lt.code:
202
- throw new lt(p);
203
- // -32002
204
- case dt.code:
205
- throw new dt(p);
206
- // -32003
207
- case ft.code:
208
- throw new ft(p);
209
- // -32004
210
- case ie.code:
211
- throw new ie(p, {
212
- method: r.method
213
- });
214
- // -32005
215
- case Ee.code:
216
- throw new Ee(p);
217
- // -32006
218
- case ut.code:
219
- throw new ut(p);
220
- // 4001
221
- case ve.code:
222
- throw new ve(p);
223
- // 4100
224
- case ct.code:
225
- throw new ct(p);
226
- // 4200
227
- case it.code:
228
- throw new it(p);
229
- // 4900
230
- case ot.code:
231
- throw new ot(p);
232
- // 4901
233
- case at.code:
234
- throw new at(p);
235
- // 4902
236
- case st.code:
237
- throw new st(p);
238
- // CAIP-25: User Rejected Error
239
- // https://docs.walletconnect.com/2.0/specs/clients/sign/error-codes#rejected-caip-25
240
- case 5e3:
241
- throw new ve(p);
242
- default:
243
- throw l instanceof F ? l : new Or(p);
244
- }
245
- }
246
- }, {
247
- delay: ({ count: l, error: p }) => {
248
- var m;
249
- if (p && p instanceof te) {
250
- const g = (m = p == null ? void 0 : p.headers) == null ? void 0 : m.get("Retry-After");
251
- if (g != null && g.match(/\d/))
252
- return Number.parseInt(g) * 1e3;
253
- }
254
- return ~~(1 << l) * o;
255
- },
256
- retryCount: c,
257
- shouldRetry: ({ error: l }) => Hn(l)
258
- }), { enabled: s, id: d });
259
- };
260
- }
261
- function Hn(e) {
262
- return "code" in e && typeof e.code == "number" ? e.code === -1 || e.code === Ee.code || e.code === Te.code : e instanceof te && e.status ? e.status === 403 || e.status === 408 || e.status === 413 || e.status === 429 || e.status === 500 || e.status === 502 || e.status === 503 || e.status === 504 : !0;
263
- }
264
- function Un({ key: e, methods: t, name: r, request: n, retryCount: s = 3, retryDelay: a = 150, timeout: o, type: c }, u) {
265
- const i = Jt();
266
- return {
267
- config: {
268
- key: e,
269
- methods: t,
270
- name: r,
271
- request: n,
272
- retryCount: s,
273
- retryDelay: a,
274
- timeout: o,
275
- type: c
276
- },
277
- request: Ln(n, { methods: t, retryCount: s, retryDelay: a, uid: i }),
278
- value: u
279
- };
280
- }
281
- class Gn extends F {
282
- constructor() {
283
- super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.", {
284
- docsPath: "/docs/clients/intro",
285
- name: "UrlRequiredError"
286
- });
287
- }
288
- }
289
- function Vn(e, { errorInstance: t = new Error("timed out"), timeout: r, signal: n }) {
290
- return new Promise((s, a) => {
291
- (async () => {
292
- let o;
293
- try {
294
- const c = new AbortController();
295
- r > 0 && (o = setTimeout(() => {
296
- n && c.abort();
297
- }, r)), s(await e({ signal: (c == null ? void 0 : c.signal) || null }));
298
- } catch (c) {
299
- (c == null ? void 0 : c.name) === "AbortError" && a(t), a(c);
300
- } finally {
301
- clearTimeout(o);
302
- }
303
- })();
304
- });
305
- }
306
- function Wn() {
307
- return {
308
- current: 0,
309
- take() {
310
- return this.current++;
311
- },
312
- reset() {
313
- this.current = 0;
314
- }
315
- };
316
- }
317
- const At = /* @__PURE__ */ Wn();
318
- function Jn(e, t = {}) {
319
- return {
320
- async request(r) {
321
- var f;
322
- const { body: n, onRequest: s = t.onRequest, onResponse: a = t.onResponse, timeout: o = t.timeout ?? 1e4 } = r, c = {
323
- ...t.fetchOptions ?? {},
324
- ...r.fetchOptions ?? {}
325
- }, { headers: u, method: i, signal: d } = c;
326
- try {
327
- const l = await Vn(async ({ signal: m }) => {
328
- const g = {
329
- ...c,
330
- body: Array.isArray(n) ? D(n.map((y) => ({
331
- jsonrpc: "2.0",
332
- id: y.id ?? At.take(),
333
- ...y
334
- }))) : D({
335
- jsonrpc: "2.0",
336
- id: n.id ?? At.take(),
337
- ...n
338
- }),
339
- headers: {
340
- "Content-Type": "application/json",
341
- ...u
342
- },
343
- method: i || "POST",
344
- signal: d || (o > 0 ? m : null)
345
- }, v = new Request(e, g), h = await (s == null ? void 0 : s(v, g)) ?? { ...g, url: e };
346
- return await fetch(h.url ?? e, h);
347
- }, {
348
- errorInstance: new bt({ body: n, url: e }),
349
- timeout: o,
350
- signal: !0
351
- });
352
- a && await a(l);
353
- let p;
354
- if ((f = l.headers.get("Content-Type")) != null && f.startsWith("application/json"))
355
- p = await l.json();
356
- else {
357
- p = await l.text();
358
- try {
359
- p = JSON.parse(p || "{}");
360
- } catch (m) {
361
- if (l.ok)
362
- throw m;
363
- p = { error: p };
364
- }
365
- }
366
- if (!l.ok)
367
- throw new te({
368
- body: n,
369
- details: D(p.error) || l.statusText,
370
- headers: l.headers,
371
- status: l.status,
372
- url: e
373
- });
374
- return p;
375
- } catch (l) {
376
- throw l instanceof te || l instanceof bt ? l : new te({
377
- body: n,
378
- cause: l,
379
- url: e
380
- });
381
- }
382
- }
383
- };
384
- }
385
- function lo(e, t = {}) {
386
- const { batch: r, fetchOptions: n, key: s = "http", methods: a, name: o = "HTTP JSON-RPC", onFetchRequest: c, onFetchResponse: u, retryDelay: i, raw: d } = t;
387
- return ({ chain: f, retryCount: l, timeout: p }) => {
388
- const { batchSize: m = 1e3, wait: g = 0 } = typeof r == "object" ? r : {}, v = t.retryCount ?? l, h = p ?? t.timeout ?? 1e4, b = e || (f == null ? void 0 : f.rpcUrls.default.http[0]);
389
- if (!b)
390
- throw new Gn();
391
- const y = Jn(b, {
392
- fetchOptions: n,
393
- onRequest: c,
394
- onResponse: u,
395
- timeout: h
396
- });
397
- return Un({
398
- key: s,
399
- methods: a,
400
- name: o,
401
- async request({ method: x, params: P }) {
402
- const A = { method: x, params: P }, { schedule: E } = _r({
403
- id: b,
404
- wait: g,
405
- shouldSplitBatch(I) {
406
- return I.length > m;
407
- },
408
- fn: (I) => y.request({
409
- body: I
410
- }),
411
- sort: (I, k) => I.id - k.id
412
- }), C = async (I) => r ? E(I) : [
413
- await y.request({
414
- body: I
415
- })
416
- ], [{ error: R, result: N }] = await C(A);
417
- if (d)
418
- return { error: R, result: N };
419
- if (R)
420
- throw new Mr({
421
- body: A,
422
- error: R,
423
- url: b
424
- });
425
- return N;
426
- },
427
- retryCount: v,
428
- retryDelay: i,
429
- timeout: h,
430
- type: "http"
431
- }, {
432
- fetchOptions: n,
433
- url: b
434
- });
435
- };
436
- }
437
- function Ve(e, t) {
438
- var n, s, a, o, c, u;
439
- if (!(e instanceof F))
440
- return !1;
441
- const r = e.walk((i) => i instanceof yt);
442
- return r instanceof yt ? !!(((n = r.data) == null ? void 0 : n.errorName) === "ResolverNotFound" || ((s = r.data) == null ? void 0 : s.errorName) === "ResolverWildcardNotSupported" || ((a = r.data) == null ? void 0 : a.errorName) === "ResolverNotContract" || ((o = r.data) == null ? void 0 : o.errorName) === "ResolverError" || ((c = r.data) == null ? void 0 : c.errorName) === "HttpError" || (u = r.reason) != null && u.includes("Wildcard on non-extended resolvers is not supported") || t === "reverse" && r.reason === jr[50]) : !1;
443
- }
444
- function Kt(e) {
445
- if (e.length !== 66 || e.indexOf("[") !== 0 || e.indexOf("]") !== 65)
446
- return null;
447
- const t = `0x${e.slice(1, 65)}`;
448
- return Lt(t) ? t : null;
449
- }
450
- function de(e) {
451
- let t = new Uint8Array(32).fill(0);
452
- if (!e)
453
- return ne(t);
454
- const r = e.split(".");
455
- for (let n = r.length - 1; n >= 0; n -= 1) {
456
- const s = Kt(r[n]), a = s ? En(s) : O(re(r[n]), "bytes");
457
- t = O(Ge([t, a]), "bytes");
458
- }
459
- return ne(t);
460
- }
461
- function Zn(e) {
462
- return `[${e.slice(2)}]`;
463
- }
464
- function Kn(e) {
465
- const t = new Uint8Array(32).fill(0);
466
- return e ? Kt(e) || O(re(e)) : ne(t);
467
- }
468
- function be(e) {
469
- const t = e.replace(/^\.|\.$/gm, "");
470
- if (t.length === 0)
471
- return new Uint8Array(1);
472
- const r = new Uint8Array(re(t).byteLength + 2);
473
- let n = 0;
474
- const s = t.split(".");
475
- for (let a = 0; a < s.length; a++) {
476
- let o = re(s[a]);
477
- o.byteLength > 255 && (o = re(Zn(Kn(s[a])))), r[n] = o.length, r.set(o, n + 1), n += o.length + 1;
478
- }
479
- return r.byteLength !== n + 1 ? r.slice(0, n + 1) : r;
480
- }
481
- async function Qn(e, { blockNumber: t, blockTag: r, coinType: n, name: s, gatewayUrls: a, strict: o, universalResolverAddress: c }) {
482
- let u = c;
483
- if (!u) {
484
- if (!e.chain)
485
- throw new Error("client chain not configured. universalResolverAddress is required.");
486
- u = ae({
487
- blockNumber: t,
488
- chain: e.chain,
489
- contract: "ensUniversalResolver"
490
- });
491
- }
492
- try {
493
- const i = X({
494
- abi: wt,
495
- functionName: "addr",
496
- ...n != null ? { args: [de(s), BigInt(n)] } : { args: [de(s)] }
497
- }), d = {
498
- address: u,
499
- abi: kt,
500
- functionName: "resolve",
501
- args: [W(be(s)), i],
502
- blockNumber: t,
503
- blockTag: r
504
- }, f = T(e, H, "readContract"), l = a ? await f({
505
- ...d,
506
- args: [...d.args, a]
507
- }) : await f(d);
508
- if (l[0] === "0x")
509
- return null;
510
- const p = he({
511
- abi: wt,
512
- args: n != null ? [de(s), BigInt(n)] : void 0,
513
- functionName: "addr",
514
- data: l[0]
515
- });
516
- return p === "0x" || An(p) === "0x00" ? null : p;
517
- } catch (i) {
518
- if (o)
519
- throw i;
520
- if (Ve(i, "resolve"))
521
- return null;
522
- throw i;
523
- }
524
- }
525
- class Xn extends F {
526
- constructor({ data: t }) {
527
- super("Unable to extract image from metadata. The metadata may be malformed or invalid.", {
528
- metaMessages: [
529
- "- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.",
530
- "",
531
- `Provided data: ${JSON.stringify(t)}`
532
- ],
533
- name: "EnsAvatarInvalidMetadataError"
534
- });
535
- }
536
- }
537
- class ee extends F {
538
- constructor({ reason: t }) {
539
- super(`ENS NFT avatar URI is invalid. ${t}`, {
540
- name: "EnsAvatarInvalidNftUriError"
541
- });
542
- }
543
- }
544
- class We extends F {
545
- constructor({ uri: t }) {
546
- super(`Unable to resolve ENS avatar URI "${t}". The URI may be malformed, invalid, or does not respond with a valid image.`, { name: "EnsAvatarUriResolutionError" });
547
- }
548
- }
549
- class Yn extends F {
550
- constructor({ namespace: t }) {
551
- super(`ENS NFT avatar namespace "${t}" is not supported. Must be "erc721" or "erc1155".`, { name: "EnsAvatarUnsupportedNamespaceError" });
552
- }
553
- }
554
- const es = /(?<protocol>https?:\/\/[^\/]*|ipfs:\/|ipns:\/|ar:\/)?(?<root>\/)?(?<subpath>ipfs\/|ipns\/)?(?<target>[\w\-.]+)(?<subtarget>\/.*)?/, ts = /^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})(\/(?<target>[\w\-.]+))?(?<subtarget>\/.*)?$/, rs = /^data:([a-zA-Z\-/+]*);base64,([^"].*)/, ns = /^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;
555
- async function ss(e) {
556
- try {
557
- const t = await fetch(e, { method: "HEAD" });
558
- if (t.status === 200) {
559
- const r = t.headers.get("content-type");
560
- return r == null ? void 0 : r.startsWith("image/");
561
- }
562
- return !1;
563
- } catch (t) {
564
- return typeof t == "object" && typeof t.response < "u" || !globalThis.hasOwnProperty("Image") ? !1 : new Promise((r) => {
565
- const n = new Image();
566
- n.onload = () => {
567
- r(!0);
568
- }, n.onerror = () => {
569
- r(!1);
570
- }, n.src = e;
571
- });
572
- }
573
- }
574
- function Tt(e, t) {
575
- return e ? e.endsWith("/") ? e.slice(0, -1) : e : t;
576
- }
577
- function Qt({ uri: e, gatewayUrls: t }) {
578
- const r = rs.test(e);
579
- if (r)
580
- return { uri: e, isOnChain: !0, isEncoded: r };
581
- const n = Tt(t == null ? void 0 : t.ipfs, "https://ipfs.io"), s = Tt(t == null ? void 0 : t.arweave, "https://arweave.net"), a = e.match(es), { protocol: o, subpath: c, target: u, subtarget: i = "" } = (a == null ? void 0 : a.groups) || {}, d = o === "ipns:/" || c === "ipns/", f = o === "ipfs:/" || c === "ipfs/" || ts.test(e);
582
- if (e.startsWith("http") && !d && !f) {
583
- let p = e;
584
- return t != null && t.arweave && (p = e.replace(/https:\/\/arweave.net/g, t == null ? void 0 : t.arweave)), { uri: p, isOnChain: !1, isEncoded: !1 };
585
- }
586
- if ((d || f) && u)
587
- return {
588
- uri: `${n}/${d ? "ipns" : "ipfs"}/${u}${i}`,
589
- isOnChain: !1,
590
- isEncoded: !1
591
- };
592
- if (o === "ar:/" && u)
593
- return {
594
- uri: `${s}/${u}${i || ""}`,
595
- isOnChain: !1,
596
- isEncoded: !1
597
- };
598
- let l = e.replace(ns, "");
599
- if (l.startsWith("<svg") && (l = `data:image/svg+xml;base64,${btoa(l)}`), l.startsWith("data:") || l.startsWith("{"))
600
- return {
601
- uri: l,
602
- isOnChain: !0,
603
- isEncoded: !1
604
- };
605
- throw new We({ uri: e });
606
- }
607
- function Xt(e) {
608
- if (typeof e != "object" || !("image" in e) && !("image_url" in e) && !("image_data" in e))
609
- throw new Xn({ data: e });
610
- return e.image || e.image_url || e.image_data;
611
- }
612
- async function as({ gatewayUrls: e, uri: t }) {
613
- try {
614
- const r = await fetch(t).then((s) => s.json());
615
- return await Je({
616
- gatewayUrls: e,
617
- uri: Xt(r)
618
- });
619
- } catch {
620
- throw new We({ uri: t });
621
- }
622
- }
623
- async function Je({ gatewayUrls: e, uri: t }) {
624
- const { uri: r, isOnChain: n } = Qt({ uri: t, gatewayUrls: e });
625
- if (n || await ss(r))
626
- return r;
627
- throw new We({ uri: t });
628
- }
629
- function os(e) {
630
- let t = e;
631
- t.startsWith("did:nft:") && (t = t.replace("did:nft:", "").replace(/_/g, "/"));
632
- const [r, n, s] = t.split("/"), [a, o] = r.split(":"), [c, u] = n.split(":");
633
- if (!a || a.toLowerCase() !== "eip155")
634
- throw new ee({ reason: "Only EIP-155 supported" });
635
- if (!o)
636
- throw new ee({ reason: "Chain ID not found" });
637
- if (!u)
638
- throw new ee({
639
- reason: "Contract address not found"
640
- });
641
- if (!s)
642
- throw new ee({ reason: "Token ID not found" });
643
- if (!c)
644
- throw new ee({ reason: "ERC namespace not found" });
645
- return {
646
- chainID: Number.parseInt(o),
647
- namespace: c.toLowerCase(),
648
- contractAddress: u,
649
- tokenID: s
650
- };
651
- }
652
- async function is(e, { nft: t }) {
653
- if (t.namespace === "erc721")
654
- return H(e, {
655
- address: t.contractAddress,
656
- abi: [
657
- {
658
- name: "tokenURI",
659
- type: "function",
660
- stateMutability: "view",
661
- inputs: [{ name: "tokenId", type: "uint256" }],
662
- outputs: [{ name: "", type: "string" }]
663
- }
664
- ],
665
- functionName: "tokenURI",
666
- args: [BigInt(t.tokenID)]
667
- });
668
- if (t.namespace === "erc1155")
669
- return H(e, {
670
- address: t.contractAddress,
671
- abi: [
672
- {
673
- name: "uri",
674
- type: "function",
675
- stateMutability: "view",
676
- inputs: [{ name: "_id", type: "uint256" }],
677
- outputs: [{ name: "", type: "string" }]
678
- }
679
- ],
680
- functionName: "uri",
681
- args: [BigInt(t.tokenID)]
682
- });
683
- throw new Yn({ namespace: t.namespace });
684
- }
685
- async function cs(e, { gatewayUrls: t, record: r }) {
686
- return /eip155:/i.test(r) ? us(e, { gatewayUrls: t, record: r }) : Je({ uri: r, gatewayUrls: t });
687
- }
688
- async function us(e, { gatewayUrls: t, record: r }) {
689
- const n = os(r), s = await is(e, { nft: n }), { uri: a, isOnChain: o, isEncoded: c } = Qt({ uri: s, gatewayUrls: t });
690
- if (o && (a.includes("data:application/json;base64,") || a.startsWith("{"))) {
691
- const i = c ? (
692
- // if it is encoded, decode it
693
- atob(a.replace("data:application/json;base64,", ""))
694
- ) : (
695
- // if it isn't encoded assume it is a JSON string, but it could be anything (it will error if it is)
696
- a
697
- ), d = JSON.parse(i);
698
- return Je({ uri: Xt(d), gatewayUrls: t });
699
- }
700
- let u = n.tokenID;
701
- return n.namespace === "erc1155" && (u = u.replace("0x", "").padStart(64, "0")), as({
702
- gatewayUrls: t,
703
- uri: a.replace(/(?:0x)?{id}/, u)
704
- });
705
- }
706
- async function Yt(e, { blockNumber: t, blockTag: r, name: n, key: s, gatewayUrls: a, strict: o, universalResolverAddress: c }) {
707
- let u = c;
708
- if (!u) {
709
- if (!e.chain)
710
- throw new Error("client chain not configured. universalResolverAddress is required.");
711
- u = ae({
712
- blockNumber: t,
713
- chain: e.chain,
714
- contract: "ensUniversalResolver"
715
- });
716
- }
717
- try {
718
- const i = {
719
- address: u,
720
- abi: kt,
721
- functionName: "resolve",
722
- args: [
723
- W(be(n)),
724
- X({
725
- abi: vt,
726
- functionName: "text",
727
- args: [de(n), s]
728
- })
729
- ],
730
- blockNumber: t,
731
- blockTag: r
732
- }, d = T(e, H, "readContract"), f = a ? await d({
733
- ...i,
734
- args: [...i.args, a]
735
- }) : await d(i);
736
- if (f[0] === "0x")
737
- return null;
738
- const l = he({
739
- abi: vt,
740
- functionName: "text",
741
- data: f[0]
742
- });
743
- return l === "" ? null : l;
744
- } catch (i) {
745
- if (o)
746
- throw i;
747
- if (Ve(i, "resolve"))
748
- return null;
749
- throw i;
750
- }
751
- }
752
- async function fs(e, { blockNumber: t, blockTag: r, assetGatewayUrls: n, name: s, gatewayUrls: a, strict: o, universalResolverAddress: c }) {
753
- const u = await T(e, Yt, "getEnsText")({
754
- blockNumber: t,
755
- blockTag: r,
756
- key: "avatar",
757
- name: s,
758
- universalResolverAddress: c,
759
- gatewayUrls: a,
760
- strict: o
761
- });
762
- if (!u)
763
- return null;
764
- try {
765
- return await cs(e, {
766
- record: u,
767
- gatewayUrls: n
768
- });
769
- } catch {
770
- return null;
771
- }
772
- }
773
- async function ds(e, { address: t, blockNumber: r, blockTag: n, gatewayUrls: s, strict: a, universalResolverAddress: o }) {
774
- let c = o;
775
- if (!c) {
776
- if (!e.chain)
777
- throw new Error("client chain not configured. universalResolverAddress is required.");
778
- c = ae({
779
- blockNumber: r,
780
- chain: e.chain,
781
- contract: "ensUniversalResolver"
782
- });
783
- }
784
- const u = `${t.toLowerCase().substring(2)}.addr.reverse`;
785
- try {
786
- const i = {
787
- address: c,
788
- abi: Lr,
789
- functionName: "reverse",
790
- args: [W(be(u))],
791
- blockNumber: r,
792
- blockTag: n
793
- }, d = T(e, H, "readContract"), [f, l] = s ? await d({
794
- ...i,
795
- args: [...i.args, s]
796
- }) : await d(i);
797
- return t.toLowerCase() !== l.toLowerCase() ? null : f;
798
- } catch (i) {
799
- if (a)
800
- throw i;
801
- if (Ve(i, "reverse"))
802
- return null;
803
- throw i;
804
- }
805
- }
806
- async function ls(e, { blockNumber: t, blockTag: r, name: n, universalResolverAddress: s }) {
807
- let a = s;
808
- if (!a) {
809
- if (!e.chain)
810
- throw new Error("client chain not configured. universalResolverAddress is required.");
811
- a = ae({
812
- blockNumber: t,
813
- chain: e.chain,
814
- contract: "ensUniversalResolver"
815
- });
816
- }
817
- const [o] = await T(e, H, "readContract")({
818
- address: a,
819
- abi: [
820
- {
821
- inputs: [{ type: "bytes" }],
822
- name: "findResolver",
823
- outputs: [{ type: "address" }, { type: "bytes32" }],
824
- stateMutability: "view",
825
- type: "function"
826
- }
827
- ],
828
- functionName: "findResolver",
829
- args: [W(be(n))],
830
- blockNumber: t,
831
- blockTag: r
832
- });
833
- return o;
834
- }
835
- async function er(e, t) {
836
- var v, h, b;
837
- const { account: r = e.account, blockNumber: n, blockTag: s = "latest", blobs: a, data: o, gas: c, gasPrice: u, maxFeePerBlobGas: i, maxFeePerGas: d, maxPriorityFeePerGas: f, to: l, value: p, ...m } = t, g = r ? V(r) : void 0;
838
- try {
839
- qe(t);
840
- const x = (n ? B(n) : void 0) || s, P = (b = (h = (v = e.chain) == null ? void 0 : v.formatters) == null ? void 0 : h.transactionRequest) == null ? void 0 : b.format, E = (P || Oe)({
841
- // Pick out extra data that might exist on the chain's transaction request type.
842
- ...Hr(m, { format: P }),
843
- from: g == null ? void 0 : g.address,
844
- blobs: a,
845
- data: o,
846
- gas: c,
847
- gasPrice: u,
848
- maxFeePerBlobGas: i,
849
- maxFeePerGas: d,
850
- maxPriorityFeePerGas: f,
851
- to: l,
852
- value: p
853
- }), C = await e.request({
854
- method: "eth_createAccessList",
855
- params: [E, x]
856
- });
857
- return {
858
- accessList: C.accessList,
859
- gasUsed: BigInt(C.gasUsed)
860
- };
861
- } catch (y) {
862
- throw Ur(y, {
863
- ...t,
864
- account: g,
865
- chain: e.chain
866
- });
867
- }
868
- }
869
- async function ps(e) {
870
- const t = _e(e, {
871
- method: "eth_newBlockFilter"
872
- }), r = await e.request({
873
- method: "eth_newBlockFilter"
874
- });
875
- return { id: r, request: t(r), type: "block" };
876
- }
877
- async function tr(e, { address: t, args: r, event: n, events: s, fromBlock: a, strict: o, toBlock: c } = {}) {
878
- const u = s ?? (n ? [n] : void 0), i = _e(e, {
879
- method: "eth_newFilter"
880
- });
881
- let d = [];
882
- u && (d = [u.flatMap((p) => St({
883
- abi: [p],
884
- eventName: p.name,
885
- args: r
886
- }))], n && (d = d[0]));
887
- const f = await e.request({
888
- method: "eth_newFilter",
889
- params: [
890
- {
891
- address: t,
892
- fromBlock: typeof a == "bigint" ? B(a) : a,
893
- toBlock: typeof c == "bigint" ? B(c) : c,
894
- ...d.length ? { topics: d } : {}
895
- }
896
- ]
897
- });
898
- return {
899
- abi: u,
900
- args: r,
901
- eventName: n ? n.name : void 0,
902
- fromBlock: a,
903
- id: f,
904
- request: i(f),
905
- strict: !!o,
906
- toBlock: c,
907
- type: "event"
908
- };
909
- }
910
- async function rr(e) {
911
- const t = _e(e, {
912
- method: "eth_newPendingTransactionFilter"
913
- }), r = await e.request({
914
- method: "eth_newPendingTransactionFilter"
915
- });
916
- return { id: r, request: t(r), type: "transaction" };
917
- }
918
- async function hs(e) {
919
- const t = await e.request({
920
- method: "eth_blobBaseFee"
921
- });
922
- return BigInt(t);
923
- }
924
- async function ms(e, { blockHash: t, blockNumber: r, blockTag: n = "latest" } = {}) {
925
- const s = r !== void 0 ? B(r) : void 0;
926
- let a;
927
- return t ? a = await e.request({
928
- method: "eth_getBlockTransactionCountByHash",
929
- params: [t]
930
- }, { dedupe: !0 }) : a = await e.request({
931
- method: "eth_getBlockTransactionCountByNumber",
932
- params: [s || n]
933
- }, { dedupe: !!s }), Ht(a);
934
- }
935
- async function It(e, { address: t, blockNumber: r, blockTag: n = "latest" }) {
936
- const s = r !== void 0 ? B(r) : void 0, a = await e.request({
937
- method: "eth_getCode",
938
- params: [t, s || n]
939
- }, { dedupe: !!s });
940
- if (a !== "0x")
941
- return a;
942
- }
943
- function gs(e) {
944
- var t;
945
- return {
946
- baseFeePerGas: e.baseFeePerGas.map((r) => BigInt(r)),
947
- gasUsedRatio: e.gasUsedRatio,
948
- oldestBlock: BigInt(e.oldestBlock),
949
- reward: (t = e.reward) == null ? void 0 : t.map((r) => r.map((n) => BigInt(n)))
950
- };
951
- }
952
- async function bs(e, { blockCount: t, blockNumber: r, blockTag: n = "latest", rewardPercentiles: s }) {
953
- const a = r ? B(r) : void 0, o = await e.request({
954
- method: "eth_feeHistory",
955
- params: [
956
- B(t),
957
- a || n,
958
- s
959
- ]
960
- }, { dedupe: !!a });
961
- return gs(o);
962
- }
963
- async function ys(e, { filter: t }) {
964
- const r = t.strict ?? !1, s = (await t.request({
965
- method: "eth_getFilterLogs",
966
- params: [t.id]
967
- })).map((a) => pe(a));
968
- return t.abi ? Gr({
969
- abi: t.abi,
970
- logs: s,
971
- strict: r
972
- }) : s;
973
- }
974
- class ws extends F {
975
- constructor({ domain: t }) {
976
- super(`Invalid domain "${D(t)}".`, {
977
- metaMessages: ["Must be a valid EIP-712 domain."]
978
- });
979
- }
980
- }
981
- class vs extends F {
982
- constructor({ primaryType: t, types: r }) {
983
- super(`Invalid primary type \`${t}\` must be one of \`${JSON.stringify(Object.keys(r))}\`.`, {
984
- docsPath: "/api/glossary/Errors#typeddatainvalidprimarytypeerror",
985
- metaMessages: ["Check that the primary type is a key in `types`."]
986
- });
987
- }
988
- }
989
- class xs extends F {
990
- constructor({ type: t }) {
991
- super(`Struct type "${t}" is invalid.`, {
992
- metaMessages: ["Struct type must not be a Solidity type."],
993
- name: "InvalidStructTypeError"
994
- });
995
- }
996
- }
997
- function Es(e) {
998
- const { domain: t = {}, message: r, primaryType: n } = e, s = {
999
- EIP712Domain: cr({ domain: t }),
1000
- ...e.types
1001
- };
1002
- ir({
1003
- domain: t,
1004
- message: r,
1005
- primaryType: n,
1006
- types: s
1007
- });
1008
- const a = ["0x1901"];
1009
- return t && a.push(As({
1010
- domain: t,
1011
- types: s
1012
- })), n !== "EIP712Domain" && a.push(nr({
1013
- data: r,
1014
- primaryType: n,
1015
- types: s
1016
- })), O(Ge(a));
1017
- }
1018
- function As({ domain: e, types: t }) {
1019
- return nr({
1020
- data: e,
1021
- primaryType: "EIP712Domain",
1022
- types: t
1023
- });
1024
- }
1025
- function nr({ data: e, primaryType: t, types: r }) {
1026
- const n = sr({
1027
- data: e,
1028
- primaryType: t,
1029
- types: r
1030
- });
1031
- return O(n);
1032
- }
1033
- function sr({ data: e, primaryType: t, types: r }) {
1034
- const n = [{ type: "bytes32" }], s = [Ts({ primaryType: t, types: r })];
1035
- for (const a of r[t]) {
1036
- const [o, c] = or({
1037
- types: r,
1038
- name: a.name,
1039
- type: a.type,
1040
- value: e[a.name]
1041
- });
1042
- n.push(o), s.push(c);
1043
- }
1044
- return Me(n, s);
1045
- }
1046
- function Ts({ primaryType: e, types: t }) {
1047
- const r = W(Is({ primaryType: e, types: t }));
1048
- return O(r);
1049
- }
1050
- function Is({ primaryType: e, types: t }) {
1051
- let r = "";
1052
- const n = ar({ primaryType: e, types: t });
1053
- n.delete(e);
1054
- const s = [e, ...Array.from(n).sort()];
1055
- for (const a of s)
1056
- r += `${a}(${t[a].map(({ name: o, type: c }) => `${c} ${o}`).join(",")})`;
1057
- return r;
1058
- }
1059
- function ar({ primaryType: e, types: t }, r = /* @__PURE__ */ new Set()) {
1060
- const n = e.match(/^\w*/u), s = n == null ? void 0 : n[0];
1061
- if (r.has(s) || t[s] === void 0)
1062
- return r;
1063
- r.add(s);
1064
- for (const a of t[s])
1065
- ar({ primaryType: a.type, types: t }, r);
1066
- return r;
1067
- }
1068
- function or({ types: e, name: t, type: r, value: n }) {
1069
- if (e[r] !== void 0)
1070
- return [
1071
- { type: "bytes32" },
1072
- O(sr({ data: n, primaryType: r, types: e }))
1073
- ];
1074
- if (r === "bytes")
1075
- return n = `0x${(n.length % 2 ? "0" : "") + n.slice(2)}`, [{ type: "bytes32" }, O(n)];
1076
- if (r === "string")
1077
- return [{ type: "bytes32" }, O(W(n))];
1078
- if (r.lastIndexOf("]") === r.length - 1) {
1079
- const s = r.slice(0, r.lastIndexOf("[")), a = n.map((o) => or({
1080
- name: t,
1081
- type: s,
1082
- types: e,
1083
- value: o
1084
- }));
1085
- return [
1086
- { type: "bytes32" },
1087
- O(Me(a.map(([o]) => o), a.map(([, o]) => o)))
1088
- ];
1089
- }
1090
- return [{ type: r }, n];
1091
- }
1092
- function Ps(e) {
1093
- const { domain: t, message: r, primaryType: n, types: s } = e, a = (u, i) => {
1094
- const d = { ...i };
1095
- for (const f of u) {
1096
- const { name: l, type: p } = f;
1097
- p === "address" && (d[l] = d[l].toLowerCase());
1098
- }
1099
- return d;
1100
- }, o = s.EIP712Domain ? t ? a(s.EIP712Domain, t) : {} : {}, c = (() => {
1101
- if (n !== "EIP712Domain")
1102
- return a(s[n], r);
1103
- })();
1104
- return D({ domain: o, message: c, primaryType: n, types: s });
1105
- }
1106
- function ir(e) {
1107
- const { domain: t, message: r, primaryType: n, types: s } = e, a = (o, c) => {
1108
- for (const u of o) {
1109
- const { name: i, type: d } = u, f = c[i], l = d.match(Vr);
1110
- if (l && (typeof f == "number" || typeof f == "bigint")) {
1111
- const [g, v, h] = l;
1112
- B(f, {
1113
- signed: v === "int",
1114
- size: Number.parseInt(h) / 8
1115
- });
1116
- }
1117
- if (d === "address" && typeof f == "string" && !Tn(f))
1118
- throw new In({ address: f });
1119
- const p = d.match(Wr);
1120
- if (p) {
1121
- const [g, v] = p;
1122
- if (v && Re(f) !== Number.parseInt(v))
1123
- throw new Jr({
1124
- expectedSize: Number.parseInt(v),
1125
- givenSize: Re(f)
1126
- });
1127
- }
1128
- const m = s[d];
1129
- m && (Rs(d), a(m, f));
1130
- }
1131
- };
1132
- if (s.EIP712Domain && t) {
1133
- if (typeof t != "object")
1134
- throw new ws({ domain: t });
1135
- a(s.EIP712Domain, t);
1136
- }
1137
- if (n !== "EIP712Domain")
1138
- if (s[n])
1139
- a(s[n], r);
1140
- else
1141
- throw new vs({ primaryType: n, types: s });
1142
- }
1143
- function cr({ domain: e }) {
1144
- return [
1145
- typeof (e == null ? void 0 : e.name) == "string" && { name: "name", type: "string" },
1146
- (e == null ? void 0 : e.version) && { name: "version", type: "string" },
1147
- (typeof (e == null ? void 0 : e.chainId) == "number" || typeof (e == null ? void 0 : e.chainId) == "bigint") && {
1148
- name: "chainId",
1149
- type: "uint256"
1150
- },
1151
- (e == null ? void 0 : e.verifyingContract) && {
1152
- name: "verifyingContract",
1153
- type: "address"
1154
- },
1155
- (e == null ? void 0 : e.salt) && { name: "salt", type: "bytes32" }
1156
- ].filter(Boolean);
1157
- }
1158
- function Rs(e) {
1159
- if (e === "address" || e === "bool" || e === "string" || e.startsWith("bytes") || e.startsWith("uint") || e.startsWith("int"))
1160
- throw new xs({ type: e });
1161
- }
1162
- const Cs = `Ethereum Signed Message:
1163
- `;
1164
- function $s(e) {
1165
- const t = typeof e == "string" ? le(e) : typeof e.raw == "string" ? e.raw : ne(e.raw), r = le(`${Cs}${Re(t)}`);
1166
- return Ge([r, t]);
1167
- }
1168
- function ur(e, t) {
1169
- return O($s(e), t);
1170
- }
1171
- const fr = "0x6492649264926492649264926492649264926492649264926492649264926492";
1172
- function Ns(e) {
1173
- return Pn(e, -32) === fr;
1174
- }
1175
- function ks(e) {
1176
- const { address: t, data: r, signature: n, to: s = "hex" } = e, a = Rn([
1177
- Me([{ type: "address" }, { type: "bytes" }, { type: "bytes" }], [t, r, n]),
1178
- fr
1179
- ]);
1180
- return s === "hex" ? a : Ut(a);
1181
- }
1182
- function Ss(e) {
1183
- return e.map((t) => ({
1184
- ...t,
1185
- value: BigInt(t.value)
1186
- }));
1187
- }
1188
- function Bs(e) {
1189
- return {
1190
- ...e,
1191
- balance: e.balance ? BigInt(e.balance) : void 0,
1192
- nonce: e.nonce ? Ht(e.nonce) : void 0,
1193
- storageProof: e.storageProof ? Ss(e.storageProof) : void 0
1194
- };
1195
- }
1196
- async function zs(e, { address: t, blockNumber: r, blockTag: n, storageKeys: s }) {
1197
- const a = n ?? "latest", o = r !== void 0 ? B(r) : void 0, c = await e.request({
1198
- method: "eth_getProof",
1199
- params: [t, s, o || a]
1200
- });
1201
- return Bs(c);
1202
- }
1203
- async function Fs(e, { address: t, blockNumber: r, blockTag: n = "latest", slot: s }) {
1204
- const a = r !== void 0 ? B(r) : void 0;
1205
- return await e.request({
1206
- method: "eth_getStorageAt",
1207
- params: [t, s, a || n]
1208
- });
1209
- }
1210
- async function Ze(e, { blockHash: t, blockNumber: r, blockTag: n, hash: s, index: a }) {
1211
- var d, f, l;
1212
- const o = n || "latest", c = r !== void 0 ? B(r) : void 0;
1213
- let u = null;
1214
- if (s ? u = await e.request({
1215
- method: "eth_getTransactionByHash",
1216
- params: [s]
1217
- }, { dedupe: !0 }) : t ? u = await e.request({
1218
- method: "eth_getTransactionByBlockHashAndIndex",
1219
- params: [t, B(a)]
1220
- }, { dedupe: !0 }) : u = await e.request({
1221
- method: "eth_getTransactionByBlockNumberAndIndex",
1222
- params: [c || o, B(a)]
1223
- }, { dedupe: !!c }), !u)
1224
- throw new Gt({
1225
- blockHash: t,
1226
- blockNumber: r,
1227
- blockTag: o,
1228
- hash: s,
1229
- index: a
1230
- });
1231
- return (((l = (f = (d = e.chain) == null ? void 0 : d.formatters) == null ? void 0 : f.transaction) == null ? void 0 : l.format) || Cn)(u);
1232
- }
1233
- async function Ds(e, { hash: t, transactionReceipt: r }) {
1234
- const [n, s] = await Promise.all([
1235
- T(e, me, "getBlockNumber")({}),
1236
- t ? T(e, Ze, "getTransaction")({ hash: t }) : void 0
1237
- ]), a = (r == null ? void 0 : r.blockNumber) || (s == null ? void 0 : s.blockNumber);
1238
- return a ? n - a + 1n : 0n;
1239
- }
1240
- async function Ne(e, { hash: t }) {
1241
- var s, a, o;
1242
- const r = await e.request({
1243
- method: "eth_getTransactionReceipt",
1244
- params: [t]
1245
- }, { dedupe: !0 });
1246
- if (!r)
1247
- throw new Vt({ hash: t });
1248
- return (((o = (a = (s = e.chain) == null ? void 0 : s.formatters) == null ? void 0 : a.transactionReceipt) == null ? void 0 : o.format) || $n)(r);
1249
- }
1250
- async function qs(e, t) {
1251
- var v;
1252
- const { allowFailure: r = !0, batchSize: n, blockNumber: s, blockTag: a, multicallAddress: o, stateOverride: c } = t, u = t.contracts, i = n ?? (typeof ((v = e.batch) == null ? void 0 : v.multicall) == "object" && e.batch.multicall.batchSize || 1024);
1253
- let d = o;
1254
- if (!d) {
1255
- if (!e.chain)
1256
- throw new Error("client chain not configured. multicallAddress is required.");
1257
- d = ae({
1258
- blockNumber: s,
1259
- chain: e.chain,
1260
- contract: "multicall3"
1261
- });
1262
- }
1263
- const f = [[]];
1264
- let l = 0, p = 0;
1265
- for (let h = 0; h < u.length; h++) {
1266
- const { abi: b, address: y, args: x, functionName: P } = u[h];
1267
- try {
1268
- const A = X({ abi: b, args: x, functionName: P });
1269
- p += (A.length - 2) / 2, // Check if batching is enabled.
1270
- i > 0 && // Check if the current size of the batch exceeds the size limit.
1271
- p > i && // Check if the current chunk is not already empty.
1272
- f[l].length > 0 && (l++, p = (A.length - 2) / 2, f[l] = []), f[l] = [
1273
- ...f[l],
1274
- {
1275
- allowFailure: !0,
1276
- callData: A,
1277
- target: y
1278
- }
1279
- ];
1280
- } catch (A) {
1281
- const E = Ie(A, {
1282
- abi: b,
1283
- address: y,
1284
- args: x,
1285
- docsPath: "/docs/contract/multicall",
1286
- functionName: P
1287
- });
1288
- if (!r)
1289
- throw E;
1290
- f[l] = [
1291
- ...f[l],
1292
- {
1293
- allowFailure: !0,
1294
- callData: "0x",
1295
- target: y
1296
- }
1297
- ];
1298
- }
1299
- }
1300
- const m = await Promise.allSettled(f.map((h) => T(e, H, "readContract")({
1301
- abi: Zr,
1302
- address: d,
1303
- args: [h],
1304
- blockNumber: s,
1305
- blockTag: a,
1306
- functionName: "aggregate3",
1307
- stateOverride: c
1308
- }))), g = [];
1309
- for (let h = 0; h < m.length; h++) {
1310
- const b = m[h];
1311
- if (b.status === "rejected") {
1312
- if (!r)
1313
- throw b.reason;
1314
- for (let x = 0; x < f[h].length; x++)
1315
- g.push({
1316
- status: "failure",
1317
- error: b.reason,
1318
- result: void 0
1319
- });
1320
- continue;
1321
- }
1322
- const y = b.value;
1323
- for (let x = 0; x < y.length; x++) {
1324
- const { returnData: P, success: A } = y[x], { callData: E } = f[h][x], { abi: C, address: R, functionName: N, args: I } = u[g.length];
1325
- try {
1326
- if (E === "0x")
1327
- throw new Bt();
1328
- if (!A)
1329
- throw new zt({ data: P });
1330
- const k = he({
1331
- abi: C,
1332
- args: I,
1333
- data: P,
1334
- functionName: N
1335
- });
1336
- g.push(r ? { result: k, status: "success" } : k);
1337
- } catch (k) {
1338
- const _ = Ie(k, {
1339
- abi: C,
1340
- address: R,
1341
- args: I,
1342
- docsPath: "/docs/contract/multicall",
1343
- functionName: N
1344
- });
1345
- if (!r)
1346
- throw _;
1347
- g.push({ error: _, result: void 0, status: "failure" });
1348
- }
1349
- }
1350
- }
1351
- if (g.length !== u.length)
1352
- throw new F("multicall results mismatch");
1353
- return g;
1354
- }
1355
- const Os = "0.1.1";
1356
- function _s() {
1357
- return Os;
1358
- }
1359
- class $ extends Error {
1360
- constructor(t, r = {}) {
1361
- const n = (() => {
1362
- var u;
1363
- if (r.cause instanceof $) {
1364
- if (r.cause.details)
1365
- return r.cause.details;
1366
- if (r.cause.shortMessage)
1367
- return r.cause.shortMessage;
1368
- }
1369
- return (u = r.cause) != null && u.message ? r.cause.message : r.details;
1370
- })(), s = r.cause instanceof $ && r.cause.docsPath || r.docsPath, o = `https://oxlib.sh${s ?? ""}`, c = [
1371
- t || "An error occurred.",
1372
- ...r.metaMessages ? ["", ...r.metaMessages] : [],
1373
- ...n || s ? [
1374
- "",
1375
- n ? `Details: ${n}` : void 0,
1376
- s ? `See: ${o}` : void 0
1377
- ] : []
1378
- ].filter((u) => typeof u == "string").join(`
1379
- `);
1380
- super(c, r.cause ? { cause: r.cause } : void 0), Object.defineProperty(this, "details", {
1381
- enumerable: !0,
1382
- configurable: !0,
1383
- writable: !0,
1384
- value: void 0
1385
- }), Object.defineProperty(this, "docs", {
1386
- enumerable: !0,
1387
- configurable: !0,
1388
- writable: !0,
1389
- value: void 0
1390
- }), Object.defineProperty(this, "docsPath", {
1391
- enumerable: !0,
1392
- configurable: !0,
1393
- writable: !0,
1394
- value: void 0
1395
- }), Object.defineProperty(this, "shortMessage", {
1396
- enumerable: !0,
1397
- configurable: !0,
1398
- writable: !0,
1399
- value: void 0
1400
- }), Object.defineProperty(this, "cause", {
1401
- enumerable: !0,
1402
- configurable: !0,
1403
- writable: !0,
1404
- value: void 0
1405
- }), Object.defineProperty(this, "name", {
1406
- enumerable: !0,
1407
- configurable: !0,
1408
- writable: !0,
1409
- value: "BaseError"
1410
- }), Object.defineProperty(this, "version", {
1411
- enumerable: !0,
1412
- configurable: !0,
1413
- writable: !0,
1414
- value: `ox@${_s()}`
1415
- }), this.cause = r.cause, this.details = n, this.docs = o, this.docsPath = s, this.shortMessage = t;
1416
- }
1417
- walk(t) {
1418
- return dr(this, t);
1419
- }
1420
- }
1421
- function dr(e, t) {
1422
- return t != null && t(e) ? e : e && typeof e == "object" && "cause" in e && e.cause ? dr(e.cause, t) : t ? null : e;
1423
- }
1424
- const Ms = "#__bigint";
1425
- function js(e, t, r) {
1426
- return JSON.stringify(e, (n, s) => typeof s == "bigint" ? s.toString() + Ms : s, r);
1427
- }
1428
- function Ls(e, t) {
1429
- if (Rt(e) > t)
1430
- throw new Xs({
1431
- givenSize: Rt(e),
1432
- maxSize: t
1433
- });
1434
- }
1435
- const L = {
1436
- zero: 48,
1437
- nine: 57,
1438
- A: 65,
1439
- F: 70,
1440
- a: 97,
1441
- f: 102
1442
- };
1443
- function Pt(e) {
1444
- if (e >= L.zero && e <= L.nine)
1445
- return e - L.zero;
1446
- if (e >= L.A && e <= L.F)
1447
- return e - (L.A - 10);
1448
- if (e >= L.a && e <= L.f)
1449
- return e - (L.a - 10);
1450
- }
1451
- function Hs(e, t = {}) {
1452
- const { dir: r, size: n = 32 } = t;
1453
- if (n === 0)
1454
- return e;
1455
- if (e.length > n)
1456
- throw new Ys({
1457
- size: e.length,
1458
- targetSize: n,
1459
- type: "Bytes"
1460
- });
1461
- const s = new Uint8Array(n);
1462
- for (let a = 0; a < n; a++) {
1463
- const o = r === "right";
1464
- s[o ? a : n - a - 1] = e[o ? a : e.length - a - 1];
1465
- }
1466
- return s;
1467
- }
1468
- function Ke(e, t) {
1469
- if (q(e) > t)
1470
- throw new sa({
1471
- givenSize: q(e),
1472
- maxSize: t
1473
- });
1474
- }
1475
- function Us(e, t) {
1476
- if (typeof t == "number" && t > 0 && t > q(e) - 1)
1477
- throw new gr({
1478
- offset: t,
1479
- position: "start",
1480
- size: q(e)
1481
- });
1482
- }
1483
- function Gs(e, t, r) {
1484
- if (typeof t == "number" && typeof r == "number" && q(e) !== r - t)
1485
- throw new gr({
1486
- offset: r,
1487
- position: "end",
1488
- size: q(e)
1489
- });
1490
- }
1491
- function lr(e, t = {}) {
1492
- const { dir: r, size: n = 32 } = t;
1493
- if (n === 0)
1494
- return e;
1495
- const s = e.replace("0x", "");
1496
- if (s.length > n * 2)
1497
- throw new aa({
1498
- size: Math.ceil(s.length / 2),
1499
- targetSize: n,
1500
- type: "Hex"
1501
- });
1502
- return `0x${s[r === "right" ? "padEnd" : "padStart"](n * 2, "0")}`;
1503
- }
1504
- const Vs = /* @__PURE__ */ new TextEncoder();
1505
- function Ws(e) {
1506
- return e instanceof Uint8Array ? e : typeof e == "string" ? Zs(e) : Js(e);
1507
- }
1508
- function Js(e) {
1509
- return e instanceof Uint8Array ? e : new Uint8Array(e);
1510
- }
1511
- function Zs(e, t = {}) {
1512
- const { size: r } = t;
1513
- let n = e;
1514
- r && (Ke(e, r), n = G(e, r));
1515
- let s = n.slice(2);
1516
- s.length % 2 && (s = `0${s}`);
1517
- const a = s.length / 2, o = new Uint8Array(a);
1518
- for (let c = 0, u = 0; c < a; c++) {
1519
- const i = Pt(s.charCodeAt(u++)), d = Pt(s.charCodeAt(u++));
1520
- if (i === void 0 || d === void 0)
1521
- throw new $(`Invalid byte sequence ("${s[u - 2]}${s[u - 1]}" in "${s}").`);
1522
- o[c] = i * 16 + d;
1523
- }
1524
- return o;
1525
- }
1526
- function Ks(e, t = {}) {
1527
- const { size: r } = t, n = Vs.encode(e);
1528
- return typeof r == "number" ? (Ls(n, r), Qs(n, r)) : n;
1529
- }
1530
- function Qs(e, t) {
1531
- return Hs(e, { dir: "right", size: t });
1532
- }
1533
- function Rt(e) {
1534
- return e.length;
1535
- }
1536
- let Xs = class extends $ {
1537
- constructor({ givenSize: t, maxSize: r }) {
1538
- super(`Size cannot exceed \`${r}\` bytes. Given size: \`${t}\` bytes.`), Object.defineProperty(this, "name", {
1539
- enumerable: !0,
1540
- configurable: !0,
1541
- writable: !0,
1542
- value: "Bytes.SizeOverflowError"
1543
- });
1544
- }
1545
- }, Ys = class extends $ {
1546
- constructor({ size: t, targetSize: r, type: n }) {
1547
- super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${r}\`).`), Object.defineProperty(this, "name", {
1548
- enumerable: !0,
1549
- configurable: !0,
1550
- writable: !0,
1551
- value: "Bytes.SizeExceedsPaddingSizeError"
1552
- });
1553
- }
1554
- };
1555
- const ea = /* @__PURE__ */ new TextEncoder(), ta = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
1556
- function ra(e, t = {}) {
1557
- const { strict: r = !1 } = t;
1558
- if (!e)
1559
- throw new Ct(e);
1560
- if (typeof e != "string")
1561
- throw new Ct(e);
1562
- if (r && !/^0x[0-9a-fA-F]*$/.test(e))
1563
- throw new $t(e);
1564
- if (!e.startsWith("0x"))
1565
- throw new $t(e);
1566
- }
1567
- function j(...e) {
1568
- return `0x${e.reduce((t, r) => t + r.replace("0x", ""), "")}`;
1569
- }
1570
- function pr(e, t = {}) {
1571
- const r = `0x${Number(e)}`;
1572
- return typeof t.size == "number" ? (Ke(r, t.size), U(r, t.size)) : r;
1573
- }
1574
- function hr(e, t = {}) {
1575
- let r = "";
1576
- for (let s = 0; s < e.length; s++)
1577
- r += ta[e[s]];
1578
- const n = `0x${r}`;
1579
- return typeof t.size == "number" ? (Ke(n, t.size), G(n, t.size)) : n;
1580
- }
1581
- function z(e, t = {}) {
1582
- const { signed: r, size: n } = t, s = BigInt(e);
1583
- let a;
1584
- n ? r ? a = (1n << BigInt(n) * 8n - 1n) - 1n : a = 2n ** (BigInt(n) * 8n) - 1n : typeof e == "number" && (a = BigInt(Number.MAX_SAFE_INTEGER));
1585
- const o = typeof a == "bigint" && r ? -a - 1n : 0;
1586
- if (a && s > a || s < o) {
1587
- const i = typeof e == "bigint" ? "n" : "";
1588
- throw new mr({
1589
- max: a ? `${a}${i}` : void 0,
1590
- min: `${o}${i}`,
1591
- signed: r,
1592
- size: n,
1593
- value: `${e}${i}`
1594
- });
1595
- }
1596
- const u = `0x${(r && s < 0 ? (1n << BigInt(n * 8)) + BigInt(s) : s).toString(16)}`;
1597
- return n ? U(u, n) : u;
1598
- }
1599
- function Qe(e, t = {}) {
1600
- return hr(ea.encode(e), t);
1601
- }
1602
- function U(e, t) {
1603
- return lr(e, { dir: "left", size: t });
1604
- }
1605
- function G(e, t) {
1606
- return lr(e, { dir: "right", size: t });
1607
- }
1608
- function Xe(e, t, r, n = {}) {
1609
- const { strict: s } = n;
1610
- Us(e, t);
1611
- const a = `0x${e.replace("0x", "").slice((t ?? 0) * 2, (r ?? e.length) * 2)}`;
1612
- return s && Gs(a, t, r), a;
1613
- }
1614
- function q(e) {
1615
- return Math.ceil((e.length - 2) / 2);
1616
- }
1617
- function na(e, t = {}) {
1618
- const { strict: r = !1 } = t;
1619
- try {
1620
- return ra(e, { strict: r }), !0;
1621
- } catch {
1622
- return !1;
1623
- }
1624
- }
1625
- class mr extends $ {
1626
- constructor({ max: t, min: r, signed: n, size: s, value: a }) {
1627
- super(`Number \`${a}\` is not in safe${s ? ` ${s * 8}-bit` : ""}${n ? " signed" : " unsigned"} integer range ${t ? `(\`${r}\` to \`${t}\`)` : `(above \`${r}\`)`}`), Object.defineProperty(this, "name", {
1628
- enumerable: !0,
1629
- configurable: !0,
1630
- writable: !0,
1631
- value: "Hex.IntegerOutOfRangeError"
1632
- });
1633
- }
1634
- }
1635
- class Ct extends $ {
1636
- constructor(t) {
1637
- super(`Value \`${typeof t == "object" ? js(t) : t}\` of type \`${typeof t}\` is an invalid hex type.`, {
1638
- metaMessages: ['Hex types must be represented as `"0x${string}"`.']
1639
- }), Object.defineProperty(this, "name", {
1640
- enumerable: !0,
1641
- configurable: !0,
1642
- writable: !0,
1643
- value: "Hex.InvalidHexTypeError"
1644
- });
1645
- }
1646
- }
1647
- class $t extends $ {
1648
- constructor(t) {
1649
- super(`Value \`${t}\` is an invalid hex value.`, {
1650
- metaMessages: [
1651
- 'Hex values must start with `"0x"` and contain only hexadecimal characters (0-9, a-f, A-F).'
1652
- ]
1653
- }), Object.defineProperty(this, "name", {
1654
- enumerable: !0,
1655
- configurable: !0,
1656
- writable: !0,
1657
- value: "Hex.InvalidHexValueError"
1658
- });
1659
- }
1660
- }
1661
- class sa extends $ {
1662
- constructor({ givenSize: t, maxSize: r }) {
1663
- super(`Size cannot exceed \`${r}\` bytes. Given size: \`${t}\` bytes.`), Object.defineProperty(this, "name", {
1664
- enumerable: !0,
1665
- configurable: !0,
1666
- writable: !0,
1667
- value: "Hex.SizeOverflowError"
1668
- });
1669
- }
1670
- }
1671
- class gr extends $ {
1672
- constructor({ offset: t, position: r, size: n }) {
1673
- super(`Slice ${r === "start" ? "starting" : "ending"} at offset \`${t}\` is out-of-bounds (size: \`${n}\`).`), Object.defineProperty(this, "name", {
1674
- enumerable: !0,
1675
- configurable: !0,
1676
- writable: !0,
1677
- value: "Hex.SliceOffsetOutOfBoundsError"
1678
- });
1679
- }
1680
- }
1681
- class aa extends $ {
1682
- constructor({ size: t, targetSize: r, type: n }) {
1683
- super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${r}\`).`), Object.defineProperty(this, "name", {
1684
- enumerable: !0,
1685
- configurable: !0,
1686
- writable: !0,
1687
- value: "Hex.SizeExceedsPaddingSizeError"
1688
- });
1689
- }
1690
- }
1691
- function oa(e) {
1692
- return {
1693
- address: e.address,
1694
- amount: z(e.amount),
1695
- index: z(e.index),
1696
- validatorIndex: z(e.validatorIndex)
1697
- };
1698
- }
1699
- function ia(e) {
1700
- return {
1701
- ...typeof e.baseFeePerGas == "bigint" && {
1702
- baseFeePerGas: z(e.baseFeePerGas)
1703
- },
1704
- ...typeof e.blobBaseFee == "bigint" && {
1705
- blobBaseFee: z(e.blobBaseFee)
1706
- },
1707
- ...typeof e.feeRecipient == "string" && {
1708
- feeRecipient: e.feeRecipient
1709
- },
1710
- ...typeof e.gasLimit == "bigint" && {
1711
- gasLimit: z(e.gasLimit)
1712
- },
1713
- ...typeof e.number == "bigint" && {
1714
- number: z(e.number)
1715
- },
1716
- ...typeof e.prevRandao == "bigint" && {
1717
- prevRandao: z(e.prevRandao)
1718
- },
1719
- ...typeof e.time == "bigint" && {
1720
- time: z(e.time)
1721
- },
1722
- ...e.withdrawals && {
1723
- withdrawals: e.withdrawals.map(oa)
1724
- }
1725
- };
1726
- }
1727
- async function ke(e, t) {
1728
- const { blockNumber: r, blockTag: n = "latest", blocks: s, returnFullTransactions: a, traceTransfers: o, validation: c } = t;
1729
- try {
1730
- const u = [];
1731
- for (const l of s) {
1732
- const p = l.blockOverrides ? ia(l.blockOverrides) : void 0, m = l.calls.map((v) => {
1733
- const h = v, b = h.account ? V(h.account) : void 0, y = {
1734
- ...h,
1735
- data: h.abi ? X(h) : h.data,
1736
- from: h.from ?? (b == null ? void 0 : b.address)
1737
- };
1738
- return qe(y), Oe(y);
1739
- }), g = l.stateOverrides ? Kr(l.stateOverrides) : void 0;
1740
- u.push({
1741
- blockOverrides: p,
1742
- calls: m,
1743
- stateOverrides: g
1744
- });
1745
- }
1746
- const d = (r ? B(r) : void 0) || n;
1747
- return (await e.request({
1748
- method: "eth_simulateV1",
1749
- params: [
1750
- { blockStateCalls: u, returnFullTransactions: a, traceTransfers: o, validation: c },
1751
- d
1752
- ]
1753
- })).map((l, p) => ({
1754
- ...Nn(l),
1755
- calls: l.calls.map((m, g) => {
1756
- var N, I;
1757
- const { abi: v, args: h, functionName: b, to: y } = s[p].calls[g], x = ((N = m.error) == null ? void 0 : N.data) ?? m.returnData, P = BigInt(m.gasUsed), A = (I = m.logs) == null ? void 0 : I.map((k) => pe(k)), E = m.status === "0x1" ? "success" : "failure", C = v && E === "success" && x !== "0x" ? he({
1758
- abi: v,
1759
- data: x,
1760
- functionName: b
1761
- }) : null, R = (() => {
1762
- var _;
1763
- if (E === "success")
1764
- return;
1765
- let k;
1766
- if (((_ = m.error) == null ? void 0 : _.data) === "0x" ? k = new Bt() : m.error && (k = new zt(m.error)), !!k)
1767
- return Ie(k, {
1768
- abi: v ?? [],
1769
- address: y,
1770
- args: h,
1771
- functionName: b ?? "<unknown>"
1772
- });
1773
- })();
1774
- return {
1775
- data: x,
1776
- gasUsed: P,
1777
- logs: A,
1778
- status: E,
1779
- ...E === "success" ? {
1780
- result: C
1781
- } : {
1782
- error: R
1783
- }
1784
- };
1785
- })
1786
- }));
1787
- } catch (u) {
1788
- const i = u, d = Qr(i, {});
1789
- throw d instanceof kn ? i : d;
1790
- }
1791
- }
1792
- function br(e, t = {}) {
1793
- const { as: r = typeof e == "string" ? "Hex" : "Bytes" } = t, n = Sn(Ws(e));
1794
- return r === "Bytes" ? n : hr(n);
1795
- }
1796
- class ca extends Map {
1797
- constructor(t) {
1798
- super(), Object.defineProperty(this, "maxSize", {
1799
- enumerable: !0,
1800
- configurable: !0,
1801
- writable: !0,
1802
- value: void 0
1803
- }), this.maxSize = t;
1804
- }
1805
- get(t) {
1806
- const r = super.get(t);
1807
- return super.has(t) && r !== void 0 && (this.delete(t), super.set(t, r)), r;
1808
- }
1809
- set(t, r) {
1810
- if (super.set(t, r), this.maxSize && this.size > this.maxSize) {
1811
- const n = this.keys().next().value;
1812
- n && this.delete(n);
1813
- }
1814
- return this;
1815
- }
1816
- }
1817
- const ua = {
1818
- checksum: /* @__PURE__ */ new ca(8192)
1819
- }, xe = ua.checksum, fa = /^0x[a-fA-F0-9]{40}$/;
1820
- function ye(e, t = {}) {
1821
- const { strict: r = !0 } = t;
1822
- if (!fa.test(e))
1823
- throw new Nt({
1824
- address: e,
1825
- cause: new la()
1826
- });
1827
- if (r) {
1828
- if (e.toLowerCase() === e)
1829
- return;
1830
- if (da(e) !== e)
1831
- throw new Nt({
1832
- address: e,
1833
- cause: new pa()
1834
- });
1835
- }
1836
- }
1837
- function da(e) {
1838
- if (xe.has(e))
1839
- return xe.get(e);
1840
- ye(e, { strict: !1 });
1841
- const t = e.substring(2).toLowerCase(), r = br(Ks(t), { as: "Bytes" }), n = t.split("");
1842
- for (let a = 0; a < 40; a += 2)
1843
- r[a >> 1] >> 4 >= 8 && n[a] && (n[a] = n[a].toUpperCase()), (r[a >> 1] & 15) >= 8 && n[a + 1] && (n[a + 1] = n[a + 1].toUpperCase());
1844
- const s = `0x${n.join("")}`;
1845
- return xe.set(e, s), s;
1846
- }
1847
- function Se(e, t = {}) {
1848
- const { strict: r = !0 } = t ?? {};
1849
- try {
1850
- return ye(e, { strict: r }), !0;
1851
- } catch {
1852
- return !1;
1853
- }
1854
- }
1855
- class Nt extends $ {
1856
- constructor({ address: t, cause: r }) {
1857
- super(`Address "${t}" is invalid.`, {
1858
- cause: r
1859
- }), Object.defineProperty(this, "name", {
1860
- enumerable: !0,
1861
- configurable: !0,
1862
- writable: !0,
1863
- value: "Address.InvalidAddressError"
1864
- });
1865
- }
1866
- }
1867
- class la extends $ {
1868
- constructor() {
1869
- super("Address is not a 20 byte (40 hexadecimal character) value."), Object.defineProperty(this, "name", {
1870
- enumerable: !0,
1871
- configurable: !0,
1872
- writable: !0,
1873
- value: "Address.InvalidInputError"
1874
- });
1875
- }
1876
- }
1877
- class pa extends $ {
1878
- constructor() {
1879
- super("Address does not match its checksum counterpart."), Object.defineProperty(this, "name", {
1880
- enumerable: !0,
1881
- configurable: !0,
1882
- writable: !0,
1883
- value: "Address.InvalidChecksumError"
1884
- });
1885
- }
1886
- }
1887
- function Be(e) {
1888
- let t = !0, r = "", n = 0, s = "", a = !1;
1889
- for (let o = 0; o < e.length; o++) {
1890
- const c = e[o];
1891
- if (["(", ")", ","].includes(c) && (t = !0), c === "(" && n++, c === ")" && n--, !!t) {
1892
- if (n === 0) {
1893
- if (c === " " && ["event", "function", "error", ""].includes(s))
1894
- s = "";
1895
- else if (s += c, c === ")") {
1896
- a = !0;
1897
- break;
1898
- }
1899
- continue;
1900
- }
1901
- if (c === " ") {
1902
- e[o - 1] !== "," && r !== "," && r !== ",(" && (r = "", t = !1);
1903
- continue;
1904
- }
1905
- s += c, r += c;
1906
- }
1907
- }
1908
- if (!a)
1909
- throw new $("Unable to normalize signature.");
1910
- return s;
1911
- }
1912
- function ze(e, t) {
1913
- const r = typeof e, n = t.type;
1914
- switch (n) {
1915
- case "address":
1916
- return Se(e, { strict: !1 });
1917
- case "bool":
1918
- return r === "boolean";
1919
- case "function":
1920
- return r === "string";
1921
- case "string":
1922
- return r === "string";
1923
- default:
1924
- return n === "tuple" && "components" in t ? Object.values(t.components).every((s, a) => ze(Object.values(e)[a], s)) : /^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(n) ? r === "number" || r === "bigint" : /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(n) ? r === "string" || e instanceof Uint8Array : /[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(n) ? Array.isArray(e) && e.every((s) => ze(s, {
1925
- ...t,
1926
- // Pop off `[]` or `[M]` from end of type
1927
- type: n.replace(/(\[[0-9]{0,}\])$/, "")
1928
- })) : !1;
1929
- }
1930
- }
1931
- function yr(e, t, r) {
1932
- for (const n in e) {
1933
- const s = e[n], a = t[n];
1934
- if (s.type === "tuple" && a.type === "tuple" && "components" in s && "components" in a)
1935
- return yr(s.components, a.components, r[n]);
1936
- const o = [s.type, a.type];
1937
- if (o.includes("address") && o.includes("bytes20") ? !0 : o.includes("address") && o.includes("string") ? Se(r[n], {
1938
- strict: !1
1939
- }) : o.includes("address") && o.includes("bytes") ? Se(r[n], {
1940
- strict: !1
1941
- }) : !1)
1942
- return o;
1943
- }
1944
- }
1945
- function wr(e, t = {}) {
1946
- const { prepare: r = !0 } = t, n = Array.isArray(e) || typeof e == "string" ? Et(e) : e;
1947
- return {
1948
- ...n,
1949
- ...r ? { hash: K(n) } : {}
1950
- };
1951
- }
1952
- function ha(e, t, r) {
1953
- const { args: n = [], prepare: s = !0 } = r ?? {}, a = na(t, { strict: !1 }), o = e.filter((i) => a ? i.type === "function" || i.type === "error" ? vr(i) === Xe(t, 0, 4) : i.type === "event" ? K(i) === t : !1 : "name" in i && i.name === t);
1954
- if (o.length === 0)
1955
- throw new Fe({ name: t });
1956
- if (o.length === 1)
1957
- return {
1958
- ...o[0],
1959
- ...s ? { hash: K(o[0]) } : {}
1960
- };
1961
- let c;
1962
- for (const i of o) {
1963
- if (!("inputs" in i))
1964
- continue;
1965
- if (!n || n.length === 0) {
1966
- if (!i.inputs || i.inputs.length === 0)
1967
- return {
1968
- ...i,
1969
- ...s ? { hash: K(i) } : {}
1970
- };
1971
- continue;
1972
- }
1973
- if (!i.inputs || i.inputs.length === 0 || i.inputs.length !== n.length)
1974
- continue;
1975
- if (n.every((f, l) => {
1976
- const p = "inputs" in i && i.inputs[l];
1977
- return p ? ze(f, p) : !1;
1978
- })) {
1979
- if (c && "inputs" in c && c.inputs) {
1980
- const f = yr(i.inputs, c.inputs, n);
1981
- if (f)
1982
- throw new ga({
1983
- abiItem: i,
1984
- type: f[0]
1985
- }, {
1986
- abiItem: c,
1987
- type: f[1]
1988
- });
1989
- }
1990
- c = i;
1991
- }
1992
- }
1993
- const u = (() => {
1994
- if (c)
1995
- return c;
1996
- const [i, ...d] = o;
1997
- return { ...i, overloads: d };
1998
- })();
1999
- if (!u)
2000
- throw new Fe({ name: t });
2001
- return {
2002
- ...u,
2003
- ...s ? { hash: K(u) } : {}
2004
- };
2005
- }
2006
- function vr(e) {
2007
- return Xe(K(e), 0, 4);
2008
- }
2009
- function ma(e) {
2010
- const t = typeof e == "string" ? e : Pe(e);
2011
- return Be(t);
2012
- }
2013
- function K(e) {
2014
- return typeof e != "string" && "hash" in e && e.hash ? e.hash : br(Qe(ma(e)));
2015
- }
2016
- class ga extends $ {
2017
- constructor(t, r) {
2018
- super("Found ambiguous types in overloaded ABI Items.", {
2019
- metaMessages: [
2020
- // TODO: abitype to add support for signature-formatted ABI items.
2021
- `\`${t.type}\` in \`${Be(Pe(t.abiItem))}\`, and`,
2022
- `\`${r.type}\` in \`${Be(Pe(r.abiItem))}\``,
2023
- "",
2024
- "These types encode differently and cannot be distinguished at runtime.",
2025
- "Remove one of the ambiguous items in the ABI."
2026
- ]
2027
- }), Object.defineProperty(this, "name", {
2028
- enumerable: !0,
2029
- configurable: !0,
2030
- writable: !0,
2031
- value: "AbiItem.AmbiguityError"
2032
- });
2033
- }
2034
- }
2035
- class Fe extends $ {
2036
- constructor({ name: t, data: r, type: n = "item" }) {
2037
- const s = t ? ` with name "${t}"` : r ? ` with data "${r}"` : "";
2038
- super(`ABI ${n}${s} not found.`), Object.defineProperty(this, "name", {
2039
- enumerable: !0,
2040
- configurable: !0,
2041
- writable: !0,
2042
- value: "AbiItem.NotFoundError"
2043
- });
2044
- }
2045
- }
2046
- const ba = /^(.*)\[([0-9]*)\]$/, ya = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/, xr = /^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;
2047
- function wa({ checksumAddress: e, parameters: t, values: r }) {
2048
- const n = [];
2049
- for (let s = 0; s < t.length; s++)
2050
- n.push(Ye({
2051
- checksumAddress: e,
2052
- parameter: t[s],
2053
- value: r[s]
2054
- }));
2055
- return n;
2056
- }
2057
- function Ye({ checksumAddress: e = !1, parameter: t, value: r }) {
2058
- const n = t, s = Ra(n.type);
2059
- if (s) {
2060
- const [a, o] = s;
2061
- return xa(r, {
2062
- checksumAddress: e,
2063
- length: a,
2064
- parameter: {
2065
- ...n,
2066
- type: o
2067
- }
2068
- });
2069
- }
2070
- if (n.type === "tuple")
2071
- return Pa(r, {
2072
- checksumAddress: e,
2073
- parameter: n
2074
- });
2075
- if (n.type === "address")
2076
- return va(r, {
2077
- checksum: e
2078
- });
2079
- if (n.type === "bool")
2080
- return Aa(r);
2081
- if (n.type.startsWith("uint") || n.type.startsWith("int")) {
2082
- const a = n.type.startsWith("int"), [, , o = "256"] = xr.exec(n.type) ?? [];
2083
- return Ta(r, {
2084
- signed: a,
2085
- size: Number(o)
2086
- });
2087
- }
2088
- if (n.type.startsWith("bytes"))
2089
- return Ea(r, { type: n.type });
2090
- if (n.type === "string")
2091
- return Ia(r);
2092
- throw new Ir(n.type);
2093
- }
2094
- function et(e) {
2095
- let t = 0;
2096
- for (let a = 0; a < e.length; a++) {
2097
- const { dynamic: o, encoded: c } = e[a];
2098
- o ? t += 32 : t += q(c);
2099
- }
2100
- const r = [], n = [];
2101
- let s = 0;
2102
- for (let a = 0; a < e.length; a++) {
2103
- const { dynamic: o, encoded: c } = e[a];
2104
- o ? (r.push(z(t + s, { size: 32 })), n.push(c), s += q(c)) : r.push(c);
2105
- }
2106
- return j(...r, ...n);
2107
- }
2108
- function va(e, t) {
2109
- const { checksum: r = !1 } = t;
2110
- return ye(e, { strict: r }), {
2111
- dynamic: !1,
2112
- encoded: U(e.toLowerCase())
2113
- };
2114
- }
2115
- function xa(e, t) {
2116
- const { checksumAddress: r, length: n, parameter: s } = t, a = n === null;
2117
- if (!Array.isArray(e))
2118
- throw new $a(e);
2119
- if (!a && e.length !== n)
2120
- throw new Ca({
2121
- expectedLength: n,
2122
- givenLength: e.length,
2123
- type: `${s.type}[${n}]`
2124
- });
2125
- let o = !1;
2126
- const c = [];
2127
- for (let u = 0; u < e.length; u++) {
2128
- const i = Ye({
2129
- checksumAddress: r,
2130
- parameter: s,
2131
- value: e[u]
2132
- });
2133
- i.dynamic && (o = !0), c.push(i);
2134
- }
2135
- if (a || o) {
2136
- const u = et(c);
2137
- if (a) {
2138
- const i = z(c.length, { size: 32 });
2139
- return {
2140
- dynamic: !0,
2141
- encoded: c.length > 0 ? j(i, u) : i
2142
- };
2143
- }
2144
- if (o)
2145
- return { dynamic: !0, encoded: u };
2146
- }
2147
- return {
2148
- dynamic: !1,
2149
- encoded: j(...c.map(({ encoded: u }) => u))
2150
- };
2151
- }
2152
- function Ea(e, { type: t }) {
2153
- const [, r] = t.split("bytes"), n = q(e);
2154
- if (!r) {
2155
- let s = e;
2156
- return n % 32 !== 0 && (s = G(s, Math.ceil((e.length - 2) / 2 / 32) * 32)), {
2157
- dynamic: !0,
2158
- encoded: j(U(z(n, { size: 32 })), s)
2159
- };
2160
- }
2161
- if (n !== Number.parseInt(r))
2162
- throw new Ar({
2163
- expectedSize: Number.parseInt(r),
2164
- value: e
2165
- });
2166
- return { dynamic: !1, encoded: G(e) };
2167
- }
2168
- function Aa(e) {
2169
- if (typeof e != "boolean")
2170
- throw new $(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);
2171
- return { dynamic: !1, encoded: U(pr(e)) };
2172
- }
2173
- function Ta(e, { signed: t, size: r }) {
2174
- if (typeof r == "number") {
2175
- const n = 2n ** (BigInt(r) - (t ? 1n : 0n)) - 1n, s = t ? -n - 1n : 0n;
2176
- if (e > n || e < s)
2177
- throw new mr({
2178
- max: n.toString(),
2179
- min: s.toString(),
2180
- signed: t,
2181
- size: r / 8,
2182
- value: e.toString()
2183
- });
2184
- }
2185
- return {
2186
- dynamic: !1,
2187
- encoded: z(e, {
2188
- size: 32,
2189
- signed: t
2190
- })
2191
- };
2192
- }
2193
- function Ia(e) {
2194
- const t = Qe(e), r = Math.ceil(q(t) / 32), n = [];
2195
- for (let s = 0; s < r; s++)
2196
- n.push(G(Xe(t, s * 32, (s + 1) * 32)));
2197
- return {
2198
- dynamic: !0,
2199
- encoded: j(G(z(q(t), { size: 32 })), ...n)
2200
- };
2201
- }
2202
- function Pa(e, t) {
2203
- const { checksumAddress: r, parameter: n } = t;
2204
- let s = !1;
2205
- const a = [];
2206
- for (let o = 0; o < n.components.length; o++) {
2207
- const c = n.components[o], u = Array.isArray(e) ? o : c.name, i = Ye({
2208
- checksumAddress: r,
2209
- parameter: c,
2210
- value: e[u]
2211
- });
2212
- a.push(i), i.dynamic && (s = !0);
2213
- }
2214
- return {
2215
- dynamic: s,
2216
- encoded: s ? et(a) : j(...a.map(({ encoded: o }) => o))
2217
- };
2218
- }
2219
- function Ra(e) {
2220
- const t = e.match(/^(.*)\[(\d+)?\]$/);
2221
- return t ? (
2222
- // Return `null` if the array is dynamic.
2223
- [t[2] ? Number(t[2]) : null, t[1]]
2224
- ) : void 0;
2225
- }
2226
- function Er(e, t, r) {
2227
- const { checksumAddress: n = !1 } = {};
2228
- if (e.length !== t.length)
2229
- throw new Tr({
2230
- expectedLength: e.length,
2231
- givenLength: t.length
2232
- });
2233
- const s = wa({
2234
- checksumAddress: n,
2235
- parameters: e,
2236
- values: t
2237
- }), a = et(s);
2238
- return a.length === 0 ? "0x" : a;
2239
- }
2240
- function De(e, t) {
2241
- if (e.length !== t.length)
2242
- throw new Tr({
2243
- expectedLength: e.length,
2244
- givenLength: t.length
2245
- });
2246
- const r = [];
2247
- for (let n = 0; n < e.length; n++) {
2248
- const s = e[n], a = t[n];
2249
- r.push(De.encode(s, a));
2250
- }
2251
- return j(...r);
2252
- }
2253
- (function(e) {
2254
- function t(r, n, s = !1) {
2255
- if (r === "address") {
2256
- const u = n;
2257
- return ye(u), U(u.toLowerCase(), s ? 32 : 0);
2258
- }
2259
- if (r === "string")
2260
- return Qe(n);
2261
- if (r === "bytes")
2262
- return n;
2263
- if (r === "bool")
2264
- return U(pr(n), s ? 32 : 1);
2265
- const a = r.match(xr);
2266
- if (a) {
2267
- const [u, i, d = "256"] = a, f = Number.parseInt(d) / 8;
2268
- return z(n, {
2269
- size: s ? 32 : f,
2270
- signed: i === "int"
2271
- });
2272
- }
2273
- const o = r.match(ya);
2274
- if (o) {
2275
- const [u, i] = o;
2276
- if (Number.parseInt(i) !== (n.length - 2) / 2)
2277
- throw new Ar({
2278
- expectedSize: Number.parseInt(i),
2279
- value: n
2280
- });
2281
- return G(n, s ? 32 : 0);
2282
- }
2283
- const c = r.match(ba);
2284
- if (c && Array.isArray(n)) {
2285
- const [u, i] = c, d = [];
2286
- for (let f = 0; f < n.length; f++)
2287
- d.push(t(i, n[f], !0));
2288
- return d.length === 0 ? "0x" : j(...d);
2289
- }
2290
- throw new Ir(r);
2291
- }
2292
- e.encode = t;
2293
- })(De || (De = {}));
2294
- class Ca extends $ {
2295
- constructor({ expectedLength: t, givenLength: r, type: n }) {
2296
- super(`Array length mismatch for type \`${n}\`. Expected: \`${t}\`. Given: \`${r}\`.`), Object.defineProperty(this, "name", {
2297
- enumerable: !0,
2298
- configurable: !0,
2299
- writable: !0,
2300
- value: "AbiParameters.ArrayLengthMismatchError"
2301
- });
2302
- }
2303
- }
2304
- class Ar extends $ {
2305
- constructor({ expectedSize: t, value: r }) {
2306
- super(`Size of bytes "${r}" (bytes${q(r)}) does not match expected size (bytes${t}).`), Object.defineProperty(this, "name", {
2307
- enumerable: !0,
2308
- configurable: !0,
2309
- writable: !0,
2310
- value: "AbiParameters.BytesSizeMismatchError"
2311
- });
2312
- }
2313
- }
2314
- class Tr extends $ {
2315
- constructor({ expectedLength: t, givenLength: r }) {
2316
- super([
2317
- "ABI encoding parameters/values length mismatch.",
2318
- `Expected length (parameters): ${t}`,
2319
- `Given length (values): ${r}`
2320
- ].join(`
2321
- `)), Object.defineProperty(this, "name", {
2322
- enumerable: !0,
2323
- configurable: !0,
2324
- writable: !0,
2325
- value: "AbiParameters.LengthMismatchError"
2326
- });
2327
- }
2328
- }
2329
- class $a extends $ {
2330
- constructor(t) {
2331
- super(`Value \`${t}\` is not a valid array.`), Object.defineProperty(this, "name", {
2332
- enumerable: !0,
2333
- configurable: !0,
2334
- writable: !0,
2335
- value: "AbiParameters.InvalidArrayError"
2336
- });
2337
- }
2338
- }
2339
- class Ir extends $ {
2340
- constructor(t) {
2341
- super(`Type \`${t}\` is not a valid ABI Type.`), Object.defineProperty(this, "name", {
2342
- enumerable: !0,
2343
- configurable: !0,
2344
- writable: !0,
2345
- value: "AbiParameters.InvalidTypeError"
2346
- });
2347
- }
2348
- }
2349
- function Na(e, t) {
2350
- var s;
2351
- const { bytecode: r, args: n } = t;
2352
- return j(r, (s = e.inputs) != null && s.length && (n != null && n.length) ? Er(e.inputs, n) : "0x");
2353
- }
2354
- function ka(e) {
2355
- return wr(e);
2356
- }
2357
- function Sa(e, ...t) {
2358
- const { overloads: r } = e, n = r ? Ba([e, ...r], e.name, {
2359
- args: t[0]
2360
- }) : e, s = za(n), a = t.length > 0 ? Er(n.inputs, t[0]) : void 0;
2361
- return a ? j(s, a) : s;
2362
- }
2363
- function J(e, t = {}) {
2364
- return wr(e, t);
2365
- }
2366
- function Ba(e, t, r) {
2367
- const n = ha(e, t, r);
2368
- if (n.type !== "function")
2369
- throw new Fe({ name: t, type: "function" });
2370
- return n;
2371
- }
2372
- function za(e) {
2373
- return vr(e);
2374
- }
2375
- const Fa = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", M = "0x0000000000000000000000000000000000000000", Da = "0x6080604052348015600e575f80fd5b5061016d8061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610029575f3560e01c8063f8b2cb4f1461002d575b5f80fd5b610047600480360381019061004291906100db565b61005d565b604051610054919061011e565b60405180910390f35b5f8173ffffffffffffffffffffffffffffffffffffffff16319050919050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100aa82610081565b9050919050565b6100ba816100a0565b81146100c4575f80fd5b50565b5f813590506100d5816100b1565b92915050565b5f602082840312156100f0576100ef61007d565b5b5f6100fd848285016100c7565b91505092915050565b5f819050919050565b61011881610106565b82525050565b5f6020820190506101315f83018461010f565b9291505056fea26469706673582212203b9fe929fe995c7cf9887f0bdba8a36dd78e8b73f149b17d2d9ad7cd09d2dc6264736f6c634300081a0033";
2376
- async function qa(e, t) {
2377
- const { blockNumber: r, blockTag: n, calls: s, stateOverrides: a, traceAssetChanges: o, traceTransfers: c, validation: u } = t, i = t.account ? V(t.account) : void 0;
2378
- if (o && !i)
2379
- throw new F("`account` is required when `traceAssetChanges` is true");
2380
- const d = i ? Na(ka("constructor(bytes, bytes)"), {
2381
- bytecode: Xr,
2382
- args: [
2383
- Da,
2384
- Sa(J("function getBalance(address)"), [i.address])
2385
- ]
2386
- }) : void 0, f = o ? await Promise.all(t.calls.map(async (w) => {
2387
- if (!w.data && !w.abi)
2388
- return;
2389
- const { accessList: S } = await er(e, {
2390
- account: i.address,
2391
- ...w,
2392
- data: w.abi ? X(w) : w.data
2393
- });
2394
- return S.map(({ address: Y, storageKeys: oe }) => oe.length > 0 ? Y : null);
2395
- })).then((w) => w.flat().filter(Boolean)) : [], l = a == null ? void 0 : a.map((w) => w.address === (i == null ? void 0 : i.address) ? {
2396
- ...w,
2397
- nonce: 0
2398
- } : w), p = await ke(e, {
2399
- blockNumber: r,
2400
- blockTag: n,
2401
- blocks: [
2402
- ...o ? [
2403
- // ETH pre balances
2404
- {
2405
- calls: [{ data: d }],
2406
- stateOverrides: a
2407
- },
2408
- // Asset pre balances
2409
- {
2410
- calls: f.map((w, S) => ({
2411
- abi: [
2412
- J("function balanceOf(address) returns (uint256)")
2413
- ],
2414
- functionName: "balanceOf",
2415
- args: [i.address],
2416
- to: w,
2417
- from: M,
2418
- nonce: S
2419
- })),
2420
- stateOverrides: [
2421
- {
2422
- address: M,
2423
- nonce: 0
2424
- }
2425
- ]
2426
- }
2427
- ] : [],
2428
- {
2429
- calls: [...s, {}].map((w, S) => ({
2430
- ...w,
2431
- from: i == null ? void 0 : i.address,
2432
- nonce: S
2433
- })),
2434
- stateOverrides: l
2435
- },
2436
- ...o ? [
2437
- // ETH post balances
2438
- {
2439
- calls: [{ data: d }]
2440
- },
2441
- // Asset post balances
2442
- {
2443
- calls: f.map((w, S) => ({
2444
- abi: [
2445
- J("function balanceOf(address) returns (uint256)")
2446
- ],
2447
- functionName: "balanceOf",
2448
- args: [i.address],
2449
- to: w,
2450
- from: M,
2451
- nonce: S
2452
- })),
2453
- stateOverrides: [
2454
- {
2455
- address: M,
2456
- nonce: 0
2457
- }
2458
- ]
2459
- },
2460
- // Decimals
2461
- {
2462
- calls: f.map((w, S) => ({
2463
- to: w,
2464
- abi: [
2465
- J("function decimals() returns (uint256)")
2466
- ],
2467
- functionName: "decimals",
2468
- from: M,
2469
- nonce: S
2470
- })),
2471
- stateOverrides: [
2472
- {
2473
- address: M,
2474
- nonce: 0
2475
- }
2476
- ]
2477
- },
2478
- // Token URI
2479
- {
2480
- calls: f.map((w, S) => ({
2481
- to: w,
2482
- abi: [
2483
- J("function tokenURI(uint256) returns (string)")
2484
- ],
2485
- functionName: "tokenURI",
2486
- args: [0n],
2487
- from: M,
2488
- nonce: S
2489
- })),
2490
- stateOverrides: [
2491
- {
2492
- address: M,
2493
- nonce: 0
2494
- }
2495
- ]
2496
- },
2497
- // Symbols
2498
- {
2499
- calls: f.map((w, S) => ({
2500
- to: w,
2501
- abi: [J("function symbol() returns (string)")],
2502
- functionName: "symbol",
2503
- from: M,
2504
- nonce: S
2505
- })),
2506
- stateOverrides: [
2507
- {
2508
- address: M,
2509
- nonce: 0
2510
- }
2511
- ]
2512
- }
2513
- ] : []
2514
- ],
2515
- traceTransfers: c,
2516
- validation: u
2517
- }), m = o ? p[2] : p[0], [g, v, , h, b, y, x, P] = o ? p : [], { calls: A, ...E } = m, C = A.slice(0, -1) ?? [], R = (g == null ? void 0 : g.calls) ?? [], N = (v == null ? void 0 : v.calls) ?? [], I = [...R, ...N].map((w) => w.status === "success" ? se(w.data) : null), k = (h == null ? void 0 : h.calls) ?? [], _ = (b == null ? void 0 : b.calls) ?? [], Rr = [...k, ..._].map((w) => w.status === "success" ? se(w.data) : null), Cr = ((y == null ? void 0 : y.calls) ?? []).map((w) => w.status === "success" ? w.result : null), $r = ((P == null ? void 0 : P.calls) ?? []).map((w) => w.status === "success" ? w.result : null), Nr = ((x == null ? void 0 : x.calls) ?? []).map((w) => w.status === "success" ? w.result : null), we = [];
2518
- for (const [w, S] of Rr.entries()) {
2519
- const Y = I[w];
2520
- if (typeof S != "bigint" || typeof Y != "bigint")
2521
- continue;
2522
- const oe = Cr[w - 1], kr = $r[w - 1], Sr = Nr[w - 1], rt = w === 0 ? {
2523
- address: Fa,
2524
- decimals: 18,
2525
- symbol: "ETH"
2526
- } : {
2527
- address: f[w - 1],
2528
- decimals: Sr || oe ? Number(oe ?? 1) : void 0,
2529
- symbol: kr ?? void 0
2530
- };
2531
- we.some((Br) => Br.token.address === rt.address) || we.push({
2532
- token: rt,
2533
- value: {
2534
- pre: Y,
2535
- post: S,
2536
- diff: S - Y
2537
- }
2538
- });
2539
- }
2540
- return {
2541
- assetChanges: we,
2542
- block: E,
2543
- results: C
2544
- };
2545
- }
2546
- function Oa({ r: e, s: t, to: r = "hex", v: n, yParity: s }) {
2547
- const a = (() => {
2548
- if (s === 0 || s === 1)
2549
- return s;
2550
- if (n && (n === 27n || n === 28n || n >= 35n))
2551
- return n % 2n === 0n ? 1 : 0;
2552
- throw new Error("Invalid `v` or `yParity` value");
2553
- })(), o = `0x${new Dn.Signature(se(e), se(t)).toCompactHex()}${a === 0 ? "1b" : "1c"}`;
2554
- return r === "hex" ? o : Ut(o);
2555
- }
2556
- async function tt(e, t) {
2557
- var f, l, p;
2558
- const { address: r, factory: n, factoryData: s, hash: a, signature: o, universalSignatureVerifierAddress: c = (p = (l = (f = e.chain) == null ? void 0 : f.contracts) == null ? void 0 : l.universalSignatureVerifier) == null ? void 0 : p.address, ...u } = t, i = Lt(o) ? o : typeof o == "object" && "r" in o && "s" in o ? Oa(o) : ne(o), d = await (async () => !n && !s || Ns(i) ? i : ks({
2559
- address: n,
2560
- data: s,
2561
- signature: i
2562
- }))();
2563
- try {
2564
- const m = c ? {
2565
- to: c,
2566
- data: X({
2567
- abi: xt,
2568
- functionName: "isValidSig",
2569
- args: [r, a, d]
2570
- }),
2571
- ...u
2572
- } : {
2573
- data: Ft({
2574
- abi: xt,
2575
- args: [r, a, d],
2576
- bytecode: Yr
2577
- }),
2578
- ...u
2579
- }, { data: g } = await T(e, Dt, "call")(m);
2580
- return Bn(g ?? "0x0");
2581
- } catch (m) {
2582
- try {
2583
- if (qt(Wt(r), await en({ hash: a, signature: o })))
2584
- return !0;
2585
- } catch {
2586
- }
2587
- if (m instanceof tn)
2588
- return !1;
2589
- throw m;
2590
- }
2591
- }
2592
- async function _a(e, { address: t, message: r, factory: n, factoryData: s, signature: a, ...o }) {
2593
- const c = ur(r);
2594
- return tt(e, {
2595
- address: t,
2596
- factory: n,
2597
- factoryData: s,
2598
- hash: c,
2599
- signature: a,
2600
- ...o
2601
- });
2602
- }
2603
- async function Ma(e, t) {
2604
- const { address: r, factory: n, factoryData: s, signature: a, message: o, primaryType: c, types: u, domain: i, ...d } = t, f = Es({ message: o, primaryType: c, types: u, domain: i });
2605
- return tt(e, {
2606
- address: r,
2607
- factory: n,
2608
- factoryData: s,
2609
- hash: f,
2610
- signature: a,
2611
- ...d
2612
- });
2613
- }
2614
- function Pr(e, { emitOnBegin: t = !1, emitMissed: r = !1, onBlockNumber: n, onError: s, poll: a, pollingInterval: o = e.pollingInterval }) {
2615
- const c = typeof a < "u" ? a : !(e.transport.type === "webSocket" || e.transport.type === "fallback" && e.transport.transports[0].config.type === "webSocket");
2616
- let u;
2617
- return c ? (() => {
2618
- const f = D([
2619
- "watchBlockNumber",
2620
- e.uid,
2621
- t,
2622
- r,
2623
- o
2624
- ]);
2625
- return Q(f, { onBlockNumber: n, onError: s }, (l) => ge(async () => {
2626
- var p;
2627
- try {
2628
- const m = await T(e, me, "getBlockNumber")({ cacheTime: 0 });
2629
- if (u) {
2630
- if (m === u)
2631
- return;
2632
- if (m - u > 1 && r)
2633
- for (let g = u + 1n; g < m; g++)
2634
- l.onBlockNumber(g, u), u = g;
2635
- }
2636
- (!u || m > u) && (l.onBlockNumber(m, u), u = m);
2637
- } catch (m) {
2638
- (p = l.onError) == null || p.call(l, m);
2639
- }
2640
- }, {
2641
- emitOnBegin: t,
2642
- interval: o
2643
- }));
2644
- })() : (() => {
2645
- const f = D([
2646
- "watchBlockNumber",
2647
- e.uid,
2648
- t,
2649
- r
2650
- ]);
2651
- return Q(f, { onBlockNumber: n, onError: s }, (l) => {
2652
- let p = !0, m = () => p = !1;
2653
- return (async () => {
2654
- try {
2655
- const g = (() => {
2656
- if (e.transport.type === "fallback") {
2657
- const h = e.transport.transports.find((b) => b.config.type === "webSocket");
2658
- return h ? h.value : e.transport;
2659
- }
2660
- return e.transport;
2661
- })(), { unsubscribe: v } = await g.subscribe({
2662
- params: ["newHeads"],
2663
- onData(h) {
2664
- var y;
2665
- if (!p)
2666
- return;
2667
- const b = se((y = h.result) == null ? void 0 : y.number);
2668
- l.onBlockNumber(b, u), u = b;
2669
- },
2670
- onError(h) {
2671
- var b;
2672
- (b = l.onError) == null || b.call(l, h);
2673
- }
2674
- });
2675
- m = v, p || m();
2676
- } catch (g) {
2677
- s == null || s(g);
2678
- }
2679
- })(), () => m();
2680
- });
2681
- })();
2682
- }
2683
- async function ja(e, {
2684
- confirmations: t = 1,
2685
- hash: r,
2686
- onReplaced: n,
2687
- pollingInterval: s = e.pollingInterval,
2688
- retryCount: a = 6,
2689
- retryDelay: o = ({ count: u }) => ~~(1 << u) * 200,
2690
- // exponential backoff
2691
- timeout: c = 18e4
2692
- }) {
2693
- const u = D(["waitForTransactionReceipt", e.uid, r]);
2694
- let i, d, f, l = !1;
2695
- const { promise: p, resolve: m, reject: g } = rn(), v = c ? setTimeout(() => g(new zn({ hash: r })), c) : void 0, h = Q(u, { onReplaced: n, resolve: m, reject: g }, (b) => {
2696
- const y = T(e, Pr, "watchBlockNumber")({
2697
- emitMissed: !0,
2698
- emitOnBegin: !0,
2699
- poll: !0,
2700
- pollingInterval: s,
2701
- async onBlockNumber(x) {
2702
- const P = (E) => {
2703
- clearTimeout(v), y(), E(), h();
2704
- };
2705
- let A = x;
2706
- if (!l)
2707
- try {
2708
- if (f) {
2709
- if (t > 1 && (!f.blockNumber || A - f.blockNumber + 1n < t))
2710
- return;
2711
- P(() => b.resolve(f));
2712
- return;
2713
- }
2714
- if (i || (l = !0, await $e(async () => {
2715
- i = await T(e, Ze, "getTransaction")({ hash: r }), i.blockNumber && (A = i.blockNumber);
2716
- }, {
2717
- delay: o,
2718
- retryCount: a
2719
- }), l = !1), f = await T(e, Ne, "getTransactionReceipt")({ hash: r }), t > 1 && (!f.blockNumber || A - f.blockNumber + 1n < t))
2720
- return;
2721
- P(() => b.resolve(f));
2722
- } catch (E) {
2723
- if (E instanceof Gt || E instanceof Vt) {
2724
- if (!i) {
2725
- l = !1;
2726
- return;
2727
- }
2728
- try {
2729
- d = i, l = !0;
2730
- const C = await $e(() => T(e, Z, "getBlock")({
2731
- blockNumber: A,
2732
- includeTransactions: !0
2733
- }), {
2734
- delay: o,
2735
- retryCount: a,
2736
- shouldRetry: ({ error: I }) => I instanceof nn
2737
- });
2738
- l = !1;
2739
- const R = C.transactions.find(({ from: I, nonce: k }) => I === d.from && k === d.nonce);
2740
- if (!R || (f = await T(e, Ne, "getTransactionReceipt")({
2741
- hash: R.hash
2742
- }), t > 1 && (!f.blockNumber || A - f.blockNumber + 1n < t)))
2743
- return;
2744
- let N = "replaced";
2745
- R.to === d.to && R.value === d.value && R.input === d.input ? N = "repriced" : R.from === R.to && R.value === 0n && (N = "cancelled"), P(() => {
2746
- var I;
2747
- (I = b.onReplaced) == null || I.call(b, {
2748
- reason: N,
2749
- replacedTransaction: d,
2750
- transaction: R,
2751
- transactionReceipt: f
2752
- }), b.resolve(f);
2753
- });
2754
- } catch (C) {
2755
- P(() => b.reject(C));
2756
- }
2757
- } else
2758
- P(() => b.reject(E));
2759
- }
2760
- }
2761
- });
2762
- });
2763
- return p;
2764
- }
2765
- function La(e, { blockTag: t = "latest", emitMissed: r = !1, emitOnBegin: n = !1, onBlock: s, onError: a, includeTransactions: o, poll: c, pollingInterval: u = e.pollingInterval }) {
2766
- const i = typeof c < "u" ? c : !(e.transport.type === "webSocket" || e.transport.type === "fallback" && e.transport.transports[0].config.type === "webSocket"), d = o ?? !1;
2767
- let f;
2768
- return i ? (() => {
2769
- const m = D([
2770
- "watchBlocks",
2771
- e.uid,
2772
- t,
2773
- r,
2774
- n,
2775
- d,
2776
- u
2777
- ]);
2778
- return Q(m, { onBlock: s, onError: a }, (g) => ge(async () => {
2779
- var v;
2780
- try {
2781
- const h = await T(e, Z, "getBlock")({
2782
- blockTag: t,
2783
- includeTransactions: d
2784
- });
2785
- if (h.number && (f != null && f.number)) {
2786
- if (h.number === f.number)
2787
- return;
2788
- if (h.number - f.number > 1 && r)
2789
- for (let b = (f == null ? void 0 : f.number) + 1n; b < h.number; b++) {
2790
- const y = await T(e, Z, "getBlock")({
2791
- blockNumber: b,
2792
- includeTransactions: d
2793
- });
2794
- g.onBlock(y, f), f = y;
2795
- }
2796
- }
2797
- // If no previous block exists, emit.
2798
- (!(f != null && f.number) || // If the block tag is "pending" with no block number, emit.
2799
- t === "pending" && !(h != null && h.number) || // If the next block number is greater than the previous block number, emit.
2800
- // We don't want to emit blocks in the past.
2801
- h.number && h.number > f.number) && (g.onBlock(h, f), f = h);
2802
- } catch (h) {
2803
- (v = g.onError) == null || v.call(g, h);
2804
- }
2805
- }, {
2806
- emitOnBegin: n,
2807
- interval: u
2808
- }));
2809
- })() : (() => {
2810
- let m = !0, g = !0, v = () => m = !1;
2811
- return (async () => {
2812
- try {
2813
- n && T(e, Z, "getBlock")({
2814
- blockTag: t,
2815
- includeTransactions: d
2816
- }).then((y) => {
2817
- m && g && (s(y, void 0), g = !1);
2818
- });
2819
- const h = (() => {
2820
- if (e.transport.type === "fallback") {
2821
- const y = e.transport.transports.find((x) => x.config.type === "webSocket");
2822
- return y ? y.value : e.transport;
2823
- }
2824
- return e.transport;
2825
- })(), { unsubscribe: b } = await h.subscribe({
2826
- params: ["newHeads"],
2827
- async onData(y) {
2828
- if (!m)
2829
- return;
2830
- const x = await T(e, Z, "getBlock")({
2831
- blockNumber: y.blockNumber,
2832
- includeTransactions: d
2833
- }).catch(() => {
2834
- });
2835
- m && (s(x, f), g = !1, f = x);
2836
- },
2837
- onError(y) {
2838
- a == null || a(y);
2839
- }
2840
- });
2841
- v = b, m || v();
2842
- } catch (h) {
2843
- a == null || a(h);
2844
- }
2845
- })(), () => v();
2846
- })();
2847
- }
2848
- function Ha(e, { address: t, args: r, batch: n = !0, event: s, events: a, fromBlock: o, onError: c, onLogs: u, poll: i, pollingInterval: d = e.pollingInterval, strict: f }) {
2849
- const l = typeof i < "u" ? i : typeof o == "bigint" ? !0 : !(e.transport.type === "webSocket" || e.transport.type === "fallback" && e.transport.transports[0].config.type === "webSocket"), p = f ?? !1;
2850
- return l ? (() => {
2851
- const v = D([
2852
- "watchEvent",
2853
- t,
2854
- r,
2855
- n,
2856
- e.uid,
2857
- s,
2858
- d,
2859
- o
2860
- ]);
2861
- return Q(v, { onLogs: u, onError: c }, (h) => {
2862
- let b;
2863
- o !== void 0 && (b = o - 1n);
2864
- let y, x = !1;
2865
- const P = ge(async () => {
2866
- var A;
2867
- if (!x) {
2868
- try {
2869
- y = await T(e, tr, "createEventFilter")({
2870
- address: t,
2871
- args: r,
2872
- event: s,
2873
- events: a,
2874
- strict: p,
2875
- fromBlock: o
2876
- });
2877
- } catch {
2878
- }
2879
- x = !0;
2880
- return;
2881
- }
2882
- try {
2883
- let E;
2884
- if (y)
2885
- E = await T(e, je, "getFilterChanges")({ filter: y });
2886
- else {
2887
- const C = await T(e, me, "getBlockNumber")({});
2888
- b && b !== C ? E = await T(e, Ot, "getLogs")({
2889
- address: t,
2890
- args: r,
2891
- event: s,
2892
- events: a,
2893
- fromBlock: b + 1n,
2894
- toBlock: C
2895
- }) : E = [], b = C;
2896
- }
2897
- if (E.length === 0)
2898
- return;
2899
- if (n)
2900
- h.onLogs(E);
2901
- else
2902
- for (const C of E)
2903
- h.onLogs([C]);
2904
- } catch (E) {
2905
- y && E instanceof Ae && (x = !1), (A = h.onError) == null || A.call(h, E);
2906
- }
2907
- }, {
2908
- emitOnBegin: !0,
2909
- interval: d
2910
- });
2911
- return async () => {
2912
- y && await T(e, Le, "uninstallFilter")({ filter: y }), P();
2913
- };
2914
- });
2915
- })() : (() => {
2916
- let v = !0, h = () => v = !1;
2917
- return (async () => {
2918
- try {
2919
- const b = (() => {
2920
- if (e.transport.type === "fallback") {
2921
- const A = e.transport.transports.find((E) => E.config.type === "webSocket");
2922
- return A ? A.value : e.transport;
2923
- }
2924
- return e.transport;
2925
- })(), y = a ?? (s ? [s] : void 0);
2926
- let x = [];
2927
- y && (x = [y.flatMap((E) => St({
2928
- abi: [E],
2929
- eventName: E.name,
2930
- args: r
2931
- }))], s && (x = x[0]));
2932
- const { unsubscribe: P } = await b.subscribe({
2933
- params: ["logs", { address: t, topics: x }],
2934
- onData(A) {
2935
- var C;
2936
- if (!v)
2937
- return;
2938
- const E = A.result;
2939
- try {
2940
- const { eventName: R, args: N } = sn({
2941
- abi: y ?? [],
2942
- data: E.data,
2943
- topics: E.topics,
2944
- strict: p
2945
- }), I = pe(E, { args: N, eventName: R });
2946
- u([I]);
2947
- } catch (R) {
2948
- let N, I;
2949
- if (R instanceof an || R instanceof on) {
2950
- if (f)
2951
- return;
2952
- N = R.abiItem.name, I = (C = R.abiItem.inputs) == null ? void 0 : C.some((_) => !("name" in _ && _.name));
2953
- }
2954
- const k = pe(E, {
2955
- args: I ? [] : {},
2956
- eventName: N
2957
- });
2958
- u([k]);
2959
- }
2960
- },
2961
- onError(A) {
2962
- c == null || c(A);
2963
- }
2964
- });
2965
- h = P, v || h();
2966
- } catch (b) {
2967
- c == null || c(b);
2968
- }
2969
- })(), () => h();
2970
- })();
2971
- }
2972
- function Ua(e, { batch: t = !0, onError: r, onTransactions: n, poll: s, pollingInterval: a = e.pollingInterval }) {
2973
- return (typeof s < "u" ? s : e.transport.type !== "webSocket") ? (() => {
2974
- const i = D([
2975
- "watchPendingTransactions",
2976
- e.uid,
2977
- t,
2978
- a
2979
- ]);
2980
- return Q(i, { onTransactions: n, onError: r }, (d) => {
2981
- let f;
2982
- const l = ge(async () => {
2983
- var p;
2984
- try {
2985
- if (!f)
2986
- try {
2987
- f = await T(e, rr, "createPendingTransactionFilter")({});
2988
- return;
2989
- } catch (g) {
2990
- throw l(), g;
2991
- }
2992
- const m = await T(e, je, "getFilterChanges")({ filter: f });
2993
- if (m.length === 0)
2994
- return;
2995
- if (t)
2996
- d.onTransactions(m);
2997
- else
2998
- for (const g of m)
2999
- d.onTransactions([g]);
3000
- } catch (m) {
3001
- (p = d.onError) == null || p.call(d, m);
3002
- }
3003
- }, {
3004
- emitOnBegin: !0,
3005
- interval: a
3006
- });
3007
- return async () => {
3008
- f && await T(e, Le, "uninstallFilter")({ filter: f }), l();
3009
- };
3010
- });
3011
- })() : (() => {
3012
- let i = !0, d = () => i = !1;
3013
- return (async () => {
3014
- try {
3015
- const { unsubscribe: f } = await e.transport.subscribe({
3016
- params: ["newPendingTransactions"],
3017
- onData(l) {
3018
- if (!i)
3019
- return;
3020
- const p = l.result;
3021
- n([p]);
3022
- },
3023
- onError(l) {
3024
- r == null || r(l);
3025
- }
3026
- });
3027
- d = f, i || d();
3028
- } catch (f) {
3029
- r == null || r(f);
3030
- }
3031
- })(), () => d();
3032
- })();
3033
- }
3034
- function Ga(e) {
3035
- var f, l, p;
3036
- const { scheme: t, statement: r, ...n } = ((f = e.match(Va)) == null ? void 0 : f.groups) ?? {}, { chainId: s, expirationTime: a, issuedAt: o, notBefore: c, requestId: u, ...i } = ((l = e.match(Wa)) == null ? void 0 : l.groups) ?? {}, d = (p = e.split("Resources:")[1]) == null ? void 0 : p.split(`
3037
- - `).slice(1);
3038
- return {
3039
- ...n,
3040
- ...i,
3041
- ...s ? { chainId: Number(s) } : {},
3042
- ...a ? { expirationTime: new Date(a) } : {},
3043
- ...o ? { issuedAt: new Date(o) } : {},
3044
- ...c ? { notBefore: new Date(c) } : {},
3045
- ...u ? { requestId: u } : {},
3046
- ...d ? { resources: d } : {},
3047
- ...t ? { scheme: t } : {},
3048
- ...r ? { statement: r } : {}
3049
- };
3050
- }
3051
- const Va = /^(?:(?<scheme>[a-zA-Z][a-zA-Z0-9+-.]*):\/\/)?(?<domain>[a-zA-Z0-9+-.]*(?::[0-9]{1,5})?) (?:wants you to sign in with your Ethereum account:\n)(?<address>0x[a-fA-F0-9]{40})\n\n(?:(?<statement>.*)\n\n)?/, Wa = /(?:URI: (?<uri>.+))\n(?:Version: (?<version>.+))\n(?:Chain ID: (?<chainId>\d+))\n(?:Nonce: (?<nonce>[a-zA-Z0-9]+))\n(?:Issued At: (?<issuedAt>.+))(?:\nExpiration Time: (?<expirationTime>.+))?(?:\nNot Before: (?<notBefore>.+))?(?:\nRequest ID: (?<requestId>.+))?/;
3052
- function Ja(e) {
3053
- const { address: t, domain: r, message: n, nonce: s, scheme: a, time: o = /* @__PURE__ */ new Date() } = e;
3054
- if (r && n.domain !== r || s && n.nonce !== s || a && n.scheme !== a || n.expirationTime && o >= n.expirationTime || n.notBefore && o < n.notBefore)
3055
- return !1;
3056
- try {
3057
- if (!n.address || t && !qt(n.address, t))
3058
- return !1;
3059
- } catch {
3060
- return !1;
3061
- }
3062
- return !0;
3063
- }
3064
- async function Za(e, t) {
3065
- const { address: r, domain: n, message: s, nonce: a, scheme: o, signature: c, time: u = /* @__PURE__ */ new Date(), ...i } = t, d = Ga(s);
3066
- if (!d.address || !Ja({
3067
- address: r,
3068
- domain: n,
3069
- message: d,
3070
- nonce: a,
3071
- scheme: o,
3072
- time: u
3073
- }))
3074
- return !1;
3075
- const l = ur(s);
3076
- return tt(e, {
3077
- address: d.address,
3078
- hash: l,
3079
- signature: c,
3080
- ...i
3081
- });
3082
- }
3083
- function Ka(e) {
3084
- return {
3085
- call: (t) => Dt(e, t),
3086
- createAccessList: (t) => er(e, t),
3087
- createBlockFilter: () => ps(e),
3088
- createContractEventFilter: (t) => yn(e, t),
3089
- createEventFilter: (t) => tr(e, t),
3090
- createPendingTransactionFilter: () => rr(e),
3091
- estimateContractGas: (t) => bn(e, t),
3092
- estimateGas: (t) => gn(e, t),
3093
- getBalance: (t) => mn(e, t),
3094
- getBlobBaseFee: () => hs(e),
3095
- getBlock: (t) => Z(e, t),
3096
- getBlockNumber: (t) => me(e, t),
3097
- getBlockTransactionCount: (t) => ms(e, t),
3098
- getBytecode: (t) => It(e, t),
3099
- getChainId: () => He(e),
3100
- getCode: (t) => It(e, t),
3101
- getContractEvents: (t) => hn(e, t),
3102
- getEip712Domain: (t) => On(e, t),
3103
- getEnsAddress: (t) => Qn(e, t),
3104
- getEnsAvatar: (t) => fs(e, t),
3105
- getEnsName: (t) => ds(e, t),
3106
- getEnsResolver: (t) => ls(e, t),
3107
- getEnsText: (t) => Yt(e, t),
3108
- getFeeHistory: (t) => bs(e, t),
3109
- estimateFeesPerGas: (t) => pn(e, t),
3110
- getFilterChanges: (t) => je(e, t),
3111
- getFilterLogs: (t) => ys(e, t),
3112
- getGasPrice: () => ln(e),
3113
- getLogs: (t) => Ot(e, t),
3114
- getProof: (t) => zs(e, t),
3115
- estimateMaxPriorityFeePerGas: (t) => dn(e, t),
3116
- getStorageAt: (t) => Fs(e, t),
3117
- getTransaction: (t) => Ze(e, t),
3118
- getTransactionConfirmations: (t) => Ds(e, t),
3119
- getTransactionCount: (t) => fn(e, t),
3120
- getTransactionReceipt: (t) => Ne(e, t),
3121
- multicall: (t) => qs(e, t),
3122
- prepareTransactionRequest: (t) => Mt(e, t),
3123
- readContract: (t) => H(e, t),
3124
- sendRawTransaction: (t) => _t(e, t),
3125
- simulate: (t) => ke(e, t),
3126
- simulateBlocks: (t) => ke(e, t),
3127
- simulateCalls: (t) => qa(e, t),
3128
- simulateContract: (t) => un(e, t),
3129
- verifyMessage: (t) => _a(e, t),
3130
- verifySiweMessage: (t) => Za(e, t),
3131
- verifyTypedData: (t) => Ma(e, t),
3132
- uninstallFilter: (t) => Le(e, t),
3133
- waitForTransactionReceipt: (t) => ja(e, t),
3134
- watchBlocks: (t) => La(e, t),
3135
- watchBlockNumber: (t) => Pr(e, t),
3136
- watchContractEvent: (t) => cn(e, t),
3137
- watchEvent: (t) => Ha(e, t),
3138
- watchPendingTransactions: (t) => Ua(e, t)
3139
- };
3140
- }
3141
- function mo(e) {
3142
- const { key: t = "public", name: r = "Public Client" } = e;
3143
- return Zt({
3144
- ...e,
3145
- key: t,
3146
- name: r,
3147
- type: "publicClient"
3148
- }).extend(Ka);
3149
- }
3150
- function Qa(e, t) {
3151
- const { abi: r, args: n, bytecode: s, ...a } = t, o = Ft({ abi: r, args: n, bytecode: s });
3152
- return jt(e, {
3153
- ...a,
3154
- ...a.authorizationList ? { to: null } : {},
3155
- data: o
3156
- });
3157
- }
3158
- async function Xa(e) {
3159
- var r;
3160
- return ((r = e.account) == null ? void 0 : r.type) === "local" ? [e.account.address] : (await e.request({ method: "eth_accounts" }, { dedupe: !0 })).map((n) => Fn(n));
3161
- }
3162
- async function Ya(e) {
3163
- return await e.request({ method: "wallet_getPermissions" }, { dedupe: !0 });
3164
- }
3165
- async function eo(e) {
3166
- return (await e.request({ method: "eth_requestAccounts" }, { dedupe: !0, retryCount: 0 })).map((r) => Wt(r));
3167
- }
3168
- async function to(e, t) {
3169
- return e.request({
3170
- method: "wallet_requestPermissions",
3171
- params: [t]
3172
- }, { retryCount: 0 });
3173
- }
3174
- async function ro(e, { account: t = e.account, message: r }) {
3175
- if (!t)
3176
- throw new Ue({
3177
- docsPath: "/docs/actions/wallet/signMessage"
3178
- });
3179
- const n = V(t);
3180
- if (n.signMessage)
3181
- return n.signMessage({ message: r });
3182
- const s = typeof r == "string" ? le(r) : r.raw instanceof Uint8Array ? W(r.raw) : r.raw;
3183
- return e.request({
3184
- method: "personal_sign",
3185
- params: [s, n.address]
3186
- }, { retryCount: 0 });
3187
- }
3188
- async function no(e, t) {
3189
- var i, d, f, l;
3190
- const { account: r = e.account, chain: n = e.chain, ...s } = t;
3191
- if (!r)
3192
- throw new Ue({
3193
- docsPath: "/docs/actions/wallet/signTransaction"
3194
- });
3195
- const a = V(r);
3196
- qe({
3197
- account: a,
3198
- ...t
3199
- });
3200
- const o = await T(e, He, "getChainId")({});
3201
- n !== null && wn({
3202
- currentChainId: o,
3203
- chain: n
3204
- });
3205
- const c = (n == null ? void 0 : n.formatters) || ((i = e.chain) == null ? void 0 : i.formatters), u = ((d = c == null ? void 0 : c.transactionRequest) == null ? void 0 : d.format) || Oe;
3206
- return a.signTransaction ? a.signTransaction({
3207
- ...s,
3208
- chainId: o
3209
- }, { serializer: (l = (f = e.chain) == null ? void 0 : f.serializers) == null ? void 0 : l.transaction }) : await e.request({
3210
- method: "eth_signTransaction",
3211
- params: [
3212
- {
3213
- ...u(s),
3214
- chainId: B(o),
3215
- from: a.address
3216
- }
3217
- ]
3218
- }, { retryCount: 0 });
3219
- }
3220
- async function so(e, t) {
3221
- const { account: r = e.account, domain: n, message: s, primaryType: a } = t;
3222
- if (!r)
3223
- throw new Ue({
3224
- docsPath: "/docs/actions/wallet/signTypedData"
3225
- });
3226
- const o = V(r), c = {
3227
- EIP712Domain: cr({ domain: n }),
3228
- ...t.types
3229
- };
3230
- if (ir({ domain: n, message: s, primaryType: a, types: c }), o.signTypedData)
3231
- return o.signTypedData({ domain: n, message: s, primaryType: a, types: c });
3232
- const u = Ps({ domain: n, message: s, primaryType: a, types: c });
3233
- return e.request({
3234
- method: "eth_signTypedData_v4",
3235
- params: [o.address, u]
3236
- }, { retryCount: 0 });
3237
- }
3238
- async function ao(e, { id: t }) {
3239
- await e.request({
3240
- method: "wallet_switchEthereumChain",
3241
- params: [
3242
- {
3243
- chainId: B(t)
3244
- }
3245
- ]
3246
- }, { retryCount: 0 });
3247
- }
3248
- async function oo(e, t) {
3249
- return await e.request({
3250
- method: "wallet_watchAsset",
3251
- params: t
3252
- }, { retryCount: 0 });
3253
- }
3254
- function io(e) {
3255
- return {
3256
- addChain: (t) => Mn(e, t),
3257
- deployContract: (t) => Qa(e, t),
3258
- getAddresses: () => Xa(e),
3259
- getChainId: () => He(e),
3260
- getPermissions: () => Ya(e),
3261
- prepareTransactionRequest: (t) => Mt(e, t),
3262
- requestAddresses: () => eo(e),
3263
- requestPermissions: (t) => to(e, t),
3264
- sendRawTransaction: (t) => _t(e, t),
3265
- sendTransaction: (t) => jt(e, t),
3266
- signMessage: (t) => ro(e, t),
3267
- signTransaction: (t) => no(e, t),
3268
- signTypedData: (t) => so(e, t),
3269
- switchChain: (t) => ao(e, t),
3270
- watchAsset: (t) => oo(e, t),
3271
- writeContract: (t) => vn(e, t)
3272
- };
3273
- }
3274
- function go(e) {
3275
- const { key: t = "wallet", name: r = "Wallet Client", transport: n } = e;
3276
- return Zt({
3277
- ...e,
3278
- key: t,
3279
- name: r,
3280
- transport: n,
3281
- type: "walletClient"
3282
- }).extend(io);
3283
- }
3284
- export {
3285
- mo as a,
3286
- Un as b,
3287
- go as c,
3288
- lo as h
3289
- };
3290
- //# sourceMappingURL=createWalletClient-D74YRepQ.js.map