@argent/x-shared 1.34.6 → 1.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/bips-CP71ZN9a.js +1 -0
  2. package/dist/bips-zBtnMbia.mjs +114 -0
  3. package/dist/chains/starknet/address.d.ts +2 -2
  4. package/dist/errors/swap.d.ts +12 -0
  5. package/dist/features/swap/index.d.ts +3 -0
  6. package/dist/features/swap/models/index.d.ts +3 -0
  7. package/dist/features/swap/models/order.model.d.ts +48 -0
  8. package/dist/features/swap/models/quote.model.d.ts +82 -0
  9. package/dist/features/swap/models/trade.model.d.ts +186 -0
  10. package/dist/features/swap/services/implementation.d.ts +14 -0
  11. package/dist/features/swap/services/index.d.ts +2 -0
  12. package/dist/features/swap/services/interface.d.ts +8 -0
  13. package/dist/features/swap/services/order.mock.d.ts +7 -0
  14. package/dist/features/swap/services/quote.mock.d.ts +29 -0
  15. package/dist/features/swap/tests/token.mock.d.ts +2 -0
  16. package/dist/features/swap/tests/trade.mock.d.ts +2 -0
  17. package/dist/features/swap/tests/walletAccount.mock.d.ts +43 -0
  18. package/dist/features/swap/utils/index.d.ts +2 -0
  19. package/dist/features/swap/utils/slippage.d.ts +16 -0
  20. package/dist/features/swap/utils/totalFee.d.ts +5 -0
  21. package/dist/index.js +2 -2
  22. package/dist/index.mjs +1355 -1425
  23. package/dist/simulation.js +1 -1
  24. package/dist/simulation.mjs +81 -80
  25. package/dist/swap.d.ts +2 -0
  26. package/dist/swap.js +1 -0
  27. package/dist/swap.mjs +183 -0
  28. package/dist/transactionVersion-CACUj2ch.mjs +793 -0
  29. package/dist/transactionVersion-CaRQ5Df4.js +1 -0
  30. package/dist/utils/bips.d.ts +7 -0
  31. package/dist/utils/index.d.ts +1 -0
  32. package/dist/webToken.model-Cl4dvcmj.mjs +1881 -0
  33. package/dist/webToken.model-Dsd8Rd3e.js +1 -0
  34. package/package.json +8 -1
  35. package/dist/transactionVersion-CKz-zi84.js +0 -1
  36. package/dist/transactionVersion-cwkr7wat.mjs +0 -2665
@@ -0,0 +1,793 @@
1
+ import { z as t } from "zod";
2
+ import { a7 as E, ar as L, t as u, a8 as V, al as rt, p as st, c as w, v as D, q as r } from "./webToken.model-Cl4dvcmj.mjs";
3
+ import { uint256 as S, num as d, hash as P, constants as T } from "starknet";
4
+ import { isString as ct, isEmpty as lt } from "lodash-es";
5
+ import "@scure/base";
6
+ import "react";
7
+ import "object-hash";
8
+ import "swr";
9
+ const me = "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7", de = "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d", ge = "0x1a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003", fe = "0x036078334509b514626504edc9fb252328d1a240e4e948bef8d0c08dff45927f", he = "0x737ee2f87ce571a58c6c8da558ec18a07ceb64a6172d5ec46171fbc80077a48", be = "0x6e150953b26271a740bf2b6e9bca17cc52c68d765f761295de51ceb8526ee72", ye = "0x4d07e40e93398ed3c76981e72dd1fd22557a78ce36c0515f679e27f0bb5bc5f";
10
+ var ut = {};
11
+ function l(e, n) {
12
+ typeof n == "boolean" && (n = { forever: n }), this._originalTimeouts = JSON.parse(JSON.stringify(e)), this._timeouts = e, this._options = n || {}, this._maxRetryTime = n && n.maxRetryTime || 1 / 0, this._fn = null, this._errors = [], this._attempts = 1, this._operationTimeout = null, this._operationTimeoutCb = null, this._timeout = null, this._operationStart = null, this._timer = null, this._options.forever && (this._cachedTimeouts = this._timeouts.slice(0));
13
+ }
14
+ var pt = l;
15
+ l.prototype.reset = function() {
16
+ this._attempts = 1, this._timeouts = this._originalTimeouts.slice(0);
17
+ };
18
+ l.prototype.stop = function() {
19
+ this._timeout && clearTimeout(this._timeout), this._timer && clearTimeout(this._timer), this._timeouts = [], this._cachedTimeouts = null;
20
+ };
21
+ l.prototype.retry = function(e) {
22
+ if (this._timeout && clearTimeout(this._timeout), !e)
23
+ return !1;
24
+ var n = (/* @__PURE__ */ new Date()).getTime();
25
+ if (e && n - this._operationStart >= this._maxRetryTime)
26
+ return this._errors.push(e), this._errors.unshift(new Error("RetryOperation timeout occurred")), !1;
27
+ this._errors.push(e);
28
+ var a = this._timeouts.shift();
29
+ if (a === void 0)
30
+ if (this._cachedTimeouts)
31
+ this._errors.splice(0, this._errors.length - 1), a = this._cachedTimeouts.slice(-1);
32
+ else
33
+ return !1;
34
+ var o = this;
35
+ return this._timer = setTimeout(function() {
36
+ o._attempts++, o._operationTimeoutCb && (o._timeout = setTimeout(function() {
37
+ o._operationTimeoutCb(o._attempts);
38
+ }, o._operationTimeout), o._options.unref && o._timeout.unref()), o._fn(o._attempts);
39
+ }, a), this._options.unref && this._timer.unref(), !0;
40
+ };
41
+ l.prototype.attempt = function(e, n) {
42
+ this._fn = e, n && (n.timeout && (this._operationTimeout = n.timeout), n.cb && (this._operationTimeoutCb = n.cb));
43
+ var a = this;
44
+ this._operationTimeoutCb && (this._timeout = setTimeout(function() {
45
+ a._operationTimeoutCb();
46
+ }, a._operationTimeout)), this._operationStart = (/* @__PURE__ */ new Date()).getTime(), this._fn(this._attempts);
47
+ };
48
+ l.prototype.try = function(e) {
49
+ this.attempt(e);
50
+ };
51
+ l.prototype.start = function(e) {
52
+ this.attempt(e);
53
+ };
54
+ l.prototype.start = l.prototype.try;
55
+ l.prototype.errors = function() {
56
+ return this._errors;
57
+ };
58
+ l.prototype.attempts = function() {
59
+ return this._attempts;
60
+ };
61
+ l.prototype.mainError = function() {
62
+ if (this._errors.length === 0)
63
+ return null;
64
+ for (var e = {}, n = null, a = 0, o = 0; o < this._errors.length; o++) {
65
+ var s = this._errors[o], c = s.message, i = (e[c] || 0) + 1;
66
+ e[c] = i, i >= a && (n = s, a = i);
67
+ }
68
+ return n;
69
+ };
70
+ (function(e) {
71
+ var n = pt;
72
+ e.operation = function(a) {
73
+ var o = e.timeouts(a);
74
+ return new n(o, {
75
+ forever: a && (a.forever || a.retries === 1 / 0),
76
+ unref: a && a.unref,
77
+ maxRetryTime: a && a.maxRetryTime
78
+ });
79
+ }, e.timeouts = function(a) {
80
+ if (a instanceof Array)
81
+ return [].concat(a);
82
+ var o = {
83
+ retries: 10,
84
+ factor: 2,
85
+ minTimeout: 1 * 1e3,
86
+ maxTimeout: 1 / 0,
87
+ randomize: !1
88
+ };
89
+ for (var s in a)
90
+ o[s] = a[s];
91
+ if (o.minTimeout > o.maxTimeout)
92
+ throw new Error("minTimeout is greater than maxTimeout");
93
+ for (var c = [], i = 0; i < o.retries; i++)
94
+ c.push(this.createTimeout(i, o));
95
+ return a && a.forever && !c.length && c.push(this.createTimeout(i, o)), c.sort(function(p, h) {
96
+ return p - h;
97
+ }), c;
98
+ }, e.createTimeout = function(a, o) {
99
+ var s = o.randomize ? Math.random() + 1 : 1, c = Math.round(s * Math.max(o.minTimeout, 1) * Math.pow(o.factor, a));
100
+ return c = Math.min(c, o.maxTimeout), c;
101
+ }, e.wrap = function(a, o, s) {
102
+ if (o instanceof Array && (s = o, o = null), !s) {
103
+ s = [];
104
+ for (var c in a)
105
+ typeof a[c] == "function" && s.push(c);
106
+ }
107
+ for (var i = 0; i < s.length; i++) {
108
+ var p = s[i], h = a[p];
109
+ a[p] = (function(ot) {
110
+ var b = e.operation(o), y = Array.prototype.slice.call(arguments, 1), it = y.pop();
111
+ y.push(function(j) {
112
+ b.retry(j) || (j && (arguments[0] = b.mainError()), it.apply(this, arguments));
113
+ }), b.attempt(function() {
114
+ ot.apply(a, y);
115
+ });
116
+ }).bind(a, h), a[p].options = o;
117
+ }
118
+ };
119
+ })(ut);
120
+ var A;
121
+ (function(e) {
122
+ e.NO_TOKEN_API_URL = "NO_TOKEN_API_URL is not defined", e.NO_TOKEN_PRICE_API_URL = "NO_TOKEN_PRICE_API_URL is not defined", e.TOKENS_DEFI_DECOMPOSITION_URL = "TOKENS_DEFI_DECOMPOSITION_URL is not defined", e.TOKENS_AIRDROPS_API_URL = "TOKENS_AIRDROPS_API_URL is not defined", e.TOKEN_PARSING_ERROR = "Unable to parse token data response", e.TOKEN_PRICE_PARSING_ERROR = "Unable to parse token price response", e.TOKEN_DEFI_DECOMPOSITION_PARSING_ERROR = "Unable to parse token defi decomposition response", e.TOKEN_PRICE_NOT_FOUND = "Token price not found", e.TOKEN_NOT_FOUND = "Token not found", e.TOKEN_DETAILS_NOT_FOUND = "Token details not found", e.FEE_TOKEN_NOT_FOUND = "Fee token not found", e.UNABLE_TO_CALCULATE_CURRENCY_VALUE = "Unable to calculate currency value", e.UNSAFE_DECIMALS = "Unsafe decimals in token";
123
+ })(A || (A = {}));
124
+ class _e extends E {
125
+ constructor(n) {
126
+ super(n, A), this.name = "TokenError";
127
+ }
128
+ }
129
+ const U = L.extend({
130
+ accruedFees: t.string(),
131
+ currentPrice: t.string(),
132
+ maxPrice: t.string(),
133
+ minPrice: t.string(),
134
+ principal: t.string()
135
+ }), B = t.object({
136
+ address: u.optional(),
137
+ currencyValue: t.string().default("0")
138
+ }), H = B.extend({
139
+ poolFeePercentage: t.string(),
140
+ tickSpacingPercentage: t.string().optional(),
141
+ tokenId: t.string().optional(),
142
+ unitCurrencyValueToken0: t.string().optional(),
143
+ unitCurrencyValueToken1: t.string().optional(),
144
+ token0: U,
145
+ token1: U
146
+ }), Se = t.array(H), Te = t.object({
147
+ name: t.string().optional(),
148
+ healthRatio: t.string().optional(),
149
+ accountAddress: u.optional()
150
+ }), M = B.extend({
151
+ totalBalances: t.record(t.string()),
152
+ collateral: t.boolean(),
153
+ debt: t.boolean(),
154
+ lending: t.boolean(),
155
+ apy: t.string().optional(),
156
+ group: t.string().optional(),
157
+ unitCurrencyValue: t.string().optional(),
158
+ positionToken: V.or(t.undefined()),
159
+ token: L.optional(),
160
+ accountAddress: u.optional(),
161
+ accountAddressGroup: t.string().optional()
162
+ }), Ae = t.array(M), mt = H.or(M), dt = t.record(t.object({
163
+ name: t.string().optional(),
164
+ healthRatio: t.string().optional(),
165
+ accountAddress: u.optional()
166
+ })), gt = t.object({
167
+ type: rt,
168
+ manageUrl: t.string().url().optional(),
169
+ name: t.string(),
170
+ positions: t.array(mt),
171
+ // other types will be added when available from be
172
+ positionsTotalValue: t.string(),
173
+ brandColor: t.string().optional(),
174
+ groups: dt.optional(),
175
+ accountAddress: u
176
+ }), ft = t.array(gt), ve = t.object({
177
+ dappId: t.string(),
178
+ products: ft
179
+ }), ht = t.object({
180
+ name: t.string().optional(),
181
+ tokenAddress: u,
182
+ token: V.optional(),
183
+ amount: t.string().optional(),
184
+ claimUrl: t.string().optional(),
185
+ claimStart: t.number(),
186
+ claimEnd: t.number().optional()
187
+ }), Ie = t.array(ht), bt = (e, n = 18) => st(e.replace(",", "."), Number(n)), yt = t.string().trim().refine((e) => e !== "", {
188
+ message: "Amount is required"
189
+ }).refine((e) => {
190
+ try {
191
+ const n = bt(e).value;
192
+ if (n < 0n)
193
+ throw new Error("Amount must be positive");
194
+ if (n === 0n)
195
+ throw new Error("Amount can not be zero");
196
+ if (n > S.UINT_256_MAX)
197
+ throw new Error("Amount is too big");
198
+ } catch {
199
+ throw new Error("Amount should be a number");
200
+ }
201
+ return !0;
202
+ }, { message: "Invalid amount" }), Ee = (e) => !!yt.parse(e), _t = t.object({
203
+ data: t.object({
204
+ code: t.string().optional(),
205
+ // "STARKNAME_NOT_FOUND",
206
+ name: t.string().optional(),
207
+ // "AddressError"
208
+ message: t.string()
209
+ // "foo.stark not found"
210
+ })
211
+ }), Ne = (e) => {
212
+ const n = _t.safeParse(e);
213
+ if (n.success)
214
+ return n.data.data.message;
215
+ }, St = 3, K = process.env.FEE_OVERHEAD ? parseFloat(process.env.FEE_OVERHEAD) : St, Tt = 1.5, f = 10, At = ({ estimatedFee: e, overheadMultiplier: n = K }) => {
216
+ const o = d.toBigInt(e) * BigInt(n * f) / BigInt(f);
217
+ return d.toHex(o);
218
+ }, ke = ({ suggestedMaxFee: e, overheadMultiplier: n = K, starknetJsOverheadMultiplier: a = Tt }) => {
219
+ const s = d.toBigInt(e) * BigInt(f) / BigInt(a * f);
220
+ return At({ estimatedFee: s, overheadMultiplier: n });
221
+ };
222
+ var v;
223
+ (function(e) {
224
+ e.SIMULATE_AND_REVIEW_FAILED = "Missing simulation";
225
+ })(v || (v = {}));
226
+ class je extends E {
227
+ constructor(n) {
228
+ super(n, v), this.name = "EstimateError";
229
+ }
230
+ }
231
+ const we = t.object({
232
+ type: t.enum(["DECLARE", "DEPLOY", "DEPLOY_ACCOUNT", "INVOKE"]).default("INVOKE"),
233
+ calls: t.array(w).or(w).optional(),
234
+ calldata: t.array(t.string()).optional(),
235
+ classHash: D.optional(),
236
+ salt: D.optional(),
237
+ signature: t.array(t.string()).optional()
238
+ }), vt = t.object({
239
+ amount: t.bigint(),
240
+ pricePerUnit: t.bigint()
241
+ }).or(t.object({ maxFee: t.bigint() })), O = t.object({
242
+ feeTokenAddress: u,
243
+ amount: t.bigint(),
244
+ pricePerUnit: t.bigint(),
245
+ max: vt.optional(),
246
+ dataGasConsumed: t.bigint().optional(),
247
+ dataGasPrice: t.bigint().optional()
248
+ }), It = t.object({
249
+ deployment: O.optional(),
250
+ transactions: O
251
+ }), Et = t.union([
252
+ t.literal("critical"),
253
+ t.literal("high"),
254
+ t.literal("caution"),
255
+ t.literal("info")
256
+ ]), Nt = t.string(), kt = t.object({
257
+ name: t.string(),
258
+ url: t.string(),
259
+ position: t.number()
260
+ }), _ = t.object({
261
+ address: t.string(),
262
+ name: t.string(),
263
+ symbol: t.string().optional(),
264
+ decimals: t.number().optional(),
265
+ unknown: t.boolean(),
266
+ iconUrl: t.string().optional(),
267
+ type: t.string()
268
+ }), C = t.discriminatedUnion("type", [
269
+ t.object({
270
+ type: t.literal("amount"),
271
+ label: t.string(),
272
+ token: _,
273
+ amount: t.string(),
274
+ usd: t.string(),
275
+ editable: t.boolean()
276
+ }),
277
+ t.object({
278
+ type: t.literal("address"),
279
+ label: t.string(),
280
+ address: t.string(),
281
+ addressName: t.string().optional(),
282
+ // tbd whether it's isVerified or verified
283
+ verified: t.boolean().optional()
284
+ }),
285
+ t.object({
286
+ type: t.literal("timestamp"),
287
+ label: t.string(),
288
+ value: t.string()
289
+ }),
290
+ t.object({
291
+ type: t.literal("token_address"),
292
+ label: t.string(),
293
+ token: _
294
+ }),
295
+ t.object({
296
+ type: t.literal("calldata"),
297
+ label: t.string(),
298
+ entrypoint: t.string(),
299
+ calldata: t.array(t.string())
300
+ }),
301
+ t.object({
302
+ type: t.literal("text"),
303
+ label: t.string(),
304
+ text: t.string()
305
+ }),
306
+ t.object({
307
+ type: t.literal("nft"),
308
+ label: t.string(),
309
+ token: _
310
+ })
311
+ ]), z = t.object({
312
+ name: t.string(),
313
+ properties: t.array(C),
314
+ defaultProperties: t.array(C).optional()
315
+ }), jt = t.union([
316
+ t.literal("verified"),
317
+ t.literal("neutral"),
318
+ t.literal("partial"),
319
+ t.literal("warn")
320
+ ]), wt = t.object({
321
+ unknown_token: t.unknown().optional(),
322
+ date_of_addition: t.string().optional(),
323
+ contract_address: u.optional(),
324
+ reason: t.string().optional(),
325
+ value: t.string().or(t.number()).optional()
326
+ }), W = t.object({
327
+ reason: Nt,
328
+ details: wt.optional(),
329
+ severity: Et
330
+ }), Dt = t.object({
331
+ assessment: jt,
332
+ warnings: t.array(W).optional(),
333
+ assessmentReasons: t.array(t.string()).optional(),
334
+ assessmentDetails: t.object({
335
+ contract_address: t.string()
336
+ }).optional(),
337
+ action: z
338
+ }), q = t.object({
339
+ name: t.string(),
340
+ description: t.string(),
341
+ logoUrl: t.string(),
342
+ iconUrl: t.string(),
343
+ argentVerified: t.boolean(),
344
+ links: t.array(kt)
345
+ }), G = t.object({
346
+ assessment: t.union([
347
+ t.literal("verified"),
348
+ t.literal("neutral"),
349
+ t.literal("partial"),
350
+ t.literal("warn")
351
+ ]),
352
+ warnings: t.array(W).optional(),
353
+ assessmentDetails: t.object({
354
+ contract_address: t.string()
355
+ }).optional(),
356
+ targetedDapp: q.optional(),
357
+ reviews: t.array(Dt)
358
+ }).optional(), X = t.object({
359
+ banner: t.string().nullable().optional(),
360
+ preview: t.string().nullable().optional(),
361
+ full: t.string().nullable().optional(),
362
+ original: t.string().nullable().optional()
363
+ }), Pt = t.object({
364
+ twitter: t.string().optional(),
365
+ external: t.string().optional(),
366
+ discord: t.string().optional()
367
+ }), N = t.object({
368
+ address: r,
369
+ decimals: t.number().optional(),
370
+ symbol: t.string().optional(),
371
+ name: t.string(),
372
+ description: t.string().optional(),
373
+ type: t.string().optional(),
374
+ usdValue: t.string().optional(),
375
+ iconUrl: t.string().optional(),
376
+ unknown: t.boolean().optional(),
377
+ imageUrls: X.optional(),
378
+ links: Pt.optional()
379
+ }), Ut = t.object({
380
+ tokenAddress: r,
381
+ owner: r,
382
+ spender: r,
383
+ value: t.string().optional(),
384
+ approvalForAll: t.boolean(),
385
+ details: N.optional()
386
+ }), Ot = t.object({
387
+ tokenAddress: r,
388
+ from: r,
389
+ to: r,
390
+ tokenId: t.string().optional(),
391
+ value: t.string().optional(),
392
+ details: N.optional()
393
+ }), m = t.union([t.string(), t.number(), t.bigint()]).transform((e) => parseInt(e.toString(), 10)), x = {
394
+ overallFee: m,
395
+ gasPrice: m,
396
+ gasUsage: m,
397
+ dataGasPrice: m.optional(),
398
+ dataGasConsumed: m.optional()
399
+ }, Ct = t.object({
400
+ ...x,
401
+ unit: t.string().transform((e) => e.toUpperCase()).pipe(t.literal("WEI")),
402
+ maxFee: m
403
+ }).or(t.object({
404
+ ...x,
405
+ unit: t.string().transform((e) => e.toUpperCase()).pipe(t.literal("FRI")),
406
+ maxAmount: m,
407
+ maxPricePerUnit: m
408
+ })), xt = t.object({
409
+ type: t.string(),
410
+ label: t.string(),
411
+ tokenId: t.string().optional(),
412
+ value: t.string().optional(),
413
+ usdValue: t.string().optional(),
414
+ token: N,
415
+ sent: t.boolean().optional(),
416
+ tokenIdDetails: t.object({
417
+ name: t.string().optional(),
418
+ description: t.string().optional(),
419
+ imageUrls: X.optional()
420
+ }).optional()
421
+ }), Ft = t.object({
422
+ approvals: t.array(Ut).optional(),
423
+ transfers: t.array(Ot).optional(),
424
+ calculatedNonce: t.string().optional(),
425
+ feeEstimation: Ct,
426
+ summary: t.array(xt).optional()
427
+ }), Rt = t.object({
428
+ label: t.string().optional(),
429
+ code: t.number().optional(),
430
+ message: t.string().optional(),
431
+ error: t.string().optional()
432
+ }), J = t.object({
433
+ reviewOfTransaction: G,
434
+ simulation: Ft,
435
+ simulationError: t.undefined()
436
+ }), Y = t.object({
437
+ reviewOfTransaction: G,
438
+ simulation: t.undefined(),
439
+ simulationError: Rt
440
+ }), Q = J.or(Y), De = t.object({
441
+ transactions: t.array(Q)
442
+ }), Pe = t.object({
443
+ transactions: t.array(Q),
444
+ enrichedFeeEstimation: It.optional(),
445
+ isBackendDown: t.boolean().default(!1).optional()
446
+ });
447
+ function Ue(e) {
448
+ return J.safeParse(e).success;
449
+ }
450
+ function Oe(e) {
451
+ return Y.safeParse(e).success;
452
+ }
453
+ const $ = t.object({
454
+ network: t.string(),
455
+ hash: t.string(),
456
+ status: t.string(),
457
+ blockNumber: t.number().optional(),
458
+ transactionIndex: t.number()
459
+ }), g = t.object({
460
+ type: t.enum(["token", "nft"]),
461
+ tokenAddress: r,
462
+ amount: t.string().optional(),
463
+ fiatAmount: t.object({
464
+ currency: t.string(),
465
+ currencyAmount: t.number()
466
+ }).optional().nullable()
467
+ }), k = t.enum(["ethereum", "starknet", "zksync", "zksync2"]), Lt = t.object({
468
+ type: t.enum(["payment", "gasFee"]),
469
+ leg: t.enum(["credit", "debit"]),
470
+ asset: g,
471
+ counterParty: r.optional(),
472
+ counterPartyNetwork: k.optional()
473
+ }), Vt = t.object({
474
+ address: r,
475
+ network: k,
476
+ type: t.enum(["wallet", "token"])
477
+ }), Bt = t.object({
478
+ chainId: t.enum(["TESTNET", "MAINNET", "SEPOLIA"]),
479
+ ethereumNetwork: t.enum(["mainnet", "sepolia"])
480
+ }), Ht = t.enum([
481
+ "approval",
482
+ "changePubKey",
483
+ "dappInteraction",
484
+ "deploy",
485
+ "gift",
486
+ "multicall",
487
+ "payment",
488
+ "security",
489
+ "trade"
490
+ ]), Z = t.enum([
491
+ "triggerEscapeGuardian",
492
+ "triggerEscapeSigner",
493
+ "escapeGuardian",
494
+ "escapeSigner",
495
+ "guardianChanged",
496
+ "guardianBackupChanged",
497
+ "signerChanged",
498
+ "cancelEscape",
499
+ "accountUpgraded",
500
+ "multisigConfigurationUpdated"
501
+ ]), Mt = t.object({
502
+ name: t.string(),
503
+ parameters: t.array(t.unknown()).optional()
504
+ }), Kt = t.object({
505
+ guid: t.string().optional(),
506
+ signerType: t.string().optional(),
507
+ // StarknetKey, Secp256k1, Secp256r1, Eip191, Webauthn
508
+ signer: t.object({
509
+ publicKey: t.string().optional()
510
+ }).optional()
511
+ }), zt = t.object({
512
+ activeAt: t.string().optional(),
513
+ newGuardian: t.string().optional(),
514
+ newImplementation: t.string().optional(),
515
+ newVersion: t.string().optional(),
516
+ signerGuid: t.string().optional(),
517
+ signers: t.array(Kt).optional()
518
+ }), F = t.discriminatedUnion("type", [
519
+ t.object({
520
+ type: t.literal("deploy"),
521
+ deployer: r,
522
+ contractAddress: r
523
+ }),
524
+ t.object({
525
+ type: t.literal("approval"),
526
+ spender: r,
527
+ asset: g,
528
+ approvalType: t.string()
529
+ }),
530
+ t.object({
531
+ type: t.literal("payment"),
532
+ counterparty: r,
533
+ leg: t.string(),
534
+ asset: g,
535
+ counterpartyNetwork: k.optional()
536
+ }),
537
+ t.object({
538
+ type: t.literal("trade"),
539
+ srcAsset: g,
540
+ destAsset: g
541
+ }),
542
+ t.object({
543
+ type: t.literal("security"),
544
+ action: Z,
545
+ context: zt.optional()
546
+ }),
547
+ t.object({
548
+ type: t.literal("dappInteraction"),
549
+ dappAddress: r,
550
+ function: Mt.optional().nullable()
551
+ // This object is often null. It happens when we were unable to get the ABI or failed decoding the function call
552
+ })
553
+ ]), Wt = t.union([
554
+ F,
555
+ t.object({
556
+ type: t.literal("multicall"),
557
+ calls: t.array(t.object({
558
+ details: F
559
+ }))
560
+ })
561
+ ]), qt = t.object({
562
+ dappId: t.string(),
563
+ name: t.string().optional().nullable()
564
+ }), tt = t.object({
565
+ sent: t.boolean(),
566
+ asset: t.discriminatedUnion("type", [
567
+ t.object({
568
+ type: t.literal("nft"),
569
+ tokenAddress: r,
570
+ tokenId: t.coerce.number().optional(),
571
+ amount: t.string().optional(),
572
+ collectionName: t.string().optional(),
573
+ collectionPreviewImage: t.string().optional().nullable(),
574
+ nftName: t.string().optional().nullable(),
575
+ nftPreviewImage: t.string().optional().nullable()
576
+ }),
577
+ t.object({
578
+ type: t.literal("token"),
579
+ tokenAddress: r,
580
+ amount: t.string().optional(),
581
+ fiatAmount: t.object({
582
+ currency: t.string(),
583
+ currencyAmount: t.coerce.string()
584
+ }).optional().nullable()
585
+ })
586
+ ])
587
+ }), Gt = t.object({
588
+ type: t.string(),
589
+ // "gas" for example
590
+ to: r,
591
+ actualFee: t.object({
592
+ type: t.string(),
593
+ tokenAddress: r,
594
+ amount: t.string().optional(),
595
+ fiatAmount: t.object({
596
+ currency: t.string(),
597
+ currencyAmount: t.number()
598
+ }).optional().nullable()
599
+ })
600
+ }), et = t.enum(["pending", "success", "failure"]), nt = t.object({
601
+ compositeId: t.string(),
602
+ id: t.string().uuid(),
603
+ status: et,
604
+ wallet: r,
605
+ txSender: r,
606
+ source: t.string(),
607
+ type: Ht,
608
+ group: t.enum(["finance", "security"]),
609
+ submitted: t.number(),
610
+ lastModified: t.number(),
611
+ transaction: $,
612
+ transfers: t.array(Lt),
613
+ // to be clarified
614
+ fees: t.array(Gt).optional(),
615
+ relatedAddresses: t.array(Vt).nullable(),
616
+ network: t.string(),
617
+ networkDetails: Bt.optional(),
618
+ details: Wt,
619
+ transferSummary: t.array(tt).optional(),
620
+ dapp: qt.optional(),
621
+ actions: t.array(z).optional(),
622
+ title: t.string().optional(),
623
+ multisigDetails: t.object({
624
+ signers: t.array(r)
625
+ }).optional()
626
+ }), Xt = t.object({
627
+ title: t.string().optional(),
628
+ shortTitle: t.string().optional(),
629
+ subtitle: t.string().optional(),
630
+ /** let's not import the keys from x-ui here */
631
+ icon: t.string().optional()
632
+ }), Jt = "native", Yt = "rejected", Qt = "cancelled", $t = "queued", Ce = nt.pick({
633
+ status: !0,
634
+ actions: !0,
635
+ submitted: !0,
636
+ lastModified: !0,
637
+ transferSummary: !0,
638
+ fees: !0,
639
+ multisigDetails: !0
640
+ }).extend({
641
+ status: t.union([
642
+ et,
643
+ t.enum([
644
+ Yt,
645
+ Qt,
646
+ $t
647
+ ])
648
+ ]),
649
+ type: t.literal(Jt),
650
+ transaction: $.pick({
651
+ hash: !0
652
+ }),
653
+ dapp: q.optional(),
654
+ meta: Xt.optional()
655
+ }), Zt = t.array(nt), xe = t.object({
656
+ activities: Zt,
657
+ page: t.number(),
658
+ pageSize: t.number(),
659
+ totalElements: t.number(),
660
+ totalPages: t.number()
661
+ });
662
+ function Fe(e) {
663
+ return Z.safeParse(e).success;
664
+ }
665
+ const at = (e) => tt.safeParse(e).success, Re = (e) => at(e) && e.asset.type === "token", Le = (e) => at(e) && e.asset.type === "nft", R = {
666
+ Transfer: P.getSelectorFromName("Transfer"),
667
+ // 0x99cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9
668
+ Approval: P.getSelectorFromName("Approval")
669
+ // 0x134692b230b9e1ffa39098904722134159652b09c5bc41d88d6698779d228ff
670
+ }, te = (e, n, a) => {
671
+ for (const o of e) {
672
+ const { events: s, internal_calls: c } = o;
673
+ for (const i of s)
674
+ for (const p of i.keys)
675
+ p === R.Approval && n.push({
676
+ tokenAddress: u.parse(o.contract_address),
677
+ owner: i.data[0],
678
+ spender: i.data[1],
679
+ value: S.uint256ToBN({ low: i.data[2], high: i.data[3] }).toString()
680
+ }), p === R.Transfer && a.push({
681
+ tokenAddress: u.parse(o.contract_address),
682
+ from: i.data[0],
683
+ to: i.data[1],
684
+ value: S.uint256ToBN({ low: i.data[2], high: i.data[3] }).toString()
685
+ });
686
+ c && te(c, n, a);
687
+ }
688
+ return { approvals: n, transfers: a };
689
+ }, ee = /(0x[a-fA-F0-9]+)\s*\('(.*?)'\)/, Ve = (e) => {
690
+ if (!ct(e))
691
+ return;
692
+ const n = e.match(ee);
693
+ if (n && !lt(n[2]))
694
+ return n[2];
695
+ };
696
+ var I;
697
+ (function(e) {
698
+ e.SIMULATE_AND_REVIEW_FAILED = "Something went wrong fetching review", e.NO_CALLS_FOUND = "No calls found", e.ONCHAIN_FEE_ESTIMATION_FAILED = "Failed to estimate fees onchain";
699
+ })(I || (I = {}));
700
+ class Be extends E {
701
+ constructor(n) {
702
+ super(n, I), this.name = "ReviewError";
703
+ }
704
+ }
705
+ const He = t.object({
706
+ reason: t.string(),
707
+ severity: t.string().optional(),
708
+ title: t.string(),
709
+ description: t.string().optional()
710
+ }), ne = Object.values(T.TRANSACTION_VERSION), Me = t.string().default("0x3").refine((e) => {
711
+ const n = d.toBigInt(e);
712
+ return ne.map((a) => d.toBigInt(a)).includes(n);
713
+ }).transform((e) => d.toHex(e));
714
+ function Ke(e) {
715
+ if (e === T.TRANSACTION_VERSION.V3 || e === T.TRANSACTION_VERSION.F3)
716
+ throw Error("Only txv1 is supported");
717
+ }
718
+ export {
719
+ Yt as $,
720
+ Ee as A,
721
+ _t as B,
722
+ Ne as C,
723
+ ke as D,
724
+ me as E,
725
+ K as F,
726
+ v as G,
727
+ we as H,
728
+ R as I,
729
+ te as J,
730
+ Ve as K,
731
+ He as L,
732
+ Me as M,
733
+ Ke as N,
734
+ at as O,
735
+ tt as P,
736
+ Jt as Q,
737
+ Be as R,
738
+ ye as S,
739
+ _e as T,
740
+ Ce as U,
741
+ Lt as V,
742
+ Wt as W,
743
+ qt as X,
744
+ Gt as Y,
745
+ nt as Z,
746
+ Xt as _,
747
+ de as a,
748
+ Qt as a0,
749
+ $t as a1,
750
+ Zt as a2,
751
+ xe as a3,
752
+ Fe as a4,
753
+ Re as a5,
754
+ Le as a6,
755
+ O as a7,
756
+ It as a8,
757
+ C as a9,
758
+ z as aa,
759
+ jt as ab,
760
+ wt as ac,
761
+ W as ad,
762
+ Dt as ae,
763
+ q as af,
764
+ Pe as ag,
765
+ Ue as ah,
766
+ Et as ai,
767
+ Nt as aj,
768
+ je as b,
769
+ At as c,
770
+ ge as d,
771
+ fe as e,
772
+ Ct as f,
773
+ he as g,
774
+ be as h,
775
+ Oe as i,
776
+ A as j,
777
+ H as k,
778
+ Se as l,
779
+ Te as m,
780
+ M as n,
781
+ Ae as o,
782
+ mt as p,
783
+ dt as q,
784
+ ut as r,
785
+ De as s,
786
+ gt as t,
787
+ ft as u,
788
+ ve as v,
789
+ ht as w,
790
+ Ie as x,
791
+ bt as y,
792
+ yt as z
793
+ };