@cartridge/controller-wasm 0.3.0 → 0.3.1

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.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Wasm bindings for Cartridge Controller and Session Account",
5
5
  "type": "module",
6
6
  "main": "./pkg-controller/account_wasm.js",
@@ -81,6 +81,8 @@ export enum ErrorCode {
81
81
  PolicyChainIdMismatch = 136,
82
82
  InvalidOwner = 137,
83
83
  GasPriceTooHigh = 138,
84
+ TransactionTimeout = 139,
85
+ ConversionError = 140,
84
86
  }
85
87
  export interface JsCall {
86
88
  contractAddress: JsFelt;
@@ -216,7 +218,6 @@ export class CartridgeAccount {
216
218
  registerSession(policies: Policy[], expires_at: bigint, public_key: JsFelt, max_fee?: JsFeeEstimate | null): Promise<any>;
217
219
  registerSessionCalldata(policies: Policy[], expires_at: bigint, public_key: JsFelt): Promise<any>;
218
220
  upgrade(new_class_hash: JsFelt): Promise<JsCall>;
219
- login(expires_at: bigint, is_controller_registered?: boolean | null, signers?: Signer | null): Promise<AuthorizedSession>;
220
221
  register(register: JsRegister): Promise<JsRegisterResponse>;
221
222
  createSession(policies: Policy[], expires_at: bigint): Promise<AuthorizedSession | undefined>;
222
223
  skipSession(policies: Policy[]): Promise<void>;
@@ -261,8 +262,8 @@ export class CartridgeAccountMeta {
261
262
  classHash(): string;
262
263
  rpcUrl(): string;
263
264
  chainId(): string;
264
- ownerGuid(): JsFelt;
265
265
  owner(): Owner;
266
+ ownerGuid(): JsFelt;
266
267
  }
267
268
  /**
268
269
  * A type used as the return type for constructing `CartridgeAccount` to provide an extra,
@@ -277,6 +278,12 @@ export class CartridgeAccountWithMeta {
277
278
  meta(): CartridgeAccountMeta;
278
279
  intoAccount(): CartridgeAccount;
279
280
  }
281
+ export class ControllerFactory {
282
+ private constructor();
283
+ free(): void;
284
+ static from_storage(app_id: string, cartridge_api_url: string): CartridgeAccountWithMeta | undefined;
285
+ static login(app_id: string, username: string, class_hash: JsFelt, rpc_url: string, chain_id: JsFelt, address: JsFelt, owner: Owner, cartridge_api_url: string, session_expires_at_s: bigint, is_controller_registered?: boolean | null): Promise<LoginResult>;
286
+ }
280
287
  export class JsControllerError {
281
288
  private constructor();
282
289
  free(): void;
@@ -285,3 +292,8 @@ export class JsControllerError {
285
292
  get data(): string | undefined;
286
293
  set data(value: string | null | undefined);
287
294
  }
295
+ export class LoginResult {
296
+ private constructor();
297
+ free(): void;
298
+ intoValues(): Array<any>;
299
+ }
@@ -315,12 +315,12 @@ function __wbg_adapter_50(arg0, arg1, arg2) {
315
315
  wasm.__wbindgen_export_7(arg0, arg1, addHeapObject(arg2));
316
316
  }
317
317
 
318
- function __wbg_adapter_280(arg0, arg1, arg2, arg3) {
318
+ function __wbg_adapter_286(arg0, arg1, arg2, arg3) {
319
319
  wasm.__wbindgen_export_8(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
320
320
  }
321
321
 
322
322
  /**
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 | 64 | 65 | 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}
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 | 64 | 65 | 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 | 139 | 140}
324
324
  */
325
325
  export const ErrorCode = Object.freeze({
326
326
  StarknetFailedToReceiveTransaction: 1, "1": "StarknetFailedToReceiveTransaction",
@@ -388,6 +388,8 @@ export const ErrorCode = Object.freeze({
388
388
  PolicyChainIdMismatch: 136, "136": "PolicyChainIdMismatch",
389
389
  InvalidOwner: 137, "137": "InvalidOwner",
390
390
  GasPriceTooHigh: 138, "138": "GasPriceTooHigh",
391
+ TransactionTimeout: 139, "139": "TransactionTimeout",
392
+ ConversionError: 140, "140": "ConversionError",
391
393
  });
392
394
 
393
395
  const __wbindgen_enum_RequestCache = ["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"];
@@ -568,16 +570,6 @@ export class CartridgeAccount {
568
570
  const ret = wasm.cartridgeaccount_upgrade(this.__wbg_ptr, addHeapObject(new_class_hash));
569
571
  return takeObject(ret);
570
572
  }
571
- /**
572
- * @param {bigint} expires_at
573
- * @param {boolean | null} [is_controller_registered]
574
- * @param {Signer | null} [signers]
575
- * @returns {Promise<AuthorizedSession>}
576
- */
577
- login(expires_at, is_controller_registered, signers) {
578
- const ret = wasm.cartridgeaccount_login(this.__wbg_ptr, expires_at, isLikeNone(is_controller_registered) ? 0xFFFFFF : is_controller_registered ? 1 : 0, isLikeNone(signers) ? 0 : addHeapObject(signers));
579
- return takeObject(ret);
580
- }
581
573
  /**
582
574
  * @param {JsRegister} register
583
575
  * @returns {Promise<JsRegisterResponse>}
@@ -937,17 +929,17 @@ export class CartridgeAccountMeta {
937
929
  }
938
930
  }
939
931
  /**
940
- * @returns {JsFelt}
932
+ * @returns {Owner}
941
933
  */
942
- ownerGuid() {
943
- const ret = wasm.cartridgeaccountmeta_ownerGuid(this.__wbg_ptr);
934
+ owner() {
935
+ const ret = wasm.cartridgeaccountmeta_owner(this.__wbg_ptr);
944
936
  return takeObject(ret);
945
937
  }
946
938
  /**
947
- * @returns {Owner}
939
+ * @returns {JsFelt}
948
940
  */
949
- owner() {
950
- const ret = wasm.cartridgeaccountmeta_owner(this.__wbg_ptr);
941
+ ownerGuid() {
942
+ const ret = wasm.cartridgeaccountmeta_ownerGuid(this.__wbg_ptr);
951
943
  return takeObject(ret);
952
944
  }
953
945
  }
@@ -1000,6 +992,74 @@ export class CartridgeAccountWithMeta {
1000
992
  }
1001
993
  }
1002
994
 
995
+ const ControllerFactoryFinalization = (typeof FinalizationRegistry === 'undefined')
996
+ ? { register: () => {}, unregister: () => {} }
997
+ : new FinalizationRegistry(ptr => wasm.__wbg_controllerfactory_free(ptr >>> 0, 1));
998
+
999
+ export class ControllerFactory {
1000
+
1001
+ __destroy_into_raw() {
1002
+ const ptr = this.__wbg_ptr;
1003
+ this.__wbg_ptr = 0;
1004
+ ControllerFactoryFinalization.unregister(this);
1005
+ return ptr;
1006
+ }
1007
+
1008
+ free() {
1009
+ const ptr = this.__destroy_into_raw();
1010
+ wasm.__wbg_controllerfactory_free(ptr, 0);
1011
+ }
1012
+ /**
1013
+ * @param {string} app_id
1014
+ * @param {string} cartridge_api_url
1015
+ * @returns {CartridgeAccountWithMeta | undefined}
1016
+ */
1017
+ static from_storage(app_id, cartridge_api_url) {
1018
+ try {
1019
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1020
+ const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
1021
+ const len0 = WASM_VECTOR_LEN;
1022
+ const ptr1 = passStringToWasm0(cartridge_api_url, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
1023
+ const len1 = WASM_VECTOR_LEN;
1024
+ wasm.cartridgeaccount_fromStorage(retptr, ptr0, len0, ptr1, len1);
1025
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1026
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1027
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1028
+ if (r2) {
1029
+ throw takeObject(r1);
1030
+ }
1031
+ return r0 === 0 ? undefined : CartridgeAccountWithMeta.__wrap(r0);
1032
+ } finally {
1033
+ wasm.__wbindgen_add_to_stack_pointer(16);
1034
+ }
1035
+ }
1036
+ /**
1037
+ * @param {string} app_id
1038
+ * @param {string} username
1039
+ * @param {JsFelt} class_hash
1040
+ * @param {string} rpc_url
1041
+ * @param {JsFelt} chain_id
1042
+ * @param {JsFelt} address
1043
+ * @param {Owner} owner
1044
+ * @param {string} cartridge_api_url
1045
+ * @param {bigint} session_expires_at_s
1046
+ * @param {boolean | null} [is_controller_registered]
1047
+ * @returns {Promise<LoginResult>}
1048
+ */
1049
+ static login(app_id, username, class_hash, rpc_url, chain_id, address, owner, cartridge_api_url, session_expires_at_s, is_controller_registered) {
1050
+ const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
1051
+ const len0 = WASM_VECTOR_LEN;
1052
+ const ptr1 = passStringToWasm0(username, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
1053
+ const len1 = WASM_VECTOR_LEN;
1054
+ const ptr2 = passStringToWasm0(rpc_url, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
1055
+ const len2 = WASM_VECTOR_LEN;
1056
+ const ptr3 = passStringToWasm0(cartridge_api_url, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
1057
+ const len3 = WASM_VECTOR_LEN;
1058
+ const ret = wasm.controllerfactory_login(ptr0, len0, ptr1, len1, addHeapObject(class_hash), ptr2, len2, addHeapObject(chain_id), addHeapObject(address), addHeapObject(owner), ptr3, len3, session_expires_at_s, isLikeNone(is_controller_registered) ? 0xFFFFFF : is_controller_registered ? 1 : 0);
1059
+ return takeObject(ret);
1060
+ }
1061
+ }
1062
+
1003
1063
  const JsControllerErrorFinalization = (typeof FinalizationRegistry === 'undefined')
1004
1064
  ? { register: () => {}, unregister: () => {} }
1005
1065
  : new FinalizationRegistry(ptr => wasm.__wbg_jscontrollererror_free(ptr >>> 0, 1));
@@ -1094,6 +1154,41 @@ export class JsControllerError {
1094
1154
  }
1095
1155
  }
1096
1156
 
1157
+ const LoginResultFinalization = (typeof FinalizationRegistry === 'undefined')
1158
+ ? { register: () => {}, unregister: () => {} }
1159
+ : new FinalizationRegistry(ptr => wasm.__wbg_loginresult_free(ptr >>> 0, 1));
1160
+
1161
+ export class LoginResult {
1162
+
1163
+ static __wrap(ptr) {
1164
+ ptr = ptr >>> 0;
1165
+ const obj = Object.create(LoginResult.prototype);
1166
+ obj.__wbg_ptr = ptr;
1167
+ LoginResultFinalization.register(obj, obj.__wbg_ptr, obj);
1168
+ return obj;
1169
+ }
1170
+
1171
+ __destroy_into_raw() {
1172
+ const ptr = this.__wbg_ptr;
1173
+ this.__wbg_ptr = 0;
1174
+ LoginResultFinalization.unregister(this);
1175
+ return ptr;
1176
+ }
1177
+
1178
+ free() {
1179
+ const ptr = this.__destroy_into_raw();
1180
+ wasm.__wbg_loginresult_free(ptr, 0);
1181
+ }
1182
+ /**
1183
+ * @returns {Array<any>}
1184
+ */
1185
+ intoValues() {
1186
+ const ptr = this.__destroy_into_raw();
1187
+ const ret = wasm.loginresult_intoValues(ptr);
1188
+ return takeObject(ret);
1189
+ }
1190
+ }
1191
+
1097
1192
  export function __wbg_String_8f0eb39a4a4c2f66(arg0, arg1) {
1098
1193
  const ret = String(getObject(arg1));
1099
1194
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
@@ -1138,6 +1233,11 @@ export function __wbg_call_7cccdd69e0791ae2() { return handleError(function (arg
1138
1233
  return addHeapObject(ret);
1139
1234
  }, arguments) };
1140
1235
 
1236
+ export function __wbg_cartridgeaccountwithmeta_new(arg0) {
1237
+ const ret = CartridgeAccountWithMeta.__wrap(arg0);
1238
+ return addHeapObject(ret);
1239
+ };
1240
+
1141
1241
  export function __wbg_clearTimeout_6222fede17abcb1a(arg0) {
1142
1242
  const ret = clearTimeout(takeObject(arg0));
1143
1243
  return addHeapObject(ret);
@@ -1333,6 +1433,11 @@ export function __wbg_log_c222819a41e063d3(arg0) {
1333
1433
  console.log(getObject(arg0));
1334
1434
  };
1335
1435
 
1436
+ export function __wbg_loginresult_new(arg0) {
1437
+ const ret = LoginResult.__wrap(arg0);
1438
+ return addHeapObject(ret);
1439
+ };
1440
+
1336
1441
  export function __wbg_msCrypto_a61aeb35a24c1329(arg0) {
1337
1442
  const ret = getObject(arg0).msCrypto;
1338
1443
  return addHeapObject(ret);
@@ -1360,7 +1465,7 @@ export function __wbg_new_23a2665fac83c611(arg0, arg1) {
1360
1465
  const a = state0.a;
1361
1466
  state0.a = 0;
1362
1467
  try {
1363
- return __wbg_adapter_280(a, state0.b, arg0, arg1);
1468
+ return __wbg_adapter_286(a, state0.b, arg0, arg1);
1364
1469
  } finally {
1365
1470
  state0.a = a;
1366
1471
  }
@@ -1702,17 +1807,17 @@ export function __wbindgen_cb_drop(arg0) {
1702
1807
  return ret;
1703
1808
  };
1704
1809
 
1705
- export function __wbindgen_closure_wrapper2565(arg0, arg1, arg2) {
1810
+ export function __wbindgen_closure_wrapper2570(arg0, arg1, arg2) {
1706
1811
  const ret = makeClosure(arg0, arg1, 33, __wbg_adapter_44);
1707
1812
  return addHeapObject(ret);
1708
1813
  };
1709
1814
 
1710
- export function __wbindgen_closure_wrapper8144(arg0, arg1, arg2) {
1815
+ export function __wbindgen_closure_wrapper8191(arg0, arg1, arg2) {
1711
1816
  const ret = makeMutClosure(arg0, arg1, 871, __wbg_adapter_47);
1712
1817
  return addHeapObject(ret);
1713
1818
  };
1714
1819
 
1715
- export function __wbindgen_closure_wrapper8293(arg0, arg1, arg2) {
1820
+ export function __wbindgen_closure_wrapper8340(arg0, arg1, arg2) {
1716
1821
  const ret = makeMutClosure(arg0, arg1, 905, __wbg_adapter_50);
1717
1822
  return addHeapObject(ret);
1718
1823
  };
Binary file
@@ -66,6 +66,8 @@ export enum ErrorCode {
66
66
  PolicyChainIdMismatch = 136,
67
67
  InvalidOwner = 137,
68
68
  GasPriceTooHigh = 138,
69
+ TransactionTimeout = 139,
70
+ ConversionError = 140,
69
71
  }
70
72
  export interface JsCall {
71
73
  contractAddress: JsFelt;
@@ -252,7 +252,7 @@ function __wbg_adapter_201(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 | 64 | 65 | 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}
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 | 64 | 65 | 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 | 139 | 140}
256
256
  */
257
257
  export const ErrorCode = Object.freeze({
258
258
  StarknetFailedToReceiveTransaction: 1, "1": "StarknetFailedToReceiveTransaction",
@@ -320,6 +320,8 @@ export const ErrorCode = Object.freeze({
320
320
  PolicyChainIdMismatch: 136, "136": "PolicyChainIdMismatch",
321
321
  InvalidOwner: 137, "137": "InvalidOwner",
322
322
  GasPriceTooHigh: 138, "138": "GasPriceTooHigh",
323
+ TransactionTimeout: 139, "139": "TransactionTimeout",
324
+ ConversionError: 140, "140": "ConversionError",
323
325
  });
324
326
 
325
327
  const __wbindgen_enum_RequestCache = ["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"];
@@ -1033,12 +1035,12 @@ export function __wbindgen_cb_drop(arg0) {
1033
1035
  return ret;
1034
1036
  };
1035
1037
 
1036
- export function __wbindgen_closure_wrapper3363(arg0, arg1, arg2) {
1038
+ export function __wbindgen_closure_wrapper3365(arg0, arg1, arg2) {
1037
1039
  const ret = makeMutClosure(arg0, arg1, 401, __wbg_adapter_42);
1038
1040
  return addHeapObject(ret);
1039
1041
  };
1040
1042
 
1041
- export function __wbindgen_closure_wrapper3499(arg0, arg1, arg2) {
1043
+ export function __wbindgen_closure_wrapper3501(arg0, arg1, arg2) {
1042
1044
  const ret = makeMutClosure(arg0, arg1, 436, __wbg_adapter_45);
1043
1045
  return addHeapObject(ret);
1044
1046
  };
Binary file