@argent/x-shared 1.64.0 → 1.66.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 +407 -402
- package/dist/node_modules/.pnpm/@starknet-io_types-js@0.7.7/node_modules/@starknet-io/types-js/dist/esm/api/nonspec.cjs +1 -0
- package/dist/node_modules/.pnpm/@starknet-io_types-js@0.7.7/node_modules/@starknet-io/types-js/dist/esm/api/nonspec.js +6 -0
- package/dist/simulation.cjs +1 -1
- package/dist/simulation.js +20 -18
- package/dist/src/accountNameGenerator/x-names.json.js +1 -1
- package/dist/src/chains/starknet/network.cjs +1 -1
- package/dist/src/chains/starknet/network.d.ts +1 -0
- package/dist/src/chains/starknet/network.js +18 -10
- package/dist/src/features/paymaster/PaymasterService.cjs +1 -1
- package/dist/src/features/paymaster/PaymasterService.d.ts +0 -1
- package/dist/src/features/paymaster/PaymasterService.js +19 -25
- package/dist/src/features/simulation/activity/schema.cjs +1 -1
- package/dist/src/features/simulation/activity/schema.d.ts +238 -12
- package/dist/src/features/simulation/activity/schema.js +48 -46
- package/dist/src/features/simulation/transactionReview/schema.cjs +1 -1
- package/dist/src/features/simulation/transactionReview/schema.d.ts +76 -0
- package/dist/src/features/simulation/transactionReview/schema.js +106 -98
- package/dist/src/features/swap/models/execute.model.d.ts +35 -0
- package/dist/src/features/swap/models/index.d.ts +1 -0
- package/dist/src/features/swap/services/ISwapTransactionService.d.ts +10 -0
- package/dist/src/features/swap/services/{implementation.d.ts → SwapSharedService.d.ts} +1 -1
- package/dist/src/features/swap/services/SwapTransactionService.cjs +1 -0
- package/dist/src/features/swap/services/SwapTransactionService.d.ts +15 -0
- package/dist/src/features/swap/services/SwapTransactionService.js +60 -0
- package/dist/src/features/swap/services/index.d.ts +4 -2
- package/dist/src/transactions/index.d.ts +1 -0
- package/dist/src/transactions/transactionExecuteTypes.cjs +1 -0
- package/dist/src/transactions/transactionExecuteTypes.d.ts +114 -0
- package/dist/src/transactions/transactionExecuteTypes.js +23 -0
- package/dist/swap.cjs +1 -1
- package/dist/swap.js +20 -18
- package/package.json +11 -11
- /package/dist/src/features/swap/services/{interface.d.ts → ISwapSharedService.d.ts} +0 -0
- /package/dist/src/features/swap/services/{implementation.cjs → SwapSharedService.cjs} +0 -0
- /package/dist/src/features/swap/services/{implementation.js → SwapSharedService.js} +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { z as t } from "zod";
|
|
2
|
-
import { estimatedFeesSchema as
|
|
3
|
-
import { severitySchema as
|
|
4
|
-
import { addressSchemaArgentBackend as n, addressSchema as
|
|
5
|
-
const
|
|
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({
|
|
6
6
|
name: t.string(),
|
|
7
7
|
url: t.string(),
|
|
8
8
|
position: t.number()
|
|
9
|
-
}),
|
|
9
|
+
}), e = t.object({
|
|
10
10
|
address: t.string(),
|
|
11
11
|
name: t.string(),
|
|
12
12
|
symbol: t.string().optional(),
|
|
@@ -14,11 +14,11 @@ const v = t.object({
|
|
|
14
14
|
unknown: t.boolean(),
|
|
15
15
|
iconUrl: t.string().optional(),
|
|
16
16
|
type: t.string()
|
|
17
|
-
}),
|
|
17
|
+
}), c = t.discriminatedUnion("type", [
|
|
18
18
|
t.object({
|
|
19
19
|
type: t.literal("amount"),
|
|
20
20
|
label: t.string(),
|
|
21
|
-
token:
|
|
21
|
+
token: e,
|
|
22
22
|
amount: t.string(),
|
|
23
23
|
usd: t.string(),
|
|
24
24
|
editable: t.boolean()
|
|
@@ -39,7 +39,7 @@ const v = t.object({
|
|
|
39
39
|
t.object({
|
|
40
40
|
type: t.literal("token_address"),
|
|
41
41
|
label: t.string(),
|
|
42
|
-
token:
|
|
42
|
+
token: e
|
|
43
43
|
}),
|
|
44
44
|
t.object({
|
|
45
45
|
type: t.literal("calldata"),
|
|
@@ -60,42 +60,42 @@ const v = t.object({
|
|
|
60
60
|
t.object({
|
|
61
61
|
type: t.literal("nft"),
|
|
62
62
|
label: t.string(),
|
|
63
|
-
token:
|
|
63
|
+
token: e
|
|
64
64
|
})
|
|
65
|
-
]),
|
|
65
|
+
]), E = t.object({
|
|
66
66
|
name: t.string(),
|
|
67
|
-
properties: t.array(
|
|
68
|
-
defaultProperties: t.array(
|
|
69
|
-
}),
|
|
67
|
+
properties: t.array(c),
|
|
68
|
+
defaultProperties: t.array(c).optional()
|
|
69
|
+
}), F = t.union([
|
|
70
70
|
t.literal("verified"),
|
|
71
71
|
t.literal("neutral"),
|
|
72
72
|
t.literal("partial"),
|
|
73
73
|
t.literal("warn")
|
|
74
|
-
]),
|
|
74
|
+
]), U = t.object({
|
|
75
75
|
unknown_token: t.unknown().optional(),
|
|
76
76
|
date_of_addition: t.string().optional(),
|
|
77
|
-
contract_address:
|
|
77
|
+
contract_address: v.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
|
+
}), 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(),
|
|
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: E
|
|
92
|
+
}), D = 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(
|
|
98
|
+
links: t.array(w)
|
|
99
99
|
}), m = t.object({
|
|
100
100
|
assessment: t.union([
|
|
101
101
|
t.literal("verified"),
|
|
@@ -103,18 +103,18 @@ const v = t.object({
|
|
|
103
103
|
t.literal("partial"),
|
|
104
104
|
t.literal("warn")
|
|
105
105
|
]),
|
|
106
|
-
warnings: t.array(
|
|
106
|
+
warnings: t.array(p).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: D.optional(),
|
|
111
|
+
reviews: t.array(x)
|
|
112
|
+
}).optional(), d = t.object({
|
|
113
113
|
banner: t.string().nullable().optional(),
|
|
114
114
|
preview: t.string().nullable().optional(),
|
|
115
115
|
full: t.string().nullable().optional(),
|
|
116
116
|
original: t.string().nullable().optional()
|
|
117
|
-
}),
|
|
117
|
+
}), A = t.object({
|
|
118
118
|
twitter: t.string().optional(),
|
|
119
119
|
external: t.string().optional(),
|
|
120
120
|
discord: t.string().optional()
|
|
@@ -128,47 +128,47 @@ const v = t.object({
|
|
|
128
128
|
usdValue: t.string().optional(),
|
|
129
129
|
iconUrl: t.string().optional(),
|
|
130
130
|
unknown: t.boolean().optional(),
|
|
131
|
-
imageUrls:
|
|
132
|
-
links:
|
|
133
|
-
}),
|
|
131
|
+
imageUrls: d.optional(),
|
|
132
|
+
links: A.optional()
|
|
133
|
+
}), T = t.object({
|
|
134
134
|
tokenAddress: n,
|
|
135
135
|
owner: n,
|
|
136
136
|
spender: n,
|
|
137
137
|
value: t.string().optional(),
|
|
138
138
|
approvalForAll: t.boolean(),
|
|
139
139
|
details: i.optional()
|
|
140
|
-
}),
|
|
140
|
+
}), P = t.object({
|
|
141
141
|
tokenAddress: n,
|
|
142
142
|
from: n,
|
|
143
143
|
to: n,
|
|
144
144
|
tokenId: t.string().optional(),
|
|
145
145
|
value: t.string().optional(),
|
|
146
146
|
details: i.optional()
|
|
147
|
-
}),
|
|
148
|
-
overallFee:
|
|
149
|
-
gasPrice:
|
|
150
|
-
gasUsage:
|
|
151
|
-
dataGasPrice:
|
|
152
|
-
dataGasConsumed:
|
|
153
|
-
},
|
|
154
|
-
...
|
|
155
|
-
unit: t.string().transform((
|
|
156
|
-
maxFee:
|
|
157
|
-
}),
|
|
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
158
|
address: n,
|
|
159
159
|
unknown: t.boolean(),
|
|
160
160
|
type: t.literal("ERC20")
|
|
161
|
-
}), _ = t.object({
|
|
162
|
-
...d,
|
|
163
|
-
unit: t.string().transform((e) => e.toUpperCase()).pipe(t.literal("FRI")),
|
|
164
|
-
maxAmount: a,
|
|
165
|
-
maxPricePerUnit: a,
|
|
166
|
-
token: g
|
|
167
161
|
}), V = t.object({
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
162
|
+
...g,
|
|
163
|
+
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({
|
|
172
172
|
type: t.string(),
|
|
173
173
|
label: t.string(),
|
|
174
174
|
tokenId: t.string().optional(),
|
|
@@ -179,69 +179,77 @@ const v = t.object({
|
|
|
179
179
|
tokenIdDetails: t.object({
|
|
180
180
|
name: t.string().optional(),
|
|
181
181
|
description: t.string().optional(),
|
|
182
|
-
imageUrls:
|
|
182
|
+
imageUrls: d.optional()
|
|
183
183
|
}).optional()
|
|
184
|
-
}), R = t.object({
|
|
185
|
-
approvals: t.array(A).optional(),
|
|
186
|
-
transfers: t.array(T).optional(),
|
|
187
|
-
calculatedNonce: t.string().optional(),
|
|
188
|
-
feeEstimation: b,
|
|
189
|
-
feeEstimations: t.array(I),
|
|
190
|
-
summary: t.array(N).optional()
|
|
191
184
|
}), C = t.object({
|
|
185
|
+
approvals: t.array(T).optional(),
|
|
186
|
+
transfers: t.array(P).optional(),
|
|
187
|
+
calculatedNonce: t.string().optional(),
|
|
188
|
+
feeEstimation: u,
|
|
189
|
+
feeEstimations: t.array(N),
|
|
190
|
+
summary: t.array(R).optional()
|
|
191
|
+
}), O = t.object({
|
|
192
192
|
label: t.string().optional(),
|
|
193
193
|
code: t.number().optional(),
|
|
194
194
|
message: t.string().optional(),
|
|
195
195
|
error: t.string().optional()
|
|
196
|
-
}),
|
|
196
|
+
}), S = t.object({
|
|
197
197
|
reviewOfTransaction: m,
|
|
198
|
-
simulation:
|
|
198
|
+
simulation: C,
|
|
199
199
|
simulationError: t.undefined()
|
|
200
|
-
}),
|
|
200
|
+
}), h = t.object({
|
|
201
201
|
reviewOfTransaction: m,
|
|
202
202
|
simulation: t.undefined(),
|
|
203
|
-
simulationError:
|
|
204
|
-
}), s =
|
|
203
|
+
simulationError: O
|
|
204
|
+
}), s = S.or(h), r = t.object({
|
|
205
205
|
subsidiseDeployment: t.boolean(),
|
|
206
206
|
subsidiseTransaction: t.boolean()
|
|
207
|
-
}),
|
|
207
|
+
}), B = t.object({
|
|
208
|
+
name: t.string().optional(),
|
|
209
|
+
shouldShow: t.boolean().optional()
|
|
210
|
+
}), l = t.array(B), q = t.object({
|
|
208
211
|
transactions: t.array(s).optional(),
|
|
209
|
-
subsidyStatus: r.optional()
|
|
210
|
-
|
|
212
|
+
subsidyStatus: r.optional(),
|
|
213
|
+
promotions: l.optional()
|
|
214
|
+
}), J = t.object({
|
|
211
215
|
transactions: t.array(s).optional(),
|
|
212
216
|
subsidyStatus: r.optional(),
|
|
213
|
-
enrichedFeeEstimation:
|
|
214
|
-
isBackendDown: t.boolean().default(!1).optional()
|
|
215
|
-
|
|
217
|
+
enrichedFeeEstimation: y.optional(),
|
|
218
|
+
isBackendDown: t.boolean().default(!1).optional(),
|
|
219
|
+
promotions: l.optional()
|
|
220
|
+
}), K = t.object({
|
|
216
221
|
transactions: t.array(s).optional(),
|
|
217
222
|
subsidyStatus: r.optional(),
|
|
218
|
-
enrichedFeeEstimation: t.array(
|
|
219
|
-
isBackendDown: t.boolean().default(!1).optional()
|
|
223
|
+
enrichedFeeEstimation: t.array(f).optional(),
|
|
224
|
+
isBackendDown: t.boolean().default(!1).optional(),
|
|
225
|
+
promotions: l.optional()
|
|
220
226
|
});
|
|
221
|
-
function
|
|
222
|
-
return
|
|
227
|
+
function L(a) {
|
|
228
|
+
return S.safeParse(a).success;
|
|
223
229
|
}
|
|
224
|
-
function
|
|
225
|
-
return
|
|
230
|
+
function M(a) {
|
|
231
|
+
return h.safeParse(a).success;
|
|
226
232
|
}
|
|
227
233
|
export {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
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,
|
|
246
|
+
B as promotionSchema,
|
|
247
|
+
l as promotionsSchema,
|
|
248
|
+
c as propertySchema,
|
|
249
|
+
x as reviewSchema,
|
|
250
|
+
q as simulateAndReviewSchema,
|
|
243
251
|
r as subsidyStatusSchema,
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
252
|
+
D as targetedDappSchema,
|
|
253
|
+
U as warningDetailsSchema,
|
|
254
|
+
p as warningSchema
|
|
247
255
|
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AllowArray, BigNumberish, CairoVersion, Call, Signature, TransactionType, UniversalDetails } from 'starknet';
|
|
2
|
+
interface ApiResourceBounds {
|
|
3
|
+
l1Gas: {
|
|
4
|
+
maxAmount?: string;
|
|
5
|
+
maxPricePerUnit?: string;
|
|
6
|
+
};
|
|
7
|
+
l2Gas: {
|
|
8
|
+
maxAmount?: string;
|
|
9
|
+
maxPricePerUnit?: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export type SwapTransactionParams = UniversalDetails & {
|
|
13
|
+
type: typeof TransactionType.INVOKE;
|
|
14
|
+
calls: AllowArray<Call>;
|
|
15
|
+
chainId: string;
|
|
16
|
+
cairoVersion: CairoVersion;
|
|
17
|
+
account: string;
|
|
18
|
+
signature: Signature;
|
|
19
|
+
};
|
|
20
|
+
export type ApiSwapRequest = {
|
|
21
|
+
type: typeof TransactionType.INVOKE;
|
|
22
|
+
calls: AllowArray<Call>;
|
|
23
|
+
chainId: string;
|
|
24
|
+
cairoVersion: CairoVersion;
|
|
25
|
+
account: string;
|
|
26
|
+
signature: Signature;
|
|
27
|
+
nonce?: BigNumberish;
|
|
28
|
+
maxFee?: BigNumberish;
|
|
29
|
+
tip?: BigNumberish;
|
|
30
|
+
version?: BigNumberish;
|
|
31
|
+
nonceDataAvailabilityMode?: string;
|
|
32
|
+
feeDataAvailabilityMode?: string;
|
|
33
|
+
resourceBounds?: ApiResourceBounds;
|
|
34
|
+
};
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TransactionExecutionResponse } from '../../../transactions/transactionExecuteTypes';
|
|
2
|
+
import { SwapTransactionParams } from '../models/execute.model';
|
|
3
|
+
import { PaymasterExecuteParams } from './../../paymaster/types';
|
|
4
|
+
export interface ISwapTransactionService {
|
|
5
|
+
execute({ paymasterParams, transactionParams, isSubsidised, }: {
|
|
6
|
+
paymasterParams?: PaymasterExecuteParams;
|
|
7
|
+
transactionParams?: SwapTransactionParams[];
|
|
8
|
+
isSubsidised?: boolean;
|
|
9
|
+
}): Promise<TransactionExecutionResponse>;
|
|
10
|
+
}
|
|
@@ -2,7 +2,7 @@ import { Address } from '../../../chains';
|
|
|
2
2
|
import { SwapOrderResponse, SwapQuoteResponse, Trade } from '../models';
|
|
3
3
|
import { IHttpService } from '../../../http';
|
|
4
4
|
import { WebToken } from '../../../tokens/service/types/webToken.model';
|
|
5
|
-
import { ISharedSwapService } from './
|
|
5
|
+
import { ISharedSwapService } from './ISwapSharedService';
|
|
6
6
|
export declare class SharedSwapService implements ISharedSwapService {
|
|
7
7
|
private readonly httpService;
|
|
8
8
|
swapQuoteUrl: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("lodash-es"),v=require("starknet"),A=require("../../../transactions/transactionExecuteTypes.cjs"),_=require("../../../../node_modules/.pnpm/@starknet-io_types-js@0.7.7/node_modules/@starknet-io/types-js/dist/esm/api/nonspec.cjs");class S{constructor(n="",t){this.argentAffiliateUrl=n,this.httpService=t}async execute({paymasterParams:n,transactionParams:t,isSubsidised:g}){if(y.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:g}:o={transactions:t==null?void 0:t.map(e=>{var c,r,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===_.ETransactionVersion.V1?i.maxFee=e.maxFee:(i.resourceBounds={l1Gas:{maxAmount:(r=(c=e.resourceBounds)==null?void 0:c.l1_gas)==null?void 0:r.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 h=await this.httpService.post(this.argentAffiliateUrl,{body:v.json.stringify(o),headers:{"Content-Type":"application/json"}}),s=A.transactionExecutionResponseSchema.safeParse(h);if(!s.success)throw new Error("Invalid response from swap API");return s.data}}exports.SwapTransactionService=S;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IHttpService } from '../../../http';
|
|
2
|
+
import { TransactionExecutionResponse } from '../../../transactions/transactionExecuteTypes';
|
|
3
|
+
import { SwapTransactionParams } from '../models/execute.model';
|
|
4
|
+
import { PaymasterExecuteParams } from './../../paymaster/types';
|
|
5
|
+
import { ISwapTransactionService } from './ISwapTransactionService';
|
|
6
|
+
export declare class SwapTransactionService implements ISwapTransactionService {
|
|
7
|
+
private readonly argentAffiliateUrl;
|
|
8
|
+
private readonly httpService;
|
|
9
|
+
constructor(argentAffiliateUrl: string | undefined, httpService: IHttpService);
|
|
10
|
+
execute({ paymasterParams, transactionParams, isSubsidised, }: {
|
|
11
|
+
paymasterParams?: PaymasterExecuteParams;
|
|
12
|
+
transactionParams?: SwapTransactionParams[];
|
|
13
|
+
isSubsidised?: boolean;
|
|
14
|
+
}): Promise<TransactionExecutionResponse>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { isEmpty as A } from "lodash-es";
|
|
2
|
+
import { json as _ } from "starknet";
|
|
3
|
+
import { transactionExecutionResponseSchema as v } from "../../../transactions/transactionExecuteTypes.js";
|
|
4
|
+
import { ETransactionVersion as y } from "../../../../node_modules/.pnpm/@starknet-io_types-js@0.7.7/node_modules/@starknet-io/types-js/dist/esm/api/nonspec.js";
|
|
5
|
+
class R {
|
|
6
|
+
constructor(i = "", n) {
|
|
7
|
+
this.argentAffiliateUrl = i, this.httpService = n;
|
|
8
|
+
}
|
|
9
|
+
async execute({ paymasterParams: i, transactionParams: n, isSubsidised: g }) {
|
|
10
|
+
if (A(this.argentAffiliateUrl))
|
|
11
|
+
throw new Error("Argent affiliate URL is not set");
|
|
12
|
+
let t;
|
|
13
|
+
i ? t = {
|
|
14
|
+
executeRequest: {
|
|
15
|
+
...i,
|
|
16
|
+
signature: i.signature,
|
|
17
|
+
deploymentData: i.deploymentData,
|
|
18
|
+
userAddress: i.accountAddress,
|
|
19
|
+
typedData: i.typedData
|
|
20
|
+
},
|
|
21
|
+
isSubsidised: g
|
|
22
|
+
} : t = {
|
|
23
|
+
transactions: n == null ? void 0 : n.map((e) => {
|
|
24
|
+
var c, r, l, u, p, d, a, f;
|
|
25
|
+
const o = {
|
|
26
|
+
type: e.type,
|
|
27
|
+
calls: e.calls,
|
|
28
|
+
chainId: e.chainId,
|
|
29
|
+
cairoVersion: e.cairoVersion,
|
|
30
|
+
account: e.account,
|
|
31
|
+
signature: e.signature,
|
|
32
|
+
nonce: e.nonce,
|
|
33
|
+
version: e.version
|
|
34
|
+
};
|
|
35
|
+
return e.version === y.V1 ? o.maxFee = e.maxFee : (o.resourceBounds = {
|
|
36
|
+
l1Gas: {
|
|
37
|
+
maxAmount: (r = (c = e.resourceBounds) == null ? void 0 : c.l1_gas) == null ? void 0 : r.max_amount,
|
|
38
|
+
maxPricePerUnit: (u = (l = e.resourceBounds) == null ? void 0 : l.l1_gas) == null ? void 0 : u.max_price_per_unit
|
|
39
|
+
},
|
|
40
|
+
l2Gas: {
|
|
41
|
+
maxAmount: (d = (p = e.resourceBounds) == null ? void 0 : p.l2_gas) == null ? void 0 : d.max_amount,
|
|
42
|
+
maxPricePerUnit: (f = (a = e.resourceBounds) == null ? void 0 : a.l2_gas) == null ? void 0 : f.max_price_per_unit
|
|
43
|
+
}
|
|
44
|
+
}, o.nonceDataAvailabilityMode = e.nonceDataAvailabilityMode, o.feeDataAvailabilityMode = e.feeDataAvailabilityMode, o.tip = e.tip), o;
|
|
45
|
+
})
|
|
46
|
+
};
|
|
47
|
+
const h = await this.httpService.post(this.argentAffiliateUrl, {
|
|
48
|
+
body: _.stringify(t),
|
|
49
|
+
headers: {
|
|
50
|
+
"Content-Type": "application/json"
|
|
51
|
+
}
|
|
52
|
+
}), s = v.safeParse(h);
|
|
53
|
+
if (!s.success)
|
|
54
|
+
throw new Error("Invalid response from swap API");
|
|
55
|
+
return s.data;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
R as SwapTransactionService
|
|
60
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("zod"),o=t.z.object({tokenType:t.z.string(),tokenAddress:t.z.string(),tokenAmount:t.z.string()}),n=t.z.object({type:t.z.enum(["lootbox"]),status:t.z.enum(["notEligible","win","loss","disabled"]),prizes:t.z.array(o).nullable().optional()}),e=t.z.object({transactionState:t.z.enum(["submitted","rejected"]).optional(),transactionHash:t.z.string(),rejectReason:t.z.string().nullable().optional(),promotions:t.z.array(n).nullable().optional()});exports.transactionExecutionResponseSchema=e;exports.transactionPromotionPrizeSchema=o;exports.transactionPromotionSchema=n;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const transactionPromotionPrizeSchema: z.ZodObject<{
|
|
3
|
+
tokenType: z.ZodString;
|
|
4
|
+
tokenAddress: z.ZodString;
|
|
5
|
+
tokenAmount: z.ZodString;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
tokenAddress: string;
|
|
8
|
+
tokenType: string;
|
|
9
|
+
tokenAmount: string;
|
|
10
|
+
}, {
|
|
11
|
+
tokenAddress: string;
|
|
12
|
+
tokenType: string;
|
|
13
|
+
tokenAmount: string;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const transactionPromotionSchema: z.ZodObject<{
|
|
16
|
+
type: z.ZodEnum<["lootbox"]>;
|
|
17
|
+
status: z.ZodEnum<["notEligible", "win", "loss", "disabled"]>;
|
|
18
|
+
prizes: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
19
|
+
tokenType: z.ZodString;
|
|
20
|
+
tokenAddress: z.ZodString;
|
|
21
|
+
tokenAmount: z.ZodString;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
tokenAddress: string;
|
|
24
|
+
tokenType: string;
|
|
25
|
+
tokenAmount: string;
|
|
26
|
+
}, {
|
|
27
|
+
tokenAddress: string;
|
|
28
|
+
tokenType: string;
|
|
29
|
+
tokenAmount: string;
|
|
30
|
+
}>, "many">>>;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
type: "lootbox";
|
|
33
|
+
status: "notEligible" | "win" | "loss" | "disabled";
|
|
34
|
+
prizes?: {
|
|
35
|
+
tokenAddress: string;
|
|
36
|
+
tokenType: string;
|
|
37
|
+
tokenAmount: string;
|
|
38
|
+
}[] | null | undefined;
|
|
39
|
+
}, {
|
|
40
|
+
type: "lootbox";
|
|
41
|
+
status: "notEligible" | "win" | "loss" | "disabled";
|
|
42
|
+
prizes?: {
|
|
43
|
+
tokenAddress: string;
|
|
44
|
+
tokenType: string;
|
|
45
|
+
tokenAmount: string;
|
|
46
|
+
}[] | null | undefined;
|
|
47
|
+
}>;
|
|
48
|
+
export declare const transactionExecutionResponseSchema: z.ZodObject<{
|
|
49
|
+
transactionState: z.ZodOptional<z.ZodEnum<["submitted", "rejected"]>>;
|
|
50
|
+
transactionHash: z.ZodString;
|
|
51
|
+
rejectReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
52
|
+
promotions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
53
|
+
type: z.ZodEnum<["lootbox"]>;
|
|
54
|
+
status: z.ZodEnum<["notEligible", "win", "loss", "disabled"]>;
|
|
55
|
+
prizes: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
56
|
+
tokenType: z.ZodString;
|
|
57
|
+
tokenAddress: z.ZodString;
|
|
58
|
+
tokenAmount: z.ZodString;
|
|
59
|
+
}, "strip", z.ZodTypeAny, {
|
|
60
|
+
tokenAddress: string;
|
|
61
|
+
tokenType: string;
|
|
62
|
+
tokenAmount: string;
|
|
63
|
+
}, {
|
|
64
|
+
tokenAddress: string;
|
|
65
|
+
tokenType: string;
|
|
66
|
+
tokenAmount: string;
|
|
67
|
+
}>, "many">>>;
|
|
68
|
+
}, "strip", z.ZodTypeAny, {
|
|
69
|
+
type: "lootbox";
|
|
70
|
+
status: "notEligible" | "win" | "loss" | "disabled";
|
|
71
|
+
prizes?: {
|
|
72
|
+
tokenAddress: string;
|
|
73
|
+
tokenType: string;
|
|
74
|
+
tokenAmount: string;
|
|
75
|
+
}[] | null | undefined;
|
|
76
|
+
}, {
|
|
77
|
+
type: "lootbox";
|
|
78
|
+
status: "notEligible" | "win" | "loss" | "disabled";
|
|
79
|
+
prizes?: {
|
|
80
|
+
tokenAddress: string;
|
|
81
|
+
tokenType: string;
|
|
82
|
+
tokenAmount: string;
|
|
83
|
+
}[] | null | undefined;
|
|
84
|
+
}>, "many">>>;
|
|
85
|
+
}, "strip", z.ZodTypeAny, {
|
|
86
|
+
transactionHash: string;
|
|
87
|
+
promotions?: {
|
|
88
|
+
type: "lootbox";
|
|
89
|
+
status: "notEligible" | "win" | "loss" | "disabled";
|
|
90
|
+
prizes?: {
|
|
91
|
+
tokenAddress: string;
|
|
92
|
+
tokenType: string;
|
|
93
|
+
tokenAmount: string;
|
|
94
|
+
}[] | null | undefined;
|
|
95
|
+
}[] | null | undefined;
|
|
96
|
+
transactionState?: "rejected" | "submitted" | undefined;
|
|
97
|
+
rejectReason?: string | null | undefined;
|
|
98
|
+
}, {
|
|
99
|
+
transactionHash: string;
|
|
100
|
+
promotions?: {
|
|
101
|
+
type: "lootbox";
|
|
102
|
+
status: "notEligible" | "win" | "loss" | "disabled";
|
|
103
|
+
prizes?: {
|
|
104
|
+
tokenAddress: string;
|
|
105
|
+
tokenType: string;
|
|
106
|
+
tokenAmount: string;
|
|
107
|
+
}[] | null | undefined;
|
|
108
|
+
}[] | null | undefined;
|
|
109
|
+
transactionState?: "rejected" | "submitted" | undefined;
|
|
110
|
+
rejectReason?: string | null | undefined;
|
|
111
|
+
}>;
|
|
112
|
+
export type TransactionExecutionResponse = z.infer<typeof transactionExecutionResponseSchema>;
|
|
113
|
+
export type TransactionPromotion = z.infer<typeof transactionPromotionSchema>;
|
|
114
|
+
export type TransactionPromotionPrize = z.infer<typeof transactionPromotionPrizeSchema>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z as t } from "zod";
|
|
2
|
+
const o = t.object({
|
|
3
|
+
tokenType: t.string(),
|
|
4
|
+
tokenAddress: t.string(),
|
|
5
|
+
tokenAmount: t.string()
|
|
6
|
+
}), n = t.object({
|
|
7
|
+
type: t.enum(["lootbox"]),
|
|
8
|
+
status: t.enum(["notEligible", "win", "loss", "disabled"]),
|
|
9
|
+
prizes: t.array(o).nullable().optional()
|
|
10
|
+
// need to support null values too
|
|
11
|
+
}), a = t.object({
|
|
12
|
+
transactionState: t.enum(["submitted", "rejected"]).optional(),
|
|
13
|
+
transactionHash: t.string(),
|
|
14
|
+
rejectReason: t.string().nullable().optional(),
|
|
15
|
+
// need to support null values too
|
|
16
|
+
promotions: t.array(n).nullable().optional()
|
|
17
|
+
// need to support null values too
|
|
18
|
+
});
|
|
19
|
+
export {
|
|
20
|
+
a as transactionExecutionResponseSchema,
|
|
21
|
+
o as transactionPromotionPrizeSchema,
|
|
22
|
+
n as transactionPromotionSchema
|
|
23
|
+
};
|
package/dist/swap.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./src/features/swap/services/SwapSharedService.cjs"),S=require("./src/features/swap/services/SwapTransactionService.cjs"),r=require("./src/features/swap/models/order.model.cjs"),e=require("./src/features/swap/models/quote.model.cjs"),a=require("./src/features/swap/models/trade.model.cjs"),c=require("./src/features/swap/utils/totalFee.cjs"),t=require("./src/features/swap/utils/slippage.cjs");exports.SharedSwapService=o.SharedSwapService;exports.SwapTransactionService=S.SwapTransactionService;exports.SwapOrderRequestSchema=r.SwapOrderRequestSchema;exports.SwapOrderResponseSchema=r.SwapOrderResponseSchema;exports.SwapDataSchema=e.SwapDataSchema;exports.SwapQuoteResponseSchema=e.SwapQuoteResponseSchema;exports.SwapQuoteRouteSchema=e.SwapQuoteRouteSchema;exports.TradeSchema=a.TradeSchema;Object.defineProperty(exports,"TradeType",{enumerable:!0,get:()=>a.TradeType});exports.TradeTypeSchema=a.TradeTypeSchema;exports.calculateTotalFee=c.calculateTotalFee;exports.maximumAmountInForTrade=t.maximumAmountInForTrade;exports.minimumAmountOutFromTrade=t.minimumAmountOutFromTrade;
|