@argent/x-shared 1.62.7 → 1.62.9

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("starknet"),h=require("url-join"),v=require("./types.cjs"),A=require("../../utils/starknet/starknet.cjs"),d=require("../../utils/url/urlWithQuery.cjs");class f{constructor(e="",t){this.argentRelayerUrl=e,this.httpService=t}async getExecutionData(e,t={}){const{useAvnu:n,isSubsidised:o}=t,{networkId:r}=e,u=r?{network:this.getArgentNetwork(r)}:void 0,a=n?h(this.getAvnuUrl(r),"/build-typed-data"):d.urlWithQuery([this.argentRelayerUrl,"/build-typed-data"],u),l={calls:n?e.calls.map(c=>({contractAddress:s.num.toHex(c.contractAddress),calldata:s.CallData.toCalldata(c.calldata).map(g=>s.num.toHex(g)),entrypoint:c.entrypoint})):e.calls,userAddress:e.accountAddress,gasTokenAddress:o?null:s.num.toHex(e.feeTokenAddress),maxGasTokenAmount:o?null:s.num.toHex(e.maxFee),accountClassHash:e.accountClassHash},i=await this.httpService.post(a,{body:s.json.stringify(l),headers:{"Content-Type":"application/json"}}),y=A.typedDataSchema.safeParse(i);if(!y.success)throw new Error("Invalid response from paymaster");return y.data}getArgentNetwork(e){if(e==="mainnet"||e==="mainnet-alpha")return"MAINNET";if(e==="sepolia"||e==="sepolia-alpha")return"SEPOLIA";throw new Error("Invalid network id")}getAvnuUrl(e){if(!e)throw new Error("Network id is required for Avnu paymaster");let t="";if(e==="mainnet"||e==="mainnet-alpha")t="starknet";else if(e==="sepolia"||e==="sepolia-alpha")t="sepolia";else throw new Error("Invalid network id");return`https://${t}.api.avnu.fi/paymaster/v1`}async execute(e,t={}){const{useAvnu:n,isSubsidised:o}=t,{networkId:r}=e,u=r?{network:this.getArgentNetwork(r)}:void 0;let a=n?h(this.getAvnuUrl(r),"/execute"):d.urlWithQuery([this.argentRelayerUrl,"/execute"],u);o&&(a=d.urlWithQuery(a,{isSubsidised:"true"}));const p={signature:e.signature,userAddress:e.accountAddress,typedData:n?s.json.stringify(e.typedData):e.typedData,deploymentData:e.deploymentData},l=await this.httpService.post(a,{body:s.json.stringify(p),headers:{"Content-Type":"application/json"}}),i=v.paymasterExecuteResponse.safeParse(l);if(!i.success)throw new Error("Invalid response from paymaster");return i.data.transactionHash}}exports.PaymasterService=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("starknet"),h=require("url-join"),v=require("./types.cjs"),f=require("../../utils/starknet/starknet.cjs"),d=require("../../utils/url/urlWithQuery.cjs");class m{constructor(e="",t){this.argentRelayerUrl=e,this.httpService=t}async getExecutionData(e,t={}){const{useAvnu:n,isSubsidised:o}=t,{networkId:r}=e,l=r?{network:this.getArgentNetwork(r)}:void 0,a=n?h(this.getAvnuUrl(r),"/build-typed-data"):d.urlWithQuery([this.argentRelayerUrl,"/build-typed-data"],l),u={calls:n?e.calls.map(c=>({contractAddress:s.num.toHex(c.contractAddress),calldata:s.CallData.toCalldata(c.calldata).map(g=>s.num.toHex(g)),entrypoint:c.entrypoint})):e.calls,userAddress:e.accountAddress,gasTokenAddress:o?null:s.num.toHex(e.feeTokenAddress),maxGasTokenAmount:o?null:s.num.toHex(e.maxFee),accountClassHash:e.accountClassHash},i=await this.httpService.post(a,{body:s.json.stringify(u),headers:{"Content-Type":"application/json"}}),y=f.typedDataSchema.safeParse(i);if(!y.success)throw new Error("Invalid response from paymaster");return y.data}getArgentNetwork(e){if(e==="mainnet"||e==="mainnet-alpha")return"mainnet";if(e==="sepolia"||e==="sepolia-alpha")return"sepolia";throw new Error("Invalid network id")}getAvnuUrl(e){if(!e)throw new Error("Network id is required for Avnu paymaster");let t="";if(e==="mainnet"||e==="mainnet-alpha")t="starknet";else if(e==="sepolia"||e==="sepolia-alpha")t="sepolia";else throw new Error("Invalid network id");return`https://${t}.api.avnu.fi/paymaster/v1`}async execute(e,t={}){const{useAvnu:n,isSubsidised:o}=t,{networkId:r}=e,l=r?{network:this.getArgentNetwork(r)}:void 0;let a=n?h(this.getAvnuUrl(r),"/execute"):d.urlWithQuery([this.argentRelayerUrl,"/execute"],l);o&&(a=d.urlWithQuery(a,{isSubsidised:"true"}));const p={signature:e.signature,userAddress:e.accountAddress,typedData:n?s.json.stringify(e.typedData):e.typedData,deploymentData:e.deploymentData},u=await this.httpService.post(a,{body:s.json.stringify(p),headers:{"Content-Type":"application/json"}}),i=v.paymasterExecuteResponse.safeParse(u);if(!i.success)throw new Error("Invalid response from paymaster");return i.data.transactionHash}}exports.PaymasterService=m;
@@ -1,9 +1,9 @@
1
- import { CallData as A, num as i, json as u } from "starknet";
1
+ import { CallData as g, num as i, json as u } from "starknet";
2
2
  import f from "url-join";
3
- import { paymasterExecuteResponse as g } from "./types.js";
4
- import { typedDataSchema as v } from "../../utils/starknet/starknet.js";
3
+ import { paymasterExecuteResponse as v } from "./types.js";
4
+ import { typedDataSchema as A } from "../../utils/starknet/starknet.js";
5
5
  import { urlWithQuery as p } from "../../utils/url/urlWithQuery.js";
6
- class D {
6
+ class E {
7
7
  constructor(e = "", t) {
8
8
  this.argentRelayerUrl = e, this.httpService = t;
9
9
  }
@@ -11,7 +11,7 @@ class D {
11
11
  const { useAvnu: r, isSubsidised: n } = t, { networkId: s } = e, l = s ? { network: this.getArgentNetwork(s) } : void 0, a = r ? f(this.getAvnuUrl(s), "/build-typed-data") : p([this.argentRelayerUrl, "/build-typed-data"], l), c = {
12
12
  calls: r ? e.calls.map((d) => ({
13
13
  contractAddress: i.toHex(d.contractAddress),
14
- calldata: A.toCalldata(d.calldata).map((m) => i.toHex(m)),
14
+ calldata: g.toCalldata(d.calldata).map((m) => i.toHex(m)),
15
15
  entrypoint: d.entrypoint
16
16
  })) : e.calls,
17
17
  userAddress: e.accountAddress,
@@ -23,16 +23,16 @@ class D {
23
23
  headers: {
24
24
  "Content-Type": "application/json"
25
25
  }
26
- }), h = v.safeParse(o);
26
+ }), h = A.safeParse(o);
27
27
  if (!h.success)
28
28
  throw new Error("Invalid response from paymaster");
29
29
  return h.data;
30
30
  }
31
31
  getArgentNetwork(e) {
32
32
  if (e === "mainnet" || e === "mainnet-alpha")
33
- return "MAINNET";
33
+ return "mainnet";
34
34
  if (e === "sepolia" || e === "sepolia-alpha")
35
- return "SEPOLIA";
35
+ return "sepolia";
36
36
  throw new Error("Invalid network id");
37
37
  }
38
38
  getAvnuUrl(e) {
@@ -63,12 +63,12 @@ class D {
63
63
  headers: {
64
64
  "Content-Type": "application/json"
65
65
  }
66
- }), o = g.safeParse(c);
66
+ }), o = v.safeParse(c);
67
67
  if (!o.success)
68
68
  throw new Error("Invalid response from paymaster");
69
69
  return o.data.transactionHash;
70
70
  }
71
71
  }
72
72
  export {
73
- D as PaymasterService
73
+ E as PaymasterService
74
74
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("url-join"),n=require("../arrays.cjs"),a=(e,t)=>{const r=new URLSearchParams(t),s=r.size?`?${r}`:"";return u(...n.ensureArray(e),s)};exports.urlWithQuery=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("url-join"),n=require("../arrays.cjs"),u=(e,t)=>{const r=new URLSearchParams(t).toString(),a=r.length?`?${r}`:"";return s(...n.ensureArray(e),a)};exports.urlWithQuery=u;
@@ -1,9 +1,9 @@
1
1
  import n from "url-join";
2
2
  import { ensureArray as s } from "../arrays.js";
3
- const m = (e, o) => {
4
- const r = new URLSearchParams(o), t = r.size ? `?${r}` : "";
5
- return n(...s(e), t);
3
+ const i = (t, a) => {
4
+ const r = new URLSearchParams(a).toString(), e = r.length ? `?${r}` : "";
5
+ return n(...s(t), e);
6
6
  };
7
7
  export {
8
- m as urlWithQuery
8
+ i as urlWithQuery
9
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@argent/x-shared",
3
- "version": "1.62.7",
3
+ "version": "1.62.9",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/argentlabs/x-shared.git"