@pufferfinance/puffer-sdk 1.28.0 → 1.28.2

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 (258) 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 +7 -7
  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 +119 -122
  8. package/dist/api/puffer-client.js.map +1 -1
  9. package/dist/ccip-78YM988s.js +150 -0
  10. package/dist/{ccip-C76-YhQK.js.map → ccip-78YM988s.js.map} +1 -1
  11. package/dist/ccip-LIGR3N1A.cjs +2 -0
  12. package/dist/{ccip-CEodLZ4s.cjs.map → ccip-LIGR3N1A.cjs.map} +1 -1
  13. package/dist/chains/constants.cjs +1 -1
  14. package/dist/chains/constants.js +1 -1
  15. package/dist/constants-6kuRTsbU.cjs +9 -0
  16. package/dist/{constants-CxSgz27h.cjs.map → constants-6kuRTsbU.cjs.map} +1 -1
  17. package/dist/{constants-C9YZ6Ewc.js → constants-CuIEh_ZS.js} +605 -656
  18. package/dist/{constants-C9YZ6Ewc.js.map → constants-CuIEh_ZS.js.map} +1 -1
  19. package/dist/contracts/abis/mainnet/Accountant.cjs.map +1 -1
  20. package/dist/contracts/abis/mainnet/Accountant.js.map +1 -1
  21. package/dist/contracts/abis/mainnet/AtomicQueue.cjs.map +1 -1
  22. package/dist/contracts/abis/mainnet/AtomicQueue.js.map +1 -1
  23. package/dist/contracts/abis/mainnet/BoringVault.cjs.map +1 -1
  24. package/dist/contracts/abis/mainnet/BoringVault.js.map +1 -1
  25. package/dist/contracts/abis/mainnet/CarrotStaker.cjs.map +1 -1
  26. package/dist/contracts/abis/mainnet/CarrotStaker.js.map +1 -1
  27. package/dist/contracts/abis/mainnet/CarrotVesting.cjs +1 -1
  28. package/dist/contracts/abis/mainnet/CarrotVesting.cjs.map +1 -1
  29. package/dist/contracts/abis/mainnet/CarrotVesting.d.ts +98 -82
  30. package/dist/contracts/abis/mainnet/CarrotVesting.js +64 -50
  31. package/dist/contracts/abis/mainnet/CarrotVesting.js.map +1 -1
  32. package/dist/contracts/abis/mainnet/ConcreteMultiStrategyVault.cjs.map +1 -1
  33. package/dist/contracts/abis/mainnet/ConcreteMultiStrategyVault.js.map +1 -1
  34. package/dist/contracts/abis/mainnet/Distributor.cjs.map +1 -1
  35. package/dist/contracts/abis/mainnet/Distributor.js.map +1 -1
  36. package/dist/contracts/abis/mainnet/ERC20Permit.cjs.map +1 -1
  37. package/dist/contracts/abis/mainnet/ERC20Permit.js.map +1 -1
  38. package/dist/contracts/abis/mainnet/GaugeRegistry.cjs.map +1 -1
  39. package/dist/contracts/abis/mainnet/GaugeRegistry.js.map +1 -1
  40. package/dist/contracts/abis/mainnet/GuardianModule.cjs.map +1 -1
  41. package/dist/contracts/abis/mainnet/GuardianModule.js.map +1 -1
  42. package/dist/contracts/abis/mainnet/InstitutionalAccessManager.cjs.map +1 -1
  43. package/dist/contracts/abis/mainnet/InstitutionalAccessManager.js.map +1 -1
  44. package/dist/contracts/abis/mainnet/InstitutionalVault.cjs.map +1 -1
  45. package/dist/contracts/abis/mainnet/InstitutionalVault.js.map +1 -1
  46. package/dist/contracts/abis/mainnet/L1RewardManager.cjs.map +1 -1
  47. package/dist/contracts/abis/mainnet/L1RewardManager.js.map +1 -1
  48. package/dist/contracts/abis/mainnet/L2RewardManager.cjs.map +1 -1
  49. package/dist/contracts/abis/mainnet/L2RewardManager.js.map +1 -1
  50. package/dist/contracts/abis/mainnet/LagoonVault.cjs.map +1 -1
  51. package/dist/contracts/abis/mainnet/LagoonVault.js.map +1 -1
  52. package/dist/contracts/abis/mainnet/PufLocker.cjs.map +1 -1
  53. package/dist/contracts/abis/mainnet/PufLocker.js.map +1 -1
  54. package/dist/contracts/abis/mainnet/PufferDepositor.cjs.map +1 -1
  55. package/dist/contracts/abis/mainnet/PufferDepositor.js.map +1 -1
  56. package/dist/contracts/abis/mainnet/PufferL2Depositor.cjs.map +1 -1
  57. package/dist/contracts/abis/mainnet/PufferL2Depositor.js.map +1 -1
  58. package/dist/contracts/abis/mainnet/PufferOracleV2.cjs.map +1 -1
  59. package/dist/contracts/abis/mainnet/PufferOracleV2.js.map +1 -1
  60. package/dist/contracts/abis/mainnet/PufferProtocol.cjs.map +1 -1
  61. package/dist/contracts/abis/mainnet/PufferProtocol.js.map +1 -1
  62. package/dist/contracts/abis/mainnet/PufferVaultV5.cjs.map +1 -1
  63. package/dist/contracts/abis/mainnet/PufferVaultV5.js.map +1 -1
  64. package/dist/contracts/abis/mainnet/PufferWithdrawalManager.cjs.map +1 -1
  65. package/dist/contracts/abis/mainnet/PufferWithdrawalManager.js.map +1 -1
  66. package/dist/contracts/abis/mainnet/Teller.cjs.map +1 -1
  67. package/dist/contracts/abis/mainnet/Teller.js.map +1 -1
  68. package/dist/contracts/abis/mainnet/ValidatorTicket.cjs.map +1 -1
  69. package/dist/contracts/abis/mainnet/ValidatorTicket.js.map +1 -1
  70. package/dist/contracts/abis/mainnet/mtwCARROT.cjs.map +1 -1
  71. package/dist/contracts/abis/mainnet/mtwCARROT.js.map +1 -1
  72. package/dist/contracts/abis/mainnet/vlPUFFER.cjs.map +1 -1
  73. package/dist/contracts/abis/mainnet/vlPUFFER.js.map +1 -1
  74. package/dist/contracts/addresses.cjs +1 -1
  75. package/dist/contracts/addresses.cjs.map +1 -1
  76. package/dist/contracts/addresses.js +4 -5
  77. package/dist/contracts/addresses.js.map +1 -1
  78. package/dist/contracts/handlers/carrot-staking-handler.cjs +1 -1
  79. package/dist/contracts/handlers/carrot-staking-handler.cjs.map +1 -1
  80. package/dist/contracts/handlers/carrot-staking-handler.d.ts +96 -6599
  81. package/dist/contracts/handlers/carrot-staking-handler.js +13 -16
  82. package/dist/contracts/handlers/carrot-staking-handler.js.map +1 -1
  83. package/dist/contracts/handlers/carrot-vesting-handler.cjs +1 -1
  84. package/dist/contracts/handlers/carrot-vesting-handler.cjs.map +1 -1
  85. package/dist/contracts/handlers/carrot-vesting-handler.d.ts +98 -6600
  86. package/dist/contracts/handlers/carrot-vesting-handler.js +21 -23
  87. package/dist/contracts/handlers/carrot-vesting-handler.js.map +1 -1
  88. package/dist/contracts/handlers/concrete-vault-handler.cjs +1 -1
  89. package/dist/contracts/handlers/concrete-vault-handler.cjs.map +1 -1
  90. package/dist/contracts/handlers/concrete-vault-handler.d.ts +96 -6599
  91. package/dist/contracts/handlers/concrete-vault-handler.js +15 -18
  92. package/dist/contracts/handlers/concrete-vault-handler.js.map +1 -1
  93. package/dist/contracts/handlers/distributor-handler.cjs +1 -1
  94. package/dist/contracts/handlers/distributor-handler.cjs.map +1 -1
  95. package/dist/contracts/handlers/distributor-handler.d.ts +96 -6599
  96. package/dist/contracts/handlers/distributor-handler.js +15 -18
  97. package/dist/contracts/handlers/distributor-handler.js.map +1 -1
  98. package/dist/contracts/handlers/erc20-permit-handler.cjs +1 -1
  99. package/dist/contracts/handlers/erc20-permit-handler.cjs.map +1 -1
  100. package/dist/contracts/handlers/erc20-permit-handler.d.ts +96 -6599
  101. package/dist/contracts/handlers/erc20-permit-handler.js +34 -38
  102. package/dist/contracts/handlers/erc20-permit-handler.js.map +1 -1
  103. package/dist/contracts/handlers/gauge-registry-handler.cjs +1 -1
  104. package/dist/contracts/handlers/gauge-registry-handler.cjs.map +1 -1
  105. package/dist/contracts/handlers/gauge-registry-handler.d.ts +96 -6599
  106. package/dist/contracts/handlers/gauge-registry-handler.js +11 -14
  107. package/dist/contracts/handlers/gauge-registry-handler.js.map +1 -1
  108. package/dist/contracts/handlers/guardian-module-handler.cjs +1 -1
  109. package/dist/contracts/handlers/guardian-module-handler.cjs.map +1 -1
  110. package/dist/contracts/handlers/guardian-module-handler.d.ts +96 -6599
  111. package/dist/contracts/handlers/guardian-module-handler.js +11 -14
  112. package/dist/contracts/handlers/guardian-module-handler.js.map +1 -1
  113. package/dist/contracts/handlers/institutional-access-manager-handler.cjs +1 -1
  114. package/dist/contracts/handlers/institutional-access-manager-handler.cjs.map +1 -1
  115. package/dist/contracts/handlers/institutional-access-manager-handler.d.ts +96 -6599
  116. package/dist/contracts/handlers/institutional-access-manager-handler.js +45 -50
  117. package/dist/contracts/handlers/institutional-access-manager-handler.js.map +1 -1
  118. package/dist/contracts/handlers/institutional-vault-handler.cjs +1 -1
  119. package/dist/contracts/handlers/institutional-vault-handler.cjs.map +1 -1
  120. package/dist/contracts/handlers/institutional-vault-handler.d.ts +96 -6599
  121. package/dist/contracts/handlers/institutional-vault-handler.js +16 -19
  122. package/dist/contracts/handlers/institutional-vault-handler.js.map +1 -1
  123. package/dist/contracts/handlers/l1-reward-manager-handler.cjs +1 -1
  124. package/dist/contracts/handlers/l1-reward-manager-handler.cjs.map +1 -1
  125. package/dist/contracts/handlers/l1-reward-manager-handler.d.ts +96 -6599
  126. package/dist/contracts/handlers/l1-reward-manager-handler.js +14 -17
  127. package/dist/contracts/handlers/l1-reward-manager-handler.js.map +1 -1
  128. package/dist/contracts/handlers/l2-reward-manager-handler.cjs +1 -1
  129. package/dist/contracts/handlers/l2-reward-manager-handler.cjs.map +1 -1
  130. package/dist/contracts/handlers/l2-reward-manager-handler.d.ts +96 -6599
  131. package/dist/contracts/handlers/l2-reward-manager-handler.js +13 -16
  132. package/dist/contracts/handlers/l2-reward-manager-handler.js.map +1 -1
  133. package/dist/contracts/handlers/lagoon-vault-handler.cjs +1 -1
  134. package/dist/contracts/handlers/lagoon-vault-handler.cjs.map +1 -1
  135. package/dist/contracts/handlers/lagoon-vault-handler.d.ts +96 -6599
  136. package/dist/contracts/handlers/lagoon-vault-handler.js +11 -14
  137. package/dist/contracts/handlers/lagoon-vault-handler.js.map +1 -1
  138. package/dist/contracts/handlers/mtw-carrot-handler.cjs +1 -1
  139. package/dist/contracts/handlers/mtw-carrot-handler.cjs.map +1 -1
  140. package/dist/contracts/handlers/mtw-carrot-handler.d.ts +96 -6599
  141. package/dist/contracts/handlers/mtw-carrot-handler.js +12 -15
  142. package/dist/contracts/handlers/mtw-carrot-handler.js.map +1 -1
  143. package/dist/contracts/handlers/nucleus-accountant-handler.cjs +1 -1
  144. package/dist/contracts/handlers/nucleus-accountant-handler.cjs.map +1 -1
  145. package/dist/contracts/handlers/nucleus-accountant-handler.d.ts +96 -6599
  146. package/dist/contracts/handlers/nucleus-accountant-handler.js +13 -16
  147. package/dist/contracts/handlers/nucleus-accountant-handler.js.map +1 -1
  148. package/dist/contracts/handlers/nucleus-atomic-queue-handler.cjs +1 -1
  149. package/dist/contracts/handlers/nucleus-atomic-queue-handler.cjs.map +1 -1
  150. package/dist/contracts/handlers/nucleus-atomic-queue-handler.d.ts +96 -6599
  151. package/dist/contracts/handlers/nucleus-atomic-queue-handler.js +14 -17
  152. package/dist/contracts/handlers/nucleus-atomic-queue-handler.js.map +1 -1
  153. package/dist/contracts/handlers/nucleus-boring-vault-handler.cjs +1 -1
  154. package/dist/contracts/handlers/nucleus-boring-vault-handler.cjs.map +1 -1
  155. package/dist/contracts/handlers/nucleus-boring-vault-handler.d.ts +96 -6599
  156. package/dist/contracts/handlers/nucleus-boring-vault-handler.js +18 -21
  157. package/dist/contracts/handlers/nucleus-boring-vault-handler.js.map +1 -1
  158. package/dist/contracts/handlers/nucleus-teller-handler.cjs +1 -1
  159. package/dist/contracts/handlers/nucleus-teller-handler.cjs.map +1 -1
  160. package/dist/contracts/handlers/nucleus-teller-handler.d.ts +96 -6599
  161. package/dist/contracts/handlers/nucleus-teller-handler.js +35 -38
  162. package/dist/contracts/handlers/nucleus-teller-handler.js.map +1 -1
  163. package/dist/contracts/handlers/puf-locker-handler.cjs +1 -1
  164. package/dist/contracts/handlers/puf-locker-handler.cjs.map +1 -1
  165. package/dist/contracts/handlers/puf-locker-handler.d.ts +96 -6599
  166. package/dist/contracts/handlers/puf-locker-handler.js +51 -54
  167. package/dist/contracts/handlers/puf-locker-handler.js.map +1 -1
  168. package/dist/contracts/handlers/puffer-depositor-handler.cjs +1 -1
  169. package/dist/contracts/handlers/puffer-depositor-handler.cjs.map +1 -1
  170. package/dist/contracts/handlers/puffer-depositor-handler.d.ts +96 -6599
  171. package/dist/contracts/handlers/puffer-depositor-handler.js +28 -31
  172. package/dist/contracts/handlers/puffer-depositor-handler.js.map +1 -1
  173. package/dist/contracts/handlers/puffer-l2-depositor-handler.cjs +1 -1
  174. package/dist/contracts/handlers/puffer-l2-depositor-handler.cjs.map +1 -1
  175. package/dist/contracts/handlers/puffer-l2-depositor-handler.d.ts +96 -6599
  176. package/dist/contracts/handlers/puffer-l2-depositor-handler.js +42 -45
  177. package/dist/contracts/handlers/puffer-l2-depositor-handler.js.map +1 -1
  178. package/dist/contracts/handlers/puffer-oracle-v2-handler.cjs +1 -1
  179. package/dist/contracts/handlers/puffer-oracle-v2-handler.cjs.map +1 -1
  180. package/dist/contracts/handlers/puffer-oracle-v2-handler.d.ts +96 -6599
  181. package/dist/contracts/handlers/puffer-oracle-v2-handler.js +13 -16
  182. package/dist/contracts/handlers/puffer-oracle-v2-handler.js.map +1 -1
  183. package/dist/contracts/handlers/puffer-protocol-handler.cjs +1 -1
  184. package/dist/contracts/handlers/puffer-protocol-handler.cjs.map +1 -1
  185. package/dist/contracts/handlers/puffer-protocol-handler.d.ts +96 -6599
  186. package/dist/contracts/handlers/puffer-protocol-handler.js +12 -15
  187. package/dist/contracts/handlers/puffer-protocol-handler.js.map +1 -1
  188. package/dist/contracts/handlers/puffer-vault-handler.cjs +1 -1
  189. package/dist/contracts/handlers/puffer-vault-handler.cjs.map +1 -1
  190. package/dist/contracts/handlers/puffer-vault-handler.d.ts +96 -6599
  191. package/dist/contracts/handlers/puffer-vault-handler.js +12 -15
  192. package/dist/contracts/handlers/puffer-vault-handler.js.map +1 -1
  193. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.cjs +1 -1
  194. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.cjs.map +1 -1
  195. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.d.ts +96 -6599
  196. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.js +15 -18
  197. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.js.map +1 -1
  198. package/dist/contracts/handlers/validator-ticket-handler.cjs +1 -1
  199. package/dist/contracts/handlers/validator-ticket-handler.cjs.map +1 -1
  200. package/dist/contracts/handlers/validator-ticket-handler.d.ts +96 -6599
  201. package/dist/contracts/handlers/validator-ticket-handler.js +12 -15
  202. package/dist/contracts/handlers/validator-ticket-handler.js.map +1 -1
  203. package/dist/contracts/handlers/vl-puffer-handler.cjs +1 -1
  204. package/dist/contracts/handlers/vl-puffer-handler.cjs.map +1 -1
  205. package/dist/contracts/handlers/vl-puffer-handler.d.ts +96 -6599
  206. package/dist/contracts/handlers/vl-puffer-handler.js +19 -22
  207. package/dist/contracts/handlers/vl-puffer-handler.js.map +1 -1
  208. package/dist/contracts/tokens.cjs +1 -1
  209. package/dist/contracts/tokens.cjs.map +1 -1
  210. package/dist/contracts/tokens.js +1 -1
  211. package/dist/contracts/tokens.js.map +1 -1
  212. package/dist/contracts/vaults-addresses.cjs +1 -1
  213. package/dist/contracts/vaults-addresses.cjs.map +1 -1
  214. package/dist/contracts/vaults-addresses.js +1 -1
  215. package/dist/contracts/vaults-addresses.js.map +1 -1
  216. package/dist/errors/base-error.cjs.map +1 -1
  217. package/dist/errors/base-error.js.map +1 -1
  218. package/dist/{getContract-DUA3M2pm.cjs → getContract-D4_SEfqa.cjs} +2 -2
  219. package/dist/{getContract-DUA3M2pm.cjs.map → getContract-D4_SEfqa.cjs.map} +1 -1
  220. package/dist/{getContract-DEPNMZxg.js → getContract-DQN7VDBo.js} +2 -2
  221. package/dist/{getContract-DEPNMZxg.js.map → getContract-DQN7VDBo.js.map} +1 -1
  222. package/dist/http-CajzXkt4.js +4005 -0
  223. package/dist/http-CajzXkt4.js.map +1 -0
  224. package/dist/http-qhIDc8Dn.cjs +5 -0
  225. package/dist/http-qhIDc8Dn.cjs.map +1 -0
  226. package/dist/{localBatchGatewayRequest-CKLnLqib.cjs → localBatchGatewayRequest-C7zYTS2c.cjs} +2 -2
  227. package/dist/{localBatchGatewayRequest-CKLnLqib.cjs.map → localBatchGatewayRequest-C7zYTS2c.cjs.map} +1 -1
  228. package/dist/{localBatchGatewayRequest-C0QtijkB.js → localBatchGatewayRequest-DtOvBmA9.js} +3 -3
  229. package/dist/{localBatchGatewayRequest-C0QtijkB.js.map → localBatchGatewayRequest-DtOvBmA9.js.map} +1 -1
  230. package/dist/main.cjs +1 -1
  231. package/dist/main.js +1 -1
  232. package/dist/secp256k1-CMP_u7qb.cjs +2 -0
  233. package/dist/secp256k1-CMP_u7qb.cjs.map +1 -0
  234. package/dist/secp256k1-DCMgMsfV.js +1297 -0
  235. package/dist/secp256k1-DCMgMsfV.js.map +1 -0
  236. package/dist/utils/time.cjs.map +1 -1
  237. package/dist/utils/time.js.map +1 -1
  238. package/dist/utils/version.cjs +1 -1
  239. package/dist/utils/version.js +1 -1
  240. package/dist/writeContract-BnmmOPwy.cjs +36 -0
  241. package/dist/writeContract-BnmmOPwy.cjs.map +1 -0
  242. package/dist/{writeContract-DkC9wV5p.js → writeContract-DYAfDrRz.js} +1788 -1712
  243. package/dist/writeContract-DYAfDrRz.js.map +1 -0
  244. package/package.json +8 -8
  245. package/dist/ccip-C76-YhQK.js +0 -152
  246. package/dist/ccip-CEodLZ4s.cjs +0 -2
  247. package/dist/constants-CxSgz27h.cjs +0 -9
  248. package/dist/createWalletClient-Cct6ojqI.cjs +0 -5
  249. package/dist/createWalletClient-Cct6ojqI.cjs.map +0 -1
  250. package/dist/createWalletClient-DAuQCrLq.js +0 -3262
  251. package/dist/createWalletClient-DAuQCrLq.js.map +0 -1
  252. package/dist/secp256k1-ClOw2ksU.js +0 -1291
  253. package/dist/secp256k1-ClOw2ksU.js.map +0 -1
  254. package/dist/secp256k1-YUzyTLhP.cjs +0 -2
  255. package/dist/secp256k1-YUzyTLhP.cjs.map +0 -1
  256. package/dist/writeContract-BfAYISeL.cjs +0 -36
  257. package/dist/writeContract-BfAYISeL.cjs.map +0 -1
  258. package/dist/writeContract-DkC9wV5p.js.map +0 -1
@@ -0,0 +1,4005 @@
1
+ import { B as At, C as cn, D as un, E as vr, F as Tt, G as kt, J as Er, K as It, L as Pr, M as re, N as k, O as W, P as dn, Q as xr, m as Ar, R as G, S as O, V as De, W as Fe, X as nt, Y as Tr, h as _, Z as fn, _ as Z, $ as pe, g as A, a0 as Ct, a1 as me, a2 as Rt, a3 as ln, r as F, a4 as Ce, a5 as Nt, a6 as kr, a7 as rt, a8 as st, a9 as Ir, aa as Cr, ab as at, ac as hn, ad as Rr, j as Re, ae as Nr, af as we, H as ue, ag as Br, U as _e, ah as Bt, ai as St, aj as $t, ak as zt, al as _t, am as Ut, an as Ot, ao as Dt, ap as Ft, aq as qt, ar as Lt, as as qe, T as Mt, at as jt, au as Vt, av as Le, aw as Me, ax as Wt, ay as Ht, az as Gt, aA as Zt, aB as Jt, aC as Sr, aD as $r, aE as zr, l as pn, aF as J, aG as ae, aH as q, aI as fe, aJ as mn, aK as _r, aL as ot, aM as M, aN as Ur, aO as Or, aP as Dr, aQ as Ne, aR as je, aS as yn, aT as bn, aU as gn, aV as wn, aW as Fr, aX as qr, aY as Lr, aZ as Mr, a_ as Ve, a$ as jr, b0 as Vr, b1 as vn, b2 as Yt, b3 as En, b4 as Wr, k as Pn, b5 as Hr, b6 as Gr, b7 as X, b8 as Zr, b9 as Jr, ba as Yr, bb as Kr, bc as it, bd as xn, be as ct, w as Qr, s as Xr, bf as An, bg as Tn, bh as kn, bi as es, bj as ts, bk as ns, a as rs, bl as Be, bm as ss, bn as as, e as os, c as is, bo as ye, bp as cs, bq as us, d as ds, br as fs, bs as ls } from "./writeContract-DYAfDrRz.js";
2
+ import { B as $, n as I, c as se, h as H, u as Ae, v as hs, w as In, x as Kt, i as Cn, b as le, a as ps, y as D, s as de, t as oe, z as Te, A as ut, L as ms, D as ke, F as We, G as Rn, I as ys, J as bs, T as Nn, K as gs, M as Bn, N as ws, O as vs, U as Es, P as Ps, e as xs, Q as As, W as Ts, R as ks } from "./constants-CuIEh_ZS.js";
3
+ import { l as dt } from "./localBatchGatewayRequest-DtOvBmA9.js";
4
+ import { secp256k1 as Is } from "./secp256k1-DCMgMsfV.js";
5
+ function Qt(e) {
6
+ let t;
7
+ if (typeof e == "string")
8
+ t = At(e);
9
+ else {
10
+ const n = cn(e), r = e.length;
11
+ for (let s = 0; s < r; s++) {
12
+ const a = e[s];
13
+ if (!un(a)) {
14
+ t = At(a, n);
15
+ break;
16
+ }
17
+ }
18
+ }
19
+ if (!t)
20
+ throw new vr({ signature: e });
21
+ return t;
22
+ }
23
+ function Xt(e) {
24
+ const t = [];
25
+ if (typeof e == "string") {
26
+ const n = Tt(e), r = n.length;
27
+ for (let s = 0; s < r; s++)
28
+ t.push(kt(n[s], { modifiers: It }));
29
+ } else {
30
+ const n = cn(e), r = e.length;
31
+ for (let s = 0; s < r; s++) {
32
+ const a = e[s];
33
+ if (un(a))
34
+ continue;
35
+ const o = Tt(a), i = o.length;
36
+ for (let c = 0; c < i; c++)
37
+ t.push(kt(o[c], { modifiers: It, structs: n }));
38
+ }
39
+ }
40
+ if (t.length === 0)
41
+ throw new Er({ params: e });
42
+ return t;
43
+ }
44
+ function be(e, t) {
45
+ if (ee(e) > t)
46
+ throw new Ls({
47
+ givenSize: ee(e),
48
+ maxSize: t
49
+ });
50
+ }
51
+ const j = {
52
+ zero: 48,
53
+ nine: 57,
54
+ A: 65,
55
+ F: 70,
56
+ a: 97,
57
+ f: 102
58
+ };
59
+ function en(e) {
60
+ if (e >= j.zero && e <= j.nine)
61
+ return e - j.zero;
62
+ if (e >= j.A && e <= j.F)
63
+ return e - (j.A - 10);
64
+ if (e >= j.a && e <= j.f)
65
+ return e - (j.a - 10);
66
+ }
67
+ function Cs(e, t = {}) {
68
+ const { dir: n, size: r = 32 } = t;
69
+ if (r === 0)
70
+ return e;
71
+ if (e.length > r)
72
+ throw new Ms({
73
+ size: e.length,
74
+ targetSize: r,
75
+ type: "Bytes"
76
+ });
77
+ const s = new Uint8Array(r);
78
+ for (let a = 0; a < r; a++) {
79
+ const o = n === "right";
80
+ s[o ? a : r - a - 1] = e[o ? a : e.length - a - 1];
81
+ }
82
+ return s;
83
+ }
84
+ function Sn(e, t = {}) {
85
+ const { dir: n = "left" } = t;
86
+ let r = e, s = 0;
87
+ for (let a = 0; a < r.length - 1 && r[n === "left" ? a : r.length - a - 1].toString() === "0"; a++)
88
+ s++;
89
+ return r = n === "left" ? r.slice(s) : r.slice(0, r.length - s), r;
90
+ }
91
+ const Rs = /* @__PURE__ */ new TextDecoder(), Ns = /* @__PURE__ */ new TextEncoder();
92
+ function Bs(e) {
93
+ return e instanceof Uint8Array ? e : typeof e == "string" ? $n(e) : Ss(e);
94
+ }
95
+ function Ss(e) {
96
+ return e instanceof Uint8Array ? e : new Uint8Array(e);
97
+ }
98
+ function $n(e, t = {}) {
99
+ const { size: n } = t;
100
+ let r = e;
101
+ n && (Pr(e, n), r = re(e, n));
102
+ let s = r.slice(2);
103
+ s.length % 2 && (s = `0${s}`);
104
+ const a = s.length / 2, o = new Uint8Array(a);
105
+ for (let i = 0, c = 0; i < a; i++) {
106
+ const u = en(s.charCodeAt(c++)), d = en(s.charCodeAt(c++));
107
+ if (u === void 0 || d === void 0)
108
+ throw new k(`Invalid byte sequence ("${s[c - 2]}${s[c - 1]}" in "${s}").`);
109
+ o[i] = u * 16 + d;
110
+ }
111
+ return o;
112
+ }
113
+ function $s(e, t = {}) {
114
+ const { size: n } = t, r = Ns.encode(e);
115
+ return typeof n == "number" ? (be(r, n), zs(r, n)) : r;
116
+ }
117
+ function zs(e, t) {
118
+ return Cs(e, { dir: "right", size: t });
119
+ }
120
+ function ee(e) {
121
+ return e.length;
122
+ }
123
+ function _s(e, t, n, r = {}) {
124
+ const { strict: s } = r;
125
+ return e.slice(t, n);
126
+ }
127
+ function Us(e, t = {}) {
128
+ const { size: n } = t;
129
+ typeof n < "u" && be(e, n);
130
+ const r = W(e, t);
131
+ return xr(r, t);
132
+ }
133
+ function Os(e, t = {}) {
134
+ const { size: n } = t;
135
+ let r = e;
136
+ if (typeof n < "u" && (be(r, n), r = zn(r)), r.length > 1 || r[0] > 1)
137
+ throw new qs(r);
138
+ return !!r[0];
139
+ }
140
+ function V(e, t = {}) {
141
+ const { size: n } = t;
142
+ typeof n < "u" && be(e, n);
143
+ const r = W(e, t);
144
+ return dn(r, t);
145
+ }
146
+ function Ds(e, t = {}) {
147
+ const { size: n } = t;
148
+ let r = e;
149
+ return typeof n < "u" && (be(r, n), r = Fs(r)), Rs.decode(r);
150
+ }
151
+ function zn(e) {
152
+ return Sn(e, { dir: "left" });
153
+ }
154
+ function Fs(e) {
155
+ return Sn(e, { dir: "right" });
156
+ }
157
+ class qs extends k {
158
+ constructor(t) {
159
+ super(`Bytes value \`${t}\` is not a valid boolean.`, {
160
+ metaMessages: [
161
+ "The bytes array must contain a single byte of either a `0` or `1` value."
162
+ ]
163
+ }), Object.defineProperty(this, "name", {
164
+ enumerable: !0,
165
+ configurable: !0,
166
+ writable: !0,
167
+ value: "Bytes.InvalidBytesBooleanError"
168
+ });
169
+ }
170
+ }
171
+ class Ls extends k {
172
+ constructor({ givenSize: t, maxSize: n }) {
173
+ super(`Size cannot exceed \`${n}\` bytes. Given size: \`${t}\` bytes.`), Object.defineProperty(this, "name", {
174
+ enumerable: !0,
175
+ configurable: !0,
176
+ writable: !0,
177
+ value: "Bytes.SizeOverflowError"
178
+ });
179
+ }
180
+ }
181
+ class Ms extends k {
182
+ constructor({ size: t, targetSize: n, type: r }) {
183
+ super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${n}\`).`), Object.defineProperty(this, "name", {
184
+ enumerable: !0,
185
+ configurable: !0,
186
+ writable: !0,
187
+ value: "Bytes.SizeExceedsPaddingSizeError"
188
+ });
189
+ }
190
+ }
191
+ class js extends $ {
192
+ constructor(t) {
193
+ super(`Call bundle failed with status: ${t.statusCode}`, {
194
+ name: "BundleFailedError"
195
+ }), Object.defineProperty(this, "result", {
196
+ enumerable: !0,
197
+ configurable: !0,
198
+ writable: !0,
199
+ value: void 0
200
+ }), this.result = t;
201
+ }
202
+ }
203
+ function Ie(e, { delay: t = 100, retryCount: n = 2, shouldRetry: r = () => !0 } = {}) {
204
+ return new Promise((s, a) => {
205
+ const o = async ({ count: i = 0 } = {}) => {
206
+ const c = async ({ error: u }) => {
207
+ const d = typeof t == "function" ? t({ count: i, error: u }) : t;
208
+ d && await Ar(d), o({ count: i + 1 });
209
+ };
210
+ try {
211
+ const u = await e();
212
+ s(u);
213
+ } catch (u) {
214
+ if (i < n && await r({ count: i, error: u }))
215
+ return c({ error: u });
216
+ a(u);
217
+ }
218
+ };
219
+ o();
220
+ });
221
+ }
222
+ const _n = "0x5792579257925792579257925792579257925792579257925792579257925792", Un = I(0, {
223
+ size: 32
224
+ });
225
+ async function Vs(e, t) {
226
+ const { account: n = e.account, capabilities: r, chain: s = e.chain, experimental_fallback: a, experimental_fallbackDelay: o = 32, forceAtomic: i = !1, id: c, version: u = "2.0.0" } = t, d = n ? O(n) : null, l = t.calls.map((f) => {
227
+ const h = f, p = h.abi ? G({
228
+ abi: h.abi,
229
+ functionName: h.functionName,
230
+ args: h.args
231
+ }) : h.data;
232
+ return {
233
+ data: h.dataSuffix && p ? se([p, h.dataSuffix]) : p,
234
+ to: h.to,
235
+ value: h.value ? I(h.value) : void 0
236
+ };
237
+ });
238
+ try {
239
+ const f = await e.request({
240
+ method: "wallet_sendCalls",
241
+ params: [
242
+ {
243
+ atomicRequired: i,
244
+ calls: l,
245
+ capabilities: r,
246
+ chainId: I(s.id),
247
+ from: d?.address,
248
+ id: c,
249
+ version: u
250
+ }
251
+ ]
252
+ }, { retryCount: 0 });
253
+ return typeof f == "string" ? { id: f } : f;
254
+ } catch (f) {
255
+ const h = f;
256
+ if (a && (h.name === "MethodNotFoundRpcError" || h.name === "MethodNotSupportedRpcError" || h.name === "UnknownRpcError" || h.details.toLowerCase().includes("does not exist / is not available") || h.details.toLowerCase().includes("missing or invalid. request()") || h.details.toLowerCase().includes("did not match any variant of untagged enum") || h.details.toLowerCase().includes("account upgraded to unsupported contract") || h.details.toLowerCase().includes("eip-7702 not supported") || h.details.toLowerCase().includes("unsupported wc_ method") || h.details.toLowerCase().includes("feature toggled misconfigured"))) {
257
+ if (r && Object.values(r).some((b) => !b.optional)) {
258
+ const b = "non-optional `capabilities` are not supported on fallback to `eth_sendTransaction`.";
259
+ throw new De(new $(b, {
260
+ details: b
261
+ }));
262
+ }
263
+ if (i && l.length > 1) {
264
+ const m = "`forceAtomic` is not supported on fallback to `eth_sendTransaction`.";
265
+ throw new Fe(new $(m, {
266
+ details: m
267
+ }));
268
+ }
269
+ const p = [];
270
+ for (const m of l) {
271
+ const b = nt(e, {
272
+ account: d,
273
+ chain: s,
274
+ data: m.data,
275
+ to: m.to,
276
+ value: m.value ? H(m.value) : void 0
277
+ });
278
+ p.push(b), o > 0 && await new Promise((w) => setTimeout(w, o));
279
+ }
280
+ const g = await Promise.allSettled(p);
281
+ if (g.every((m) => m.status === "rejected"))
282
+ throw g[0].reason;
283
+ const y = g.map((m) => m.status === "fulfilled" ? m.value : Un);
284
+ return {
285
+ id: se([
286
+ ...y,
287
+ I(s.id, { size: 32 }),
288
+ _n
289
+ ])
290
+ };
291
+ }
292
+ throw Tr(f, {
293
+ ...t,
294
+ account: d,
295
+ chain: t.chain
296
+ });
297
+ }
298
+ }
299
+ async function On(e, t) {
300
+ async function n(d) {
301
+ if (d.endsWith(_n.slice(2))) {
302
+ const f = In(Kt(d, -64, -32)), h = Kt(d, 0, -64).slice(2).match(/.{1,64}/g), p = await Promise.all(h.map((y) => Un.slice(2) !== y ? e.request({
303
+ method: "eth_getTransactionReceipt",
304
+ params: [`0x${y}`]
305
+ }, { dedupe: !0 }) : void 0)), g = p.some((y) => y === null) ? 100 : p.every((y) => y?.status === "0x1") ? 200 : p.every((y) => y?.status === "0x0") ? 500 : 600;
306
+ return {
307
+ atomic: !1,
308
+ chainId: Ae(f),
309
+ receipts: p.filter(Boolean),
310
+ status: g,
311
+ version: "2.0.0"
312
+ };
313
+ }
314
+ return e.request({
315
+ method: "wallet_getCallsStatus",
316
+ params: [d]
317
+ });
318
+ }
319
+ const { atomic: r = !1, chainId: s, receipts: a, version: o = "2.0.0", ...i } = await n(t.id), [c, u] = (() => {
320
+ const d = i.status;
321
+ return d >= 100 && d < 200 ? ["pending", d] : d >= 200 && d < 300 ? ["success", d] : d >= 300 && d < 700 ? ["failure", d] : d === "CONFIRMED" ? ["success", 200] : d === "PENDING" ? ["pending", 100] : [void 0, d];
322
+ })();
323
+ return {
324
+ ...i,
325
+ atomic: r,
326
+ // @ts-expect-error: for backwards compatibility
327
+ chainId: s ? Ae(s) : void 0,
328
+ receipts: a?.map((d) => ({
329
+ ...d,
330
+ blockNumber: H(d.blockNumber),
331
+ gasUsed: H(d.gasUsed),
332
+ status: hs[d.status]
333
+ })) ?? [],
334
+ statusCode: u,
335
+ status: c,
336
+ version: o
337
+ };
338
+ }
339
+ async function Ws(e, t) {
340
+ const {
341
+ id: n,
342
+ pollingInterval: r = e.pollingInterval,
343
+ status: s = ({ statusCode: g }) => g === 200 || g >= 300,
344
+ retryCount: a = 4,
345
+ retryDelay: o = ({ count: g }) => ~~(1 << g) * 200,
346
+ // exponential backoff
347
+ timeout: i = 6e4,
348
+ throwOnFailure: c = !1
349
+ } = t, u = _(["waitForCallsStatus", e.uid, n]), { promise: d, resolve: l, reject: f } = fn();
350
+ let h;
351
+ const p = Z(u, { resolve: l, reject: f }, (g) => {
352
+ const y = pe(async () => {
353
+ const m = (b) => {
354
+ clearTimeout(h), y(), b(), p();
355
+ };
356
+ try {
357
+ const b = await Ie(async () => {
358
+ const w = await A(e, On, "getCallsStatus")({ id: n });
359
+ if (c && w.status === "failure")
360
+ throw new js(w);
361
+ return w;
362
+ }, {
363
+ retryCount: a,
364
+ delay: o
365
+ });
366
+ if (!s(b))
367
+ return;
368
+ m(() => g.resolve(b));
369
+ } catch (b) {
370
+ m(() => g.reject(b));
371
+ }
372
+ }, {
373
+ interval: r,
374
+ emitOnBegin: !0
375
+ });
376
+ return y;
377
+ });
378
+ return h = i ? setTimeout(() => {
379
+ p(), clearTimeout(h), f(new Hs({ id: n }));
380
+ }, i) : void 0, await d;
381
+ }
382
+ class Hs extends $ {
383
+ constructor({ id: t }) {
384
+ super(`Timed out while waiting for call bundle with id "${t}" to be confirmed.`, { name: "WaitForCallsStatusTimeoutError" });
385
+ }
386
+ }
387
+ const He = 256;
388
+ let ve = He, Ee;
389
+ function Dn(e = 11) {
390
+ if (!Ee || ve + e > He * 2) {
391
+ Ee = "", ve = 0;
392
+ for (let t = 0; t < He; t++)
393
+ Ee += (256 + Math.random() * 256 | 0).toString(16).substring(1);
394
+ }
395
+ return Ee.substring(ve, ve++ + e);
396
+ }
397
+ function Fn(e) {
398
+ const { batch: t, chain: n, ccipRead: r, key: s = "base", name: a = "Base Client", type: o = "base" } = e, i = e.experimental_blockTag ?? (typeof n?.experimental_preconfirmationTime == "number" ? "pending" : void 0), c = n?.blockTime ?? 12e3, u = Math.min(Math.max(Math.floor(c / 2), 500), 4e3), d = e.pollingInterval ?? u, l = e.cacheTime ?? d, f = e.account ? O(e.account) : void 0, { config: h, request: p, value: g } = e.transport({
399
+ chain: n,
400
+ pollingInterval: d
401
+ }), y = { ...h, ...g }, m = {
402
+ account: f,
403
+ batch: t,
404
+ cacheTime: l,
405
+ ccipRead: r,
406
+ chain: n,
407
+ key: s,
408
+ name: a,
409
+ pollingInterval: d,
410
+ request: p,
411
+ transport: y,
412
+ type: o,
413
+ uid: Dn(),
414
+ ...i ? { experimental_blockTag: i } : {}
415
+ };
416
+ function b(w) {
417
+ return (P) => {
418
+ const x = P(w);
419
+ for (const v in m)
420
+ delete x[v];
421
+ const T = { ...w, ...x };
422
+ return Object.assign(T, { extend: b(T) });
423
+ };
424
+ }
425
+ return Object.assign(m, { extend: b(m) });
426
+ }
427
+ function ft(e) {
428
+ if (!(e instanceof $))
429
+ return !1;
430
+ const t = e.walk((n) => n instanceof Ct);
431
+ return t instanceof Ct ? t.data?.errorName === "HttpError" || t.data?.errorName === "ResolverError" || t.data?.errorName === "ResolverNotContract" || t.data?.errorName === "ResolverNotFound" || t.data?.errorName === "ReverseAddressMismatch" || t.data?.errorName === "UnsupportedResolverProfile" : !1;
432
+ }
433
+ function qn(e) {
434
+ if (e.length !== 66 || e.indexOf("[") !== 0 || e.indexOf("]") !== 65)
435
+ return null;
436
+ const t = `0x${e.slice(1, 65)}`;
437
+ return Cn(t) ? t : null;
438
+ }
439
+ function Ge(e) {
440
+ let t = new Uint8Array(32).fill(0);
441
+ if (!e)
442
+ return le(t);
443
+ const n = e.split(".");
444
+ for (let r = n.length - 1; r >= 0; r -= 1) {
445
+ const s = qn(n[r]), a = s ? ps(s) : D(de(n[r]), "bytes");
446
+ t = D(se([t, a]), "bytes");
447
+ }
448
+ return le(t);
449
+ }
450
+ function Gs(e) {
451
+ return `[${e.slice(2)}]`;
452
+ }
453
+ function Zs(e) {
454
+ const t = new Uint8Array(32).fill(0);
455
+ return e ? qn(e) || D(de(e)) : le(t);
456
+ }
457
+ function lt(e) {
458
+ const t = e.replace(/^\.|\.$/gm, "");
459
+ if (t.length === 0)
460
+ return new Uint8Array(1);
461
+ const n = new Uint8Array(de(t).byteLength + 2);
462
+ let r = 0;
463
+ const s = t.split(".");
464
+ for (let a = 0; a < s.length; a++) {
465
+ let o = de(s[a]);
466
+ o.byteLength > 255 && (o = de(Gs(Zs(s[a])))), n[r] = o.length, n.set(o, r + 1), r += o.length + 1;
467
+ }
468
+ return n.byteLength !== r + 1 ? n.slice(0, r + 1) : n;
469
+ }
470
+ async function Js(e, t) {
471
+ const { blockNumber: n, blockTag: r, coinType: s, name: a, gatewayUrls: o, strict: i } = t, { chain: c } = e, u = (() => {
472
+ if (t.universalResolverAddress)
473
+ return t.universalResolverAddress;
474
+ if (!c)
475
+ throw new Error("client chain not configured. universalResolverAddress is required.");
476
+ return me({
477
+ blockNumber: n,
478
+ chain: c,
479
+ contract: "ensUniversalResolver"
480
+ });
481
+ })(), d = c?.ensTlds;
482
+ if (d && !d.some((f) => a.endsWith(f)))
483
+ return null;
484
+ const l = s != null ? [Ge(a), BigInt(s)] : [Ge(a)];
485
+ try {
486
+ const f = G({
487
+ abi: Rt,
488
+ functionName: "addr",
489
+ args: l
490
+ }), h = {
491
+ address: u,
492
+ abi: ln,
493
+ functionName: "resolveWithGateways",
494
+ args: [
495
+ oe(lt(a)),
496
+ f,
497
+ o ?? [dt]
498
+ ],
499
+ blockNumber: n,
500
+ blockTag: r
501
+ }, g = await A(e, F, "readContract")(h);
502
+ if (g[0] === "0x")
503
+ return null;
504
+ const y = Ce({
505
+ abi: Rt,
506
+ args: l,
507
+ functionName: "addr",
508
+ data: g[0]
509
+ });
510
+ return y === "0x" || In(y) === "0x00" ? null : y;
511
+ } catch (f) {
512
+ if (i)
513
+ throw f;
514
+ if (ft(f))
515
+ return null;
516
+ throw f;
517
+ }
518
+ }
519
+ class Ys extends $ {
520
+ constructor({ data: t }) {
521
+ super("Unable to extract image from metadata. The metadata may be malformed or invalid.", {
522
+ metaMessages: [
523
+ "- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.",
524
+ "",
525
+ `Provided data: ${JSON.stringify(t)}`
526
+ ],
527
+ name: "EnsAvatarInvalidMetadataError"
528
+ });
529
+ }
530
+ }
531
+ class ce extends $ {
532
+ constructor({ reason: t }) {
533
+ super(`ENS NFT avatar URI is invalid. ${t}`, {
534
+ name: "EnsAvatarInvalidNftUriError"
535
+ });
536
+ }
537
+ }
538
+ class ht extends $ {
539
+ constructor({ uri: t }) {
540
+ super(`Unable to resolve ENS avatar URI "${t}". The URI may be malformed, invalid, or does not respond with a valid image.`, { name: "EnsAvatarUriResolutionError" });
541
+ }
542
+ }
543
+ class Ks extends $ {
544
+ constructor({ namespace: t }) {
545
+ super(`ENS NFT avatar namespace "${t}" is not supported. Must be "erc721" or "erc1155".`, { name: "EnsAvatarUnsupportedNamespaceError" });
546
+ }
547
+ }
548
+ const Qs = /(?<protocol>https?:\/\/[^/]*|ipfs:\/|ipns:\/|ar:\/)?(?<root>\/)?(?<subpath>ipfs\/|ipns\/)?(?<target>[\w\-.]+)(?<subtarget>\/.*)?/, Xs = /^(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>\/.*)?$/, ea = /^data:([a-zA-Z\-/+]*);base64,([^"].*)/, ta = /^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;
549
+ async function na(e) {
550
+ try {
551
+ const t = await fetch(e, { method: "HEAD" });
552
+ return t.status === 200 ? t.headers.get("content-type")?.startsWith("image/") : !1;
553
+ } catch (t) {
554
+ return typeof t == "object" && typeof t.response < "u" || !Object.hasOwn(globalThis, "Image") ? !1 : new Promise((n) => {
555
+ const r = new Image();
556
+ r.onload = () => {
557
+ n(!0);
558
+ }, r.onerror = () => {
559
+ n(!1);
560
+ }, r.src = e;
561
+ });
562
+ }
563
+ }
564
+ function tn(e, t) {
565
+ return e ? e.endsWith("/") ? e.slice(0, -1) : e : t;
566
+ }
567
+ function Ln({ uri: e, gatewayUrls: t }) {
568
+ const n = ea.test(e);
569
+ if (n)
570
+ return { uri: e, isOnChain: !0, isEncoded: n };
571
+ const r = tn(t?.ipfs, "https://ipfs.io"), s = tn(t?.arweave, "https://arweave.net"), a = e.match(Qs), { protocol: o, subpath: i, target: c, subtarget: u = "" } = a?.groups || {}, d = o === "ipns:/" || i === "ipns/", l = o === "ipfs:/" || i === "ipfs/" || Xs.test(e);
572
+ if (e.startsWith("http") && !d && !l) {
573
+ let h = e;
574
+ return t?.arweave && (h = e.replace(/https:\/\/arweave.net/g, t?.arweave)), { uri: h, isOnChain: !1, isEncoded: !1 };
575
+ }
576
+ if ((d || l) && c)
577
+ return {
578
+ uri: `${r}/${d ? "ipns" : "ipfs"}/${c}${u}`,
579
+ isOnChain: !1,
580
+ isEncoded: !1
581
+ };
582
+ if (o === "ar:/" && c)
583
+ return {
584
+ uri: `${s}/${c}${u || ""}`,
585
+ isOnChain: !1,
586
+ isEncoded: !1
587
+ };
588
+ let f = e.replace(ta, "");
589
+ if (f.startsWith("<svg") && (f = `data:image/svg+xml;base64,${btoa(f)}`), f.startsWith("data:") || f.startsWith("{"))
590
+ return {
591
+ uri: f,
592
+ isOnChain: !0,
593
+ isEncoded: !1
594
+ };
595
+ throw new ht({ uri: e });
596
+ }
597
+ function Mn(e) {
598
+ if (typeof e != "object" || !("image" in e) && !("image_url" in e) && !("image_data" in e))
599
+ throw new Ys({ data: e });
600
+ return e.image || e.image_url || e.image_data;
601
+ }
602
+ async function ra({ gatewayUrls: e, uri: t }) {
603
+ try {
604
+ const n = await fetch(t).then((s) => s.json());
605
+ return await pt({
606
+ gatewayUrls: e,
607
+ uri: Mn(n)
608
+ });
609
+ } catch {
610
+ throw new ht({ uri: t });
611
+ }
612
+ }
613
+ async function pt({ gatewayUrls: e, uri: t }) {
614
+ const { uri: n, isOnChain: r } = Ln({ uri: t, gatewayUrls: e });
615
+ if (r || await na(n))
616
+ return n;
617
+ throw new ht({ uri: t });
618
+ }
619
+ function sa(e) {
620
+ let t = e;
621
+ t.startsWith("did:nft:") && (t = t.replace("did:nft:", "").replace(/_/g, "/"));
622
+ const [n, r, s] = t.split("/"), [a, o] = n.split(":"), [i, c] = r.split(":");
623
+ if (!a || a.toLowerCase() !== "eip155")
624
+ throw new ce({ reason: "Only EIP-155 supported" });
625
+ if (!o)
626
+ throw new ce({ reason: "Chain ID not found" });
627
+ if (!c)
628
+ throw new ce({
629
+ reason: "Contract address not found"
630
+ });
631
+ if (!s)
632
+ throw new ce({ reason: "Token ID not found" });
633
+ if (!i)
634
+ throw new ce({ reason: "ERC namespace not found" });
635
+ return {
636
+ chainID: Number.parseInt(o, 10),
637
+ namespace: i.toLowerCase(),
638
+ contractAddress: c,
639
+ tokenID: s
640
+ };
641
+ }
642
+ async function aa(e, { nft: t }) {
643
+ if (t.namespace === "erc721")
644
+ return F(e, {
645
+ address: t.contractAddress,
646
+ abi: [
647
+ {
648
+ name: "tokenURI",
649
+ type: "function",
650
+ stateMutability: "view",
651
+ inputs: [{ name: "tokenId", type: "uint256" }],
652
+ outputs: [{ name: "", type: "string" }]
653
+ }
654
+ ],
655
+ functionName: "tokenURI",
656
+ args: [BigInt(t.tokenID)]
657
+ });
658
+ if (t.namespace === "erc1155")
659
+ return F(e, {
660
+ address: t.contractAddress,
661
+ abi: [
662
+ {
663
+ name: "uri",
664
+ type: "function",
665
+ stateMutability: "view",
666
+ inputs: [{ name: "_id", type: "uint256" }],
667
+ outputs: [{ name: "", type: "string" }]
668
+ }
669
+ ],
670
+ functionName: "uri",
671
+ args: [BigInt(t.tokenID)]
672
+ });
673
+ throw new Ks({ namespace: t.namespace });
674
+ }
675
+ async function oa(e, { gatewayUrls: t, record: n }) {
676
+ return /eip155:/i.test(n) ? ia(e, { gatewayUrls: t, record: n }) : pt({ uri: n, gatewayUrls: t });
677
+ }
678
+ async function ia(e, { gatewayUrls: t, record: n }) {
679
+ const r = sa(n), s = await aa(e, { nft: r }), { uri: a, isOnChain: o, isEncoded: i } = Ln({ uri: s, gatewayUrls: t });
680
+ if (o && (a.includes("data:application/json;base64,") || a.startsWith("{"))) {
681
+ const u = i ? (
682
+ // if it is encoded, decode it
683
+ atob(a.replace("data:application/json;base64,", ""))
684
+ ) : (
685
+ // if it isn't encoded assume it is a JSON string, but it could be anything (it will error if it is)
686
+ a
687
+ ), d = JSON.parse(u);
688
+ return pt({ uri: Mn(d), gatewayUrls: t });
689
+ }
690
+ let c = r.tokenID;
691
+ return r.namespace === "erc1155" && (c = c.replace("0x", "").padStart(64, "0")), ra({
692
+ gatewayUrls: t,
693
+ uri: a.replace(/(?:0x)?{id}/, c)
694
+ });
695
+ }
696
+ async function jn(e, t) {
697
+ const { blockNumber: n, blockTag: r, key: s, name: a, gatewayUrls: o, strict: i } = t, { chain: c } = e, u = (() => {
698
+ if (t.universalResolverAddress)
699
+ return t.universalResolverAddress;
700
+ if (!c)
701
+ throw new Error("client chain not configured. universalResolverAddress is required.");
702
+ return me({
703
+ blockNumber: n,
704
+ chain: c,
705
+ contract: "ensUniversalResolver"
706
+ });
707
+ })(), d = c?.ensTlds;
708
+ if (d && !d.some((l) => a.endsWith(l)))
709
+ return null;
710
+ try {
711
+ const l = {
712
+ address: u,
713
+ abi: ln,
714
+ args: [
715
+ oe(lt(a)),
716
+ G({
717
+ abi: Nt,
718
+ functionName: "text",
719
+ args: [Ge(a), s]
720
+ }),
721
+ o ?? [dt]
722
+ ],
723
+ functionName: "resolveWithGateways",
724
+ blockNumber: n,
725
+ blockTag: r
726
+ }, h = await A(e, F, "readContract")(l);
727
+ if (h[0] === "0x")
728
+ return null;
729
+ const p = Ce({
730
+ abi: Nt,
731
+ functionName: "text",
732
+ data: h[0]
733
+ });
734
+ return p === "" ? null : p;
735
+ } catch (l) {
736
+ if (i)
737
+ throw l;
738
+ if (ft(l))
739
+ return null;
740
+ throw l;
741
+ }
742
+ }
743
+ async function ca(e, { blockNumber: t, blockTag: n, assetGatewayUrls: r, name: s, gatewayUrls: a, strict: o, universalResolverAddress: i }) {
744
+ const c = await A(e, jn, "getEnsText")({
745
+ blockNumber: t,
746
+ blockTag: n,
747
+ key: "avatar",
748
+ name: s,
749
+ universalResolverAddress: i,
750
+ gatewayUrls: a,
751
+ strict: o
752
+ });
753
+ if (!c)
754
+ return null;
755
+ try {
756
+ return await oa(e, {
757
+ record: c,
758
+ gatewayUrls: r
759
+ });
760
+ } catch {
761
+ return null;
762
+ }
763
+ }
764
+ async function ua(e, t) {
765
+ const { address: n, blockNumber: r, blockTag: s, coinType: a = 60n, gatewayUrls: o, strict: i } = t, { chain: c } = e, u = (() => {
766
+ if (t.universalResolverAddress)
767
+ return t.universalResolverAddress;
768
+ if (!c)
769
+ throw new Error("client chain not configured. universalResolverAddress is required.");
770
+ return me({
771
+ blockNumber: r,
772
+ chain: c,
773
+ contract: "ensUniversalResolver"
774
+ });
775
+ })();
776
+ try {
777
+ const d = {
778
+ address: u,
779
+ abi: kr,
780
+ args: [n, a, o ?? [dt]],
781
+ functionName: "reverseWithGateways",
782
+ blockNumber: r,
783
+ blockTag: s
784
+ }, l = A(e, F, "readContract"), [f] = await l(d);
785
+ return f || null;
786
+ } catch (d) {
787
+ if (i)
788
+ throw d;
789
+ if (ft(d))
790
+ return null;
791
+ throw d;
792
+ }
793
+ }
794
+ async function da(e, t) {
795
+ const { blockNumber: n, blockTag: r, name: s } = t, { chain: a } = e, o = (() => {
796
+ if (t.universalResolverAddress)
797
+ return t.universalResolverAddress;
798
+ if (!a)
799
+ throw new Error("client chain not configured. universalResolverAddress is required.");
800
+ return me({
801
+ blockNumber: n,
802
+ chain: a,
803
+ contract: "ensUniversalResolver"
804
+ });
805
+ })(), i = a?.ensTlds;
806
+ if (i && !i.some((u) => s.endsWith(u)))
807
+ throw new Error(`${s} is not a valid ENS TLD (${i?.join(", ")}) for chain "${a.name}" (id: ${a.id}).`);
808
+ const [c] = await A(e, F, "readContract")({
809
+ address: o,
810
+ abi: [
811
+ {
812
+ inputs: [{ type: "bytes" }],
813
+ name: "findResolver",
814
+ outputs: [
815
+ { type: "address" },
816
+ { type: "bytes32" },
817
+ { type: "uint256" }
818
+ ],
819
+ stateMutability: "view",
820
+ type: "function"
821
+ }
822
+ ],
823
+ functionName: "findResolver",
824
+ args: [oe(lt(s))],
825
+ blockNumber: n,
826
+ blockTag: r
827
+ });
828
+ return c;
829
+ }
830
+ async function Vn(e, t) {
831
+ const { account: n = e.account, blockNumber: r, blockTag: s = "latest", blobs: a, data: o, gas: i, gasPrice: c, maxFeePerBlobGas: u, maxFeePerGas: d, maxPriorityFeePerGas: l, to: f, value: h, ...p } = t, g = n ? O(n) : void 0;
832
+ try {
833
+ rt(t);
834
+ const m = (typeof r == "bigint" ? I(r) : void 0) || s, b = e.chain?.formatters?.transactionRequest?.format, P = (b || st)({
835
+ // Pick out extra data that might exist on the chain's transaction request type.
836
+ ...Ir(p, { format: b }),
837
+ from: g?.address,
838
+ blobs: a,
839
+ data: o,
840
+ gas: i,
841
+ gasPrice: c,
842
+ maxFeePerBlobGas: u,
843
+ maxFeePerGas: d,
844
+ maxPriorityFeePerGas: l,
845
+ to: f,
846
+ value: h
847
+ }), x = await e.request({
848
+ method: "eth_createAccessList",
849
+ params: [P, m]
850
+ });
851
+ return {
852
+ accessList: x.accessList,
853
+ gasUsed: BigInt(x.gasUsed)
854
+ };
855
+ } catch (y) {
856
+ throw Cr(y, {
857
+ ...t,
858
+ account: g,
859
+ chain: e.chain
860
+ });
861
+ }
862
+ }
863
+ async function fa(e) {
864
+ const t = at(e, {
865
+ method: "eth_newBlockFilter"
866
+ }), n = await e.request({
867
+ method: "eth_newBlockFilter"
868
+ });
869
+ return { id: n, request: t(n), type: "block" };
870
+ }
871
+ async function Wn(e, { address: t, args: n, event: r, events: s, fromBlock: a, strict: o, toBlock: i } = {}) {
872
+ const c = s ?? (r ? [r] : void 0), u = at(e, {
873
+ method: "eth_newFilter"
874
+ });
875
+ let d = [];
876
+ c && (d = [c.flatMap((h) => hn({
877
+ abi: [h],
878
+ eventName: h.name,
879
+ args: n
880
+ }))], r && (d = d[0]));
881
+ const l = await e.request({
882
+ method: "eth_newFilter",
883
+ params: [
884
+ {
885
+ address: t,
886
+ fromBlock: typeof a == "bigint" ? I(a) : a,
887
+ toBlock: typeof i == "bigint" ? I(i) : i,
888
+ ...d.length ? { topics: d } : {}
889
+ }
890
+ ]
891
+ });
892
+ return {
893
+ abi: c,
894
+ args: n,
895
+ eventName: r ? r.name : void 0,
896
+ fromBlock: a,
897
+ id: l,
898
+ request: u(l),
899
+ strict: !!o,
900
+ toBlock: i,
901
+ type: "event"
902
+ };
903
+ }
904
+ async function Hn(e) {
905
+ const t = at(e, {
906
+ method: "eth_newPendingTransactionFilter"
907
+ }), n = await e.request({
908
+ method: "eth_newPendingTransactionFilter"
909
+ });
910
+ return { id: n, request: t(n), type: "transaction" };
911
+ }
912
+ async function la(e) {
913
+ const t = await e.request({
914
+ method: "eth_blobBaseFee"
915
+ });
916
+ return BigInt(t);
917
+ }
918
+ async function ha(e, { blockHash: t, blockNumber: n, blockTag: r = "latest" } = {}) {
919
+ const s = n !== void 0 ? I(n) : void 0;
920
+ let a;
921
+ return t ? a = await e.request({
922
+ method: "eth_getBlockTransactionCountByHash",
923
+ params: [t]
924
+ }, { dedupe: !0 }) : a = await e.request({
925
+ method: "eth_getBlockTransactionCountByNumber",
926
+ params: [s || r]
927
+ }, { dedupe: !!s }), Ae(a);
928
+ }
929
+ async function Ze(e, { address: t, blockNumber: n, blockTag: r = "latest" }) {
930
+ const s = n !== void 0 ? I(n) : void 0, a = await e.request({
931
+ method: "eth_getCode",
932
+ params: [t, s || r]
933
+ }, { dedupe: !!s });
934
+ if (a !== "0x")
935
+ return a;
936
+ }
937
+ class pa extends $ {
938
+ constructor({ address: t }) {
939
+ super(`No EIP-712 domain found on contract "${t}".`, {
940
+ metaMessages: [
941
+ "Ensure that:",
942
+ `- The contract is deployed at the address "${t}".`,
943
+ "- `eip712Domain()` function exists on the contract.",
944
+ "- `eip712Domain()` function matches signature to ERC-5267 specification."
945
+ ],
946
+ name: "Eip712DomainNotFoundError"
947
+ });
948
+ }
949
+ }
950
+ async function ma(e, t) {
951
+ const { address: n, factory: r, factoryData: s } = t;
952
+ try {
953
+ const [a, o, i, c, u, d, l] = await A(e, F, "readContract")({
954
+ abi: ya,
955
+ address: n,
956
+ functionName: "eip712Domain",
957
+ factory: r,
958
+ factoryData: s
959
+ });
960
+ return {
961
+ domain: {
962
+ name: o,
963
+ version: i,
964
+ chainId: Number(c),
965
+ verifyingContract: u,
966
+ salt: d
967
+ },
968
+ extensions: l,
969
+ fields: a
970
+ };
971
+ } catch (a) {
972
+ const o = a;
973
+ throw o.name === "ContractFunctionExecutionError" && o.cause.name === "ContractFunctionZeroDataError" ? new pa({ address: n }) : o;
974
+ }
975
+ }
976
+ const ya = [
977
+ {
978
+ inputs: [],
979
+ name: "eip712Domain",
980
+ outputs: [
981
+ { name: "fields", type: "bytes1" },
982
+ { name: "name", type: "string" },
983
+ { name: "version", type: "string" },
984
+ { name: "chainId", type: "uint256" },
985
+ { name: "verifyingContract", type: "address" },
986
+ { name: "salt", type: "bytes32" },
987
+ { name: "extensions", type: "uint256[]" }
988
+ ],
989
+ stateMutability: "view",
990
+ type: "function"
991
+ }
992
+ ];
993
+ function ba(e) {
994
+ return {
995
+ baseFeePerGas: e.baseFeePerGas.map((t) => BigInt(t)),
996
+ gasUsedRatio: e.gasUsedRatio,
997
+ oldestBlock: BigInt(e.oldestBlock),
998
+ reward: e.reward?.map((t) => t.map((n) => BigInt(n)))
999
+ };
1000
+ }
1001
+ async function ga(e, { blockCount: t, blockNumber: n, blockTag: r = "latest", rewardPercentiles: s }) {
1002
+ const a = typeof n == "bigint" ? I(n) : void 0, o = await e.request({
1003
+ method: "eth_feeHistory",
1004
+ params: [
1005
+ I(t),
1006
+ a || r,
1007
+ s
1008
+ ]
1009
+ }, { dedupe: !!a });
1010
+ return ba(o);
1011
+ }
1012
+ async function wa(e, { filter: t }) {
1013
+ const n = t.strict ?? !1, s = (await t.request({
1014
+ method: "eth_getFilterLogs",
1015
+ params: [t.id]
1016
+ })).map((a) => Te(a));
1017
+ return t.abi ? Rr({
1018
+ abi: t.abi,
1019
+ logs: s,
1020
+ strict: n
1021
+ }) : s;
1022
+ }
1023
+ async function va({ address: e, authorization: t, signature: n }) {
1024
+ return Re(ut(e), await Nr({
1025
+ authorization: t,
1026
+ signature: n
1027
+ }));
1028
+ }
1029
+ const Pe = /* @__PURE__ */ new ms(8192);
1030
+ function Ea(e, { enabled: t = !0, id: n }) {
1031
+ if (!t || !n)
1032
+ return e();
1033
+ if (Pe.get(n))
1034
+ return Pe.get(n);
1035
+ const r = e().finally(() => Pe.delete(n));
1036
+ return Pe.set(n, r), r;
1037
+ }
1038
+ function Pa(e, t = {}) {
1039
+ return async (n, r = {}) => {
1040
+ const { dedupe: s = !1, methods: a, retryDelay: o = 150, retryCount: i = 3, uid: c } = {
1041
+ ...t,
1042
+ ...r
1043
+ }, { method: u } = n;
1044
+ if (a?.exclude?.includes(u))
1045
+ throw new we(new Error("method not supported"), {
1046
+ method: u
1047
+ });
1048
+ if (a?.include && !a.include.includes(u))
1049
+ throw new we(new Error("method not supported"), {
1050
+ method: u
1051
+ });
1052
+ const d = s ? ke(`${c}.${_(n)}`) : void 0;
1053
+ return Ea(() => Ie(async () => {
1054
+ try {
1055
+ return await e(n);
1056
+ } catch (l) {
1057
+ const f = l;
1058
+ switch (f.code) {
1059
+ // -32700
1060
+ case Zt.code:
1061
+ throw new Zt(f);
1062
+ // -32600
1063
+ case Gt.code:
1064
+ throw new Gt(f);
1065
+ // -32601
1066
+ case Ht.code:
1067
+ throw new Ht(f, { method: n.method });
1068
+ // -32602
1069
+ case Wt.code:
1070
+ throw new Wt(f);
1071
+ // -32603
1072
+ case Me.code:
1073
+ throw new Me(f);
1074
+ // -32000
1075
+ case Le.code:
1076
+ throw new Le(f);
1077
+ // -32001
1078
+ case Vt.code:
1079
+ throw new Vt(f);
1080
+ // -32002
1081
+ case jt.code:
1082
+ throw new jt(f);
1083
+ // -32003
1084
+ case Mt.code:
1085
+ throw new Mt(f);
1086
+ // -32004
1087
+ case we.code:
1088
+ throw new we(f, {
1089
+ method: n.method
1090
+ });
1091
+ // -32005
1092
+ case qe.code:
1093
+ throw new qe(f);
1094
+ // -32006
1095
+ case Lt.code:
1096
+ throw new Lt(f);
1097
+ // 4001
1098
+ case _e.code:
1099
+ throw new _e(f);
1100
+ // 4100
1101
+ case qt.code:
1102
+ throw new qt(f);
1103
+ // 4200
1104
+ case Ft.code:
1105
+ throw new Ft(f);
1106
+ // 4900
1107
+ case Dt.code:
1108
+ throw new Dt(f);
1109
+ // 4901
1110
+ case Ot.code:
1111
+ throw new Ot(f);
1112
+ // 4902
1113
+ case Ut.code:
1114
+ throw new Ut(f);
1115
+ // 5700
1116
+ case De.code:
1117
+ throw new De(f);
1118
+ // 5710
1119
+ case _t.code:
1120
+ throw new _t(f);
1121
+ // 5720
1122
+ case zt.code:
1123
+ throw new zt(f);
1124
+ // 5730
1125
+ case $t.code:
1126
+ throw new $t(f);
1127
+ // 5740
1128
+ case St.code:
1129
+ throw new St(f);
1130
+ // 5750
1131
+ case Bt.code:
1132
+ throw new Bt(f);
1133
+ // 5760
1134
+ case Fe.code:
1135
+ throw new Fe(f);
1136
+ // CAIP-25: User Rejected Error
1137
+ // https://docs.walletconnect.com/2.0/specs/clients/sign/error-codes#rejected-caip-25
1138
+ case 5e3:
1139
+ throw new _e(f);
1140
+ default:
1141
+ throw l instanceof $ ? l : new Br(f);
1142
+ }
1143
+ }
1144
+ }, {
1145
+ delay: ({ count: l, error: f }) => {
1146
+ if (f && f instanceof ue) {
1147
+ const h = f?.headers?.get("Retry-After");
1148
+ if (h?.match(/\d/))
1149
+ return Number.parseInt(h, 10) * 1e3;
1150
+ }
1151
+ return ~~(1 << l) * o;
1152
+ },
1153
+ retryCount: i,
1154
+ shouldRetry: ({ error: l }) => xa(l)
1155
+ }), { enabled: s, id: d });
1156
+ };
1157
+ }
1158
+ function xa(e) {
1159
+ return "code" in e && typeof e.code == "number" ? e.code === -1 || e.code === qe.code || e.code === Me.code : e instanceof ue && 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;
1160
+ }
1161
+ function Aa(e, { errorInstance: t = new Error("timed out"), timeout: n, signal: r }) {
1162
+ return new Promise((s, a) => {
1163
+ (async () => {
1164
+ let o;
1165
+ try {
1166
+ const i = new AbortController();
1167
+ n > 0 && (o = setTimeout(() => {
1168
+ r && i.abort();
1169
+ }, n)), s(await e({ signal: i?.signal || null }));
1170
+ } catch (i) {
1171
+ i?.name === "AbortError" && a(t), a(i);
1172
+ } finally {
1173
+ clearTimeout(o);
1174
+ }
1175
+ })();
1176
+ });
1177
+ }
1178
+ function Ta() {
1179
+ return {
1180
+ current: 0,
1181
+ take() {
1182
+ return this.current++;
1183
+ },
1184
+ reset() {
1185
+ this.current = 0;
1186
+ }
1187
+ };
1188
+ }
1189
+ const nn = /* @__PURE__ */ Ta();
1190
+ function ka(e, t = {}) {
1191
+ return {
1192
+ async request(n) {
1193
+ const { body: r, fetchFn: s = t.fetchFn ?? fetch, onRequest: a = t.onRequest, onResponse: o = t.onResponse, timeout: i = t.timeout ?? 1e4 } = n, c = {
1194
+ ...t.fetchOptions ?? {},
1195
+ ...n.fetchOptions ?? {}
1196
+ }, { headers: u, method: d, signal: l } = c;
1197
+ try {
1198
+ const f = await Aa(async ({ signal: p }) => {
1199
+ const g = {
1200
+ ...c,
1201
+ body: Array.isArray(r) ? _(r.map((w) => ({
1202
+ jsonrpc: "2.0",
1203
+ id: w.id ?? nn.take(),
1204
+ ...w
1205
+ }))) : _({
1206
+ jsonrpc: "2.0",
1207
+ id: r.id ?? nn.take(),
1208
+ ...r
1209
+ }),
1210
+ headers: {
1211
+ "Content-Type": "application/json",
1212
+ ...u
1213
+ },
1214
+ method: d || "POST",
1215
+ signal: l || (i > 0 ? p : null)
1216
+ }, y = new Request(e, g), m = await a?.(y, g) ?? { ...g, url: e };
1217
+ return await s(m.url ?? e, m);
1218
+ }, {
1219
+ errorInstance: new Jt({ body: r, url: e }),
1220
+ timeout: i,
1221
+ signal: !0
1222
+ });
1223
+ o && await o(f);
1224
+ let h;
1225
+ if (f.headers.get("Content-Type")?.startsWith("application/json"))
1226
+ h = await f.json();
1227
+ else {
1228
+ h = await f.text();
1229
+ try {
1230
+ h = JSON.parse(h || "{}");
1231
+ } catch (p) {
1232
+ if (f.ok)
1233
+ throw p;
1234
+ h = { error: h };
1235
+ }
1236
+ }
1237
+ if (!f.ok)
1238
+ throw new ue({
1239
+ body: r,
1240
+ details: _(h.error) || f.statusText,
1241
+ headers: f.headers,
1242
+ status: f.status,
1243
+ url: e
1244
+ });
1245
+ return h;
1246
+ } catch (f) {
1247
+ throw f instanceof ue || f instanceof Jt ? f : new ue({
1248
+ body: r,
1249
+ cause: f,
1250
+ url: e
1251
+ });
1252
+ }
1253
+ }
1254
+ };
1255
+ }
1256
+ const Ia = `Ethereum Signed Message:
1257
+ `;
1258
+ function Ca(e) {
1259
+ const t = typeof e == "string" ? ke(e) : typeof e.raw == "string" ? e.raw : le(e.raw), n = ke(`${Ia}${We(t)}`);
1260
+ return se([n, t]);
1261
+ }
1262
+ function Gn(e, t) {
1263
+ return D(Ca(e), t);
1264
+ }
1265
+ class Ra extends $ {
1266
+ constructor({ domain: t }) {
1267
+ super(`Invalid domain "${_(t)}".`, {
1268
+ metaMessages: ["Must be a valid EIP-712 domain."]
1269
+ });
1270
+ }
1271
+ }
1272
+ class Na extends $ {
1273
+ constructor({ primaryType: t, types: n }) {
1274
+ super(`Invalid primary type \`${t}\` must be one of \`${JSON.stringify(Object.keys(n))}\`.`, {
1275
+ docsPath: "/api/glossary/Errors#typeddatainvalidprimarytypeerror",
1276
+ metaMessages: ["Check that the primary type is a key in `types`."]
1277
+ });
1278
+ }
1279
+ }
1280
+ class Ba extends $ {
1281
+ constructor({ type: t }) {
1282
+ super(`Struct type "${t}" is invalid.`, {
1283
+ metaMessages: ["Struct type must not be a Solidity type."],
1284
+ name: "InvalidStructTypeError"
1285
+ });
1286
+ }
1287
+ }
1288
+ function Sa(e) {
1289
+ const { domain: t, message: n, primaryType: r, types: s } = e, a = (c, u) => {
1290
+ const d = { ...u };
1291
+ for (const l of c) {
1292
+ const { name: f, type: h } = l;
1293
+ h === "address" && (d[f] = d[f].toLowerCase());
1294
+ }
1295
+ return d;
1296
+ }, o = s.EIP712Domain ? t ? a(s.EIP712Domain, t) : {} : {}, i = (() => {
1297
+ if (r !== "EIP712Domain")
1298
+ return a(s[r], n);
1299
+ })();
1300
+ return _({ domain: o, message: i, primaryType: r, types: s });
1301
+ }
1302
+ function Zn(e) {
1303
+ const { domain: t, message: n, primaryType: r, types: s } = e, a = (o, i) => {
1304
+ for (const c of o) {
1305
+ const { name: u, type: d } = c, l = i[u], f = d.match(Sr);
1306
+ if (f && (typeof l == "number" || typeof l == "bigint")) {
1307
+ const [g, y, m] = f;
1308
+ I(l, {
1309
+ signed: y === "int",
1310
+ size: Number.parseInt(m, 10) / 8
1311
+ });
1312
+ }
1313
+ if (d === "address" && typeof l == "string" && !Rn(l))
1314
+ throw new ys({ address: l });
1315
+ const h = d.match($r);
1316
+ if (h) {
1317
+ const [g, y] = h;
1318
+ if (y && We(l) !== Number.parseInt(y, 10))
1319
+ throw new zr({
1320
+ expectedSize: Number.parseInt(y, 10),
1321
+ givenSize: We(l)
1322
+ });
1323
+ }
1324
+ const p = s[d];
1325
+ p && ($a(d), a(p, l));
1326
+ }
1327
+ };
1328
+ if (s.EIP712Domain && t) {
1329
+ if (typeof t != "object")
1330
+ throw new Ra({ domain: t });
1331
+ a(s.EIP712Domain, t);
1332
+ }
1333
+ if (r !== "EIP712Domain")
1334
+ if (s[r])
1335
+ a(s[r], n);
1336
+ else
1337
+ throw new Na({ primaryType: r, types: s });
1338
+ }
1339
+ function Jn({ domain: e }) {
1340
+ return [
1341
+ typeof e?.name == "string" && { name: "name", type: "string" },
1342
+ e?.version && { name: "version", type: "string" },
1343
+ (typeof e?.chainId == "number" || typeof e?.chainId == "bigint") && {
1344
+ name: "chainId",
1345
+ type: "uint256"
1346
+ },
1347
+ e?.verifyingContract && {
1348
+ name: "verifyingContract",
1349
+ type: "address"
1350
+ },
1351
+ e?.salt && { name: "salt", type: "bytes32" }
1352
+ ].filter(Boolean);
1353
+ }
1354
+ function $a(e) {
1355
+ if (e === "address" || e === "bool" || e === "string" || e.startsWith("bytes") || e.startsWith("uint") || e.startsWith("int"))
1356
+ throw new Ba({ type: e });
1357
+ }
1358
+ function za(e) {
1359
+ const { domain: t = {}, message: n, primaryType: r } = e, s = {
1360
+ EIP712Domain: Jn({ domain: t }),
1361
+ ...e.types
1362
+ };
1363
+ Zn({
1364
+ domain: t,
1365
+ message: n,
1366
+ primaryType: r,
1367
+ types: s
1368
+ });
1369
+ const a = ["0x1901"];
1370
+ return t && a.push(_a({
1371
+ domain: t,
1372
+ types: s
1373
+ })), r !== "EIP712Domain" && a.push(Yn({
1374
+ data: n,
1375
+ primaryType: r,
1376
+ types: s
1377
+ })), D(se(a));
1378
+ }
1379
+ function _a({ domain: e, types: t }) {
1380
+ return Yn({
1381
+ data: e,
1382
+ primaryType: "EIP712Domain",
1383
+ types: t
1384
+ });
1385
+ }
1386
+ function Yn({ data: e, primaryType: t, types: n }) {
1387
+ const r = Kn({
1388
+ data: e,
1389
+ primaryType: t,
1390
+ types: n
1391
+ });
1392
+ return D(r);
1393
+ }
1394
+ function Kn({ data: e, primaryType: t, types: n }) {
1395
+ const r = [{ type: "bytes32" }], s = [Ua({ primaryType: t, types: n })];
1396
+ for (const a of n[t]) {
1397
+ const [o, i] = Xn({
1398
+ types: n,
1399
+ name: a.name,
1400
+ type: a.type,
1401
+ value: e[a.name]
1402
+ });
1403
+ r.push(o), s.push(i);
1404
+ }
1405
+ return pn(r, s);
1406
+ }
1407
+ function Ua({ primaryType: e, types: t }) {
1408
+ const n = oe(Oa({ primaryType: e, types: t }));
1409
+ return D(n);
1410
+ }
1411
+ function Oa({ primaryType: e, types: t }) {
1412
+ let n = "";
1413
+ const r = Qn({ primaryType: e, types: t });
1414
+ r.delete(e);
1415
+ const s = [e, ...Array.from(r).sort()];
1416
+ for (const a of s)
1417
+ n += `${a}(${t[a].map(({ name: o, type: i }) => `${i} ${o}`).join(",")})`;
1418
+ return n;
1419
+ }
1420
+ function Qn({ primaryType: e, types: t }, n = /* @__PURE__ */ new Set()) {
1421
+ const s = e.match(/^\w*/u)?.[0];
1422
+ if (n.has(s) || t[s] === void 0)
1423
+ return n;
1424
+ n.add(s);
1425
+ for (const a of t[s])
1426
+ Qn({ primaryType: a.type, types: t }, n);
1427
+ return n;
1428
+ }
1429
+ function Xn({ types: e, name: t, type: n, value: r }) {
1430
+ if (e[n] !== void 0)
1431
+ return [
1432
+ { type: "bytes32" },
1433
+ D(Kn({ data: r, primaryType: n, types: e }))
1434
+ ];
1435
+ if (n === "bytes")
1436
+ return r = `0x${(r.length % 2 ? "0" : "") + r.slice(2)}`, [{ type: "bytes32" }, D(r)];
1437
+ if (n === "string")
1438
+ return [{ type: "bytes32" }, D(oe(r))];
1439
+ if (n.lastIndexOf("]") === n.length - 1) {
1440
+ const s = n.slice(0, n.lastIndexOf("[")), a = r.map((o) => Xn({
1441
+ name: t,
1442
+ type: s,
1443
+ types: e,
1444
+ value: o
1445
+ }));
1446
+ return [
1447
+ { type: "bytes32" },
1448
+ D(pn(a.map(([o]) => o), a.map(([, o]) => o)))
1449
+ ];
1450
+ }
1451
+ return [{ type: n }, r];
1452
+ }
1453
+ class Da extends Map {
1454
+ constructor(t) {
1455
+ super(), Object.defineProperty(this, "maxSize", {
1456
+ enumerable: !0,
1457
+ configurable: !0,
1458
+ writable: !0,
1459
+ value: void 0
1460
+ }), this.maxSize = t;
1461
+ }
1462
+ get(t) {
1463
+ const n = super.get(t);
1464
+ return super.has(t) && n !== void 0 && (this.delete(t), super.set(t, n)), n;
1465
+ }
1466
+ set(t, n) {
1467
+ if (super.set(t, n), this.maxSize && this.size > this.maxSize) {
1468
+ const r = this.keys().next().value;
1469
+ r && this.delete(r);
1470
+ }
1471
+ return this;
1472
+ }
1473
+ }
1474
+ const Fa = {
1475
+ checksum: /* @__PURE__ */ new Da(8192)
1476
+ }, Ue = Fa.checksum;
1477
+ function er(e, t = {}) {
1478
+ const { as: n = typeof e == "string" ? "Hex" : "Bytes" } = t, r = bs(Bs(e));
1479
+ return n === "Bytes" ? r : W(r);
1480
+ }
1481
+ const qa = /^0x[a-fA-F0-9]{40}$/;
1482
+ function Se(e, t = {}) {
1483
+ const { strict: n = !0 } = t;
1484
+ if (!qa.test(e))
1485
+ throw new rn({
1486
+ address: e,
1487
+ cause: new La()
1488
+ });
1489
+ if (n) {
1490
+ if (e.toLowerCase() === e)
1491
+ return;
1492
+ if (tr(e) !== e)
1493
+ throw new rn({
1494
+ address: e,
1495
+ cause: new Ma()
1496
+ });
1497
+ }
1498
+ }
1499
+ function tr(e) {
1500
+ if (Ue.has(e))
1501
+ return Ue.get(e);
1502
+ Se(e, { strict: !1 });
1503
+ const t = e.substring(2).toLowerCase(), n = er($s(t), { as: "Bytes" }), r = t.split("");
1504
+ for (let a = 0; a < 40; a += 2)
1505
+ 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());
1506
+ const s = `0x${r.join("")}`;
1507
+ return Ue.set(e, s), s;
1508
+ }
1509
+ function Je(e, t = {}) {
1510
+ const { strict: n = !0 } = t ?? {};
1511
+ try {
1512
+ return Se(e, { strict: n }), !0;
1513
+ } catch {
1514
+ return !1;
1515
+ }
1516
+ }
1517
+ class rn extends k {
1518
+ constructor({ address: t, cause: n }) {
1519
+ super(`Address "${t}" is invalid.`, {
1520
+ cause: n
1521
+ }), Object.defineProperty(this, "name", {
1522
+ enumerable: !0,
1523
+ configurable: !0,
1524
+ writable: !0,
1525
+ value: "Address.InvalidAddressError"
1526
+ });
1527
+ }
1528
+ }
1529
+ class La extends k {
1530
+ constructor() {
1531
+ super("Address is not a 20 byte (40 hexadecimal character) value."), Object.defineProperty(this, "name", {
1532
+ enumerable: !0,
1533
+ configurable: !0,
1534
+ writable: !0,
1535
+ value: "Address.InvalidInputError"
1536
+ });
1537
+ }
1538
+ }
1539
+ class Ma extends k {
1540
+ constructor() {
1541
+ super("Address does not match its checksum counterpart."), Object.defineProperty(this, "name", {
1542
+ enumerable: !0,
1543
+ configurable: !0,
1544
+ writable: !0,
1545
+ value: "Address.InvalidChecksumError"
1546
+ });
1547
+ }
1548
+ }
1549
+ const ja = /^(.*)\[([0-9]*)\]$/, Va = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/, nr = /^(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)?$/, sn = 2n ** 256n - 1n;
1550
+ function ne(e, t, n) {
1551
+ const { checksumAddress: r, staticPosition: s } = n, a = bt(t.type);
1552
+ if (a) {
1553
+ const [o, i] = a;
1554
+ return Ha(e, { ...t, type: i }, { checksumAddress: r, length: o, staticPosition: s });
1555
+ }
1556
+ if (t.type === "tuple")
1557
+ return Ya(e, t, {
1558
+ checksumAddress: r,
1559
+ staticPosition: s
1560
+ });
1561
+ if (t.type === "address")
1562
+ return Wa(e, { checksum: r });
1563
+ if (t.type === "bool")
1564
+ return Ga(e);
1565
+ if (t.type.startsWith("bytes"))
1566
+ return Za(e, t, { staticPosition: s });
1567
+ if (t.type.startsWith("uint") || t.type.startsWith("int"))
1568
+ return Ja(e, t);
1569
+ if (t.type === "string")
1570
+ return Ka(e, { staticPosition: s });
1571
+ throw new wt(t.type);
1572
+ }
1573
+ const an = 32, Ye = 32;
1574
+ function Wa(e, t = {}) {
1575
+ const { checksum: n = !1 } = t, r = e.readBytes(32);
1576
+ return [((a) => n ? tr(a) : a)(W(_s(r, -20))), 32];
1577
+ }
1578
+ function Ha(e, t, n) {
1579
+ const { checksumAddress: r, length: s, staticPosition: a } = n;
1580
+ if (!s) {
1581
+ const c = V(e.readBytes(Ye)), u = a + c, d = u + an;
1582
+ e.setPosition(u);
1583
+ const l = V(e.readBytes(an)), f = he(t);
1584
+ let h = 0;
1585
+ const p = [];
1586
+ for (let g = 0; g < l; ++g) {
1587
+ e.setPosition(d + (f ? g * 32 : h));
1588
+ const [y, m] = ne(e, t, {
1589
+ checksumAddress: r,
1590
+ staticPosition: d
1591
+ });
1592
+ h += m, p.push(y);
1593
+ }
1594
+ return e.setPosition(a + 32), [p, 32];
1595
+ }
1596
+ if (he(t)) {
1597
+ const c = V(e.readBytes(Ye)), u = a + c, d = [];
1598
+ for (let l = 0; l < s; ++l) {
1599
+ e.setPosition(u + l * 32);
1600
+ const [f] = ne(e, t, {
1601
+ checksumAddress: r,
1602
+ staticPosition: u
1603
+ });
1604
+ d.push(f);
1605
+ }
1606
+ return e.setPosition(a + 32), [d, 32];
1607
+ }
1608
+ let o = 0;
1609
+ const i = [];
1610
+ for (let c = 0; c < s; ++c) {
1611
+ const [u, d] = ne(e, t, {
1612
+ checksumAddress: r,
1613
+ staticPosition: a + o
1614
+ });
1615
+ o += d, i.push(u);
1616
+ }
1617
+ return [i, o];
1618
+ }
1619
+ function Ga(e) {
1620
+ return [Os(e.readBytes(32), { size: 32 }), 32];
1621
+ }
1622
+ function Za(e, t, { staticPosition: n }) {
1623
+ const [r, s] = t.type.split("bytes");
1624
+ if (!s) {
1625
+ const o = V(e.readBytes(32));
1626
+ e.setPosition(n + o);
1627
+ const i = V(e.readBytes(32));
1628
+ if (i === 0)
1629
+ return e.setPosition(n + 32), ["0x", 32];
1630
+ const c = e.readBytes(i);
1631
+ return e.setPosition(n + 32), [W(c), 32];
1632
+ }
1633
+ return [W(e.readBytes(Number.parseInt(s, 10), 32)), 32];
1634
+ }
1635
+ function Ja(e, t) {
1636
+ const n = t.type.startsWith("int"), r = Number.parseInt(t.type.split("int")[1] || "256", 10), s = e.readBytes(32);
1637
+ return [
1638
+ r > 48 ? Us(s, { signed: n }) : V(s, { signed: n }),
1639
+ 32
1640
+ ];
1641
+ }
1642
+ function Ya(e, t, n) {
1643
+ const { checksumAddress: r, staticPosition: s } = n, a = t.components.length === 0 || t.components.some(({ name: c }) => !c), o = a ? [] : {};
1644
+ let i = 0;
1645
+ if (he(t)) {
1646
+ const c = V(e.readBytes(Ye)), u = s + c;
1647
+ for (let d = 0; d < t.components.length; ++d) {
1648
+ const l = t.components[d];
1649
+ e.setPosition(u + i);
1650
+ const [f, h] = ne(e, l, {
1651
+ checksumAddress: r,
1652
+ staticPosition: u
1653
+ });
1654
+ i += h, o[a ? d : l?.name] = f;
1655
+ }
1656
+ return e.setPosition(s + 32), [o, 32];
1657
+ }
1658
+ for (let c = 0; c < t.components.length; ++c) {
1659
+ const u = t.components[c], [d, l] = ne(e, u, {
1660
+ checksumAddress: r,
1661
+ staticPosition: s
1662
+ });
1663
+ o[a ? c : u?.name] = d, i += l;
1664
+ }
1665
+ return [o, i];
1666
+ }
1667
+ function Ka(e, { staticPosition: t }) {
1668
+ const n = V(e.readBytes(32)), r = t + n;
1669
+ e.setPosition(r);
1670
+ const s = V(e.readBytes(32));
1671
+ if (s === 0)
1672
+ return e.setPosition(t + 32), ["", 32];
1673
+ const a = e.readBytes(s, 32), o = Ds(zn(a));
1674
+ return e.setPosition(t + 32), [o, 32];
1675
+ }
1676
+ function Qa({ checksumAddress: e, parameters: t, values: n }) {
1677
+ const r = [];
1678
+ for (let s = 0; s < t.length; s++)
1679
+ r.push(mt({
1680
+ checksumAddress: e,
1681
+ parameter: t[s],
1682
+ value: n[s]
1683
+ }));
1684
+ return r;
1685
+ }
1686
+ function mt({ checksumAddress: e = !1, parameter: t, value: n }) {
1687
+ const r = t, s = bt(r.type);
1688
+ if (s) {
1689
+ const [a, o] = s;
1690
+ return eo(n, {
1691
+ checksumAddress: e,
1692
+ length: a,
1693
+ parameter: {
1694
+ ...r,
1695
+ type: o
1696
+ }
1697
+ });
1698
+ }
1699
+ if (r.type === "tuple")
1700
+ return ao(n, {
1701
+ checksumAddress: e,
1702
+ parameter: r
1703
+ });
1704
+ if (r.type === "address")
1705
+ return Xa(n, {
1706
+ checksum: e
1707
+ });
1708
+ if (r.type === "bool")
1709
+ return no(n);
1710
+ if (r.type.startsWith("uint") || r.type.startsWith("int")) {
1711
+ const a = r.type.startsWith("int"), [, , o = "256"] = nr.exec(r.type) ?? [];
1712
+ return ro(n, {
1713
+ signed: a,
1714
+ size: Number(o)
1715
+ });
1716
+ }
1717
+ if (r.type.startsWith("bytes"))
1718
+ return to(n, { type: r.type });
1719
+ if (r.type === "string")
1720
+ return so(n);
1721
+ throw new wt(r.type);
1722
+ }
1723
+ function yt(e) {
1724
+ let t = 0;
1725
+ for (let a = 0; a < e.length; a++) {
1726
+ const { dynamic: o, encoded: i } = e[a];
1727
+ o ? t += 32 : t += J(i);
1728
+ }
1729
+ const n = [], r = [];
1730
+ let s = 0;
1731
+ for (let a = 0; a < e.length; a++) {
1732
+ const { dynamic: o, encoded: i } = e[a];
1733
+ o ? (n.push(ae(t + s, { size: 32 })), r.push(i), s += J(i)) : n.push(i);
1734
+ }
1735
+ return q(...n, ...r);
1736
+ }
1737
+ function Xa(e, t) {
1738
+ const { checksum: n = !1 } = t;
1739
+ return Se(e, { strict: n }), {
1740
+ dynamic: !1,
1741
+ encoded: fe(e.toLowerCase())
1742
+ };
1743
+ }
1744
+ function eo(e, t) {
1745
+ const { checksumAddress: n, length: r, parameter: s } = t, a = r === null;
1746
+ if (!Array.isArray(e))
1747
+ throw new mo(e);
1748
+ if (!a && e.length !== r)
1749
+ throw new po({
1750
+ expectedLength: r,
1751
+ givenLength: e.length,
1752
+ type: `${s.type}[${r}]`
1753
+ });
1754
+ let o = !1;
1755
+ const i = [];
1756
+ for (let c = 0; c < e.length; c++) {
1757
+ const u = mt({
1758
+ checksumAddress: n,
1759
+ parameter: s,
1760
+ value: e[c]
1761
+ });
1762
+ u.dynamic && (o = !0), i.push(u);
1763
+ }
1764
+ if (a || o) {
1765
+ const c = yt(i);
1766
+ if (a) {
1767
+ const u = ae(i.length, { size: 32 });
1768
+ return {
1769
+ dynamic: !0,
1770
+ encoded: i.length > 0 ? q(u, c) : u
1771
+ };
1772
+ }
1773
+ if (o)
1774
+ return { dynamic: !0, encoded: c };
1775
+ }
1776
+ return {
1777
+ dynamic: !1,
1778
+ encoded: q(...i.map(({ encoded: c }) => c))
1779
+ };
1780
+ }
1781
+ function to(e, { type: t }) {
1782
+ const [, n] = t.split("bytes"), r = J(e);
1783
+ if (!n) {
1784
+ let s = e;
1785
+ return r % 32 !== 0 && (s = re(s, Math.ceil((e.length - 2) / 2 / 32) * 32)), {
1786
+ dynamic: !0,
1787
+ encoded: q(fe(ae(r, { size: 32 })), s)
1788
+ };
1789
+ }
1790
+ if (r !== Number.parseInt(n, 10))
1791
+ throw new sr({
1792
+ expectedSize: Number.parseInt(n, 10),
1793
+ value: e
1794
+ });
1795
+ return { dynamic: !1, encoded: re(e) };
1796
+ }
1797
+ function no(e) {
1798
+ if (typeof e != "boolean")
1799
+ throw new k(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);
1800
+ return { dynamic: !1, encoded: fe(mn(e)) };
1801
+ }
1802
+ function ro(e, { signed: t, size: n }) {
1803
+ if (typeof n == "number") {
1804
+ const r = 2n ** (BigInt(n) - (t ? 1n : 0n)) - 1n, s = t ? -r - 1n : 0n;
1805
+ if (e > r || e < s)
1806
+ throw new _r({
1807
+ max: r.toString(),
1808
+ min: s.toString(),
1809
+ signed: t,
1810
+ size: n / 8,
1811
+ value: e.toString()
1812
+ });
1813
+ }
1814
+ return {
1815
+ dynamic: !1,
1816
+ encoded: ae(e, {
1817
+ size: 32,
1818
+ signed: t
1819
+ })
1820
+ };
1821
+ }
1822
+ function so(e) {
1823
+ const t = ot(e), n = Math.ceil(J(t) / 32), r = [];
1824
+ for (let s = 0; s < n; s++)
1825
+ r.push(re(M(t, s * 32, (s + 1) * 32)));
1826
+ return {
1827
+ dynamic: !0,
1828
+ encoded: q(re(ae(J(t), { size: 32 })), ...r)
1829
+ };
1830
+ }
1831
+ function ao(e, t) {
1832
+ const { checksumAddress: n, parameter: r } = t;
1833
+ let s = !1;
1834
+ const a = [];
1835
+ for (let o = 0; o < r.components.length; o++) {
1836
+ const i = r.components[o], c = Array.isArray(e) ? o : i.name, u = mt({
1837
+ checksumAddress: n,
1838
+ parameter: i,
1839
+ value: e[c]
1840
+ });
1841
+ a.push(u), u.dynamic && (s = !0);
1842
+ }
1843
+ return {
1844
+ dynamic: s,
1845
+ encoded: s ? yt(a) : q(...a.map(({ encoded: o }) => o))
1846
+ };
1847
+ }
1848
+ function bt(e) {
1849
+ const t = e.match(/^(.*)\[(\d+)?\]$/);
1850
+ return t ? (
1851
+ // Return `null` if the array is dynamic.
1852
+ [t[2] ? Number(t[2]) : null, t[1]]
1853
+ ) : void 0;
1854
+ }
1855
+ function he(e) {
1856
+ const { type: t } = e;
1857
+ if (t === "string" || t === "bytes" || t.endsWith("[]"))
1858
+ return !0;
1859
+ if (t === "tuple")
1860
+ return e.components?.some(he);
1861
+ const n = bt(e.type);
1862
+ return !!(n && he({
1863
+ ...e,
1864
+ type: n[1]
1865
+ }));
1866
+ }
1867
+ const oo = {
1868
+ bytes: new Uint8Array(),
1869
+ dataView: new DataView(new ArrayBuffer(0)),
1870
+ position: 0,
1871
+ positionReadCount: /* @__PURE__ */ new Map(),
1872
+ recursiveReadCount: 0,
1873
+ recursiveReadLimit: Number.POSITIVE_INFINITY,
1874
+ assertReadLimit() {
1875
+ if (this.recursiveReadCount >= this.recursiveReadLimit)
1876
+ throw new uo({
1877
+ count: this.recursiveReadCount + 1,
1878
+ limit: this.recursiveReadLimit
1879
+ });
1880
+ },
1881
+ assertPosition(e) {
1882
+ if (e < 0 || e > this.bytes.length - 1)
1883
+ throw new co({
1884
+ length: this.bytes.length,
1885
+ position: e
1886
+ });
1887
+ },
1888
+ decrementPosition(e) {
1889
+ if (e < 0)
1890
+ throw new on({ offset: e });
1891
+ const t = this.position - e;
1892
+ this.assertPosition(t), this.position = t;
1893
+ },
1894
+ getReadCount(e) {
1895
+ return this.positionReadCount.get(e || this.position) || 0;
1896
+ },
1897
+ incrementPosition(e) {
1898
+ if (e < 0)
1899
+ throw new on({ offset: e });
1900
+ const t = this.position + e;
1901
+ this.assertPosition(t), this.position = t;
1902
+ },
1903
+ inspectByte(e) {
1904
+ const t = e ?? this.position;
1905
+ return this.assertPosition(t), this.bytes[t];
1906
+ },
1907
+ inspectBytes(e, t) {
1908
+ const n = t ?? this.position;
1909
+ return this.assertPosition(n + e - 1), this.bytes.subarray(n, n + e);
1910
+ },
1911
+ inspectUint8(e) {
1912
+ const t = e ?? this.position;
1913
+ return this.assertPosition(t), this.bytes[t];
1914
+ },
1915
+ inspectUint16(e) {
1916
+ const t = e ?? this.position;
1917
+ return this.assertPosition(t + 1), this.dataView.getUint16(t);
1918
+ },
1919
+ inspectUint24(e) {
1920
+ const t = e ?? this.position;
1921
+ return this.assertPosition(t + 2), (this.dataView.getUint16(t) << 8) + this.dataView.getUint8(t + 2);
1922
+ },
1923
+ inspectUint32(e) {
1924
+ const t = e ?? this.position;
1925
+ return this.assertPosition(t + 3), this.dataView.getUint32(t);
1926
+ },
1927
+ pushByte(e) {
1928
+ this.assertPosition(this.position), this.bytes[this.position] = e, this.position++;
1929
+ },
1930
+ pushBytes(e) {
1931
+ this.assertPosition(this.position + e.length - 1), this.bytes.set(e, this.position), this.position += e.length;
1932
+ },
1933
+ pushUint8(e) {
1934
+ this.assertPosition(this.position), this.bytes[this.position] = e, this.position++;
1935
+ },
1936
+ pushUint16(e) {
1937
+ this.assertPosition(this.position + 1), this.dataView.setUint16(this.position, e), this.position += 2;
1938
+ },
1939
+ pushUint24(e) {
1940
+ this.assertPosition(this.position + 2), this.dataView.setUint16(this.position, e >> 8), this.dataView.setUint8(this.position + 2, e & 255), this.position += 3;
1941
+ },
1942
+ pushUint32(e) {
1943
+ this.assertPosition(this.position + 3), this.dataView.setUint32(this.position, e), this.position += 4;
1944
+ },
1945
+ readByte() {
1946
+ this.assertReadLimit(), this._touch();
1947
+ const e = this.inspectByte();
1948
+ return this.position++, e;
1949
+ },
1950
+ readBytes(e, t) {
1951
+ this.assertReadLimit(), this._touch();
1952
+ const n = this.inspectBytes(e);
1953
+ return this.position += t ?? e, n;
1954
+ },
1955
+ readUint8() {
1956
+ this.assertReadLimit(), this._touch();
1957
+ const e = this.inspectUint8();
1958
+ return this.position += 1, e;
1959
+ },
1960
+ readUint16() {
1961
+ this.assertReadLimit(), this._touch();
1962
+ const e = this.inspectUint16();
1963
+ return this.position += 2, e;
1964
+ },
1965
+ readUint24() {
1966
+ this.assertReadLimit(), this._touch();
1967
+ const e = this.inspectUint24();
1968
+ return this.position += 3, e;
1969
+ },
1970
+ readUint32() {
1971
+ this.assertReadLimit(), this._touch();
1972
+ const e = this.inspectUint32();
1973
+ return this.position += 4, e;
1974
+ },
1975
+ get remaining() {
1976
+ return this.bytes.length - this.position;
1977
+ },
1978
+ setPosition(e) {
1979
+ const t = this.position;
1980
+ return this.assertPosition(e), this.position = e, () => this.position = t;
1981
+ },
1982
+ _touch() {
1983
+ if (this.recursiveReadLimit === Number.POSITIVE_INFINITY)
1984
+ return;
1985
+ const e = this.getReadCount();
1986
+ this.positionReadCount.set(this.position, e + 1), e > 0 && this.recursiveReadCount++;
1987
+ }
1988
+ };
1989
+ function io(e, { recursiveReadLimit: t = 8192 } = {}) {
1990
+ const n = Object.create(oo);
1991
+ return n.bytes = e, n.dataView = new DataView(e.buffer, e.byteOffset, e.byteLength), n.positionReadCount = /* @__PURE__ */ new Map(), n.recursiveReadLimit = t, n;
1992
+ }
1993
+ class on extends k {
1994
+ constructor({ offset: t }) {
1995
+ super(`Offset \`${t}\` cannot be negative.`), Object.defineProperty(this, "name", {
1996
+ enumerable: !0,
1997
+ configurable: !0,
1998
+ writable: !0,
1999
+ value: "Cursor.NegativeOffsetError"
2000
+ });
2001
+ }
2002
+ }
2003
+ class co extends k {
2004
+ constructor({ length: t, position: n }) {
2005
+ super(`Position \`${n}\` is out of bounds (\`0 < position < ${t}\`).`), Object.defineProperty(this, "name", {
2006
+ enumerable: !0,
2007
+ configurable: !0,
2008
+ writable: !0,
2009
+ value: "Cursor.PositionOutOfBoundsError"
2010
+ });
2011
+ }
2012
+ }
2013
+ class uo extends k {
2014
+ constructor({ count: t, limit: n }) {
2015
+ super(`Recursive read limit of \`${n}\` exceeded (recursive read count: \`${t}\`).`), Object.defineProperty(this, "name", {
2016
+ enumerable: !0,
2017
+ configurable: !0,
2018
+ writable: !0,
2019
+ value: "Cursor.RecursiveReadLimitExceededError"
2020
+ });
2021
+ }
2022
+ }
2023
+ function fo(e, t, n = {}) {
2024
+ const { as: r = "Array", checksumAddress: s = !1 } = n, a = typeof t == "string" ? $n(t) : t, o = io(a);
2025
+ if (ee(a) === 0 && e.length > 0)
2026
+ throw new ho();
2027
+ if (ee(a) && ee(a) < 32)
2028
+ throw new lo({
2029
+ data: typeof t == "string" ? t : W(t),
2030
+ parameters: e,
2031
+ size: ee(a)
2032
+ });
2033
+ let i = 0;
2034
+ const c = r === "Array" ? [] : {};
2035
+ for (let u = 0; u < e.length; ++u) {
2036
+ const d = e[u];
2037
+ o.setPosition(i);
2038
+ const [l, f] = ne(o, d, {
2039
+ checksumAddress: s,
2040
+ staticPosition: 0
2041
+ });
2042
+ i += f, r === "Array" ? c.push(l) : c[d.name ?? u] = l;
2043
+ }
2044
+ return c;
2045
+ }
2046
+ function gt(e, t, n) {
2047
+ const { checksumAddress: r = !1 } = {};
2048
+ if (e.length !== t.length)
2049
+ throw new ar({
2050
+ expectedLength: e.length,
2051
+ givenLength: t.length
2052
+ });
2053
+ const s = Qa({
2054
+ checksumAddress: r,
2055
+ parameters: e,
2056
+ values: t
2057
+ }), a = yt(s);
2058
+ return a.length === 0 ? "0x" : a;
2059
+ }
2060
+ function Ke(e, t) {
2061
+ if (e.length !== t.length)
2062
+ throw new ar({
2063
+ expectedLength: e.length,
2064
+ givenLength: t.length
2065
+ });
2066
+ const n = [];
2067
+ for (let r = 0; r < e.length; r++) {
2068
+ const s = e[r], a = t[r];
2069
+ n.push(Ke.encode(s, a));
2070
+ }
2071
+ return q(...n);
2072
+ }
2073
+ (function(e) {
2074
+ function t(n, r, s = !1) {
2075
+ if (n === "address") {
2076
+ const c = r;
2077
+ return Se(c), fe(c.toLowerCase(), s ? 32 : 0);
2078
+ }
2079
+ if (n === "string")
2080
+ return ot(r);
2081
+ if (n === "bytes")
2082
+ return r;
2083
+ if (n === "bool")
2084
+ return fe(mn(r), s ? 32 : 1);
2085
+ const a = n.match(nr);
2086
+ if (a) {
2087
+ const [c, u, d = "256"] = a, l = Number.parseInt(d, 10) / 8;
2088
+ return ae(r, {
2089
+ size: s ? 32 : l,
2090
+ signed: u === "int"
2091
+ });
2092
+ }
2093
+ const o = n.match(Va);
2094
+ if (o) {
2095
+ const [c, u] = o;
2096
+ if (Number.parseInt(u, 10) !== (r.length - 2) / 2)
2097
+ throw new sr({
2098
+ expectedSize: Number.parseInt(u, 10),
2099
+ value: r
2100
+ });
2101
+ return re(r, s ? 32 : 0);
2102
+ }
2103
+ const i = n.match(ja);
2104
+ if (i && Array.isArray(r)) {
2105
+ const [c, u] = i, d = [];
2106
+ for (let l = 0; l < r.length; l++)
2107
+ d.push(t(u, r[l], !0));
2108
+ return d.length === 0 ? "0x" : q(...d);
2109
+ }
2110
+ throw new wt(n);
2111
+ }
2112
+ e.encode = t;
2113
+ })(Ke || (Ke = {}));
2114
+ function rr(e) {
2115
+ return Array.isArray(e) && typeof e[0] == "string" || typeof e == "string" ? Xt(e) : e;
2116
+ }
2117
+ class lo extends k {
2118
+ constructor({ data: t, parameters: n, size: r }) {
2119
+ super(`Data size of ${r} bytes is too small for given parameters.`, {
2120
+ metaMessages: [
2121
+ `Params: (${Ur(n)})`,
2122
+ `Data: ${t} (${r} bytes)`
2123
+ ]
2124
+ }), Object.defineProperty(this, "name", {
2125
+ enumerable: !0,
2126
+ configurable: !0,
2127
+ writable: !0,
2128
+ value: "AbiParameters.DataSizeTooSmallError"
2129
+ });
2130
+ }
2131
+ }
2132
+ class ho extends k {
2133
+ constructor() {
2134
+ super('Cannot decode zero data ("0x") with ABI parameters.'), Object.defineProperty(this, "name", {
2135
+ enumerable: !0,
2136
+ configurable: !0,
2137
+ writable: !0,
2138
+ value: "AbiParameters.ZeroDataError"
2139
+ });
2140
+ }
2141
+ }
2142
+ class po extends k {
2143
+ constructor({ expectedLength: t, givenLength: n, type: r }) {
2144
+ super(`Array length mismatch for type \`${r}\`. Expected: \`${t}\`. Given: \`${n}\`.`), Object.defineProperty(this, "name", {
2145
+ enumerable: !0,
2146
+ configurable: !0,
2147
+ writable: !0,
2148
+ value: "AbiParameters.ArrayLengthMismatchError"
2149
+ });
2150
+ }
2151
+ }
2152
+ class sr extends k {
2153
+ constructor({ expectedSize: t, value: n }) {
2154
+ super(`Size of bytes "${n}" (bytes${J(n)}) does not match expected size (bytes${t}).`), Object.defineProperty(this, "name", {
2155
+ enumerable: !0,
2156
+ configurable: !0,
2157
+ writable: !0,
2158
+ value: "AbiParameters.BytesSizeMismatchError"
2159
+ });
2160
+ }
2161
+ }
2162
+ class ar extends k {
2163
+ constructor({ expectedLength: t, givenLength: n }) {
2164
+ super([
2165
+ "ABI encoding parameters/values length mismatch.",
2166
+ `Expected length (parameters): ${t}`,
2167
+ `Given length (values): ${n}`
2168
+ ].join(`
2169
+ `)), Object.defineProperty(this, "name", {
2170
+ enumerable: !0,
2171
+ configurable: !0,
2172
+ writable: !0,
2173
+ value: "AbiParameters.LengthMismatchError"
2174
+ });
2175
+ }
2176
+ }
2177
+ class mo extends k {
2178
+ constructor(t) {
2179
+ super(`Value \`${t}\` is not a valid array.`), Object.defineProperty(this, "name", {
2180
+ enumerable: !0,
2181
+ configurable: !0,
2182
+ writable: !0,
2183
+ value: "AbiParameters.InvalidArrayError"
2184
+ });
2185
+ }
2186
+ }
2187
+ class wt extends k {
2188
+ constructor(t) {
2189
+ super(`Type \`${t}\` is not a valid ABI Type.`), Object.defineProperty(this, "name", {
2190
+ enumerable: !0,
2191
+ configurable: !0,
2192
+ writable: !0,
2193
+ value: "AbiParameters.InvalidTypeError"
2194
+ });
2195
+ }
2196
+ }
2197
+ function or(e, t = {}) {
2198
+ const { recovered: n } = t;
2199
+ if (typeof e.r > "u")
2200
+ throw new Oe({ signature: e });
2201
+ if (typeof e.s > "u")
2202
+ throw new Oe({ signature: e });
2203
+ if (n && typeof e.yParity > "u")
2204
+ throw new Oe({ signature: e });
2205
+ if (e.r < 0n || e.r > sn)
2206
+ throw new Po({ value: e.r });
2207
+ if (e.s < 0n || e.s > sn)
2208
+ throw new xo({ value: e.s });
2209
+ if (typeof e.yParity == "number" && e.yParity !== 0 && e.yParity !== 1)
2210
+ throw new Et({ value: e.yParity });
2211
+ }
2212
+ function yo(e) {
2213
+ return ir(W(e));
2214
+ }
2215
+ function ir(e) {
2216
+ if (e.length !== 130 && e.length !== 132)
2217
+ throw new Eo({ signature: e });
2218
+ const t = BigInt(M(e, 0, 32)), n = BigInt(M(e, 32, 64)), r = (() => {
2219
+ const s = +`0x${e.slice(130)}`;
2220
+ if (!Number.isNaN(s))
2221
+ try {
2222
+ return vt(s);
2223
+ } catch {
2224
+ throw new Et({ value: s });
2225
+ }
2226
+ })();
2227
+ return typeof r > "u" ? {
2228
+ r: t,
2229
+ s: n
2230
+ } : {
2231
+ r: t,
2232
+ s: n,
2233
+ yParity: r
2234
+ };
2235
+ }
2236
+ function bo(e) {
2237
+ if (!(typeof e.r > "u") && !(typeof e.s > "u"))
2238
+ return go(e);
2239
+ }
2240
+ function go(e) {
2241
+ const t = typeof e == "string" ? ir(e) : e instanceof Uint8Array ? yo(e) : typeof e.r == "string" ? vo(e) : e.v ? wo(e) : {
2242
+ r: e.r,
2243
+ s: e.s,
2244
+ ...typeof e.yParity < "u" ? { yParity: e.yParity } : {}
2245
+ };
2246
+ return or(t), t;
2247
+ }
2248
+ function wo(e) {
2249
+ return {
2250
+ r: e.r,
2251
+ s: e.s,
2252
+ yParity: vt(e.v)
2253
+ };
2254
+ }
2255
+ function vo(e) {
2256
+ const t = (() => {
2257
+ const n = e.v ? Number(e.v) : void 0;
2258
+ let r = e.yParity ? Number(e.yParity) : void 0;
2259
+ if (typeof n == "number" && typeof r != "number" && (r = vt(n)), typeof r != "number")
2260
+ throw new Et({ value: e.yParity });
2261
+ return r;
2262
+ })();
2263
+ return {
2264
+ r: BigInt(e.r),
2265
+ s: BigInt(e.s),
2266
+ yParity: t
2267
+ };
2268
+ }
2269
+ function vt(e) {
2270
+ if (e === 0 || e === 27)
2271
+ return 0;
2272
+ if (e === 1 || e === 28)
2273
+ return 1;
2274
+ if (e >= 35)
2275
+ return e % 2 === 0 ? 1 : 0;
2276
+ throw new Ao({ value: e });
2277
+ }
2278
+ class Eo extends k {
2279
+ constructor({ signature: t }) {
2280
+ super(`Value \`${t}\` is an invalid signature size.`, {
2281
+ metaMessages: [
2282
+ "Expected: 64 bytes or 65 bytes.",
2283
+ `Received ${J(Dr(t))} bytes.`
2284
+ ]
2285
+ }), Object.defineProperty(this, "name", {
2286
+ enumerable: !0,
2287
+ configurable: !0,
2288
+ writable: !0,
2289
+ value: "Signature.InvalidSerializedSizeError"
2290
+ });
2291
+ }
2292
+ }
2293
+ class Oe extends k {
2294
+ constructor({ signature: t }) {
2295
+ super(`Signature \`${Or(t)}\` is missing either an \`r\`, \`s\`, or \`yParity\` property.`), Object.defineProperty(this, "name", {
2296
+ enumerable: !0,
2297
+ configurable: !0,
2298
+ writable: !0,
2299
+ value: "Signature.MissingPropertiesError"
2300
+ });
2301
+ }
2302
+ }
2303
+ class Po extends k {
2304
+ constructor({ value: t }) {
2305
+ super(`Value \`${t}\` is an invalid r value. r must be a positive integer less than 2^256.`), Object.defineProperty(this, "name", {
2306
+ enumerable: !0,
2307
+ configurable: !0,
2308
+ writable: !0,
2309
+ value: "Signature.InvalidRError"
2310
+ });
2311
+ }
2312
+ }
2313
+ class xo extends k {
2314
+ constructor({ value: t }) {
2315
+ super(`Value \`${t}\` is an invalid s value. s must be a positive integer less than 2^256.`), Object.defineProperty(this, "name", {
2316
+ enumerable: !0,
2317
+ configurable: !0,
2318
+ writable: !0,
2319
+ value: "Signature.InvalidSError"
2320
+ });
2321
+ }
2322
+ }
2323
+ class Et extends k {
2324
+ constructor({ value: t }) {
2325
+ super(`Value \`${t}\` is an invalid y-parity value. Y-parity must be 0 or 1.`), Object.defineProperty(this, "name", {
2326
+ enumerable: !0,
2327
+ configurable: !0,
2328
+ writable: !0,
2329
+ value: "Signature.InvalidYParityError"
2330
+ });
2331
+ }
2332
+ }
2333
+ class Ao extends k {
2334
+ constructor({ value: t }) {
2335
+ super(`Value \`${t}\` is an invalid v value. v must be 27, 28 or >=35.`), Object.defineProperty(this, "name", {
2336
+ enumerable: !0,
2337
+ configurable: !0,
2338
+ writable: !0,
2339
+ value: "Signature.InvalidVError"
2340
+ });
2341
+ }
2342
+ }
2343
+ function To(e, t = {}) {
2344
+ return typeof e.chainId == "string" ? ko(e) : { ...e, ...t.signature };
2345
+ }
2346
+ function ko(e) {
2347
+ const { address: t, chainId: n, nonce: r } = e, s = bo(e);
2348
+ return {
2349
+ address: t,
2350
+ chainId: Number(n),
2351
+ nonce: BigInt(r),
2352
+ ...s
2353
+ };
2354
+ }
2355
+ const Io = "0x8010801080108010801080108010801080108010801080108010801080108010", Co = rr("(uint256 chainId, address delegation, uint256 nonce, uint8 yParity, uint256 r, uint256 s), address to, bytes data");
2356
+ function cr(e) {
2357
+ if (typeof e == "string") {
2358
+ if (M(e, -32) !== Io)
2359
+ throw new Bo(e);
2360
+ } else
2361
+ or(e.authorization);
2362
+ }
2363
+ function Ro(e) {
2364
+ cr(e);
2365
+ const t = dn(M(e, -64, -32)), n = M(e, -t - 64, -64), r = M(e, 0, -t - 64), [s, a, o] = fo(Co, n);
2366
+ return {
2367
+ authorization: To({
2368
+ address: s.delegation,
2369
+ chainId: Number(s.chainId),
2370
+ nonce: s.nonce,
2371
+ yParity: s.yParity,
2372
+ r: s.r,
2373
+ s: s.s
2374
+ }),
2375
+ signature: r,
2376
+ ...o && o !== "0x" ? { data: o, to: a } : {}
2377
+ };
2378
+ }
2379
+ function No(e) {
2380
+ try {
2381
+ return cr(e), !0;
2382
+ } catch {
2383
+ return !1;
2384
+ }
2385
+ }
2386
+ let Bo = class extends k {
2387
+ constructor(t) {
2388
+ super(`Value \`${t}\` is an invalid ERC-8010 wrapped signature.`), Object.defineProperty(this, "name", {
2389
+ enumerable: !0,
2390
+ configurable: !0,
2391
+ writable: !0,
2392
+ value: "SignatureErc8010.InvalidWrappedSignatureError"
2393
+ });
2394
+ }
2395
+ };
2396
+ function So(e) {
2397
+ return e.map((t) => ({
2398
+ ...t,
2399
+ value: BigInt(t.value)
2400
+ }));
2401
+ }
2402
+ function $o(e) {
2403
+ return {
2404
+ ...e,
2405
+ balance: e.balance ? BigInt(e.balance) : void 0,
2406
+ nonce: e.nonce ? Ae(e.nonce) : void 0,
2407
+ storageProof: e.storageProof ? So(e.storageProof) : void 0
2408
+ };
2409
+ }
2410
+ async function zo(e, { address: t, blockNumber: n, blockTag: r, storageKeys: s }) {
2411
+ const a = r ?? "latest", o = n !== void 0 ? I(n) : void 0, i = await e.request({
2412
+ method: "eth_getProof",
2413
+ params: [t, s, o || a]
2414
+ });
2415
+ return $o(i);
2416
+ }
2417
+ async function _o(e, { address: t, blockNumber: n, blockTag: r = "latest", slot: s }) {
2418
+ const a = n !== void 0 ? I(n) : void 0;
2419
+ return await e.request({
2420
+ method: "eth_getStorageAt",
2421
+ params: [t, s, a || r]
2422
+ });
2423
+ }
2424
+ async function Pt(e, { blockHash: t, blockNumber: n, blockTag: r, hash: s, index: a }) {
2425
+ const o = r || "latest", i = n !== void 0 ? I(n) : void 0;
2426
+ let c = null;
2427
+ if (s ? c = await e.request({
2428
+ method: "eth_getTransactionByHash",
2429
+ params: [s]
2430
+ }, { dedupe: !0 }) : t ? c = await e.request({
2431
+ method: "eth_getTransactionByBlockHashAndIndex",
2432
+ params: [t, I(a)]
2433
+ }, { dedupe: !0 }) : c = await e.request({
2434
+ method: "eth_getTransactionByBlockNumberAndIndex",
2435
+ params: [i || o, I(a)]
2436
+ }, { dedupe: !!i }), !c)
2437
+ throw new Nn({
2438
+ blockHash: t,
2439
+ blockNumber: n,
2440
+ blockTag: o,
2441
+ hash: s,
2442
+ index: a
2443
+ });
2444
+ return (e.chain?.formatters?.transaction?.format || gs)(c);
2445
+ }
2446
+ async function Uo(e, { hash: t, transactionReceipt: n }) {
2447
+ const [r, s] = await Promise.all([
2448
+ A(e, Ne, "getBlockNumber")({}),
2449
+ t ? A(e, Pt, "getTransaction")({ hash: t }) : void 0
2450
+ ]), a = n?.blockNumber || s?.blockNumber;
2451
+ return a ? r - a + 1n : 0n;
2452
+ }
2453
+ async function xe(e, { hash: t }) {
2454
+ const n = await e.request({
2455
+ method: "eth_getTransactionReceipt",
2456
+ params: [t]
2457
+ }, { dedupe: !0 });
2458
+ if (!n)
2459
+ throw new Bn({ hash: t });
2460
+ return (e.chain?.formatters?.transactionReceipt?.format || ws)(n);
2461
+ }
2462
+ async function Oo(e, t) {
2463
+ const { account: n, authorizationList: r, allowFailure: s = !0, blockNumber: a, blockOverrides: o, blockTag: i, stateOverride: c } = t, u = t.contracts, { batchSize: d = t.batchSize ?? 1024, deployless: l = t.deployless ?? !1 } = typeof e.batch?.multicall == "object" ? e.batch.multicall : {}, f = (() => {
2464
+ if (t.multicallAddress)
2465
+ return t.multicallAddress;
2466
+ if (l)
2467
+ return null;
2468
+ if (e.chain)
2469
+ return me({
2470
+ blockNumber: a,
2471
+ chain: e.chain,
2472
+ contract: "multicall3"
2473
+ });
2474
+ throw new Error("client chain not configured. multicallAddress is required.");
2475
+ })(), h = [[]];
2476
+ let p = 0, g = 0;
2477
+ for (let b = 0; b < u.length; b++) {
2478
+ const { abi: w, address: P, args: x, functionName: T } = u[b];
2479
+ try {
2480
+ const v = G({ abi: w, args: x, functionName: T });
2481
+ g += (v.length - 2) / 2, // Check if batching is enabled.
2482
+ d > 0 && // Check if the current size of the batch exceeds the size limit.
2483
+ g > d && // Check if the current chunk is not already empty.
2484
+ h[p].length > 0 && (p++, g = (v.length - 2) / 2, h[p] = []), h[p] = [
2485
+ ...h[p],
2486
+ {
2487
+ allowFailure: !0,
2488
+ callData: v,
2489
+ target: P
2490
+ }
2491
+ ];
2492
+ } catch (v) {
2493
+ const R = je(v, {
2494
+ abi: w,
2495
+ address: P,
2496
+ args: x,
2497
+ docsPath: "/docs/contract/multicall",
2498
+ functionName: T,
2499
+ sender: n
2500
+ });
2501
+ if (!s)
2502
+ throw R;
2503
+ h[p] = [
2504
+ ...h[p],
2505
+ {
2506
+ allowFailure: !0,
2507
+ callData: "0x",
2508
+ target: P
2509
+ }
2510
+ ];
2511
+ }
2512
+ }
2513
+ const y = await Promise.allSettled(h.map((b) => A(e, F, "readContract")({
2514
+ ...f === null ? { code: bn } : { address: f },
2515
+ abi: yn,
2516
+ account: n,
2517
+ args: [b],
2518
+ authorizationList: r,
2519
+ blockNumber: a,
2520
+ blockOverrides: o,
2521
+ blockTag: i,
2522
+ functionName: "aggregate3",
2523
+ stateOverride: c
2524
+ }))), m = [];
2525
+ for (let b = 0; b < y.length; b++) {
2526
+ const w = y[b];
2527
+ if (w.status === "rejected") {
2528
+ if (!s)
2529
+ throw w.reason;
2530
+ for (let x = 0; x < h[b].length; x++)
2531
+ m.push({
2532
+ status: "failure",
2533
+ error: w.reason,
2534
+ result: void 0
2535
+ });
2536
+ continue;
2537
+ }
2538
+ const P = w.value;
2539
+ for (let x = 0; x < P.length; x++) {
2540
+ const { returnData: T, success: v } = P[x], { callData: R } = h[b][x], { abi: B, address: C, functionName: S, args: N } = u[m.length];
2541
+ try {
2542
+ if (R === "0x")
2543
+ throw new gn();
2544
+ if (!v)
2545
+ throw new wn({ data: T });
2546
+ const U = Ce({
2547
+ abi: B,
2548
+ args: N,
2549
+ data: T,
2550
+ functionName: S
2551
+ });
2552
+ m.push(s ? { result: U, status: "success" } : U);
2553
+ } catch (U) {
2554
+ const K = je(U, {
2555
+ abi: B,
2556
+ address: C,
2557
+ args: N,
2558
+ docsPath: "/docs/contract/multicall",
2559
+ functionName: S
2560
+ });
2561
+ if (!s)
2562
+ throw K;
2563
+ m.push({ error: K, result: void 0, status: "failure" });
2564
+ }
2565
+ }
2566
+ }
2567
+ if (m.length !== u.length)
2568
+ throw new $("multicall results mismatch");
2569
+ return m;
2570
+ }
2571
+ async function Qe(e, t) {
2572
+ const { blockNumber: n, blockTag: r = e.experimental_blockTag ?? "latest", blocks: s, returnFullTransactions: a, traceTransfers: o, validation: i } = t;
2573
+ try {
2574
+ const c = [];
2575
+ for (const f of s) {
2576
+ const h = f.blockOverrides ? Fr(f.blockOverrides) : void 0, p = f.calls.map((y) => {
2577
+ const m = y, b = m.account ? O(m.account) : void 0, w = m.abi ? G(m) : m.data, P = {
2578
+ ...m,
2579
+ data: m.dataSuffix ? se([w || "0x", m.dataSuffix]) : w,
2580
+ from: m.from ?? b?.address
2581
+ };
2582
+ return rt(P), st(P);
2583
+ }), g = f.stateOverrides ? qr(f.stateOverrides) : void 0;
2584
+ c.push({
2585
+ blockOverrides: h,
2586
+ calls: p,
2587
+ stateOverrides: g
2588
+ });
2589
+ }
2590
+ const d = (typeof n == "bigint" ? I(n) : void 0) || r;
2591
+ return (await e.request({
2592
+ method: "eth_simulateV1",
2593
+ params: [
2594
+ { blockStateCalls: c, returnFullTransactions: a, traceTransfers: o, validation: i },
2595
+ d
2596
+ ]
2597
+ })).map((f, h) => ({
2598
+ ...vs(f),
2599
+ calls: f.calls.map((p, g) => {
2600
+ const { abi: y, args: m, functionName: b, to: w } = s[h].calls[g], P = p.error?.data ?? p.returnData, x = BigInt(p.gasUsed), T = p.logs?.map((C) => Te(C)), v = p.status === "0x1" ? "success" : "failure", R = y && v === "success" && P !== "0x" ? Ce({
2601
+ abi: y,
2602
+ data: P,
2603
+ functionName: b
2604
+ }) : null, B = (() => {
2605
+ if (v === "success")
2606
+ return;
2607
+ let C;
2608
+ if (p.error?.data === "0x" ? C = new gn() : p.error && (C = new wn(p.error)), !!C)
2609
+ return je(C, {
2610
+ abi: y ?? [],
2611
+ address: w ?? "0x",
2612
+ args: m,
2613
+ functionName: b ?? "<unknown>"
2614
+ });
2615
+ })();
2616
+ return {
2617
+ data: P,
2618
+ gasUsed: x,
2619
+ logs: T,
2620
+ status: v,
2621
+ ...v === "success" ? {
2622
+ result: R
2623
+ } : {
2624
+ error: B
2625
+ }
2626
+ };
2627
+ })
2628
+ }));
2629
+ } catch (c) {
2630
+ const u = c, d = Lr(u, {});
2631
+ throw d instanceof Es ? u : d;
2632
+ }
2633
+ }
2634
+ function Xe(e) {
2635
+ let t = !0, n = "", r = 0, s = "", a = !1;
2636
+ for (let o = 0; o < e.length; o++) {
2637
+ const i = e[o];
2638
+ if (["(", ")", ","].includes(i) && (t = !0), i === "(" && r++, i === ")" && r--, !!t) {
2639
+ if (r === 0) {
2640
+ if (i === " " && ["event", "function", "error", ""].includes(s))
2641
+ s = "";
2642
+ else if (s += i, i === ")") {
2643
+ a = !0;
2644
+ break;
2645
+ }
2646
+ continue;
2647
+ }
2648
+ if (i === " ") {
2649
+ e[o - 1] !== "," && n !== "," && n !== ",(" && (n = "", t = !1);
2650
+ continue;
2651
+ }
2652
+ s += i, n += i;
2653
+ }
2654
+ }
2655
+ if (!a)
2656
+ throw new k("Unable to normalize signature.");
2657
+ return s;
2658
+ }
2659
+ function et(e, t) {
2660
+ const n = typeof e, r = t.type;
2661
+ switch (r) {
2662
+ case "address":
2663
+ return Je(e, { strict: !1 });
2664
+ case "bool":
2665
+ return n === "boolean";
2666
+ case "function":
2667
+ return n === "string";
2668
+ case "string":
2669
+ return n === "string";
2670
+ default:
2671
+ return r === "tuple" && "components" in t ? Object.values(t.components).every((s, a) => et(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) => et(s, {
2672
+ ...t,
2673
+ // Pop off `[]` or `[M]` from end of type
2674
+ type: r.replace(/(\[[0-9]{0,}\])$/, "")
2675
+ })) : !1;
2676
+ }
2677
+ }
2678
+ function ur(e, t, n) {
2679
+ for (const r in e) {
2680
+ const s = e[r], a = t[r];
2681
+ if (s.type === "tuple" && a.type === "tuple" && "components" in s && "components" in a)
2682
+ return ur(s.components, a.components, n[r]);
2683
+ const o = [s.type, a.type];
2684
+ if (o.includes("address") && o.includes("bytes20") ? !0 : o.includes("address") && o.includes("string") ? Je(n[r], {
2685
+ strict: !1
2686
+ }) : o.includes("address") && o.includes("bytes") ? Je(n[r], {
2687
+ strict: !1
2688
+ }) : !1)
2689
+ return o;
2690
+ }
2691
+ }
2692
+ function dr(e, t = {}) {
2693
+ const { prepare: n = !0 } = t, r = Array.isArray(e) || typeof e == "string" ? Qt(e) : e;
2694
+ return {
2695
+ ...r,
2696
+ ...n ? { hash: te(r) } : {}
2697
+ };
2698
+ }
2699
+ function Do(e, t, n) {
2700
+ const { args: r = [], prepare: s = !0 } = n ?? {}, a = Mr(t, { strict: !1 }), o = e.filter((u) => a ? u.type === "function" || u.type === "error" ? fr(u) === M(t, 0, 4) : u.type === "event" ? te(u) === t : !1 : "name" in u && u.name === t);
2701
+ if (o.length === 0)
2702
+ throw new tt({ name: t });
2703
+ if (o.length === 1)
2704
+ return {
2705
+ ...o[0],
2706
+ ...s ? { hash: te(o[0]) } : {}
2707
+ };
2708
+ let i;
2709
+ for (const u of o) {
2710
+ if (!("inputs" in u))
2711
+ continue;
2712
+ if (!r || r.length === 0) {
2713
+ if (!u.inputs || u.inputs.length === 0)
2714
+ return {
2715
+ ...u,
2716
+ ...s ? { hash: te(u) } : {}
2717
+ };
2718
+ continue;
2719
+ }
2720
+ if (!u.inputs || u.inputs.length === 0 || u.inputs.length !== r.length)
2721
+ continue;
2722
+ if (r.every((l, f) => {
2723
+ const h = "inputs" in u && u.inputs[f];
2724
+ return h ? et(l, h) : !1;
2725
+ })) {
2726
+ if (i && "inputs" in i && i.inputs) {
2727
+ const l = ur(u.inputs, i.inputs, r);
2728
+ if (l)
2729
+ throw new qo({
2730
+ abiItem: u,
2731
+ type: l[0]
2732
+ }, {
2733
+ abiItem: i,
2734
+ type: l[1]
2735
+ });
2736
+ }
2737
+ i = u;
2738
+ }
2739
+ }
2740
+ const c = (() => {
2741
+ if (i)
2742
+ return i;
2743
+ const [u, ...d] = o;
2744
+ return { ...u, overloads: d };
2745
+ })();
2746
+ if (!c)
2747
+ throw new tt({ name: t });
2748
+ return {
2749
+ ...c,
2750
+ ...s ? { hash: te(c) } : {}
2751
+ };
2752
+ }
2753
+ function fr(e) {
2754
+ return M(te(e), 0, 4);
2755
+ }
2756
+ function Fo(e) {
2757
+ const t = typeof e == "string" ? e : Ve(e);
2758
+ return Xe(t);
2759
+ }
2760
+ function te(e) {
2761
+ return typeof e != "string" && "hash" in e && e.hash ? e.hash : er(ot(Fo(e)));
2762
+ }
2763
+ class qo extends k {
2764
+ constructor(t, n) {
2765
+ super("Found ambiguous types in overloaded ABI Items.", {
2766
+ metaMessages: [
2767
+ // TODO: abitype to add support for signature-formatted ABI items.
2768
+ `\`${t.type}\` in \`${Xe(Ve(t.abiItem))}\`, and`,
2769
+ `\`${n.type}\` in \`${Xe(Ve(n.abiItem))}\``,
2770
+ "",
2771
+ "These types encode differently and cannot be distinguished at runtime.",
2772
+ "Remove one of the ambiguous items in the ABI."
2773
+ ]
2774
+ }), Object.defineProperty(this, "name", {
2775
+ enumerable: !0,
2776
+ configurable: !0,
2777
+ writable: !0,
2778
+ value: "AbiItem.AmbiguityError"
2779
+ });
2780
+ }
2781
+ }
2782
+ class tt extends k {
2783
+ constructor({ name: t, data: n, type: r = "item" }) {
2784
+ const s = t ? ` with name "${t}"` : n ? ` with data "${n}"` : "";
2785
+ super(`ABI ${r}${s} not found.`), Object.defineProperty(this, "name", {
2786
+ enumerable: !0,
2787
+ configurable: !0,
2788
+ writable: !0,
2789
+ value: "AbiItem.NotFoundError"
2790
+ });
2791
+ }
2792
+ }
2793
+ function Lo(e, t) {
2794
+ const { bytecode: n, args: r } = t;
2795
+ return q(n, e.inputs?.length && r?.length ? gt(e.inputs, r) : "0x");
2796
+ }
2797
+ function Mo(e) {
2798
+ return dr(e);
2799
+ }
2800
+ function jo(e, ...t) {
2801
+ const { overloads: n } = e, r = n ? Vo([e, ...n], e.name, {
2802
+ args: t[0]
2803
+ }) : e, s = Wo(r), a = t.length > 0 ? gt(r.inputs, t[0]) : void 0;
2804
+ return a ? q(s, a) : s;
2805
+ }
2806
+ function Q(e, t = {}) {
2807
+ return dr(e, t);
2808
+ }
2809
+ function Vo(e, t, n) {
2810
+ const r = Do(e, t, n);
2811
+ if (r.type !== "function")
2812
+ throw new tt({ name: t, type: "function" });
2813
+ return r;
2814
+ }
2815
+ function Wo(e) {
2816
+ return fr(e);
2817
+ }
2818
+ const Ho = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", L = "0x0000000000000000000000000000000000000000", Go = "0x6080604052348015600e575f80fd5b5061016d8061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610029575f3560e01c8063f8b2cb4f1461002d575b5f80fd5b610047600480360381019061004291906100db565b61005d565b604051610054919061011e565b60405180910390f35b5f8173ffffffffffffffffffffffffffffffffffffffff16319050919050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100aa82610081565b9050919050565b6100ba816100a0565b81146100c4575f80fd5b50565b5f813590506100d5816100b1565b92915050565b5f602082840312156100f0576100ef61007d565b5b5f6100fd848285016100c7565b91505092915050565b5f819050919050565b61011881610106565b82525050565b5f6020820190506101315f83018461010f565b9291505056fea26469706673582212203b9fe929fe995c7cf9887f0bdba8a36dd78e8b73f149b17d2d9ad7cd09d2dc6264736f6c634300081a0033";
2819
+ async function Zo(e, t) {
2820
+ const { blockNumber: n, blockTag: r, calls: s, stateOverrides: a, traceAssetChanges: o, traceTransfers: i, validation: c } = t, u = t.account ? O(t.account) : void 0;
2821
+ if (o && !u)
2822
+ throw new $("`account` is required when `traceAssetChanges` is true");
2823
+ const d = u ? Lo(Mo("constructor(bytes, bytes)"), {
2824
+ bytecode: jr,
2825
+ args: [
2826
+ Go,
2827
+ jo(Q("function getBalance(address)"), [u.address])
2828
+ ]
2829
+ }) : void 0, l = o ? await Promise.all(t.calls.map(async (E) => {
2830
+ if (!E.data && !E.abi)
2831
+ return;
2832
+ const { accessList: z } = await Vn(e, {
2833
+ account: u.address,
2834
+ ...E,
2835
+ data: E.abi ? G(E) : E.data
2836
+ });
2837
+ return z.map(({ address: ie, storageKeys: ge }) => ge.length > 0 ? ie : null);
2838
+ })).then((E) => E.flat().filter(Boolean)) : [], f = await Qe(e, {
2839
+ blockNumber: n,
2840
+ blockTag: r,
2841
+ blocks: [
2842
+ ...o ? [
2843
+ // ETH pre balances
2844
+ {
2845
+ calls: [{ data: d }],
2846
+ stateOverrides: a
2847
+ },
2848
+ // Asset pre balances
2849
+ {
2850
+ calls: l.map((E, z) => ({
2851
+ abi: [
2852
+ Q("function balanceOf(address) returns (uint256)")
2853
+ ],
2854
+ functionName: "balanceOf",
2855
+ args: [u.address],
2856
+ to: E,
2857
+ from: L,
2858
+ nonce: z
2859
+ })),
2860
+ stateOverrides: [
2861
+ {
2862
+ address: L,
2863
+ nonce: 0
2864
+ }
2865
+ ]
2866
+ }
2867
+ ] : [],
2868
+ {
2869
+ calls: [...s, {}].map((E) => ({
2870
+ ...E,
2871
+ from: u?.address
2872
+ })),
2873
+ stateOverrides: a
2874
+ },
2875
+ ...o ? [
2876
+ // ETH post balances
2877
+ {
2878
+ calls: [{ data: d }]
2879
+ },
2880
+ // Asset post balances
2881
+ {
2882
+ calls: l.map((E, z) => ({
2883
+ abi: [
2884
+ Q("function balanceOf(address) returns (uint256)")
2885
+ ],
2886
+ functionName: "balanceOf",
2887
+ args: [u.address],
2888
+ to: E,
2889
+ from: L,
2890
+ nonce: z
2891
+ })),
2892
+ stateOverrides: [
2893
+ {
2894
+ address: L,
2895
+ nonce: 0
2896
+ }
2897
+ ]
2898
+ },
2899
+ // Decimals
2900
+ {
2901
+ calls: l.map((E, z) => ({
2902
+ to: E,
2903
+ abi: [
2904
+ Q("function decimals() returns (uint256)")
2905
+ ],
2906
+ functionName: "decimals",
2907
+ from: L,
2908
+ nonce: z
2909
+ })),
2910
+ stateOverrides: [
2911
+ {
2912
+ address: L,
2913
+ nonce: 0
2914
+ }
2915
+ ]
2916
+ },
2917
+ // Token URI
2918
+ {
2919
+ calls: l.map((E, z) => ({
2920
+ to: E,
2921
+ abi: [
2922
+ Q("function tokenURI(uint256) returns (string)")
2923
+ ],
2924
+ functionName: "tokenURI",
2925
+ args: [0n],
2926
+ from: L,
2927
+ nonce: z
2928
+ })),
2929
+ stateOverrides: [
2930
+ {
2931
+ address: L,
2932
+ nonce: 0
2933
+ }
2934
+ ]
2935
+ },
2936
+ // Symbols
2937
+ {
2938
+ calls: l.map((E, z) => ({
2939
+ to: E,
2940
+ abi: [Q("function symbol() returns (string)")],
2941
+ functionName: "symbol",
2942
+ from: L,
2943
+ nonce: z
2944
+ })),
2945
+ stateOverrides: [
2946
+ {
2947
+ address: L,
2948
+ nonce: 0
2949
+ }
2950
+ ]
2951
+ }
2952
+ ] : []
2953
+ ],
2954
+ traceTransfers: i,
2955
+ validation: c
2956
+ }), h = o ? f[2] : f[0], [p, g, , y, m, b, w, P] = o ? f : [], { calls: x, ...T } = h, v = x.slice(0, -1) ?? [], R = p?.calls ?? [], B = g?.calls ?? [], C = [...R, ...B].map((E) => E.status === "success" ? H(E.data) : null), S = y?.calls ?? [], N = m?.calls ?? [], U = [...S, ...N].map((E) => E.status === "success" ? H(E.data) : null), K = (b?.calls ?? []).map((E) => E.status === "success" ? E.result : null), mr = (P?.calls ?? []).map((E) => E.status === "success" ? E.result : null), yr = (w?.calls ?? []).map((E) => E.status === "success" ? E.result : null), ze = [];
2957
+ for (const [E, z] of U.entries()) {
2958
+ const ie = C[E];
2959
+ if (typeof z != "bigint" || typeof ie != "bigint")
2960
+ continue;
2961
+ const ge = K[E - 1], br = mr[E - 1], gr = yr[E - 1], xt = E === 0 ? {
2962
+ address: Ho,
2963
+ decimals: 18,
2964
+ symbol: "ETH"
2965
+ } : {
2966
+ address: l[E - 1],
2967
+ decimals: gr || ge ? Number(ge ?? 1) : void 0,
2968
+ symbol: br ?? void 0
2969
+ };
2970
+ ze.some((wr) => wr.token.address === xt.address) || ze.push({
2971
+ token: xt,
2972
+ value: {
2973
+ pre: ie,
2974
+ post: z,
2975
+ diff: z - ie
2976
+ }
2977
+ });
2978
+ }
2979
+ return {
2980
+ assetChanges: ze,
2981
+ block: T,
2982
+ results: v
2983
+ };
2984
+ }
2985
+ const lr = "0x6492649264926492649264926492649264926492649264926492649264926492";
2986
+ function Jo(e) {
2987
+ if (M(e, -32) !== lr)
2988
+ throw new Qo(e);
2989
+ }
2990
+ function Yo(e) {
2991
+ const { data: t, signature: n, to: r } = e;
2992
+ return q(gt(rr("address, bytes, bytes"), [
2993
+ r,
2994
+ t,
2995
+ n
2996
+ ]), lr);
2997
+ }
2998
+ function Ko(e) {
2999
+ try {
3000
+ return Jo(e), !0;
3001
+ } catch {
3002
+ return !1;
3003
+ }
3004
+ }
3005
+ class Qo extends k {
3006
+ constructor(t) {
3007
+ super(`Value \`${t}\` is an invalid ERC-6492 wrapped signature.`), Object.defineProperty(this, "name", {
3008
+ enumerable: !0,
3009
+ configurable: !0,
3010
+ writable: !0,
3011
+ value: "SignatureErc6492.InvalidWrappedSignatureError"
3012
+ });
3013
+ }
3014
+ }
3015
+ function Xo({ r: e, s: t, to: n = "hex", v: r, yParity: s }) {
3016
+ const a = (() => {
3017
+ if (s === 0 || s === 1)
3018
+ return s;
3019
+ if (r && (r === 27n || r === 28n || r >= 35n))
3020
+ return r % 2n === 0n ? 1 : 0;
3021
+ throw new Error("Invalid `v` or `yParity` value");
3022
+ })(), o = `0x${new Is.Signature(H(e), H(t)).toCompactHex()}${a === 0 ? "1b" : "1c"}`;
3023
+ return n === "hex" ? o : Ps(o);
3024
+ }
3025
+ async function $e(e, t) {
3026
+ const { address: n, hash: r, erc6492VerifierAddress: s = t.universalSignatureVerifierAddress ?? e.chain?.contracts?.erc6492Verifier?.address, multicallAddress: a = t.multicallAddress ?? e.chain?.contracts?.multicall3?.address } = t, o = (() => {
3027
+ const i = t.signature;
3028
+ return Cn(i) ? i : typeof i == "object" && "r" in i && "s" in i ? Xo(i) : le(i);
3029
+ })();
3030
+ try {
3031
+ return No(o) ? await ei(e, {
3032
+ ...t,
3033
+ multicallAddress: a,
3034
+ signature: o
3035
+ }) : await ti(e, {
3036
+ ...t,
3037
+ verifierAddress: s,
3038
+ signature: o
3039
+ });
3040
+ } catch (i) {
3041
+ try {
3042
+ if (Re(ut(n), await Vr({ hash: r, signature: o })))
3043
+ return !0;
3044
+ } catch {
3045
+ }
3046
+ if (i instanceof Y)
3047
+ return !1;
3048
+ throw i;
3049
+ }
3050
+ }
3051
+ async function ei(e, t) {
3052
+ const { address: n, blockNumber: r, blockTag: s, hash: a, multicallAddress: o } = t, { authorization: i, data: c, signature: u, to: d } = Ro(t.signature);
3053
+ if (await Ze(e, {
3054
+ address: n,
3055
+ blockNumber: r,
3056
+ blockTag: s
3057
+ }) === xs(["0xef0100", i.address]))
3058
+ return await ni(e, {
3059
+ address: n,
3060
+ blockNumber: r,
3061
+ blockTag: s,
3062
+ hash: a,
3063
+ signature: u
3064
+ });
3065
+ const f = {
3066
+ address: i.address,
3067
+ chainId: Number(i.chainId),
3068
+ nonce: Number(i.nonce),
3069
+ r: I(i.r, { size: 32 }),
3070
+ s: I(i.s, { size: 32 }),
3071
+ yParity: i.yParity
3072
+ };
3073
+ if (!await va({
3074
+ address: n,
3075
+ authorization: f
3076
+ }))
3077
+ throw new Y();
3078
+ const p = await A(e, F, "readContract")({
3079
+ ...o ? { address: o } : { code: bn },
3080
+ authorizationList: [f],
3081
+ abi: yn,
3082
+ blockNumber: r,
3083
+ blockTag: "pending",
3084
+ functionName: "aggregate3",
3085
+ args: [
3086
+ [
3087
+ ...c ? [
3088
+ {
3089
+ allowFailure: !0,
3090
+ target: d ?? n,
3091
+ callData: c
3092
+ }
3093
+ ] : [],
3094
+ {
3095
+ allowFailure: !0,
3096
+ target: n,
3097
+ callData: G({
3098
+ abi: vn,
3099
+ functionName: "isValidSignature",
3100
+ args: [a, u]
3101
+ })
3102
+ }
3103
+ ]
3104
+ ]
3105
+ });
3106
+ if (p[p.length - 1]?.returnData?.startsWith("0x1626ba7e"))
3107
+ return !0;
3108
+ throw new Y();
3109
+ }
3110
+ async function ti(e, t) {
3111
+ const { address: n, factory: r, factoryData: s, hash: a, signature: o, verifierAddress: i, ...c } = t, u = await (async () => !r && !s || Ko(o) ? o : Yo({
3112
+ data: s,
3113
+ signature: o,
3114
+ to: r
3115
+ }))(), d = i ? {
3116
+ to: i,
3117
+ data: G({
3118
+ abi: Yt,
3119
+ functionName: "isValidSig",
3120
+ args: [n, a, u]
3121
+ }),
3122
+ ...c
3123
+ } : {
3124
+ data: En({
3125
+ abi: Yt,
3126
+ args: [n, a, u],
3127
+ bytecode: Wr
3128
+ }),
3129
+ ...c
3130
+ }, { data: l } = await A(e, Pn, "call")(d).catch((f) => {
3131
+ throw f instanceof Hr ? new Y() : f;
3132
+ });
3133
+ if (As(l ?? "0x0"))
3134
+ return !0;
3135
+ throw new Y();
3136
+ }
3137
+ async function ni(e, t) {
3138
+ const { address: n, blockNumber: r, blockTag: s, hash: a, signature: o } = t;
3139
+ if ((await A(e, F, "readContract")({
3140
+ address: n,
3141
+ abi: vn,
3142
+ args: [a, o],
3143
+ blockNumber: r,
3144
+ blockTag: s,
3145
+ functionName: "isValidSignature"
3146
+ }).catch((c) => {
3147
+ throw c instanceof Gr ? new Y() : c;
3148
+ })).startsWith("0x1626ba7e"))
3149
+ return !0;
3150
+ throw new Y();
3151
+ }
3152
+ class Y extends Error {
3153
+ }
3154
+ async function ri(e, { address: t, message: n, factory: r, factoryData: s, signature: a, ...o }) {
3155
+ const i = Gn(n);
3156
+ return $e(e, {
3157
+ address: t,
3158
+ factory: r,
3159
+ factoryData: s,
3160
+ hash: i,
3161
+ signature: a,
3162
+ ...o
3163
+ });
3164
+ }
3165
+ async function si(e, t) {
3166
+ const { address: n, factory: r, factoryData: s, signature: a, message: o, primaryType: i, types: c, domain: u, ...d } = t, l = za({ message: o, primaryType: i, types: c, domain: u });
3167
+ return $e(e, {
3168
+ address: n,
3169
+ factory: r,
3170
+ factoryData: s,
3171
+ hash: l,
3172
+ signature: a,
3173
+ ...d
3174
+ });
3175
+ }
3176
+ function hr(e, { emitOnBegin: t = !1, emitMissed: n = !1, onBlockNumber: r, onError: s, poll: a, pollingInterval: o = e.pollingInterval }) {
3177
+ const i = typeof a < "u" ? a : !(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"));
3178
+ let c;
3179
+ return i ? (() => {
3180
+ const l = _([
3181
+ "watchBlockNumber",
3182
+ e.uid,
3183
+ t,
3184
+ n,
3185
+ o
3186
+ ]);
3187
+ return Z(l, { onBlockNumber: r, onError: s }, (f) => pe(async () => {
3188
+ try {
3189
+ const h = await A(e, Ne, "getBlockNumber")({ cacheTime: 0 });
3190
+ if (c !== void 0) {
3191
+ if (h === c)
3192
+ return;
3193
+ if (h - c > 1 && n)
3194
+ for (let p = c + 1n; p < h; p++)
3195
+ f.onBlockNumber(p, c), c = p;
3196
+ }
3197
+ (c === void 0 || h > c) && (f.onBlockNumber(h, c), c = h);
3198
+ } catch (h) {
3199
+ f.onError?.(h);
3200
+ }
3201
+ }, {
3202
+ emitOnBegin: t,
3203
+ interval: o
3204
+ }));
3205
+ })() : (() => {
3206
+ const l = _([
3207
+ "watchBlockNumber",
3208
+ e.uid,
3209
+ t,
3210
+ n
3211
+ ]);
3212
+ return Z(l, { onBlockNumber: r, onError: s }, (f) => {
3213
+ let h = !0, p = () => h = !1;
3214
+ return (async () => {
3215
+ try {
3216
+ const g = (() => {
3217
+ if (e.transport.type === "fallback") {
3218
+ const m = e.transport.transports.find((b) => b.config.type === "webSocket" || b.config.type === "ipc");
3219
+ return m ? m.value : e.transport;
3220
+ }
3221
+ return e.transport;
3222
+ })(), { unsubscribe: y } = await g.subscribe({
3223
+ params: ["newHeads"],
3224
+ onData(m) {
3225
+ if (!h)
3226
+ return;
3227
+ const b = H(m.result?.number);
3228
+ f.onBlockNumber(b, c), c = b;
3229
+ },
3230
+ onError(m) {
3231
+ f.onError?.(m);
3232
+ }
3233
+ });
3234
+ p = y, h || p();
3235
+ } catch (g) {
3236
+ s?.(g);
3237
+ }
3238
+ })(), () => p();
3239
+ });
3240
+ })();
3241
+ }
3242
+ async function ai(e, t) {
3243
+ const {
3244
+ checkReplacement: n = !0,
3245
+ confirmations: r = 1,
3246
+ hash: s,
3247
+ onReplaced: a,
3248
+ retryCount: o = 6,
3249
+ retryDelay: i = ({ count: x }) => ~~(1 << x) * 200,
3250
+ // exponential backoff
3251
+ timeout: c = 18e4
3252
+ } = t, u = _(["waitForTransactionReceipt", e.uid, s]), d = t.pollingInterval ? t.pollingInterval : e.chain?.experimental_preconfirmationTime ? e.chain.experimental_preconfirmationTime : e.pollingInterval;
3253
+ let l, f, h, p = !1, g, y;
3254
+ const { promise: m, resolve: b, reject: w } = fn(), P = c ? setTimeout(() => {
3255
+ y?.(), g?.(), w(new Ts({ hash: s }));
3256
+ }, c) : void 0;
3257
+ return g = Z(u, { onReplaced: a, resolve: b, reject: w }, async (x) => {
3258
+ if (h = await A(e, xe, "getTransactionReceipt")({ hash: s }).catch(() => {
3259
+ }), h && r <= 1) {
3260
+ clearTimeout(P), x.resolve(h), g?.();
3261
+ return;
3262
+ }
3263
+ y = A(e, hr, "watchBlockNumber")({
3264
+ emitMissed: !0,
3265
+ emitOnBegin: !0,
3266
+ poll: !0,
3267
+ pollingInterval: d,
3268
+ async onBlockNumber(T) {
3269
+ const v = (B) => {
3270
+ clearTimeout(P), y?.(), B(), g?.();
3271
+ };
3272
+ let R = T;
3273
+ if (!p)
3274
+ try {
3275
+ if (h) {
3276
+ if (r > 1 && (!h.blockNumber || R - h.blockNumber + 1n < r))
3277
+ return;
3278
+ v(() => x.resolve(h));
3279
+ return;
3280
+ }
3281
+ if (n && !l && (p = !0, await Ie(async () => {
3282
+ l = await A(e, Pt, "getTransaction")({ hash: s }), l.blockNumber && (R = l.blockNumber);
3283
+ }, {
3284
+ delay: i,
3285
+ retryCount: o
3286
+ }), p = !1), h = await A(e, xe, "getTransactionReceipt")({ hash: s }), r > 1 && (!h.blockNumber || R - h.blockNumber + 1n < r))
3287
+ return;
3288
+ v(() => x.resolve(h));
3289
+ } catch (B) {
3290
+ if (B instanceof Nn || B instanceof Bn) {
3291
+ if (!l) {
3292
+ p = !1;
3293
+ return;
3294
+ }
3295
+ try {
3296
+ f = l, p = !0;
3297
+ const C = await Ie(() => A(e, X, "getBlock")({
3298
+ blockNumber: R,
3299
+ includeTransactions: !0
3300
+ }), {
3301
+ delay: i,
3302
+ retryCount: o,
3303
+ shouldRetry: ({ error: U }) => U instanceof Zr
3304
+ });
3305
+ p = !1;
3306
+ const S = C.transactions.find(({ from: U, nonce: K }) => U === f.from && K === f.nonce);
3307
+ if (!S || (h = await A(e, xe, "getTransactionReceipt")({
3308
+ hash: S.hash
3309
+ }), r > 1 && (!h.blockNumber || R - h.blockNumber + 1n < r)))
3310
+ return;
3311
+ let N = "replaced";
3312
+ S.to === f.to && S.value === f.value && S.input === f.input ? N = "repriced" : S.from === S.to && S.value === 0n && (N = "cancelled"), v(() => {
3313
+ x.onReplaced?.({
3314
+ reason: N,
3315
+ replacedTransaction: f,
3316
+ transaction: S,
3317
+ transactionReceipt: h
3318
+ }), x.resolve(h);
3319
+ });
3320
+ } catch (C) {
3321
+ v(() => x.reject(C));
3322
+ }
3323
+ } else
3324
+ v(() => x.reject(B));
3325
+ }
3326
+ }
3327
+ });
3328
+ }), m;
3329
+ }
3330
+ function oi(e, { blockTag: t = e.experimental_blockTag ?? "latest", emitMissed: n = !1, emitOnBegin: r = !1, onBlock: s, onError: a, includeTransactions: o, poll: i, pollingInterval: c = e.pollingInterval }) {
3331
+ const u = typeof i < "u" ? i : !(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")), d = o ?? !1;
3332
+ let l;
3333
+ return u ? (() => {
3334
+ const p = _([
3335
+ "watchBlocks",
3336
+ e.uid,
3337
+ t,
3338
+ n,
3339
+ r,
3340
+ d,
3341
+ c
3342
+ ]);
3343
+ return Z(p, { onBlock: s, onError: a }, (g) => pe(async () => {
3344
+ try {
3345
+ const y = await A(e, X, "getBlock")({
3346
+ blockTag: t,
3347
+ includeTransactions: d
3348
+ });
3349
+ if (y.number !== null && l?.number != null) {
3350
+ if (y.number === l.number)
3351
+ return;
3352
+ if (y.number - l.number > 1 && n)
3353
+ for (let m = l?.number + 1n; m < y.number; m++) {
3354
+ const b = await A(e, X, "getBlock")({
3355
+ blockNumber: m,
3356
+ includeTransactions: d
3357
+ });
3358
+ g.onBlock(b, l), l = b;
3359
+ }
3360
+ }
3361
+ // If no previous block exists, emit.
3362
+ (l?.number == null || // If the block tag is "pending" with no block number, emit.
3363
+ t === "pending" && y?.number == null || // If the next block number is greater than the previous block number, emit.
3364
+ // We don't want to emit blocks in the past.
3365
+ y.number !== null && y.number > l.number) && (g.onBlock(y, l), l = y);
3366
+ } catch (y) {
3367
+ g.onError?.(y);
3368
+ }
3369
+ }, {
3370
+ emitOnBegin: r,
3371
+ interval: c
3372
+ }));
3373
+ })() : (() => {
3374
+ let p = !0, g = !0, y = () => p = !1;
3375
+ return (async () => {
3376
+ try {
3377
+ r && A(e, X, "getBlock")({
3378
+ blockTag: t,
3379
+ includeTransactions: d
3380
+ }).then((w) => {
3381
+ p && g && (s(w, void 0), g = !1);
3382
+ }).catch(a);
3383
+ const m = (() => {
3384
+ if (e.transport.type === "fallback") {
3385
+ const w = e.transport.transports.find((P) => P.config.type === "webSocket" || P.config.type === "ipc");
3386
+ return w ? w.value : e.transport;
3387
+ }
3388
+ return e.transport;
3389
+ })(), { unsubscribe: b } = await m.subscribe({
3390
+ params: ["newHeads"],
3391
+ async onData(w) {
3392
+ if (!p)
3393
+ return;
3394
+ const P = await A(e, X, "getBlock")({
3395
+ blockNumber: w.result?.number,
3396
+ includeTransactions: d
3397
+ }).catch(() => {
3398
+ });
3399
+ p && (s(P, l), g = !1, l = P);
3400
+ },
3401
+ onError(w) {
3402
+ a?.(w);
3403
+ }
3404
+ });
3405
+ y = b, p || y();
3406
+ } catch (m) {
3407
+ a?.(m);
3408
+ }
3409
+ })(), () => y();
3410
+ })();
3411
+ }
3412
+ function ii(e, { address: t, args: n, batch: r = !0, event: s, events: a, fromBlock: o, onError: i, onLogs: c, poll: u, pollingInterval: d = e.pollingInterval, strict: l }) {
3413
+ const f = typeof u < "u" ? u : 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")), h = l ?? !1;
3414
+ return f ? (() => {
3415
+ const y = _([
3416
+ "watchEvent",
3417
+ t,
3418
+ n,
3419
+ r,
3420
+ e.uid,
3421
+ s,
3422
+ d,
3423
+ o
3424
+ ]);
3425
+ return Z(y, { onLogs: c, onError: i }, (m) => {
3426
+ let b;
3427
+ o !== void 0 && (b = o - 1n);
3428
+ let w, P = !1;
3429
+ const x = pe(async () => {
3430
+ if (!P) {
3431
+ try {
3432
+ w = await A(e, Wn, "createEventFilter")({
3433
+ address: t,
3434
+ args: n,
3435
+ event: s,
3436
+ events: a,
3437
+ strict: h,
3438
+ fromBlock: o
3439
+ });
3440
+ } catch {
3441
+ }
3442
+ P = !0;
3443
+ return;
3444
+ }
3445
+ try {
3446
+ let T;
3447
+ if (w)
3448
+ T = await A(e, it, "getFilterChanges")({ filter: w });
3449
+ else {
3450
+ const v = await A(e, Ne, "getBlockNumber")({});
3451
+ b && b !== v ? T = await A(e, xn, "getLogs")({
3452
+ address: t,
3453
+ args: n,
3454
+ event: s,
3455
+ events: a,
3456
+ fromBlock: b + 1n,
3457
+ toBlock: v
3458
+ }) : T = [], b = v;
3459
+ }
3460
+ if (T.length === 0)
3461
+ return;
3462
+ if (r)
3463
+ m.onLogs(T);
3464
+ else
3465
+ for (const v of T)
3466
+ m.onLogs([v]);
3467
+ } catch (T) {
3468
+ w && T instanceof Le && (P = !1), m.onError?.(T);
3469
+ }
3470
+ }, {
3471
+ emitOnBegin: !0,
3472
+ interval: d
3473
+ });
3474
+ return async () => {
3475
+ w && await A(e, ct, "uninstallFilter")({ filter: w }), x();
3476
+ };
3477
+ });
3478
+ })() : (() => {
3479
+ let y = !0, m = () => y = !1;
3480
+ return (async () => {
3481
+ try {
3482
+ const b = (() => {
3483
+ if (e.transport.type === "fallback") {
3484
+ const T = e.transport.transports.find((v) => v.config.type === "webSocket" || v.config.type === "ipc");
3485
+ return T ? T.value : e.transport;
3486
+ }
3487
+ return e.transport;
3488
+ })(), w = a ?? (s ? [s] : void 0);
3489
+ let P = [];
3490
+ w && (P = [w.flatMap((v) => hn({
3491
+ abi: [v],
3492
+ eventName: v.name,
3493
+ args: n
3494
+ }))], s && (P = P[0]));
3495
+ const { unsubscribe: x } = await b.subscribe({
3496
+ params: ["logs", { address: t, topics: P }],
3497
+ onData(T) {
3498
+ if (!y)
3499
+ return;
3500
+ const v = T.result;
3501
+ try {
3502
+ const { eventName: R, args: B } = Jr({
3503
+ abi: w ?? [],
3504
+ data: v.data,
3505
+ topics: v.topics,
3506
+ strict: h
3507
+ }), C = Te(v, { args: B, eventName: R });
3508
+ c([C]);
3509
+ } catch (R) {
3510
+ let B, C;
3511
+ if (R instanceof Yr || R instanceof Kr) {
3512
+ if (l)
3513
+ return;
3514
+ B = R.abiItem.name, C = R.abiItem.inputs?.some((N) => !("name" in N && N.name));
3515
+ }
3516
+ const S = Te(v, {
3517
+ args: C ? [] : {},
3518
+ eventName: B
3519
+ });
3520
+ c([S]);
3521
+ }
3522
+ },
3523
+ onError(T) {
3524
+ i?.(T);
3525
+ }
3526
+ });
3527
+ m = x, y || m();
3528
+ } catch (b) {
3529
+ i?.(b);
3530
+ }
3531
+ })(), () => m();
3532
+ })();
3533
+ }
3534
+ function ci(e, { batch: t = !0, onError: n, onTransactions: r, poll: s, pollingInterval: a = e.pollingInterval }) {
3535
+ return (typeof s < "u" ? s : e.transport.type !== "webSocket" && e.transport.type !== "ipc") ? (() => {
3536
+ const u = _([
3537
+ "watchPendingTransactions",
3538
+ e.uid,
3539
+ t,
3540
+ a
3541
+ ]);
3542
+ return Z(u, { onTransactions: r, onError: n }, (d) => {
3543
+ let l;
3544
+ const f = pe(async () => {
3545
+ try {
3546
+ if (!l)
3547
+ try {
3548
+ l = await A(e, Hn, "createPendingTransactionFilter")({});
3549
+ return;
3550
+ } catch (p) {
3551
+ throw f(), p;
3552
+ }
3553
+ const h = await A(e, it, "getFilterChanges")({ filter: l });
3554
+ if (h.length === 0)
3555
+ return;
3556
+ if (t)
3557
+ d.onTransactions(h);
3558
+ else
3559
+ for (const p of h)
3560
+ d.onTransactions([p]);
3561
+ } catch (h) {
3562
+ d.onError?.(h);
3563
+ }
3564
+ }, {
3565
+ emitOnBegin: !0,
3566
+ interval: a
3567
+ });
3568
+ return async () => {
3569
+ l && await A(e, ct, "uninstallFilter")({ filter: l }), f();
3570
+ };
3571
+ });
3572
+ })() : (() => {
3573
+ let u = !0, d = () => u = !1;
3574
+ return (async () => {
3575
+ try {
3576
+ const { unsubscribe: l } = await e.transport.subscribe({
3577
+ params: ["newPendingTransactions"],
3578
+ onData(f) {
3579
+ if (!u)
3580
+ return;
3581
+ const h = f.result;
3582
+ r([h]);
3583
+ },
3584
+ onError(f) {
3585
+ n?.(f);
3586
+ }
3587
+ });
3588
+ d = l, u || d();
3589
+ } catch (l) {
3590
+ n?.(l);
3591
+ }
3592
+ })(), () => d();
3593
+ })();
3594
+ }
3595
+ function ui(e) {
3596
+ const { scheme: t, statement: n, ...r } = e.match(di)?.groups ?? {}, { chainId: s, expirationTime: a, issuedAt: o, notBefore: i, requestId: c, ...u } = e.match(fi)?.groups ?? {}, d = e.split("Resources:")[1]?.split(`
3597
+ - `).slice(1);
3598
+ return {
3599
+ ...r,
3600
+ ...u,
3601
+ ...s ? { chainId: Number(s) } : {},
3602
+ ...a ? { expirationTime: new Date(a) } : {},
3603
+ ...o ? { issuedAt: new Date(o) } : {},
3604
+ ...i ? { notBefore: new Date(i) } : {},
3605
+ ...c ? { requestId: c } : {},
3606
+ ...d ? { resources: d } : {},
3607
+ ...t ? { scheme: t } : {},
3608
+ ...n ? { statement: n } : {}
3609
+ };
3610
+ }
3611
+ const di = /^(?:(?<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)?/, fi = /(?: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>.+))?/;
3612
+ function li(e) {
3613
+ const { address: t, domain: n, message: r, nonce: s, scheme: a, time: o = /* @__PURE__ */ new Date() } = e;
3614
+ if (n && r.domain !== n || s && r.nonce !== s || a && r.scheme !== a || r.expirationTime && o >= r.expirationTime || r.notBefore && o < r.notBefore)
3615
+ return !1;
3616
+ try {
3617
+ if (!r.address || !Rn(r.address, { strict: !1 }) || t && !Re(r.address, t))
3618
+ return !1;
3619
+ } catch {
3620
+ return !1;
3621
+ }
3622
+ return !0;
3623
+ }
3624
+ async function hi(e, t) {
3625
+ const { address: n, domain: r, message: s, nonce: a, scheme: o, signature: i, time: c = /* @__PURE__ */ new Date(), ...u } = t, d = ui(s);
3626
+ if (!d.address || !li({
3627
+ address: n,
3628
+ domain: r,
3629
+ message: d,
3630
+ nonce: a,
3631
+ scheme: o,
3632
+ time: c
3633
+ }))
3634
+ return !1;
3635
+ const f = Gn(s);
3636
+ return $e(e, {
3637
+ address: d.address,
3638
+ hash: f,
3639
+ signature: i,
3640
+ ...u
3641
+ });
3642
+ }
3643
+ function pi(e) {
3644
+ return {
3645
+ call: (t) => Pn(e, t),
3646
+ createAccessList: (t) => Vn(e, t),
3647
+ createBlockFilter: () => fa(e),
3648
+ createContractEventFilter: (t) => is(e, t),
3649
+ createEventFilter: (t) => Wn(e, t),
3650
+ createPendingTransactionFilter: () => Hn(e),
3651
+ estimateContractGas: (t) => os(e, t),
3652
+ estimateGas: (t) => as(e, t),
3653
+ getBalance: (t) => ss(e, t),
3654
+ getBlobBaseFee: () => la(e),
3655
+ getBlock: (t) => X(e, t),
3656
+ getBlockNumber: (t) => Ne(e, t),
3657
+ getBlockTransactionCount: (t) => ha(e, t),
3658
+ getBytecode: (t) => Ze(e, t),
3659
+ getChainId: () => Be(e),
3660
+ getCode: (t) => Ze(e, t),
3661
+ getContractEvents: (t) => rs(e, t),
3662
+ getEip712Domain: (t) => ma(e, t),
3663
+ getEnsAddress: (t) => Js(e, t),
3664
+ getEnsAvatar: (t) => ca(e, t),
3665
+ getEnsName: (t) => ua(e, t),
3666
+ getEnsResolver: (t) => da(e, t),
3667
+ getEnsText: (t) => jn(e, t),
3668
+ getFeeHistory: (t) => ga(e, t),
3669
+ estimateFeesPerGas: (t) => ns(e, t),
3670
+ getFilterChanges: (t) => it(e, t),
3671
+ getFilterLogs: (t) => wa(e, t),
3672
+ getGasPrice: () => ts(e),
3673
+ getLogs: (t) => xn(e, t),
3674
+ getProof: (t) => zo(e, t),
3675
+ estimateMaxPriorityFeePerGas: (t) => es(e, t),
3676
+ getStorageAt: (t) => _o(e, t),
3677
+ getTransaction: (t) => Pt(e, t),
3678
+ getTransactionConfirmations: (t) => Uo(e, t),
3679
+ getTransactionCount: (t) => kn(e, t),
3680
+ getTransactionReceipt: (t) => xe(e, t),
3681
+ multicall: (t) => Oo(e, t),
3682
+ prepareTransactionRequest: (t) => Tn(e, t),
3683
+ readContract: (t) => F(e, t),
3684
+ sendRawTransaction: (t) => An(e, t),
3685
+ simulate: (t) => Qe(e, t),
3686
+ simulateBlocks: (t) => Qe(e, t),
3687
+ simulateCalls: (t) => Zo(e, t),
3688
+ simulateContract: (t) => Xr(e, t),
3689
+ verifyHash: (t) => $e(e, t),
3690
+ verifyMessage: (t) => ri(e, t),
3691
+ verifySiweMessage: (t) => hi(e, t),
3692
+ verifyTypedData: (t) => si(e, t),
3693
+ uninstallFilter: (t) => ct(e, t),
3694
+ waitForTransactionReceipt: (t) => ai(e, t),
3695
+ watchBlocks: (t) => oi(e, t),
3696
+ watchBlockNumber: (t) => hr(e, t),
3697
+ watchContractEvent: (t) => Qr(e, t),
3698
+ watchEvent: (t) => ii(e, t),
3699
+ watchPendingTransactions: (t) => ci(e, t)
3700
+ };
3701
+ }
3702
+ function Oi(e) {
3703
+ const { key: t = "public", name: n = "Public Client" } = e;
3704
+ return Fn({
3705
+ ...e,
3706
+ key: t,
3707
+ name: n,
3708
+ type: "publicClient"
3709
+ }).extend(pi);
3710
+ }
3711
+ async function mi(e, { chain: t }) {
3712
+ const { id: n, name: r, nativeCurrency: s, rpcUrls: a, blockExplorers: o } = t;
3713
+ await e.request({
3714
+ method: "wallet_addEthereumChain",
3715
+ params: [
3716
+ {
3717
+ chainId: I(n),
3718
+ chainName: r,
3719
+ nativeCurrency: s,
3720
+ rpcUrls: a.default.http,
3721
+ blockExplorerUrls: o ? Object.values(o).map(({ url: i }) => i) : void 0
3722
+ }
3723
+ ]
3724
+ }, { dedupe: !0, retryCount: 0 });
3725
+ }
3726
+ function yi(e, t) {
3727
+ const { abi: n, args: r, bytecode: s, ...a } = t, o = En({ abi: n, args: r, bytecode: s });
3728
+ return nt(e, {
3729
+ ...a,
3730
+ ...a.authorizationList ? { to: null } : {},
3731
+ data: o
3732
+ });
3733
+ }
3734
+ async function bi(e) {
3735
+ return e.account?.type === "local" ? [e.account.address] : (await e.request({ method: "eth_accounts" }, { dedupe: !0 })).map((n) => ks(n));
3736
+ }
3737
+ async function gi(e, t = {}) {
3738
+ const { account: n = e.account, chainId: r } = t, s = n ? O(n) : void 0, a = r ? [s?.address, [I(r)]] : [s?.address], o = await e.request({
3739
+ method: "wallet_getCapabilities",
3740
+ params: a
3741
+ }), i = {};
3742
+ for (const [c, u] of Object.entries(o)) {
3743
+ i[Number(c)] = {};
3744
+ for (let [d, l] of Object.entries(u))
3745
+ d === "addSubAccount" && (d = "unstable_addSubAccount"), i[Number(c)][d] = l;
3746
+ }
3747
+ return typeof r == "number" ? i[r] : i;
3748
+ }
3749
+ async function wi(e) {
3750
+ return await e.request({ method: "wallet_getPermissions" }, { dedupe: !0 });
3751
+ }
3752
+ async function pr(e, t) {
3753
+ const { account: n = e.account, chainId: r, nonce: s } = t;
3754
+ if (!n)
3755
+ throw new ye({
3756
+ docsPath: "/docs/eip7702/prepareAuthorization"
3757
+ });
3758
+ const a = O(n), o = (() => {
3759
+ if (t.executor)
3760
+ return t.executor === "self" ? t.executor : O(t.executor);
3761
+ })(), i = {
3762
+ address: t.contractAddress ?? t.address,
3763
+ chainId: r,
3764
+ nonce: s
3765
+ };
3766
+ return typeof i.chainId > "u" && (i.chainId = e.chain?.id ?? await A(e, Be, "getChainId")({})), typeof i.nonce > "u" && (i.nonce = await A(e, kn, "getTransactionCount")({
3767
+ address: a.address,
3768
+ blockTag: "pending"
3769
+ }), (o === "self" || o?.address && Re(o.address, a.address)) && (i.nonce += 1)), i;
3770
+ }
3771
+ async function vi(e) {
3772
+ return (await e.request({ method: "eth_requestAccounts" }, { dedupe: !0, retryCount: 0 })).map((n) => ut(n));
3773
+ }
3774
+ async function Ei(e, t) {
3775
+ return e.request({
3776
+ method: "wallet_requestPermissions",
3777
+ params: [t]
3778
+ }, { retryCount: 0 });
3779
+ }
3780
+ async function Pi(e, t) {
3781
+ const { id: n } = t;
3782
+ await e.request({
3783
+ method: "wallet_showCallsStatus",
3784
+ params: [n]
3785
+ });
3786
+ }
3787
+ async function xi(e, t) {
3788
+ const { account: n = e.account } = t;
3789
+ if (!n)
3790
+ throw new ye({
3791
+ docsPath: "/docs/eip7702/signAuthorization"
3792
+ });
3793
+ const r = O(n);
3794
+ if (!r.signAuthorization)
3795
+ throw new cs({
3796
+ docsPath: "/docs/eip7702/signAuthorization",
3797
+ metaMessages: [
3798
+ "The `signAuthorization` Action does not support JSON-RPC Accounts."
3799
+ ],
3800
+ type: r.type
3801
+ });
3802
+ const s = await pr(e, t);
3803
+ return r.signAuthorization(s);
3804
+ }
3805
+ async function Ai(e, { account: t = e.account, message: n }) {
3806
+ if (!t)
3807
+ throw new ye({
3808
+ docsPath: "/docs/actions/wallet/signMessage"
3809
+ });
3810
+ const r = O(t);
3811
+ if (r.signMessage)
3812
+ return r.signMessage({ message: n });
3813
+ const s = typeof n == "string" ? ke(n) : n.raw instanceof Uint8Array ? oe(n.raw) : n.raw;
3814
+ return e.request({
3815
+ method: "personal_sign",
3816
+ params: [s, r.address]
3817
+ }, { retryCount: 0 });
3818
+ }
3819
+ async function Ti(e, t) {
3820
+ const { account: n = e.account, chain: r = e.chain, ...s } = t;
3821
+ if (!n)
3822
+ throw new ye({
3823
+ docsPath: "/docs/actions/wallet/signTransaction"
3824
+ });
3825
+ const a = O(n);
3826
+ rt({
3827
+ account: a,
3828
+ ...t
3829
+ });
3830
+ const o = await A(e, Be, "getChainId")({});
3831
+ r !== null && us({
3832
+ currentChainId: o,
3833
+ chain: r
3834
+ });
3835
+ const c = (r?.formatters || e.chain?.formatters)?.transactionRequest?.format || st;
3836
+ return a.signTransaction ? a.signTransaction({
3837
+ ...s,
3838
+ chainId: o
3839
+ }, { serializer: e.chain?.serializers?.transaction }) : await e.request({
3840
+ method: "eth_signTransaction",
3841
+ params: [
3842
+ {
3843
+ ...c(s),
3844
+ chainId: I(o),
3845
+ from: a.address
3846
+ }
3847
+ ]
3848
+ }, { retryCount: 0 });
3849
+ }
3850
+ async function ki(e, t) {
3851
+ const { account: n = e.account, domain: r, message: s, primaryType: a } = t;
3852
+ if (!n)
3853
+ throw new ye({
3854
+ docsPath: "/docs/actions/wallet/signTypedData"
3855
+ });
3856
+ const o = O(n), i = {
3857
+ EIP712Domain: Jn({ domain: r }),
3858
+ ...t.types
3859
+ };
3860
+ if (Zn({ domain: r, message: s, primaryType: a, types: i }), o.signTypedData)
3861
+ return o.signTypedData({ domain: r, message: s, primaryType: a, types: i });
3862
+ const c = Sa({ domain: r, message: s, primaryType: a, types: i });
3863
+ return e.request({
3864
+ method: "eth_signTypedData_v4",
3865
+ params: [o.address, c]
3866
+ }, { retryCount: 0 });
3867
+ }
3868
+ async function Ii(e, { id: t }) {
3869
+ await e.request({
3870
+ method: "wallet_switchEthereumChain",
3871
+ params: [
3872
+ {
3873
+ chainId: I(t)
3874
+ }
3875
+ ]
3876
+ }, { retryCount: 0 });
3877
+ }
3878
+ async function Ci(e, t) {
3879
+ return await e.request({
3880
+ method: "wallet_watchAsset",
3881
+ params: t
3882
+ }, { retryCount: 0 });
3883
+ }
3884
+ function Ri(e) {
3885
+ return {
3886
+ addChain: (t) => mi(e, t),
3887
+ deployContract: (t) => yi(e, t),
3888
+ getAddresses: () => bi(e),
3889
+ getCallsStatus: (t) => On(e, t),
3890
+ getCapabilities: (t) => gi(e, t),
3891
+ getChainId: () => Be(e),
3892
+ getPermissions: () => wi(e),
3893
+ prepareAuthorization: (t) => pr(e, t),
3894
+ prepareTransactionRequest: (t) => Tn(e, t),
3895
+ requestAddresses: () => vi(e),
3896
+ requestPermissions: (t) => Ei(e, t),
3897
+ sendCalls: (t) => Vs(e, t),
3898
+ sendRawTransaction: (t) => An(e, t),
3899
+ sendTransaction: (t) => nt(e, t),
3900
+ showCallsStatus: (t) => Pi(e, t),
3901
+ signAuthorization: (t) => xi(e, t),
3902
+ signMessage: (t) => Ai(e, t),
3903
+ signTransaction: (t) => Ti(e, t),
3904
+ signTypedData: (t) => ki(e, t),
3905
+ switchChain: (t) => Ii(e, t),
3906
+ waitForCallsStatus: (t) => Ws(e, t),
3907
+ watchAsset: (t) => Ci(e, t),
3908
+ writeContract: (t) => ds(e, t)
3909
+ };
3910
+ }
3911
+ function Di(e) {
3912
+ const { key: t = "wallet", name: n = "Wallet Client", transport: r } = e;
3913
+ return Fn({
3914
+ ...e,
3915
+ key: t,
3916
+ name: n,
3917
+ transport: r,
3918
+ type: "walletClient"
3919
+ }).extend(Ri);
3920
+ }
3921
+ function Ni({ key: e, methods: t, name: n, request: r, retryCount: s = 3, retryDelay: a = 150, timeout: o, type: i }, c) {
3922
+ const u = Dn();
3923
+ return {
3924
+ config: {
3925
+ key: e,
3926
+ methods: t,
3927
+ name: n,
3928
+ request: r,
3929
+ retryCount: s,
3930
+ retryDelay: a,
3931
+ timeout: o,
3932
+ type: i
3933
+ },
3934
+ request: Pa(r, { methods: t, retryCount: s, retryDelay: a, uid: u }),
3935
+ value: c
3936
+ };
3937
+ }
3938
+ class Bi extends $ {
3939
+ constructor() {
3940
+ super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.", {
3941
+ docsPath: "/docs/clients/intro",
3942
+ name: "UrlRequiredError"
3943
+ });
3944
+ }
3945
+ }
3946
+ function Fi(e, t = {}) {
3947
+ const { batch: n, fetchFn: r, fetchOptions: s, key: a = "http", methods: o, name: i = "HTTP JSON-RPC", onFetchRequest: c, onFetchResponse: u, retryDelay: d, raw: l } = t;
3948
+ return ({ chain: f, retryCount: h, timeout: p }) => {
3949
+ const { batchSize: g = 1e3, wait: y = 0 } = typeof n == "object" ? n : {}, m = t.retryCount ?? h, b = p ?? t.timeout ?? 1e4, w = e || f?.rpcUrls.default.http[0];
3950
+ if (!w)
3951
+ throw new Bi();
3952
+ const P = ka(w, {
3953
+ fetchFn: r,
3954
+ fetchOptions: s,
3955
+ onRequest: c,
3956
+ onResponse: u,
3957
+ timeout: b
3958
+ });
3959
+ return Ni({
3960
+ key: a,
3961
+ methods: o,
3962
+ name: i,
3963
+ async request({ method: x, params: T }) {
3964
+ const v = { method: x, params: T }, { schedule: R } = fs({
3965
+ id: w,
3966
+ wait: y,
3967
+ shouldSplitBatch(N) {
3968
+ return N.length > g;
3969
+ },
3970
+ fn: (N) => P.request({
3971
+ body: N
3972
+ }),
3973
+ sort: (N, U) => N.id - U.id
3974
+ }), B = async (N) => n ? R(N) : [
3975
+ await P.request({
3976
+ body: N
3977
+ })
3978
+ ], [{ error: C, result: S }] = await B(v);
3979
+ if (l)
3980
+ return { error: C, result: S };
3981
+ if (C)
3982
+ throw new ls({
3983
+ body: v,
3984
+ error: C,
3985
+ url: w
3986
+ });
3987
+ return S;
3988
+ },
3989
+ retryCount: m,
3990
+ retryDelay: d,
3991
+ timeout: b,
3992
+ type: "http"
3993
+ }, {
3994
+ fetchOptions: s,
3995
+ url: w
3996
+ });
3997
+ };
3998
+ }
3999
+ export {
4000
+ Oi as a,
4001
+ Ni as b,
4002
+ Di as c,
4003
+ Fi as h
4004
+ };
4005
+ //# sourceMappingURL=http-CajzXkt4.js.map