@sovereign-sdk/universal-wallet-wasm 0.3.0 → 0.5.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.
@@ -1,65 +1,58 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * Well-known ids of types utilized in the rollup.
5
- */
4
+ * Well-known ids of types utilized in the rollup.
5
+ */
6
6
  export enum KnownTypeId {
7
- /**
8
- * The type id of the transaction.
9
- */
7
+ /**
8
+ * The type id of the transaction.
9
+ */
10
10
  Transaction = 0,
11
- /**
12
- * The type id of the unsigned transaction.
13
- */
11
+ /**
12
+ * The type id of the unsigned transaction.
13
+ */
14
14
  UnsignedTransaction = 1,
15
- /**
16
- * The type id of the runtime call.
17
- */
15
+ /**
16
+ * The type id of the runtime call.
17
+ */
18
18
  RuntimeCall = 2,
19
19
  }
20
20
  /**
21
- * A rollup schema is a description of the types that are utilized in the rollup.
22
- * It is used to serialize and deserialize the types.
23
- * As well as display them in a human-readable way that is verified by the rollup.
24
- */
21
+ * A rollup schema is a description of the types that are utilized in the rollup.
22
+ * It is used to serialize and deserialize the types.
23
+ * As well as display them in a human-readable way that is verified by the rollup.
24
+ */
25
25
  export class Schema {
26
+ private constructor();
26
27
  free(): void;
27
- /**
28
- * Creates a `Schema` instance from the provided JSON descriptor.
29
- * @param {string} json
30
- * @returns {Schema}
31
- */
28
+ /**
29
+ * Creates a `Schema` instance from the provided JSON descriptor.
30
+ */
32
31
  static fromJSON(json: string): Schema;
33
- /**
34
- * Converts the provided JSON to borsh according to the provided schema.
35
- * @param {number} type_index
36
- * @param {string} input
37
- * @returns {Uint8Array}
38
- */
32
+ /**
33
+ * Converts the provided JSON to borsh according to the provided schema.
34
+ */
39
35
  jsonToBorsh(type_index: number, input: string): Uint8Array;
40
- /**
41
- * Displays the provided borsh bytes as a string according to the provided schema.
42
- * @param {number} type_index
43
- * @param {Uint8Array} input
44
- * @returns {string}
45
- */
36
+ /**
37
+ * Displays the provided borsh bytes as a string according to the provided schema.
38
+ */
46
39
  display(type_index: number, input: Uint8Array): string;
47
- /**
48
- * Get the index of the provided known type within the schema.
49
- * @param {KnownTypeId} known_type_id
50
- * @returns {number}
51
- */
40
+ /**
41
+ * Get the index of the provided known type within the schema.
42
+ */
52
43
  knownTypeIndex(known_type_id: KnownTypeId): number;
53
- /**
54
- * Get the chain hash from the schema.
55
- */
56
- readonly chainHash: Uint8Array;
57
- /**
58
- * Returns the JSON descriptor that was used to create this schema instance.
59
- */
44
+ eip712Json(type_index: number, input: Uint8Array): string;
45
+ eip712SigningHash(type_index: number, input: Uint8Array): Uint8Array;
46
+ /**
47
+ * Returns the JSON descriptor that was used to create this schema instance.
48
+ */
60
49
  readonly descriptor: string;
61
- /**
62
- * Get the metadata hash from the schema.
63
- */
50
+ /**
51
+ * Get the metadata hash from the schema.
52
+ */
64
53
  readonly metadataHash: Uint8Array;
54
+ /**
55
+ * Get the chain hash from the schema.
56
+ */
57
+ readonly chainHash: Uint8Array;
65
58
  }
@@ -1,5 +1,5 @@
1
-
2
1
  import * as wasm from "./wallet_wasm_bg.wasm";
2
+ export * from "./wallet_wasm_bg.js";
3
3
  import { __wbg_set_wasm } from "./wallet_wasm_bg.js";
4
4
  __wbg_set_wasm(wasm);
5
- export * from "./wallet_wasm_bg.js";
5
+ wasm.__wbindgen_start();
@@ -24,21 +24,6 @@ function getStringFromWasm0(ptr, len) {
24
24
  return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
25
25
  }
26
26
 
27
- const heap = new Array(128).fill(undefined);
28
-
29
- heap.push(undefined, null, true, false);
30
-
31
- let heap_next = heap.length;
32
-
33
- function addHeapObject(obj) {
34
- if (heap_next === heap.length) heap.push(heap.length + 1);
35
- const idx = heap_next;
36
- heap_next = heap[idx];
37
-
38
- heap[idx] = obj;
39
- return idx;
40
- }
41
-
42
27
  let WASM_VECTOR_LEN = 0;
43
28
 
44
29
  const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
@@ -97,27 +82,10 @@ function passStringToWasm0(arg, malloc, realloc) {
97
82
  return ptr;
98
83
  }
99
84
 
100
- let cachedDataViewMemory0 = null;
101
-
102
- function getDataViewMemory0() {
103
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
104
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
105
- }
106
- return cachedDataViewMemory0;
107
- }
108
-
109
- function getObject(idx) { return heap[idx]; }
110
-
111
- function dropObject(idx) {
112
- if (idx < 132) return;
113
- heap[idx] = heap_next;
114
- heap_next = idx;
115
- }
116
-
117
- function takeObject(idx) {
118
- const ret = getObject(idx);
119
- dropObject(idx);
120
- return ret;
85
+ function takeFromExternrefTable0(idx) {
86
+ const value = wasm.__wbindgen_export_0.get(idx);
87
+ wasm.__externref_table_dealloc(idx);
88
+ return value;
121
89
  }
122
90
 
123
91
  function getArrayU8FromWasm0(ptr, len) {
@@ -132,30 +100,32 @@ function passArray8ToWasm0(arg, malloc) {
132
100
  return ptr;
133
101
  }
134
102
  /**
135
- * Well-known ids of types utilized in the rollup.
136
- */
103
+ * Well-known ids of types utilized in the rollup.
104
+ * @enum {0 | 1 | 2}
105
+ */
137
106
  export const KnownTypeId = Object.freeze({
138
- /**
139
- * The type id of the transaction.
140
- */
141
- Transaction:0,"0":"Transaction",
142
- /**
143
- * The type id of the unsigned transaction.
144
- */
145
- UnsignedTransaction:1,"1":"UnsignedTransaction",
146
- /**
147
- * The type id of the runtime call.
148
- */
149
- RuntimeCall:2,"2":"RuntimeCall", });
107
+ /**
108
+ * The type id of the transaction.
109
+ */
110
+ Transaction: 0, "0": "Transaction",
111
+ /**
112
+ * The type id of the unsigned transaction.
113
+ */
114
+ UnsignedTransaction: 1, "1": "UnsignedTransaction",
115
+ /**
116
+ * The type id of the runtime call.
117
+ */
118
+ RuntimeCall: 2, "2": "RuntimeCall",
119
+ });
150
120
 
151
121
  const SchemaFinalization = (typeof FinalizationRegistry === 'undefined')
152
122
  ? { register: () => {}, unregister: () => {} }
153
123
  : new FinalizationRegistry(ptr => wasm.__wbg_schema_free(ptr >>> 0, 1));
154
124
  /**
155
- * A rollup schema is a description of the types that are utilized in the rollup.
156
- * It is used to serialize and deserialize the types.
157
- * As well as display them in a human-readable way that is verified by the rollup.
158
- */
125
+ * A rollup schema is a description of the types that are utilized in the rollup.
126
+ * It is used to serialize and deserialize the types.
127
+ * As well as display them in a human-readable way that is verified by the rollup.
128
+ */
159
129
  export class Schema {
160
130
 
161
131
  static __wrap(ptr) {
@@ -178,174 +148,173 @@ export class Schema {
178
148
  wasm.__wbg_schema_free(ptr, 0);
179
149
  }
180
150
  /**
181
- * Creates a `Schema` instance from the provided JSON descriptor.
182
- * @param {string} json
183
- * @returns {Schema}
184
- */
151
+ * Creates a `Schema` instance from the provided JSON descriptor.
152
+ * @param {string} json
153
+ * @returns {Schema}
154
+ */
185
155
  static fromJSON(json) {
186
- try {
187
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
188
- const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
189
- const len0 = WASM_VECTOR_LEN;
190
- wasm.schema_fromJSON(retptr, ptr0, len0);
191
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
192
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
193
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
194
- if (r2) {
195
- throw takeObject(r1);
196
- }
197
- return Schema.__wrap(r0);
198
- } finally {
199
- wasm.__wbindgen_add_to_stack_pointer(16);
156
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
157
+ const len0 = WASM_VECTOR_LEN;
158
+ const ret = wasm.schema_fromJSON(ptr0, len0);
159
+ if (ret[2]) {
160
+ throw takeFromExternrefTable0(ret[1]);
200
161
  }
162
+ return Schema.__wrap(ret[0]);
201
163
  }
202
164
  /**
203
- * Returns the JSON descriptor that was used to create this schema instance.
204
- * @returns {string}
205
- */
165
+ * Returns the JSON descriptor that was used to create this schema instance.
166
+ * @returns {string}
167
+ */
206
168
  get descriptor() {
207
169
  let deferred1_0;
208
170
  let deferred1_1;
209
171
  try {
210
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
211
- wasm.schema_descriptor(retptr, this.__wbg_ptr);
212
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
213
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
214
- deferred1_0 = r0;
215
- deferred1_1 = r1;
216
- return getStringFromWasm0(r0, r1);
172
+ const ret = wasm.schema_descriptor(this.__wbg_ptr);
173
+ deferred1_0 = ret[0];
174
+ deferred1_1 = ret[1];
175
+ return getStringFromWasm0(ret[0], ret[1]);
217
176
  } finally {
218
- wasm.__wbindgen_add_to_stack_pointer(16);
219
177
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
220
178
  }
221
179
  }
222
180
  /**
223
- * Converts the provided JSON to borsh according to the provided schema.
224
- * @param {number} type_index
225
- * @param {string} input
226
- * @returns {Uint8Array}
227
- */
181
+ * Converts the provided JSON to borsh according to the provided schema.
182
+ * @param {number} type_index
183
+ * @param {string} input
184
+ * @returns {Uint8Array}
185
+ */
228
186
  jsonToBorsh(type_index, input) {
229
- try {
230
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
231
- const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
232
- const len0 = WASM_VECTOR_LEN;
233
- wasm.schema_jsonToBorsh(retptr, this.__wbg_ptr, type_index, ptr0, len0);
234
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
235
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
236
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
237
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
238
- if (r3) {
239
- throw takeObject(r2);
240
- }
241
- var v2 = getArrayU8FromWasm0(r0, r1).slice();
242
- wasm.__wbindgen_free(r0, r1 * 1, 1);
243
- return v2;
244
- } finally {
245
- wasm.__wbindgen_add_to_stack_pointer(16);
187
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
188
+ const len0 = WASM_VECTOR_LEN;
189
+ const ret = wasm.schema_jsonToBorsh(this.__wbg_ptr, type_index, ptr0, len0);
190
+ if (ret[3]) {
191
+ throw takeFromExternrefTable0(ret[2]);
246
192
  }
193
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
194
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
195
+ return v2;
247
196
  }
248
197
  /**
249
- * Displays the provided borsh bytes as a string according to the provided schema.
250
- * @param {number} type_index
251
- * @param {Uint8Array} input
252
- * @returns {string}
253
- */
198
+ * Displays the provided borsh bytes as a string according to the provided schema.
199
+ * @param {number} type_index
200
+ * @param {Uint8Array} input
201
+ * @returns {string}
202
+ */
254
203
  display(type_index, input) {
255
204
  let deferred3_0;
256
205
  let deferred3_1;
257
206
  try {
258
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
259
207
  const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
260
208
  const len0 = WASM_VECTOR_LEN;
261
- wasm.schema_display(retptr, this.__wbg_ptr, type_index, ptr0, len0);
262
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
263
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
264
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
265
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
266
- var ptr2 = r0;
267
- var len2 = r1;
268
- if (r3) {
209
+ const ret = wasm.schema_display(this.__wbg_ptr, type_index, ptr0, len0);
210
+ var ptr2 = ret[0];
211
+ var len2 = ret[1];
212
+ if (ret[3]) {
269
213
  ptr2 = 0; len2 = 0;
270
- throw takeObject(r2);
214
+ throw takeFromExternrefTable0(ret[2]);
271
215
  }
272
216
  deferred3_0 = ptr2;
273
217
  deferred3_1 = len2;
274
218
  return getStringFromWasm0(ptr2, len2);
275
219
  } finally {
276
- wasm.__wbindgen_add_to_stack_pointer(16);
277
220
  wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
278
221
  }
279
222
  }
280
223
  /**
281
- * Get the index of the provided known type within the schema.
282
- * @param {KnownTypeId} known_type_id
283
- * @returns {number}
284
- */
224
+ * Get the index of the provided known type within the schema.
225
+ * @param {KnownTypeId} known_type_id
226
+ * @returns {number}
227
+ */
285
228
  knownTypeIndex(known_type_id) {
286
- try {
287
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
288
- wasm.schema_knownTypeIndex(retptr, this.__wbg_ptr, known_type_id);
289
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
290
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
291
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
292
- if (r2) {
293
- throw takeObject(r1);
294
- }
295
- return r0 >>> 0;
296
- } finally {
297
- wasm.__wbindgen_add_to_stack_pointer(16);
229
+ const ret = wasm.schema_knownTypeIndex(this.__wbg_ptr, known_type_id);
230
+ if (ret[2]) {
231
+ throw takeFromExternrefTable0(ret[1]);
298
232
  }
233
+ return ret[0] >>> 0;
299
234
  }
300
235
  /**
301
- * Get the metadata hash from the schema.
302
- * @returns {Uint8Array}
303
- */
236
+ * Get the metadata hash from the schema.
237
+ * @returns {Uint8Array}
238
+ */
304
239
  get metadataHash() {
305
- try {
306
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
307
- wasm.schema_metadataHash(retptr, this.__wbg_ptr);
308
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
309
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
310
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
311
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
312
- if (r3) {
313
- throw takeObject(r2);
314
- }
315
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
316
- wasm.__wbindgen_free(r0, r1 * 1, 1);
317
- return v1;
318
- } finally {
319
- wasm.__wbindgen_add_to_stack_pointer(16);
240
+ const ret = wasm.schema_metadataHash(this.__wbg_ptr);
241
+ if (ret[3]) {
242
+ throw takeFromExternrefTable0(ret[2]);
320
243
  }
244
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
245
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
246
+ return v1;
321
247
  }
322
248
  /**
323
- * Get the chain hash from the schema.
324
- * @returns {Uint8Array}
325
- */
249
+ * Get the chain hash from the schema.
250
+ * @returns {Uint8Array}
251
+ */
326
252
  get chainHash() {
253
+ const ret = wasm.schema_chainHash(this.__wbg_ptr);
254
+ if (ret[3]) {
255
+ throw takeFromExternrefTable0(ret[2]);
256
+ }
257
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
258
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
259
+ return v1;
260
+ }
261
+ /**
262
+ * @param {number} type_index
263
+ * @param {Uint8Array} input
264
+ * @returns {string}
265
+ */
266
+ eip712Json(type_index, input) {
267
+ let deferred3_0;
268
+ let deferred3_1;
327
269
  try {
328
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
329
- wasm.schema_chainHash(retptr, this.__wbg_ptr);
330
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
331
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
332
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
333
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
334
- if (r3) {
335
- throw takeObject(r2);
270
+ const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
271
+ const len0 = WASM_VECTOR_LEN;
272
+ const ret = wasm.schema_eip712Json(this.__wbg_ptr, type_index, ptr0, len0);
273
+ var ptr2 = ret[0];
274
+ var len2 = ret[1];
275
+ if (ret[3]) {
276
+ ptr2 = 0; len2 = 0;
277
+ throw takeFromExternrefTable0(ret[2]);
336
278
  }
337
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
338
- wasm.__wbindgen_free(r0, r1 * 1, 1);
339
- return v1;
279
+ deferred3_0 = ptr2;
280
+ deferred3_1 = len2;
281
+ return getStringFromWasm0(ptr2, len2);
340
282
  } finally {
341
- wasm.__wbindgen_add_to_stack_pointer(16);
283
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
342
284
  }
343
285
  }
286
+ /**
287
+ * @param {number} type_index
288
+ * @param {Uint8Array} input
289
+ * @returns {Uint8Array}
290
+ */
291
+ eip712SigningHash(type_index, input) {
292
+ const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
293
+ const len0 = WASM_VECTOR_LEN;
294
+ const ret = wasm.schema_eip712SigningHash(this.__wbg_ptr, type_index, ptr0, len0);
295
+ if (ret[3]) {
296
+ throw takeFromExternrefTable0(ret[2]);
297
+ }
298
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
299
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
300
+ return v2;
301
+ }
344
302
  }
345
303
 
346
304
  export function __wbindgen_error_new(arg0, arg1) {
347
305
  const ret = new Error(getStringFromWasm0(arg0, arg1));
348
- return addHeapObject(ret);
306
+ return ret;
307
+ };
308
+
309
+ export function __wbindgen_init_externref_table() {
310
+ const table = wasm.__wbindgen_export_0;
311
+ const offset = table.grow(4);
312
+ table.set(0, undefined);
313
+ table.set(offset + 0, undefined);
314
+ table.set(offset + 1, null);
315
+ table.set(offset + 2, true);
316
+ table.set(offset + 3, false);
317
+ ;
349
318
  };
350
319
 
351
320
  export function __wbindgen_throw(arg0, arg1) {
Binary file
@@ -1,15 +1,19 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
- export function __wbg_schema_free(a: number, b: number): void;
5
- export function schema_fromJSON(a: number, b: number, c: number): void;
6
- export function schema_descriptor(a: number, b: number): void;
7
- export function schema_jsonToBorsh(a: number, b: number, c: number, d: number, e: number): void;
8
- export function schema_display(a: number, b: number, c: number, d: number, e: number): void;
9
- export function schema_knownTypeIndex(a: number, b: number, c: number): void;
10
- export function schema_metadataHash(a: number, b: number): void;
11
- export function schema_chainHash(a: number, b: number): void;
12
- export function __wbindgen_add_to_stack_pointer(a: number): number;
13
- export function __wbindgen_malloc(a: number, b: number): number;
14
- export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
15
- export function __wbindgen_free(a: number, b: number, c: number): void;
4
+ export const __wbg_schema_free: (a: number, b: number) => void;
5
+ export const schema_fromJSON: (a: number, b: number) => [number, number, number];
6
+ export const schema_descriptor: (a: number) => [number, number];
7
+ export const schema_jsonToBorsh: (a: number, b: number, c: number, d: number) => [number, number, number, number];
8
+ export const schema_display: (a: number, b: number, c: number, d: number) => [number, number, number, number];
9
+ export const schema_knownTypeIndex: (a: number, b: number) => [number, number, number];
10
+ export const schema_metadataHash: (a: number) => [number, number, number, number];
11
+ export const schema_chainHash: (a: number) => [number, number, number, number];
12
+ export const schema_eip712Json: (a: number, b: number, c: number, d: number) => [number, number, number, number];
13
+ export const schema_eip712SigningHash: (a: number, b: number, c: number, d: number) => [number, number, number, number];
14
+ export const __wbindgen_export_0: WebAssembly.Table;
15
+ export const __wbindgen_malloc: (a: number, b: number) => number;
16
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
17
+ export const __externref_table_dealloc: (a: number) => void;
18
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
19
+ export const __wbindgen_start: () => void;
@@ -1,65 +1,58 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * Well-known ids of types utilized in the rollup.
5
- */
4
+ * Well-known ids of types utilized in the rollup.
5
+ */
6
6
  export enum KnownTypeId {
7
- /**
8
- * The type id of the transaction.
9
- */
7
+ /**
8
+ * The type id of the transaction.
9
+ */
10
10
  Transaction = 0,
11
- /**
12
- * The type id of the unsigned transaction.
13
- */
11
+ /**
12
+ * The type id of the unsigned transaction.
13
+ */
14
14
  UnsignedTransaction = 1,
15
- /**
16
- * The type id of the runtime call.
17
- */
15
+ /**
16
+ * The type id of the runtime call.
17
+ */
18
18
  RuntimeCall = 2,
19
19
  }
20
20
  /**
21
- * A rollup schema is a description of the types that are utilized in the rollup.
22
- * It is used to serialize and deserialize the types.
23
- * As well as display them in a human-readable way that is verified by the rollup.
24
- */
21
+ * A rollup schema is a description of the types that are utilized in the rollup.
22
+ * It is used to serialize and deserialize the types.
23
+ * As well as display them in a human-readable way that is verified by the rollup.
24
+ */
25
25
  export class Schema {
26
+ private constructor();
26
27
  free(): void;
27
- /**
28
- * Creates a `Schema` instance from the provided JSON descriptor.
29
- * @param {string} json
30
- * @returns {Schema}
31
- */
28
+ /**
29
+ * Creates a `Schema` instance from the provided JSON descriptor.
30
+ */
32
31
  static fromJSON(json: string): Schema;
33
- /**
34
- * Converts the provided JSON to borsh according to the provided schema.
35
- * @param {number} type_index
36
- * @param {string} input
37
- * @returns {Uint8Array}
38
- */
32
+ /**
33
+ * Converts the provided JSON to borsh according to the provided schema.
34
+ */
39
35
  jsonToBorsh(type_index: number, input: string): Uint8Array;
40
- /**
41
- * Displays the provided borsh bytes as a string according to the provided schema.
42
- * @param {number} type_index
43
- * @param {Uint8Array} input
44
- * @returns {string}
45
- */
36
+ /**
37
+ * Displays the provided borsh bytes as a string according to the provided schema.
38
+ */
46
39
  display(type_index: number, input: Uint8Array): string;
47
- /**
48
- * Get the index of the provided known type within the schema.
49
- * @param {KnownTypeId} known_type_id
50
- * @returns {number}
51
- */
40
+ /**
41
+ * Get the index of the provided known type within the schema.
42
+ */
52
43
  knownTypeIndex(known_type_id: KnownTypeId): number;
53
- /**
54
- * Get the chain hash from the schema.
55
- */
56
- readonly chainHash: Uint8Array;
57
- /**
58
- * Returns the JSON descriptor that was used to create this schema instance.
59
- */
44
+ eip712Json(type_index: number, input: Uint8Array): string;
45
+ eip712SigningHash(type_index: number, input: Uint8Array): Uint8Array;
46
+ /**
47
+ * Returns the JSON descriptor that was used to create this schema instance.
48
+ */
60
49
  readonly descriptor: string;
61
- /**
62
- * Get the metadata hash from the schema.
63
- */
50
+ /**
51
+ * Get the metadata hash from the schema.
52
+ */
64
53
  readonly metadataHash: Uint8Array;
54
+ /**
55
+ * Get the chain hash from the schema.
56
+ */
57
+ readonly chainHash: Uint8Array;
65
58
  }
@@ -22,21 +22,6 @@ function getStringFromWasm0(ptr, len) {
22
22
  return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
23
23
  }
24
24
 
25
- const heap = new Array(128).fill(undefined);
26
-
27
- heap.push(undefined, null, true, false);
28
-
29
- let heap_next = heap.length;
30
-
31
- function addHeapObject(obj) {
32
- if (heap_next === heap.length) heap.push(heap.length + 1);
33
- const idx = heap_next;
34
- heap_next = heap[idx];
35
-
36
- heap[idx] = obj;
37
- return idx;
38
- }
39
-
40
25
  let WASM_VECTOR_LEN = 0;
41
26
 
42
27
  let cachedTextEncoder = new TextEncoder('utf-8');
@@ -93,27 +78,10 @@ function passStringToWasm0(arg, malloc, realloc) {
93
78
  return ptr;
94
79
  }
95
80
 
96
- let cachedDataViewMemory0 = null;
97
-
98
- function getDataViewMemory0() {
99
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
100
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
101
- }
102
- return cachedDataViewMemory0;
103
- }
104
-
105
- function getObject(idx) { return heap[idx]; }
106
-
107
- function dropObject(idx) {
108
- if (idx < 132) return;
109
- heap[idx] = heap_next;
110
- heap_next = idx;
111
- }
112
-
113
- function takeObject(idx) {
114
- const ret = getObject(idx);
115
- dropObject(idx);
116
- return ret;
81
+ function takeFromExternrefTable0(idx) {
82
+ const value = wasm.__wbindgen_export_0.get(idx);
83
+ wasm.__externref_table_dealloc(idx);
84
+ return value;
117
85
  }
118
86
 
119
87
  function getArrayU8FromWasm0(ptr, len) {
@@ -128,30 +96,32 @@ function passArray8ToWasm0(arg, malloc) {
128
96
  return ptr;
129
97
  }
130
98
  /**
131
- * Well-known ids of types utilized in the rollup.
132
- */
99
+ * Well-known ids of types utilized in the rollup.
100
+ * @enum {0 | 1 | 2}
101
+ */
133
102
  module.exports.KnownTypeId = Object.freeze({
134
- /**
135
- * The type id of the transaction.
136
- */
137
- Transaction:0,"0":"Transaction",
138
- /**
139
- * The type id of the unsigned transaction.
140
- */
141
- UnsignedTransaction:1,"1":"UnsignedTransaction",
142
- /**
143
- * The type id of the runtime call.
144
- */
145
- RuntimeCall:2,"2":"RuntimeCall", });
103
+ /**
104
+ * The type id of the transaction.
105
+ */
106
+ Transaction: 0, "0": "Transaction",
107
+ /**
108
+ * The type id of the unsigned transaction.
109
+ */
110
+ UnsignedTransaction: 1, "1": "UnsignedTransaction",
111
+ /**
112
+ * The type id of the runtime call.
113
+ */
114
+ RuntimeCall: 2, "2": "RuntimeCall",
115
+ });
146
116
 
147
117
  const SchemaFinalization = (typeof FinalizationRegistry === 'undefined')
148
118
  ? { register: () => {}, unregister: () => {} }
149
119
  : new FinalizationRegistry(ptr => wasm.__wbg_schema_free(ptr >>> 0, 1));
150
120
  /**
151
- * A rollup schema is a description of the types that are utilized in the rollup.
152
- * It is used to serialize and deserialize the types.
153
- * As well as display them in a human-readable way that is verified by the rollup.
154
- */
121
+ * A rollup schema is a description of the types that are utilized in the rollup.
122
+ * It is used to serialize and deserialize the types.
123
+ * As well as display them in a human-readable way that is verified by the rollup.
124
+ */
155
125
  class Schema {
156
126
 
157
127
  static __wrap(ptr) {
@@ -174,175 +144,174 @@ class Schema {
174
144
  wasm.__wbg_schema_free(ptr, 0);
175
145
  }
176
146
  /**
177
- * Creates a `Schema` instance from the provided JSON descriptor.
178
- * @param {string} json
179
- * @returns {Schema}
180
- */
147
+ * Creates a `Schema` instance from the provided JSON descriptor.
148
+ * @param {string} json
149
+ * @returns {Schema}
150
+ */
181
151
  static fromJSON(json) {
182
- try {
183
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
184
- const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
185
- const len0 = WASM_VECTOR_LEN;
186
- wasm.schema_fromJSON(retptr, ptr0, len0);
187
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
188
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
189
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
190
- if (r2) {
191
- throw takeObject(r1);
192
- }
193
- return Schema.__wrap(r0);
194
- } finally {
195
- wasm.__wbindgen_add_to_stack_pointer(16);
152
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
153
+ const len0 = WASM_VECTOR_LEN;
154
+ const ret = wasm.schema_fromJSON(ptr0, len0);
155
+ if (ret[2]) {
156
+ throw takeFromExternrefTable0(ret[1]);
196
157
  }
158
+ return Schema.__wrap(ret[0]);
197
159
  }
198
160
  /**
199
- * Returns the JSON descriptor that was used to create this schema instance.
200
- * @returns {string}
201
- */
161
+ * Returns the JSON descriptor that was used to create this schema instance.
162
+ * @returns {string}
163
+ */
202
164
  get descriptor() {
203
165
  let deferred1_0;
204
166
  let deferred1_1;
205
167
  try {
206
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
207
- wasm.schema_descriptor(retptr, this.__wbg_ptr);
208
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
209
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
210
- deferred1_0 = r0;
211
- deferred1_1 = r1;
212
- return getStringFromWasm0(r0, r1);
168
+ const ret = wasm.schema_descriptor(this.__wbg_ptr);
169
+ deferred1_0 = ret[0];
170
+ deferred1_1 = ret[1];
171
+ return getStringFromWasm0(ret[0], ret[1]);
213
172
  } finally {
214
- wasm.__wbindgen_add_to_stack_pointer(16);
215
173
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
216
174
  }
217
175
  }
218
176
  /**
219
- * Converts the provided JSON to borsh according to the provided schema.
220
- * @param {number} type_index
221
- * @param {string} input
222
- * @returns {Uint8Array}
223
- */
177
+ * Converts the provided JSON to borsh according to the provided schema.
178
+ * @param {number} type_index
179
+ * @param {string} input
180
+ * @returns {Uint8Array}
181
+ */
224
182
  jsonToBorsh(type_index, input) {
225
- try {
226
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
227
- const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
228
- const len0 = WASM_VECTOR_LEN;
229
- wasm.schema_jsonToBorsh(retptr, this.__wbg_ptr, type_index, ptr0, len0);
230
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
231
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
232
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
233
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
234
- if (r3) {
235
- throw takeObject(r2);
236
- }
237
- var v2 = getArrayU8FromWasm0(r0, r1).slice();
238
- wasm.__wbindgen_free(r0, r1 * 1, 1);
239
- return v2;
240
- } finally {
241
- wasm.__wbindgen_add_to_stack_pointer(16);
183
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
184
+ const len0 = WASM_VECTOR_LEN;
185
+ const ret = wasm.schema_jsonToBorsh(this.__wbg_ptr, type_index, ptr0, len0);
186
+ if (ret[3]) {
187
+ throw takeFromExternrefTable0(ret[2]);
242
188
  }
189
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
190
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
191
+ return v2;
243
192
  }
244
193
  /**
245
- * Displays the provided borsh bytes as a string according to the provided schema.
246
- * @param {number} type_index
247
- * @param {Uint8Array} input
248
- * @returns {string}
249
- */
194
+ * Displays the provided borsh bytes as a string according to the provided schema.
195
+ * @param {number} type_index
196
+ * @param {Uint8Array} input
197
+ * @returns {string}
198
+ */
250
199
  display(type_index, input) {
251
200
  let deferred3_0;
252
201
  let deferred3_1;
253
202
  try {
254
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
255
203
  const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
256
204
  const len0 = WASM_VECTOR_LEN;
257
- wasm.schema_display(retptr, this.__wbg_ptr, type_index, ptr0, len0);
258
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
259
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
260
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
261
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
262
- var ptr2 = r0;
263
- var len2 = r1;
264
- if (r3) {
205
+ const ret = wasm.schema_display(this.__wbg_ptr, type_index, ptr0, len0);
206
+ var ptr2 = ret[0];
207
+ var len2 = ret[1];
208
+ if (ret[3]) {
265
209
  ptr2 = 0; len2 = 0;
266
- throw takeObject(r2);
210
+ throw takeFromExternrefTable0(ret[2]);
267
211
  }
268
212
  deferred3_0 = ptr2;
269
213
  deferred3_1 = len2;
270
214
  return getStringFromWasm0(ptr2, len2);
271
215
  } finally {
272
- wasm.__wbindgen_add_to_stack_pointer(16);
273
216
  wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
274
217
  }
275
218
  }
276
219
  /**
277
- * Get the index of the provided known type within the schema.
278
- * @param {KnownTypeId} known_type_id
279
- * @returns {number}
280
- */
220
+ * Get the index of the provided known type within the schema.
221
+ * @param {KnownTypeId} known_type_id
222
+ * @returns {number}
223
+ */
281
224
  knownTypeIndex(known_type_id) {
282
- try {
283
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
284
- wasm.schema_knownTypeIndex(retptr, this.__wbg_ptr, known_type_id);
285
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
286
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
287
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
288
- if (r2) {
289
- throw takeObject(r1);
290
- }
291
- return r0 >>> 0;
292
- } finally {
293
- wasm.__wbindgen_add_to_stack_pointer(16);
225
+ const ret = wasm.schema_knownTypeIndex(this.__wbg_ptr, known_type_id);
226
+ if (ret[2]) {
227
+ throw takeFromExternrefTable0(ret[1]);
294
228
  }
229
+ return ret[0] >>> 0;
295
230
  }
296
231
  /**
297
- * Get the metadata hash from the schema.
298
- * @returns {Uint8Array}
299
- */
232
+ * Get the metadata hash from the schema.
233
+ * @returns {Uint8Array}
234
+ */
300
235
  get metadataHash() {
301
- try {
302
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
303
- wasm.schema_metadataHash(retptr, this.__wbg_ptr);
304
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
305
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
306
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
307
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
308
- if (r3) {
309
- throw takeObject(r2);
310
- }
311
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
312
- wasm.__wbindgen_free(r0, r1 * 1, 1);
313
- return v1;
314
- } finally {
315
- wasm.__wbindgen_add_to_stack_pointer(16);
236
+ const ret = wasm.schema_metadataHash(this.__wbg_ptr);
237
+ if (ret[3]) {
238
+ throw takeFromExternrefTable0(ret[2]);
316
239
  }
240
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
241
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
242
+ return v1;
317
243
  }
318
244
  /**
319
- * Get the chain hash from the schema.
320
- * @returns {Uint8Array}
321
- */
245
+ * Get the chain hash from the schema.
246
+ * @returns {Uint8Array}
247
+ */
322
248
  get chainHash() {
249
+ const ret = wasm.schema_chainHash(this.__wbg_ptr);
250
+ if (ret[3]) {
251
+ throw takeFromExternrefTable0(ret[2]);
252
+ }
253
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
254
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
255
+ return v1;
256
+ }
257
+ /**
258
+ * @param {number} type_index
259
+ * @param {Uint8Array} input
260
+ * @returns {string}
261
+ */
262
+ eip712Json(type_index, input) {
263
+ let deferred3_0;
264
+ let deferred3_1;
323
265
  try {
324
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
325
- wasm.schema_chainHash(retptr, this.__wbg_ptr);
326
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
327
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
328
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
329
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
330
- if (r3) {
331
- throw takeObject(r2);
266
+ const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
267
+ const len0 = WASM_VECTOR_LEN;
268
+ const ret = wasm.schema_eip712Json(this.__wbg_ptr, type_index, ptr0, len0);
269
+ var ptr2 = ret[0];
270
+ var len2 = ret[1];
271
+ if (ret[3]) {
272
+ ptr2 = 0; len2 = 0;
273
+ throw takeFromExternrefTable0(ret[2]);
332
274
  }
333
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
334
- wasm.__wbindgen_free(r0, r1 * 1, 1);
335
- return v1;
275
+ deferred3_0 = ptr2;
276
+ deferred3_1 = len2;
277
+ return getStringFromWasm0(ptr2, len2);
336
278
  } finally {
337
- wasm.__wbindgen_add_to_stack_pointer(16);
279
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
338
280
  }
339
281
  }
282
+ /**
283
+ * @param {number} type_index
284
+ * @param {Uint8Array} input
285
+ * @returns {Uint8Array}
286
+ */
287
+ eip712SigningHash(type_index, input) {
288
+ const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
289
+ const len0 = WASM_VECTOR_LEN;
290
+ const ret = wasm.schema_eip712SigningHash(this.__wbg_ptr, type_index, ptr0, len0);
291
+ if (ret[3]) {
292
+ throw takeFromExternrefTable0(ret[2]);
293
+ }
294
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
295
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
296
+ return v2;
297
+ }
340
298
  }
341
299
  module.exports.Schema = Schema;
342
300
 
343
301
  module.exports.__wbindgen_error_new = function(arg0, arg1) {
344
302
  const ret = new Error(getStringFromWasm0(arg0, arg1));
345
- return addHeapObject(ret);
303
+ return ret;
304
+ };
305
+
306
+ module.exports.__wbindgen_init_externref_table = function() {
307
+ const table = wasm.__wbindgen_export_0;
308
+ const offset = table.grow(4);
309
+ table.set(0, undefined);
310
+ table.set(offset + 0, undefined);
311
+ table.set(offset + 1, null);
312
+ table.set(offset + 2, true);
313
+ table.set(offset + 3, false);
314
+ ;
346
315
  };
347
316
 
348
317
  module.exports.__wbindgen_throw = function(arg0, arg1) {
@@ -357,3 +326,5 @@ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
357
326
  wasm = wasmInstance.exports;
358
327
  module.exports.__wasm = wasm;
359
328
 
329
+ wasm.__wbindgen_start();
330
+
Binary file
@@ -1,15 +1,19 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
- export function __wbg_schema_free(a: number, b: number): void;
5
- export function schema_fromJSON(a: number, b: number, c: number): void;
6
- export function schema_descriptor(a: number, b: number): void;
7
- export function schema_jsonToBorsh(a: number, b: number, c: number, d: number, e: number): void;
8
- export function schema_display(a: number, b: number, c: number, d: number, e: number): void;
9
- export function schema_knownTypeIndex(a: number, b: number, c: number): void;
10
- export function schema_metadataHash(a: number, b: number): void;
11
- export function schema_chainHash(a: number, b: number): void;
12
- export function __wbindgen_add_to_stack_pointer(a: number): number;
13
- export function __wbindgen_malloc(a: number, b: number): number;
14
- export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
15
- export function __wbindgen_free(a: number, b: number, c: number): void;
4
+ export const __wbg_schema_free: (a: number, b: number) => void;
5
+ export const schema_fromJSON: (a: number, b: number) => [number, number, number];
6
+ export const schema_descriptor: (a: number) => [number, number];
7
+ export const schema_jsonToBorsh: (a: number, b: number, c: number, d: number) => [number, number, number, number];
8
+ export const schema_display: (a: number, b: number, c: number, d: number) => [number, number, number, number];
9
+ export const schema_knownTypeIndex: (a: number, b: number) => [number, number, number];
10
+ export const schema_metadataHash: (a: number) => [number, number, number, number];
11
+ export const schema_chainHash: (a: number) => [number, number, number, number];
12
+ export const schema_eip712Json: (a: number, b: number, c: number, d: number) => [number, number, number, number];
13
+ export const schema_eip712SigningHash: (a: number, b: number, c: number, d: number) => [number, number, number, number];
14
+ export const __wbindgen_export_0: WebAssembly.Table;
15
+ export const __wbindgen_malloc: (a: number, b: number) => number;
16
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
17
+ export const __externref_table_dealloc: (a: number) => void;
18
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
19
+ export const __wbindgen_start: () => void;
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@sovereign-sdk/universal-wallet-wasm",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
+ "repository": "github:Sovereign-Labs/sovereign-sdk-web3-js",
4
5
  "files": [
5
6
  "dist/**/*",
6
7
  "!dist/**/.gitignore",