@cartridge/controller-wasm 0.7.14-3d082f2 → 0.7.14-4ec2e4fc
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/package.json +7 -4
- package/pkg-controller/account_wasm.d.ts +382 -330
- package/pkg-controller/account_wasm.js +7 -2
- package/pkg-controller/account_wasm_bg.js +1274 -1353
- package/pkg-controller/account_wasm_bg.wasm +0 -0
- package/pkg-session/session_wasm.d.ts +205 -165
- package/pkg-session/session_wasm.js +7 -2
- package/pkg-session/session_wasm_bg.js +842 -940
- package/pkg-session/session_wasm_bg.wasm +0 -0
|
@@ -1,123 +1,5 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
/**
|
|
4
|
-
* Computes the Starknet contract address for a controller account without needing a full instance.
|
|
5
|
-
*
|
|
6
|
-
* # Arguments
|
|
7
|
-
*
|
|
8
|
-
* * `class_hash` - The class hash of the account contract (JsFelt).
|
|
9
|
-
* * `owner` - The owner configuration for the account.
|
|
10
|
-
* * `salt` - The salt used for address calculation (JsFelt).
|
|
11
|
-
*
|
|
12
|
-
* # Returns
|
|
13
|
-
*
|
|
14
|
-
* The computed Starknet contract address as a `JsFelt`.
|
|
15
|
-
*/
|
|
16
|
-
export function computeAccountAddress(class_hash: JsFelt, owner: Owner, salt: JsFelt): JsFelt;
|
|
17
|
-
/**
|
|
18
|
-
* Subscribes to the creation of a session for a given controller, session_key_guid and cartridge api url.
|
|
19
|
-
* The goal of this function is to know from any place when the register session flow has been completed, and to
|
|
20
|
-
* get the authorization.
|
|
21
|
-
*/
|
|
22
|
-
export function subscribeCreateSession(session_key_guid: JsFelt, cartridge_api_url: string): Promise<JsSubscribeSessionResult>;
|
|
23
|
-
export function signerToGuid(signer: Signer): JsFelt;
|
|
24
|
-
export enum ErrorCode {
|
|
25
|
-
StarknetFailedToReceiveTransaction = 1,
|
|
26
|
-
StarknetContractNotFound = 20,
|
|
27
|
-
StarknetBlockNotFound = 24,
|
|
28
|
-
StarknetInvalidTransactionIndex = 27,
|
|
29
|
-
StarknetClassHashNotFound = 28,
|
|
30
|
-
StarknetTransactionHashNotFound = 29,
|
|
31
|
-
StarknetPageSizeTooBig = 31,
|
|
32
|
-
StarknetNoBlocks = 32,
|
|
33
|
-
StarknetInvalidContinuationToken = 33,
|
|
34
|
-
StarknetTooManyKeysInFilter = 34,
|
|
35
|
-
StarknetContractError = 40,
|
|
36
|
-
StarknetTransactionExecutionError = 41,
|
|
37
|
-
StarknetClassAlreadyDeclared = 51,
|
|
38
|
-
StarknetInvalidTransactionNonce = 52,
|
|
39
|
-
StarknetInsufficientMaxFee = 53,
|
|
40
|
-
StarknetInsufficientAccountBalance = 54,
|
|
41
|
-
StarknetValidationFailure = 55,
|
|
42
|
-
StarknetCompilationFailed = 56,
|
|
43
|
-
StarknetContractClassSizeIsTooLarge = 57,
|
|
44
|
-
StarknetNonAccount = 58,
|
|
45
|
-
StarknetDuplicateTx = 59,
|
|
46
|
-
StarknetCompiledClassHashMismatch = 60,
|
|
47
|
-
StarknetUnsupportedTxVersion = 61,
|
|
48
|
-
StarknetUnsupportedContractClassVersion = 62,
|
|
49
|
-
StarknetUnexpectedError = 63,
|
|
50
|
-
StarknetNoTraceAvailable = 10,
|
|
51
|
-
StarknetReplacementTransactionUnderpriced = 64,
|
|
52
|
-
StarknetFeeBelowMinimum = 65,
|
|
53
|
-
SignError = 101,
|
|
54
|
-
StorageError = 102,
|
|
55
|
-
AccountFactoryError = 103,
|
|
56
|
-
PaymasterExecutionTimeNotReached = 104,
|
|
57
|
-
PaymasterExecutionTimePassed = 105,
|
|
58
|
-
PaymasterInvalidCaller = 106,
|
|
59
|
-
PaymasterRateLimitExceeded = 107,
|
|
60
|
-
PaymasterNotSupported = 108,
|
|
61
|
-
PaymasterHttp = 109,
|
|
62
|
-
PaymasterExcecution = 110,
|
|
63
|
-
PaymasterSerialization = 111,
|
|
64
|
-
CartridgeControllerNotDeployed = 112,
|
|
65
|
-
InsufficientBalance = 113,
|
|
66
|
-
OriginError = 114,
|
|
67
|
-
EncodingError = 115,
|
|
68
|
-
SerdeWasmBindgenError = 116,
|
|
69
|
-
CairoSerdeError = 117,
|
|
70
|
-
CairoShortStringToFeltError = 118,
|
|
71
|
-
DeviceCreateCredential = 119,
|
|
72
|
-
DeviceGetAssertion = 120,
|
|
73
|
-
DeviceBadAssertion = 121,
|
|
74
|
-
DeviceChannel = 122,
|
|
75
|
-
DeviceOrigin = 123,
|
|
76
|
-
AccountSigning = 124,
|
|
77
|
-
AccountProvider = 125,
|
|
78
|
-
AccountClassHashCalculation = 126,
|
|
79
|
-
AccountFeeOutOfRange = 128,
|
|
80
|
-
ProviderRateLimited = 129,
|
|
81
|
-
ProviderArrayLengthMismatch = 130,
|
|
82
|
-
ProviderOther = 131,
|
|
83
|
-
SessionAlreadyRegistered = 132,
|
|
84
|
-
UrlParseError = 133,
|
|
85
|
-
Base64DecodeError = 134,
|
|
86
|
-
CoseError = 135,
|
|
87
|
-
PolicyChainIdMismatch = 136,
|
|
88
|
-
InvalidOwner = 137,
|
|
89
|
-
GasPriceTooHigh = 138,
|
|
90
|
-
TransactionTimeout = 139,
|
|
91
|
-
ConversionError = 140,
|
|
92
|
-
InvalidChainId = 141,
|
|
93
|
-
SessionRefreshRequired = 142,
|
|
94
|
-
ManualExecutionRequired = 143,
|
|
95
|
-
ForbiddenEntrypoint = 144,
|
|
96
|
-
GasAmountTooHigh = 145,
|
|
97
|
-
ApproveExecutionRequired = 146,
|
|
98
|
-
}
|
|
99
|
-
export interface JsCall {
|
|
100
|
-
contractAddress: JsFelt;
|
|
101
|
-
entrypoint: string;
|
|
102
|
-
calldata: JsFelt[];
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export type JsPriceUnit = "WEI" | "FRI";
|
|
106
|
-
|
|
107
|
-
export interface JsEstimateFeeDetails {
|
|
108
|
-
nonce: JsFelt;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export interface JsFeeEstimate {
|
|
112
|
-
l1_gas_consumed: number;
|
|
113
|
-
l1_gas_price: number;
|
|
114
|
-
l2_gas_consumed: number;
|
|
115
|
-
l2_gas_price: number;
|
|
116
|
-
l1_data_gas_consumed: number;
|
|
117
|
-
l1_data_gas_price: number;
|
|
118
|
-
overall_fee: number;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
3
|
/**
|
|
122
4
|
* JavaScript-friendly OutsideExecution V3 structure
|
|
123
5
|
*/
|
|
@@ -137,9 +19,21 @@ export interface JsSignedOutsideExecution {
|
|
|
137
19
|
signature: JsFelt[];
|
|
138
20
|
}
|
|
139
21
|
|
|
140
|
-
export interface
|
|
141
|
-
|
|
142
|
-
|
|
22
|
+
export interface ApprovalPolicy {
|
|
23
|
+
target: JsFelt;
|
|
24
|
+
spender: JsFelt;
|
|
25
|
+
amount: JsFelt;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface AuthorizedSession {
|
|
29
|
+
session: Session;
|
|
30
|
+
authorization: JsFelt[] | null;
|
|
31
|
+
isRegistered: boolean;
|
|
32
|
+
expiresAt: number;
|
|
33
|
+
allowedPoliciesRoot: JsFelt;
|
|
34
|
+
metadataHash: JsFelt;
|
|
35
|
+
sessionKeyGuid: JsFelt;
|
|
36
|
+
guardianKeyGuid: JsFelt;
|
|
143
37
|
}
|
|
144
38
|
|
|
145
39
|
export interface CallPolicy {
|
|
@@ -148,35 +42,81 @@ export interface CallPolicy {
|
|
|
148
42
|
authorized?: boolean;
|
|
149
43
|
}
|
|
150
44
|
|
|
151
|
-
export interface
|
|
152
|
-
|
|
153
|
-
|
|
45
|
+
export interface Credentials {
|
|
46
|
+
authorization: JsFelt[];
|
|
47
|
+
privateKey: JsFelt;
|
|
154
48
|
}
|
|
155
49
|
|
|
156
|
-
export interface
|
|
157
|
-
|
|
158
|
-
spender: JsFelt;
|
|
159
|
-
amount: JsFelt;
|
|
50
|
+
export interface Eip191Signer {
|
|
51
|
+
address: string;
|
|
160
52
|
}
|
|
161
53
|
|
|
162
|
-
export
|
|
54
|
+
export interface ImportedControllerMetadata {
|
|
55
|
+
username: string;
|
|
56
|
+
classHash: JsFelt;
|
|
57
|
+
rpcUrl: string;
|
|
58
|
+
salt: JsFelt;
|
|
59
|
+
owner: Owner;
|
|
60
|
+
address: JsFelt;
|
|
61
|
+
chainId: JsFelt;
|
|
62
|
+
}
|
|
163
63
|
|
|
164
|
-
export
|
|
64
|
+
export interface ImportedProvedPolicy {
|
|
65
|
+
policy: Policy;
|
|
66
|
+
proof: JsFelt[];
|
|
67
|
+
}
|
|
165
68
|
|
|
166
|
-
export
|
|
69
|
+
export interface ImportedSession {
|
|
70
|
+
requestedPolicies: Policy[];
|
|
71
|
+
provedPolicies: ImportedProvedPolicy[];
|
|
72
|
+
expiresAt: number;
|
|
73
|
+
allowedPoliciesRoot: JsFelt;
|
|
74
|
+
metadataHash: JsFelt;
|
|
75
|
+
sessionKeyGuid: JsFelt;
|
|
76
|
+
guardianKeyGuid: JsFelt;
|
|
77
|
+
metadata: string;
|
|
78
|
+
}
|
|
167
79
|
|
|
168
|
-
export interface
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
80
|
+
export interface ImportedSessionMetadata {
|
|
81
|
+
session: ImportedSession;
|
|
82
|
+
maxFee?: JsFelt;
|
|
83
|
+
credentials?: Credentials;
|
|
84
|
+
isRegistered: boolean;
|
|
85
|
+
appId?: string;
|
|
86
|
+
policies?: Policy[];
|
|
172
87
|
}
|
|
173
88
|
|
|
174
|
-
export interface
|
|
175
|
-
|
|
89
|
+
export interface JsCall {
|
|
90
|
+
contractAddress: JsFelt;
|
|
91
|
+
entrypoint: string;
|
|
92
|
+
calldata: JsFelt[];
|
|
176
93
|
}
|
|
177
94
|
|
|
178
|
-
export interface
|
|
179
|
-
|
|
95
|
+
export interface JsEstimateFeeDetails {
|
|
96
|
+
nonce: JsFelt;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface JsFeeEstimate {
|
|
100
|
+
l1_gas_consumed: number;
|
|
101
|
+
l1_gas_price: number;
|
|
102
|
+
l2_gas_consumed: number;
|
|
103
|
+
l2_gas_price: number;
|
|
104
|
+
l1_data_gas_consumed: number;
|
|
105
|
+
l1_data_gas_price: number;
|
|
106
|
+
overall_fee: number;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface Owner {
|
|
110
|
+
signer?: Signer;
|
|
111
|
+
account?: JsFelt;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface Session {
|
|
115
|
+
policies: Policy[];
|
|
116
|
+
expiresAt: number;
|
|
117
|
+
metadataHash: JsFelt;
|
|
118
|
+
sessionKeyGuid: JsFelt;
|
|
119
|
+
guardianKeyGuid: JsFelt;
|
|
180
120
|
}
|
|
181
121
|
|
|
182
122
|
export interface Signer {
|
|
@@ -186,114 +126,118 @@ export interface Signer {
|
|
|
186
126
|
eip191?: Eip191Signer;
|
|
187
127
|
}
|
|
188
128
|
|
|
189
|
-
export
|
|
129
|
+
export interface StarknetSigner {
|
|
130
|
+
privateKey: JsFelt;
|
|
131
|
+
}
|
|
190
132
|
|
|
191
|
-
export
|
|
133
|
+
export interface TypedDataPolicy {
|
|
134
|
+
scope_hash: JsFelt;
|
|
135
|
+
authorized?: boolean;
|
|
136
|
+
}
|
|
192
137
|
|
|
193
|
-
export
|
|
138
|
+
export interface WebauthnSigner {
|
|
139
|
+
rpId: string;
|
|
140
|
+
credentialId: string;
|
|
141
|
+
publicKey: string;
|
|
142
|
+
}
|
|
194
143
|
|
|
195
144
|
export type Felts = JsFelt[];
|
|
196
145
|
|
|
146
|
+
export type JsAddSignerInput = SignerInput;
|
|
147
|
+
|
|
197
148
|
export type JsFeeSource = "PAYMASTER" | "CREDITS";
|
|
198
149
|
|
|
199
|
-
export type
|
|
150
|
+
export type JsFelt = Felt;
|
|
151
|
+
|
|
152
|
+
export type JsPriceUnit = "WEI" | "FRI";
|
|
153
|
+
|
|
154
|
+
export type JsRegister = RegisterInput;
|
|
155
|
+
|
|
156
|
+
export type JsRegisterResponse = ResponseData;
|
|
157
|
+
|
|
158
|
+
export type JsRemoveSignerInput = SignerInput;
|
|
200
159
|
|
|
201
160
|
export type JsRevokableSession = RevokableSession;
|
|
202
161
|
|
|
203
|
-
export
|
|
204
|
-
session: Session;
|
|
205
|
-
authorization: JsFelt[] | null;
|
|
206
|
-
isRegistered: boolean;
|
|
207
|
-
expiresAt: number;
|
|
208
|
-
allowedPoliciesRoot: JsFelt;
|
|
209
|
-
metadataHash: JsFelt;
|
|
210
|
-
sessionKeyGuid: JsFelt;
|
|
211
|
-
guardianKeyGuid: JsFelt;
|
|
212
|
-
}
|
|
162
|
+
export type JsSubscribeSessionResult = SubscribeCreateSessionSubscribeCreateSession;
|
|
213
163
|
|
|
214
|
-
export
|
|
215
|
-
policies: Policy[];
|
|
216
|
-
expiresAt: number;
|
|
217
|
-
metadataHash: JsFelt;
|
|
218
|
-
sessionKeyGuid: JsFelt;
|
|
219
|
-
guardianKeyGuid: JsFelt;
|
|
220
|
-
}
|
|
164
|
+
export type Policy = CallPolicy | TypedDataPolicy | ApprovalPolicy;
|
|
221
165
|
|
|
222
|
-
export interface Credentials {
|
|
223
|
-
authorization: JsFelt[];
|
|
224
|
-
privateKey: JsFelt;
|
|
225
|
-
}
|
|
226
166
|
|
|
227
167
|
export class CartridgeAccount {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
168
|
+
private constructor();
|
|
169
|
+
free(): void;
|
|
170
|
+
[Symbol.dispose](): void;
|
|
171
|
+
addOwner(owner?: Signer | null, signer_input?: JsAddSignerInput | null, rp_id?: string | null): Promise<void>;
|
|
172
|
+
createPasskeySigner(rp_id: string): Promise<JsAddSignerInput>;
|
|
173
|
+
createSession(app_id: string, policies: Policy[], expires_at: bigint, authorize_user_execution?: boolean | null): Promise<AuthorizedSession | undefined>;
|
|
174
|
+
delegateAccount(): Promise<JsFelt>;
|
|
175
|
+
deploySelf(max_fee?: JsFeeEstimate | null): Promise<any>;
|
|
176
|
+
disconnect(): Promise<void>;
|
|
177
|
+
estimateInvokeFee(calls: JsCall[]): Promise<JsFeeEstimate>;
|
|
178
|
+
execute(calls: JsCall[], max_fee?: JsFeeEstimate | null, fee_source?: JsFeeSource | null): Promise<any>;
|
|
179
|
+
executeFromOutsideV2(calls: JsCall[], fee_source?: JsFeeSource | null): Promise<any>;
|
|
180
|
+
executeFromOutsideV3(calls: JsCall[], fee_source?: JsFeeSource | null): Promise<any>;
|
|
181
|
+
exportAuthorizedSession(app_id?: string | null): Promise<ImportedSessionMetadata | undefined>;
|
|
182
|
+
exportMetadata(): Promise<ImportedControllerMetadata>;
|
|
183
|
+
static fromStorage(cartridge_api_url: string): Promise<CartridgeAccountWithMeta | undefined>;
|
|
184
|
+
getNonce(): Promise<any>;
|
|
185
|
+
hasAuthorizedPoliciesForCalls(app_id: string, calls: JsCall[]): Promise<boolean>;
|
|
186
|
+
hasAuthorizedPoliciesForMessage(app_id: string, typed_data: string): Promise<boolean>;
|
|
187
|
+
/**
|
|
188
|
+
* Checks if there are stored policies for a given app_id.
|
|
189
|
+
*
|
|
190
|
+
* # Parameters
|
|
191
|
+
* - `app_id`: The application identifier to check for stored policies
|
|
192
|
+
*
|
|
193
|
+
* # Returns
|
|
194
|
+
* `true` if policies exist for the given app_id, `false` otherwise
|
|
195
|
+
*/
|
|
196
|
+
hasPoliciesForAppId(app_id: string): Promise<boolean>;
|
|
197
|
+
hasRequestedSession(app_id: string, policies: Policy[]): Promise<boolean>;
|
|
198
|
+
importSession(imported_session: ImportedSessionMetadata): Promise<void>;
|
|
199
|
+
isRegisteredSessionAuthorized(policies: Policy[], public_key?: JsFelt | null): Promise<AuthorizedSession | undefined>;
|
|
200
|
+
/**
|
|
201
|
+
* Creates a new `CartridgeAccount` instance.
|
|
202
|
+
*
|
|
203
|
+
* # Parameters
|
|
204
|
+
* - `rpc_url`: The URL of the JSON-RPC endpoint.
|
|
205
|
+
* - `address`: The blockchain address associated with the account.
|
|
206
|
+
* - `username`: Username associated with the account.
|
|
207
|
+
* - `owner`: A Owner struct containing the owner signer and associated data.
|
|
208
|
+
*/
|
|
209
|
+
static new(class_hash: JsFelt, rpc_url: string, address: JsFelt, username: string, owner: Owner, cartridge_api_url: string): Promise<CartridgeAccountWithMeta>;
|
|
210
|
+
/**
|
|
211
|
+
* Creates a new `CartridgeAccount` instance with a randomly generated Starknet signer.
|
|
212
|
+
* The controller address is computed internally based on the generated signer.
|
|
213
|
+
*
|
|
214
|
+
* # Parameters
|
|
215
|
+
* - `rpc_url`: The URL of the JSON-RPC endpoint.
|
|
216
|
+
* - `username`: Username associated with the account.
|
|
217
|
+
*/
|
|
218
|
+
static newHeadless(class_hash: JsFelt, rpc_url: string, username: string, cartridge_api_url: string): Promise<CartridgeAccountWithMeta>;
|
|
219
|
+
register(register: JsRegister): Promise<JsRegisterResponse>;
|
|
220
|
+
registerSession(app_id: string, policies: Policy[], expires_at: bigint, public_key: JsFelt, max_fee?: JsFeeEstimate | null): Promise<any>;
|
|
221
|
+
registerSessionCalldata(policies: Policy[], expires_at: bigint, public_key: JsFelt): Promise<any>;
|
|
222
|
+
removeOwner(signer: JsRemoveSignerInput): Promise<void>;
|
|
223
|
+
revokeSession(session: JsRevokableSession): Promise<void>;
|
|
224
|
+
revokeSessions(sessions: JsRevokableSession[]): Promise<void>;
|
|
225
|
+
/**
|
|
226
|
+
* Signs an OutsideExecution V3 transaction and returns both the OutsideExecution object and its signature.
|
|
227
|
+
*
|
|
228
|
+
* # Parameters
|
|
229
|
+
* - `calls`: Array of calls to execute from outside
|
|
230
|
+
*
|
|
231
|
+
* # Returns
|
|
232
|
+
* A `JsSignedOutsideExecution` containing the OutsideExecution V3 object and its signature
|
|
233
|
+
*/
|
|
234
|
+
signExecuteFromOutside(calls: JsCall[]): Promise<JsSignedOutsideExecution>;
|
|
235
|
+
signMessage(typed_data: string): Promise<Felts>;
|
|
236
|
+
skipSession(app_id: string, policies: Policy[]): Promise<void>;
|
|
237
|
+
trySessionExecute(app_id: string, calls: JsCall[], fee_source?: JsFeeSource | null): Promise<any>;
|
|
238
|
+
upgrade(new_class_hash: JsFelt): Promise<JsCall>;
|
|
296
239
|
}
|
|
240
|
+
|
|
297
241
|
/**
|
|
298
242
|
* A type for accessing fixed attributes of `CartridgeAccount`.
|
|
299
243
|
*
|
|
@@ -308,17 +252,18 @@ export class CartridgeAccount {
|
|
|
308
252
|
* be needed.
|
|
309
253
|
*/
|
|
310
254
|
export class CartridgeAccountMeta {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
255
|
+
private constructor();
|
|
256
|
+
free(): void;
|
|
257
|
+
[Symbol.dispose](): void;
|
|
258
|
+
address(): string;
|
|
259
|
+
chainId(): string;
|
|
260
|
+
classHash(): string;
|
|
261
|
+
owner(): Owner;
|
|
262
|
+
ownerGuid(): JsFelt;
|
|
263
|
+
rpcUrl(): string;
|
|
264
|
+
username(): string;
|
|
321
265
|
}
|
|
266
|
+
|
|
322
267
|
/**
|
|
323
268
|
* A type used as the return type for constructing `CartridgeAccount` to provide an extra,
|
|
324
269
|
* separately borrowable `meta` field for synchronously accessing fixed fields.
|
|
@@ -327,113 +272,220 @@ export class CartridgeAccountMeta {
|
|
|
327
272
|
* don't implement `IntoWasmAbi` which is needed for crossing JS-WASM boundary.
|
|
328
273
|
*/
|
|
329
274
|
export class CartridgeAccountWithMeta {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
275
|
+
private constructor();
|
|
276
|
+
free(): void;
|
|
277
|
+
[Symbol.dispose](): void;
|
|
278
|
+
intoAccount(): CartridgeAccount;
|
|
279
|
+
meta(): CartridgeAccountMeta;
|
|
335
280
|
}
|
|
281
|
+
|
|
336
282
|
export class ControllerFactory {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
283
|
+
private constructor();
|
|
284
|
+
free(): void;
|
|
285
|
+
[Symbol.dispose](): void;
|
|
286
|
+
/**
|
|
287
|
+
* This should only be used with webauthn signers
|
|
288
|
+
*/
|
|
289
|
+
static apiLogin(username: string, class_hash: JsFelt, rpc_url: string, address: JsFelt, owner: Owner, cartridge_api_url: string): Promise<CartridgeAccountWithMeta>;
|
|
290
|
+
static fromMetadata(metadata: ImportedControllerMetadata, cartridge_api_url: string): Promise<CartridgeAccountWithMeta>;
|
|
291
|
+
static fromStorage(cartridge_api_url: string): Promise<CartridgeAccountWithMeta | undefined>;
|
|
292
|
+
/**
|
|
293
|
+
* Login to an existing controller account.
|
|
294
|
+
*
|
|
295
|
+
* # Parameters
|
|
296
|
+
*
|
|
297
|
+
* * `create_wildcard_session` - Whether to create a wildcard session on login. Defaults to `true`
|
|
298
|
+
* for backward compatibility. Set to `false` when using the `register_session` flow where
|
|
299
|
+
* specific policies will be registered instead of using a wildcard session.
|
|
300
|
+
*
|
|
301
|
+
* # Returns
|
|
302
|
+
*
|
|
303
|
+
* Returns a `LoginResult` containing:
|
|
304
|
+
* * `account` - The controller account
|
|
305
|
+
* * `session` - Optional session (Some if `create_wildcard_session` is true, None otherwise)
|
|
306
|
+
*
|
|
307
|
+
* # Testing
|
|
308
|
+
*
|
|
309
|
+
* The core logic is tested in the SDK layer:
|
|
310
|
+
* * `account_sdk::tests::session_test::test_wildcard_session_creation` - Tests session creation
|
|
311
|
+
* * `account_sdk::tests::session_test::test_login_with_wildcard_session_and_execute` - Tests login with session + execution
|
|
312
|
+
* * `account_sdk::tests::session_test::test_login_without_session_can_still_execute` - Tests login without session + execution
|
|
313
|
+
*
|
|
314
|
+
* The WASM layer is a thin wrapper that:
|
|
315
|
+
* 1. Converts WASM types to SDK types
|
|
316
|
+
* 2. Calls `Controller::new` and optionally `create_wildcard_session`
|
|
317
|
+
* 3. Handles WebAuthn signer updates when multiple signers are present
|
|
318
|
+
* 4. Registers the session with Cartridge API if requested
|
|
319
|
+
*/
|
|
320
|
+
static login(username: string, class_hash: JsFelt, rpc_url: string, address: JsFelt, owner: Owner, cartridge_api_url: string, session_expires_at_s: bigint, is_controller_registered?: boolean | null, create_wildcard_session?: boolean | null, app_id?: string | null): Promise<LoginResult>;
|
|
374
321
|
}
|
|
322
|
+
|
|
323
|
+
export enum ErrorCode {
|
|
324
|
+
StarknetFailedToReceiveTransaction = 1,
|
|
325
|
+
StarknetContractNotFound = 20,
|
|
326
|
+
StarknetBlockNotFound = 24,
|
|
327
|
+
StarknetInvalidTransactionIndex = 27,
|
|
328
|
+
StarknetClassHashNotFound = 28,
|
|
329
|
+
StarknetTransactionHashNotFound = 29,
|
|
330
|
+
StarknetPageSizeTooBig = 31,
|
|
331
|
+
StarknetNoBlocks = 32,
|
|
332
|
+
StarknetInvalidContinuationToken = 33,
|
|
333
|
+
StarknetTooManyKeysInFilter = 34,
|
|
334
|
+
StarknetContractError = 40,
|
|
335
|
+
StarknetTransactionExecutionError = 41,
|
|
336
|
+
StarknetClassAlreadyDeclared = 51,
|
|
337
|
+
StarknetInvalidTransactionNonce = 52,
|
|
338
|
+
StarknetInsufficientMaxFee = 53,
|
|
339
|
+
StarknetInsufficientAccountBalance = 54,
|
|
340
|
+
StarknetValidationFailure = 55,
|
|
341
|
+
StarknetCompilationFailed = 56,
|
|
342
|
+
StarknetContractClassSizeIsTooLarge = 57,
|
|
343
|
+
StarknetNonAccount = 58,
|
|
344
|
+
StarknetDuplicateTx = 59,
|
|
345
|
+
StarknetCompiledClassHashMismatch = 60,
|
|
346
|
+
StarknetUnsupportedTxVersion = 61,
|
|
347
|
+
StarknetUnsupportedContractClassVersion = 62,
|
|
348
|
+
StarknetUnexpectedError = 63,
|
|
349
|
+
StarknetNoTraceAvailable = 10,
|
|
350
|
+
StarknetReplacementTransactionUnderpriced = 64,
|
|
351
|
+
StarknetFeeBelowMinimum = 65,
|
|
352
|
+
SignError = 101,
|
|
353
|
+
StorageError = 102,
|
|
354
|
+
AccountFactoryError = 103,
|
|
355
|
+
PaymasterExecutionTimeNotReached = 104,
|
|
356
|
+
PaymasterExecutionTimePassed = 105,
|
|
357
|
+
PaymasterInvalidCaller = 106,
|
|
358
|
+
PaymasterRateLimitExceeded = 107,
|
|
359
|
+
PaymasterNotSupported = 108,
|
|
360
|
+
PaymasterHttp = 109,
|
|
361
|
+
PaymasterExcecution = 110,
|
|
362
|
+
PaymasterSerialization = 111,
|
|
363
|
+
CartridgeControllerNotDeployed = 112,
|
|
364
|
+
InsufficientBalance = 113,
|
|
365
|
+
OriginError = 114,
|
|
366
|
+
EncodingError = 115,
|
|
367
|
+
SerdeWasmBindgenError = 116,
|
|
368
|
+
CairoSerdeError = 117,
|
|
369
|
+
CairoShortStringToFeltError = 118,
|
|
370
|
+
DeviceCreateCredential = 119,
|
|
371
|
+
DeviceGetAssertion = 120,
|
|
372
|
+
DeviceBadAssertion = 121,
|
|
373
|
+
DeviceChannel = 122,
|
|
374
|
+
DeviceOrigin = 123,
|
|
375
|
+
AccountSigning = 124,
|
|
376
|
+
AccountProvider = 125,
|
|
377
|
+
AccountClassHashCalculation = 126,
|
|
378
|
+
AccountFeeOutOfRange = 128,
|
|
379
|
+
ProviderRateLimited = 129,
|
|
380
|
+
ProviderArrayLengthMismatch = 130,
|
|
381
|
+
ProviderOther = 131,
|
|
382
|
+
SessionAlreadyRegistered = 132,
|
|
383
|
+
UrlParseError = 133,
|
|
384
|
+
Base64DecodeError = 134,
|
|
385
|
+
CoseError = 135,
|
|
386
|
+
PolicyChainIdMismatch = 136,
|
|
387
|
+
InvalidOwner = 137,
|
|
388
|
+
GasPriceTooHigh = 138,
|
|
389
|
+
TransactionTimeout = 139,
|
|
390
|
+
ConversionError = 140,
|
|
391
|
+
InvalidChainId = 141,
|
|
392
|
+
SessionRefreshRequired = 142,
|
|
393
|
+
ManualExecutionRequired = 143,
|
|
394
|
+
ForbiddenEntrypoint = 144,
|
|
395
|
+
GasAmountTooHigh = 145,
|
|
396
|
+
ApproveExecutionRequired = 146,
|
|
397
|
+
}
|
|
398
|
+
|
|
375
399
|
/**
|
|
376
400
|
* JavaScript-friendly chain configuration
|
|
377
401
|
*/
|
|
378
402
|
export class JsChainConfig {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
403
|
+
free(): void;
|
|
404
|
+
[Symbol.dispose](): void;
|
|
405
|
+
constructor(class_hash: JsFelt, rpc_url: string, owner: Owner, address?: JsFelt | null);
|
|
406
|
+
readonly address: JsFelt | undefined;
|
|
407
|
+
readonly class_hash: JsFelt;
|
|
408
|
+
readonly owner: Owner;
|
|
409
|
+
readonly rpc_url: string;
|
|
386
410
|
}
|
|
411
|
+
|
|
387
412
|
export class JsControllerError {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
413
|
+
private constructor();
|
|
414
|
+
free(): void;
|
|
415
|
+
[Symbol.dispose](): void;
|
|
416
|
+
code: ErrorCode;
|
|
417
|
+
get data(): string | undefined;
|
|
418
|
+
set data(value: string | null | undefined);
|
|
419
|
+
message: string;
|
|
395
420
|
}
|
|
421
|
+
|
|
396
422
|
export class LoginResult {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
423
|
+
private constructor();
|
|
424
|
+
free(): void;
|
|
425
|
+
[Symbol.dispose](): void;
|
|
426
|
+
intoValues(): Array<any>;
|
|
401
427
|
}
|
|
428
|
+
|
|
402
429
|
/**
|
|
403
430
|
* WASM bindings for MultiChainController
|
|
404
431
|
*/
|
|
405
432
|
export class MultiChainAccount {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
433
|
+
private constructor();
|
|
434
|
+
free(): void;
|
|
435
|
+
[Symbol.dispose](): void;
|
|
436
|
+
/**
|
|
437
|
+
* Adds a new chain configuration
|
|
438
|
+
*/
|
|
439
|
+
addChain(config: JsChainConfig): Promise<void>;
|
|
440
|
+
/**
|
|
441
|
+
* Gets an account instance for a specific chain
|
|
442
|
+
*/
|
|
443
|
+
controller(chain_id: JsFelt): Promise<CartridgeAccount>;
|
|
444
|
+
/**
|
|
445
|
+
* Creates a new MultiChainAccount with multiple chain configurations
|
|
446
|
+
*/
|
|
447
|
+
static create(username: string, chain_configs: JsChainConfig[], cartridge_api_url: string): Promise<MultiChainAccount>;
|
|
448
|
+
/**
|
|
449
|
+
* Loads a MultiChainAccount from storage
|
|
450
|
+
*/
|
|
451
|
+
static fromStorage(cartridge_api_url: string): Promise<MultiChainAccount | undefined>;
|
|
452
|
+
/**
|
|
453
|
+
* Removes a chain configuration
|
|
454
|
+
*/
|
|
455
|
+
removeChain(chain_id: JsFelt): Promise<void>;
|
|
429
456
|
}
|
|
457
|
+
|
|
430
458
|
/**
|
|
431
459
|
* Metadata for displaying multi-chain information
|
|
432
460
|
*/
|
|
433
461
|
export class MultiChainAccountMeta {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
462
|
+
private constructor();
|
|
463
|
+
free(): void;
|
|
464
|
+
[Symbol.dispose](): void;
|
|
465
|
+
readonly chains: JsFelt[];
|
|
466
|
+
readonly username: string;
|
|
439
467
|
}
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Computes the Starknet contract address for a controller account without needing a full instance.
|
|
471
|
+
*
|
|
472
|
+
* # Arguments
|
|
473
|
+
*
|
|
474
|
+
* * `class_hash` - The class hash of the account contract (JsFelt).
|
|
475
|
+
* * `owner` - The owner configuration for the account.
|
|
476
|
+
* * `salt` - The salt used for address calculation (JsFelt).
|
|
477
|
+
*
|
|
478
|
+
* # Returns
|
|
479
|
+
*
|
|
480
|
+
* The computed Starknet contract address as a `JsFelt`.
|
|
481
|
+
*/
|
|
482
|
+
export function computeAccountAddress(class_hash: JsFelt, owner: Owner, salt: JsFelt): JsFelt;
|
|
483
|
+
|
|
484
|
+
export function signerToGuid(signer: Signer): JsFelt;
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Subscribes to the creation of a session for a given controller, session_key_guid and cartridge api url.
|
|
488
|
+
* The goal of this function is to know from any place when the register session flow has been completed, and to
|
|
489
|
+
* get the authorization.
|
|
490
|
+
*/
|
|
491
|
+
export function subscribeCreateSession(session_key_guid: JsFelt, cartridge_api_url: string): Promise<JsSubscribeSessionResult>;
|