@springmicro/auth 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2021 @@
1
+ import { bN as R } from "./Web3Auth-C5tucK1E.js";
2
+ const Qt = () => "9.1.0", Yt = (e) => e.toString(16).padStart(2, "0"), Jt = (e) => {
3
+ const t = new Uint8Array(e / 2);
4
+ return window.crypto.getRandomValues(t), Array.from(t, Yt).join("");
5
+ }, Zt = () => typeof window < "u" ? Jt(10) : (/* @__PURE__ */ new Date()).getTime().toString(36);
6
+ class V {
7
+ }
8
+ V.makeRequest = (e, t) => ({
9
+ id: Zt(),
10
+ method: e,
11
+ params: t,
12
+ env: {
13
+ sdkVersion: Qt()
14
+ }
15
+ });
16
+ V.makeResponse = (e, t, n) => ({
17
+ id: e,
18
+ success: !0,
19
+ version: n,
20
+ data: t
21
+ });
22
+ V.makeErrorResponse = (e, t, n) => ({
23
+ id: e,
24
+ success: !1,
25
+ error: t,
26
+ version: n
27
+ });
28
+ var b;
29
+ (function(e) {
30
+ e.sendTransactions = "sendTransactions", e.rpcCall = "rpcCall", e.getChainInfo = "getChainInfo", e.getSafeInfo = "getSafeInfo", e.getTxBySafeTxHash = "getTxBySafeTxHash", e.getSafeBalances = "getSafeBalances", e.signMessage = "signMessage", e.signTypedMessage = "signTypedMessage", e.getEnvironmentInfo = "getEnvironmentInfo", e.getOffChainSignature = "getOffChainSignature", e.requestAddressBook = "requestAddressBook", e.wallet_getPermissions = "wallet_getPermissions", e.wallet_requestPermissions = "wallet_requestPermissions";
31
+ })(b || (b = {}));
32
+ var J;
33
+ (function(e) {
34
+ e.requestAddressBook = "requestAddressBook";
35
+ })(J || (J = {}));
36
+ class xt {
37
+ constructor(t = null, n = !1) {
38
+ this.allowedOrigins = null, this.callbacks = /* @__PURE__ */ new Map(), this.debugMode = !1, this.isServer = typeof window > "u", this.isValidMessage = ({ origin: i, data: s, source: r }) => {
39
+ const o = !s, c = !this.isServer && r === window.parent, l = typeof s.version < "u" && parseInt(s.version.split(".")[0]), g = typeof l == "number" && l >= 1;
40
+ let h = !0;
41
+ return Array.isArray(this.allowedOrigins) && (h = this.allowedOrigins.find((y) => y.test(i)) !== void 0), !o && c && g && h;
42
+ }, this.logIncomingMessage = (i) => {
43
+ console.info(`Safe Apps SDK v1: A message was received from origin ${i.origin}. `, i.data);
44
+ }, this.onParentMessage = (i) => {
45
+ this.isValidMessage(i) && (this.debugMode && this.logIncomingMessage(i), this.handleIncomingMessage(i.data));
46
+ }, this.handleIncomingMessage = (i) => {
47
+ const { id: s } = i, r = this.callbacks.get(s);
48
+ r && (r(i), this.callbacks.delete(s));
49
+ }, this.send = (i, s) => {
50
+ const r = V.makeRequest(i, s);
51
+ if (this.isServer)
52
+ throw new Error("Window doesn't exist");
53
+ return window.parent.postMessage(r, "*"), new Promise((o, c) => {
54
+ this.callbacks.set(r.id, (l) => {
55
+ if (!l.success) {
56
+ c(new Error(l.error));
57
+ return;
58
+ }
59
+ o(l);
60
+ });
61
+ });
62
+ }, this.allowedOrigins = t, this.debugMode = n, this.isServer || window.addEventListener("message", this.onParentMessage);
63
+ }
64
+ }
65
+ const Se = (e) => typeof e == "object" && e != null && "domain" in e && "types" in e && "message" in e;
66
+ var en = {}, A = {}, T = {}, ne = R && R.__awaiter || function(e, t, n, i) {
67
+ function s(r) {
68
+ return r instanceof n ? r : new n(function(o) {
69
+ o(r);
70
+ });
71
+ }
72
+ return new (n || (n = Promise))(function(r, o) {
73
+ function c(h) {
74
+ try {
75
+ g(i.next(h));
76
+ } catch (y) {
77
+ o(y);
78
+ }
79
+ }
80
+ function l(h) {
81
+ try {
82
+ g(i.throw(h));
83
+ } catch (y) {
84
+ o(y);
85
+ }
86
+ }
87
+ function g(h) {
88
+ h.done ? r(h.value) : s(h.value).then(c, l);
89
+ }
90
+ g((i = i.apply(e, t || [])).next());
91
+ });
92
+ };
93
+ Object.defineProperty(T, "__esModule", { value: !0 });
94
+ T.getData = T.fetchData = T.stringifyQuery = T.insertParams = void 0;
95
+ const tn = (e) => typeof e == "object" && e !== null && "code" in e && "message" in e;
96
+ function nn(e, t, n) {
97
+ return e.replace(new RegExp(`\\{${t}\\}`, "g"), n);
98
+ }
99
+ function sn(e, t) {
100
+ return t ? Object.keys(t).reduce((n, i) => nn(n, i, String(t[i])), e) : e;
101
+ }
102
+ T.insertParams = sn;
103
+ function rn(e) {
104
+ if (!e)
105
+ return "";
106
+ const t = new URLSearchParams();
107
+ Object.keys(e).forEach((i) => {
108
+ e[i] != null && t.append(i, String(e[i]));
109
+ });
110
+ const n = t.toString();
111
+ return n ? `?${n}` : "";
112
+ }
113
+ T.stringifyQuery = rn;
114
+ function Ie(e) {
115
+ return ne(this, void 0, void 0, function* () {
116
+ let t;
117
+ try {
118
+ t = yield e.json();
119
+ } catch {
120
+ t = {};
121
+ }
122
+ if (!e.ok) {
123
+ const n = tn(t) ? `CGW error - ${t.code}: ${t.message}` : `CGW error - status ${e.statusText}`;
124
+ throw new Error(n);
125
+ }
126
+ return t;
127
+ });
128
+ }
129
+ function on(e, t, n, i, s) {
130
+ return ne(this, void 0, void 0, function* () {
131
+ const r = Object.assign({ "Content-Type": "application/json" }, i), o = {
132
+ method: t ?? "POST",
133
+ headers: r
134
+ };
135
+ s && (o.credentials = s), n != null && (o.body = typeof n == "string" ? n : JSON.stringify(n));
136
+ const c = yield fetch(e, o);
137
+ return Ie(c);
138
+ });
139
+ }
140
+ T.fetchData = on;
141
+ function an(e, t, n) {
142
+ return ne(this, void 0, void 0, function* () {
143
+ const i = {
144
+ method: "GET"
145
+ };
146
+ t && (i.headers = Object.assign(Object.assign({}, t), { "Content-Type": "application/json" })), n && (i.credentials = n);
147
+ const s = yield fetch(e, i);
148
+ return Ie(s);
149
+ });
150
+ }
151
+ T.getData = an;
152
+ Object.defineProperty(A, "__esModule", { value: !0 });
153
+ A.getEndpoint = A.deleteEndpoint = A.putEndpoint = A.postEndpoint = void 0;
154
+ const D = T;
155
+ function W(e, t, n, i) {
156
+ const s = (0, D.insertParams)(t, n), r = (0, D.stringifyQuery)(i);
157
+ return `${e}${s}${r}`;
158
+ }
159
+ function cn(e, t, n) {
160
+ const i = W(e, t, n == null ? void 0 : n.path, n == null ? void 0 : n.query);
161
+ return (0, D.fetchData)(i, "POST", n == null ? void 0 : n.body, n == null ? void 0 : n.headers, n == null ? void 0 : n.credentials);
162
+ }
163
+ A.postEndpoint = cn;
164
+ function un(e, t, n) {
165
+ const i = W(e, t, n == null ? void 0 : n.path, n == null ? void 0 : n.query);
166
+ return (0, D.fetchData)(i, "PUT", n == null ? void 0 : n.body, n == null ? void 0 : n.headers, n == null ? void 0 : n.credentials);
167
+ }
168
+ A.putEndpoint = un;
169
+ function fn(e, t, n) {
170
+ const i = W(e, t, n == null ? void 0 : n.path, n == null ? void 0 : n.query);
171
+ return (0, D.fetchData)(i, "DELETE", n == null ? void 0 : n.body, n == null ? void 0 : n.headers, n == null ? void 0 : n.credentials);
172
+ }
173
+ A.deleteEndpoint = fn;
174
+ function dn(e, t, n, i) {
175
+ if (i)
176
+ return (0, D.getData)(i, void 0, n == null ? void 0 : n.credentials);
177
+ const s = W(e, t, n == null ? void 0 : n.path, n == null ? void 0 : n.query);
178
+ return (0, D.getData)(s, n == null ? void 0 : n.headers, n == null ? void 0 : n.credentials);
179
+ }
180
+ A.getEndpoint = dn;
181
+ var q = {};
182
+ Object.defineProperty(q, "__esModule", { value: !0 });
183
+ q.DEFAULT_BASE_URL = void 0;
184
+ q.DEFAULT_BASE_URL = "https://safe-client.safe.global";
185
+ var ve = {};
186
+ (function(e) {
187
+ Object.defineProperty(e, "__esModule", { value: !0 }), e.ImplementationVersionState = void 0, function(t) {
188
+ t.UP_TO_DATE = "UP_TO_DATE", t.OUTDATED = "OUTDATED", t.UNKNOWN = "UNKNOWN";
189
+ }(e.ImplementationVersionState || (e.ImplementationVersionState = {}));
190
+ })(ve);
191
+ var we = {};
192
+ (function(e) {
193
+ Object.defineProperty(e, "__esModule", { value: !0 }), e.SafeAppSocialPlatforms = e.SafeAppFeatures = e.SafeAppAccessPolicyTypes = void 0, function(t) {
194
+ t.NoRestrictions = "NO_RESTRICTIONS", t.DomainAllowlist = "DOMAIN_ALLOWLIST";
195
+ }(e.SafeAppAccessPolicyTypes || (e.SafeAppAccessPolicyTypes = {})), function(t) {
196
+ t.BATCHED_TRANSACTIONS = "BATCHED_TRANSACTIONS";
197
+ }(e.SafeAppFeatures || (e.SafeAppFeatures = {})), function(t) {
198
+ t.TWITTER = "TWITTER", t.GITHUB = "GITHUB", t.DISCORD = "DISCORD";
199
+ }(e.SafeAppSocialPlatforms || (e.SafeAppSocialPlatforms = {}));
200
+ })(we);
201
+ var Oe = {};
202
+ (function(e) {
203
+ Object.defineProperty(e, "__esModule", { value: !0 }), e.LabelValue = e.StartTimeValue = e.DurationType = e.DetailedExecutionInfoType = e.TransactionListItemType = e.ConflictType = e.TransactionInfoType = e.SettingsInfoType = e.TransactionTokenType = e.TransferDirection = e.TransactionStatus = e.Operation = void 0, function(t) {
204
+ t[t.CALL = 0] = "CALL", t[t.DELEGATE = 1] = "DELEGATE";
205
+ }(e.Operation || (e.Operation = {})), function(t) {
206
+ t.AWAITING_CONFIRMATIONS = "AWAITING_CONFIRMATIONS", t.AWAITING_EXECUTION = "AWAITING_EXECUTION", t.CANCELLED = "CANCELLED", t.FAILED = "FAILED", t.SUCCESS = "SUCCESS";
207
+ }(e.TransactionStatus || (e.TransactionStatus = {})), function(t) {
208
+ t.INCOMING = "INCOMING", t.OUTGOING = "OUTGOING", t.UNKNOWN = "UNKNOWN";
209
+ }(e.TransferDirection || (e.TransferDirection = {})), function(t) {
210
+ t.ERC20 = "ERC20", t.ERC721 = "ERC721", t.NATIVE_COIN = "NATIVE_COIN";
211
+ }(e.TransactionTokenType || (e.TransactionTokenType = {})), function(t) {
212
+ t.SET_FALLBACK_HANDLER = "SET_FALLBACK_HANDLER", t.ADD_OWNER = "ADD_OWNER", t.REMOVE_OWNER = "REMOVE_OWNER", t.SWAP_OWNER = "SWAP_OWNER", t.CHANGE_THRESHOLD = "CHANGE_THRESHOLD", t.CHANGE_IMPLEMENTATION = "CHANGE_IMPLEMENTATION", t.ENABLE_MODULE = "ENABLE_MODULE", t.DISABLE_MODULE = "DISABLE_MODULE", t.SET_GUARD = "SET_GUARD", t.DELETE_GUARD = "DELETE_GUARD";
213
+ }(e.SettingsInfoType || (e.SettingsInfoType = {})), function(t) {
214
+ t.TRANSFER = "Transfer", t.SETTINGS_CHANGE = "SettingsChange", t.CUSTOM = "Custom", t.CREATION = "Creation", t.SWAP_ORDER = "SwapOrder", t.TWAP_ORDER = "TwapOrder", t.SWAP_TRANSFER = "SwapTransfer";
215
+ }(e.TransactionInfoType || (e.TransactionInfoType = {})), function(t) {
216
+ t.NONE = "None", t.HAS_NEXT = "HasNext", t.END = "End";
217
+ }(e.ConflictType || (e.ConflictType = {})), function(t) {
218
+ t.TRANSACTION = "TRANSACTION", t.LABEL = "LABEL", t.CONFLICT_HEADER = "CONFLICT_HEADER", t.DATE_LABEL = "DATE_LABEL";
219
+ }(e.TransactionListItemType || (e.TransactionListItemType = {})), function(t) {
220
+ t.MULTISIG = "MULTISIG", t.MODULE = "MODULE";
221
+ }(e.DetailedExecutionInfoType || (e.DetailedExecutionInfoType = {})), function(t) {
222
+ t.AUTO = "AUTO", t.LIMIT_DURATION = "LIMIT_DURATION";
223
+ }(e.DurationType || (e.DurationType = {})), function(t) {
224
+ t.AT_MINING_TIME = "AT_MINING_TIME", t.AT_EPOCH = "AT_EPOCH";
225
+ }(e.StartTimeValue || (e.StartTimeValue = {})), function(t) {
226
+ t.Queued = "Queued", t.Next = "Next";
227
+ }(e.LabelValue || (e.LabelValue = {}));
228
+ })(Oe);
229
+ var Ne = {};
230
+ (function(e) {
231
+ Object.defineProperty(e, "__esModule", { value: !0 }), e.FEATURES = e.GAS_PRICE_TYPE = e.RPC_AUTHENTICATION = void 0, function(t) {
232
+ t.API_KEY_PATH = "API_KEY_PATH", t.NO_AUTHENTICATION = "NO_AUTHENTICATION", t.UNKNOWN = "UNKNOWN";
233
+ }(e.RPC_AUTHENTICATION || (e.RPC_AUTHENTICATION = {})), function(t) {
234
+ t.ORACLE = "ORACLE", t.FIXED = "FIXED", t.FIXED_1559 = "FIXED1559", t.UNKNOWN = "UNKNOWN";
235
+ }(e.GAS_PRICE_TYPE || (e.GAS_PRICE_TYPE = {})), function(t) {
236
+ t.ERC721 = "ERC721", t.SAFE_APPS = "SAFE_APPS", t.CONTRACT_INTERACTION = "CONTRACT_INTERACTION", t.DOMAIN_LOOKUP = "DOMAIN_LOOKUP", t.SPENDING_LIMIT = "SPENDING_LIMIT", t.EIP1559 = "EIP1559", t.SAFE_TX_GAS_OPTIONAL = "SAFE_TX_GAS_OPTIONAL", t.TX_SIMULATION = "TX_SIMULATION", t.EIP1271 = "EIP1271";
237
+ }(e.FEATURES || (e.FEATURES = {}));
238
+ })(Ne);
239
+ var Ce = {};
240
+ (function(e) {
241
+ Object.defineProperty(e, "__esModule", { value: !0 }), e.TokenType = void 0, function(t) {
242
+ t.ERC20 = "ERC20", t.ERC721 = "ERC721", t.NATIVE_TOKEN = "NATIVE_TOKEN";
243
+ }(e.TokenType || (e.TokenType = {}));
244
+ })(Ce);
245
+ var Pe = {};
246
+ Object.defineProperty(Pe, "__esModule", { value: !0 });
247
+ var De = {};
248
+ (function(e) {
249
+ Object.defineProperty(e, "__esModule", { value: !0 }), e.ConfirmationViewTypes = void 0, function(t) {
250
+ t.COW_SWAP_ORDER = "COW_SWAP_ORDER", t.COW_SWAP_TWAP_ORDER = "COW_SWAP_TWAP_ORDER";
251
+ }(e.ConfirmationViewTypes || (e.ConfirmationViewTypes = {}));
252
+ })(De);
253
+ var Me = {};
254
+ (function(e) {
255
+ Object.defineProperty(e, "__esModule", { value: !0 }), e.SafeMessageStatus = e.SafeMessageListItemType = void 0, function(t) {
256
+ t.DATE_LABEL = "DATE_LABEL", t.MESSAGE = "MESSAGE";
257
+ }(e.SafeMessageListItemType || (e.SafeMessageListItemType = {})), function(t) {
258
+ t.NEEDS_CONFIRMATION = "NEEDS_CONFIRMATION", t.CONFIRMED = "CONFIRMED";
259
+ }(e.SafeMessageStatus || (e.SafeMessageStatus = {}));
260
+ })(Me);
261
+ var Re = {};
262
+ (function(e) {
263
+ Object.defineProperty(e, "__esModule", { value: !0 }), e.DeviceType = void 0, function(t) {
264
+ t.ANDROID = "ANDROID", t.IOS = "IOS", t.WEB = "WEB";
265
+ }(e.DeviceType || (e.DeviceType = {}));
266
+ })(Re);
267
+ var $e = {};
268
+ Object.defineProperty($e, "__esModule", { value: !0 });
269
+ (function(e) {
270
+ var t = R && R.__createBinding || (Object.create ? function(a, u, f, d) {
271
+ d === void 0 && (d = f);
272
+ var w = Object.getOwnPropertyDescriptor(u, f);
273
+ (!w || ("get" in w ? !u.__esModule : w.writable || w.configurable)) && (w = { enumerable: !0, get: function() {
274
+ return u[f];
275
+ } }), Object.defineProperty(a, d, w);
276
+ } : function(a, u, f, d) {
277
+ d === void 0 && (d = f), a[d] = u[f];
278
+ }), n = R && R.__exportStar || function(a, u) {
279
+ for (var f in a) f !== "default" && !Object.prototype.hasOwnProperty.call(u, f) && t(u, a, f);
280
+ };
281
+ Object.defineProperty(e, "__esModule", { value: !0 }), e.deleteAccount = e.getAccount = e.createAccount = e.verifyAuth = e.getAuthNonce = e.getContract = e.getSafeOverviews = e.unsubscribeAll = e.unsubscribeSingle = e.registerRecoveryModule = e.deleteRegisteredEmail = e.getRegisteredEmail = e.verifyEmail = e.resendEmailVerificationCode = e.changeEmail = e.registerEmail = e.unregisterDevice = e.unregisterSafe = e.registerDevice = e.getDelegates = e.confirmSafeMessage = e.proposeSafeMessage = e.getSafeMessage = e.getSafeMessages = e.getDecodedData = e.getMasterCopies = e.getSafeApps = e.getChainConfig = e.getChainsConfig = e.getConfirmationView = e.proposeTransaction = e.getNonces = e.postSafeGasEstimation = e.deleteTransaction = e.getTransactionDetails = e.getTransactionQueue = e.getTransactionHistory = e.getCollectiblesPage = e.getCollectibles = e.getAllOwnedSafes = e.getOwnedSafes = e.getFiatCurrencies = e.getBalances = e.getMultisigTransactions = e.getModuleTransactions = e.getIncomingTransfers = e.getSafeInfo = e.getRelayCount = e.relayTransaction = e.setBaseUrl = void 0, e.putAccountDataSettings = e.getAccountDataSettings = e.getAccountDataTypes = void 0;
282
+ const i = A, s = q;
283
+ n(ve, e), n(we, e), n(Oe, e), n(Ne, e), n(Ce, e), n(Pe, e), n(De, e), n(Me, e), n(Re, e), n($e, e);
284
+ let r = s.DEFAULT_BASE_URL;
285
+ const o = (a) => {
286
+ r = a;
287
+ };
288
+ e.setBaseUrl = o;
289
+ function c(a, u) {
290
+ return (0, i.postEndpoint)(r, "/v1/chains/{chainId}/relay", { path: { chainId: a }, body: u });
291
+ }
292
+ e.relayTransaction = c;
293
+ function l(a, u) {
294
+ return (0, i.getEndpoint)(r, "/v1/chains/{chainId}/relay/{address}", { path: { chainId: a, address: u } });
295
+ }
296
+ e.getRelayCount = l;
297
+ function g(a, u) {
298
+ return (0, i.getEndpoint)(r, "/v1/chains/{chainId}/safes/{address}", { path: { chainId: a, address: u } });
299
+ }
300
+ e.getSafeInfo = g;
301
+ function h(a, u, f, d) {
302
+ return (0, i.getEndpoint)(r, "/v1/chains/{chainId}/safes/{address}/incoming-transfers/", {
303
+ path: { chainId: a, address: u },
304
+ query: f
305
+ }, d);
306
+ }
307
+ e.getIncomingTransfers = h;
308
+ function y(a, u, f, d) {
309
+ return (0, i.getEndpoint)(r, "/v1/chains/{chainId}/safes/{address}/module-transactions/", {
310
+ path: { chainId: a, address: u },
311
+ query: f
312
+ }, d);
313
+ }
314
+ e.getModuleTransactions = y;
315
+ function M(a, u, f, d) {
316
+ return (0, i.getEndpoint)(r, "/v1/chains/{chainId}/safes/{address}/multisig-transactions/", {
317
+ path: { chainId: a, address: u },
318
+ query: f
319
+ }, d);
320
+ }
321
+ e.getMultisigTransactions = M;
322
+ function S(a, u, f = "usd", d = {}) {
323
+ return (0, i.getEndpoint)(r, "/v1/chains/{chainId}/safes/{address}/balances/{currency}", {
324
+ path: { chainId: a, address: u, currency: f },
325
+ query: d
326
+ });
327
+ }
328
+ e.getBalances = S;
329
+ function z() {
330
+ return (0, i.getEndpoint)(r, "/v1/balances/supported-fiat-codes");
331
+ }
332
+ e.getFiatCurrencies = z;
333
+ function K(a, u) {
334
+ return (0, i.getEndpoint)(r, "/v1/chains/{chainId}/owners/{address}/safes", { path: { chainId: a, address: u } });
335
+ }
336
+ e.getOwnedSafes = K;
337
+ function P(a) {
338
+ return (0, i.getEndpoint)(r, "/v1/owners/{address}/safes", { path: { address: a } });
339
+ }
340
+ e.getAllOwnedSafes = P;
341
+ function X(a, u, f = {}) {
342
+ return (0, i.getEndpoint)(r, "/v1/chains/{chainId}/safes/{address}/collectibles", {
343
+ path: { chainId: a, address: u },
344
+ query: f
345
+ });
346
+ }
347
+ e.getCollectibles = X;
348
+ function ct(a, u, f = {}, d) {
349
+ return (0, i.getEndpoint)(r, "/v2/chains/{chainId}/safes/{address}/collectibles", { path: { chainId: a, address: u }, query: f }, d);
350
+ }
351
+ e.getCollectiblesPage = ct;
352
+ function ut(a, u, f = {}, d) {
353
+ return (0, i.getEndpoint)(r, "/v1/chains/{chainId}/safes/{safe_address}/transactions/history", { path: { chainId: a, safe_address: u }, query: f }, d);
354
+ }
355
+ e.getTransactionHistory = ut;
356
+ function ft(a, u, f = {}, d) {
357
+ return (0, i.getEndpoint)(r, "/v1/chains/{chainId}/safes/{safe_address}/transactions/queued", { path: { chainId: a, safe_address: u }, query: f }, d);
358
+ }
359
+ e.getTransactionQueue = ft;
360
+ function dt(a, u) {
361
+ return (0, i.getEndpoint)(r, "/v1/chains/{chainId}/transactions/{transactionId}", {
362
+ path: { chainId: a, transactionId: u }
363
+ });
364
+ }
365
+ e.getTransactionDetails = dt;
366
+ function lt(a, u, f) {
367
+ return (0, i.deleteEndpoint)(r, "/v1/chains/{chainId}/transactions/{safeTxHash}", {
368
+ path: { chainId: a, safeTxHash: u },
369
+ body: { signature: f }
370
+ });
371
+ }
372
+ e.deleteTransaction = lt;
373
+ function ht(a, u, f) {
374
+ return (0, i.postEndpoint)(r, "/v2/chains/{chainId}/safes/{safe_address}/multisig-transactions/estimations", {
375
+ path: { chainId: a, safe_address: u },
376
+ body: f
377
+ });
378
+ }
379
+ e.postSafeGasEstimation = ht;
380
+ function gt(a, u) {
381
+ return (0, i.getEndpoint)(r, "/v1/chains/{chainId}/safes/{safe_address}/nonces", {
382
+ path: { chainId: a, safe_address: u }
383
+ });
384
+ }
385
+ e.getNonces = gt;
386
+ function yt(a, u, f) {
387
+ return (0, i.postEndpoint)(r, "/v1/chains/{chainId}/transactions/{safe_address}/propose", {
388
+ path: { chainId: a, safe_address: u },
389
+ body: f
390
+ });
391
+ }
392
+ e.proposeTransaction = yt;
393
+ function pt(a, u, f, d) {
394
+ return (0, i.postEndpoint)(r, "/v1/chains/{chainId}/safes/{safe_address}/views/transaction-confirmation", {
395
+ path: { chainId: a, safe_address: u },
396
+ body: { data: f, to: d }
397
+ });
398
+ }
399
+ e.getConfirmationView = pt;
400
+ function bt(a) {
401
+ return (0, i.getEndpoint)(r, "/v1/chains", {
402
+ query: a
403
+ });
404
+ }
405
+ e.getChainsConfig = bt;
406
+ function mt(a) {
407
+ return (0, i.getEndpoint)(r, "/v1/chains/{chainId}", {
408
+ path: { chainId: a }
409
+ });
410
+ }
411
+ e.getChainConfig = mt;
412
+ function Et(a, u = {}) {
413
+ return (0, i.getEndpoint)(r, "/v1/chains/{chainId}/safe-apps", {
414
+ path: { chainId: a },
415
+ query: u
416
+ });
417
+ }
418
+ e.getSafeApps = Et;
419
+ function At(a) {
420
+ return (0, i.getEndpoint)(r, "/v1/chains/{chainId}/about/master-copies", {
421
+ path: { chainId: a }
422
+ });
423
+ }
424
+ e.getMasterCopies = At;
425
+ function Tt(a, u, f) {
426
+ return (0, i.postEndpoint)(r, "/v1/chains/{chainId}/data-decoder", {
427
+ path: { chainId: a },
428
+ body: { data: u, to: f }
429
+ });
430
+ }
431
+ e.getDecodedData = Tt;
432
+ function _t(a, u, f) {
433
+ return (0, i.getEndpoint)(r, "/v1/chains/{chainId}/safes/{safe_address}/messages", { path: { chainId: a, safe_address: u }, query: {} }, f);
434
+ }
435
+ e.getSafeMessages = _t;
436
+ function St(a, u) {
437
+ return (0, i.getEndpoint)(r, "/v1/chains/{chainId}/messages/{message_hash}", {
438
+ path: { chainId: a, message_hash: u }
439
+ });
440
+ }
441
+ e.getSafeMessage = St;
442
+ function It(a, u, f) {
443
+ return (0, i.postEndpoint)(r, "/v1/chains/{chainId}/safes/{safe_address}/messages", {
444
+ path: { chainId: a, safe_address: u },
445
+ body: f
446
+ });
447
+ }
448
+ e.proposeSafeMessage = It;
449
+ function vt(a, u, f) {
450
+ return (0, i.postEndpoint)(r, "/v1/chains/{chainId}/messages/{message_hash}/signatures", {
451
+ path: { chainId: a, message_hash: u },
452
+ body: f
453
+ });
454
+ }
455
+ e.confirmSafeMessage = vt;
456
+ function wt(a, u = {}) {
457
+ return (0, i.getEndpoint)(r, "/v1/chains/{chainId}/delegates", {
458
+ path: { chainId: a },
459
+ query: u
460
+ });
461
+ }
462
+ e.getDelegates = wt;
463
+ function Ot(a) {
464
+ return (0, i.postEndpoint)(r, "/v1/register/notifications", {
465
+ body: a
466
+ });
467
+ }
468
+ e.registerDevice = Ot;
469
+ function Nt(a, u, f) {
470
+ return (0, i.deleteEndpoint)(r, "/v1/chains/{chainId}/notifications/devices/{uuid}/safes/{safe_address}", {
471
+ path: { chainId: a, safe_address: u, uuid: f }
472
+ });
473
+ }
474
+ e.unregisterSafe = Nt;
475
+ function Ct(a, u) {
476
+ return (0, i.deleteEndpoint)(r, "/v1/chains/{chainId}/notifications/devices/{uuid}", {
477
+ path: { chainId: a, uuid: u }
478
+ });
479
+ }
480
+ e.unregisterDevice = Ct;
481
+ function Pt(a, u, f, d) {
482
+ return (0, i.postEndpoint)(r, "/v1/chains/{chainId}/safes/{safe_address}/emails", {
483
+ path: { chainId: a, safe_address: u },
484
+ body: f,
485
+ headers: d
486
+ });
487
+ }
488
+ e.registerEmail = Pt;
489
+ function Dt(a, u, f, d, w) {
490
+ return (0, i.putEndpoint)(r, "/v1/chains/{chainId}/safes/{safe_address}/emails/{signer}", {
491
+ path: { chainId: a, safe_address: u, signer: f },
492
+ body: d,
493
+ headers: w
494
+ });
495
+ }
496
+ e.changeEmail = Dt;
497
+ function Mt(a, u, f) {
498
+ return (0, i.postEndpoint)(r, "/v1/chains/{chainId}/safes/{safe_address}/emails/{signer}/verify-resend", {
499
+ path: { chainId: a, safe_address: u, signer: f },
500
+ body: ""
501
+ });
502
+ }
503
+ e.resendEmailVerificationCode = Mt;
504
+ function Rt(a, u, f, d) {
505
+ return (0, i.putEndpoint)(r, "/v1/chains/{chainId}/safes/{safe_address}/emails/{signer}/verify", {
506
+ path: { chainId: a, safe_address: u, signer: f },
507
+ body: d
508
+ });
509
+ }
510
+ e.verifyEmail = Rt;
511
+ function $t(a, u, f, d) {
512
+ return (0, i.getEndpoint)(r, "/v1/chains/{chainId}/safes/{safe_address}/emails/{signer}", {
513
+ path: { chainId: a, safe_address: u, signer: f },
514
+ headers: d
515
+ });
516
+ }
517
+ e.getRegisteredEmail = $t;
518
+ function Lt(a, u, f, d) {
519
+ return (0, i.deleteEndpoint)(r, "/v1/chains/{chainId}/safes/{safe_address}/emails/{signer}", {
520
+ path: { chainId: a, safe_address: u, signer: f },
521
+ headers: d
522
+ });
523
+ }
524
+ e.deleteRegisteredEmail = Lt;
525
+ function Bt(a, u, f) {
526
+ return (0, i.postEndpoint)(r, "/v1/chains/{chainId}/safes/{safe_address}/recovery", {
527
+ path: { chainId: a, safe_address: u },
528
+ body: f
529
+ });
530
+ }
531
+ e.registerRecoveryModule = Bt;
532
+ function jt(a) {
533
+ return (0, i.deleteEndpoint)(r, "/v1/subscriptions", { query: a });
534
+ }
535
+ e.unsubscribeSingle = jt;
536
+ function Ht(a) {
537
+ return (0, i.deleteEndpoint)(r, "/v1/subscriptions/all", { query: a });
538
+ }
539
+ e.unsubscribeAll = Ht;
540
+ function Ut(a, u) {
541
+ return (0, i.getEndpoint)(r, "/v1/safes", {
542
+ query: Object.assign(Object.assign({}, u), { safes: a.join(",") })
543
+ });
544
+ }
545
+ e.getSafeOverviews = Ut;
546
+ function kt(a, u) {
547
+ return (0, i.getEndpoint)(r, "/v1/chains/{chainId}/contracts/{contractAddress}", {
548
+ path: {
549
+ chainId: a,
550
+ contractAddress: u
551
+ }
552
+ });
553
+ }
554
+ e.getContract = kt;
555
+ function zt() {
556
+ return (0, i.getEndpoint)(r, "/v1/auth/nonce", { credentials: "include" });
557
+ }
558
+ e.getAuthNonce = zt;
559
+ function Ft(a) {
560
+ return (0, i.postEndpoint)(r, "/v1/auth/verify", {
561
+ body: a,
562
+ credentials: "include"
563
+ });
564
+ }
565
+ e.verifyAuth = Ft;
566
+ function Gt(a) {
567
+ return (0, i.postEndpoint)(r, "/v1/accounts", {
568
+ body: a,
569
+ credentials: "include"
570
+ });
571
+ }
572
+ e.createAccount = Gt;
573
+ function Vt(a) {
574
+ return (0, i.getEndpoint)(r, "/v1/accounts/{address}", {
575
+ path: { address: a },
576
+ credentials: "include"
577
+ });
578
+ }
579
+ e.getAccount = Vt;
580
+ function Wt(a) {
581
+ return (0, i.deleteEndpoint)(r, "/v1/accounts/{address}", {
582
+ path: { address: a },
583
+ credentials: "include"
584
+ });
585
+ }
586
+ e.deleteAccount = Wt;
587
+ function qt() {
588
+ return (0, i.getEndpoint)(r, "/v1/accounts/data-types");
589
+ }
590
+ e.getAccountDataTypes = qt;
591
+ function Kt(a) {
592
+ return (0, i.getEndpoint)(r, "/v1/accounts/{address}/data-settings", {
593
+ path: { address: a },
594
+ credentials: "include"
595
+ });
596
+ }
597
+ e.getAccountDataSettings = Kt;
598
+ function Xt(a, u) {
599
+ return (0, i.putEndpoint)(r, "/v1/accounts/{address}/data-settings", {
600
+ path: { address: a },
601
+ body: u,
602
+ credentials: "include"
603
+ });
604
+ }
605
+ e.putAccountDataSettings = Xt;
606
+ })(en);
607
+ class ln {
608
+ constructor(t) {
609
+ this.communicator = t;
610
+ }
611
+ async getBySafeTxHash(t) {
612
+ if (!t)
613
+ throw new Error("Invalid safeTxHash");
614
+ return (await this.communicator.send(b.getTxBySafeTxHash, { safeTxHash: t })).data;
615
+ }
616
+ async signMessage(t) {
617
+ const n = {
618
+ message: t
619
+ };
620
+ return (await this.communicator.send(b.signMessage, n)).data;
621
+ }
622
+ async signTypedMessage(t) {
623
+ if (!Se(t))
624
+ throw new Error("Invalid typed data");
625
+ return (await this.communicator.send(b.signTypedMessage, { typedData: t })).data;
626
+ }
627
+ async send({ txs: t, params: n }) {
628
+ if (!t || !t.length)
629
+ throw new Error("No transactions were passed");
630
+ const i = {
631
+ txs: t,
632
+ params: n
633
+ };
634
+ return (await this.communicator.send(b.sendTransactions, i)).data;
635
+ }
636
+ }
637
+ const m = {
638
+ eth_call: "eth_call",
639
+ eth_gasPrice: "eth_gasPrice",
640
+ eth_getLogs: "eth_getLogs",
641
+ eth_getBalance: "eth_getBalance",
642
+ eth_getCode: "eth_getCode",
643
+ eth_getBlockByHash: "eth_getBlockByHash",
644
+ eth_getBlockByNumber: "eth_getBlockByNumber",
645
+ eth_getStorageAt: "eth_getStorageAt",
646
+ eth_getTransactionByHash: "eth_getTransactionByHash",
647
+ eth_getTransactionReceipt: "eth_getTransactionReceipt",
648
+ eth_getTransactionCount: "eth_getTransactionCount",
649
+ eth_estimateGas: "eth_estimateGas",
650
+ safe_setSettings: "safe_setSettings"
651
+ }, I = {
652
+ defaultBlockParam: (e = "latest") => e,
653
+ returnFullTxObjectParam: (e = !1) => e,
654
+ blockNumberToHex: (e) => Number.isInteger(e) ? `0x${e.toString(16)}` : e
655
+ };
656
+ class hn {
657
+ constructor(t) {
658
+ this.communicator = t, this.call = this.buildRequest({
659
+ call: m.eth_call,
660
+ formatters: [null, I.defaultBlockParam]
661
+ }), this.getBalance = this.buildRequest({
662
+ call: m.eth_getBalance,
663
+ formatters: [null, I.defaultBlockParam]
664
+ }), this.getCode = this.buildRequest({
665
+ call: m.eth_getCode,
666
+ formatters: [null, I.defaultBlockParam]
667
+ }), this.getStorageAt = this.buildRequest({
668
+ call: m.eth_getStorageAt,
669
+ formatters: [null, I.blockNumberToHex, I.defaultBlockParam]
670
+ }), this.getPastLogs = this.buildRequest({
671
+ call: m.eth_getLogs
672
+ }), this.getBlockByHash = this.buildRequest({
673
+ call: m.eth_getBlockByHash,
674
+ formatters: [null, I.returnFullTxObjectParam]
675
+ }), this.getBlockByNumber = this.buildRequest({
676
+ call: m.eth_getBlockByNumber,
677
+ formatters: [I.blockNumberToHex, I.returnFullTxObjectParam]
678
+ }), this.getTransactionByHash = this.buildRequest({
679
+ call: m.eth_getTransactionByHash
680
+ }), this.getTransactionReceipt = this.buildRequest({
681
+ call: m.eth_getTransactionReceipt
682
+ }), this.getTransactionCount = this.buildRequest({
683
+ call: m.eth_getTransactionCount,
684
+ formatters: [null, I.defaultBlockParam]
685
+ }), this.getGasPrice = this.buildRequest({
686
+ call: m.eth_gasPrice
687
+ }), this.getEstimateGas = (n) => this.buildRequest({
688
+ call: m.eth_estimateGas
689
+ })([n]), this.setSafeSettings = this.buildRequest({
690
+ call: m.safe_setSettings
691
+ });
692
+ }
693
+ buildRequest(t) {
694
+ const { call: n, formatters: i } = t;
695
+ return async (s) => {
696
+ i && Array.isArray(s) && i.forEach((c, l) => {
697
+ c && (s[l] = c(s[l]));
698
+ });
699
+ const r = {
700
+ call: n,
701
+ params: s || []
702
+ };
703
+ return (await this.communicator.send(b.rpcCall, r)).data;
704
+ };
705
+ }
706
+ }
707
+ function gn(e, t) {
708
+ const n = e.exec(t);
709
+ return n == null ? void 0 : n.groups;
710
+ }
711
+ const fe = /^tuple(?<array>(\[(\d*)\])*)$/;
712
+ function Z(e) {
713
+ let t = e.type;
714
+ if (fe.test(e.type) && "components" in e) {
715
+ t = "(";
716
+ const n = e.components.length;
717
+ for (let s = 0; s < n; s++) {
718
+ const r = e.components[s];
719
+ t += Z(r), s < n - 1 && (t += ", ");
720
+ }
721
+ const i = gn(fe, e.type);
722
+ return t += `)${(i == null ? void 0 : i.array) ?? ""}`, Z({
723
+ ...e,
724
+ type: t
725
+ });
726
+ }
727
+ return "indexed" in e && e.indexed && (t = `${t} indexed`), e.name ? `${t} ${e.name}` : t;
728
+ }
729
+ function L(e) {
730
+ let t = "";
731
+ const n = e.length;
732
+ for (let i = 0; i < n; i++) {
733
+ const s = e[i];
734
+ t += Z(s), i !== n - 1 && (t += ", ");
735
+ }
736
+ return t;
737
+ }
738
+ function yn(e) {
739
+ return e.type === "function" ? `function ${e.name}(${L(e.inputs)})${e.stateMutability && e.stateMutability !== "nonpayable" ? ` ${e.stateMutability}` : ""}${e.outputs.length ? ` returns (${L(e.outputs)})` : ""}` : e.type === "event" ? `event ${e.name}(${L(e.inputs)})` : e.type === "error" ? `error ${e.name}(${L(e.inputs)})` : e.type === "constructor" ? `constructor(${L(e.inputs)})${e.stateMutability === "payable" ? " payable" : ""}` : e.type === "fallback" ? "fallback()" : "receive() external payable";
740
+ }
741
+ function x(e, { includeName: t = !1 } = {}) {
742
+ if (e.type !== "function" && e.type !== "event" && e.type !== "error")
743
+ throw new wn(e.type);
744
+ return `${e.name}(${Le(e.inputs, { includeName: t })})`;
745
+ }
746
+ function Le(e, { includeName: t = !1 } = {}) {
747
+ return e ? e.map((n) => pn(n, { includeName: t })).join(t ? ", " : ",") : "";
748
+ }
749
+ function pn(e, { includeName: t }) {
750
+ return e.type.startsWith("tuple") ? `(${Le(e.components, { includeName: t })})${e.type.slice(5)}` : e.type + (t && e.name ? ` ${e.name}` : "");
751
+ }
752
+ function U(e, { strict: t = !0 } = {}) {
753
+ return !e || typeof e != "string" ? !1 : t ? /^0x[0-9a-fA-F]*$/.test(e) : e.startsWith("0x");
754
+ }
755
+ function E(e) {
756
+ return U(e, { strict: !1 }) ? Math.ceil((e.length - 2) / 2) : e.length;
757
+ }
758
+ const bn = "2.18.5", mn = () => `viem@${bn}`;
759
+ class p extends Error {
760
+ constructor(t, n = {}) {
761
+ var c;
762
+ const i = n.cause instanceof p ? n.cause.details : (c = n.cause) != null && c.message ? n.cause.message : n.details, s = n.cause instanceof p && n.cause.docsPath || n.docsPath, r = mn(), o = [
763
+ t || "An error occurred.",
764
+ "",
765
+ ...n.metaMessages ? [...n.metaMessages, ""] : [],
766
+ ...s ? [
767
+ `Docs: ${n.docsBaseUrl ?? "https://viem.sh"}${s}${n.docsSlug ? `#${n.docsSlug}` : ""}`
768
+ ] : [],
769
+ ...i ? [`Details: ${i}`] : [],
770
+ `Version: ${r}`
771
+ ].join(`
772
+ `);
773
+ super(o, n.cause ? { cause: n.cause } : void 0), Object.defineProperty(this, "details", {
774
+ enumerable: !0,
775
+ configurable: !0,
776
+ writable: !0,
777
+ value: void 0
778
+ }), Object.defineProperty(this, "docsPath", {
779
+ enumerable: !0,
780
+ configurable: !0,
781
+ writable: !0,
782
+ value: void 0
783
+ }), Object.defineProperty(this, "metaMessages", {
784
+ enumerable: !0,
785
+ configurable: !0,
786
+ writable: !0,
787
+ value: void 0
788
+ }), Object.defineProperty(this, "shortMessage", {
789
+ enumerable: !0,
790
+ configurable: !0,
791
+ writable: !0,
792
+ value: void 0
793
+ }), Object.defineProperty(this, "version", {
794
+ enumerable: !0,
795
+ configurable: !0,
796
+ writable: !0,
797
+ value: void 0
798
+ }), Object.defineProperty(this, "name", {
799
+ enumerable: !0,
800
+ configurable: !0,
801
+ writable: !0,
802
+ value: "ViemError"
803
+ }), this.details = i, this.docsPath = s, this.metaMessages = n.metaMessages, this.shortMessage = t, this.version = r;
804
+ }
805
+ walk(t) {
806
+ return Be(this, t);
807
+ }
808
+ }
809
+ function Be(e, t) {
810
+ return t != null && t(e) ? e : e && typeof e == "object" && "cause" in e ? Be(e.cause, t) : t ? null : e;
811
+ }
812
+ class En extends p {
813
+ constructor({ expectedLength: t, givenLength: n, type: i }) {
814
+ super([
815
+ `ABI encoding array length mismatch for type ${i}.`,
816
+ `Expected length: ${t}`,
817
+ `Given length: ${n}`
818
+ ].join(`
819
+ `)), Object.defineProperty(this, "name", {
820
+ enumerable: !0,
821
+ configurable: !0,
822
+ writable: !0,
823
+ value: "AbiEncodingArrayLengthMismatchError"
824
+ });
825
+ }
826
+ }
827
+ class An extends p {
828
+ constructor({ expectedSize: t, value: n }) {
829
+ super(`Size of bytes "${n}" (bytes${E(n)}) does not match expected size (bytes${t}).`), Object.defineProperty(this, "name", {
830
+ enumerable: !0,
831
+ configurable: !0,
832
+ writable: !0,
833
+ value: "AbiEncodingBytesSizeMismatchError"
834
+ });
835
+ }
836
+ }
837
+ class Tn extends p {
838
+ constructor({ expectedLength: t, givenLength: n }) {
839
+ super([
840
+ "ABI encoding params/values length mismatch.",
841
+ `Expected length (params): ${t}`,
842
+ `Given length (values): ${n}`
843
+ ].join(`
844
+ `)), Object.defineProperty(this, "name", {
845
+ enumerable: !0,
846
+ configurable: !0,
847
+ writable: !0,
848
+ value: "AbiEncodingLengthMismatchError"
849
+ });
850
+ }
851
+ }
852
+ class de extends p {
853
+ constructor(t, { docsPath: n } = {}) {
854
+ super([
855
+ `Function ${t ? `"${t}" ` : ""}not found on ABI.`,
856
+ "Make sure you are using the correct ABI and that the function exists on it."
857
+ ].join(`
858
+ `), {
859
+ docsPath: n
860
+ }), Object.defineProperty(this, "name", {
861
+ enumerable: !0,
862
+ configurable: !0,
863
+ writable: !0,
864
+ value: "AbiFunctionNotFoundError"
865
+ });
866
+ }
867
+ }
868
+ class _n extends p {
869
+ constructor(t, n) {
870
+ super("Found ambiguous types in overloaded ABI items.", {
871
+ metaMessages: [
872
+ `\`${t.type}\` in \`${x(t.abiItem)}\`, and`,
873
+ `\`${n.type}\` in \`${x(n.abiItem)}\``,
874
+ "",
875
+ "These types encode differently and cannot be distinguished at runtime.",
876
+ "Remove one of the ambiguous items in the ABI."
877
+ ]
878
+ }), Object.defineProperty(this, "name", {
879
+ enumerable: !0,
880
+ configurable: !0,
881
+ writable: !0,
882
+ value: "AbiItemAmbiguityError"
883
+ });
884
+ }
885
+ }
886
+ class Sn extends p {
887
+ constructor({ expectedSize: t, givenSize: n }) {
888
+ super(`Expected bytes${t}, got bytes${n}.`), Object.defineProperty(this, "name", {
889
+ enumerable: !0,
890
+ configurable: !0,
891
+ writable: !0,
892
+ value: "BytesSizeMismatchError"
893
+ });
894
+ }
895
+ }
896
+ class In extends p {
897
+ constructor(t, { docsPath: n }) {
898
+ super([
899
+ `Type "${t}" is not a valid encoding type.`,
900
+ "Please provide a valid ABI type."
901
+ ].join(`
902
+ `), { docsPath: n }), Object.defineProperty(this, "name", {
903
+ enumerable: !0,
904
+ configurable: !0,
905
+ writable: !0,
906
+ value: "InvalidAbiEncodingType"
907
+ });
908
+ }
909
+ }
910
+ class vn extends p {
911
+ constructor(t) {
912
+ super([`Value "${t}" is not a valid array.`].join(`
913
+ `)), Object.defineProperty(this, "name", {
914
+ enumerable: !0,
915
+ configurable: !0,
916
+ writable: !0,
917
+ value: "InvalidArrayError"
918
+ });
919
+ }
920
+ }
921
+ class wn extends p {
922
+ constructor(t) {
923
+ super([
924
+ `"${t}" is not a valid definition type.`,
925
+ 'Valid types: "function", "event", "error"'
926
+ ].join(`
927
+ `)), Object.defineProperty(this, "name", {
928
+ enumerable: !0,
929
+ configurable: !0,
930
+ writable: !0,
931
+ value: "InvalidDefinitionTypeError"
932
+ });
933
+ }
934
+ }
935
+ class je extends p {
936
+ constructor({ offset: t, position: n, size: i }) {
937
+ super(`Slice ${n === "start" ? "starting" : "ending"} at offset "${t}" is out-of-bounds (size: ${i}).`), Object.defineProperty(this, "name", {
938
+ enumerable: !0,
939
+ configurable: !0,
940
+ writable: !0,
941
+ value: "SliceOffsetOutOfBoundsError"
942
+ });
943
+ }
944
+ }
945
+ class He extends p {
946
+ constructor({ size: t, targetSize: n, type: i }) {
947
+ super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (${t}) exceeds padding size (${n}).`), Object.defineProperty(this, "name", {
948
+ enumerable: !0,
949
+ configurable: !0,
950
+ writable: !0,
951
+ value: "SizeExceedsPaddingSizeError"
952
+ });
953
+ }
954
+ }
955
+ function $(e, { dir: t, size: n = 32 } = {}) {
956
+ return typeof e == "string" ? O(e, { dir: t, size: n }) : On(e, { dir: t, size: n });
957
+ }
958
+ function O(e, { dir: t, size: n = 32 } = {}) {
959
+ if (n === null)
960
+ return e;
961
+ const i = e.replace("0x", "");
962
+ if (i.length > n * 2)
963
+ throw new He({
964
+ size: Math.ceil(i.length / 2),
965
+ targetSize: n,
966
+ type: "hex"
967
+ });
968
+ return `0x${i[t === "right" ? "padEnd" : "padStart"](n * 2, "0")}`;
969
+ }
970
+ function On(e, { dir: t, size: n = 32 } = {}) {
971
+ if (n === null)
972
+ return e;
973
+ if (e.length > n)
974
+ throw new He({
975
+ size: e.length,
976
+ targetSize: n,
977
+ type: "bytes"
978
+ });
979
+ const i = new Uint8Array(n);
980
+ for (let s = 0; s < n; s++) {
981
+ const r = t === "right";
982
+ i[r ? s : n - s - 1] = e[r ? s : e.length - s - 1];
983
+ }
984
+ return i;
985
+ }
986
+ class Nn extends p {
987
+ constructor({ max: t, min: n, signed: i, size: s, value: r }) {
988
+ super(`Number "${r}" is not in safe ${s ? `${s * 8}-bit ${i ? "signed" : "unsigned"} ` : ""}integer range ${t ? `(${n} to ${t})` : `(above ${n})`}`), Object.defineProperty(this, "name", {
989
+ enumerable: !0,
990
+ configurable: !0,
991
+ writable: !0,
992
+ value: "IntegerOutOfRangeError"
993
+ });
994
+ }
995
+ }
996
+ class Cn extends p {
997
+ constructor({ givenSize: t, maxSize: n }) {
998
+ super(`Size cannot exceed ${n} bytes. Given size: ${t} bytes.`), Object.defineProperty(this, "name", {
999
+ enumerable: !0,
1000
+ configurable: !0,
1001
+ writable: !0,
1002
+ value: "SizeOverflowError"
1003
+ });
1004
+ }
1005
+ }
1006
+ function k(e, { size: t }) {
1007
+ if (E(e) > t)
1008
+ throw new Cn({
1009
+ givenSize: E(e),
1010
+ maxSize: t
1011
+ });
1012
+ }
1013
+ const Pn = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
1014
+ function ie(e, t = {}) {
1015
+ return typeof e == "number" || typeof e == "bigint" ? C(e, t) : typeof e == "string" ? G(e, t) : typeof e == "boolean" ? Ue(e, t) : se(e, t);
1016
+ }
1017
+ function Ue(e, t = {}) {
1018
+ const n = `0x${Number(e)}`;
1019
+ return typeof t.size == "number" ? (k(n, { size: t.size }), $(n, { size: t.size })) : n;
1020
+ }
1021
+ function se(e, t = {}) {
1022
+ let n = "";
1023
+ for (let s = 0; s < e.length; s++)
1024
+ n += Pn[e[s]];
1025
+ const i = `0x${n}`;
1026
+ return typeof t.size == "number" ? (k(i, { size: t.size }), $(i, { dir: "right", size: t.size })) : i;
1027
+ }
1028
+ function C(e, t = {}) {
1029
+ const { signed: n, size: i } = t, s = BigInt(e);
1030
+ let r;
1031
+ i ? n ? r = (1n << BigInt(i) * 8n - 1n) - 1n : r = 2n ** (BigInt(i) * 8n) - 1n : typeof e == "number" && (r = BigInt(Number.MAX_SAFE_INTEGER));
1032
+ const o = typeof r == "bigint" && n ? -r - 1n : 0;
1033
+ if (r && s > r || s < o) {
1034
+ const l = typeof e == "bigint" ? "n" : "";
1035
+ throw new Nn({
1036
+ max: r ? `${r}${l}` : void 0,
1037
+ min: `${o}${l}`,
1038
+ signed: n,
1039
+ size: i,
1040
+ value: `${e}${l}`
1041
+ });
1042
+ }
1043
+ const c = `0x${(n && s < 0 ? (1n << BigInt(i * 8)) + BigInt(s) : s).toString(16)}`;
1044
+ return i ? $(c, { size: i }) : c;
1045
+ }
1046
+ const Dn = /* @__PURE__ */ new TextEncoder();
1047
+ function G(e, t = {}) {
1048
+ const n = Dn.encode(e);
1049
+ return se(n, t);
1050
+ }
1051
+ const Mn = /* @__PURE__ */ new TextEncoder();
1052
+ function ke(e, t = {}) {
1053
+ return typeof e == "number" || typeof e == "bigint" ? $n(e, t) : typeof e == "boolean" ? Rn(e, t) : U(e) ? ze(e, t) : Fe(e, t);
1054
+ }
1055
+ function Rn(e, t = {}) {
1056
+ const n = new Uint8Array(1);
1057
+ return n[0] = Number(e), typeof t.size == "number" ? (k(n, { size: t.size }), $(n, { size: t.size })) : n;
1058
+ }
1059
+ const v = {
1060
+ zero: 48,
1061
+ nine: 57,
1062
+ A: 65,
1063
+ F: 70,
1064
+ a: 97,
1065
+ f: 102
1066
+ };
1067
+ function le(e) {
1068
+ if (e >= v.zero && e <= v.nine)
1069
+ return e - v.zero;
1070
+ if (e >= v.A && e <= v.F)
1071
+ return e - (v.A - 10);
1072
+ if (e >= v.a && e <= v.f)
1073
+ return e - (v.a - 10);
1074
+ }
1075
+ function ze(e, t = {}) {
1076
+ let n = e;
1077
+ t.size && (k(n, { size: t.size }), n = $(n, { dir: "right", size: t.size }));
1078
+ let i = n.slice(2);
1079
+ i.length % 2 && (i = `0${i}`);
1080
+ const s = i.length / 2, r = new Uint8Array(s);
1081
+ for (let o = 0, c = 0; o < s; o++) {
1082
+ const l = le(i.charCodeAt(c++)), g = le(i.charCodeAt(c++));
1083
+ if (l === void 0 || g === void 0)
1084
+ throw new p(`Invalid byte sequence ("${i[c - 2]}${i[c - 1]}" in "${i}").`);
1085
+ r[o] = l * 16 + g;
1086
+ }
1087
+ return r;
1088
+ }
1089
+ function $n(e, t) {
1090
+ const n = C(e, t);
1091
+ return ze(n);
1092
+ }
1093
+ function Fe(e, t = {}) {
1094
+ const n = Mn.encode(e);
1095
+ return typeof t.size == "number" ? (k(n, { size: t.size }), $(n, { dir: "right", size: t.size })) : n;
1096
+ }
1097
+ function he(e) {
1098
+ if (!Number.isSafeInteger(e) || e < 0)
1099
+ throw new Error(`positive integer expected, not ${e}`);
1100
+ }
1101
+ function Ln(e) {
1102
+ return e instanceof Uint8Array || e != null && typeof e == "object" && e.constructor.name === "Uint8Array";
1103
+ }
1104
+ function re(e, ...t) {
1105
+ if (!Ln(e))
1106
+ throw new Error("Uint8Array expected");
1107
+ if (t.length > 0 && !t.includes(e.length))
1108
+ throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`);
1109
+ }
1110
+ function ge(e, t = !0) {
1111
+ if (e.destroyed)
1112
+ throw new Error("Hash instance has been destroyed");
1113
+ if (t && e.finished)
1114
+ throw new Error("Hash#digest() has already been called");
1115
+ }
1116
+ function Bn(e, t) {
1117
+ re(e);
1118
+ const n = t.outputLen;
1119
+ if (e.length < n)
1120
+ throw new Error(`digestInto() expects output buffer of length at least ${n}`);
1121
+ }
1122
+ const F = /* @__PURE__ */ BigInt(2 ** 32 - 1), ye = /* @__PURE__ */ BigInt(32);
1123
+ function jn(e, t = !1) {
1124
+ return t ? { h: Number(e & F), l: Number(e >> ye & F) } : { h: Number(e >> ye & F) | 0, l: Number(e & F) | 0 };
1125
+ }
1126
+ function Hn(e, t = !1) {
1127
+ let n = new Uint32Array(e.length), i = new Uint32Array(e.length);
1128
+ for (let s = 0; s < e.length; s++) {
1129
+ const { h: r, l: o } = jn(e[s], t);
1130
+ [n[s], i[s]] = [r, o];
1131
+ }
1132
+ return [n, i];
1133
+ }
1134
+ const Un = (e, t, n) => e << n | t >>> 32 - n, kn = (e, t, n) => t << n | e >>> 32 - n, zn = (e, t, n) => t << n - 32 | e >>> 64 - n, Fn = (e, t, n) => e << n - 32 | t >>> 64 - n;
1135
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1136
+ const Gn = (e) => new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4)), pe = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68, Vn = (e) => e << 24 & 4278190080 | e << 8 & 16711680 | e >>> 8 & 65280 | e >>> 24 & 255;
1137
+ function be(e) {
1138
+ for (let t = 0; t < e.length; t++)
1139
+ e[t] = Vn(e[t]);
1140
+ }
1141
+ function Wn(e) {
1142
+ if (typeof e != "string")
1143
+ throw new Error(`utf8ToBytes expected string, got ${typeof e}`);
1144
+ return new Uint8Array(new TextEncoder().encode(e));
1145
+ }
1146
+ function Ge(e) {
1147
+ return typeof e == "string" && (e = Wn(e)), re(e), e;
1148
+ }
1149
+ class qn {
1150
+ // Safe version that clones internal state
1151
+ clone() {
1152
+ return this._cloneInto();
1153
+ }
1154
+ }
1155
+ function Kn(e) {
1156
+ const t = (i) => e().update(Ge(i)).digest(), n = e();
1157
+ return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
1158
+ }
1159
+ const Ve = [], We = [], qe = [], Xn = /* @__PURE__ */ BigInt(0), B = /* @__PURE__ */ BigInt(1), Qn = /* @__PURE__ */ BigInt(2), Yn = /* @__PURE__ */ BigInt(7), Jn = /* @__PURE__ */ BigInt(256), Zn = /* @__PURE__ */ BigInt(113);
1160
+ for (let e = 0, t = B, n = 1, i = 0; e < 24; e++) {
1161
+ [n, i] = [i, (2 * n + 3 * i) % 5], Ve.push(2 * (5 * i + n)), We.push((e + 1) * (e + 2) / 2 % 64);
1162
+ let s = Xn;
1163
+ for (let r = 0; r < 7; r++)
1164
+ t = (t << B ^ (t >> Yn) * Zn) % Jn, t & Qn && (s ^= B << (B << /* @__PURE__ */ BigInt(r)) - B);
1165
+ qe.push(s);
1166
+ }
1167
+ const [xn, ei] = /* @__PURE__ */ Hn(qe, !0), me = (e, t, n) => n > 32 ? zn(e, t, n) : Un(e, t, n), Ee = (e, t, n) => n > 32 ? Fn(e, t, n) : kn(e, t, n);
1168
+ function ti(e, t = 24) {
1169
+ const n = new Uint32Array(10);
1170
+ for (let i = 24 - t; i < 24; i++) {
1171
+ for (let o = 0; o < 10; o++)
1172
+ n[o] = e[o] ^ e[o + 10] ^ e[o + 20] ^ e[o + 30] ^ e[o + 40];
1173
+ for (let o = 0; o < 10; o += 2) {
1174
+ const c = (o + 8) % 10, l = (o + 2) % 10, g = n[l], h = n[l + 1], y = me(g, h, 1) ^ n[c], M = Ee(g, h, 1) ^ n[c + 1];
1175
+ for (let S = 0; S < 50; S += 10)
1176
+ e[o + S] ^= y, e[o + S + 1] ^= M;
1177
+ }
1178
+ let s = e[2], r = e[3];
1179
+ for (let o = 0; o < 24; o++) {
1180
+ const c = We[o], l = me(s, r, c), g = Ee(s, r, c), h = Ve[o];
1181
+ s = e[h], r = e[h + 1], e[h] = l, e[h + 1] = g;
1182
+ }
1183
+ for (let o = 0; o < 50; o += 10) {
1184
+ for (let c = 0; c < 10; c++)
1185
+ n[c] = e[o + c];
1186
+ for (let c = 0; c < 10; c++)
1187
+ e[o + c] ^= ~n[(c + 2) % 10] & n[(c + 4) % 10];
1188
+ }
1189
+ e[0] ^= xn[i], e[1] ^= ei[i];
1190
+ }
1191
+ n.fill(0);
1192
+ }
1193
+ class oe extends qn {
1194
+ // NOTE: we accept arguments in bytes instead of bits here.
1195
+ constructor(t, n, i, s = !1, r = 24) {
1196
+ if (super(), this.blockLen = t, this.suffix = n, this.outputLen = i, this.enableXOF = s, this.rounds = r, this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, he(i), 0 >= this.blockLen || this.blockLen >= 200)
1197
+ throw new Error("Sha3 supports only keccak-f1600 function");
1198
+ this.state = new Uint8Array(200), this.state32 = Gn(this.state);
1199
+ }
1200
+ keccak() {
1201
+ pe || be(this.state32), ti(this.state32, this.rounds), pe || be(this.state32), this.posOut = 0, this.pos = 0;
1202
+ }
1203
+ update(t) {
1204
+ ge(this);
1205
+ const { blockLen: n, state: i } = this;
1206
+ t = Ge(t);
1207
+ const s = t.length;
1208
+ for (let r = 0; r < s; ) {
1209
+ const o = Math.min(n - this.pos, s - r);
1210
+ for (let c = 0; c < o; c++)
1211
+ i[this.pos++] ^= t[r++];
1212
+ this.pos === n && this.keccak();
1213
+ }
1214
+ return this;
1215
+ }
1216
+ finish() {
1217
+ if (this.finished)
1218
+ return;
1219
+ this.finished = !0;
1220
+ const { state: t, suffix: n, pos: i, blockLen: s } = this;
1221
+ t[i] ^= n, n & 128 && i === s - 1 && this.keccak(), t[s - 1] ^= 128, this.keccak();
1222
+ }
1223
+ writeInto(t) {
1224
+ ge(this, !1), re(t), this.finish();
1225
+ const n = this.state, { blockLen: i } = this;
1226
+ for (let s = 0, r = t.length; s < r; ) {
1227
+ this.posOut >= i && this.keccak();
1228
+ const o = Math.min(i - this.posOut, r - s);
1229
+ t.set(n.subarray(this.posOut, this.posOut + o), s), this.posOut += o, s += o;
1230
+ }
1231
+ return t;
1232
+ }
1233
+ xofInto(t) {
1234
+ if (!this.enableXOF)
1235
+ throw new Error("XOF is not possible for this instance");
1236
+ return this.writeInto(t);
1237
+ }
1238
+ xof(t) {
1239
+ return he(t), this.xofInto(new Uint8Array(t));
1240
+ }
1241
+ digestInto(t) {
1242
+ if (Bn(t, this), this.finished)
1243
+ throw new Error("digest() was already called");
1244
+ return this.writeInto(t), this.destroy(), t;
1245
+ }
1246
+ digest() {
1247
+ return this.digestInto(new Uint8Array(this.outputLen));
1248
+ }
1249
+ destroy() {
1250
+ this.destroyed = !0, this.state.fill(0);
1251
+ }
1252
+ _cloneInto(t) {
1253
+ const { blockLen: n, suffix: i, outputLen: s, rounds: r, enableXOF: o } = this;
1254
+ return t || (t = new oe(n, i, s, o, r)), t.state32.set(this.state32), t.pos = this.pos, t.posOut = this.posOut, t.finished = this.finished, t.rounds = r, t.suffix = i, t.outputLen = s, t.enableXOF = o, t.destroyed = this.destroyed, t;
1255
+ }
1256
+ }
1257
+ const ni = (e, t, n) => Kn(() => new oe(t, e, n)), ii = /* @__PURE__ */ ni(1, 136, 256 / 8);
1258
+ function _(e, t) {
1259
+ const n = t || "hex", i = ii(U(e, { strict: !1 }) ? ke(e) : e);
1260
+ return n === "bytes" ? i : ie(i);
1261
+ }
1262
+ const si = (e) => _(ke(e));
1263
+ function ri(e) {
1264
+ return si(e);
1265
+ }
1266
+ function oi(e) {
1267
+ let t = !0, n = "", i = 0, s = "", r = !1;
1268
+ for (let o = 0; o < e.length; o++) {
1269
+ const c = e[o];
1270
+ if (["(", ")", ","].includes(c) && (t = !0), c === "(" && i++, c === ")" && i--, !!t) {
1271
+ if (i === 0) {
1272
+ if (c === " " && ["event", "function", ""].includes(s))
1273
+ s = "";
1274
+ else if (s += c, c === ")") {
1275
+ r = !0;
1276
+ break;
1277
+ }
1278
+ continue;
1279
+ }
1280
+ if (c === " ") {
1281
+ e[o - 1] !== "," && n !== "," && n !== ",(" && (n = "", t = !1);
1282
+ continue;
1283
+ }
1284
+ s += c, n += c;
1285
+ }
1286
+ }
1287
+ if (!r)
1288
+ throw new p("Unable to normalize signature.");
1289
+ return s;
1290
+ }
1291
+ const ai = (e) => {
1292
+ const t = typeof e == "string" ? e : yn(e);
1293
+ return oi(t);
1294
+ };
1295
+ function Ke(e) {
1296
+ return ri(ai(e));
1297
+ }
1298
+ const ci = Ke;
1299
+ class Xe extends p {
1300
+ constructor({ address: t }) {
1301
+ super(`Address "${t}" is invalid.`, {
1302
+ metaMessages: [
1303
+ "- Address must be a hex value of 20 bytes (40 hex characters).",
1304
+ "- Address must match its checksum counterpart."
1305
+ ]
1306
+ }), Object.defineProperty(this, "name", {
1307
+ enumerable: !0,
1308
+ configurable: !0,
1309
+ writable: !0,
1310
+ value: "InvalidAddressError"
1311
+ });
1312
+ }
1313
+ }
1314
+ class Qe extends Map {
1315
+ constructor(t) {
1316
+ super(), Object.defineProperty(this, "maxSize", {
1317
+ enumerable: !0,
1318
+ configurable: !0,
1319
+ writable: !0,
1320
+ value: void 0
1321
+ }), this.maxSize = t;
1322
+ }
1323
+ set(t, n) {
1324
+ return super.set(t, n), this.maxSize && this.size > this.maxSize && this.delete(this.keys().next().value), this;
1325
+ }
1326
+ }
1327
+ const Q = /* @__PURE__ */ new Qe(8192);
1328
+ function ui(e, t) {
1329
+ if (Q.has(`${e}.${t}`))
1330
+ return Q.get(`${e}.${t}`);
1331
+ const n = e.substring(2).toLowerCase(), i = _(Fe(n), "bytes"), s = n.split("");
1332
+ for (let o = 0; o < 40; o += 2)
1333
+ i[o >> 1] >> 4 >= 8 && s[o] && (s[o] = s[o].toUpperCase()), (i[o >> 1] & 15) >= 8 && s[o + 1] && (s[o + 1] = s[o + 1].toUpperCase());
1334
+ const r = `0x${s.join("")}`;
1335
+ return Q.set(`${e}.${t}`, r), r;
1336
+ }
1337
+ const fi = /^0x[a-fA-F0-9]{40}$/, Y = /* @__PURE__ */ new Qe(8192);
1338
+ function j(e, t) {
1339
+ const { strict: n = !0 } = t ?? {}, i = `${e}.${n}`;
1340
+ if (Y.has(i))
1341
+ return Y.get(i);
1342
+ const s = fi.test(e) ? e.toLowerCase() === e ? !0 : n ? ui(e) === e : !0 : !1;
1343
+ return Y.set(i, s), s;
1344
+ }
1345
+ function N(e) {
1346
+ return typeof e[0] == "string" ? Ye(e) : di(e);
1347
+ }
1348
+ function di(e) {
1349
+ let t = 0;
1350
+ for (const s of e)
1351
+ t += s.length;
1352
+ const n = new Uint8Array(t);
1353
+ let i = 0;
1354
+ for (const s of e)
1355
+ n.set(s, i), i += s.length;
1356
+ return n;
1357
+ }
1358
+ function Ye(e) {
1359
+ return `0x${e.reduce((t, n) => t + n.replace("0x", ""), "")}`;
1360
+ }
1361
+ function Je(e, t, n, { strict: i } = {}) {
1362
+ return U(e, { strict: !1 }) ? hi(e, t, n, {
1363
+ strict: i
1364
+ }) : li(e, t, n, {
1365
+ strict: i
1366
+ });
1367
+ }
1368
+ function Ze(e, t) {
1369
+ if (typeof t == "number" && t > 0 && t > E(e) - 1)
1370
+ throw new je({
1371
+ offset: t,
1372
+ position: "start",
1373
+ size: E(e)
1374
+ });
1375
+ }
1376
+ function xe(e, t, n) {
1377
+ if (typeof t == "number" && typeof n == "number" && E(e) !== n - t)
1378
+ throw new je({
1379
+ offset: n,
1380
+ position: "end",
1381
+ size: E(e)
1382
+ });
1383
+ }
1384
+ function li(e, t, n, { strict: i } = {}) {
1385
+ Ze(e, t);
1386
+ const s = e.slice(t, n);
1387
+ return i && xe(s, t, n), s;
1388
+ }
1389
+ function hi(e, t, n, { strict: i } = {}) {
1390
+ Ze(e, t);
1391
+ const s = `0x${e.replace("0x", "").slice((t ?? 0) * 2, (n ?? e.length) * 2)}`;
1392
+ return i && xe(s, t, n), s;
1393
+ }
1394
+ function ae(e, t) {
1395
+ if (e.length !== t.length)
1396
+ throw new Tn({
1397
+ expectedLength: e.length,
1398
+ givenLength: t.length
1399
+ });
1400
+ const n = gi({
1401
+ params: e,
1402
+ values: t
1403
+ }), i = ue(n);
1404
+ return i.length === 0 ? "0x" : i;
1405
+ }
1406
+ function gi({ params: e, values: t }) {
1407
+ const n = [];
1408
+ for (let i = 0; i < e.length; i++)
1409
+ n.push(ce({ param: e[i], value: t[i] }));
1410
+ return n;
1411
+ }
1412
+ function ce({ param: e, value: t }) {
1413
+ const n = _i(e.type);
1414
+ if (n) {
1415
+ const [i, s] = n;
1416
+ return pi(t, { length: i, param: { ...e, type: s } });
1417
+ }
1418
+ if (e.type === "tuple")
1419
+ return Ti(t, {
1420
+ param: e
1421
+ });
1422
+ if (e.type === "address")
1423
+ return yi(t);
1424
+ if (e.type === "bool")
1425
+ return mi(t);
1426
+ if (e.type.startsWith("uint") || e.type.startsWith("int")) {
1427
+ const i = e.type.startsWith("int");
1428
+ return Ei(t, { signed: i });
1429
+ }
1430
+ if (e.type.startsWith("bytes"))
1431
+ return bi(t, { param: e });
1432
+ if (e.type === "string")
1433
+ return Ai(t);
1434
+ throw new In(e.type, {
1435
+ docsPath: "/docs/contract/encodeAbiParameters"
1436
+ });
1437
+ }
1438
+ function ue(e) {
1439
+ let t = 0;
1440
+ for (let r = 0; r < e.length; r++) {
1441
+ const { dynamic: o, encoded: c } = e[r];
1442
+ o ? t += 32 : t += E(c);
1443
+ }
1444
+ const n = [], i = [];
1445
+ let s = 0;
1446
+ for (let r = 0; r < e.length; r++) {
1447
+ const { dynamic: o, encoded: c } = e[r];
1448
+ o ? (n.push(C(t + s, { size: 32 })), i.push(c), s += E(c)) : n.push(c);
1449
+ }
1450
+ return N([...n, ...i]);
1451
+ }
1452
+ function yi(e) {
1453
+ if (!j(e))
1454
+ throw new Xe({ address: e });
1455
+ return { dynamic: !1, encoded: O(e.toLowerCase()) };
1456
+ }
1457
+ function pi(e, { length: t, param: n }) {
1458
+ const i = t === null;
1459
+ if (!Array.isArray(e))
1460
+ throw new vn(e);
1461
+ if (!i && e.length !== t)
1462
+ throw new En({
1463
+ expectedLength: t,
1464
+ givenLength: e.length,
1465
+ type: `${n.type}[${t}]`
1466
+ });
1467
+ let s = !1;
1468
+ const r = [];
1469
+ for (let o = 0; o < e.length; o++) {
1470
+ const c = ce({ param: n, value: e[o] });
1471
+ c.dynamic && (s = !0), r.push(c);
1472
+ }
1473
+ if (i || s) {
1474
+ const o = ue(r);
1475
+ if (i) {
1476
+ const c = C(r.length, { size: 32 });
1477
+ return {
1478
+ dynamic: !0,
1479
+ encoded: r.length > 0 ? N([c, o]) : c
1480
+ };
1481
+ }
1482
+ if (s)
1483
+ return { dynamic: !0, encoded: o };
1484
+ }
1485
+ return {
1486
+ dynamic: !1,
1487
+ encoded: N(r.map(({ encoded: o }) => o))
1488
+ };
1489
+ }
1490
+ function bi(e, { param: t }) {
1491
+ const [, n] = t.type.split("bytes"), i = E(e);
1492
+ if (!n) {
1493
+ let s = e;
1494
+ return i % 32 !== 0 && (s = O(s, {
1495
+ dir: "right",
1496
+ size: Math.ceil((e.length - 2) / 2 / 32) * 32
1497
+ })), {
1498
+ dynamic: !0,
1499
+ encoded: N([O(C(i, { size: 32 })), s])
1500
+ };
1501
+ }
1502
+ if (i !== Number.parseInt(n))
1503
+ throw new An({
1504
+ expectedSize: Number.parseInt(n),
1505
+ value: e
1506
+ });
1507
+ return { dynamic: !1, encoded: O(e, { dir: "right" }) };
1508
+ }
1509
+ function mi(e) {
1510
+ if (typeof e != "boolean")
1511
+ throw new p(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);
1512
+ return { dynamic: !1, encoded: O(Ue(e)) };
1513
+ }
1514
+ function Ei(e, { signed: t }) {
1515
+ return {
1516
+ dynamic: !1,
1517
+ encoded: C(e, {
1518
+ size: 32,
1519
+ signed: t
1520
+ })
1521
+ };
1522
+ }
1523
+ function Ai(e) {
1524
+ const t = G(e), n = Math.ceil(E(t) / 32), i = [];
1525
+ for (let s = 0; s < n; s++)
1526
+ i.push(O(Je(t, s * 32, (s + 1) * 32), {
1527
+ dir: "right"
1528
+ }));
1529
+ return {
1530
+ dynamic: !0,
1531
+ encoded: N([
1532
+ O(C(E(t), { size: 32 })),
1533
+ ...i
1534
+ ])
1535
+ };
1536
+ }
1537
+ function Ti(e, { param: t }) {
1538
+ let n = !1;
1539
+ const i = [];
1540
+ for (let s = 0; s < t.components.length; s++) {
1541
+ const r = t.components[s], o = Array.isArray(e) ? s : r.name, c = ce({
1542
+ param: r,
1543
+ value: e[o]
1544
+ });
1545
+ i.push(c), c.dynamic && (n = !0);
1546
+ }
1547
+ return {
1548
+ dynamic: n,
1549
+ encoded: n ? ue(i) : N(i.map(({ encoded: s }) => s))
1550
+ };
1551
+ }
1552
+ function _i(e) {
1553
+ const t = e.match(/^(.*)\[(\d+)?\]$/);
1554
+ return t ? (
1555
+ // Return `null` if the array is dynamic.
1556
+ [t[2] ? Number(t[2]) : null, t[1]]
1557
+ ) : void 0;
1558
+ }
1559
+ const et = (e) => Je(Ke(e), 0, 4);
1560
+ function Si(e) {
1561
+ const { abi: t, args: n = [], name: i } = e, s = U(i, { strict: !1 }), r = t.filter((c) => s ? c.type === "function" ? et(c) === i : c.type === "event" ? ci(c) === i : !1 : "name" in c && c.name === i);
1562
+ if (r.length === 0)
1563
+ return;
1564
+ if (r.length === 1)
1565
+ return r[0];
1566
+ let o;
1567
+ for (const c of r) {
1568
+ if (!("inputs" in c))
1569
+ continue;
1570
+ if (!n || n.length === 0) {
1571
+ if (!c.inputs || c.inputs.length === 0)
1572
+ return c;
1573
+ continue;
1574
+ }
1575
+ if (!c.inputs || c.inputs.length === 0 || c.inputs.length !== n.length)
1576
+ continue;
1577
+ if (n.every((g, h) => {
1578
+ const y = "inputs" in c && c.inputs[h];
1579
+ return y ? ee(g, y) : !1;
1580
+ })) {
1581
+ if (o && "inputs" in o && o.inputs) {
1582
+ const g = tt(c.inputs, o.inputs, n);
1583
+ if (g)
1584
+ throw new _n({
1585
+ abiItem: c,
1586
+ type: g[0]
1587
+ }, {
1588
+ abiItem: o,
1589
+ type: g[1]
1590
+ });
1591
+ }
1592
+ o = c;
1593
+ }
1594
+ }
1595
+ return o || r[0];
1596
+ }
1597
+ function ee(e, t) {
1598
+ const n = typeof e, i = t.type;
1599
+ switch (i) {
1600
+ case "address":
1601
+ return j(e, { strict: !1 });
1602
+ case "bool":
1603
+ return n === "boolean";
1604
+ case "function":
1605
+ return n === "string";
1606
+ case "string":
1607
+ return n === "string";
1608
+ default:
1609
+ return i === "tuple" && "components" in t ? Object.values(t.components).every((s, r) => ee(Object.values(e)[r], 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(i) ? n === "number" || n === "bigint" : /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(i) ? n === "string" || e instanceof Uint8Array : /[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(i) ? Array.isArray(e) && e.every((s) => ee(s, {
1610
+ ...t,
1611
+ // Pop off `[]` or `[M]` from end of type
1612
+ type: i.replace(/(\[[0-9]{0,}\])$/, "")
1613
+ })) : !1;
1614
+ }
1615
+ }
1616
+ function tt(e, t, n) {
1617
+ for (const i in e) {
1618
+ const s = e[i], r = t[i];
1619
+ if (s.type === "tuple" && r.type === "tuple" && "components" in s && "components" in r)
1620
+ return tt(s.components, r.components, n[i]);
1621
+ const o = [s.type, r.type];
1622
+ if (o.includes("address") && o.includes("bytes20") ? !0 : o.includes("address") && o.includes("string") ? j(n[i], { strict: !1 }) : o.includes("address") && o.includes("bytes") ? j(n[i], { strict: !1 }) : !1)
1623
+ return o;
1624
+ }
1625
+ }
1626
+ const Ae = "/docs/contract/encodeFunctionData";
1627
+ function Ii(e) {
1628
+ const { abi: t, args: n, functionName: i } = e;
1629
+ let s = t[0];
1630
+ if (i) {
1631
+ const r = Si({
1632
+ abi: t,
1633
+ args: n,
1634
+ name: i
1635
+ });
1636
+ if (!r)
1637
+ throw new de(i, { docsPath: Ae });
1638
+ s = r;
1639
+ }
1640
+ if (s.type !== "function")
1641
+ throw new de(void 0, { docsPath: Ae });
1642
+ return {
1643
+ abi: [s],
1644
+ functionName: et(x(s))
1645
+ };
1646
+ }
1647
+ function Te(e) {
1648
+ const { args: t } = e, { abi: n, functionName: i } = (() => {
1649
+ var c;
1650
+ return e.abi.length === 1 && ((c = e.functionName) != null && c.startsWith("0x")) ? e : Ii(e);
1651
+ })(), s = n[0], r = i, o = "inputs" in s && s.inputs ? ae(s.inputs, t ?? []) : void 0;
1652
+ return Ye([r, o ?? "0x"]);
1653
+ }
1654
+ const vi = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/, wi = /^(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)?$/;
1655
+ function Oi(e) {
1656
+ const { domain: t = {}, message: n, primaryType: i } = e, s = {
1657
+ EIP712Domain: Mi({ domain: t }),
1658
+ ...e.types
1659
+ };
1660
+ Di({
1661
+ domain: t,
1662
+ message: n,
1663
+ primaryType: i,
1664
+ types: s
1665
+ });
1666
+ const r = ["0x1901"];
1667
+ return t && r.push(Ni({
1668
+ domain: t,
1669
+ types: s
1670
+ })), i !== "EIP712Domain" && r.push(nt({
1671
+ data: n,
1672
+ primaryType: i,
1673
+ types: s
1674
+ })), _(N(r));
1675
+ }
1676
+ function Ni({ domain: e, types: t }) {
1677
+ return nt({
1678
+ data: e,
1679
+ primaryType: "EIP712Domain",
1680
+ types: t
1681
+ });
1682
+ }
1683
+ function nt({ data: e, primaryType: t, types: n }) {
1684
+ const i = it({
1685
+ data: e,
1686
+ primaryType: t,
1687
+ types: n
1688
+ });
1689
+ return _(i);
1690
+ }
1691
+ function it({ data: e, primaryType: t, types: n }) {
1692
+ const i = [{ type: "bytes32" }], s = [Ci({ primaryType: t, types: n })];
1693
+ for (const r of n[t]) {
1694
+ const [o, c] = rt({
1695
+ types: n,
1696
+ name: r.name,
1697
+ type: r.type,
1698
+ value: e[r.name]
1699
+ });
1700
+ i.push(o), s.push(c);
1701
+ }
1702
+ return ae(i, s);
1703
+ }
1704
+ function Ci({ primaryType: e, types: t }) {
1705
+ const n = ie(Pi({ primaryType: e, types: t }));
1706
+ return _(n);
1707
+ }
1708
+ function Pi({ primaryType: e, types: t }) {
1709
+ let n = "";
1710
+ const i = st({ primaryType: e, types: t });
1711
+ i.delete(e);
1712
+ const s = [e, ...Array.from(i).sort()];
1713
+ for (const r of s)
1714
+ n += `${r}(${t[r].map(({ name: o, type: c }) => `${c} ${o}`).join(",")})`;
1715
+ return n;
1716
+ }
1717
+ function st({ primaryType: e, types: t }, n = /* @__PURE__ */ new Set()) {
1718
+ const i = e.match(/^\w*/u), s = i == null ? void 0 : i[0];
1719
+ if (n.has(s) || t[s] === void 0)
1720
+ return n;
1721
+ n.add(s);
1722
+ for (const r of t[s])
1723
+ st({ primaryType: r.type, types: t }, n);
1724
+ return n;
1725
+ }
1726
+ function rt({ types: e, name: t, type: n, value: i }) {
1727
+ if (e[n] !== void 0)
1728
+ return [
1729
+ { type: "bytes32" },
1730
+ _(it({ data: i, primaryType: n, types: e }))
1731
+ ];
1732
+ if (n === "bytes")
1733
+ return i = `0x${(i.length % 2 ? "0" : "") + i.slice(2)}`, [{ type: "bytes32" }, _(i)];
1734
+ if (n === "string")
1735
+ return [{ type: "bytes32" }, _(ie(i))];
1736
+ if (n.lastIndexOf("]") === n.length - 1) {
1737
+ const s = n.slice(0, n.lastIndexOf("[")), r = i.map((o) => rt({
1738
+ name: t,
1739
+ type: s,
1740
+ types: e,
1741
+ value: o
1742
+ }));
1743
+ return [
1744
+ { type: "bytes32" },
1745
+ _(ae(r.map(([o]) => o), r.map(([, o]) => o)))
1746
+ ];
1747
+ }
1748
+ return [{ type: n }, i];
1749
+ }
1750
+ function Di(e) {
1751
+ const { domain: t, message: n, primaryType: i, types: s } = e, r = (o, c) => {
1752
+ for (const l of o) {
1753
+ const { name: g, type: h } = l, y = c[g], M = h.match(wi);
1754
+ if (M && (typeof y == "number" || typeof y == "bigint")) {
1755
+ const [K, P, X] = M;
1756
+ C(y, {
1757
+ signed: P === "int",
1758
+ size: Number.parseInt(X) / 8
1759
+ });
1760
+ }
1761
+ if (h === "address" && typeof y == "string" && !j(y))
1762
+ throw new Xe({ address: y });
1763
+ const S = h.match(vi);
1764
+ if (S) {
1765
+ const [K, P] = S;
1766
+ if (P && E(y) !== Number.parseInt(P))
1767
+ throw new Sn({
1768
+ expectedSize: Number.parseInt(P),
1769
+ givenSize: E(y)
1770
+ });
1771
+ }
1772
+ const z = s[h];
1773
+ z && r(z, y);
1774
+ }
1775
+ };
1776
+ s.EIP712Domain && t && r(s.EIP712Domain, t), i !== "EIP712Domain" && r(s[i], n);
1777
+ }
1778
+ function Mi({ domain: e }) {
1779
+ return [
1780
+ typeof (e == null ? void 0 : e.name) == "string" && { name: "name", type: "string" },
1781
+ (e == null ? void 0 : e.version) && { name: "version", type: "string" },
1782
+ typeof (e == null ? void 0 : e.chainId) == "number" && {
1783
+ name: "chainId",
1784
+ type: "uint256"
1785
+ },
1786
+ (e == null ? void 0 : e.verifyingContract) && {
1787
+ name: "verifyingContract",
1788
+ type: "address"
1789
+ },
1790
+ (e == null ? void 0 : e.salt) && { name: "salt", type: "bytes32" }
1791
+ ].filter(Boolean);
1792
+ }
1793
+ const Ri = `Ethereum Signed Message:
1794
+ `;
1795
+ function $i(e) {
1796
+ const t = typeof e == "string" ? G(e) : typeof e.raw == "string" ? e.raw : se(e.raw), n = G(`${Ri}${E(t)}`);
1797
+ return N([n, t]);
1798
+ }
1799
+ function Li(e, t) {
1800
+ return _($i(e), t);
1801
+ }
1802
+ const Bi = "0x1626ba7e", ji = "0x20c13b0b", te = 4001;
1803
+ class H extends Error {
1804
+ constructor(t, n, i) {
1805
+ super(t), this.code = n, this.data = i, Object.setPrototypeOf(this, H.prototype);
1806
+ }
1807
+ }
1808
+ class ot {
1809
+ constructor(t) {
1810
+ this.communicator = t;
1811
+ }
1812
+ async getPermissions() {
1813
+ return (await this.communicator.send(b.wallet_getPermissions, void 0)).data;
1814
+ }
1815
+ async requestPermissions(t) {
1816
+ if (!this.isPermissionRequestValid(t))
1817
+ throw new H("Permissions request is invalid", te);
1818
+ try {
1819
+ return (await this.communicator.send(b.wallet_requestPermissions, t)).data;
1820
+ } catch {
1821
+ throw new H("Permissions rejected", te);
1822
+ }
1823
+ }
1824
+ isPermissionRequestValid(t) {
1825
+ return t.every((n) => typeof n == "object" ? Object.keys(n).every((i) => !!Object.values(J).includes(i)) : !1);
1826
+ }
1827
+ }
1828
+ const _e = (e, t) => t.some((n) => n.parentCapability === e), Hi = () => (e, t, n) => {
1829
+ const i = n.value;
1830
+ return n.value = async function() {
1831
+ const s = new ot(this.communicator);
1832
+ let r = await s.getPermissions();
1833
+ if (_e(t, r) || (r = await s.requestPermissions([{ [t]: {} }])), !_e(t, r))
1834
+ throw new H("Permissions rejected", te);
1835
+ return i.apply(this);
1836
+ }, n;
1837
+ };
1838
+ var Ui = function(e, t, n, i) {
1839
+ var s = arguments.length, r = s < 3 ? t : i === null ? i = Object.getOwnPropertyDescriptor(t, n) : i, o;
1840
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(e, t, n, i);
1841
+ else for (var c = e.length - 1; c >= 0; c--) (o = e[c]) && (r = (s < 3 ? o(r) : s > 3 ? o(t, n, r) : o(t, n)) || r);
1842
+ return s > 3 && r && Object.defineProperty(t, n, r), r;
1843
+ };
1844
+ class at {
1845
+ constructor(t) {
1846
+ this.communicator = t;
1847
+ }
1848
+ async getChainInfo() {
1849
+ return (await this.communicator.send(b.getChainInfo, void 0)).data;
1850
+ }
1851
+ async getInfo() {
1852
+ return (await this.communicator.send(b.getSafeInfo, void 0)).data;
1853
+ }
1854
+ // There is a possibility that this method will change because we may add pagination to the endpoint
1855
+ async experimental_getBalances({ currency: t = "usd" } = {}) {
1856
+ return (await this.communicator.send(b.getSafeBalances, {
1857
+ currency: t
1858
+ })).data;
1859
+ }
1860
+ async check1271Signature(t, n = "0x") {
1861
+ const i = await this.getInfo(), s = Te({
1862
+ abi: [
1863
+ {
1864
+ constant: !1,
1865
+ inputs: [
1866
+ {
1867
+ name: "_dataHash",
1868
+ type: "bytes32"
1869
+ },
1870
+ {
1871
+ name: "_signature",
1872
+ type: "bytes"
1873
+ }
1874
+ ],
1875
+ name: "isValidSignature",
1876
+ outputs: [
1877
+ {
1878
+ name: "",
1879
+ type: "bytes4"
1880
+ }
1881
+ ],
1882
+ payable: !1,
1883
+ stateMutability: "nonpayable",
1884
+ type: "function"
1885
+ }
1886
+ ],
1887
+ functionName: "isValidSignature",
1888
+ args: [t, n]
1889
+ }), r = {
1890
+ call: m.eth_call,
1891
+ params: [
1892
+ {
1893
+ to: i.safeAddress,
1894
+ data: s
1895
+ },
1896
+ "latest"
1897
+ ]
1898
+ };
1899
+ try {
1900
+ return (await this.communicator.send(b.rpcCall, r)).data.slice(0, 10).toLowerCase() === Bi;
1901
+ } catch {
1902
+ return !1;
1903
+ }
1904
+ }
1905
+ async check1271SignatureBytes(t, n = "0x") {
1906
+ const i = await this.getInfo(), s = Te({
1907
+ abi: [
1908
+ {
1909
+ constant: !1,
1910
+ inputs: [
1911
+ {
1912
+ name: "_data",
1913
+ type: "bytes"
1914
+ },
1915
+ {
1916
+ name: "_signature",
1917
+ type: "bytes"
1918
+ }
1919
+ ],
1920
+ name: "isValidSignature",
1921
+ outputs: [
1922
+ {
1923
+ name: "",
1924
+ type: "bytes4"
1925
+ }
1926
+ ],
1927
+ payable: !1,
1928
+ stateMutability: "nonpayable",
1929
+ type: "function"
1930
+ }
1931
+ ],
1932
+ functionName: "isValidSignature",
1933
+ args: [t, n]
1934
+ }), r = {
1935
+ call: m.eth_call,
1936
+ params: [
1937
+ {
1938
+ to: i.safeAddress,
1939
+ data: s
1940
+ },
1941
+ "latest"
1942
+ ]
1943
+ };
1944
+ try {
1945
+ return (await this.communicator.send(b.rpcCall, r)).data.slice(0, 10).toLowerCase() === ji;
1946
+ } catch {
1947
+ return !1;
1948
+ }
1949
+ }
1950
+ calculateMessageHash(t) {
1951
+ return Li(t);
1952
+ }
1953
+ calculateTypedMessageHash(t) {
1954
+ const n = typeof t.domain.chainId == "object" ? t.domain.chainId.toNumber() : Number(t.domain.chainId);
1955
+ let i = t.primaryType;
1956
+ if (!i) {
1957
+ const s = Object.values(t.types), r = Object.keys(t.types).filter((o) => s.every((c) => c.every(({ type: l }) => l.replace("[", "").replace("]", "") !== o)));
1958
+ if (r.length === 0 || r.length > 1)
1959
+ throw new Error("Please specify primaryType");
1960
+ i = r[0];
1961
+ }
1962
+ return Oi({
1963
+ message: t.message,
1964
+ domain: {
1965
+ ...t.domain,
1966
+ chainId: n,
1967
+ verifyingContract: t.domain.verifyingContract,
1968
+ salt: t.domain.salt
1969
+ },
1970
+ types: t.types,
1971
+ primaryType: i
1972
+ });
1973
+ }
1974
+ async getOffChainSignature(t) {
1975
+ return (await this.communicator.send(b.getOffChainSignature, t)).data;
1976
+ }
1977
+ async isMessageSigned(t, n = "0x") {
1978
+ let i;
1979
+ if (typeof t == "string" && (i = async () => {
1980
+ const s = this.calculateMessageHash(t);
1981
+ return await this.isMessageHashSigned(s, n);
1982
+ }), Se(t) && (i = async () => {
1983
+ const s = this.calculateTypedMessageHash(t);
1984
+ return await this.isMessageHashSigned(s, n);
1985
+ }), i)
1986
+ return await i();
1987
+ throw new Error("Invalid message type");
1988
+ }
1989
+ async isMessageHashSigned(t, n = "0x") {
1990
+ const i = [this.check1271Signature.bind(this), this.check1271SignatureBytes.bind(this)];
1991
+ for (const s of i)
1992
+ if (await s(t, n))
1993
+ return !0;
1994
+ return !1;
1995
+ }
1996
+ async getEnvironmentInfo() {
1997
+ return (await this.communicator.send(b.getEnvironmentInfo, void 0)).data;
1998
+ }
1999
+ async requestAddressBook() {
2000
+ return (await this.communicator.send(b.requestAddressBook, void 0)).data;
2001
+ }
2002
+ }
2003
+ Ui([
2004
+ Hi()
2005
+ ], at.prototype, "requestAddressBook", null);
2006
+ class ki {
2007
+ constructor(t = {}) {
2008
+ const { allowedDomains: n = null, debug: i = !1 } = t;
2009
+ this.communicator = new xt(n, i), this.eth = new hn(this.communicator), this.txs = new ln(this.communicator), this.safe = new at(this.communicator), this.wallet = new ot(this.communicator);
2010
+ }
2011
+ }
2012
+ const Fi = ki;
2013
+ export {
2014
+ V as MessageFormatter,
2015
+ b as Methods,
2016
+ m as RPC_CALLS,
2017
+ J as RestrictedMethods,
2018
+ Fi as default,
2019
+ Qt as getSDKVersion,
2020
+ Se as isObjectEIP712TypedData
2021
+ };