@argent/x-shared 1.70.3 → 1.71.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 (47) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.js +286 -307
  3. package/dist/simulation.cjs +1 -1
  4. package/dist/simulation.js +66 -68
  5. package/dist/src/features/paymaster/types.d.ts +2 -2
  6. package/dist/src/features/simulation/fees/schema.cjs +1 -1
  7. package/dist/src/features/simulation/fees/schema.d.ts +665 -705
  8. package/dist/src/features/simulation/fees/schema.js +32 -39
  9. package/dist/src/features/simulation/transactionReview/schema.cjs +1 -1
  10. package/dist/src/features/simulation/transactionReview/schema.d.ts +2117 -7917
  11. package/dist/src/features/simulation/transactionReview/schema.js +103 -112
  12. package/dist/src/features/swap/models/execute.model.d.ts +4 -0
  13. package/dist/src/features/swap/services/SwapTransactionService.cjs +1 -1
  14. package/dist/src/features/swap/services/SwapTransactionService.js +22 -18
  15. package/dist/src/tokens/isUnlimitedAmount.cjs +1 -1
  16. package/dist/src/tokens/isUnlimitedAmount.js +3 -3
  17. package/dist/src/transactions/amount.cjs +1 -1
  18. package/dist/src/transactions/amount.d.ts +2 -2
  19. package/dist/src/transactions/amount.js +9 -9
  20. package/dist/src/transactions/estimate/adjustment.cjs +1 -0
  21. package/dist/src/transactions/estimate/adjustment.d.ts +4 -0
  22. package/dist/src/transactions/estimate/adjustment.js +7 -0
  23. package/dist/src/transactions/estimate/argentMaxFee.d.ts +3 -3
  24. package/dist/src/transactions/estimate/index.d.ts +0 -1
  25. package/dist/src/transactions/estimate/model.d.ts +1 -10
  26. package/dist/src/transactions/estimate/utils.cjs +1 -1
  27. package/dist/src/transactions/estimate/utils.d.ts +31 -61
  28. package/dist/src/transactions/estimate/utils.js +156 -223
  29. package/dist/src/transactions/index.d.ts +0 -1
  30. package/dist/src/transactions/service/implementation.cjs +1 -1
  31. package/dist/src/transactions/service/implementation.d.ts +39 -22
  32. package/dist/src/transactions/service/implementation.js +130 -97
  33. package/dist/src/transactions/service/index.d.ts +1 -0
  34. package/dist/src/transactions/service/utils.cjs +1 -0
  35. package/dist/src/transactions/service/utils.d.ts +25 -0
  36. package/dist/src/transactions/service/utils.js +25 -0
  37. package/dist/src/transactions/transactionSimulationTypes.d.ts +1 -7
  38. package/dist/src/transactions/transactionVersion.cjs +1 -1
  39. package/dist/src/transactions/transactionVersion.d.ts +5 -6
  40. package/dist/src/transactions/transactionVersion.js +10 -12
  41. package/package.json +2 -2
  42. package/dist/src/transactions/estimate/utilsV2.cjs +0 -1
  43. package/dist/src/transactions/estimate/utilsV2.d.ts +0 -26
  44. package/dist/src/transactions/estimate/utilsV2.js +0 -107
  45. package/dist/src/transactions/getTransactionVersion.cjs +0 -1
  46. package/dist/src/transactions/getTransactionVersion.d.ts +0 -12
  47. package/dist/src/transactions/getTransactionVersion.js +0 -21
@@ -1,8 +1,8 @@
1
1
  import { z as t } from "zod";
2
- import { estimatedFeesSchema as y, estimatedFeesV2Schema as f } from "../fees/schema.js";
3
- import { severitySchema as j, reasonsSchema as k } from "../warning/schema.js";
4
- import { addressSchemaArgentBackend as n, addressSchema as v } from "../../../chains/starknet/address.js";
5
- const w = t.object({
2
+ import { severitySchema as y, reasonsSchema as j } from "../warning/schema.js";
3
+ import { estimatedFeesSchema as f } from "../fees/schema.js";
4
+ import { addressSchemaArgentBackend as o, addressSchema as k } from "../../../chains/starknet/address.js";
5
+ const v = t.object({
6
6
  name: t.string(),
7
7
  url: t.string(),
8
8
  position: t.number()
@@ -14,7 +14,7 @@ const w = t.object({
14
14
  unknown: t.boolean(),
15
15
  iconUrl: t.string().optional(),
16
16
  type: t.string()
17
- }), c = t.discriminatedUnion("type", [
17
+ }), r = t.discriminatedUnion("type", [
18
18
  t.object({
19
19
  type: t.literal("amount"),
20
20
  label: t.string(),
@@ -62,54 +62,54 @@ const w = t.object({
62
62
  label: t.string(),
63
63
  token: e
64
64
  })
65
- ]), E = t.object({
65
+ ]), w = t.object({
66
66
  name: t.string(),
67
- properties: t.array(c),
68
- defaultProperties: t.array(c).optional()
69
- }), F = t.union([
67
+ properties: t.array(r),
68
+ defaultProperties: t.array(r).optional()
69
+ }), E = t.union([
70
70
  t.literal("verified"),
71
71
  t.literal("neutral"),
72
72
  t.literal("partial"),
73
73
  t.literal("warn")
74
- ]), U = t.object({
74
+ ]), D = t.object({
75
75
  unknown_token: t.unknown().optional(),
76
76
  date_of_addition: t.string().optional(),
77
- contract_address: v.optional(),
77
+ contract_address: k.optional(),
78
78
  reason: t.string().optional(),
79
79
  value: t.string().or(t.number()).optional()
80
- }), p = t.object({
81
- reason: k,
82
- details: U.optional(),
83
- severity: j
84
- }), x = t.object({
85
- assessment: F,
86
- warnings: t.array(p).optional(),
80
+ }), l = t.object({
81
+ reason: j,
82
+ details: D.optional(),
83
+ severity: y
84
+ }), U = t.object({
85
+ assessment: E,
86
+ warnings: t.array(l).optional(),
87
87
  assessmentReasons: t.array(t.string()).optional(),
88
88
  assessmentDetails: t.object({
89
89
  contract_address: t.string()
90
90
  }).optional(),
91
- action: E
92
- }), D = t.object({
91
+ action: w
92
+ }), F = t.object({
93
93
  name: t.string(),
94
94
  description: t.string(),
95
95
  logoUrl: t.string().optional(),
96
96
  iconUrl: t.string().optional(),
97
97
  argentVerified: t.boolean(),
98
- links: t.array(w)
99
- }), m = t.object({
98
+ links: t.array(v)
99
+ }), c = t.object({
100
100
  assessment: t.union([
101
101
  t.literal("verified"),
102
102
  t.literal("neutral"),
103
103
  t.literal("partial"),
104
104
  t.literal("warn")
105
105
  ]),
106
- warnings: t.array(p).optional(),
106
+ warnings: t.array(l).optional(),
107
107
  assessmentDetails: t.object({
108
108
  contract_address: t.string()
109
109
  }).optional(),
110
- targetedDapp: D.optional(),
111
- reviews: t.array(x)
112
- }).optional(), d = t.object({
110
+ targetedDapp: F.optional(),
111
+ reviews: t.array(U)
112
+ }).optional(), p = t.object({
113
113
  banner: t.string().nullable().optional(),
114
114
  preview: t.string().nullable().optional(),
115
115
  full: t.string().nullable().optional(),
@@ -118,8 +118,8 @@ const w = t.object({
118
118
  twitter: t.string().optional(),
119
119
  external: t.string().optional(),
120
120
  discord: t.string().optional()
121
- }), i = t.object({
122
- address: n,
121
+ }), s = t.object({
122
+ address: o,
123
123
  decimals: t.number().optional(),
124
124
  symbol: t.string().optional(),
125
125
  name: t.string(),
@@ -128,128 +128,119 @@ const w = t.object({
128
128
  usdValue: t.string().optional(),
129
129
  iconUrl: t.string().optional(),
130
130
  unknown: t.boolean().optional(),
131
- imageUrls: d.optional(),
131
+ imageUrls: p.optional(),
132
132
  links: A.optional()
133
- }), T = t.object({
134
- tokenAddress: n,
135
- owner: n,
136
- spender: n,
133
+ }), _ = t.object({
134
+ tokenAddress: o,
135
+ owner: o,
136
+ spender: o,
137
137
  value: t.string().optional(),
138
138
  approvalForAll: t.boolean(),
139
- details: i.optional()
140
- }), P = t.object({
141
- tokenAddress: n,
142
- from: n,
143
- to: n,
139
+ details: s.optional()
140
+ }), x = t.object({
141
+ tokenAddress: o,
142
+ from: o,
143
+ to: o,
144
144
  tokenId: t.string().optional(),
145
145
  value: t.string().optional(),
146
- details: i.optional()
147
- }), o = t.union([t.string(), t.number(), t.bigint()]).transform((a) => parseInt(a.toString(), 10)), g = {
148
- overallFee: o,
149
- gasPrice: o,
150
- gasUsage: o,
151
- dataGasPrice: o.optional(),
152
- dataGasConsumed: o.optional()
153
- }, _ = t.object({
154
- ...g,
155
- unit: t.string().transform((a) => a.toUpperCase()).pipe(t.literal("WEI")),
156
- maxFee: o
157
- }), b = t.object({
158
- address: n,
146
+ details: s.optional()
147
+ }), n = t.union([t.string(), t.number(), t.bigint()]).transform((a) => parseInt(a.toString(), 10)), m = t.object({
148
+ address: o,
159
149
  unknown: t.boolean(),
160
150
  type: t.literal("ERC20")
161
- }), V = t.object({
162
- ...g,
151
+ }), i = t.object({
152
+ maxAmount: n,
153
+ maxPricePerUnit: n
154
+ }), T = t.object({
155
+ l1Gas: i,
156
+ l1DataGas: i,
157
+ l2Gas: i
158
+ }), N = t.object({
159
+ token: m,
160
+ overallFee: n,
161
+ maxFee: n
162
+ }), b = t.object({
163
+ overallFee: n,
164
+ resourceBounds: T,
163
165
  unit: t.string().transform((a) => a.toUpperCase()).pipe(t.literal("FRI")),
164
- maxAmount: o,
165
- maxPricePerUnit: o,
166
- token: b
167
- }), I = t.object({
168
- token: b,
169
- overallFee: o,
170
- maxFee: o
171
- }), u = _.or(V), N = u.or(I), R = t.object({
166
+ token: m
167
+ }), P = b.or(N), R = t.object({
172
168
  type: t.string(),
173
169
  label: t.string(),
174
170
  tokenId: t.string().optional(),
175
171
  value: t.string().optional(),
176
172
  usdValue: t.string().optional(),
177
- token: i,
173
+ token: s,
178
174
  sent: t.boolean().optional(),
179
175
  tokenIdDetails: t.object({
180
176
  name: t.string().optional(),
181
177
  description: t.string().optional(),
182
- imageUrls: d.optional()
178
+ imageUrls: p.optional()
183
179
  }).optional()
184
- }), C = t.object({
185
- approvals: t.array(T).optional(),
186
- transfers: t.array(P).optional(),
180
+ }), I = t.object({
181
+ approvals: t.array(_).optional(),
182
+ transfers: t.array(x).optional(),
187
183
  calculatedNonce: t.string().optional(),
188
- feeEstimation: u,
189
- feeEstimations: t.array(N),
184
+ feeEstimation: b,
185
+ feeEstimations: t.array(P),
190
186
  summary: t.array(R).optional()
191
187
  }), O = t.object({
192
188
  label: t.string().optional(),
193
189
  code: t.number().optional(),
194
190
  message: t.string().optional(),
195
191
  error: t.string().optional()
196
- }), S = t.object({
197
- reviewOfTransaction: m,
198
- simulation: C,
192
+ }), d = t.object({
193
+ reviewOfTransaction: c,
194
+ simulation: I,
199
195
  simulationError: t.undefined()
200
- }), h = t.object({
201
- reviewOfTransaction: m,
196
+ }), g = t.object({
197
+ reviewOfTransaction: c,
202
198
  simulation: t.undefined(),
203
199
  simulationError: O
204
- }), s = S.or(h), r = t.object({
200
+ }), u = d.or(g), S = t.object({
205
201
  subsidiseDeployment: t.boolean(),
206
202
  subsidiseTransaction: t.boolean()
207
203
  }), B = t.object({
208
204
  name: t.string().optional(),
209
205
  shouldShow: t.boolean().optional()
210
- }), l = t.array(B), q = t.object({
211
- transactions: t.array(s).optional(),
212
- subsidyStatus: r.optional(),
213
- promotions: l.optional()
214
- }), J = t.object({
215
- transactions: t.array(s).optional(),
216
- subsidyStatus: r.optional(),
217
- enrichedFeeEstimation: y.optional(),
218
- isBackendDown: t.boolean().default(!1).optional(),
219
- promotions: l.optional()
220
- }), K = t.object({
221
- transactions: t.array(s).optional(),
222
- subsidyStatus: r.optional(),
206
+ }), h = t.array(B), H = t.object({
207
+ transactions: t.array(u).optional(),
208
+ canSubsidise: t.boolean().optional(),
209
+ subsidyStatus: S.optional(),
210
+ promotions: h.optional()
211
+ }), q = t.object({
212
+ transactions: t.array(u).optional(),
213
+ canSubsidise: t.boolean().optional(),
214
+ subsidyStatus: S.optional(),
223
215
  enrichedFeeEstimation: t.array(f).optional(),
224
216
  isBackendDown: t.boolean().default(!1).optional(),
225
- promotions: l.optional()
217
+ promotions: h.optional()
226
218
  });
227
- function L(a) {
228
- return S.safeParse(a).success;
219
+ function J(a) {
220
+ return d.safeParse(a).success;
229
221
  }
230
- function M(a) {
231
- return h.safeParse(a).success;
222
+ function K(a) {
223
+ return g.safeParse(a).success;
232
224
  }
233
225
  export {
234
- E as actionSchema,
235
- F as assessmentSchema,
236
- J as enrichedSimulateAndReviewSchema,
237
- K as enrichedSimulateAndReviewV2Schema,
238
- N as feeEstimationNativeOrPaymasterSchema,
239
- u as feeEstimationSchema,
240
- _ as feeEstimationTxV1Schema,
241
- V as feeEstimationTxV3Schema,
242
- L as isNotTransactionSimulationError,
243
- M as isTransactionSimulationError,
244
- I as paymasterFeeEstimationSchema,
245
- b as paymasterFeeTokenSchema,
226
+ w as actionSchema,
227
+ E as assessmentSchema,
228
+ q as enrichedSimulateAndReviewSchema,
229
+ i as feeEstimationGasSchema,
230
+ P as feeEstimationNativeOrPaymasterSchema,
231
+ T as feeEstimationResourceBoundSchema,
232
+ b as feeEstimationSchema,
233
+ J as isNotTransactionSimulationError,
234
+ K as isTransactionSimulationError,
235
+ N as paymasterFeeEstimationSchema,
236
+ m as paymasterFeeTokenSchema,
246
237
  B as promotionSchema,
247
- l as promotionsSchema,
248
- c as propertySchema,
249
- x as reviewSchema,
250
- q as simulateAndReviewSchema,
251
- r as subsidyStatusSchema,
252
- D as targetedDappSchema,
253
- U as warningDetailsSchema,
254
- p as warningSchema
238
+ h as promotionsSchema,
239
+ r as propertySchema,
240
+ U as reviewSchema,
241
+ H as simulateAndReviewSchema,
242
+ S as subsidyStatusSchema,
243
+ F as targetedDappSchema,
244
+ D as warningDetailsSchema,
245
+ l as warningSchema
255
246
  };
@@ -8,6 +8,10 @@ interface ApiResourceBounds {
8
8
  maxAmount?: string;
9
9
  maxPricePerUnit?: string;
10
10
  };
11
+ l1DataGas: {
12
+ maxAmount?: string;
13
+ maxPricePerUnit?: string;
14
+ };
11
15
  }
12
16
  export type SwapTransactionParams = UniversalDetails & {
13
17
  type: typeof TransactionType.INVOKE;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("lodash-es"),S=require("starknet"),b=require("../../../transactions/transactionExecuteTypes.cjs"),q=require("../../../../node_modules/.pnpm/@starknet-io_types-js@0.7.7/node_modules/@starknet-io/types-js/dist/esm/api/nonspec.cjs"),w=require("../../../utils/url/urlWithQuery.cjs");class D{constructor(n="",t){this.argentAffiliateUrl=n,this.httpService=t}async execute({paymasterParams:n,transactionParams:t,isSubsidised:y,currency:h}){if(_.isEmpty(this.argentAffiliateUrl))throw new Error("Argent affiliate URL is not set");let o;n?o={executeRequest:{...n,signature:n.signature,deploymentData:n.deploymentData,userAddress:n.accountAddress,typedData:n.typedData},isSubsidised:y}:o={transactions:t==null?void 0:t.map(e=>{var r,c,u,l,a,d,p,f;const i={type:e.type,calls:e.calls,chainId:e.chainId,cairoVersion:e.cairoVersion,account:e.account,signature:e.signature,nonce:e.nonce,version:e.version};return e.version===q.ETransactionVersion.V1?i.maxFee=e.maxFee:(i.resourceBounds={l1Gas:{maxAmount:(c=(r=e.resourceBounds)==null?void 0:r.l1_gas)==null?void 0:c.max_amount,maxPricePerUnit:(l=(u=e.resourceBounds)==null?void 0:u.l1_gas)==null?void 0:l.max_price_per_unit},l2Gas:{maxAmount:(d=(a=e.resourceBounds)==null?void 0:a.l2_gas)==null?void 0:d.max_amount,maxPricePerUnit:(f=(p=e.resourceBounds)==null?void 0:p.l2_gas)==null?void 0:f.max_price_per_unit}},i.nonceDataAvailabilityMode=e.nonceDataAvailabilityMode,i.feeDataAvailabilityMode=e.feeDataAvailabilityMode,i.tip=e.tip),i})};const g={currency:h},v=w.urlWithQuery(this.argentAffiliateUrl,g),A=await this.httpService.post(v,{body:S.json.stringify(o),headers:{"Content-Type":"application/json"}}),s=b.transactionExecutionResponseSchema.safeParse(A);if(!s.success)throw new Error("Invalid response from swap API");return s.data}}exports.SwapTransactionService=D;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("lodash-es"),w=require("starknet"),B=require("../../../transactions/transactionExecuteTypes.cjs"),E=require("../../../../node_modules/.pnpm/@starknet-io_types-js@0.7.7/node_modules/@starknet-io/types-js/dist/esm/api/nonspec.cjs"),U=require("../../../utils/url/urlWithQuery.cjs");class T{constructor(n="",i){this.argentAffiliateUrl=n,this.httpService=i}async execute({paymasterParams:n,transactionParams:i,isSubsidised:A,currency:v}){if(q.isEmpty(this.argentAffiliateUrl))throw new Error("Argent affiliate URL is not set");let o;n?o={executeRequest:{...n,signature:n.signature,deploymentData:n.deploymentData,userAddress:n.accountAddress,typedData:n.typedData},isSubsidised:A}:o={transactions:i==null?void 0:i.map(e=>{var r,c,u,a,l,d,p,_,f,g,y,h;const t={type:e.type,calls:e.calls,chainId:e.chainId,cairoVersion:e.cairoVersion,account:e.account,signature:e.signature,nonce:e.nonce,version:e.version};return e.version===E.ETransactionVersion.V1?t.maxFee=e.maxFee:(t.resourceBounds={l1Gas:{maxAmount:(c=(r=e.resourceBounds)==null?void 0:r.l1_gas)==null?void 0:c.max_amount,maxPricePerUnit:(a=(u=e.resourceBounds)==null?void 0:u.l1_gas)==null?void 0:a.max_price_per_unit},l2Gas:{maxAmount:(d=(l=e.resourceBounds)==null?void 0:l.l2_gas)==null?void 0:d.max_amount,maxPricePerUnit:(_=(p=e.resourceBounds)==null?void 0:p.l2_gas)==null?void 0:_.max_price_per_unit},l1DataGas:{maxAmount:(g=(f=e.resourceBounds)==null?void 0:f.l1_data_gas)==null?void 0:g.max_amount,maxPricePerUnit:(h=(y=e.resourceBounds)==null?void 0:y.l1_data_gas)==null?void 0:h.max_price_per_unit}},t.nonceDataAvailabilityMode=e.nonceDataAvailabilityMode,t.feeDataAvailabilityMode=e.feeDataAvailabilityMode,t.tip=e.tip),t})};const D={currency:v},S=U.urlWithQuery(this.argentAffiliateUrl,D),b=await this.httpService.post(S,{body:w.json.stringify(o),headers:{"Content-Type":"application/json"}}),s=B.transactionExecutionResponseSchema.safeParse(b);if(!s.success)throw new Error("Invalid response from swap API");return s.data}}exports.SwapTransactionService=T;
@@ -1,14 +1,14 @@
1
- import { isEmpty as v } from "lodash-es";
2
- import { json as D } from "starknet";
3
- import { transactionExecutionResponseSchema as w } from "../../../transactions/transactionExecuteTypes.js";
4
- import { ETransactionVersion as b } from "../../../../node_modules/.pnpm/@starknet-io_types-js@0.7.7/node_modules/@starknet-io/types-js/dist/esm/api/nonspec.js";
5
- import { urlWithQuery as U } from "../../../utils/url/urlWithQuery.js";
6
- class q {
1
+ import { isEmpty as U } from "lodash-es";
2
+ import { json as b } from "starknet";
3
+ import { transactionExecutionResponseSchema as m } from "../../../transactions/transactionExecuteTypes.js";
4
+ import { ETransactionVersion as E } from "../../../../node_modules/.pnpm/@starknet-io_types-js@0.7.7/node_modules/@starknet-io/types-js/dist/esm/api/nonspec.js";
5
+ import { urlWithQuery as R } from "../../../utils/url/urlWithQuery.js";
6
+ class j {
7
7
  constructor(o = "", n) {
8
8
  this.argentAffiliateUrl = o, this.httpService = n;
9
9
  }
10
- async execute({ paymasterParams: o, transactionParams: n, isSubsidised: h, currency: g }) {
11
- if (v(this.argentAffiliateUrl))
10
+ async execute({ paymasterParams: o, transactionParams: n, isSubsidised: y, currency: v }) {
11
+ if (U(this.argentAffiliateUrl))
12
12
  throw new Error("Argent affiliate URL is not set");
13
13
  let t;
14
14
  o ? t = {
@@ -19,10 +19,10 @@ class q {
19
19
  userAddress: o.accountAddress,
20
20
  typedData: o.typedData
21
21
  },
22
- isSubsidised: h
22
+ isSubsidised: y
23
23
  } : t = {
24
24
  transactions: n == null ? void 0 : n.map((e) => {
25
- var s, c, u, l, p, a, d, f;
25
+ var s, c, u, l, a, p, d, f, _, g, h, A;
26
26
  const i = {
27
27
  type: e.type,
28
28
  calls: e.calls,
@@ -33,31 +33,35 @@ class q {
33
33
  nonce: e.nonce,
34
34
  version: e.version
35
35
  };
36
- return e.version === b.V1 ? i.maxFee = e.maxFee : (i.resourceBounds = {
36
+ return e.version === E.V1 ? i.maxFee = e.maxFee : (i.resourceBounds = {
37
37
  l1Gas: {
38
38
  maxAmount: (c = (s = e.resourceBounds) == null ? void 0 : s.l1_gas) == null ? void 0 : c.max_amount,
39
39
  maxPricePerUnit: (l = (u = e.resourceBounds) == null ? void 0 : u.l1_gas) == null ? void 0 : l.max_price_per_unit
40
40
  },
41
41
  l2Gas: {
42
- maxAmount: (a = (p = e.resourceBounds) == null ? void 0 : p.l2_gas) == null ? void 0 : a.max_amount,
42
+ maxAmount: (p = (a = e.resourceBounds) == null ? void 0 : a.l2_gas) == null ? void 0 : p.max_amount,
43
43
  maxPricePerUnit: (f = (d = e.resourceBounds) == null ? void 0 : d.l2_gas) == null ? void 0 : f.max_price_per_unit
44
+ },
45
+ l1DataGas: {
46
+ maxAmount: (g = (_ = e.resourceBounds) == null ? void 0 : _.l1_data_gas) == null ? void 0 : g.max_amount,
47
+ maxPricePerUnit: (A = (h = e.resourceBounds) == null ? void 0 : h.l1_data_gas) == null ? void 0 : A.max_price_per_unit
44
48
  }
45
49
  }, i.nonceDataAvailabilityMode = e.nonceDataAvailabilityMode, i.feeDataAvailabilityMode = e.feeDataAvailabilityMode, i.tip = e.tip), i;
46
50
  })
47
51
  };
48
- const y = {
49
- currency: g
50
- }, A = U(this.argentAffiliateUrl, y), _ = await this.httpService.post(A, {
51
- body: D.stringify(t),
52
+ const D = {
53
+ currency: v
54
+ }, w = R(this.argentAffiliateUrl, D), B = await this.httpService.post(w, {
55
+ body: b.stringify(t),
52
56
  headers: {
53
57
  "Content-Type": "application/json"
54
58
  }
55
- }), r = w.safeParse(_);
59
+ }), r = m.safeParse(B);
56
60
  if (!r.success)
57
61
  throw new Error("Invalid response from swap API");
58
62
  return r.data;
59
63
  }
60
64
  }
61
65
  export {
62
- q as SwapTransactionService
66
+ j as SwapTransactionService
63
67
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("starknet"),{UINT_256_MAX:e}=n.uint256,i=t=>String(t)===String(e);exports.isUnlimitedAmount=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("starknet"),i=t=>String(t)===String(e.UINT_256_MAX);exports.isUnlimitedAmount=i;
@@ -1,5 +1,5 @@
1
- import { uint256 as n } from "starknet";
2
- const { UINT_256_MAX: i } = n, o = (t) => String(t) === String(i);
1
+ import { UINT_256_MAX as r } from "starknet";
2
+ const n = (t) => String(t) === String(r);
3
3
  export {
4
- o as isUnlimitedAmount
4
+ n as isUnlimitedAmount
5
5
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("starknet"),u=require("zod"),i=require("../bigdecimal/parseUnits.cjs"),r=(e,t=18)=>i.parseUnits(e.replace(",","."),Number(t)),n=u.z.string().trim().refine(e=>e!=="",{message:"Amount is required"}).refine(e=>{try{const t=r(e).value;if(t<0n)throw new Error("Amount must be positive");if(t===0n)throw new Error("Amount can not be zero");if(t>o.uint256.UINT_256_MAX)throw new Error("Amount is too big")}catch{throw new Error("Amount should be a number")}return!0},{message:"Invalid amount"}),s=e=>!!n.parse(e);exports.inputAmountSchema=n;exports.isValidInputAmount=s;exports.parseAmount=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("starknet"),u=require("zod"),s=require("../bigdecimal/parseUnits.cjs"),t=(e,r=18)=>s.parseUnits(e.replace(",","."),Number(r)),n=u.z.string().trim().refine(e=>e!=="",{message:"Amount is required"}).refine(e=>{try{const r=t(e).value;if(r<0n)throw new Error("Amount must be positive");if(r===0n)throw new Error("Amount can not be zero");if(r>o.UINT_256_MAX)throw new Error("Amount is too big")}catch{throw new Error("Amount should be a number")}return!0},{message:"Invalid amount"}),i=e=>!!n.parse(e);exports.inputAmountSchema=n;exports.isValidInputAmount=i;exports.parseAmount=t;
@@ -1,5 +1,5 @@
1
- import { num } from 'starknet';
1
+ import { BigNumberish } from 'starknet';
2
2
  import { z } from 'zod';
3
- export declare const parseAmount: (amount: string, decimals?: num.BigNumberish) => import('..').BigDecimal;
3
+ export declare const parseAmount: (amount: string, decimals?: BigNumberish) => import('..').BigDecimal;
4
4
  export declare const inputAmountSchema: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
5
5
  export declare const isValidInputAmount: (amount: string) => boolean;
@@ -1,24 +1,24 @@
1
- import { uint256 as t } from "starknet";
2
- import { z as n } from "zod";
3
- import { parseUnits as e } from "../bigdecimal/parseUnits.js";
4
- const i = (r, o = 18) => e(r.replace(",", "."), Number(o)), m = n.string().trim().refine((r) => r !== "", {
1
+ import { UINT_256_MAX as t } from "starknet";
2
+ import { z as e } from "zod";
3
+ import { parseUnits as n } from "../bigdecimal/parseUnits.js";
4
+ const m = (r, o = 18) => n(r.replace(",", "."), Number(o)), i = e.string().trim().refine((r) => r !== "", {
5
5
  message: "Amount is required"
6
6
  }).refine((r) => {
7
7
  try {
8
- const o = i(r).value;
8
+ const o = m(r).value;
9
9
  if (o < 0n)
10
10
  throw new Error("Amount must be positive");
11
11
  if (o === 0n)
12
12
  throw new Error("Amount can not be zero");
13
- if (o > t.UINT_256_MAX)
13
+ if (o > t)
14
14
  throw new Error("Amount is too big");
15
15
  } catch {
16
16
  throw new Error("Amount should be a number");
17
17
  }
18
18
  return !0;
19
- }, { message: "Invalid amount" }), p = (r) => !!m.parse(r);
19
+ }, { message: "Invalid amount" }), p = (r) => !!i.parse(r);
20
20
  export {
21
- m as inputAmountSchema,
21
+ i as inputAmountSchema,
22
22
  p as isValidInputAmount,
23
- i as parseAmount
23
+ m as parseAmount
24
24
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=e=>{const t=Math.cbrt(e);return isNaN(t)?Math.cbrt(2):t};exports.calculateCubeRootAdjustment=c;
@@ -0,0 +1,4 @@
1
+ export type FeeAdjustmentFn = (ratio: number) => number;
2
+ export declare const calculateSqrtAdjustment: (ratio: number) => number;
3
+ export declare const calculateCubeRootAdjustment: (ratio: number) => number;
4
+ export declare const calculateNonLinearAdjustment: (ratio: number) => number;
@@ -0,0 +1,7 @@
1
+ const c = (r) => {
2
+ const t = Math.cbrt(r);
3
+ return isNaN(t) ? Math.cbrt(2) : t;
4
+ };
5
+ export {
6
+ c as calculateCubeRootAdjustment
7
+ };
@@ -1,7 +1,7 @@
1
- import { num } from 'starknet';
1
+ import { BigNumberish } from 'starknet';
2
2
  export declare const FEE_OVERHEAD: number;
3
3
  export declare const argentMaxFee: ({ estimatedFee, overheadMultiplier, }: {
4
- estimatedFee: num.BigNumberish;
4
+ estimatedFee: BigNumberish;
5
5
  overheadMultiplier?: number;
6
6
  }) => string;
7
7
  /**
@@ -12,7 +12,7 @@ export declare const argentMaxFee: ({ estimatedFee, overheadMultiplier, }: {
12
12
  * @returns: the maximum fee considering the overhead
13
13
  */
14
14
  export declare const modifySnjsFeeOverhead: ({ suggestedMaxFee, overheadMultiplier, starknetJsOverheadMultiplier, }: {
15
- suggestedMaxFee: num.BigNumberish;
15
+ suggestedMaxFee: BigNumberish;
16
16
  overheadMultiplier?: number;
17
17
  starknetJsOverheadMultiplier?: number;
18
18
  }) => string;
@@ -2,4 +2,3 @@ export * from './argentMaxFee';
2
2
  export * from './error';
3
3
  export * from './model';
4
4
  export * from './utils';
5
- export * from './utilsV2';
@@ -23,7 +23,6 @@ export declare const transactionReviewTransactionsSchema: z.ZodObject<{
23
23
  calls?: Call | Call[] | undefined;
24
24
  }>;
25
25
  export type TransactionReviewTransactions = z.infer<typeof transactionReviewTransactionsSchema>;
26
- export type WEI = "WEI" | "wei";
27
26
  export type FRI = "FRI" | "fri";
28
27
  export interface ApiTransactionReviewV2RequestBody {
29
28
  transactions: Array<{
@@ -37,14 +36,7 @@ export interface ApiTransactionReviewV2RequestBody {
37
36
  calldata?: Calldata;
38
37
  }>;
39
38
  }
40
- export type FeeEstimationV1<T> = {
41
- unit: WEI;
42
- maxFee: T;
43
- overallFee: T;
44
- gasPrice: T;
45
- gasUsage: T;
46
- };
47
- export type FeeEstimationV3<T> = {
39
+ export type FeeEstimation<T = bigint> = {
48
40
  unit: FRI;
49
41
  overallFee: T;
50
42
  gasPrice: T;
@@ -52,4 +44,3 @@ export type FeeEstimationV3<T> = {
52
44
  maxAmount: T;
53
45
  maxPricePerUnit: T;
54
46
  };
55
- export type CastFeeEstimation<T> = FeeEstimationV1<T> | FeeEstimationV3<T>;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("lodash-es"),a=require("starknet"),y=require("../../chains/starknet/address.cjs"),x=require("../../chains/starknet/constants.cjs"),U=require("./argentMaxFee.cjs"),E=require("./error.cjs"),h=require("../../utils/starknet/starknet.cjs"),P=require("../../features/simulation/transactionReview/schema.cjs"),S=require("../../utils/arrays.cjs");function F(t){return A.upperCase(t.unit)==="WEI"}function G(t){return A.upperCase(t.unit)==="FRI"}function u(t,n){return F(t)?{...t,maxFee:n(t.maxFee),overallFee:n(t.overallFee),gasPrice:n(t.gasPrice),gasUsage:n(t.gasUsage)}:{...t,overallFee:n(t.overallFee),gasPrice:n(t.gasPrice),gasUsage:n(t.gasUsage),maxAmount:n(t.maxAmount),maxPricePerUnit:n(t.maxPricePerUnit)}}function d(t){return F(t)?{maxFee:t.maxFee}:{amount:t.maxAmount,pricePerUnit:t.maxPricePerUnit}}function p(t){return G({unit:t})?x.STRK_TOKEN_ADDRESS:x.ETH_TOKEN_ADDRESS}function k(t,n,e=2){const r=BigInt(10**e),o=BigInt(Math.round(n*10**e));return t*o/r}const N=[x.STRK_TOKEN_ADDRESS],I=(t,n=C)=>{if(t.max&&"amount"in t.max)return{...t,...t.max};const e=10000n,{amount:r,pricePerUnit:o,dataGasConsumed:s=0n,dataGasPrice:m=0n}=t,c=r*o+s*m;if(c<0)throw Error("Cannot calculate max fee for negative fee");const i=a.num.toBigInt(U.argentMaxFee({estimatedFee:c})),f=Number(i)/Number(c),M=n(f),g=BigInt(Math.trunc(M*Number(e)));return{...t,amount:r*g/e,pricePerUnit:o*g/e,dataGasConsumed:s*g/e,dataGasPrice:m*g/e}},l=t=>{const{amount:n,pricePerUnit:e,dataGasConsumed:r=0n,dataGasPrice:o=0n}=t;return n*e+r*o},B=t=>{if(t.max)return"maxFee"in t.max?t.max.maxFee:l(t.max)},T=t=>{const n=B(t);return n||l(I(t))},R=t=>{if(t.deployment&&!y.isEqualAddress(t.deployment.feeTokenAddress,t.transactions.feeTokenAddress))throw Error("Cannot calculate estimated fees for different tokens");const n=l(t.transactions),e=t.deployment?l(t.deployment):0n;return n+e},q=t=>{if(t.deployment&&!y.isEqualAddress(t.deployment.feeTokenAddress,t.transactions.feeTokenAddress))throw Error("Cannot calculate estimated fees for different tokens");const n=t.deployment?T(t.deployment):0n,e=T(t.transactions);return n+e},D=(t,n)=>[{contractAddress:t,entrypoint:"transfer",calldata:a.CallData.compile(h.transferCalldataSchema.parse({recipient:n,amount:a.uint256.bnToUint256(BigInt(1))}))}],_=(t,n)=>{if(!t)return{transactions:{feeTokenAddress:n??x.ETH_TOKEN_ADDRESS,amount:0n,pricePerUnit:0n,dataGasConsumed:0n,dataGasPrice:0n}};if(!Array.isArray(t))throw Error(`Unexpected simulation response. Expected array. Got ${typeof t}`);if(t.length===1){const e=P.feeEstimationSchema.parse(t[0].feeEstimation);return{transactions:{feeTokenAddress:p(e.unit),amount:a.num.toBigInt(e.gasUsage),pricePerUnit:a.num.toBigInt(e.gasPrice),max:d(u(e,a.num.toBigInt)),dataGasConsumed:e.dataGasConsumed?a.num.toBigInt(e.dataGasConsumed):0n,dataGasPrice:e.dataGasPrice?a.num.toBigInt(e.dataGasPrice):0n}}}if(t.length===2){const e=P.feeEstimationSchema.parse(t[0].feeEstimation),r=P.feeEstimationSchema.parse(t[1].feeEstimation);return{deployment:{feeTokenAddress:p(e.unit),amount:a.num.toBigInt(e.gasUsage),pricePerUnit:a.num.toBigInt(e.gasPrice),max:d(u(e,a.num.toBigInt)),dataGasConsumed:e.dataGasConsumed?a.num.toBigInt(e.dataGasConsumed):0n,dataGasPrice:e.dataGasPrice?a.num.toBigInt(e.dataGasPrice):0n},transactions:{feeTokenAddress:p(r.unit),amount:a.num.toBigInt(r.gasUsage),pricePerUnit:a.num.toBigInt(r.gasPrice),max:d(u(r,a.num.toBigInt)),dataGasConsumed:r.dataGasConsumed?a.num.toBigInt(r.dataGasConsumed):0n,dataGasPrice:r.dataGasPrice?a.num.toBigInt(r.dataGasPrice):0n}}}throw Error("Unexpected simulation response length")},b=({transaction:t,nonce:n,chainId:e,version:r,isDeploymentTransaction:o,cairoVersion:s,address:m,appDomain:c})=>{let i=n;o&&t.type!=="DEPLOY_ACCOUNT"&&(i=a.num.toHex(1));const f=S.ensureArray(t.calls);return{type:t.type,chainId:e,cairoVersion:s,nonce:i,version:r,account:m,calls:f,calldata:t.calldata,salt:t.salt,signature:t.signature,classHash:t.classHash,appDomain:c}},W=(t,n)=>{const{transactions:e}=t;if(!e)throw new E.EstimateError({code:"SIMULATE_AND_REVIEW_FAILED"});const r=e.map(i=>{if(!i.simulation)throw new E.EstimateError({code:"SIMULATE_AND_REVIEW_FAILED"});return i}),o=r.map(i=>({...i.simulation,feeEstimation:u(i.simulation.feeEstimation,Number)})),s=_(o,n),[m,c]=r.length===1?[r[0],void 0]:[r[1],r[0]];return{...s,transactions:{...s.transactions,dataGasConsumed:s.transactions.dataGasConsumed??0n,dataGasPrice:s.transactions.dataGasPrice??0n,max:d(u(m.simulation.feeEstimation,a.num.toBigInt))},deployment:s.deployment&&c?{...s.deployment,dataGasConsumed:s.deployment.dataGasConsumed??0n,dataGasPrice:s.deployment.dataGasPrice??0n,max:d(u(c.simulation.feeEstimation,a.num.toBigInt))}:void 0}},j=t=>({max_amount:a.num.toHex(t.amount),max_price_per_unit:a.num.toHex(t.pricePerUnit)}),w=(t,n,e)=>({max_amount:a.num.toHex(t/n),max_price_per_unit:a.num.toHex(e)}),H=t=>{const n=I(t),e=T(t);return{maxFee:e,resourceBounds:{l1_gas:(o=>o!==void 0&&"amount"in o&&"pricePerUnit"in o)(t.max)?j(t.max):w(e,t.pricePerUnit,n.pricePerUnit),l2_gas:{max_amount:"0x0",max_price_per_unit:"0x0"}}}},L=t=>{const n=Math.sqrt(t);return isNaN(n)?Math.sqrt(2):n},C=t=>{const n=Math.cbrt(t);return isNaN(n)?Math.cbrt(2):n},v=t=>t<1||isNaN(t)?1.1:Math.log(t+1)+1;exports.buildDummyTx=D;exports.calculateCubeRootAdjustment=C;exports.calculateNonLinearAdjustment=v;exports.calculateSqrtAdjustment=L;exports.castFeeEstimation=u;exports.estimatedFeeToMaxFeeTotal=T;exports.estimatedFeeToMaxResourceBounds=H;exports.estimatedFeeToTotal=l;exports.estimatedFeesToMaxFeeTotal=q;exports.estimatedFeesToTotal=R;exports.getEstimatedFeeFromBulkSimulation=_;exports.getEstimatedFeeFromSimulationAndRespectWatermarkFee=W;exports.getPayloadFromTransaction=b;exports.getWatermarkedMaxFeeTotal=B;exports.isFRI=G;exports.isWEI=F;exports.multiplyBigIntByFloat=k;exports.toMax=d;exports.tokensRequireTxV3Support=N;exports.unitToFeeTokenAddress=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("lodash-es"),o=require("starknet"),C=require("./adjustment.cjs"),N=require("./argentMaxFee.cjs"),E=require("./error.cjs"),y=require("../../chains/starknet/constants.cjs"),F=require("../../chains/starknet/address.cjs"),D=e=>{const{transactions:t}=e;if(!t)throw new E.EstimateError({code:"SIMULATE_AND_REVIEW_FAILED"});if(!Array.isArray(t))throw Error(`Unexpected simulation response. Expected array. Got ${typeof t}`);if(p.isEmpty(t))return[];if(t.length>2)throw Error(`Unexpected simulation response length. Got ${t.length}`);const a=t.map(m=>{if(!m.simulation)throw new E.EstimateError({code:"SIMULATE_AND_REVIEW_FAILED"});return{...m.simulation,...I(m.simulation.feeEstimations)}}),[s,n]=a.length===1?[a[0],void 0]:[a[1],a[0]],r=T(s,n),i=x(s,n);return[...r,...i]},I=e=>{const[t,a]=p.partition(e,s=>"unit"in s&&s.unit==="FRI");return{nativeFeeEstimations:t,paymasterFeeEstimations:a}},x=(e,t)=>{if(!e)return[];if(!t)return e.paymasterFeeEstimations.map(n=>({type:"paymaster",transactions:l(n),deployment:void 0}));const a=t.paymasterFeeEstimations,s=e.paymasterFeeEstimations;if(a.length!==s.length)throw Error("Deployment and transaction fee estimations length mismatch");return s.map((n,r)=>({type:"paymaster",transactions:l(n),deployment:l(a[r])}))},T=(e,t)=>{if(!e)return[];if(!t)return e.nativeFeeEstimations.map(n=>({type:"native",transactions:g(n),deployment:void 0}));const a=t.nativeFeeEstimations,s=e.nativeFeeEstimations;if(a.length!==s.length)throw Error("Deployment and transaction fee estimations length mismatch");return s.map((n,r)=>({type:"native",transactions:g(n),deployment:g(a[r])}))},l=e=>({feeTokenAddress:e.token.address,maxFee:BigInt(e.maxFee),overallFee:BigInt(e.overallFee)}),g=e=>({feeTokenAddress:y.STRK_TOKEN_ADDRESS,l1Gas:{gasConsumed:o.num.toBigInt(e.resourceBounds.l1Gas.maxAmount),gasPrice:o.num.toBigInt(e.resourceBounds.l1Gas.maxPricePerUnit)},l1DataGas:{gasConsumed:o.num.toBigInt(e.resourceBounds.l1DataGas.maxAmount),gasPrice:o.num.toBigInt(e.resourceBounds.l1DataGas.maxPricePerUnit)},l2Gas:{gasConsumed:o.num.toBigInt(e.resourceBounds.l2Gas.maxAmount),gasPrice:o.num.toBigInt(e.resourceBounds.l2Gas.maxPricePerUnit)}}),M=e=>{const{l1Gas:t,l2Gas:a,l1DataGas:s}=e.resourceBounds,n=t.maxAmount*t.maxPricePerUnit+a.maxAmount*a.maxPricePerUnit+s.maxAmount*s.maxPricePerUnit;return o.num.toBigInt(n)},S=e=>{var s;if(e.type==="paymaster")return e.transactions.maxFee+(((s=e.deployment)==null?void 0:s.maxFee)??0n);if(e.deployment&&!F.isEqualAddress(e.deployment.feeTokenAddress,e.transactions.feeTokenAddress))throw Error("Cannot calculate estimated fees for different tokens");const t=e.deployment?u(e.deployment):0n,a=u(e.transactions);return t+a},k=e=>{var t;return e.type==="paymaster"?e.transactions.overallFee+(((t=e.deployment)==null?void 0:t.overallFee)??0n):G(e)},f=(e=[])=>e.filter(a=>a.type==="native"),w=e=>e.filter(t=>t.type==="paymaster"),P=()=>y.STRK_TOKEN_ADDRESS,A=(e=[],t)=>{const a=f(e).find(s=>F.isEqualAddress(s.transactions.feeTokenAddress,t));if(!a)throw Error(`No native estimated fee found for ${t}`);return a},v=(e=[])=>{const t=P();return A(e,t)},R=(e=[])=>v(e),G=e=>{if(e.deployment&&!F.isEqualAddress(e.deployment.feeTokenAddress,e.transactions.feeTokenAddress))throw Error("Cannot calculate estimated fees for different tokens");const t=c(e.transactions),a=e.deployment?c(e.deployment):0n;return t+a},c=e=>{const{l1Gas:t,l2Gas:a,l1DataGas:s}=e;return t.gasConsumed*t.gasPrice+a.gasConsumed*a.gasPrice+s.gasConsumed*s.gasPrice},u=e=>c(_(e)),_=(e,t=C.calculateCubeRootAdjustment)=>{const a=10000n,{l1Gas:s,l2Gas:n,l1DataGas:r}=e,i=s.gasConsumed*s.gasPrice+n.gasConsumed*n.gasPrice+r.gasConsumed*r.gasPrice;if(i<0)throw Error("Cannot calculate max fee for negative fee");const m=o.num.toBigInt(N.argentMaxFee({estimatedFee:i})),B=Number(m)/Number(i),h=t(B),d=BigInt(Math.trunc(h*Number(a)));return{...e,l1Gas:{gasConsumed:s.gasConsumed*d/a,gasPrice:s.gasPrice},l2Gas:{gasConsumed:n.gasConsumed*d/a,gasPrice:n.gasPrice},l1DataGas:{gasConsumed:r.gasConsumed*d/a,gasPrice:r.gasPrice}}},V=e=>{const t=_(e);return u(e),{resourceBounds:{l1_gas:q(t.l1Gas),l2_gas:{max_amount:o.num.toHex(t.l2Gas.gasConsumed),max_price_per_unit:o.num.toHex(t.l2Gas.gasPrice)},l1_data_gas:{max_amount:o.num.toHex(t.l1DataGas.gasConsumed),max_price_per_unit:o.num.toHex(t.l1DataGas.gasPrice)}}}},q=e=>({max_amount:o.num.toHex(e.gasConsumed),max_price_per_unit:o.num.toHex(e.gasPrice)});exports.estimatedFeeToMaxFeeTotal=u;exports.estimatedFeeToMaxResourceBounds=V;exports.estimatedFeeToTotal=c;exports.estimatedFeesToMaxFeeTotalV2=S;exports.estimatedFeesToTotal=G;exports.estimatedFeesToTotalV2=k;exports.filterPaymasterEstimatedFees=w;exports.getEstimatedFeeFromSimulationAndRespectWatermarkFeeV2=D;exports.getNativeEstimatedFeeByFeeToken=A;exports.getNativeEstimatedFeeByTxVersion=v;exports.getNativeEstimatedFeeForAccount=R;exports.getNativeEstimatedFees=f;exports.getNativeFeeFromSimulation=T;exports.getNativeFeeTokenAddress=P;exports.getPaymasterFeeFromSimulation=x;exports.toMaxFeeEstimation=M;