@cartridge/controller-wasm 0.7.14-de92897 → 0.7.14-efe4c2fe

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,27 +1,5 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export interface JsCall {
4
- contractAddress: JsFelt;
5
- entrypoint: string;
6
- calldata: JsFelt[];
7
- }
8
-
9
- export type JsPriceUnit = "WEI" | "FRI";
10
-
11
- export interface JsEstimateFeeDetails {
12
- nonce: JsFelt;
13
- }
14
-
15
- export interface JsFeeEstimate {
16
- l1_gas_consumed: number;
17
- l1_gas_price: number;
18
- l2_gas_consumed: number;
19
- l2_gas_price: number;
20
- l1_data_gas_consumed: number;
21
- l1_data_gas_price: number;
22
- overall_fee: number;
23
- }
24
-
25
3
  /**
26
4
  * JavaScript-friendly OutsideExecution V3 structure
27
5
  */
@@ -41,9 +19,21 @@ export interface JsSignedOutsideExecution {
41
19
  signature: JsFelt[];
42
20
  }
43
21
 
44
- export interface Owner {
45
- signer?: Signer;
46
- account?: JsFelt;
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;
47
37
  }
48
38
 
49
39
  export interface CallPolicy {
@@ -52,35 +42,46 @@ export interface CallPolicy {
52
42
  authorized?: boolean;
53
43
  }
54
44
 
55
- export interface TypedDataPolicy {
56
- scope_hash: JsFelt;
57
- authorized?: boolean;
45
+ export interface Credentials {
46
+ authorization: JsFelt[];
47
+ privateKey: JsFelt;
58
48
  }
59
49
 
60
- export interface ApprovalPolicy {
61
- target: JsFelt;
62
- spender: JsFelt;
63
- amount: JsFelt;
50
+ export interface Eip191Signer {
51
+ address: string;
64
52
  }
65
53
 
66
- export type Policy = CallPolicy | TypedDataPolicy | ApprovalPolicy;
67
-
68
- export type JsRegister = RegisterInput;
54
+ export interface JsCall {
55
+ contractAddress: JsFelt;
56
+ entrypoint: string;
57
+ calldata: JsFelt[];
58
+ }
69
59
 
70
- export type JsRegisterResponse = ResponseData;
60
+ export interface JsEstimateFeeDetails {
61
+ nonce: JsFelt;
62
+ }
71
63
 
72
- export interface WebauthnSigner {
73
- rpId: string;
74
- credentialId: string;
75
- publicKey: string;
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;
76
72
  }
77
73
 
78
- export interface StarknetSigner {
79
- privateKey: JsFelt;
74
+ export interface Owner {
75
+ signer?: Signer;
76
+ account?: JsFelt;
80
77
  }
81
78
 
82
- export interface Eip191Signer {
83
- address: string;
79
+ export interface Session {
80
+ policies: Policy[];
81
+ expiresAt: number;
82
+ metadataHash: JsFelt;
83
+ sessionKeyGuid: JsFelt;
84
+ guardianKeyGuid: JsFelt;
84
85
  }
85
86
 
86
87
  export interface Signer {
@@ -90,312 +91,340 @@ export interface Signer {
90
91
  eip191?: Eip191Signer;
91
92
  }
92
93
 
93
- export type JsAddSignerInput = SignerInput;
94
+ export interface StarknetSigner {
95
+ privateKey: JsFelt;
96
+ }
94
97
 
95
- export type JsRemoveSignerInput = SignerInput;
98
+ export interface TypedDataPolicy {
99
+ scope_hash: JsFelt;
100
+ authorized?: boolean;
101
+ }
96
102
 
97
- export type JsFelt = Felt;
103
+ export interface WebauthnSigner {
104
+ rpId: string;
105
+ credentialId: string;
106
+ publicKey: string;
107
+ }
98
108
 
99
109
  export type Felts = JsFelt[];
100
110
 
111
+ export type JsAddSignerInput = SignerInput;
112
+
101
113
  export type JsFeeSource = "PAYMASTER" | "CREDITS";
102
114
 
103
- export type JsSubscribeSessionResult = SubscribeCreateSessionSubscribeCreateSession;
115
+ export type JsFelt = Felt;
104
116
 
105
- export type JsRevokableSession = RevokableSession;
117
+ export type JsPriceUnit = "WEI" | "FRI";
106
118
 
107
- export interface AuthorizedSession {
108
- session: Session;
109
- authorization: JsFelt[] | null;
110
- isRegistered: boolean;
111
- expiresAt: number;
112
- allowedPoliciesRoot: JsFelt;
113
- metadataHash: JsFelt;
114
- sessionKeyGuid: JsFelt;
115
- guardianKeyGuid: JsFelt;
116
- }
119
+ export type JsRegister = RegisterInput;
117
120
 
118
- export interface Session {
119
- policies: Policy[];
120
- expiresAt: number;
121
- metadataHash: JsFelt;
122
- sessionKeyGuid: JsFelt;
123
- guardianKeyGuid: JsFelt;
124
- }
121
+ export type JsRegisterResponse = ResponseData;
125
122
 
126
- export interface Credentials {
127
- authorization: JsFelt[];
128
- privateKey: JsFelt;
129
- }
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
130
 
131
131
 
132
132
  export class CartridgeAccount {
133
- private constructor();
134
- free(): void;
135
- [Symbol.dispose](): void;
136
- /**
137
- * Creates a new `CartridgeAccount` instance.
138
- *
139
- * # Parameters
140
- * - `rpc_url`: The URL of the JSON-RPC endpoint.
141
- * - `address`: The blockchain address associated with the account.
142
- * - `username`: Username associated with the account.
143
- * - `owner`: A Owner struct containing the owner signer and associated data.
144
- */
145
- static new(class_hash: JsFelt, rpc_url: string, address: JsFelt, username: string, owner: Owner, cartridge_api_url: string): Promise<CartridgeAccountWithMeta>;
146
- /**
147
- * Creates a new `CartridgeAccount` instance with a randomly generated Starknet signer.
148
- * The controller address is computed internally based on the generated signer.
149
- *
150
- * # Parameters
151
- * - `rpc_url`: The URL of the JSON-RPC endpoint.
152
- * - `username`: Username associated with the account.
153
- */
154
- static newHeadless(class_hash: JsFelt, rpc_url: string, username: string, cartridge_api_url: string): Promise<CartridgeAccountWithMeta>;
155
- static fromStorage(cartridge_api_url: string): Promise<CartridgeAccountWithMeta | undefined>;
156
- disconnect(): Promise<void>;
157
- registerSession(app_id: string, policies: Policy[], expires_at: bigint, public_key: JsFelt, max_fee?: JsFeeEstimate | null): Promise<any>;
158
- registerSessionCalldata(policies: Policy[], expires_at: bigint, public_key: JsFelt): Promise<any>;
159
- upgrade(new_class_hash: JsFelt): Promise<JsCall>;
160
- register(register: JsRegister): Promise<JsRegisterResponse>;
161
- createSession(app_id: string, policies: Policy[], expires_at: bigint, authorize_user_execution?: boolean | null): Promise<AuthorizedSession | undefined>;
162
- skipSession(app_id: string, policies: Policy[]): Promise<void>;
163
- addOwner(owner?: Signer | null, signer_input?: JsAddSignerInput | null, rp_id?: string | null): Promise<void>;
164
- removeOwner(signer: JsRemoveSignerInput): Promise<void>;
165
- createPasskeySigner(rp_id: string): Promise<JsAddSignerInput>;
166
- estimateInvokeFee(calls: JsCall[]): Promise<JsFeeEstimate>;
167
- execute(calls: JsCall[], max_fee?: JsFeeEstimate | null, fee_source?: JsFeeSource | null): Promise<any>;
168
- executeFromOutsideV2(calls: JsCall[], fee_source?: JsFeeSource | null): Promise<any>;
169
- executeFromOutsideV3(calls: JsCall[], fee_source?: JsFeeSource | null): Promise<any>;
170
- trySessionExecute(app_id: string, calls: JsCall[], fee_source?: JsFeeSource | null): Promise<any>;
171
- isRegisteredSessionAuthorized(policies: Policy[], public_key?: JsFelt | null): Promise<AuthorizedSession | undefined>;
172
- hasRequestedSession(app_id: string, policies: Policy[]): Promise<boolean>;
173
- revokeSession(session: JsRevokableSession): Promise<void>;
174
- revokeSessions(sessions: JsRevokableSession[]): Promise<void>;
175
- signMessage(typed_data: string): Promise<Felts>;
176
- getNonce(): Promise<any>;
177
- deploySelf(max_fee?: JsFeeEstimate | null): Promise<any>;
178
- delegateAccount(): Promise<JsFelt>;
179
- hasAuthorizedPoliciesForCalls(app_id: string, calls: JsCall[]): Promise<boolean>;
180
- hasAuthorizedPoliciesForMessage(app_id: string, typed_data: string): Promise<boolean>;
181
- /**
182
- * Signs an OutsideExecution V3 transaction and returns both the OutsideExecution object and its signature.
183
- *
184
- * # Parameters
185
- * - `calls`: Array of calls to execute from outside
186
- *
187
- * # Returns
188
- * A `JsSignedOutsideExecution` containing the OutsideExecution V3 object and its signature
189
- */
190
- signExecuteFromOutside(calls: JsCall[]): Promise<JsSignedOutsideExecution>;
191
- /**
192
- * Checks if there are stored policies for a given app_id.
193
- *
194
- * # Parameters
195
- * - `app_id`: The application identifier to check for stored policies
196
- *
197
- * # Returns
198
- * `true` if policies exist for the given app_id, `false` otherwise
199
- */
200
- hasPoliciesForAppId(app_id: string): Promise<boolean>;
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
- username(): string;
208
- address(): string;
209
- classHash(): string;
210
- rpcUrl(): string;
211
- chainId(): string;
212
- owner(): Owner;
213
- ownerGuid(): JsFelt;
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
- meta(): CartridgeAccountMeta;
221
- intoAccount(): CartridgeAccount;
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 rpc_url: string;
346
- readonly owner: Owner;
347
- readonly address: JsFelt | undefined;
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
- * Creates a new MultiChainAccount with multiple chain configurations
373
- */
374
- static create(username: string, chain_configs: JsChainConfig[], cartridge_api_url: string): Promise<MultiChainAccount>;
375
- /**
376
- * Loads a MultiChainAccount from storage
377
- */
378
- static fromStorage(cartridge_api_url: string): Promise<MultiChainAccount | undefined>;
379
- /**
380
- * Adds a new chain configuration
381
- */
382
- addChain(config: JsChainConfig): Promise<void>;
383
- /**
384
- * Removes a chain configuration
385
- */
386
- removeChain(chain_id: JsFelt): Promise<void>;
387
- /**
388
- * Gets an account instance for a specific chain
389
- */
390
- controller(chain_id: JsFelt): Promise<CartridgeAccount>;
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 username: string;
398
- readonly chains: JsFelt[];
423
+ private constructor();
424
+ free(): void;
425
+ [Symbol.dispose](): void;
426
+ readonly chains: JsFelt[];
427
+ readonly username: string;
399
428
  }
400
429
 
401
430
  /**