@directcryptopay/sdk 0.2.4 → 0.3.0

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