@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.
- package/dist/index.cjs +1 -1
- package/dist/index.js +286 -307
- package/dist/simulation.cjs +1 -1
- package/dist/simulation.js +66 -68
- package/dist/src/features/paymaster/types.d.ts +2 -2
- package/dist/src/features/simulation/fees/schema.cjs +1 -1
- package/dist/src/features/simulation/fees/schema.d.ts +665 -705
- package/dist/src/features/simulation/fees/schema.js +32 -39
- package/dist/src/features/simulation/transactionReview/schema.cjs +1 -1
- package/dist/src/features/simulation/transactionReview/schema.d.ts +2117 -7917
- package/dist/src/features/simulation/transactionReview/schema.js +103 -112
- package/dist/src/features/swap/models/execute.model.d.ts +4 -0
- package/dist/src/features/swap/services/SwapTransactionService.cjs +1 -1
- package/dist/src/features/swap/services/SwapTransactionService.js +22 -18
- package/dist/src/tokens/isUnlimitedAmount.cjs +1 -1
- package/dist/src/tokens/isUnlimitedAmount.js +3 -3
- package/dist/src/transactions/amount.cjs +1 -1
- package/dist/src/transactions/amount.d.ts +2 -2
- package/dist/src/transactions/amount.js +9 -9
- package/dist/src/transactions/estimate/adjustment.cjs +1 -0
- package/dist/src/transactions/estimate/adjustment.d.ts +4 -0
- package/dist/src/transactions/estimate/adjustment.js +7 -0
- package/dist/src/transactions/estimate/argentMaxFee.d.ts +3 -3
- package/dist/src/transactions/estimate/index.d.ts +0 -1
- package/dist/src/transactions/estimate/model.d.ts +1 -10
- package/dist/src/transactions/estimate/utils.cjs +1 -1
- package/dist/src/transactions/estimate/utils.d.ts +31 -61
- package/dist/src/transactions/estimate/utils.js +156 -223
- package/dist/src/transactions/index.d.ts +0 -1
- package/dist/src/transactions/service/implementation.cjs +1 -1
- package/dist/src/transactions/service/implementation.d.ts +39 -22
- package/dist/src/transactions/service/implementation.js +130 -97
- package/dist/src/transactions/service/index.d.ts +1 -0
- package/dist/src/transactions/service/utils.cjs +1 -0
- package/dist/src/transactions/service/utils.d.ts +25 -0
- package/dist/src/transactions/service/utils.js +25 -0
- package/dist/src/transactions/transactionSimulationTypes.d.ts +1 -7
- package/dist/src/transactions/transactionVersion.cjs +1 -1
- package/dist/src/transactions/transactionVersion.d.ts +5 -6
- package/dist/src/transactions/transactionVersion.js +10 -12
- package/package.json +2 -2
- package/dist/src/transactions/estimate/utilsV2.cjs +0 -1
- package/dist/src/transactions/estimate/utilsV2.d.ts +0 -26
- package/dist/src/transactions/estimate/utilsV2.js +0 -107
- package/dist/src/transactions/getTransactionVersion.cjs +0 -1
- package/dist/src/transactions/getTransactionVersion.d.ts +0 -12
- package/dist/src/transactions/getTransactionVersion.js +0 -21
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z as t } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { addressSchemaArgentBackend as
|
|
5
|
-
const
|
|
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
|
-
}),
|
|
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
|
-
]),
|
|
65
|
+
]), w = t.object({
|
|
66
66
|
name: t.string(),
|
|
67
|
-
properties: t.array(
|
|
68
|
-
defaultProperties: t.array(
|
|
69
|
-
}),
|
|
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
|
-
]),
|
|
74
|
+
]), D = t.object({
|
|
75
75
|
unknown_token: t.unknown().optional(),
|
|
76
76
|
date_of_addition: t.string().optional(),
|
|
77
|
-
contract_address:
|
|
77
|
+
contract_address: k.optional(),
|
|
78
78
|
reason: t.string().optional(),
|
|
79
79
|
value: t.string().or(t.number()).optional()
|
|
80
|
-
}),
|
|
81
|
-
reason:
|
|
82
|
-
details:
|
|
83
|
-
severity:
|
|
84
|
-
}),
|
|
85
|
-
assessment:
|
|
86
|
-
warnings: t.array(
|
|
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:
|
|
92
|
-
}),
|
|
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(
|
|
99
|
-
}),
|
|
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(
|
|
106
|
+
warnings: t.array(l).optional(),
|
|
107
107
|
assessmentDetails: t.object({
|
|
108
108
|
contract_address: t.string()
|
|
109
109
|
}).optional(),
|
|
110
|
-
targetedDapp:
|
|
111
|
-
reviews: t.array(
|
|
112
|
-
}).optional(),
|
|
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
|
-
}),
|
|
122
|
-
address:
|
|
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:
|
|
131
|
+
imageUrls: p.optional(),
|
|
132
132
|
links: A.optional()
|
|
133
|
-
}),
|
|
134
|
-
tokenAddress:
|
|
135
|
-
owner:
|
|
136
|
-
spender:
|
|
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:
|
|
140
|
-
}),
|
|
141
|
-
tokenAddress:
|
|
142
|
-
from:
|
|
143
|
-
to:
|
|
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:
|
|
147
|
-
}),
|
|
148
|
-
|
|
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
|
-
}),
|
|
162
|
-
|
|
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
|
-
|
|
165
|
-
|
|
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:
|
|
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:
|
|
178
|
+
imageUrls: p.optional()
|
|
183
179
|
}).optional()
|
|
184
|
-
}),
|
|
185
|
-
approvals: t.array(
|
|
186
|
-
transfers: t.array(
|
|
180
|
+
}), I = t.object({
|
|
181
|
+
approvals: t.array(_).optional(),
|
|
182
|
+
transfers: t.array(x).optional(),
|
|
187
183
|
calculatedNonce: t.string().optional(),
|
|
188
|
-
feeEstimation:
|
|
189
|
-
feeEstimations: t.array(
|
|
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
|
-
}),
|
|
197
|
-
reviewOfTransaction:
|
|
198
|
-
simulation:
|
|
192
|
+
}), d = t.object({
|
|
193
|
+
reviewOfTransaction: c,
|
|
194
|
+
simulation: I,
|
|
199
195
|
simulationError: t.undefined()
|
|
200
|
-
}),
|
|
201
|
-
reviewOfTransaction:
|
|
196
|
+
}), g = t.object({
|
|
197
|
+
reviewOfTransaction: c,
|
|
202
198
|
simulation: t.undefined(),
|
|
203
199
|
simulationError: O
|
|
204
|
-
}),
|
|
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
|
-
}),
|
|
211
|
-
transactions: t.array(
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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:
|
|
217
|
+
promotions: h.optional()
|
|
226
218
|
});
|
|
227
|
-
function
|
|
228
|
-
return
|
|
219
|
+
function J(a) {
|
|
220
|
+
return d.safeParse(a).success;
|
|
229
221
|
}
|
|
230
|
-
function
|
|
231
|
-
return
|
|
222
|
+
function K(a) {
|
|
223
|
+
return g.safeParse(a).success;
|
|
232
224
|
}
|
|
233
225
|
export {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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
|
|
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
|
|
2
|
-
import { json as
|
|
3
|
-
import { transactionExecutionResponseSchema as
|
|
4
|
-
import { ETransactionVersion as
|
|
5
|
-
import { urlWithQuery as
|
|
6
|
-
class
|
|
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:
|
|
11
|
-
if (
|
|
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:
|
|
22
|
+
isSubsidised: y
|
|
23
23
|
} : t = {
|
|
24
24
|
transactions: n == null ? void 0 : n.map((e) => {
|
|
25
|
-
var s, c, u, l,
|
|
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 ===
|
|
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: (
|
|
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
|
|
49
|
-
currency:
|
|
50
|
-
},
|
|
51
|
-
body:
|
|
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 =
|
|
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
|
-
|
|
66
|
+
j as SwapTransactionService
|
|
63
67
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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 {
|
|
2
|
-
const
|
|
1
|
+
import { UINT_256_MAX as r } from "starknet";
|
|
2
|
+
const n = (t) => String(t) === String(r);
|
|
3
3
|
export {
|
|
4
|
-
|
|
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"),
|
|
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 {
|
|
1
|
+
import { BigNumberish } from 'starknet';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
export declare const parseAmount: (amount: string, decimals?:
|
|
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 {
|
|
2
|
-
import { z as
|
|
3
|
-
import { parseUnits as
|
|
4
|
-
const
|
|
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 =
|
|
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
|
|
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) => !!
|
|
19
|
+
}, { message: "Invalid amount" }), p = (r) => !!i.parse(r);
|
|
20
20
|
export {
|
|
21
|
-
|
|
21
|
+
i as inputAmountSchema,
|
|
22
22
|
p as isValidInputAmount,
|
|
23
|
-
|
|
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;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BigNumberish } from 'starknet';
|
|
2
2
|
export declare const FEE_OVERHEAD: number;
|
|
3
3
|
export declare const argentMaxFee: ({ estimatedFee, overheadMultiplier, }: {
|
|
4
|
-
estimatedFee:
|
|
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:
|
|
15
|
+
suggestedMaxFee: BigNumberish;
|
|
16
16
|
overheadMultiplier?: number;
|
|
17
17
|
starknetJsOverheadMultiplier?: number;
|
|
18
18
|
}) => string;
|
|
@@ -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
|
|
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
|
|
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;
|