@pufferfinance/puffer-sdk 1.9.0 → 1.10.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 (192) hide show
  1. package/dist/api/puffer-client-helpers.cjs +1 -1
  2. package/dist/api/puffer-client-helpers.cjs.map +1 -1
  3. package/dist/api/puffer-client-helpers.js +82 -81
  4. package/dist/api/puffer-client-helpers.js.map +1 -1
  5. package/dist/api/puffer-client.cjs +1 -1
  6. package/dist/api/puffer-client.cjs.map +1 -1
  7. package/dist/api/puffer-client.js +2 -2
  8. package/dist/api/puffer-client.js.map +1 -1
  9. package/dist/ccip-BO_b9tFc.cjs +2 -0
  10. package/dist/ccip-BO_b9tFc.cjs.map +1 -0
  11. package/dist/ccip-DLDO0_x2.js +148 -0
  12. package/dist/ccip-DLDO0_x2.js.map +1 -0
  13. package/dist/chains/constants.cjs +1 -1
  14. package/dist/chains/constants.js +1 -1
  15. package/dist/constants-BjRNQpT2.js +1997 -0
  16. package/dist/constants-BjRNQpT2.js.map +1 -0
  17. package/dist/constants-DA2xUb9r.cjs +9 -0
  18. package/dist/constants-DA2xUb9r.cjs.map +1 -0
  19. package/dist/contracts/abis/holesky/PufferDepositor.cjs.map +1 -1
  20. package/dist/contracts/abis/holesky/PufferDepositor.js.map +1 -1
  21. package/dist/contracts/abis/holesky/PufferVaultV2.cjs.map +1 -1
  22. package/dist/contracts/abis/holesky/PufferVaultV2.js.map +1 -1
  23. package/dist/contracts/abis/l1-reward-manager-abis.cjs +1 -1
  24. package/dist/contracts/abis/l1-reward-manager-abis.cjs.map +1 -1
  25. package/dist/contracts/abis/l1-reward-manager-abis.js +1 -1
  26. package/dist/contracts/abis/l2-reward-manager-abis.cjs +1 -1
  27. package/dist/contracts/abis/l2-reward-manager-abis.cjs.map +1 -1
  28. package/dist/contracts/abis/l2-reward-manager-abis.js +1 -1
  29. package/dist/contracts/abis/mainnet/Accountant.cjs.map +1 -1
  30. package/dist/contracts/abis/mainnet/Accountant.js.map +1 -1
  31. package/dist/contracts/abis/mainnet/AtomicQueue.cjs.map +1 -1
  32. package/dist/contracts/abis/mainnet/AtomicQueue.js.map +1 -1
  33. package/dist/contracts/abis/mainnet/BoringVault.cjs.map +1 -1
  34. package/dist/contracts/abis/mainnet/BoringVault.js.map +1 -1
  35. package/dist/contracts/abis/mainnet/ERC20Permit.cjs.map +1 -1
  36. package/dist/contracts/abis/mainnet/ERC20Permit.js.map +1 -1
  37. package/dist/contracts/abis/mainnet/L1RewardManager.cjs.map +1 -1
  38. package/dist/contracts/abis/mainnet/L1RewardManager.js.map +1 -1
  39. package/dist/contracts/abis/mainnet/L2RewardManager.cjs.map +1 -1
  40. package/dist/contracts/abis/mainnet/L2RewardManager.js.map +1 -1
  41. package/dist/contracts/abis/mainnet/PufLocker.cjs.map +1 -1
  42. package/dist/contracts/abis/mainnet/PufLocker.js.map +1 -1
  43. package/dist/contracts/abis/mainnet/PufferDepositor.cjs.map +1 -1
  44. package/dist/contracts/abis/mainnet/PufferDepositor.js.map +1 -1
  45. package/dist/contracts/abis/mainnet/PufferL2Depositor.cjs.map +1 -1
  46. package/dist/contracts/abis/mainnet/PufferL2Depositor.js.map +1 -1
  47. package/dist/contracts/abis/mainnet/PufferVaultV2.cjs.map +1 -1
  48. package/dist/contracts/abis/mainnet/PufferVaultV2.js.map +1 -1
  49. package/dist/contracts/abis/mainnet/PufferWithdrawalManager.cjs.map +1 -1
  50. package/dist/contracts/abis/mainnet/PufferWithdrawalManager.js.map +1 -1
  51. package/dist/contracts/abis/mainnet/Teller.cjs.map +1 -1
  52. package/dist/contracts/abis/mainnet/Teller.js.map +1 -1
  53. package/dist/contracts/abis/nucleus-accountant-abis.cjs +1 -1
  54. package/dist/contracts/abis/nucleus-accountant-abis.cjs.map +1 -1
  55. package/dist/contracts/abis/nucleus-accountant-abis.js +1 -1
  56. package/dist/contracts/abis/nucleus-atomic-queue-abis.cjs +1 -1
  57. package/dist/contracts/abis/nucleus-atomic-queue-abis.cjs.map +1 -1
  58. package/dist/contracts/abis/nucleus-atomic-queue-abis.js +1 -1
  59. package/dist/contracts/abis/nucleus-boring-vault-abis.cjs +1 -1
  60. package/dist/contracts/abis/nucleus-boring-vault-abis.cjs.map +1 -1
  61. package/dist/contracts/abis/nucleus-boring-vault-abis.js +1 -1
  62. package/dist/contracts/abis/nucleus-teller-abis.cjs +1 -1
  63. package/dist/contracts/abis/nucleus-teller-abis.cjs.map +1 -1
  64. package/dist/contracts/abis/nucleus-teller-abis.js +1 -1
  65. package/dist/contracts/abis/puf-locker-abis.cjs +1 -1
  66. package/dist/contracts/abis/puf-locker-abis.cjs.map +1 -1
  67. package/dist/contracts/abis/puf-locker-abis.js +1 -1
  68. package/dist/contracts/abis/puffer-depositor-abis.cjs +1 -1
  69. package/dist/contracts/abis/puffer-depositor-abis.cjs.map +1 -1
  70. package/dist/contracts/abis/puffer-depositor-abis.js +1 -1
  71. package/dist/contracts/abis/puffer-depositor-abis.js.map +1 -1
  72. package/dist/contracts/abis/puffer-vault-abis.cjs +1 -1
  73. package/dist/contracts/abis/puffer-vault-abis.cjs.map +1 -1
  74. package/dist/contracts/abis/puffer-vault-abis.js +1 -1
  75. package/dist/contracts/abis/puffer-vault-abis.js.map +1 -1
  76. package/dist/contracts/abis/puffer-withdrawal-manager-abis.cjs +1 -1
  77. package/dist/contracts/abis/puffer-withdrawal-manager-abis.cjs.map +1 -1
  78. package/dist/contracts/abis/puffer-withdrawal-manager-abis.js +1 -1
  79. package/dist/contracts/addresses.cjs +1 -1
  80. package/dist/contracts/addresses.cjs.map +1 -1
  81. package/dist/contracts/addresses.d.ts +26 -12
  82. package/dist/contracts/addresses.js +29 -12
  83. package/dist/contracts/addresses.js.map +1 -1
  84. package/dist/contracts/handlers/erc20-permit-handler.cjs +1 -1
  85. package/dist/contracts/handlers/erc20-permit-handler.cjs.map +1 -1
  86. package/dist/contracts/handlers/erc20-permit-handler.d.ts +11128 -2714
  87. package/dist/contracts/handlers/erc20-permit-handler.js +3 -3
  88. package/dist/contracts/handlers/erc20-permit-handler.js.map +1 -1
  89. package/dist/contracts/handlers/l1-reward-manager-handler.cjs +1 -1
  90. package/dist/contracts/handlers/l1-reward-manager-handler.cjs.map +1 -1
  91. package/dist/contracts/handlers/l1-reward-manager-handler.d.ts +11128 -2714
  92. package/dist/contracts/handlers/l1-reward-manager-handler.js +2 -2
  93. package/dist/contracts/handlers/l1-reward-manager-handler.js.map +1 -1
  94. package/dist/contracts/handlers/l2-reward-manager-handler.cjs +1 -1
  95. package/dist/contracts/handlers/l2-reward-manager-handler.cjs.map +1 -1
  96. package/dist/contracts/handlers/l2-reward-manager-handler.d.ts +11128 -2714
  97. package/dist/contracts/handlers/l2-reward-manager-handler.js +2 -2
  98. package/dist/contracts/handlers/l2-reward-manager-handler.js.map +1 -1
  99. package/dist/contracts/handlers/nucleus-accountant-handler.cjs +1 -1
  100. package/dist/contracts/handlers/nucleus-accountant-handler.cjs.map +1 -1
  101. package/dist/contracts/handlers/nucleus-accountant-handler.d.ts +11173 -2749
  102. package/dist/contracts/handlers/nucleus-accountant-handler.js +26 -11
  103. package/dist/contracts/handlers/nucleus-accountant-handler.js.map +1 -1
  104. package/dist/contracts/handlers/nucleus-atomic-queue-handler.cjs +1 -1
  105. package/dist/contracts/handlers/nucleus-atomic-queue-handler.cjs.map +1 -1
  106. package/dist/contracts/handlers/nucleus-atomic-queue-handler.d.ts +11128 -2714
  107. package/dist/contracts/handlers/nucleus-atomic-queue-handler.js +5 -5
  108. package/dist/contracts/handlers/nucleus-atomic-queue-handler.js.map +1 -1
  109. package/dist/contracts/handlers/nucleus-boring-vault-handler.cjs +1 -1
  110. package/dist/contracts/handlers/nucleus-boring-vault-handler.cjs.map +1 -1
  111. package/dist/contracts/handlers/nucleus-boring-vault-handler.d.ts +11187 -2769
  112. package/dist/contracts/handlers/nucleus-boring-vault-handler.js +39 -35
  113. package/dist/contracts/handlers/nucleus-boring-vault-handler.js.map +1 -1
  114. package/dist/contracts/handlers/nucleus-teller-handler.cjs +1 -1
  115. package/dist/contracts/handlers/nucleus-teller-handler.cjs.map +1 -1
  116. package/dist/contracts/handlers/nucleus-teller-handler.d.ts +11172 -2749
  117. package/dist/contracts/handlers/nucleus-teller-handler.js +30 -19
  118. package/dist/contracts/handlers/nucleus-teller-handler.js.map +1 -1
  119. package/dist/contracts/handlers/puf-locker-handler.cjs +1 -1
  120. package/dist/contracts/handlers/puf-locker-handler.cjs.map +1 -1
  121. package/dist/contracts/handlers/puf-locker-handler.d.ts +11128 -2714
  122. package/dist/contracts/handlers/puf-locker-handler.js +2 -2
  123. package/dist/contracts/handlers/puf-locker-handler.js.map +1 -1
  124. package/dist/contracts/handlers/puffer-depositor-handler.cjs +1 -1
  125. package/dist/contracts/handlers/puffer-depositor-handler.cjs.map +1 -1
  126. package/dist/contracts/handlers/puffer-depositor-handler.d.ts +11128 -2714
  127. package/dist/contracts/handlers/puffer-depositor-handler.js +2 -2
  128. package/dist/contracts/handlers/puffer-depositor-handler.js.map +1 -1
  129. package/dist/contracts/handlers/puffer-l2-depositor-handler.cjs +1 -1
  130. package/dist/contracts/handlers/puffer-l2-depositor-handler.cjs.map +1 -1
  131. package/dist/contracts/handlers/puffer-l2-depositor-handler.d.ts +11128 -2714
  132. package/dist/contracts/handlers/puffer-l2-depositor-handler.js +2 -2
  133. package/dist/contracts/handlers/puffer-l2-depositor-handler.js.map +1 -1
  134. package/dist/contracts/handlers/puffer-vault-handler.cjs +1 -1
  135. package/dist/contracts/handlers/puffer-vault-handler.cjs.map +1 -1
  136. package/dist/contracts/handlers/puffer-vault-handler.d.ts +11128 -2714
  137. package/dist/contracts/handlers/puffer-vault-handler.js +2 -2
  138. package/dist/contracts/handlers/puffer-vault-handler.js.map +1 -1
  139. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.cjs +1 -1
  140. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.cjs.map +1 -1
  141. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.d.ts +11128 -2714
  142. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.js +2 -2
  143. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.js.map +1 -1
  144. package/dist/contracts/tokens.cjs +1 -1
  145. package/dist/contracts/tokens.cjs.map +1 -1
  146. package/dist/contracts/tokens.d.ts +8 -2
  147. package/dist/contracts/tokens.js +40 -10
  148. package/dist/contracts/tokens.js.map +1 -1
  149. package/dist/createWalletClient-BuLYysrp.cjs +4 -0
  150. package/dist/createWalletClient-BuLYysrp.cjs.map +1 -0
  151. package/dist/createWalletClient-DNcW-ENe.js +2028 -0
  152. package/dist/createWalletClient-DNcW-ENe.js.map +1 -0
  153. package/dist/errors/base-error.cjs.map +1 -1
  154. package/dist/errors/base-error.js.map +1 -1
  155. package/dist/{getContract-MrPLx6gp.cjs → getContract-3QbyfZBF.cjs} +2 -2
  156. package/dist/getContract-3QbyfZBF.cjs.map +1 -0
  157. package/dist/{getContract-B3Spz0SO.js → getContract-CezEyDf-.js} +2 -2
  158. package/dist/{getContract-MrPLx6gp.cjs.map → getContract-CezEyDf-.js.map} +1 -1
  159. package/dist/main.cjs +1 -1
  160. package/dist/main.js +24 -23
  161. package/dist/secp256k1-3OC5y4qp.js +1579 -0
  162. package/dist/secp256k1-3OC5y4qp.js.map +1 -0
  163. package/dist/secp256k1-bcahnPX9.cjs +2 -0
  164. package/dist/secp256k1-bcahnPX9.cjs.map +1 -0
  165. package/dist/utils/version.cjs +1 -1
  166. package/dist/utils/version.js +1 -1
  167. package/dist/writeContract-ChuHpJLC.js +3799 -0
  168. package/dist/writeContract-ChuHpJLC.js.map +1 -0
  169. package/dist/writeContract-D97dSJQe.cjs +32 -0
  170. package/dist/writeContract-D97dSJQe.cjs.map +1 -0
  171. package/package.json +13 -13
  172. package/dist/ccip-D4klNwCt.js +0 -159
  173. package/dist/ccip-D4klNwCt.js.map +0 -1
  174. package/dist/ccip-DLDqFodf.cjs +0 -2
  175. package/dist/ccip-DLDqFodf.cjs.map +0 -1
  176. package/dist/constants-BvU-JhfL.cjs +0 -9
  177. package/dist/constants-BvU-JhfL.cjs.map +0 -1
  178. package/dist/constants-rWWWhxR_.js +0 -2099
  179. package/dist/constants-rWWWhxR_.js.map +0 -1
  180. package/dist/createWalletClient-Bmopj8MM.cjs +0 -4
  181. package/dist/createWalletClient-Bmopj8MM.cjs.map +0 -1
  182. package/dist/createWalletClient-DKcpswHR.js +0 -2007
  183. package/dist/createWalletClient-DKcpswHR.js.map +0 -1
  184. package/dist/getContract-B3Spz0SO.js.map +0 -1
  185. package/dist/secp256k1-BLbXMlpX.js +0 -1172
  186. package/dist/secp256k1-BLbXMlpX.js.map +0 -1
  187. package/dist/secp256k1-CFnFaJ0H.cjs +0 -2
  188. package/dist/secp256k1-CFnFaJ0H.cjs.map +0 -1
  189. package/dist/writeContract-BBHpAss8.cjs +0 -32
  190. package/dist/writeContract-BBHpAss8.cjs.map +0 -1
  191. package/dist/writeContract-RluxM31W.js +0 -3833
  192. package/dist/writeContract-RluxM31W.js.map +0 -1
@@ -1,2007 +0,0 @@
1
- import { g as C, r as D, p as Q, k as Nt, d as P, H, l as kt, U as te, S as Ie, C as Ne, P as ke, m as Ae, n as Pe, J as Be, L as ne, M as De, T as qe, R as Fe, o as Se, I as re, q as ae, t as _e, u as Me, v as $e, x as ze, y as He, z as At, A as Pt, B as je, D as Bt, E as U, F as fe, G as Oe, K as Ke, N as le, O as Le, Q as Dt, V as pe, W as Qe, X as qt, j as he, Y as Ft, Z as X, _ as Ue, $ as St, a0 as _t, a1 as Mt, h as Xe, a2 as Ye, a3 as $t, a4 as zt, i as et, a5 as Ht, a6 as _, a7 as Y, a8 as V, a9 as jt, aa as Ot, ab as Lt, ac as Ut, ad as me, ae as ge, af as tt, c as Gt, e as Wt, ag as Zt, ah as ye, a as Jt, ai as Vt, aj as Kt, ak as Qt, al as Xt, am as nt, an as rt, s as Yt, w as en, ao as at, ap as be, aq as tn, ar as nn, as as rn, b as an } from "./writeContract-RluxM31W.js";
2
- import { B as F, n as k, L as sn, k as A, d as K, i as M, f as O, j as se, l as j, c as we, m as q, o as on, q as ve, u as oe, v as cn, I as un, w as ie, x as st, y as L, z as dn, A as fn, D as ot, T as it, E as ln, F as ct, G as pn, J as ut, W as Ge, K as hn } from "./constants-rWWWhxR_.js";
3
- import { e as mn, s as gn } from "./secp256k1-BLbXMlpX.js";
4
- class yn extends F {
5
- constructor({ address: t }) {
6
- super(`No EIP-712 domain found on contract "${t}".`, {
7
- metaMessages: [
8
- "Ensure that:",
9
- `- The contract is deployed at the address "${t}".`,
10
- "- `eip712Domain()` function exists on the contract.",
11
- "- `eip712Domain()` function matches signature to ERC-5267 specification."
12
- ]
13
- }), Object.defineProperty(this, "name", {
14
- enumerable: !0,
15
- configurable: !0,
16
- writable: !0,
17
- value: "Eip712DomainNotFoundError"
18
- });
19
- }
20
- }
21
- async function bn(e, t) {
22
- const { address: n, factory: r, factoryData: s } = t;
23
- try {
24
- const [a, o, c, d, l, i, u] = await C(e, D, "readContract")({
25
- abi: wn,
26
- address: n,
27
- functionName: "eip712Domain",
28
- factory: r,
29
- factoryData: s
30
- });
31
- return {
32
- domain: {
33
- name: o,
34
- version: c,
35
- chainId: Number(d),
36
- verifyingContract: l,
37
- salt: i
38
- },
39
- extensions: u,
40
- fields: a
41
- };
42
- } catch (a) {
43
- const o = a;
44
- throw o.name === "ContractFunctionExecutionError" && o.cause.name === "ContractFunctionZeroDataError" ? new yn({ address: n }) : o;
45
- }
46
- }
47
- const wn = [
48
- {
49
- inputs: [],
50
- name: "eip712Domain",
51
- outputs: [
52
- { name: "fields", type: "bytes1" },
53
- { name: "name", type: "string" },
54
- { name: "version", type: "string" },
55
- { name: "chainId", type: "uint256" },
56
- { name: "verifyingContract", type: "address" },
57
- { name: "salt", type: "bytes32" },
58
- { name: "extensions", type: "uint256[]" }
59
- ],
60
- stateMutability: "view",
61
- type: "function"
62
- }
63
- ];
64
- async function vn(e, { chain: t }) {
65
- const { id: n, name: r, nativeCurrency: s, rpcUrls: a, blockExplorers: o } = t;
66
- await e.request({
67
- method: "wallet_addEthereumChain",
68
- params: [
69
- {
70
- chainId: k(n),
71
- chainName: r,
72
- nativeCurrency: s,
73
- rpcUrls: a.default.http,
74
- blockExplorerUrls: o ? Object.values(o).map(({ url: c }) => c) : void 0
75
- }
76
- ]
77
- }, { dedupe: !0, retryCount: 0 });
78
- }
79
- const ce = 256;
80
- let G = ce, W;
81
- function dt(e = 11) {
82
- if (!W || G + e > ce * 2) {
83
- W = "", G = 0;
84
- for (let t = 0; t < ce; t++)
85
- W += (256 + Math.random() * 256 | 0).toString(16).substring(1);
86
- }
87
- return W.substring(G, G++ + e);
88
- }
89
- function ft(e) {
90
- const { batch: t, cacheTime: n = e.pollingInterval ?? 4e3, ccipRead: r, key: s = "base", name: a = "Base Client", pollingInterval: o = 4e3, type: c = "base" } = e, d = e.chain, l = e.account ? Q(e.account) : void 0, { config: i, request: u, value: f } = e.transport({
91
- chain: d,
92
- pollingInterval: o
93
- }), h = { ...i, ...f }, y = {
94
- account: l,
95
- batch: t,
96
- cacheTime: n,
97
- ccipRead: r,
98
- chain: d,
99
- key: s,
100
- name: a,
101
- pollingInterval: o,
102
- request: u,
103
- transport: h,
104
- type: c,
105
- uid: dt()
106
- };
107
- function g(b) {
108
- return (p) => {
109
- const m = p(b);
110
- for (const w in y)
111
- delete m[w];
112
- const v = { ...b, ...m };
113
- return Object.assign(v, { extend: g(v) });
114
- };
115
- }
116
- return Object.assign(y, { extend: g(y) });
117
- }
118
- const Z = /* @__PURE__ */ new sn(8192);
119
- function Tn(e, { enabled: t = !0, id: n }) {
120
- if (!t || !n)
121
- return e();
122
- if (Z.get(n))
123
- return Z.get(n);
124
- const r = e().finally(() => Z.delete(n));
125
- return Z.set(n, r), r;
126
- }
127
- function ue(e, { delay: t = 100, retryCount: n = 2, shouldRetry: r = () => !0 } = {}) {
128
- return new Promise((s, a) => {
129
- const o = async ({ count: c = 0 } = {}) => {
130
- const d = async ({ error: l }) => {
131
- const i = typeof t == "function" ? t({ count: c, error: l }) : t;
132
- i && await Nt(i), o({ count: c + 1 });
133
- };
134
- try {
135
- const l = await e();
136
- s(l);
137
- } catch (l) {
138
- if (c < n && await r({ count: c, error: l }))
139
- return d({ error: l });
140
- a(l);
141
- }
142
- };
143
- o();
144
- });
145
- }
146
- function Rn(e, t = {}) {
147
- return async (n, r = {}) => {
148
- const { dedupe: s = !1, retryDelay: a = 150, retryCount: o = 3, uid: c } = {
149
- ...t,
150
- ...r
151
- }, d = s ? A(K(`${c}.${P(n)}`)) : void 0;
152
- return Tn(() => ue(async () => {
153
- try {
154
- return await e(n);
155
- } catch (l) {
156
- const i = l;
157
- switch (i.code) {
158
- case ze.code:
159
- throw new ze(i);
160
- case $e.code:
161
- throw new $e(i);
162
- case Me.code:
163
- throw new Me(i, { method: n.method });
164
- case _e.code:
165
- throw new _e(i);
166
- case ae.code:
167
- throw new ae(i);
168
- case re.code:
169
- throw new re(i);
170
- case Se.code:
171
- throw new Se(i);
172
- case Fe.code:
173
- throw new Fe(i);
174
- case qe.code:
175
- throw new qe(i);
176
- case De.code:
177
- throw new De(i, {
178
- method: n.method
179
- });
180
- case ne.code:
181
- throw new ne(i);
182
- case Be.code:
183
- throw new Be(i);
184
- case te.code:
185
- throw new te(i);
186
- case Pe.code:
187
- throw new Pe(i);
188
- case Ae.code:
189
- throw new Ae(i);
190
- case ke.code:
191
- throw new ke(i);
192
- case Ne.code:
193
- throw new Ne(i);
194
- case Ie.code:
195
- throw new Ie(i);
196
- case 5e3:
197
- throw new te(i);
198
- default:
199
- throw l instanceof F ? l : new kt(i);
200
- }
201
- }
202
- }, {
203
- delay: ({ count: l, error: i }) => {
204
- var u;
205
- if (i && i instanceof H) {
206
- const f = (u = i == null ? void 0 : i.headers) == null ? void 0 : u.get("Retry-After");
207
- if (f != null && f.match(/\d/))
208
- return Number.parseInt(f) * 1e3;
209
- }
210
- return ~~(1 << l) * a;
211
- },
212
- retryCount: o,
213
- shouldRetry: ({ error: l }) => Cn(l)
214
- }), { enabled: s, id: d });
215
- };
216
- }
217
- function Cn(e) {
218
- return "code" in e && typeof e.code == "number" ? e.code === -1 || e.code === ne.code || e.code === ae.code : e instanceof H && e.status ? e.status === 403 || e.status === 408 || e.status === 413 || e.status === 429 || e.status === 500 || e.status === 502 || e.status === 503 || e.status === 504 : !0;
219
- }
220
- function En({ key: e, name: t, request: n, retryCount: r = 3, retryDelay: s = 150, timeout: a, type: o }, c) {
221
- const d = dt();
222
- return {
223
- config: {
224
- key: e,
225
- name: t,
226
- request: n,
227
- retryCount: r,
228
- retryDelay: s,
229
- timeout: a,
230
- type: o
231
- },
232
- request: Rn(n, { retryCount: r, retryDelay: s, uid: d }),
233
- value: c
234
- };
235
- }
236
- class xn extends F {
237
- constructor() {
238
- super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.", {
239
- docsPath: "/docs/clients/intro"
240
- });
241
- }
242
- }
243
- function In(e, { errorInstance: t = new Error("timed out"), timeout: n, signal: r }) {
244
- return new Promise((s, a) => {
245
- (async () => {
246
- let o;
247
- try {
248
- const c = new AbortController();
249
- n > 0 && (o = setTimeout(() => {
250
- r ? c.abort() : a(t);
251
- }, n)), s(await e({ signal: (c == null ? void 0 : c.signal) || null }));
252
- } catch (c) {
253
- (c == null ? void 0 : c.name) === "AbortError" && a(t), a(c);
254
- } finally {
255
- clearTimeout(o);
256
- }
257
- })();
258
- });
259
- }
260
- function Nn() {
261
- return {
262
- current: 0,
263
- take() {
264
- return this.current++;
265
- },
266
- reset() {
267
- this.current = 0;
268
- }
269
- };
270
- }
271
- const We = /* @__PURE__ */ Nn();
272
- function kn(e, t = {}) {
273
- return {
274
- async request(n) {
275
- var u;
276
- const { body: r, onRequest: s = t.onRequest, onResponse: a = t.onResponse, timeout: o = t.timeout ?? 1e4 } = n, c = {
277
- ...t.fetchOptions ?? {},
278
- ...n.fetchOptions ?? {}
279
- }, { headers: d, method: l, signal: i } = c;
280
- try {
281
- const f = await In(async ({ signal: y }) => {
282
- const g = {
283
- ...c,
284
- body: Array.isArray(r) ? P(r.map((m) => ({
285
- jsonrpc: "2.0",
286
- id: m.id ?? We.take(),
287
- ...m
288
- }))) : P({
289
- jsonrpc: "2.0",
290
- id: r.id ?? We.take(),
291
- ...r
292
- }),
293
- headers: {
294
- "Content-Type": "application/json",
295
- ...d
296
- },
297
- method: l || "POST",
298
- signal: i || (o > 0 ? y : null)
299
- }, b = new Request(e, g);
300
- return s && await s(b), await fetch(e, g);
301
- }, {
302
- errorInstance: new He({ body: r, url: e }),
303
- timeout: o,
304
- signal: !0
305
- });
306
- a && await a(f);
307
- let h;
308
- if ((u = f.headers.get("Content-Type")) != null && u.startsWith("application/json") ? h = await f.json() : (h = await f.text(), h = JSON.parse(h || "{}")), !f.ok)
309
- throw new H({
310
- body: r,
311
- details: P(h.error) || f.statusText,
312
- headers: f.headers,
313
- status: f.status,
314
- url: e
315
- });
316
- return h;
317
- } catch (f) {
318
- throw f instanceof H || f instanceof He ? f : new H({
319
- body: r,
320
- cause: f,
321
- url: e
322
- });
323
- }
324
- }
325
- };
326
- }
327
- function Jr(e, t = {}) {
328
- const { batch: n, fetchOptions: r, key: s = "http", name: a = "HTTP JSON-RPC", onFetchRequest: o, onFetchResponse: c, retryDelay: d } = t;
329
- return ({ chain: l, retryCount: i, timeout: u }) => {
330
- const { batchSize: f = 1e3, wait: h = 0 } = typeof n == "object" ? n : {}, y = t.retryCount ?? i, g = u ?? t.timeout ?? 1e4, b = e || (l == null ? void 0 : l.rpcUrls.default.http[0]);
331
- if (!b)
332
- throw new xn();
333
- const p = kn(b, {
334
- fetchOptions: r,
335
- onRequest: o,
336
- onResponse: c,
337
- timeout: g
338
- });
339
- return En({
340
- key: s,
341
- name: a,
342
- async request({ method: m, params: v }) {
343
- const w = { method: m, params: v }, { schedule: I } = Pt({
344
- id: b,
345
- wait: h,
346
- shouldSplitBatch(x) {
347
- return x.length > f;
348
- },
349
- fn: (x) => p.request({
350
- body: x
351
- }),
352
- sort: (x, N) => x.id - N.id
353
- }), R = async (x) => n ? I(x) : [
354
- await p.request({
355
- body: x
356
- })
357
- ], [{ error: T, result: E }] = await R(w);
358
- if (T)
359
- throw new At({
360
- body: w,
361
- error: T,
362
- url: b
363
- });
364
- return E;
365
- },
366
- retryCount: y,
367
- retryDelay: d,
368
- timeout: g,
369
- type: "http"
370
- }, {
371
- fetchOptions: r,
372
- url: b
373
- });
374
- };
375
- }
376
- function Te(e, t) {
377
- var r, s, a, o, c, d;
378
- if (!(e instanceof F))
379
- return !1;
380
- const n = e.walk((l) => l instanceof je);
381
- return n instanceof je ? !!(((r = n.data) == null ? void 0 : r.errorName) === "ResolverNotFound" || ((s = n.data) == null ? void 0 : s.errorName) === "ResolverWildcardNotSupported" || ((a = n.data) == null ? void 0 : a.errorName) === "ResolverNotContract" || ((o = n.data) == null ? void 0 : o.errorName) === "ResolverError" || ((c = n.data) == null ? void 0 : c.errorName) === "HttpError" || (d = n.reason) != null && d.includes("Wildcard on non-extended resolvers is not supported") || t === "reverse" && n.reason === Bt[50]) : !1;
382
- }
383
- function lt(e) {
384
- if (e.length !== 66 || e.indexOf("[") !== 0 || e.indexOf("]") !== 65)
385
- return null;
386
- const t = `0x${e.slice(1, 65)}`;
387
- return M(t) ? t : null;
388
- }
389
- function J(e) {
390
- let t = new Uint8Array(32).fill(0);
391
- if (!e)
392
- return O(t);
393
- const n = e.split(".");
394
- for (let r = n.length - 1; r >= 0; r -= 1) {
395
- const s = lt(n[r]), a = s ? se(s) : A(j(n[r]), "bytes");
396
- t = A(we([t, a]), "bytes");
397
- }
398
- return O(t);
399
- }
400
- function An(e) {
401
- return `[${e.slice(2)}]`;
402
- }
403
- function Pn(e) {
404
- const t = new Uint8Array(32).fill(0);
405
- return e ? lt(e) || A(j(e)) : O(t);
406
- }
407
- function ee(e) {
408
- const t = e.replace(/^\.|\.$/gm, "");
409
- if (t.length === 0)
410
- return new Uint8Array(1);
411
- const n = new Uint8Array(j(t).byteLength + 2);
412
- let r = 0;
413
- const s = t.split(".");
414
- for (let a = 0; a < s.length; a++) {
415
- let o = j(s[a]);
416
- o.byteLength > 255 && (o = j(An(Pn(s[a])))), n[r] = o.length, n.set(o, r + 1), r += o.length + 1;
417
- }
418
- return n.byteLength !== r + 1 ? n.slice(0, r + 1) : n;
419
- }
420
- async function Bn(e, { blockNumber: t, blockTag: n, coinType: r, name: s, gatewayUrls: a, strict: o, universalResolverAddress: c }) {
421
- let d = c;
422
- if (!d) {
423
- if (!e.chain)
424
- throw new Error("client chain not configured. universalResolverAddress is required.");
425
- d = U({
426
- blockNumber: t,
427
- chain: e.chain,
428
- contract: "ensUniversalResolver"
429
- });
430
- }
431
- try {
432
- const l = fe({
433
- abi: Oe,
434
- functionName: "addr",
435
- ...r != null ? { args: [J(s), BigInt(r)] } : { args: [J(s)] }
436
- }), i = {
437
- address: d,
438
- abi: Ke,
439
- functionName: "resolve",
440
- args: [q(ee(s)), l],
441
- blockNumber: t,
442
- blockTag: n
443
- }, u = C(e, D, "readContract"), f = a ? await u({
444
- ...i,
445
- args: [...i.args, a]
446
- }) : await u(i);
447
- if (f[0] === "0x")
448
- return null;
449
- const h = le({
450
- abi: Oe,
451
- args: r != null ? [J(s), BigInt(r)] : void 0,
452
- functionName: "addr",
453
- data: f[0]
454
- });
455
- return h === "0x" || on(h) === "0x00" ? null : h;
456
- } catch (l) {
457
- if (o)
458
- throw l;
459
- if (Te(l, "resolve"))
460
- return null;
461
- throw l;
462
- }
463
- }
464
- class Dn extends F {
465
- constructor({ data: t }) {
466
- super("Unable to extract image from metadata. The metadata may be malformed or invalid.", {
467
- metaMessages: [
468
- "- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.",
469
- "",
470
- `Provided data: ${JSON.stringify(t)}`
471
- ]
472
- }), Object.defineProperty(this, "name", {
473
- enumerable: !0,
474
- configurable: !0,
475
- writable: !0,
476
- value: "EnsAvatarInvalidMetadataError"
477
- });
478
- }
479
- }
480
- class z extends F {
481
- constructor({ reason: t }) {
482
- super(`ENS NFT avatar URI is invalid. ${t}`), Object.defineProperty(this, "name", {
483
- enumerable: !0,
484
- configurable: !0,
485
- writable: !0,
486
- value: "EnsAvatarInvalidNftUriError"
487
- });
488
- }
489
- }
490
- class Re extends F {
491
- constructor({ uri: t }) {
492
- super(`Unable to resolve ENS avatar URI "${t}". The URI may be malformed, invalid, or does not respond with a valid image.`), Object.defineProperty(this, "name", {
493
- enumerable: !0,
494
- configurable: !0,
495
- writable: !0,
496
- value: "EnsAvatarUriResolutionError"
497
- });
498
- }
499
- }
500
- class qn extends F {
501
- constructor({ namespace: t }) {
502
- super(`ENS NFT avatar namespace "${t}" is not supported. Must be "erc721" or "erc1155".`), Object.defineProperty(this, "name", {
503
- enumerable: !0,
504
- configurable: !0,
505
- writable: !0,
506
- value: "EnsAvatarUnsupportedNamespaceError"
507
- });
508
- }
509
- }
510
- const Fn = /(?<protocol>https?:\/\/[^\/]*|ipfs:\/|ipns:\/|ar:\/)?(?<root>\/)?(?<subpath>ipfs\/|ipns\/)?(?<target>[\w\-.]+)(?<subtarget>\/.*)?/, Sn = /^(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>\/.*)?$/, _n = /^data:([a-zA-Z\-/+]*);base64,([^"].*)/, Mn = /^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;
511
- async function $n(e) {
512
- try {
513
- const t = await fetch(e, { method: "HEAD" });
514
- if (t.status === 200) {
515
- const n = t.headers.get("content-type");
516
- return n == null ? void 0 : n.startsWith("image/");
517
- }
518
- return !1;
519
- } catch (t) {
520
- return typeof t == "object" && typeof t.response < "u" || !globalThis.hasOwnProperty("Image") ? !1 : new Promise((n) => {
521
- const r = new Image();
522
- r.onload = () => {
523
- n(!0);
524
- }, r.onerror = () => {
525
- n(!1);
526
- }, r.src = e;
527
- });
528
- }
529
- }
530
- function Ze(e, t) {
531
- return e ? e.endsWith("/") ? e.slice(0, -1) : e : t;
532
- }
533
- function pt({ uri: e, gatewayUrls: t }) {
534
- const n = _n.test(e);
535
- if (n)
536
- return { uri: e, isOnChain: !0, isEncoded: n };
537
- const r = Ze(t == null ? void 0 : t.ipfs, "https://ipfs.io"), s = Ze(t == null ? void 0 : t.arweave, "https://arweave.net"), a = e.match(Fn), { protocol: o, subpath: c, target: d, subtarget: l = "" } = (a == null ? void 0 : a.groups) || {}, i = o === "ipns:/" || c === "ipns/", u = o === "ipfs:/" || c === "ipfs/" || Sn.test(e);
538
- if (e.startsWith("http") && !i && !u) {
539
- let h = e;
540
- return t != null && t.arweave && (h = e.replace(/https:\/\/arweave.net/g, t == null ? void 0 : t.arweave)), { uri: h, isOnChain: !1, isEncoded: !1 };
541
- }
542
- if ((i || u) && d)
543
- return {
544
- uri: `${r}/${i ? "ipns" : "ipfs"}/${d}${l}`,
545
- isOnChain: !1,
546
- isEncoded: !1
547
- };
548
- if (o === "ar:/" && d)
549
- return {
550
- uri: `${s}/${d}${l || ""}`,
551
- isOnChain: !1,
552
- isEncoded: !1
553
- };
554
- let f = e.replace(Mn, "");
555
- if (f.startsWith("<svg") && (f = `data:image/svg+xml;base64,${btoa(f)}`), f.startsWith("data:") || f.startsWith("{"))
556
- return {
557
- uri: f,
558
- isOnChain: !0,
559
- isEncoded: !1
560
- };
561
- throw new Re({ uri: e });
562
- }
563
- function ht(e) {
564
- if (typeof e != "object" || !("image" in e) && !("image_url" in e) && !("image_data" in e))
565
- throw new Dn({ data: e });
566
- return e.image || e.image_url || e.image_data;
567
- }
568
- async function zn({ gatewayUrls: e, uri: t }) {
569
- try {
570
- const n = await fetch(t).then((s) => s.json());
571
- return await Ce({
572
- gatewayUrls: e,
573
- uri: ht(n)
574
- });
575
- } catch {
576
- throw new Re({ uri: t });
577
- }
578
- }
579
- async function Ce({ gatewayUrls: e, uri: t }) {
580
- const { uri: n, isOnChain: r } = pt({ uri: t, gatewayUrls: e });
581
- if (r || await $n(n))
582
- return n;
583
- throw new Re({ uri: t });
584
- }
585
- function Hn(e) {
586
- let t = e;
587
- t.startsWith("did:nft:") && (t = t.replace("did:nft:", "").replace(/_/g, "/"));
588
- const [n, r, s] = t.split("/"), [a, o] = n.split(":"), [c, d] = r.split(":");
589
- if (!a || a.toLowerCase() !== "eip155")
590
- throw new z({ reason: "Only EIP-155 supported" });
591
- if (!o)
592
- throw new z({ reason: "Chain ID not found" });
593
- if (!d)
594
- throw new z({
595
- reason: "Contract address not found"
596
- });
597
- if (!s)
598
- throw new z({ reason: "Token ID not found" });
599
- if (!c)
600
- throw new z({ reason: "ERC namespace not found" });
601
- return {
602
- chainID: Number.parseInt(o),
603
- namespace: c.toLowerCase(),
604
- contractAddress: d,
605
- tokenID: s
606
- };
607
- }
608
- async function jn(e, { nft: t }) {
609
- if (t.namespace === "erc721")
610
- return D(e, {
611
- address: t.contractAddress,
612
- abi: [
613
- {
614
- name: "tokenURI",
615
- type: "function",
616
- stateMutability: "view",
617
- inputs: [{ name: "tokenId", type: "uint256" }],
618
- outputs: [{ name: "", type: "string" }]
619
- }
620
- ],
621
- functionName: "tokenURI",
622
- args: [BigInt(t.tokenID)]
623
- });
624
- if (t.namespace === "erc1155")
625
- return D(e, {
626
- address: t.contractAddress,
627
- abi: [
628
- {
629
- name: "uri",
630
- type: "function",
631
- stateMutability: "view",
632
- inputs: [{ name: "_id", type: "uint256" }],
633
- outputs: [{ name: "", type: "string" }]
634
- }
635
- ],
636
- functionName: "uri",
637
- args: [BigInt(t.tokenID)]
638
- });
639
- throw new qn({ namespace: t.namespace });
640
- }
641
- async function On(e, { gatewayUrls: t, record: n }) {
642
- return /eip155:/i.test(n) ? Ln(e, { gatewayUrls: t, record: n }) : Ce({ uri: n, gatewayUrls: t });
643
- }
644
- async function Ln(e, { gatewayUrls: t, record: n }) {
645
- const r = Hn(n), s = await jn(e, { nft: r }), { uri: a, isOnChain: o, isEncoded: c } = pt({ uri: s, gatewayUrls: t });
646
- if (o && (a.includes("data:application/json;base64,") || a.startsWith("{"))) {
647
- const l = c ? (
648
- // if it is encoded, decode it
649
- atob(a.replace("data:application/json;base64,", ""))
650
- ) : (
651
- // if it isn't encoded assume it is a JSON string, but it could be anything (it will error if it is)
652
- a
653
- ), i = JSON.parse(l);
654
- return Ce({ uri: ht(i), gatewayUrls: t });
655
- }
656
- let d = r.tokenID;
657
- return r.namespace === "erc1155" && (d = d.replace("0x", "").padStart(64, "0")), zn({
658
- gatewayUrls: t,
659
- uri: a.replace(/(?:0x)?{id}/, d)
660
- });
661
- }
662
- async function mt(e, { blockNumber: t, blockTag: n, name: r, key: s, gatewayUrls: a, strict: o, universalResolverAddress: c }) {
663
- let d = c;
664
- if (!d) {
665
- if (!e.chain)
666
- throw new Error("client chain not configured. universalResolverAddress is required.");
667
- d = U({
668
- blockNumber: t,
669
- chain: e.chain,
670
- contract: "ensUniversalResolver"
671
- });
672
- }
673
- try {
674
- const l = {
675
- address: d,
676
- abi: Ke,
677
- functionName: "resolve",
678
- args: [
679
- q(ee(r)),
680
- fe({
681
- abi: Le,
682
- functionName: "text",
683
- args: [J(r), s]
684
- })
685
- ],
686
- blockNumber: t,
687
- blockTag: n
688
- }, i = C(e, D, "readContract"), u = a ? await i({
689
- ...l,
690
- args: [...l.args, a]
691
- }) : await i(l);
692
- if (u[0] === "0x")
693
- return null;
694
- const f = le({
695
- abi: Le,
696
- functionName: "text",
697
- data: u[0]
698
- });
699
- return f === "" ? null : f;
700
- } catch (l) {
701
- if (o)
702
- throw l;
703
- if (Te(l, "resolve"))
704
- return null;
705
- throw l;
706
- }
707
- }
708
- async function Un(e, { blockNumber: t, blockTag: n, assetGatewayUrls: r, name: s, gatewayUrls: a, strict: o, universalResolverAddress: c }) {
709
- const d = await C(e, mt, "getEnsText")({
710
- blockNumber: t,
711
- blockTag: n,
712
- key: "avatar",
713
- name: s,
714
- universalResolverAddress: c,
715
- gatewayUrls: a,
716
- strict: o
717
- });
718
- if (!d)
719
- return null;
720
- try {
721
- return await On(e, {
722
- record: d,
723
- gatewayUrls: r
724
- });
725
- } catch {
726
- return null;
727
- }
728
- }
729
- async function Gn(e, { address: t, blockNumber: n, blockTag: r, gatewayUrls: s, strict: a, universalResolverAddress: o }) {
730
- let c = o;
731
- if (!c) {
732
- if (!e.chain)
733
- throw new Error("client chain not configured. universalResolverAddress is required.");
734
- c = U({
735
- blockNumber: n,
736
- chain: e.chain,
737
- contract: "ensUniversalResolver"
738
- });
739
- }
740
- const d = `${t.toLowerCase().substring(2)}.addr.reverse`;
741
- try {
742
- const l = {
743
- address: c,
744
- abi: Dt,
745
- functionName: "reverse",
746
- args: [q(ee(d))],
747
- blockNumber: n,
748
- blockTag: r
749
- }, i = C(e, D, "readContract"), [u, f] = s ? await i({
750
- ...l,
751
- args: [...l.args, s]
752
- }) : await i(l);
753
- return t.toLowerCase() !== f.toLowerCase() ? null : u;
754
- } catch (l) {
755
- if (a)
756
- throw l;
757
- if (Te(l, "reverse"))
758
- return null;
759
- throw l;
760
- }
761
- }
762
- async function Wn(e, { blockNumber: t, blockTag: n, name: r, universalResolverAddress: s }) {
763
- let a = s;
764
- if (!a) {
765
- if (!e.chain)
766
- throw new Error("client chain not configured. universalResolverAddress is required.");
767
- a = U({
768
- blockNumber: t,
769
- chain: e.chain,
770
- contract: "ensUniversalResolver"
771
- });
772
- }
773
- const [o] = await C(e, D, "readContract")({
774
- address: a,
775
- abi: [
776
- {
777
- inputs: [{ type: "bytes" }],
778
- name: "findResolver",
779
- outputs: [{ type: "address" }, { type: "bytes32" }],
780
- stateMutability: "view",
781
- type: "function"
782
- }
783
- ],
784
- functionName: "findResolver",
785
- args: [q(ee(r))],
786
- blockNumber: t,
787
- blockTag: n
788
- });
789
- return o;
790
- }
791
- async function Zn(e) {
792
- const t = pe(e, {
793
- method: "eth_newBlockFilter"
794
- }), n = await e.request({
795
- method: "eth_newBlockFilter"
796
- });
797
- return { id: n, request: t(n), type: "block" };
798
- }
799
- async function gt(e, { address: t, args: n, event: r, events: s, fromBlock: a, strict: o, toBlock: c } = {}) {
800
- const d = s ?? (r ? [r] : void 0), l = pe(e, {
801
- method: "eth_newFilter"
802
- });
803
- let i = [];
804
- d && (i = [d.flatMap((h) => Qe({
805
- abi: [h],
806
- eventName: h.name,
807
- args: n
808
- }))], r && (i = i[0]));
809
- const u = await e.request({
810
- method: "eth_newFilter",
811
- params: [
812
- {
813
- address: t,
814
- fromBlock: typeof a == "bigint" ? k(a) : a,
815
- toBlock: typeof c == "bigint" ? k(c) : c,
816
- ...i.length ? { topics: i } : {}
817
- }
818
- ]
819
- });
820
- return {
821
- abi: d,
822
- args: n,
823
- eventName: r ? r.name : void 0,
824
- fromBlock: a,
825
- id: u,
826
- request: l(u),
827
- strict: !!o,
828
- toBlock: c,
829
- type: "event"
830
- };
831
- }
832
- async function yt(e) {
833
- const t = pe(e, {
834
- method: "eth_newPendingTransactionFilter"
835
- }), n = await e.request({
836
- method: "eth_newPendingTransactionFilter"
837
- });
838
- return { id: n, request: t(n), type: "transaction" };
839
- }
840
- async function Jn(e, { address: t, blockNumber: n, blockTag: r = "latest" }) {
841
- const s = n ? k(n) : void 0, a = await e.request({
842
- method: "eth_getBalance",
843
- params: [t, s || r]
844
- });
845
- return BigInt(a);
846
- }
847
- async function Vn(e) {
848
- const t = await e.request({
849
- method: "eth_blobBaseFee"
850
- });
851
- return BigInt(t);
852
- }
853
- async function Kn(e, { blockHash: t, blockNumber: n, blockTag: r = "latest" } = {}) {
854
- const s = n !== void 0 ? k(n) : void 0;
855
- let a;
856
- return t ? a = await e.request({
857
- method: "eth_getBlockTransactionCountByHash",
858
- params: [t]
859
- }, { dedupe: !0 }) : a = await e.request({
860
- method: "eth_getBlockTransactionCountByNumber",
861
- params: [s || r]
862
- }, { dedupe: !!s }), ve(a);
863
- }
864
- async function Je(e, { address: t, blockNumber: n, blockTag: r = "latest" }) {
865
- const s = n !== void 0 ? k(n) : void 0, a = await e.request({
866
- method: "eth_getCode",
867
- params: [t, s || r]
868
- }, { dedupe: !!s });
869
- if (a !== "0x")
870
- return a;
871
- }
872
- function Qn(e) {
873
- var t;
874
- return {
875
- baseFeePerGas: e.baseFeePerGas.map((n) => BigInt(n)),
876
- gasUsedRatio: e.gasUsedRatio,
877
- oldestBlock: BigInt(e.oldestBlock),
878
- reward: (t = e.reward) == null ? void 0 : t.map((n) => n.map((r) => BigInt(r)))
879
- };
880
- }
881
- async function Xn(e, { blockCount: t, blockNumber: n, blockTag: r = "latest", rewardPercentiles: s }) {
882
- const a = n ? k(n) : void 0, o = await e.request({
883
- method: "eth_feeHistory",
884
- params: [
885
- k(t),
886
- a || r,
887
- s
888
- ]
889
- }, { dedupe: !!a });
890
- return Qn(o);
891
- }
892
- async function Yn(e, { filter: t }) {
893
- const n = t.strict ?? !1, s = (await t.request({
894
- method: "eth_getFilterLogs",
895
- params: [t.id]
896
- })).map((a) => oe(a));
897
- return t.abi ? qt({
898
- abi: t.abi,
899
- logs: s,
900
- strict: n
901
- }) : s;
902
- }
903
- const er = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/, tr = /^(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)?$/;
904
- function nr(e) {
905
- const { domain: t = {}, message: n, primaryType: r } = e, s = {
906
- EIP712Domain: Ct({ domain: t }),
907
- ...e.types
908
- };
909
- Rt({
910
- domain: t,
911
- message: n,
912
- primaryType: r,
913
- types: s
914
- });
915
- const a = ["0x1901"];
916
- return t && a.push(rr({
917
- domain: t,
918
- types: s
919
- })), r !== "EIP712Domain" && a.push(bt({
920
- data: n,
921
- primaryType: r,
922
- types: s
923
- })), A(we(a));
924
- }
925
- function rr({ domain: e, types: t }) {
926
- return bt({
927
- data: e,
928
- primaryType: "EIP712Domain",
929
- types: t
930
- });
931
- }
932
- function bt({ data: e, primaryType: t, types: n }) {
933
- const r = wt({
934
- data: e,
935
- primaryType: t,
936
- types: n
937
- });
938
- return A(r);
939
- }
940
- function wt({ data: e, primaryType: t, types: n }) {
941
- const r = [{ type: "bytes32" }], s = [ar({ primaryType: t, types: n })];
942
- for (const a of n[t]) {
943
- const [o, c] = Tt({
944
- types: n,
945
- name: a.name,
946
- type: a.type,
947
- value: e[a.name]
948
- });
949
- r.push(o), s.push(c);
950
- }
951
- return he(r, s);
952
- }
953
- function ar({ primaryType: e, types: t }) {
954
- const n = q(sr({ primaryType: e, types: t }));
955
- return A(n);
956
- }
957
- function sr({ primaryType: e, types: t }) {
958
- let n = "";
959
- const r = vt({ primaryType: e, types: t });
960
- r.delete(e);
961
- const s = [e, ...Array.from(r).sort()];
962
- for (const a of s)
963
- n += `${a}(${t[a].map(({ name: o, type: c }) => `${c} ${o}`).join(",")})`;
964
- return n;
965
- }
966
- function vt({ primaryType: e, types: t }, n = /* @__PURE__ */ new Set()) {
967
- const r = e.match(/^\w*/u), s = r == null ? void 0 : r[0];
968
- if (n.has(s) || t[s] === void 0)
969
- return n;
970
- n.add(s);
971
- for (const a of t[s])
972
- vt({ primaryType: a.type, types: t }, n);
973
- return n;
974
- }
975
- function Tt({ types: e, name: t, type: n, value: r }) {
976
- if (e[n] !== void 0)
977
- return [
978
- { type: "bytes32" },
979
- A(wt({ data: r, primaryType: n, types: e }))
980
- ];
981
- if (n === "bytes")
982
- return r = `0x${(r.length % 2 ? "0" : "") + r.slice(2)}`, [{ type: "bytes32" }, A(r)];
983
- if (n === "string")
984
- return [{ type: "bytes32" }, A(q(r))];
985
- if (n.lastIndexOf("]") === n.length - 1) {
986
- const s = n.slice(0, n.lastIndexOf("[")), a = r.map((o) => Tt({
987
- name: t,
988
- type: s,
989
- types: e,
990
- value: o
991
- }));
992
- return [
993
- { type: "bytes32" },
994
- A(he(a.map(([o]) => o), a.map(([, o]) => o)))
995
- ];
996
- }
997
- return [{ type: n }, r];
998
- }
999
- function or(e) {
1000
- const { domain: t, message: n, primaryType: r, types: s } = e, a = (d, l) => {
1001
- const i = { ...l };
1002
- for (const u of d) {
1003
- const { name: f, type: h } = u;
1004
- h === "address" && (i[f] = i[f].toLowerCase());
1005
- }
1006
- return i;
1007
- }, o = s.EIP712Domain ? t ? a(s.EIP712Domain, t) : {} : {}, c = (() => {
1008
- if (r !== "EIP712Domain")
1009
- return a(s[r], n);
1010
- })();
1011
- return P({ domain: o, message: c, primaryType: r, types: s });
1012
- }
1013
- function Rt(e) {
1014
- const { domain: t, message: n, primaryType: r, types: s } = e, a = (o, c) => {
1015
- for (const d of o) {
1016
- const { name: l, type: i } = d, u = c[l], f = i.match(tr);
1017
- if (f && (typeof u == "number" || typeof u == "bigint")) {
1018
- const [g, b, p] = f;
1019
- k(u, {
1020
- signed: b === "int",
1021
- size: Number.parseInt(p) / 8
1022
- });
1023
- }
1024
- if (i === "address" && typeof u == "string" && !cn(u))
1025
- throw new un({ address: u });
1026
- const h = i.match(er);
1027
- if (h) {
1028
- const [g, b] = h;
1029
- if (b && ie(u) !== Number.parseInt(b))
1030
- throw new Ft({
1031
- expectedSize: Number.parseInt(b),
1032
- givenSize: ie(u)
1033
- });
1034
- }
1035
- const y = s[i];
1036
- y && a(y, u);
1037
- }
1038
- };
1039
- s.EIP712Domain && t && a(s.EIP712Domain, t), r !== "EIP712Domain" && a(s[r], n);
1040
- }
1041
- function Ct({ domain: e }) {
1042
- return [
1043
- typeof (e == null ? void 0 : e.name) == "string" && { name: "name", type: "string" },
1044
- (e == null ? void 0 : e.version) && { name: "version", type: "string" },
1045
- typeof (e == null ? void 0 : e.chainId) == "number" && {
1046
- name: "chainId",
1047
- type: "uint256"
1048
- },
1049
- (e == null ? void 0 : e.verifyingContract) && {
1050
- name: "verifyingContract",
1051
- type: "address"
1052
- },
1053
- (e == null ? void 0 : e.salt) && { name: "salt", type: "bytes32" }
1054
- ].filter(Boolean);
1055
- }
1056
- function ir(e) {
1057
- const t = A(`0x${e.substring(4)}`).substring(26);
1058
- return st(`0x${t}`);
1059
- }
1060
- async function cr({ hash: e, signature: t }) {
1061
- const n = M(e) ? e : q(e), { secp256k1: r } = await import("./secp256k1-BLbXMlpX.js").then((o) => o.a);
1062
- return `0x${(() => {
1063
- if (typeof t == "object" && "r" in t && "s" in t) {
1064
- const { r: l, s: i, v: u, yParity: f } = t, h = Number(f ?? u), y = Ve(h);
1065
- return new r.Signature(L(l), L(i)).addRecoveryBit(y);
1066
- }
1067
- const o = M(t) ? t : q(t), c = ve(`0x${o.slice(130)}`), d = Ve(c);
1068
- return r.Signature.fromCompact(o.substring(2, 130)).addRecoveryBit(d);
1069
- })().recoverPublicKey(n.substring(2)).toHex(!1)}`;
1070
- }
1071
- function Ve(e) {
1072
- if (e === 0 || e === 1)
1073
- return e;
1074
- if (e === 27)
1075
- return 0;
1076
- if (e === 28)
1077
- return 1;
1078
- throw new Error("Invalid yParityOrV value");
1079
- }
1080
- async function ur({ hash: e, signature: t }) {
1081
- return ir(await cr({ hash: e, signature: t }));
1082
- }
1083
- const dr = `Ethereum Signed Message:
1084
- `;
1085
- function fr(e) {
1086
- const t = typeof e == "string" ? K(e) : typeof e.raw == "string" ? e.raw : O(e.raw), n = K(`${dr}${ie(t)}`);
1087
- return we([n, t]);
1088
- }
1089
- function Et(e, t) {
1090
- return A(fr(e), t);
1091
- }
1092
- const xt = "0x6492649264926492649264926492649264926492649264926492649264926492";
1093
- function lr(e) {
1094
- return dn(e, -32) === xt;
1095
- }
1096
- function pr(e) {
1097
- const { address: t, data: n, signature: r, to: s = "hex" } = e, a = fn([
1098
- he([{ type: "address" }, { type: "bytes" }, { type: "bytes" }], [t, n, r]),
1099
- xt
1100
- ]);
1101
- return s === "hex" ? a : ot(a);
1102
- }
1103
- function hr(e) {
1104
- return e.map((t) => ({
1105
- ...t,
1106
- value: BigInt(t.value)
1107
- }));
1108
- }
1109
- function mr(e) {
1110
- return {
1111
- ...e,
1112
- balance: e.balance ? BigInt(e.balance) : void 0,
1113
- nonce: e.nonce ? ve(e.nonce) : void 0,
1114
- storageProof: e.storageProof ? hr(e.storageProof) : void 0
1115
- };
1116
- }
1117
- async function gr(e, { address: t, blockNumber: n, blockTag: r, storageKeys: s }) {
1118
- const a = r ?? "latest", o = n !== void 0 ? k(n) : void 0, c = await e.request({
1119
- method: "eth_getProof",
1120
- params: [t, s, o || a]
1121
- });
1122
- return mr(c);
1123
- }
1124
- async function yr(e, { address: t, blockNumber: n, blockTag: r = "latest", slot: s }) {
1125
- const a = n !== void 0 ? k(n) : void 0;
1126
- return await e.request({
1127
- method: "eth_getStorageAt",
1128
- params: [t, s, a || r]
1129
- });
1130
- }
1131
- async function Ee(e, { blockHash: t, blockNumber: n, blockTag: r, hash: s, index: a }) {
1132
- var i, u, f;
1133
- const o = r || "latest", c = n !== void 0 ? k(n) : void 0;
1134
- let d = null;
1135
- if (s ? d = await e.request({
1136
- method: "eth_getTransactionByHash",
1137
- params: [s]
1138
- }, { dedupe: !0 }) : t ? d = await e.request({
1139
- method: "eth_getTransactionByBlockHashAndIndex",
1140
- params: [t, k(a)]
1141
- }, { dedupe: !0 }) : (c || o) && (d = await e.request({
1142
- method: "eth_getTransactionByBlockNumberAndIndex",
1143
- params: [c || o, k(a)]
1144
- }, { dedupe: !!c })), !d)
1145
- throw new it({
1146
- blockHash: t,
1147
- blockNumber: n,
1148
- blockTag: o,
1149
- hash: s,
1150
- index: a
1151
- });
1152
- return (((f = (u = (i = e.chain) == null ? void 0 : i.formatters) == null ? void 0 : u.transaction) == null ? void 0 : f.format) || ln)(d);
1153
- }
1154
- async function br(e, { hash: t, transactionReceipt: n }) {
1155
- const [r, s] = await Promise.all([
1156
- C(e, X, "getBlockNumber")({}),
1157
- t ? C(e, Ee, "getTransaction")({ hash: t }) : void 0
1158
- ]), a = (n == null ? void 0 : n.blockNumber) || (s == null ? void 0 : s.blockNumber);
1159
- return a ? r - a + 1n : 0n;
1160
- }
1161
- async function de(e, { hash: t }) {
1162
- var s, a, o;
1163
- const n = await e.request({
1164
- method: "eth_getTransactionReceipt",
1165
- params: [t]
1166
- }, { dedupe: !0 });
1167
- if (!n)
1168
- throw new ct({ hash: t });
1169
- return (((o = (a = (s = e.chain) == null ? void 0 : s.formatters) == null ? void 0 : a.transactionReceipt) == null ? void 0 : o.format) || pn)(n);
1170
- }
1171
- async function wr(e, t) {
1172
- var b;
1173
- const { allowFailure: n = !0, batchSize: r, blockNumber: s, blockTag: a, multicallAddress: o, stateOverride: c } = t, d = t.contracts, l = r ?? (typeof ((b = e.batch) == null ? void 0 : b.multicall) == "object" && e.batch.multicall.batchSize || 1024);
1174
- let i = o;
1175
- if (!i) {
1176
- if (!e.chain)
1177
- throw new Error("client chain not configured. multicallAddress is required.");
1178
- i = U({
1179
- blockNumber: s,
1180
- chain: e.chain,
1181
- contract: "multicall3"
1182
- });
1183
- }
1184
- const u = [[]];
1185
- let f = 0, h = 0;
1186
- for (let p = 0; p < d.length; p++) {
1187
- const { abi: m, address: v, args: w, functionName: I } = d[p];
1188
- try {
1189
- const R = fe({ abi: m, args: w, functionName: I });
1190
- h += (R.length - 2) / 2, // Check if batching is enabled.
1191
- l > 0 && // Check if the current size of the batch exceeds the size limit.
1192
- h > l && // Check if the current chunk is not already empty.
1193
- u[f].length > 0 && (f++, h = (R.length - 2) / 2, u[f] = []), u[f] = [
1194
- ...u[f],
1195
- {
1196
- allowFailure: !0,
1197
- callData: R,
1198
- target: v
1199
- }
1200
- ];
1201
- } catch (R) {
1202
- const T = Ue(R, {
1203
- abi: m,
1204
- address: v,
1205
- args: w,
1206
- docsPath: "/docs/contract/multicall",
1207
- functionName: I
1208
- });
1209
- if (!n)
1210
- throw T;
1211
- u[f] = [
1212
- ...u[f],
1213
- {
1214
- allowFailure: !0,
1215
- callData: "0x",
1216
- target: v
1217
- }
1218
- ];
1219
- }
1220
- }
1221
- const y = await Promise.allSettled(u.map((p) => C(e, D, "readContract")({
1222
- abi: St,
1223
- address: i,
1224
- args: [p],
1225
- blockNumber: s,
1226
- blockTag: a,
1227
- functionName: "aggregate3",
1228
- stateOverride: c
1229
- }))), g = [];
1230
- for (let p = 0; p < y.length; p++) {
1231
- const m = y[p];
1232
- if (m.status === "rejected") {
1233
- if (!n)
1234
- throw m.reason;
1235
- for (let w = 0; w < u[p].length; w++)
1236
- g.push({
1237
- status: "failure",
1238
- error: m.reason,
1239
- result: void 0
1240
- });
1241
- continue;
1242
- }
1243
- const v = m.value;
1244
- for (let w = 0; w < v.length; w++) {
1245
- const { returnData: I, success: R } = v[w], { callData: T } = u[p][w], { abi: E, address: x, functionName: N, args: B } = d[g.length];
1246
- try {
1247
- if (T === "0x")
1248
- throw new _t();
1249
- if (!R)
1250
- throw new Mt({ data: I });
1251
- const S = le({
1252
- abi: E,
1253
- args: B,
1254
- data: I,
1255
- functionName: N
1256
- });
1257
- g.push(n ? { result: S, status: "success" } : S);
1258
- } catch (S) {
1259
- const $ = Ue(S, {
1260
- abi: E,
1261
- address: x,
1262
- args: B,
1263
- docsPath: "/docs/contract/multicall",
1264
- functionName: N
1265
- });
1266
- if (!n)
1267
- throw $;
1268
- g.push({ error: $, result: void 0, status: "failure" });
1269
- }
1270
- }
1271
- }
1272
- if (g.length !== d.length)
1273
- throw new F("multicall results mismatch");
1274
- return g;
1275
- }
1276
- function vr(e, t) {
1277
- const n = M(e) ? se(e) : e, r = M(t) ? se(t) : t;
1278
- return mn(n, r);
1279
- }
1280
- function Tr({ r: e, s: t, to: n = "hex", v: r, yParity: s }) {
1281
- const a = (() => {
1282
- if (s === 0 || s === 1)
1283
- return s;
1284
- if (r && (r === 27n || r === 28n || r >= 35n))
1285
- return r % 2n === 0n ? 1 : 0;
1286
- throw new Error("Invalid `v` or `yParity` value");
1287
- })(), o = `0x${new gn.Signature(L(e), L(t)).toCompactHex()}${a === 0 ? "1b" : "1c"}`;
1288
- return n === "hex" ? o : ot(o);
1289
- }
1290
- async function xe(e, t) {
1291
- const { address: n, factory: r, factoryData: s, hash: a, signature: o, ...c } = t, d = M(o) ? o : typeof o == "object" && "r" in o && "s" in o ? Tr(o) : O(o), l = await (async () => !r && !s || lr(d) ? d : pr({
1292
- address: r,
1293
- data: s,
1294
- signature: d
1295
- }))();
1296
- try {
1297
- const { data: i } = await C(e, Xe, "call")({
1298
- data: Ye({
1299
- abi: $t,
1300
- args: [n, a, l],
1301
- bytecode: zt
1302
- }),
1303
- ...c
1304
- });
1305
- return vr(i ?? "0x0", "0x1");
1306
- } catch (i) {
1307
- try {
1308
- if (et(ut(n), await ur({ hash: a, signature: o })))
1309
- return !0;
1310
- } catch {
1311
- }
1312
- if (i instanceof Ht)
1313
- return !1;
1314
- throw i;
1315
- }
1316
- }
1317
- async function Rr(e, { address: t, message: n, factory: r, factoryData: s, signature: a, ...o }) {
1318
- const c = Et(n);
1319
- return xe(e, {
1320
- address: t,
1321
- factory: r,
1322
- factoryData: s,
1323
- hash: c,
1324
- signature: a,
1325
- ...o
1326
- });
1327
- }
1328
- async function Cr(e, t) {
1329
- const { address: n, factory: r, factoryData: s, signature: a, message: o, primaryType: c, types: d, domain: l, ...i } = t, u = nr({ message: o, primaryType: c, types: d, domain: l });
1330
- return xe(e, {
1331
- address: n,
1332
- factory: r,
1333
- factoryData: s,
1334
- hash: u,
1335
- signature: a,
1336
- ...i
1337
- });
1338
- }
1339
- function It(e, { emitOnBegin: t = !1, emitMissed: n = !1, onBlockNumber: r, onError: s, poll: a, pollingInterval: o = e.pollingInterval }) {
1340
- const c = typeof a < "u" ? a : !(e.transport.type === "webSocket" || e.transport.type === "fallback" && e.transport.transports[0].config.type === "webSocket");
1341
- let d;
1342
- return c ? (() => {
1343
- const u = P([
1344
- "watchBlockNumber",
1345
- e.uid,
1346
- t,
1347
- n,
1348
- o
1349
- ]);
1350
- return _(u, { onBlockNumber: r, onError: s }, (f) => Y(async () => {
1351
- var h;
1352
- try {
1353
- const y = await C(e, X, "getBlockNumber")({ cacheTime: 0 });
1354
- if (d) {
1355
- if (y === d)
1356
- return;
1357
- if (y - d > 1 && n)
1358
- for (let g = d + 1n; g < y; g++)
1359
- f.onBlockNumber(g, d), d = g;
1360
- }
1361
- (!d || y > d) && (f.onBlockNumber(y, d), d = y);
1362
- } catch (y) {
1363
- (h = f.onError) == null || h.call(f, y);
1364
- }
1365
- }, {
1366
- emitOnBegin: t,
1367
- interval: o
1368
- }));
1369
- })() : (() => {
1370
- const u = P([
1371
- "watchBlockNumber",
1372
- e.uid,
1373
- t,
1374
- n
1375
- ]);
1376
- return _(u, { onBlockNumber: r, onError: s }, (f) => {
1377
- let h = !0, y = () => h = !1;
1378
- return (async () => {
1379
- try {
1380
- const g = (() => {
1381
- if (e.transport.type === "fallback") {
1382
- const p = e.transport.transports.find((m) => m.config.type === "webSocket");
1383
- return p ? p.value : e.transport;
1384
- }
1385
- return e.transport;
1386
- })(), { unsubscribe: b } = await g.subscribe({
1387
- params: ["newHeads"],
1388
- onData(p) {
1389
- var v;
1390
- if (!h)
1391
- return;
1392
- const m = L((v = p.result) == null ? void 0 : v.number);
1393
- f.onBlockNumber(m, d), d = m;
1394
- },
1395
- onError(p) {
1396
- var m;
1397
- (m = f.onError) == null || m.call(f, p);
1398
- }
1399
- });
1400
- y = b, h || y();
1401
- } catch (g) {
1402
- s == null || s(g);
1403
- }
1404
- })(), () => y();
1405
- });
1406
- })();
1407
- }
1408
- async function Er(e, {
1409
- confirmations: t = 1,
1410
- hash: n,
1411
- onReplaced: r,
1412
- pollingInterval: s = e.pollingInterval,
1413
- retryCount: a = 6,
1414
- retryDelay: o = ({ count: d }) => ~~(1 << d) * 200,
1415
- // exponential backoff
1416
- timeout: c
1417
- }) {
1418
- const d = P(["waitForTransactionReceipt", e.uid, n]);
1419
- let l = 0, i, u, f, h = !1;
1420
- return new Promise((y, g) => {
1421
- c && setTimeout(() => g(new Ge({ hash: n })), c);
1422
- const b = _(d, { onReplaced: r, resolve: y, reject: g }, (p) => {
1423
- const m = C(e, It, "watchBlockNumber")({
1424
- emitMissed: !0,
1425
- emitOnBegin: !0,
1426
- poll: !0,
1427
- pollingInterval: s,
1428
- async onBlockNumber(v) {
1429
- const w = (R) => {
1430
- m(), R(), b();
1431
- };
1432
- let I = v;
1433
- if (!h) {
1434
- l > a && w(() => p.reject(new Ge({ hash: n })));
1435
- try {
1436
- if (f) {
1437
- if (t > 1 && (!f.blockNumber || I - f.blockNumber + 1n < t))
1438
- return;
1439
- w(() => p.resolve(f));
1440
- return;
1441
- }
1442
- if (i || (h = !0, await ue(async () => {
1443
- i = await C(e, Ee, "getTransaction")({ hash: n }), i.blockNumber && (I = i.blockNumber);
1444
- }, {
1445
- delay: o,
1446
- retryCount: a
1447
- }), h = !1), f = await C(e, de, "getTransactionReceipt")({ hash: n }), t > 1 && (!f.blockNumber || I - f.blockNumber + 1n < t))
1448
- return;
1449
- w(() => p.resolve(f));
1450
- } catch (R) {
1451
- if (R instanceof it || R instanceof ct) {
1452
- if (!i) {
1453
- h = !1;
1454
- return;
1455
- }
1456
- try {
1457
- u = i, h = !0;
1458
- const T = await ue(() => C(e, V, "getBlock")({
1459
- blockNumber: I,
1460
- includeTransactions: !0
1461
- }), {
1462
- delay: o,
1463
- retryCount: a,
1464
- shouldRetry: ({ error: N }) => N instanceof jt
1465
- });
1466
- h = !1;
1467
- const E = T.transactions.find(({ from: N, nonce: B }) => N === u.from && B === u.nonce);
1468
- if (!E || (f = await C(e, de, "getTransactionReceipt")({
1469
- hash: E.hash
1470
- }), t > 1 && (!f.blockNumber || I - f.blockNumber + 1n < t)))
1471
- return;
1472
- let x = "replaced";
1473
- E.to === u.to && E.value === u.value ? x = "repriced" : E.from === E.to && E.value === 0n && (x = "cancelled"), w(() => {
1474
- var N;
1475
- (N = p.onReplaced) == null || N.call(p, {
1476
- reason: x,
1477
- replacedTransaction: u,
1478
- transaction: E,
1479
- transactionReceipt: f
1480
- }), p.resolve(f);
1481
- });
1482
- } catch (T) {
1483
- w(() => p.reject(T));
1484
- }
1485
- } else
1486
- w(() => p.reject(R));
1487
- } finally {
1488
- l++;
1489
- }
1490
- }
1491
- }
1492
- });
1493
- });
1494
- });
1495
- }
1496
- function xr(e, { blockTag: t = "latest", emitMissed: n = !1, emitOnBegin: r = !1, onBlock: s, onError: a, includeTransactions: o, poll: c, pollingInterval: d = e.pollingInterval }) {
1497
- const l = typeof c < "u" ? c : !(e.transport.type === "webSocket" || e.transport.type === "fallback" && e.transport.transports[0].config.type === "webSocket"), i = o ?? !1;
1498
- let u;
1499
- return l ? (() => {
1500
- const y = P([
1501
- "watchBlocks",
1502
- e.uid,
1503
- t,
1504
- n,
1505
- r,
1506
- i,
1507
- d
1508
- ]);
1509
- return _(y, { onBlock: s, onError: a }, (g) => Y(async () => {
1510
- var b;
1511
- try {
1512
- const p = await C(e, V, "getBlock")({
1513
- blockTag: t,
1514
- includeTransactions: i
1515
- });
1516
- if (p.number && (u != null && u.number)) {
1517
- if (p.number === u.number)
1518
- return;
1519
- if (p.number - u.number > 1 && n)
1520
- for (let m = (u == null ? void 0 : u.number) + 1n; m < p.number; m++) {
1521
- const v = await C(e, V, "getBlock")({
1522
- blockNumber: m,
1523
- includeTransactions: i
1524
- });
1525
- g.onBlock(v, u), u = v;
1526
- }
1527
- }
1528
- // If no previous block exists, emit.
1529
- (!(u != null && u.number) || // If the block tag is "pending" with no block number, emit.
1530
- t === "pending" && !(p != null && p.number) || // If the next block number is greater than the previous block number, emit.
1531
- // We don't want to emit blocks in the past.
1532
- p.number && p.number > u.number) && (g.onBlock(p, u), u = p);
1533
- } catch (p) {
1534
- (b = g.onError) == null || b.call(g, p);
1535
- }
1536
- }, {
1537
- emitOnBegin: r,
1538
- interval: d
1539
- }));
1540
- })() : (() => {
1541
- let y = !0, g = () => y = !1;
1542
- return (async () => {
1543
- try {
1544
- const b = (() => {
1545
- if (e.transport.type === "fallback") {
1546
- const m = e.transport.transports.find((v) => v.config.type === "webSocket");
1547
- return m ? m.value : e.transport;
1548
- }
1549
- return e.transport;
1550
- })(), { unsubscribe: p } = await b.subscribe({
1551
- params: ["newHeads"],
1552
- onData(m) {
1553
- var I, R, T;
1554
- if (!y)
1555
- return;
1556
- const w = (((T = (R = (I = e.chain) == null ? void 0 : I.formatters) == null ? void 0 : R.block) == null ? void 0 : T.format) || hn)(m.result);
1557
- s(w, u), u = w;
1558
- },
1559
- onError(m) {
1560
- a == null || a(m);
1561
- }
1562
- });
1563
- g = p, y || g();
1564
- } catch (b) {
1565
- a == null || a(b);
1566
- }
1567
- })(), () => g();
1568
- })();
1569
- }
1570
- function Ir(e, { address: t, args: n, batch: r = !0, event: s, events: a, fromBlock: o, onError: c, onLogs: d, poll: l, pollingInterval: i = e.pollingInterval, strict: u }) {
1571
- const f = typeof l < "u" ? l : typeof o == "bigint" ? !0 : !(e.transport.type === "webSocket" || e.transport.type === "fallback" && e.transport.transports[0].config.type === "webSocket"), h = u ?? !1;
1572
- return f ? (() => {
1573
- const b = P([
1574
- "watchEvent",
1575
- t,
1576
- n,
1577
- r,
1578
- e.uid,
1579
- s,
1580
- i,
1581
- o
1582
- ]);
1583
- return _(b, { onLogs: d, onError: c }, (p) => {
1584
- let m;
1585
- o !== void 0 && (m = o - 1n);
1586
- let v, w = !1;
1587
- const I = Y(async () => {
1588
- var R;
1589
- if (!w) {
1590
- try {
1591
- v = await C(e, gt, "createEventFilter")({
1592
- address: t,
1593
- args: n,
1594
- event: s,
1595
- events: a,
1596
- strict: h,
1597
- fromBlock: o
1598
- });
1599
- } catch {
1600
- }
1601
- w = !0;
1602
- return;
1603
- }
1604
- try {
1605
- let T;
1606
- if (v)
1607
- T = await C(e, ge, "getFilterChanges")({ filter: v });
1608
- else {
1609
- const E = await C(e, X, "getBlockNumber")({});
1610
- m && m !== E ? T = await C(e, tt, "getLogs")({
1611
- address: t,
1612
- args: n,
1613
- event: s,
1614
- events: a,
1615
- fromBlock: m + 1n,
1616
- toBlock: E
1617
- }) : T = [], m = E;
1618
- }
1619
- if (T.length === 0)
1620
- return;
1621
- if (r)
1622
- p.onLogs(T);
1623
- else
1624
- for (const E of T)
1625
- p.onLogs([E]);
1626
- } catch (T) {
1627
- v && T instanceof re && (w = !1), (R = p.onError) == null || R.call(p, T);
1628
- }
1629
- }, {
1630
- emitOnBegin: !0,
1631
- interval: i
1632
- });
1633
- return async () => {
1634
- v && await C(e, me, "uninstallFilter")({ filter: v }), I();
1635
- };
1636
- });
1637
- })() : (() => {
1638
- let b = !0, p = () => b = !1;
1639
- return (async () => {
1640
- try {
1641
- const m = (() => {
1642
- if (e.transport.type === "fallback") {
1643
- const R = e.transport.transports.find((T) => T.config.type === "webSocket");
1644
- return R ? R.value : e.transport;
1645
- }
1646
- return e.transport;
1647
- })(), v = a ?? (s ? [s] : void 0);
1648
- let w = [];
1649
- v && (w = [v.flatMap((T) => Qe({
1650
- abi: [T],
1651
- eventName: T.name,
1652
- args: n
1653
- }))], s && (w = w[0]));
1654
- const { unsubscribe: I } = await m.subscribe({
1655
- params: ["logs", { address: t, topics: w }],
1656
- onData(R) {
1657
- var E;
1658
- if (!b)
1659
- return;
1660
- const T = R.result;
1661
- try {
1662
- const { eventName: x, args: N } = Ot({
1663
- abi: v ?? [],
1664
- data: T.data,
1665
- topics: T.topics,
1666
- strict: h
1667
- }), B = oe(T, { args: N, eventName: x });
1668
- d([B]);
1669
- } catch (x) {
1670
- let N, B;
1671
- if (x instanceof Lt || x instanceof Ut) {
1672
- if (u)
1673
- return;
1674
- N = x.abiItem.name, B = (E = x.abiItem.inputs) == null ? void 0 : E.some(($) => !("name" in $ && $.name));
1675
- }
1676
- const S = oe(T, {
1677
- args: B ? [] : {},
1678
- eventName: N
1679
- });
1680
- d([S]);
1681
- }
1682
- },
1683
- onError(R) {
1684
- c == null || c(R);
1685
- }
1686
- });
1687
- p = I, b || p();
1688
- } catch (m) {
1689
- c == null || c(m);
1690
- }
1691
- })(), () => p();
1692
- })();
1693
- }
1694
- function Nr(e, { batch: t = !0, onError: n, onTransactions: r, poll: s, pollingInterval: a = e.pollingInterval }) {
1695
- return (typeof s < "u" ? s : e.transport.type !== "webSocket") ? (() => {
1696
- const l = P([
1697
- "watchPendingTransactions",
1698
- e.uid,
1699
- t,
1700
- a
1701
- ]);
1702
- return _(l, { onTransactions: r, onError: n }, (i) => {
1703
- let u;
1704
- const f = Y(async () => {
1705
- var h;
1706
- try {
1707
- if (!u)
1708
- try {
1709
- u = await C(e, yt, "createPendingTransactionFilter")({});
1710
- return;
1711
- } catch (g) {
1712
- throw f(), g;
1713
- }
1714
- const y = await C(e, ge, "getFilterChanges")({ filter: u });
1715
- if (y.length === 0)
1716
- return;
1717
- if (t)
1718
- i.onTransactions(y);
1719
- else
1720
- for (const g of y)
1721
- i.onTransactions([g]);
1722
- } catch (y) {
1723
- (h = i.onError) == null || h.call(i, y);
1724
- }
1725
- }, {
1726
- emitOnBegin: !0,
1727
- interval: a
1728
- });
1729
- return async () => {
1730
- u && await C(e, me, "uninstallFilter")({ filter: u }), f();
1731
- };
1732
- });
1733
- })() : (() => {
1734
- let l = !0, i = () => l = !1;
1735
- return (async () => {
1736
- try {
1737
- const { unsubscribe: u } = await e.transport.subscribe({
1738
- params: ["newPendingTransactions"],
1739
- onData(f) {
1740
- if (!l)
1741
- return;
1742
- const h = f.result;
1743
- r([h]);
1744
- },
1745
- onError(f) {
1746
- n == null || n(f);
1747
- }
1748
- });
1749
- i = u, l || i();
1750
- } catch (u) {
1751
- n == null || n(u);
1752
- }
1753
- })(), () => i();
1754
- })();
1755
- }
1756
- function kr(e) {
1757
- var u, f, h;
1758
- const { scheme: t, statement: n, ...r } = ((u = e.match(Ar)) == null ? void 0 : u.groups) ?? {}, { chainId: s, expirationTime: a, issuedAt: o, notBefore: c, requestId: d, ...l } = ((f = e.match(Pr)) == null ? void 0 : f.groups) ?? {}, i = (h = e.split("Resources:")[1]) == null ? void 0 : h.split(`
1759
- - `).slice(1);
1760
- return {
1761
- ...r,
1762
- ...l,
1763
- ...s ? { chainId: Number(s) } : {},
1764
- ...a ? { expirationTime: new Date(a) } : {},
1765
- ...o ? { issuedAt: new Date(o) } : {},
1766
- ...c ? { notBefore: new Date(c) } : {},
1767
- ...d ? { requestId: d } : {},
1768
- ...i ? { resources: i } : {},
1769
- ...t ? { scheme: t } : {},
1770
- ...n ? { statement: n } : {}
1771
- };
1772
- }
1773
- const Ar = /^(?:(?<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)?/, Pr = /(?: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>.+))?/;
1774
- function Br(e) {
1775
- const { address: t, domain: n, message: r, nonce: s, scheme: a, time: o = /* @__PURE__ */ new Date() } = e;
1776
- if (n && r.domain !== n || s && r.nonce !== s || a && r.scheme !== a || r.expirationTime && o >= r.expirationTime || r.notBefore && o < r.notBefore)
1777
- return !1;
1778
- try {
1779
- if (!r.address || t && !et(r.address, t))
1780
- return !1;
1781
- } catch {
1782
- return !1;
1783
- }
1784
- return !0;
1785
- }
1786
- async function Dr(e, t) {
1787
- const { address: n, domain: r, message: s, nonce: a, scheme: o, signature: c, time: d = /* @__PURE__ */ new Date(), ...l } = t, i = kr(s);
1788
- if (!i.address || !Br({
1789
- address: n,
1790
- domain: r,
1791
- message: i,
1792
- nonce: a,
1793
- scheme: o,
1794
- time: d
1795
- }))
1796
- return !1;
1797
- const f = Et(s);
1798
- return xe(e, {
1799
- address: i.address,
1800
- hash: f,
1801
- signature: c,
1802
- ...l
1803
- });
1804
- }
1805
- function qr(e) {
1806
- return {
1807
- call: (t) => Xe(e, t),
1808
- createBlockFilter: () => Zn(e),
1809
- createContractEventFilter: (t) => Gt(e, t),
1810
- createEventFilter: (t) => gt(e, t),
1811
- createPendingTransactionFilter: () => yt(e),
1812
- estimateContractGas: (t) => Wt(e, t),
1813
- estimateGas: (t) => Zt(e, t),
1814
- getBalance: (t) => Jn(e, t),
1815
- getBlobBaseFee: () => Vn(e),
1816
- getBlock: (t) => V(e, t),
1817
- getBlockNumber: (t) => X(e, t),
1818
- getBlockTransactionCount: (t) => Kn(e, t),
1819
- getBytecode: (t) => Je(e, t),
1820
- getChainId: () => ye(e),
1821
- getCode: (t) => Je(e, t),
1822
- getContractEvents: (t) => Jt(e, t),
1823
- getEip712Domain: (t) => bn(e, t),
1824
- getEnsAddress: (t) => Bn(e, t),
1825
- getEnsAvatar: (t) => Un(e, t),
1826
- getEnsName: (t) => Gn(e, t),
1827
- getEnsResolver: (t) => Wn(e, t),
1828
- getEnsText: (t) => mt(e, t),
1829
- getFeeHistory: (t) => Xn(e, t),
1830
- estimateFeesPerGas: (t) => Vt(e, t),
1831
- getFilterChanges: (t) => ge(e, t),
1832
- getFilterLogs: (t) => Yn(e, t),
1833
- getGasPrice: () => Kt(e),
1834
- getLogs: (t) => tt(e, t),
1835
- getProof: (t) => gr(e, t),
1836
- estimateMaxPriorityFeePerGas: (t) => Qt(e, t),
1837
- getStorageAt: (t) => yr(e, t),
1838
- getTransaction: (t) => Ee(e, t),
1839
- getTransactionConfirmations: (t) => br(e, t),
1840
- getTransactionCount: (t) => Xt(e, t),
1841
- getTransactionReceipt: (t) => de(e, t),
1842
- multicall: (t) => wr(e, t),
1843
- prepareTransactionRequest: (t) => nt(e, t),
1844
- readContract: (t) => D(e, t),
1845
- sendRawTransaction: (t) => rt(e, t),
1846
- simulateContract: (t) => Yt(e, t),
1847
- verifyMessage: (t) => Rr(e, t),
1848
- verifySiweMessage: (t) => Dr(e, t),
1849
- verifyTypedData: (t) => Cr(e, t),
1850
- uninstallFilter: (t) => me(e, t),
1851
- waitForTransactionReceipt: (t) => Er(e, t),
1852
- watchBlocks: (t) => xr(e, t),
1853
- watchBlockNumber: (t) => It(e, t),
1854
- watchContractEvent: (t) => en(e, t),
1855
- watchEvent: (t) => Ir(e, t),
1856
- watchPendingTransactions: (t) => Nr(e, t)
1857
- };
1858
- }
1859
- function Vr(e) {
1860
- const { key: t = "public", name: n = "Public Client" } = e;
1861
- return ft({
1862
- ...e,
1863
- key: t,
1864
- name: n,
1865
- type: "publicClient"
1866
- }).extend(qr);
1867
- }
1868
- function Fr(e, t) {
1869
- const { abi: n, args: r, bytecode: s, ...a } = t, o = Ye({ abi: n, args: r, bytecode: s });
1870
- return at(e, {
1871
- ...a,
1872
- data: o
1873
- });
1874
- }
1875
- async function Sr(e) {
1876
- var n;
1877
- return ((n = e.account) == null ? void 0 : n.type) === "local" ? [e.account.address] : (await e.request({ method: "eth_accounts" }, { dedupe: !0 })).map((r) => st(r));
1878
- }
1879
- async function _r(e) {
1880
- return await e.request({ method: "wallet_getPermissions" }, { dedupe: !0 });
1881
- }
1882
- async function Mr(e) {
1883
- return (await e.request({ method: "eth_requestAccounts" }, { dedupe: !0, retryCount: 0 })).map((n) => ut(n));
1884
- }
1885
- async function $r(e, t) {
1886
- return e.request({
1887
- method: "wallet_requestPermissions",
1888
- params: [t]
1889
- }, { retryCount: 0 });
1890
- }
1891
- async function zr(e, { account: t = e.account, message: n }) {
1892
- if (!t)
1893
- throw new be({
1894
- docsPath: "/docs/actions/wallet/signMessage"
1895
- });
1896
- const r = Q(t);
1897
- if (r.signMessage)
1898
- return r.signMessage({ message: n });
1899
- const s = typeof n == "string" ? K(n) : n.raw instanceof Uint8Array ? q(n.raw) : n.raw;
1900
- return e.request({
1901
- method: "personal_sign",
1902
- params: [s, r.address]
1903
- }, { retryCount: 0 });
1904
- }
1905
- async function Hr(e, t) {
1906
- var l, i, u, f;
1907
- const { account: n = e.account, chain: r = e.chain, ...s } = t;
1908
- if (!n)
1909
- throw new be({
1910
- docsPath: "/docs/actions/wallet/signTransaction"
1911
- });
1912
- const a = Q(n);
1913
- tn({
1914
- account: a,
1915
- ...t
1916
- });
1917
- const o = await C(e, ye, "getChainId")({});
1918
- r !== null && nn({
1919
- currentChainId: o,
1920
- chain: r
1921
- });
1922
- const c = (r == null ? void 0 : r.formatters) || ((l = e.chain) == null ? void 0 : l.formatters), d = ((i = c == null ? void 0 : c.transactionRequest) == null ? void 0 : i.format) || rn;
1923
- return a.signTransaction ? a.signTransaction({
1924
- ...s,
1925
- chainId: o
1926
- }, { serializer: (f = (u = e.chain) == null ? void 0 : u.serializers) == null ? void 0 : f.transaction }) : await e.request({
1927
- method: "eth_signTransaction",
1928
- params: [
1929
- {
1930
- ...d(s),
1931
- chainId: k(o),
1932
- from: a.address
1933
- }
1934
- ]
1935
- }, { retryCount: 0 });
1936
- }
1937
- async function jr(e, t) {
1938
- const { account: n = e.account, domain: r, message: s, primaryType: a } = t;
1939
- if (!n)
1940
- throw new be({
1941
- docsPath: "/docs/actions/wallet/signTypedData"
1942
- });
1943
- const o = Q(n), c = {
1944
- EIP712Domain: Ct({ domain: r }),
1945
- ...t.types
1946
- };
1947
- if (Rt({ domain: r, message: s, primaryType: a, types: c }), o.signTypedData)
1948
- return o.signTypedData({ domain: r, message: s, primaryType: a, types: c });
1949
- const d = or({ domain: r, message: s, primaryType: a, types: c });
1950
- return e.request({
1951
- method: "eth_signTypedData_v4",
1952
- params: [o.address, d]
1953
- }, { retryCount: 0 });
1954
- }
1955
- async function Or(e, { id: t }) {
1956
- await e.request({
1957
- method: "wallet_switchEthereumChain",
1958
- params: [
1959
- {
1960
- chainId: k(t)
1961
- }
1962
- ]
1963
- }, { retryCount: 0 });
1964
- }
1965
- async function Lr(e, t) {
1966
- return await e.request({
1967
- method: "wallet_watchAsset",
1968
- params: t
1969
- }, { retryCount: 0 });
1970
- }
1971
- function Ur(e) {
1972
- return {
1973
- addChain: (t) => vn(e, t),
1974
- deployContract: (t) => Fr(e, t),
1975
- getAddresses: () => Sr(e),
1976
- getChainId: () => ye(e),
1977
- getPermissions: () => _r(e),
1978
- prepareTransactionRequest: (t) => nt(e, t),
1979
- requestAddresses: () => Mr(e),
1980
- requestPermissions: (t) => $r(e, t),
1981
- sendRawTransaction: (t) => rt(e, t),
1982
- sendTransaction: (t) => at(e, t),
1983
- signMessage: (t) => zr(e, t),
1984
- signTransaction: (t) => Hr(e, t),
1985
- signTypedData: (t) => jr(e, t),
1986
- switchChain: (t) => Or(e, t),
1987
- watchAsset: (t) => Lr(e, t),
1988
- writeContract: (t) => an(e, t)
1989
- };
1990
- }
1991
- function Kr(e) {
1992
- const { key: t = "wallet", name: n = "Wallet Client", transport: r } = e;
1993
- return ft({
1994
- ...e,
1995
- key: t,
1996
- name: n,
1997
- transport: r,
1998
- type: "walletClient"
1999
- }).extend(Ur);
2000
- }
2001
- export {
2002
- Vr as a,
2003
- En as b,
2004
- Kr as c,
2005
- Jr as h
2006
- };
2007
- //# sourceMappingURL=createWalletClient-DKcpswHR.js.map