@argent/x-shared 1.69.0 → 1.70.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/src/features/swap/services/ISwapTransactionService.d.ts +2 -1
- package/dist/src/features/swap/services/SwapTransactionService.cjs +1 -1
- package/dist/src/features/swap/services/SwapTransactionService.d.ts +2 -1
- package/dist/src/features/swap/services/SwapTransactionService.js +33 -30
- package/package.json +1 -1
|
@@ -2,9 +2,10 @@ import { TransactionExecutionResponse } from '../../../transactions/transactionE
|
|
|
2
2
|
import { SwapTransactionParams } from '../models/execute.model';
|
|
3
3
|
import { PaymasterExecuteParams } from './../../paymaster/types';
|
|
4
4
|
export interface ISwapTransactionService {
|
|
5
|
-
execute({ paymasterParams, transactionParams, isSubsidised, }: {
|
|
5
|
+
execute({ paymasterParams, transactionParams, isSubsidised, currency, }: {
|
|
6
6
|
paymasterParams?: PaymasterExecuteParams;
|
|
7
7
|
transactionParams?: SwapTransactionParams[];
|
|
8
8
|
isSubsidised?: boolean;
|
|
9
|
+
currency: string;
|
|
9
10
|
}): Promise<TransactionExecutionResponse>;
|
|
10
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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;
|
|
@@ -7,9 +7,10 @@ export declare class SwapTransactionService implements ISwapTransactionService {
|
|
|
7
7
|
private readonly argentAffiliateUrl;
|
|
8
8
|
private readonly httpService;
|
|
9
9
|
constructor(argentAffiliateUrl: string | undefined, httpService: IHttpService);
|
|
10
|
-
execute({ paymasterParams, transactionParams, isSubsidised, }: {
|
|
10
|
+
execute({ paymasterParams, transactionParams, isSubsidised, currency, }: {
|
|
11
11
|
paymasterParams?: PaymasterExecuteParams;
|
|
12
12
|
transactionParams?: SwapTransactionParams[];
|
|
13
13
|
isSubsidised?: boolean;
|
|
14
|
+
currency: string;
|
|
14
15
|
}): Promise<TransactionExecutionResponse>;
|
|
15
16
|
}
|
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import { isEmpty as
|
|
2
|
-
import { json as
|
|
3
|
-
import { transactionExecutionResponseSchema as
|
|
4
|
-
import { ETransactionVersion as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 {
|
|
7
|
+
constructor(o = "", n) {
|
|
8
|
+
this.argentAffiliateUrl = o, this.httpService = n;
|
|
8
9
|
}
|
|
9
|
-
async execute({ paymasterParams:
|
|
10
|
-
if (
|
|
10
|
+
async execute({ paymasterParams: o, transactionParams: n, isSubsidised: h, currency: g }) {
|
|
11
|
+
if (v(this.argentAffiliateUrl))
|
|
11
12
|
throw new Error("Argent affiliate URL is not set");
|
|
12
13
|
let t;
|
|
13
|
-
|
|
14
|
+
o ? t = {
|
|
14
15
|
executeRequest: {
|
|
15
|
-
...
|
|
16
|
-
signature:
|
|
17
|
-
deploymentData:
|
|
18
|
-
userAddress:
|
|
19
|
-
typedData:
|
|
16
|
+
...o,
|
|
17
|
+
signature: o.signature,
|
|
18
|
+
deploymentData: o.deploymentData,
|
|
19
|
+
userAddress: o.accountAddress,
|
|
20
|
+
typedData: o.typedData
|
|
20
21
|
},
|
|
21
|
-
isSubsidised:
|
|
22
|
+
isSubsidised: h
|
|
22
23
|
} : t = {
|
|
23
24
|
transactions: n == null ? void 0 : n.map((e) => {
|
|
24
|
-
var c,
|
|
25
|
-
const
|
|
25
|
+
var s, c, u, l, p, a, d, f;
|
|
26
|
+
const i = {
|
|
26
27
|
type: e.type,
|
|
27
28
|
calls: e.calls,
|
|
28
29
|
chainId: e.chainId,
|
|
@@ -32,29 +33,31 @@ class R {
|
|
|
32
33
|
nonce: e.nonce,
|
|
33
34
|
version: e.version
|
|
34
35
|
};
|
|
35
|
-
return e.version ===
|
|
36
|
+
return e.version === b.V1 ? i.maxFee = e.maxFee : (i.resourceBounds = {
|
|
36
37
|
l1Gas: {
|
|
37
|
-
maxAmount: (
|
|
38
|
-
maxPricePerUnit: (
|
|
38
|
+
maxAmount: (c = (s = e.resourceBounds) == null ? void 0 : s.l1_gas) == null ? void 0 : c.max_amount,
|
|
39
|
+
maxPricePerUnit: (l = (u = e.resourceBounds) == null ? void 0 : u.l1_gas) == null ? void 0 : l.max_price_per_unit
|
|
39
40
|
},
|
|
40
41
|
l2Gas: {
|
|
41
|
-
maxAmount: (
|
|
42
|
-
maxPricePerUnit: (f = (
|
|
42
|
+
maxAmount: (a = (p = e.resourceBounds) == null ? void 0 : p.l2_gas) == null ? void 0 : a.max_amount,
|
|
43
|
+
maxPricePerUnit: (f = (d = e.resourceBounds) == null ? void 0 : d.l2_gas) == null ? void 0 : f.max_price_per_unit
|
|
43
44
|
}
|
|
44
|
-
},
|
|
45
|
+
}, i.nonceDataAvailabilityMode = e.nonceDataAvailabilityMode, i.feeDataAvailabilityMode = e.feeDataAvailabilityMode, i.tip = e.tip), i;
|
|
45
46
|
})
|
|
46
47
|
};
|
|
47
|
-
const
|
|
48
|
-
|
|
48
|
+
const y = {
|
|
49
|
+
currency: g
|
|
50
|
+
}, A = U(this.argentAffiliateUrl, y), _ = await this.httpService.post(A, {
|
|
51
|
+
body: D.stringify(t),
|
|
49
52
|
headers: {
|
|
50
53
|
"Content-Type": "application/json"
|
|
51
54
|
}
|
|
52
|
-
}),
|
|
53
|
-
if (!
|
|
55
|
+
}), r = w.safeParse(_);
|
|
56
|
+
if (!r.success)
|
|
54
57
|
throw new Error("Invalid response from swap API");
|
|
55
|
-
return
|
|
58
|
+
return r.data;
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
61
|
export {
|
|
59
|
-
|
|
62
|
+
q as SwapTransactionService
|
|
60
63
|
};
|