@argent/x-shared 1.62.2 → 1.62.4
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/paymaster/IPaymasterService.d.ts +3 -6
- package/dist/src/features/paymaster/PaymasterService.cjs +1 -1
- package/dist/src/features/paymaster/PaymasterService.d.ts +3 -6
- package/dist/src/features/paymaster/PaymasterService.js +30 -30
- package/dist/src/features/paymaster/types.d.ts +4 -0
- package/dist/src/onchainRecovery/schema.cjs +1 -1
- package/dist/src/onchainRecovery/schema.d.ts +13 -13
- package/dist/src/onchainRecovery/schema.js +14 -14
- package/package.json +1 -1
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { TypedData } from 'starknet';
|
|
2
|
-
import { PaymasterExecutionDataParams, PaymasterExecuteParams } from './types';
|
|
2
|
+
import { PaymasterExecutionDataParams, PaymasterExecuteParams, PaymasterOptions } from './types';
|
|
3
3
|
export interface IPaymasterService {
|
|
4
|
-
getExecutionData(params: PaymasterExecutionDataParams,
|
|
5
|
-
execute(params: PaymasterExecuteParams, options?:
|
|
6
|
-
useAvnu?: boolean;
|
|
7
|
-
isSubsidised?: boolean;
|
|
8
|
-
}): Promise<string>;
|
|
4
|
+
getExecutionData(params: PaymasterExecutionDataParams, options?: PaymasterOptions): Promise<TypedData>;
|
|
5
|
+
execute(params: PaymasterExecuteParams, options?: PaymasterOptions): Promise<string>;
|
|
9
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("starknet"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("starknet"),d=require("url-join"),y=require("./types.cjs"),h=require("../../utils/starknet/starknet.cjs");class f{constructor(e="",t){this.argentRelayerUrl=e,this.httpService=t}async getExecutionData(e,t={}){const{useAvnu:n,isSubsidised:a}=t,r=d(n?this.getAvnuUrl(e.networkId):this.argentRelayerUrl,"/build-typed-data"),i={calls:n?e.calls.map(c=>({contractAddress:s.num.toHex(c.contractAddress),calldata:s.CallData.toCalldata(c.calldata).map(p=>s.num.toHex(p)),entrypoint:c.entrypoint})):e.calls,userAddress:e.accountAddress,gasTokenAddress:a?null:s.num.toHex(e.feeTokenAddress),maxGasTokenAmount:a?null:s.num.toHex(e.feeTokenAddress),accountClassHash:e.accountClassHash},o=await this.httpService.post(r,{body:s.json.stringify(i),headers:{"Content-Type":"application/json"}}),u=h.typedDataSchema.safeParse(o);if(!u.success)throw new Error("Invalid response from paymaster");return u.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:a}=t;let r=d(n?this.getAvnuUrl(e.networkId):this.argentRelayerUrl,"/execute");a&&(r=d(r,"?isSubsidised=true"));const l={signature:e.signature,userAddress:e.accountAddress,typedData:n?s.json.stringify(e.typedData):e.typedData,deploymentData:e.deploymentData},i=await this.httpService.post(r,{body:s.json.stringify(l),headers:{"Content-Type":"application/json"}}),o=y.paymasterExecuteResponse.safeParse(i);if(!o.success)throw new Error("Invalid response from paymaster");return o.data.transactionHash}}exports.PaymasterService=f;
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { TypedData } from '@starknet-io/types-js';
|
|
2
2
|
import { IHttpService } from '../../http';
|
|
3
3
|
import { IPaymasterService } from './IPaymasterService';
|
|
4
|
-
import { PaymasterExecuteParams, PaymasterExecutionDataParams } from './types';
|
|
4
|
+
import { PaymasterOptions, PaymasterExecuteParams, PaymasterExecutionDataParams } from './types';
|
|
5
5
|
export declare class PaymasterService implements IPaymasterService {
|
|
6
6
|
private readonly argentRelayerUrl;
|
|
7
7
|
private readonly httpService;
|
|
8
8
|
constructor(argentRelayerUrl: string | undefined, httpService: IHttpService);
|
|
9
|
-
getExecutionData(params: PaymasterExecutionDataParams,
|
|
9
|
+
getExecutionData(params: PaymasterExecutionDataParams, options?: PaymasterOptions): Promise<TypedData>;
|
|
10
10
|
getAvnuUrl(networkId?: string): string;
|
|
11
|
-
execute(params: PaymasterExecuteParams, options?:
|
|
12
|
-
useAvnu?: boolean;
|
|
13
|
-
isSubsidised?: boolean;
|
|
14
|
-
}): Promise<string>;
|
|
11
|
+
execute(params: PaymasterExecuteParams, options?: PaymasterOptions): Promise<string>;
|
|
15
12
|
}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { CallData as
|
|
2
|
-
import
|
|
3
|
-
import { paymasterExecuteResponse as
|
|
4
|
-
import { typedDataSchema as
|
|
5
|
-
class
|
|
1
|
+
import { CallData as h, num as o, json as l } from "starknet";
|
|
2
|
+
import c from "url-join";
|
|
3
|
+
import { paymasterExecuteResponse as f } from "./types.js";
|
|
4
|
+
import { typedDataSchema as A } from "../../utils/starknet/starknet.js";
|
|
5
|
+
class b {
|
|
6
6
|
constructor(e = "", t) {
|
|
7
7
|
this.argentRelayerUrl = e, this.httpService = t;
|
|
8
8
|
}
|
|
9
|
-
async getExecutionData(e, t =
|
|
10
|
-
const r =
|
|
11
|
-
calls:
|
|
12
|
-
contractAddress: o.toHex(
|
|
13
|
-
calldata:
|
|
14
|
-
entrypoint:
|
|
9
|
+
async getExecutionData(e, t = {}) {
|
|
10
|
+
const { useAvnu: s, isSubsidised: a } = t, r = c(s ? this.getAvnuUrl(e.networkId) : this.argentRelayerUrl, "/build-typed-data"), i = {
|
|
11
|
+
calls: s ? e.calls.map((d) => ({
|
|
12
|
+
contractAddress: o.toHex(d.contractAddress),
|
|
13
|
+
calldata: h.toCalldata(d.calldata).map((y) => o.toHex(y)),
|
|
14
|
+
entrypoint: d.entrypoint
|
|
15
15
|
})) : e.calls,
|
|
16
16
|
userAddress: e.accountAddress,
|
|
17
|
-
gasTokenAddress: o.toHex(e.feeTokenAddress),
|
|
18
|
-
maxGasTokenAmount: o.toHex(e.
|
|
17
|
+
gasTokenAddress: a ? null : o.toHex(e.feeTokenAddress),
|
|
18
|
+
maxGasTokenAmount: a ? null : o.toHex(e.feeTokenAddress),
|
|
19
19
|
accountClassHash: e.accountClassHash
|
|
20
|
-
},
|
|
21
|
-
body:
|
|
20
|
+
}, n = await this.httpService.post(r, {
|
|
21
|
+
body: l.stringify(i),
|
|
22
22
|
headers: {
|
|
23
23
|
"Content-Type": "application/json"
|
|
24
24
|
}
|
|
25
|
-
}),
|
|
26
|
-
if (!
|
|
25
|
+
}), p = A.safeParse(n);
|
|
26
|
+
if (!p.success)
|
|
27
27
|
throw new Error("Invalid response from paymaster");
|
|
28
|
-
return
|
|
28
|
+
return p.data;
|
|
29
29
|
}
|
|
30
30
|
getAvnuUrl(e) {
|
|
31
31
|
if (!e)
|
|
@@ -39,26 +39,26 @@ class x {
|
|
|
39
39
|
throw new Error("Invalid network id");
|
|
40
40
|
return `https://${t}.api.avnu.fi/paymaster/v1`;
|
|
41
41
|
}
|
|
42
|
-
async execute(e, t) {
|
|
43
|
-
const { useAvnu:
|
|
44
|
-
let
|
|
45
|
-
|
|
46
|
-
const
|
|
42
|
+
async execute(e, t = {}) {
|
|
43
|
+
const { useAvnu: s, isSubsidised: a } = t;
|
|
44
|
+
let r = c(s ? this.getAvnuUrl(e.networkId) : this.argentRelayerUrl, "/execute");
|
|
45
|
+
a && (r = c(r, "?isSubsidised=true"));
|
|
46
|
+
const u = {
|
|
47
47
|
signature: e.signature,
|
|
48
48
|
userAddress: e.accountAddress,
|
|
49
|
-
typedData:
|
|
49
|
+
typedData: s ? l.stringify(e.typedData) : e.typedData,
|
|
50
50
|
deploymentData: e.deploymentData
|
|
51
|
-
},
|
|
52
|
-
body:
|
|
51
|
+
}, i = await this.httpService.post(r, {
|
|
52
|
+
body: l.stringify(u),
|
|
53
53
|
headers: {
|
|
54
54
|
"Content-Type": "application/json"
|
|
55
55
|
}
|
|
56
|
-
}),
|
|
57
|
-
if (!
|
|
56
|
+
}), n = f.safeParse(i);
|
|
57
|
+
if (!n.success)
|
|
58
58
|
throw new Error("Invalid response from paymaster");
|
|
59
|
-
return
|
|
59
|
+
return n.data.transactionHash;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
export {
|
|
63
|
-
|
|
63
|
+
b as PaymasterService
|
|
64
64
|
};
|
|
@@ -177,3 +177,7 @@ export declare const paymasterExecuteResponse: z.ZodObject<{
|
|
|
177
177
|
transactionHash: string;
|
|
178
178
|
}>;
|
|
179
179
|
export type PaymasterExecuteResponse = z.infer<typeof paymasterExecuteResponse>;
|
|
180
|
+
export type PaymasterOptions = {
|
|
181
|
+
useAvnu?: boolean;
|
|
182
|
+
isSubsidised?: boolean;
|
|
183
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("zod"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("zod"),a=require("../chains/starknet/address.cjs"),c=require("../utils/hex.cjs");exports.RecoveryStatusEnum=void 0;(function(r){r.NOT_STARTED="NOT_STARTED",r.ONGOING="ONGOING",r.AWAITING_FUNDS="AWAITING_FUNDS",r.AWAITING_COMPLETION="AWAITING_COMPLETION",r.COMPLETED="COMPLETED",r.CANCELLED="CANCELLED",r.ERROR="ERROR"})(exports.RecoveryStatusEnum||(exports.RecoveryStatusEnum={}));const i=e.z.object({recoveryId:e.z.number()}),s=e.z.object({feeToken:a.addressSchema,signerSignature:e.z.object({type:e.z.literal("StarknetKey"),signer:e.z.object({publicKey:c.hexSchema,r:c.hexSchema,s:c.hexSchema})})}),t=e.z.nativeEnum(exports.RecoveryStatusEnum),o=e.z.object({recoveryId:e.z.number(),status:t,completionTime:e.z.string().optional()}),h=e.z.object({activeRecovery:o.optional().or(e.z.null()).optional(),minFees:e.z.record(e.z.number()).optional()}),S=e.z.object({recovery:o.optional().or(e.z.null()).optional(),minFees:e.z.record(e.z.number()).optional()});exports.StartOnchainRecoveryErrorStatusEnum=void 0;(function(r){r.UNDEPLOYED_ACCOUNT="undeployedAccount",r.NOT_ENOUGH_TO_PAY_FEES="notEnoughToPayFees",r.RECOVERY_ALREADY_EXISTS="recoveryAlreadyExists"})(exports.StartOnchainRecoveryErrorStatusEnum||(exports.StartOnchainRecoveryErrorStatusEnum={}));const n=e.z.nativeEnum(exports.StartOnchainRecoveryErrorStatusEnum),E=e.z.object({status:n});exports.activeOnchainRecoverySchema=h;exports.onchainRecoverySchema=S;exports.recoveryBaseSchema=o;exports.recoveryBodySchema=s;exports.recoveryStatusSchema=t;exports.startOnchainRecoveryErrorSchema=E;exports.startOnchainRecoveryErrorStatusSchema=n;exports.startOnchainRecoverySchema=i;
|
|
@@ -72,43 +72,43 @@ export declare const recoveryStatusSchema: z.ZodNativeEnum<typeof RecoveryStatus
|
|
|
72
72
|
export declare const recoveryBaseSchema: z.ZodObject<{
|
|
73
73
|
recoveryId: z.ZodNumber;
|
|
74
74
|
status: z.ZodNativeEnum<typeof RecoveryStatusEnum>;
|
|
75
|
-
completionTime: z.ZodOptional<z.
|
|
75
|
+
completionTime: z.ZodOptional<z.ZodString>;
|
|
76
76
|
}, "strip", z.ZodTypeAny, {
|
|
77
77
|
status: RecoveryStatusEnum;
|
|
78
78
|
recoveryId: number;
|
|
79
|
-
completionTime?:
|
|
79
|
+
completionTime?: string | undefined;
|
|
80
80
|
}, {
|
|
81
81
|
status: RecoveryStatusEnum;
|
|
82
82
|
recoveryId: number;
|
|
83
|
-
completionTime?:
|
|
83
|
+
completionTime?: string | undefined;
|
|
84
84
|
}>;
|
|
85
85
|
export declare const activeOnchainRecoverySchema: z.ZodObject<{
|
|
86
86
|
activeRecovery: z.ZodOptional<z.ZodUnion<[z.ZodOptional<z.ZodObject<{
|
|
87
87
|
recoveryId: z.ZodNumber;
|
|
88
88
|
status: z.ZodNativeEnum<typeof RecoveryStatusEnum>;
|
|
89
|
-
completionTime: z.ZodOptional<z.
|
|
89
|
+
completionTime: z.ZodOptional<z.ZodString>;
|
|
90
90
|
}, "strip", z.ZodTypeAny, {
|
|
91
91
|
status: RecoveryStatusEnum;
|
|
92
92
|
recoveryId: number;
|
|
93
|
-
completionTime?:
|
|
93
|
+
completionTime?: string | undefined;
|
|
94
94
|
}, {
|
|
95
95
|
status: RecoveryStatusEnum;
|
|
96
96
|
recoveryId: number;
|
|
97
|
-
completionTime?:
|
|
97
|
+
completionTime?: string | undefined;
|
|
98
98
|
}>>, z.ZodNull]>>;
|
|
99
99
|
minFees: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
100
100
|
}, "strip", z.ZodTypeAny, {
|
|
101
101
|
activeRecovery?: {
|
|
102
102
|
status: RecoveryStatusEnum;
|
|
103
103
|
recoveryId: number;
|
|
104
|
-
completionTime?:
|
|
104
|
+
completionTime?: string | undefined;
|
|
105
105
|
} | null | undefined;
|
|
106
106
|
minFees?: Record<string, number> | undefined;
|
|
107
107
|
}, {
|
|
108
108
|
activeRecovery?: {
|
|
109
109
|
status: RecoveryStatusEnum;
|
|
110
110
|
recoveryId: number;
|
|
111
|
-
completionTime?:
|
|
111
|
+
completionTime?: string | undefined;
|
|
112
112
|
} | null | undefined;
|
|
113
113
|
minFees?: Record<string, number> | undefined;
|
|
114
114
|
}>;
|
|
@@ -116,15 +116,15 @@ export declare const onchainRecoverySchema: z.ZodObject<{
|
|
|
116
116
|
recovery: z.ZodOptional<z.ZodUnion<[z.ZodOptional<z.ZodObject<{
|
|
117
117
|
recoveryId: z.ZodNumber;
|
|
118
118
|
status: z.ZodNativeEnum<typeof RecoveryStatusEnum>;
|
|
119
|
-
completionTime: z.ZodOptional<z.
|
|
119
|
+
completionTime: z.ZodOptional<z.ZodString>;
|
|
120
120
|
}, "strip", z.ZodTypeAny, {
|
|
121
121
|
status: RecoveryStatusEnum;
|
|
122
122
|
recoveryId: number;
|
|
123
|
-
completionTime?:
|
|
123
|
+
completionTime?: string | undefined;
|
|
124
124
|
}, {
|
|
125
125
|
status: RecoveryStatusEnum;
|
|
126
126
|
recoveryId: number;
|
|
127
|
-
completionTime?:
|
|
127
|
+
completionTime?: string | undefined;
|
|
128
128
|
}>>, z.ZodNull]>>;
|
|
129
129
|
minFees: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
130
130
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -132,14 +132,14 @@ export declare const onchainRecoverySchema: z.ZodObject<{
|
|
|
132
132
|
recovery?: {
|
|
133
133
|
status: RecoveryStatusEnum;
|
|
134
134
|
recoveryId: number;
|
|
135
|
-
completionTime?:
|
|
135
|
+
completionTime?: string | undefined;
|
|
136
136
|
} | null | undefined;
|
|
137
137
|
}, {
|
|
138
138
|
minFees?: Record<string, number> | undefined;
|
|
139
139
|
recovery?: {
|
|
140
140
|
status: RecoveryStatusEnum;
|
|
141
141
|
recoveryId: number;
|
|
142
|
-
completionTime?:
|
|
142
|
+
completionTime?: string | undefined;
|
|
143
143
|
} | null | undefined;
|
|
144
144
|
}>;
|
|
145
145
|
export declare enum StartOnchainRecoveryErrorStatusEnum {
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { z as e } from "zod";
|
|
2
2
|
import { addressSchema as a } from "../chains/starknet/address.js";
|
|
3
|
-
import { hexSchema as
|
|
4
|
-
var
|
|
3
|
+
import { hexSchema as c } from "../utils/hex.js";
|
|
4
|
+
var r;
|
|
5
5
|
(function(o) {
|
|
6
6
|
o.NOT_STARTED = "NOT_STARTED", o.ONGOING = "ONGOING", o.AWAITING_FUNDS = "AWAITING_FUNDS", o.AWAITING_COMPLETION = "AWAITING_COMPLETION", o.COMPLETED = "COMPLETED", o.CANCELLED = "CANCELLED", o.ERROR = "ERROR";
|
|
7
|
-
})(
|
|
8
|
-
const
|
|
7
|
+
})(r || (r = {}));
|
|
8
|
+
const m = e.object({
|
|
9
9
|
recoveryId: e.number()
|
|
10
10
|
}), N = e.object({
|
|
11
11
|
feeToken: a,
|
|
12
12
|
signerSignature: e.object({
|
|
13
13
|
type: e.literal("StarknetKey"),
|
|
14
14
|
signer: e.object({
|
|
15
|
-
publicKey:
|
|
16
|
-
r,
|
|
17
|
-
s:
|
|
15
|
+
publicKey: c,
|
|
16
|
+
r: c,
|
|
17
|
+
s: c
|
|
18
18
|
})
|
|
19
19
|
})
|
|
20
|
-
}), i = e.nativeEnum(
|
|
20
|
+
}), i = e.nativeEnum(r), t = e.object({
|
|
21
21
|
recoveryId: e.number(),
|
|
22
22
|
status: i,
|
|
23
|
-
completionTime: e.
|
|
23
|
+
completionTime: e.string().optional()
|
|
24
24
|
}), A = e.object({
|
|
25
25
|
activeRecovery: t.optional().or(e.null()).optional(),
|
|
26
26
|
minFees: e.record(e.number()).optional()
|
|
@@ -32,11 +32,11 @@ var n;
|
|
|
32
32
|
(function(o) {
|
|
33
33
|
o.UNDEPLOYED_ACCOUNT = "undeployedAccount", o.NOT_ENOUGH_TO_PAY_FEES = "notEnoughToPayFees", o.RECOVERY_ALREADY_EXISTS = "recoveryAlreadyExists";
|
|
34
34
|
})(n || (n = {}));
|
|
35
|
-
const
|
|
36
|
-
status:
|
|
35
|
+
const s = e.nativeEnum(n), h = e.object({
|
|
36
|
+
status: s
|
|
37
37
|
});
|
|
38
38
|
export {
|
|
39
|
-
|
|
39
|
+
r as RecoveryStatusEnum,
|
|
40
40
|
n as StartOnchainRecoveryErrorStatusEnum,
|
|
41
41
|
A as activeOnchainRecoverySchema,
|
|
42
42
|
l as onchainRecoverySchema,
|
|
@@ -44,6 +44,6 @@ export {
|
|
|
44
44
|
N as recoveryBodySchema,
|
|
45
45
|
i as recoveryStatusSchema,
|
|
46
46
|
h as startOnchainRecoveryErrorSchema,
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
s as startOnchainRecoveryErrorStatusSchema,
|
|
48
|
+
m as startOnchainRecoverySchema
|
|
49
49
|
};
|