@cartridge/controller-wasm 0.2.3 → 0.2.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cartridge/controller-wasm",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Wasm bindings for Cartridge Controller and Session Account",
5
5
  "type": "module",
6
6
  "main": "./pkg-controller/account_wasm.js",
@@ -78,6 +78,7 @@ export enum ErrorCode {
78
78
  CoseError = 135,
79
79
  PolicyChainIdMismatch = 136,
80
80
  InvalidOwner = 137,
81
+ GasPriceTooHigh = 138,
81
82
  }
82
83
  export interface JsCall {
83
84
  contractAddress: JsFelt;
@@ -194,6 +195,17 @@ export class CartridgeAccount {
194
195
  * - `owner`: A Owner struct containing the owner signer and associated data.
195
196
  */
196
197
  static new(app_id: string, class_hash: JsFelt, rpc_url: string, chain_id: JsFelt, address: JsFelt, username: string, owner: Owner, cartridge_api_url: string): CartridgeAccountWithMeta;
198
+ /**
199
+ * Creates a new `CartridgeAccount` instance with a randomly generated Starknet signer.
200
+ * The controller address is computed internally based on the generated signer.
201
+ *
202
+ * # Parameters
203
+ * - `app_id`: Application identifier.
204
+ * - `rpc_url`: The URL of the JSON-RPC endpoint.
205
+ * - `chain_id`: Identifier of the blockchain network to interact with.
206
+ * - `username`: Username associated with the account.
207
+ */
208
+ static newHeadless(app_id: string, class_hash: JsFelt, rpc_url: string, chain_id: JsFelt, username: string, cartridge_api_url: string): CartridgeAccountWithMeta;
197
209
  static fromStorage(app_id: string, cartridge_api_url: string): CartridgeAccountWithMeta | undefined;
198
210
  disconnect(): Promise<void>;
199
211
  registerSession(policies: Policy[], expires_at: bigint, public_key: JsFelt, max_fee?: JsFeeEstimate | null): Promise<any>;
@@ -203,7 +215,8 @@ export class CartridgeAccount {
203
215
  register(register: JsRegister): Promise<JsRegisterResponse>;
204
216
  createSession(policies: Policy[], expires_at: bigint): Promise<AuthorizedSession | undefined>;
205
217
  skipSession(policies: Policy[]): Promise<void>;
206
- addOwner(owner: Signer, signer_input: JsSignerInput): Promise<void>;
218
+ addOwner(owner?: Signer | null, signer_input?: JsSignerInput | null, rp_id?: string | null): Promise<void>;
219
+ createPasskeySigner(rp_id: string): Promise<JsSignerInput>;
207
220
  estimateInvokeFee(calls: JsCall[]): Promise<JsFeeEstimate>;
208
221
  execute(calls: JsCall[], max_fee?: JsFeeEstimate | null, fee_source?: JsFeeSource | null): Promise<any>;
209
222
  executeFromOutsideV2(calls: JsCall[], fee_source?: JsFeeSource | null): Promise<any>;
@@ -140,6 +140,28 @@ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
140
140
  wasm.__wbindgen_export_4.get(state.dtor)(state.a, state.b)
141
141
  });
142
142
 
143
+ function makeClosure(arg0, arg1, dtor, f) {
144
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
145
+ const real = (...args) => {
146
+ // First up with a closure we increment the internal reference
147
+ // count. This ensures that the Rust closure environment won't
148
+ // be deallocated while we're invoking it.
149
+ state.cnt++;
150
+ try {
151
+ return f(state.a, state.b, ...args);
152
+ } finally {
153
+ if (--state.cnt === 0) {
154
+ wasm.__wbindgen_export_4.get(state.dtor)(state.a, state.b);
155
+ state.a = 0;
156
+ CLOSURE_DTORS.unregister(state);
157
+ }
158
+ }
159
+ };
160
+ real.original = state;
161
+ CLOSURE_DTORS.register(real, state, state);
162
+ return real;
163
+ }
164
+
143
165
  function makeMutClosure(arg0, arg1, dtor, f) {
144
166
  const state = { a: arg0, b: arg1, cnt: 1, dtor };
145
167
  const real = (...args) => {
@@ -281,20 +303,24 @@ export function computeAccountAddress(class_hash, owner, salt) {
281
303
  }
282
304
  }
283
305
 
284
- function __wbg_adapter_44(arg0, arg1) {
285
- wasm.__wbindgen_export_5(arg0, arg1);
306
+ function __wbg_adapter_44(arg0, arg1, arg2) {
307
+ wasm.__wbindgen_export_5(arg0, arg1, addHeapObject(arg2));
308
+ }
309
+
310
+ function __wbg_adapter_47(arg0, arg1) {
311
+ wasm.__wbindgen_export_6(arg0, arg1);
286
312
  }
287
313
 
288
- function __wbg_adapter_47(arg0, arg1, arg2) {
289
- wasm.__wbindgen_export_6(arg0, arg1, addHeapObject(arg2));
314
+ function __wbg_adapter_50(arg0, arg1, arg2) {
315
+ wasm.__wbindgen_export_7(arg0, arg1, addHeapObject(arg2));
290
316
  }
291
317
 
292
- function __wbg_adapter_259(arg0, arg1, arg2, arg3) {
293
- wasm.__wbindgen_export_7(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
318
+ function __wbg_adapter_276(arg0, arg1, arg2, arg3) {
319
+ wasm.__wbindgen_export_8(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
294
320
  }
295
321
 
296
322
  /**
297
- * @enum {1 | 20 | 24 | 27 | 28 | 29 | 31 | 32 | 33 | 34 | 40 | 41 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 10 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137}
323
+ * @enum {1 | 20 | 24 | 27 | 28 | 29 | 31 | 32 | 33 | 34 | 40 | 41 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 10 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138}
298
324
  */
299
325
  export const ErrorCode = Object.freeze({
300
326
  StarknetFailedToReceiveTransaction: 1, "1": "StarknetFailedToReceiveTransaction",
@@ -359,6 +385,7 @@ export const ErrorCode = Object.freeze({
359
385
  CoseError: 135, "135": "CoseError",
360
386
  PolicyChainIdMismatch: 136, "136": "PolicyChainIdMismatch",
361
387
  InvalidOwner: 137, "137": "InvalidOwner",
388
+ GasPriceTooHigh: 138, "138": "GasPriceTooHigh",
362
389
  });
363
390
 
364
391
  const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
@@ -433,6 +460,46 @@ export class CartridgeAccount {
433
460
  wasm.__wbindgen_add_to_stack_pointer(16);
434
461
  }
435
462
  }
463
+ /**
464
+ * Creates a new `CartridgeAccount` instance with a randomly generated Starknet signer.
465
+ * The controller address is computed internally based on the generated signer.
466
+ *
467
+ * # Parameters
468
+ * - `app_id`: Application identifier.
469
+ * - `rpc_url`: The URL of the JSON-RPC endpoint.
470
+ * - `chain_id`: Identifier of the blockchain network to interact with.
471
+ * - `username`: Username associated with the account.
472
+ * @param {string} app_id
473
+ * @param {JsFelt} class_hash
474
+ * @param {string} rpc_url
475
+ * @param {JsFelt} chain_id
476
+ * @param {string} username
477
+ * @param {string} cartridge_api_url
478
+ * @returns {CartridgeAccountWithMeta}
479
+ */
480
+ static newHeadless(app_id, class_hash, rpc_url, chain_id, username, cartridge_api_url) {
481
+ try {
482
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
483
+ const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
484
+ const len0 = WASM_VECTOR_LEN;
485
+ const ptr1 = passStringToWasm0(rpc_url, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
486
+ const len1 = WASM_VECTOR_LEN;
487
+ const ptr2 = passStringToWasm0(username, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
488
+ const len2 = WASM_VECTOR_LEN;
489
+ const ptr3 = passStringToWasm0(cartridge_api_url, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
490
+ const len3 = WASM_VECTOR_LEN;
491
+ wasm.cartridgeaccount_newHeadless(retptr, ptr0, len0, addHeapObject(class_hash), ptr1, len1, addHeapObject(chain_id), ptr2, len2, ptr3, len3);
492
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
493
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
494
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
495
+ if (r2) {
496
+ throw takeObject(r1);
497
+ }
498
+ return CartridgeAccountWithMeta.__wrap(r0);
499
+ } finally {
500
+ wasm.__wbindgen_add_to_stack_pointer(16);
501
+ }
502
+ }
436
503
  /**
437
504
  * @param {string} app_id
438
505
  * @param {string} cartridge_api_url
@@ -537,12 +604,25 @@ export class CartridgeAccount {
537
604
  return takeObject(ret);
538
605
  }
539
606
  /**
540
- * @param {Signer} owner
541
- * @param {JsSignerInput} signer_input
607
+ * @param {Signer | null} [owner]
608
+ * @param {JsSignerInput | null} [signer_input]
609
+ * @param {string | null} [rp_id]
542
610
  * @returns {Promise<void>}
543
611
  */
544
- addOwner(owner, signer_input) {
545
- const ret = wasm.cartridgeaccount_addOwner(this.__wbg_ptr, addHeapObject(owner), addHeapObject(signer_input));
612
+ addOwner(owner, signer_input, rp_id) {
613
+ var ptr0 = isLikeNone(rp_id) ? 0 : passStringToWasm0(rp_id, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
614
+ var len0 = WASM_VECTOR_LEN;
615
+ const ret = wasm.cartridgeaccount_addOwner(this.__wbg_ptr, isLikeNone(owner) ? 0 : addHeapObject(owner), isLikeNone(signer_input) ? 0 : addHeapObject(signer_input), ptr0, len0);
616
+ return takeObject(ret);
617
+ }
618
+ /**
619
+ * @param {string} rp_id
620
+ * @returns {Promise<JsSignerInput>}
621
+ */
622
+ createPasskeySigner(rp_id) {
623
+ const ptr0 = passStringToWasm0(rp_id, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
624
+ const len0 = WASM_VECTOR_LEN;
625
+ const ret = wasm.cartridgeaccount_createPasskeySigner(this.__wbg_ptr, ptr0, len0);
546
626
  return takeObject(ret);
547
627
  }
548
628
  /**
@@ -1007,6 +1087,10 @@ export function __wbg_abort_775ef1d17fc65868(arg0) {
1007
1087
  getObject(arg0).abort();
1008
1088
  };
1009
1089
 
1090
+ export function __wbg_addEventListener_90e553fdce254421() { return handleError(function (arg0, arg1, arg2, arg3) {
1091
+ getObject(arg0).addEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3));
1092
+ }, arguments) };
1093
+
1010
1094
  export function __wbg_append_8c7dd8d641a5f01b() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
1011
1095
  getObject(arg0).append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
1012
1096
  }, arguments) };
@@ -1055,6 +1139,11 @@ export function __wbg_crypto_574e78ad8b13b65f(arg0) {
1055
1139
  return addHeapObject(ret);
1056
1140
  };
1057
1141
 
1142
+ export function __wbg_data_432d9c3df2630942(arg0) {
1143
+ const ret = getObject(arg0).data;
1144
+ return addHeapObject(ret);
1145
+ };
1146
+
1058
1147
  export function __wbg_done_769e5ede4b31c67b(arg0) {
1059
1148
  const ret = getObject(arg0).done;
1060
1149
  return ret;
@@ -1248,7 +1337,7 @@ export function __wbg_new_23a2665fac83c611(arg0, arg1) {
1248
1337
  const a = state0.a;
1249
1338
  state0.a = 0;
1250
1339
  try {
1251
- return __wbg_adapter_259(a, state0.b, arg0, arg1);
1340
+ return __wbg_adapter_276(a, state0.b, arg0, arg1);
1252
1341
  } finally {
1253
1342
  state0.a = a;
1254
1343
  }
@@ -1335,6 +1424,19 @@ export function __wbg_obtain_a9626b3b96e6dc2c(arg0) {
1335
1424
  return addHeapObject(ret);
1336
1425
  };
1337
1426
 
1427
+ export function __wbg_open_133269b8b8f0081c() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
1428
+ const ret = getObject(arg0).open(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), getStringFromWasm0(arg5, arg6));
1429
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
1430
+ }, arguments) };
1431
+
1432
+ export function __wbg_origin_1d664917fb08d320(arg0, arg1) {
1433
+ const ret = getObject(arg1).origin;
1434
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
1435
+ const len1 = WASM_VECTOR_LEN;
1436
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1437
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1438
+ };
1439
+
1338
1440
  export function __wbg_origin_7c5d649acdace3ea() { return handleError(function (arg0, arg1) {
1339
1441
  const ret = getObject(arg1).origin;
1340
1442
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
@@ -1366,6 +1468,10 @@ export function __wbg_randomFillSync_ac0988aba3254290() { return handleError(fun
1366
1468
  getObject(arg0).randomFillSync(takeObject(arg1));
1367
1469
  }, arguments) };
1368
1470
 
1471
+ export function __wbg_removeEventListener_056dfe8c3d6c58f9() { return handleError(function (arg0, arg1, arg2, arg3) {
1472
+ getObject(arg0).removeEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3));
1473
+ }, arguments) };
1474
+
1369
1475
  export function __wbg_removeItem_9d2669ee3bba6f7d() { return handleError(function (arg0, arg1, arg2) {
1370
1476
  getObject(arg0).removeItem(getStringFromWasm0(arg1, arg2));
1371
1477
  }, arguments) };
@@ -1530,6 +1636,14 @@ export function __wbg_url_ae10c34ca209681d(arg0, arg1) {
1530
1636
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1531
1637
  };
1532
1638
 
1639
+ export function __wbg_userAgent_12e9d8e62297563f() { return handleError(function (arg0, arg1) {
1640
+ const ret = getObject(arg1).userAgent;
1641
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
1642
+ const len1 = WASM_VECTOR_LEN;
1643
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1644
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1645
+ }, arguments) };
1646
+
1533
1647
  export function __wbg_value_cd1ffa7b1ab794f1(arg0) {
1534
1648
  const ret = getObject(arg0).value;
1535
1649
  return addHeapObject(ret);
@@ -1561,13 +1675,18 @@ export function __wbindgen_cb_drop(arg0) {
1561
1675
  return ret;
1562
1676
  };
1563
1677
 
1564
- export function __wbindgen_closure_wrapper5664(arg0, arg1, arg2) {
1565
- const ret = makeMutClosure(arg0, arg1, 663, __wbg_adapter_44);
1678
+ export function __wbindgen_closure_wrapper1273(arg0, arg1, arg2) {
1679
+ const ret = makeClosure(arg0, arg1, 26, __wbg_adapter_44);
1680
+ return addHeapObject(ret);
1681
+ };
1682
+
1683
+ export function __wbindgen_closure_wrapper5787(arg0, arg1, arg2) {
1684
+ const ret = makeMutClosure(arg0, arg1, 676, __wbg_adapter_47);
1566
1685
  return addHeapObject(ret);
1567
1686
  };
1568
1687
 
1569
- export function __wbindgen_closure_wrapper5810(arg0, arg1, arg2) {
1570
- const ret = makeMutClosure(arg0, arg1, 696, __wbg_adapter_47);
1688
+ export function __wbindgen_closure_wrapper5933(arg0, arg1, arg2) {
1689
+ const ret = makeMutClosure(arg0, arg1, 709, __wbg_adapter_50);
1571
1690
  return addHeapObject(ret);
1572
1691
  };
1573
1692
 
Binary file
@@ -63,6 +63,7 @@ export enum ErrorCode {
63
63
  CoseError = 135,
64
64
  PolicyChainIdMismatch = 136,
65
65
  InvalidOwner = 137,
66
+ GasPriceTooHigh = 138,
66
67
  }
67
68
  export interface JsCall {
68
69
  contractAddress: JsFelt;
@@ -252,7 +252,7 @@ function __wbg_adapter_199(arg0, arg1, arg2, arg3) {
252
252
  }
253
253
 
254
254
  /**
255
- * @enum {1 | 20 | 24 | 27 | 28 | 29 | 31 | 32 | 33 | 34 | 40 | 41 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 10 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137}
255
+ * @enum {1 | 20 | 24 | 27 | 28 | 29 | 31 | 32 | 33 | 34 | 40 | 41 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 10 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138}
256
256
  */
257
257
  export const ErrorCode = Object.freeze({
258
258
  StarknetFailedToReceiveTransaction: 1, "1": "StarknetFailedToReceiveTransaction",
@@ -317,6 +317,7 @@ export const ErrorCode = Object.freeze({
317
317
  CoseError: 135, "135": "CoseError",
318
318
  PolicyChainIdMismatch: 136, "136": "PolicyChainIdMismatch",
319
319
  InvalidOwner: 137, "137": "InvalidOwner",
320
+ GasPriceTooHigh: 138, "138": "GasPriceTooHigh",
320
321
  });
321
322
 
322
323
  const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
@@ -1024,13 +1025,13 @@ export function __wbindgen_cb_drop(arg0) {
1024
1025
  return ret;
1025
1026
  };
1026
1027
 
1027
- export function __wbindgen_closure_wrapper2845(arg0, arg1, arg2) {
1028
- const ret = makeMutClosure(arg0, arg1, 363, __wbg_adapter_42);
1028
+ export function __wbindgen_closure_wrapper2837(arg0, arg1, arg2) {
1029
+ const ret = makeMutClosure(arg0, arg1, 361, __wbg_adapter_42);
1029
1030
  return addHeapObject(ret);
1030
1031
  };
1031
1032
 
1032
- export function __wbindgen_closure_wrapper2978(arg0, arg1, arg2) {
1033
- const ret = makeMutClosure(arg0, arg1, 396, __wbg_adapter_45);
1033
+ export function __wbindgen_closure_wrapper2970(arg0, arg1, arg2) {
1034
+ const ret = makeMutClosure(arg0, arg1, 394, __wbg_adapter_45);
1034
1035
  return addHeapObject(ret);
1035
1036
  };
1036
1037
 
Binary file