@argent/x-shared 1.77.2 → 1.78.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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./src/features/paymaster/PaymasterService.cjs"),e=require("./src/features/paymaster/types.cjs");exports.PaymasterService=a.PaymasterService;exports.paymasterExecuteParams=e.paymasterExecuteParams;exports.paymasterExecuteResponse=e.paymasterExecuteResponse;exports.paymasterExecutionDataParams=e.paymasterExecutionDataParams;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./src/features/paymaster/PaymasterService.cjs"),e=require("./src/features/paymaster/types.cjs");exports.PaymasterService=a.PaymasterService;exports.paymasterDeployAccountParams=e.paymasterDeployAccountParams;exports.paymasterExecuteParams=e.paymasterExecuteParams;exports.paymasterExecuteResponse=e.paymasterExecuteResponse;exports.paymasterExecutionDataParams=e.paymasterExecutionDataParams;
package/dist/paymaster.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { PaymasterService as r } from "./src/features/paymaster/PaymasterService.js";
2
- import { paymasterExecuteParams as m, paymasterExecuteResponse as s, paymasterExecutionDataParams as o } from "./src/features/paymaster/types.js";
2
+ import { paymasterDeployAccountParams as m, paymasterExecuteParams as s, paymasterExecuteResponse as o, paymasterExecutionDataParams as p } from "./src/features/paymaster/types.js";
3
3
  export {
4
4
  r as PaymasterService,
5
- m as paymasterExecuteParams,
6
- s as paymasterExecuteResponse,
7
- o as paymasterExecutionDataParams
5
+ m as paymasterDeployAccountParams,
6
+ s as paymasterExecuteParams,
7
+ o as paymasterExecuteResponse,
8
+ p as paymasterExecutionDataParams
8
9
  };
@@ -1,6 +1,7 @@
1
1
  import { TypedData } from 'starknet';
2
- import { PaymasterExecutionDataParams, PaymasterExecuteParams, PaymasterOptions } from './types';
2
+ import { PaymasterExecutionDataParams, PaymasterExecuteParams, PaymasterOptions, PaymasterDeployAccountParams } from './types';
3
3
  export interface IPaymasterService {
4
4
  getExecutionData(params: PaymasterExecutionDataParams, options?: PaymasterOptions): Promise<TypedData>;
5
5
  execute(params: PaymasterExecuteParams, options?: PaymasterOptions): Promise<string>;
6
+ deployAccount(params: PaymasterDeployAccountParams, options?: PaymasterOptions): Promise<string>;
6
7
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("starknet"),h=require("url-join"),f=require("./types.cjs"),g=require("../../chains/starknet/network.cjs"),w=require("../../utils/starknet/starknet.cjs"),d=require("../../utils/url/urlWithQuery.cjs");class A{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:g.getArgentNetwork(r)}:void 0,a=n?h(this.getAvnuUrl(r),"/build-typed-data"):d.urlWithQuery([this.argentRelayerUrl,"/build-typed-data"],u),c={calls:n?e.calls.map(l=>({contractAddress:s.num.toHex(l.contractAddress),calldata:s.CallData.toCalldata(l.calldata).map(v=>s.num.toHex(v)),entrypoint:l.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(c),headers:{"Content-Type":"application/json"}}),p=w.typedDataSchema.safeParse(i);if(!p.success)throw new Error("Invalid response from paymaster");return p.data}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:g.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 y={signature:e.signature,userAddress:e.accountAddress,typedData:n?s.json.stringify(e.typedData):e.typedData,deploymentData:e.deploymentData},c=await this.httpService.post(a,{body:s.json.stringify(y),headers:{"Content-Type":"application/json"}}),i=f.paymasterExecuteResponse.safeParse(c);if(!i.success)throw new Error("Invalid response from paymaster");return i.data.transactionHash}}exports.PaymasterService=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("starknet"),p=require("url-join"),v=require("./types.cjs"),h=require("../../chains/starknet/network.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:o,isSubsidised:i}=t,{networkId:s}=e,u=s?{network:h.getArgentNetwork(s)}:void 0,r=o?p(this.getAvnuUrl(s),"/build-typed-data"):d.urlWithQuery([this.argentRelayerUrl,"/build-typed-data"],u),c={calls:o?e.calls.map(y=>({contractAddress:n.num.toHex(y.contractAddress),calldata:n.CallData.toCalldata(y.calldata).map(w=>n.num.toHex(w)),entrypoint:y.entrypoint})):e.calls,userAddress:e.accountAddress,gasTokenAddress:i?null:n.num.toHex(e.feeTokenAddress),maxGasTokenAmount:i?null:n.num.toHex(e.maxFee),accountClassHash:e.accountClassHash},a=await this.httpService.post(r,{body:n.json.stringify(c),headers:{"Content-Type":"application/json"}}),g=A.typedDataSchema.safeParse(a);if(!g.success)throw new Error("Invalid response from paymaster");return g.data}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:o,isSubsidised:i}=t,{networkId:s}=e,u=s?{network:h.getArgentNetwork(s)}:void 0;let r=o?p(this.getAvnuUrl(s),"/execute"):d.urlWithQuery([this.argentRelayerUrl,"/execute"],u);i&&(r=d.urlWithQuery(r,{isSubsidised:"true"}));const l={signature:e.signature,userAddress:e.accountAddress,typedData:o?n.json.stringify(e.typedData):e.typedData,deploymentData:e.deploymentData},c=await this.httpService.post(r,{body:n.json.stringify(l),headers:{"Content-Type":"application/json"}}),a=v.paymasterExecuteResponse.safeParse(c);if(!a.success)throw new Error("Invalid response from paymaster");return a.data.transactionHash}async deployAccount(e,t={}){const{useAvnu:o,isSubsidised:i}=t,{networkId:s}=e,u=s?{network:h.getArgentNetwork(s)}:void 0;let r=o?p(this.getAvnuUrl(s),"/execute"):d.urlWithQuery([this.argentRelayerUrl,"/execute"],u);i&&(r=d.urlWithQuery(r,{isSubsidised:"true"}));const l={userAddress:e.accountAddress,deploymentData:e.deploymentData},c=await this.httpService.post(r,{body:n.json.stringify(l),headers:{"Content-Type":"application/json"}}),a=v.paymasterExecuteResponse.safeParse(c);if(!a.success)throw new Error("Invalid response from paymaster");return a.data.transactionHash}}exports.PaymasterService=f;
@@ -1,7 +1,7 @@
1
1
  import { TypedData } from '@starknet-io/types-js';
2
2
  import { IHttpService } from '../../http';
3
3
  import { IPaymasterService } from './IPaymasterService';
4
- import { PaymasterOptions, PaymasterExecuteParams, PaymasterExecutionDataParams } from './types';
4
+ import { PaymasterDeployAccountParams, PaymasterOptions, PaymasterExecuteParams, PaymasterExecutionDataParams } from './types';
5
5
  export declare class PaymasterService implements IPaymasterService {
6
6
  private readonly argentRelayerUrl;
7
7
  private readonly httpService;
@@ -9,4 +9,5 @@ export declare class PaymasterService implements IPaymasterService {
9
9
  getExecutionData(params: PaymasterExecutionDataParams, options?: PaymasterOptions): Promise<TypedData>;
10
10
  getAvnuUrl(networkId?: string): string;
11
11
  execute(params: PaymasterExecuteParams, options?: PaymasterOptions): Promise<string>;
12
+ deployAccount(params: PaymasterDeployAccountParams, options?: PaymasterOptions): Promise<string>;
12
13
  }
@@ -1,33 +1,33 @@
1
- import { CallData as A, num as i, json as u } from "starknet";
2
- import f from "url-join";
3
- import { paymasterExecuteResponse as g } from "./types.js";
4
- import { getArgentNetwork as m } from "../../chains/starknet/network.js";
5
- import { typedDataSchema as w } from "../../utils/starknet/starknet.js";
6
- import { urlWithQuery as p } from "../../utils/url/urlWithQuery.js";
7
- class E {
1
+ import { CallData as A, num as u, json as p } from "starknet";
2
+ import h from "url-join";
3
+ import { paymasterExecuteResponse as v } from "./types.js";
4
+ import { getArgentNetwork as f } from "../../chains/starknet/network.js";
5
+ import { typedDataSchema as g } from "../../utils/starknet/starknet.js";
6
+ import { urlWithQuery as c } from "../../utils/url/urlWithQuery.js";
7
+ class U {
8
8
  constructor(e = "", t) {
9
9
  this.argentRelayerUrl = e, this.httpService = t;
10
10
  }
11
11
  async getExecutionData(e, t = {}) {
12
- const { useAvnu: r, isSubsidised: o } = t, { networkId: s } = e, d = s ? { network: m(s) } : void 0, a = r ? f(this.getAvnuUrl(s), "/build-typed-data") : p([this.argentRelayerUrl, "/build-typed-data"], d), c = {
13
- calls: r ? e.calls.map((l) => ({
14
- contractAddress: i.toHex(l.contractAddress),
15
- calldata: A.toCalldata(l.calldata).map((v) => i.toHex(v)),
16
- entrypoint: l.entrypoint
12
+ const { useAvnu: n, isSubsidised: a } = t, { networkId: s } = e, i = s ? { network: f(s) } : void 0, r = n ? h(this.getAvnuUrl(s), "/build-typed-data") : c([this.argentRelayerUrl, "/build-typed-data"], i), d = {
13
+ calls: n ? e.calls.map((y) => ({
14
+ contractAddress: u.toHex(y.contractAddress),
15
+ calldata: A.toCalldata(y.calldata).map((w) => u.toHex(w)),
16
+ entrypoint: y.entrypoint
17
17
  })) : e.calls,
18
18
  userAddress: e.accountAddress,
19
- gasTokenAddress: o ? null : i.toHex(e.feeTokenAddress),
20
- maxGasTokenAmount: o ? null : i.toHex(e.maxFee),
19
+ gasTokenAddress: a ? null : u.toHex(e.feeTokenAddress),
20
+ maxGasTokenAmount: a ? null : u.toHex(e.maxFee),
21
21
  accountClassHash: e.accountClassHash
22
- }, n = await this.httpService.post(a, {
23
- body: u.stringify(c),
22
+ }, o = await this.httpService.post(r, {
23
+ body: p.stringify(d),
24
24
  headers: {
25
25
  "Content-Type": "application/json"
26
26
  }
27
- }), h = w.safeParse(n);
28
- if (!h.success)
27
+ }), m = g.safeParse(o);
28
+ if (!m.success)
29
29
  throw new Error("Invalid response from paymaster");
30
- return h.data;
30
+ return m.data;
31
31
  }
32
32
  getAvnuUrl(e) {
33
33
  if (!e)
@@ -42,27 +42,46 @@ class E {
42
42
  return `https://${t}.api.avnu.fi/paymaster/v1`;
43
43
  }
44
44
  async execute(e, t = {}) {
45
- const { useAvnu: r, isSubsidised: o } = t, { networkId: s } = e, d = s ? { network: m(s) } : void 0;
46
- let a = r ? f(this.getAvnuUrl(s), "/execute") : p([this.argentRelayerUrl, "/execute"], d);
47
- o && (a = p(a, {
45
+ const { useAvnu: n, isSubsidised: a } = t, { networkId: s } = e, i = s ? { network: f(s) } : void 0;
46
+ let r = n ? h(this.getAvnuUrl(s), "/execute") : c([this.argentRelayerUrl, "/execute"], i);
47
+ a && (r = c(r, {
48
48
  isSubsidised: "true"
49
49
  }));
50
- const y = {
50
+ const l = {
51
51
  signature: e.signature,
52
52
  userAddress: e.accountAddress,
53
- typedData: r ? u.stringify(e.typedData) : e.typedData,
53
+ typedData: n ? p.stringify(e.typedData) : e.typedData,
54
54
  deploymentData: e.deploymentData
55
- }, c = await this.httpService.post(a, {
56
- body: u.stringify(y),
55
+ }, d = await this.httpService.post(r, {
56
+ body: p.stringify(l),
57
57
  headers: {
58
58
  "Content-Type": "application/json"
59
59
  }
60
- }), n = g.safeParse(c);
61
- if (!n.success)
60
+ }), o = v.safeParse(d);
61
+ if (!o.success)
62
62
  throw new Error("Invalid response from paymaster");
63
- return n.data.transactionHash;
63
+ return o.data.transactionHash;
64
+ }
65
+ async deployAccount(e, t = {}) {
66
+ const { useAvnu: n, isSubsidised: a } = t, { networkId: s } = e, i = s ? { network: f(s) } : void 0;
67
+ let r = n ? h(this.getAvnuUrl(s), "/execute") : c([this.argentRelayerUrl, "/execute"], i);
68
+ a && (r = c(r, {
69
+ isSubsidised: "true"
70
+ }));
71
+ const l = {
72
+ userAddress: e.accountAddress,
73
+ deploymentData: e.deploymentData
74
+ }, d = await this.httpService.post(r, {
75
+ body: p.stringify(l),
76
+ headers: {
77
+ "Content-Type": "application/json"
78
+ }
79
+ }), o = v.safeParse(d);
80
+ if (!o.success)
81
+ throw new Error("Invalid response from paymaster");
82
+ return o.data.transactionHash;
64
83
  }
65
84
  }
66
85
  export {
67
- E as PaymasterService
86
+ U as PaymasterService
68
87
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("zod"),t=require("../../chains/starknet/address.cjs"),r=require("../../utils/starknet/starknet.cjs"),e=require("../../backend/schema.cjs"),s=a.z.object({calls:a.z.array(r.callSchema),accountAddress:t.addressSchema,networkId:e.argentNetworkIdSchema.or(e.argentBackendNetworkIdSchema).optional(),feeTokenAddress:t.addressSchema,maxFee:r.bigNumberishSchema,accountClassHash:a.z.string().optional()}),o=a.z.object({signature:a.z.string().array(),accountAddress:t.addressSchema,typedData:r.typedDataSchema,networkId:e.argentNetworkIdSchema.or(e.argentBackendNetworkIdSchema).optional(),deploymentData:a.z.object({class_hash:a.z.string().optional(),salt:a.z.string().or(a.z.number()).or(a.z.bigint()).optional(),unique:a.z.string(),calldata:a.z.array(a.z.string())}).optional()}),n=a.z.object({transactionHash:a.z.string()});exports.paymasterExecuteParams=o;exports.paymasterExecuteResponse=n;exports.paymasterExecutionDataParams=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("zod"),t=require("../../chains/starknet/address.cjs"),r=require("../../utils/starknet/starknet.cjs"),e=require("../../backend/schema.cjs"),s=a.z.object({calls:a.z.array(r.callSchema),accountAddress:t.addressSchema,networkId:e.argentNetworkIdSchema.or(e.argentBackendNetworkIdSchema).optional(),feeTokenAddress:t.addressSchema,maxFee:r.bigNumberishSchema,accountClassHash:a.z.string().optional()}),o=a.z.object({signature:a.z.string().array(),accountAddress:t.addressSchema,typedData:r.typedDataSchema,networkId:e.argentNetworkIdSchema.or(e.argentBackendNetworkIdSchema).optional(),deploymentData:a.z.object({class_hash:a.z.string().optional(),salt:a.z.string().or(a.z.number()).or(a.z.bigint()).optional(),unique:a.z.string(),calldata:a.z.array(a.z.string())}).optional()}),n=a.z.object({transactionHash:a.z.string()}),c=a.z.object({accountAddress:t.addressSchema,networkId:e.argentNetworkIdSchema.or(e.argentBackendNetworkIdSchema).optional(),deploymentData:a.z.object({class_hash:a.z.string().optional(),salt:a.z.string().or(a.z.number()).or(a.z.bigint()).optional(),unique:a.z.string(),calldata:a.z.array(a.z.string())}).optional()});exports.paymasterDeployAccountParams=c;exports.paymasterExecuteParams=o;exports.paymasterExecuteResponse=n;exports.paymasterExecutionDataParams=s;
@@ -57,3 +57,20 @@ export type PaymasterOptions = {
57
57
  useAvnu?: boolean;
58
58
  isSubsidised?: boolean;
59
59
  };
60
+ export declare const paymasterDeployAccountParams: z.ZodObject<{
61
+ accountAddress: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodString>, z.ZodTransform<`0x${string}`, string>>;
62
+ networkId: z.ZodOptional<z.ZodUnion<[z.ZodEnum<{
63
+ "mainnet-alpha": "mainnet-alpha";
64
+ "sepolia-alpha": "sepolia-alpha";
65
+ }>, z.ZodEnum<{
66
+ mainnet: "mainnet";
67
+ sepolia: "sepolia";
68
+ }>]>>;
69
+ deploymentData: z.ZodOptional<z.ZodObject<{
70
+ class_hash: z.ZodOptional<z.ZodString>;
71
+ salt: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodNumber]>, z.ZodBigInt]>>;
72
+ unique: z.ZodString;
73
+ calldata: z.ZodArray<z.ZodString>;
74
+ }, z.core.$strip>>;
75
+ }, z.core.$strip>;
76
+ export type PaymasterDeployAccountParams = z.infer<typeof paymasterDeployAccountParams>;
@@ -1,19 +1,19 @@
1
1
  import { z as a } from "zod";
2
2
  import { addressSchema as t } from "../../chains/starknet/address.js";
3
- import { bigNumberishSchema as o, callSchema as s, typedDataSchema as n } from "../../utils/starknet/starknet.js";
4
- import { argentNetworkIdSchema as e, argentBackendNetworkIdSchema as r } from "../../backend/schema.js";
5
- const d = a.object({
6
- calls: a.array(s),
3
+ import { bigNumberishSchema as e, callSchema as n, typedDataSchema as s } from "../../utils/starknet/starknet.js";
4
+ import { argentNetworkIdSchema as o, argentBackendNetworkIdSchema as r } from "../../backend/schema.js";
5
+ const p = a.object({
6
+ calls: a.array(n),
7
7
  accountAddress: t,
8
- networkId: e.or(r).optional(),
8
+ networkId: o.or(r).optional(),
9
9
  feeTokenAddress: t,
10
- maxFee: o,
10
+ maxFee: e,
11
11
  accountClassHash: a.string().optional()
12
- }), l = a.object({
12
+ }), d = a.object({
13
13
  signature: a.string().array(),
14
14
  accountAddress: t,
15
- typedData: n,
16
- networkId: e.or(r).optional(),
15
+ typedData: s,
16
+ networkId: o.or(r).optional(),
17
17
  deploymentData: a.object({
18
18
  class_hash: a.string().optional(),
19
19
  salt: a.string().or(a.number()).or(a.bigint()).optional(),
@@ -22,9 +22,19 @@ const d = a.object({
22
22
  }).optional()
23
23
  }), g = a.object({
24
24
  transactionHash: a.string()
25
+ }), u = a.object({
26
+ accountAddress: t,
27
+ networkId: o.or(r).optional(),
28
+ deploymentData: a.object({
29
+ class_hash: a.string().optional(),
30
+ salt: a.string().or(a.number()).or(a.bigint()).optional(),
31
+ unique: a.string(),
32
+ calldata: a.array(a.string())
33
+ }).optional()
25
34
  });
26
35
  export {
27
- l as paymasterExecuteParams,
36
+ u as paymasterDeployAccountParams,
37
+ d as paymasterExecuteParams,
28
38
  g as paymasterExecuteResponse,
29
- d as paymasterExecutionDataParams
39
+ p as paymasterExecutionDataParams
30
40
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@argent/x-shared",
3
- "version": "1.77.2",
3
+ "version": "1.78.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/argentlabs/x-shared.git"