@sovereign-sdk/universal-wallet-wasm 0.0.2 → 0.1.0

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.
@@ -2,6 +2,13 @@
2
2
  /* eslint-disable */
3
3
  /**
4
4
  */
5
+ export enum KnownTypeId {
6
+ Transaction = 0,
7
+ UnsignedTransaction = 1,
8
+ RuntimeCall = 2,
9
+ }
10
+ /**
11
+ */
5
12
  export class Schema {
6
13
  free(): void;
7
14
  /**
@@ -12,14 +19,22 @@ export class Schema {
12
19
  static fromJSON(json: string): Schema;
13
20
  /**
14
21
  * Converts the provided JSON to borsh according to the provided schema.
22
+ * @param {number} type_index
15
23
  * @param {string} input
16
24
  * @returns {Uint8Array}
17
25
  */
18
- jsonToBorsh(input: string): Uint8Array;
26
+ jsonToBorsh(type_index: number, input: string): Uint8Array;
19
27
  /**
20
28
  * Displays the provided borsh bytes as a string according to the provided schema.
29
+ * @param {number} type_index
21
30
  * @param {Uint8Array} input
22
31
  * @returns {string}
23
32
  */
24
- display(input: Uint8Array): string;
33
+ display(type_index: number, input: Uint8Array): string;
34
+ /**
35
+ * Get the index of the provided known type within the schema.
36
+ * @param {KnownTypeId} known_type_id
37
+ * @returns {number}
38
+ */
39
+ knownTypeIndex(known_type_id: KnownTypeId): number;
25
40
  }
@@ -131,6 +131,9 @@ function passArray8ToWasm0(arg, malloc) {
131
131
  WASM_VECTOR_LEN = arg.length;
132
132
  return ptr;
133
133
  }
134
+ /**
135
+ */
136
+ export const KnownTypeId = Object.freeze({ Transaction:0,"0":"Transaction",UnsignedTransaction:1,"1":"UnsignedTransaction",RuntimeCall:2,"2":"RuntimeCall", });
134
137
 
135
138
  const SchemaFinalization = (typeof FinalizationRegistry === 'undefined')
136
139
  ? { register: () => {}, unregister: () => {} }
@@ -182,15 +185,16 @@ export class Schema {
182
185
  }
183
186
  /**
184
187
  * Converts the provided JSON to borsh according to the provided schema.
188
+ * @param {number} type_index
185
189
  * @param {string} input
186
190
  * @returns {Uint8Array}
187
191
  */
188
- jsonToBorsh(input) {
192
+ jsonToBorsh(type_index, input) {
189
193
  try {
190
194
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
191
195
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
192
196
  const len0 = WASM_VECTOR_LEN;
193
- wasm.schema_jsonToBorsh(retptr, this.__wbg_ptr, ptr0, len0);
197
+ wasm.schema_jsonToBorsh(retptr, this.__wbg_ptr, type_index, ptr0, len0);
194
198
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
195
199
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
196
200
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -207,17 +211,18 @@ export class Schema {
207
211
  }
208
212
  /**
209
213
  * Displays the provided borsh bytes as a string according to the provided schema.
214
+ * @param {number} type_index
210
215
  * @param {Uint8Array} input
211
216
  * @returns {string}
212
217
  */
213
- display(input) {
218
+ display(type_index, input) {
214
219
  let deferred3_0;
215
220
  let deferred3_1;
216
221
  try {
217
222
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
218
223
  const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
219
224
  const len0 = WASM_VECTOR_LEN;
220
- wasm.schema_display(retptr, this.__wbg_ptr, ptr0, len0);
225
+ wasm.schema_display(retptr, this.__wbg_ptr, type_index, ptr0, len0);
221
226
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
222
227
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
223
228
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -236,6 +241,26 @@ export class Schema {
236
241
  wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
237
242
  }
238
243
  }
244
+ /**
245
+ * Get the index of the provided known type within the schema.
246
+ * @param {KnownTypeId} known_type_id
247
+ * @returns {number}
248
+ */
249
+ knownTypeIndex(known_type_id) {
250
+ try {
251
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
252
+ wasm.schema_knownTypeIndex(retptr, this.__wbg_ptr, known_type_id);
253
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
254
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
255
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
256
+ if (r2) {
257
+ throw takeObject(r1);
258
+ }
259
+ return r0 >>> 0;
260
+ } finally {
261
+ wasm.__wbindgen_add_to_stack_pointer(16);
262
+ }
263
+ }
239
264
  }
240
265
 
241
266
  export function __wbindgen_string_new(arg0, arg1) {
Binary file
@@ -3,8 +3,9 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export function __wbg_schema_free(a: number, b: number): void;
5
5
  export function schema_fromJSON(a: number, b: number, c: number): void;
6
- export function schema_jsonToBorsh(a: number, b: number, c: number, d: number): void;
7
- export function schema_display(a: number, b: number, c: number, d: number): void;
6
+ export function schema_jsonToBorsh(a: number, b: number, c: number, d: number, e: number): void;
7
+ export function schema_display(a: number, b: number, c: number, d: number, e: number): void;
8
+ export function schema_knownTypeIndex(a: number, b: number, c: number): void;
8
9
  export function __wbindgen_add_to_stack_pointer(a: number): number;
9
10
  export function __wbindgen_malloc(a: number, b: number): number;
10
11
  export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
@@ -2,6 +2,13 @@
2
2
  /* eslint-disable */
3
3
  /**
4
4
  */
5
+ export enum KnownTypeId {
6
+ Transaction = 0,
7
+ UnsignedTransaction = 1,
8
+ RuntimeCall = 2,
9
+ }
10
+ /**
11
+ */
5
12
  export class Schema {
6
13
  free(): void;
7
14
  /**
@@ -12,14 +19,22 @@ export class Schema {
12
19
  static fromJSON(json: string): Schema;
13
20
  /**
14
21
  * Converts the provided JSON to borsh according to the provided schema.
22
+ * @param {number} type_index
15
23
  * @param {string} input
16
24
  * @returns {Uint8Array}
17
25
  */
18
- jsonToBorsh(input: string): Uint8Array;
26
+ jsonToBorsh(type_index: number, input: string): Uint8Array;
19
27
  /**
20
28
  * Displays the provided borsh bytes as a string according to the provided schema.
29
+ * @param {number} type_index
21
30
  * @param {Uint8Array} input
22
31
  * @returns {string}
23
32
  */
24
- display(input: Uint8Array): string;
33
+ display(type_index: number, input: Uint8Array): string;
34
+ /**
35
+ * Get the index of the provided known type within the schema.
36
+ * @param {KnownTypeId} known_type_id
37
+ * @returns {number}
38
+ */
39
+ knownTypeIndex(known_type_id: KnownTypeId): number;
25
40
  }
@@ -127,6 +127,9 @@ function passArray8ToWasm0(arg, malloc) {
127
127
  WASM_VECTOR_LEN = arg.length;
128
128
  return ptr;
129
129
  }
130
+ /**
131
+ */
132
+ module.exports.KnownTypeId = Object.freeze({ Transaction:0,"0":"Transaction",UnsignedTransaction:1,"1":"UnsignedTransaction",RuntimeCall:2,"2":"RuntimeCall", });
130
133
 
131
134
  const SchemaFinalization = (typeof FinalizationRegistry === 'undefined')
132
135
  ? { register: () => {}, unregister: () => {} }
@@ -178,15 +181,16 @@ class Schema {
178
181
  }
179
182
  /**
180
183
  * Converts the provided JSON to borsh according to the provided schema.
184
+ * @param {number} type_index
181
185
  * @param {string} input
182
186
  * @returns {Uint8Array}
183
187
  */
184
- jsonToBorsh(input) {
188
+ jsonToBorsh(type_index, input) {
185
189
  try {
186
190
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
187
191
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
188
192
  const len0 = WASM_VECTOR_LEN;
189
- wasm.schema_jsonToBorsh(retptr, this.__wbg_ptr, ptr0, len0);
193
+ wasm.schema_jsonToBorsh(retptr, this.__wbg_ptr, type_index, ptr0, len0);
190
194
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
191
195
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
192
196
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -203,17 +207,18 @@ class Schema {
203
207
  }
204
208
  /**
205
209
  * Displays the provided borsh bytes as a string according to the provided schema.
210
+ * @param {number} type_index
206
211
  * @param {Uint8Array} input
207
212
  * @returns {string}
208
213
  */
209
- display(input) {
214
+ display(type_index, input) {
210
215
  let deferred3_0;
211
216
  let deferred3_1;
212
217
  try {
213
218
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
214
219
  const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
215
220
  const len0 = WASM_VECTOR_LEN;
216
- wasm.schema_display(retptr, this.__wbg_ptr, ptr0, len0);
221
+ wasm.schema_display(retptr, this.__wbg_ptr, type_index, ptr0, len0);
217
222
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
218
223
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
219
224
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -232,6 +237,26 @@ class Schema {
232
237
  wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
233
238
  }
234
239
  }
240
+ /**
241
+ * Get the index of the provided known type within the schema.
242
+ * @param {KnownTypeId} known_type_id
243
+ * @returns {number}
244
+ */
245
+ knownTypeIndex(known_type_id) {
246
+ try {
247
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
248
+ wasm.schema_knownTypeIndex(retptr, this.__wbg_ptr, known_type_id);
249
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
250
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
251
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
252
+ if (r2) {
253
+ throw takeObject(r1);
254
+ }
255
+ return r0 >>> 0;
256
+ } finally {
257
+ wasm.__wbindgen_add_to_stack_pointer(16);
258
+ }
259
+ }
235
260
  }
236
261
  module.exports.Schema = Schema;
237
262
 
Binary file
@@ -3,8 +3,9 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export function __wbg_schema_free(a: number, b: number): void;
5
5
  export function schema_fromJSON(a: number, b: number, c: number): void;
6
- export function schema_jsonToBorsh(a: number, b: number, c: number, d: number): void;
7
- export function schema_display(a: number, b: number, c: number, d: number): void;
6
+ export function schema_jsonToBorsh(a: number, b: number, c: number, d: number, e: number): void;
7
+ export function schema_display(a: number, b: number, c: number, d: number, e: number): void;
8
+ export function schema_knownTypeIndex(a: number, b: number, c: number): void;
8
9
  export function __wbindgen_add_to_stack_pointer(a: number): number;
9
10
  export function __wbindgen_malloc(a: number, b: number): number;
10
11
  export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sovereign-sdk/universal-wallet-wasm",
3
- "version": "0.0.2",
3
+ "version": "0.1.0",
4
4
  "files": [
5
5
  "dist/**/*",
6
6
  "!dist/**/.gitignore",
@@ -10,13 +10,14 @@
10
10
  "README.md"
11
11
  ],
12
12
  "exports": {
13
- ".": {
14
- "types": "./dist/node/wallet_wasm.d.ts",
15
- "node": "./dist/node/wallet_wasm.js",
16
- "import": "./dist/esm/wallet_wasm.js",
17
- "require": "./dist/node/wallet_wasm.js"
18
- }
13
+ "types": "./dist/node/wallet_wasm.d.ts",
14
+ "node": "./dist/node/wallet_wasm.js",
15
+ "import": "./dist/esm/wallet_wasm.js",
16
+ "require": "./dist/node/wallet_wasm.js"
19
17
  },
18
+ "main": "dist/node/wallet_wasm.js",
19
+ "module": "dist/esm/wallet_wasm.js",
20
+ "types": "dist/node/wallet_wasm.d.ts",
20
21
  "devDependencies": {
21
22
  "@types/node": "^22.7.4",
22
23
  "vitest": "^2.1.1",