@cartridge/controller-wasm 0.9.0 → 0.9.2

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