@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.
@@ -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 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;
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 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;
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: i, transactionParams: n, isSubsidised: g }) {
10
- if (A(this.argentAffiliateUrl))
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
- i ? t = {
14
+ o ? t = {
14
15
  executeRequest: {
15
- ...i,
16
- signature: i.signature,
17
- deploymentData: i.deploymentData,
18
- userAddress: i.accountAddress,
19
- typedData: i.typedData
16
+ ...o,
17
+ signature: o.signature,
18
+ deploymentData: o.deploymentData,
19
+ userAddress: o.accountAddress,
20
+ typedData: o.typedData
20
21
  },
21
- isSubsidised: g
22
+ isSubsidised: h
22
23
  } : t = {
23
24
  transactions: n == null ? void 0 : n.map((e) => {
24
- var c, r, l, u, p, d, a, f;
25
- const o = {
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 === y.V1 ? o.maxFee = e.maxFee : (o.resourceBounds = {
36
+ return e.version === b.V1 ? i.maxFee = e.maxFee : (i.resourceBounds = {
36
37
  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
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: (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
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
- }, o.nonceDataAvailabilityMode = e.nonceDataAvailabilityMode, o.feeDataAvailabilityMode = e.feeDataAvailabilityMode, o.tip = e.tip), o;
45
+ }, i.nonceDataAvailabilityMode = e.nonceDataAvailabilityMode, i.feeDataAvailabilityMode = e.feeDataAvailabilityMode, i.tip = e.tip), i;
45
46
  })
46
47
  };
47
- const h = await this.httpService.post(this.argentAffiliateUrl, {
48
- body: _.stringify(t),
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
- }), s = v.safeParse(h);
53
- if (!s.success)
55
+ }), r = w.safeParse(_);
56
+ if (!r.success)
54
57
  throw new Error("Invalid response from swap API");
55
- return s.data;
58
+ return r.data;
56
59
  }
57
60
  }
58
61
  export {
59
- R as SwapTransactionService
62
+ q as SwapTransactionService
60
63
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@argent/x-shared",
3
- "version": "1.69.0",
3
+ "version": "1.70.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/argentlabs/x-shared.git"