@sovereign-sdk/universal-wallet-wasm 0.1.3 → 0.1.4

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/README.md CHANGED
@@ -1,19 +1,76 @@
1
1
  # @sovereign-sdk/universal-wallet-wasm
2
2
 
3
- To install dependencies:
3
+ [![npm version](https://img.shields.io/npm/v/@sovereign-sdk/universal-wallet-wasm.svg)](https://www.npmjs.com/package/@sovereign-sdk/universal-wallet-wasm)
4
+ [![CI](https://github.com/Sovereign-Labs/sovereign-sdk-web3-js/actions/workflows/ci.yaml/badge.svg)](https://github.com/Sovereign-Labs/sovereign-sdk-web3-js/actions/workflows/ci.yaml)
5
+
6
+ WebAssembly bindings for Sovereign SDK's universal wallet, providing schema validation and serialization utilities.
7
+
8
+ ## Installation
4
9
 
5
10
  ```bash
6
- pnpm install
11
+ npm install @sovereign-sdk/universal-wallet-wasm
7
12
  ```
8
13
 
9
- Compile to wasm and build JavaScript packages:
14
+ ## Features
10
15
 
11
- ```bash
12
- pnpm run build
16
+ - 🔄 JSON to Borsh serialization of rollup types
17
+ - 📝 Schema validation
18
+ - 📄 Human-readable display of Borsh bytes
19
+
20
+ ## Usage
21
+
22
+ ```typescript
23
+ import { Schema, KnownTypeId } from '@sovereign-sdk/universal-wallet-wasm';
24
+
25
+ // Initialize schema from JSON outputted during rollup compilation
26
+ const schema = Schema.fromJSON(JSON.stringify(yourSchemaJson));
27
+
28
+ // Convert JSON to Borsh bytes
29
+ const runtimeCall = { value_setter: { set_many_values: [4, 6] } };
30
+ const borshBytes = schema.jsonToBorsh(
31
+ schema.knownTypeIndex(KnownTypeId.RuntimeCall),
32
+ JSON.stringify(runtimeCall)
33
+ );
34
+
35
+ // Display Borsh bytes as human-readable string
36
+ const displayed = schema.display(
37
+ schema.knownTypeIndex(KnownTypeId.RuntimeCall),
38
+ borshBytes
39
+ );
13
40
  ```
14
41
 
15
- Run tests (must compile first):
42
+ ## Development Guide
16
43
 
17
- ```bash
18
- pnpm run test
44
+ This package uses [wasm-pack](https://rustwasm.github.io/wasm-pack/) to compile Rust code to WebAssembly and generate JavaScript bindings.
45
+
46
+ ### Prerequisites
47
+
48
+ 1. Install Rust (version 1.79 or later)
49
+ 2. Install Node.js dependencies: `pnpm install`
50
+
51
+ ### Build Commands
52
+
53
+ - `pnpm build` - Builds both Node.js and ESM targets
54
+ - `pnpm compile:node` - Builds Node.js target only
55
+ - `pnpm compile:esm` - Builds ESM target only
56
+ - `pnpm test` - Runs tests
57
+
58
+ ### Project Structure
59
+
60
+ ```
61
+ universal-wallet-wasm/
62
+ ├── src/ # Rust source code
63
+ ├── tests/ # TypeScript tests
64
+ ├── dist/ # Compiled outputs (generated)
65
+ │ ├── node/ # Node.js target
66
+ │ └── esm/ # ESM target
67
+ └── Cargo.toml # Rust dependencies
68
+ └── package.json # NPM package configuration
19
69
  ```
70
+
71
+ ### Making Changes
72
+
73
+ 1. Edit Rust code in `src/lib.rs`
74
+ 2. Run `pnpm build` to compile
75
+ 3. Add tests in `tests/` directory
76
+ 4. Run `pnpm test` to verify changes
@@ -1,19 +1,76 @@
1
1
  # @sovereign-sdk/universal-wallet-wasm
2
2
 
3
- To install dependencies:
3
+ [![npm version](https://img.shields.io/npm/v/@sovereign-sdk/universal-wallet-wasm.svg)](https://www.npmjs.com/package/@sovereign-sdk/universal-wallet-wasm)
4
+ [![CI](https://github.com/Sovereign-Labs/sovereign-sdk-web3-js/actions/workflows/ci.yaml/badge.svg)](https://github.com/Sovereign-Labs/sovereign-sdk-web3-js/actions/workflows/ci.yaml)
5
+
6
+ WebAssembly bindings for Sovereign SDK's universal wallet, providing schema validation and serialization utilities.
7
+
8
+ ## Installation
4
9
 
5
10
  ```bash
6
- pnpm install
11
+ npm install @sovereign-sdk/universal-wallet-wasm
7
12
  ```
8
13
 
9
- Compile to wasm and build JavaScript packages:
14
+ ## Features
10
15
 
11
- ```bash
12
- pnpm run build
16
+ - 🔄 JSON to Borsh serialization of rollup types
17
+ - 📝 Schema validation
18
+ - 📄 Human-readable display of Borsh bytes
19
+
20
+ ## Usage
21
+
22
+ ```typescript
23
+ import { Schema, KnownTypeId } from '@sovereign-sdk/universal-wallet-wasm';
24
+
25
+ // Initialize schema from JSON outputted during rollup compilation
26
+ const schema = Schema.fromJSON(JSON.stringify(yourSchemaJson));
27
+
28
+ // Convert JSON to Borsh bytes
29
+ const runtimeCall = { value_setter: { set_many_values: [4, 6] } };
30
+ const borshBytes = schema.jsonToBorsh(
31
+ schema.knownTypeIndex(KnownTypeId.RuntimeCall),
32
+ JSON.stringify(runtimeCall)
33
+ );
34
+
35
+ // Display Borsh bytes as human-readable string
36
+ const displayed = schema.display(
37
+ schema.knownTypeIndex(KnownTypeId.RuntimeCall),
38
+ borshBytes
39
+ );
13
40
  ```
14
41
 
15
- Run tests (must compile first):
42
+ ## Development Guide
16
43
 
17
- ```bash
18
- pnpm run test
44
+ This package uses [wasm-pack](https://rustwasm.github.io/wasm-pack/) to compile Rust code to WebAssembly and generate JavaScript bindings.
45
+
46
+ ### Prerequisites
47
+
48
+ 1. Install Rust (version 1.79 or later)
49
+ 2. Install Node.js dependencies: `pnpm install`
50
+
51
+ ### Build Commands
52
+
53
+ - `pnpm build` - Builds both Node.js and ESM targets
54
+ - `pnpm compile:node` - Builds Node.js target only
55
+ - `pnpm compile:esm` - Builds ESM target only
56
+ - `pnpm test` - Runs tests
57
+
58
+ ### Project Structure
59
+
60
+ ```
61
+ universal-wallet-wasm/
62
+ ├── src/ # Rust source code
63
+ ├── tests/ # TypeScript tests
64
+ ├── dist/ # Compiled outputs (generated)
65
+ │ ├── node/ # Node.js target
66
+ │ └── esm/ # ESM target
67
+ └── Cargo.toml # Rust dependencies
68
+ └── package.json # NPM package configuration
19
69
  ```
70
+
71
+ ### Making Changes
72
+
73
+ 1. Edit Rust code in `src/lib.rs`
74
+ 2. Run `pnpm build` to compile
75
+ 3. Add tests in `tests/` directory
76
+ 4. Run `pnpm test` to verify changes
@@ -1,13 +1,26 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
+ * Well-known ids of types utilized in the rollup.
4
5
  */
5
6
  export enum KnownTypeId {
7
+ /**
8
+ * The type id of the transaction.
9
+ */
6
10
  Transaction = 0,
11
+ /**
12
+ * The type id of the unsigned transaction.
13
+ */
7
14
  UnsignedTransaction = 1,
15
+ /**
16
+ * The type id of the runtime call.
17
+ */
8
18
  RuntimeCall = 2,
9
19
  }
10
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.
11
24
  */
12
25
  export class Schema {
13
26
  free(): void;
@@ -37,4 +50,8 @@ export class Schema {
37
50
  * @returns {number}
38
51
  */
39
52
  knownTypeIndex(known_type_id: KnownTypeId): number;
53
+ /**
54
+ * Returns the JSON descriptor that was used to create this schema instance.
55
+ */
56
+ readonly descriptor: string;
40
57
  }
@@ -132,13 +132,29 @@ function passArray8ToWasm0(arg, malloc) {
132
132
  return ptr;
133
133
  }
134
134
  /**
135
+ * Well-known ids of types utilized in the rollup.
135
136
  */
136
- export const KnownTypeId = Object.freeze({ Transaction:0,"0":"Transaction",UnsignedTransaction:1,"1":"UnsignedTransaction",RuntimeCall:2,"2":"RuntimeCall", });
137
+ 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", });
137
150
 
138
151
  const SchemaFinalization = (typeof FinalizationRegistry === 'undefined')
139
152
  ? { register: () => {}, unregister: () => {} }
140
153
  : new FinalizationRegistry(ptr => wasm.__wbg_schema_free(ptr >>> 0, 1));
141
154
  /**
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.
142
158
  */
143
159
  export class Schema {
144
160
 
@@ -184,6 +200,26 @@ export class Schema {
184
200
  }
185
201
  }
186
202
  /**
203
+ * Returns the JSON descriptor that was used to create this schema instance.
204
+ * @returns {string}
205
+ */
206
+ get descriptor() {
207
+ let deferred1_0;
208
+ let deferred1_1;
209
+ 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);
217
+ } finally {
218
+ wasm.__wbindgen_add_to_stack_pointer(16);
219
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
220
+ }
221
+ }
222
+ /**
187
223
  * Converts the provided JSON to borsh according to the provided schema.
188
224
  * @param {number} type_index
189
225
  * @param {string} input
Binary file
@@ -3,6 +3,7 @@
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_descriptor(a: number, b: number): void;
6
7
  export function schema_jsonToBorsh(a: number, b: number, c: number, d: number, e: number): void;
7
8
  export function schema_display(a: number, b: number, c: number, d: number, e: number): void;
8
9
  export function schema_knownTypeIndex(a: number, b: number, c: number): void;
@@ -1,19 +1,76 @@
1
1
  # @sovereign-sdk/universal-wallet-wasm
2
2
 
3
- To install dependencies:
3
+ [![npm version](https://img.shields.io/npm/v/@sovereign-sdk/universal-wallet-wasm.svg)](https://www.npmjs.com/package/@sovereign-sdk/universal-wallet-wasm)
4
+ [![CI](https://github.com/Sovereign-Labs/sovereign-sdk-web3-js/actions/workflows/ci.yaml/badge.svg)](https://github.com/Sovereign-Labs/sovereign-sdk-web3-js/actions/workflows/ci.yaml)
5
+
6
+ WebAssembly bindings for Sovereign SDK's universal wallet, providing schema validation and serialization utilities.
7
+
8
+ ## Installation
4
9
 
5
10
  ```bash
6
- pnpm install
11
+ npm install @sovereign-sdk/universal-wallet-wasm
7
12
  ```
8
13
 
9
- Compile to wasm and build JavaScript packages:
14
+ ## Features
10
15
 
11
- ```bash
12
- pnpm run build
16
+ - 🔄 JSON to Borsh serialization of rollup types
17
+ - 📝 Schema validation
18
+ - 📄 Human-readable display of Borsh bytes
19
+
20
+ ## Usage
21
+
22
+ ```typescript
23
+ import { Schema, KnownTypeId } from '@sovereign-sdk/universal-wallet-wasm';
24
+
25
+ // Initialize schema from JSON outputted during rollup compilation
26
+ const schema = Schema.fromJSON(JSON.stringify(yourSchemaJson));
27
+
28
+ // Convert JSON to Borsh bytes
29
+ const runtimeCall = { value_setter: { set_many_values: [4, 6] } };
30
+ const borshBytes = schema.jsonToBorsh(
31
+ schema.knownTypeIndex(KnownTypeId.RuntimeCall),
32
+ JSON.stringify(runtimeCall)
33
+ );
34
+
35
+ // Display Borsh bytes as human-readable string
36
+ const displayed = schema.display(
37
+ schema.knownTypeIndex(KnownTypeId.RuntimeCall),
38
+ borshBytes
39
+ );
13
40
  ```
14
41
 
15
- Run tests (must compile first):
42
+ ## Development Guide
16
43
 
17
- ```bash
18
- pnpm run test
44
+ This package uses [wasm-pack](https://rustwasm.github.io/wasm-pack/) to compile Rust code to WebAssembly and generate JavaScript bindings.
45
+
46
+ ### Prerequisites
47
+
48
+ 1. Install Rust (version 1.79 or later)
49
+ 2. Install Node.js dependencies: `pnpm install`
50
+
51
+ ### Build Commands
52
+
53
+ - `pnpm build` - Builds both Node.js and ESM targets
54
+ - `pnpm compile:node` - Builds Node.js target only
55
+ - `pnpm compile:esm` - Builds ESM target only
56
+ - `pnpm test` - Runs tests
57
+
58
+ ### Project Structure
59
+
60
+ ```
61
+ universal-wallet-wasm/
62
+ ├── src/ # Rust source code
63
+ ├── tests/ # TypeScript tests
64
+ ├── dist/ # Compiled outputs (generated)
65
+ │ ├── node/ # Node.js target
66
+ │ └── esm/ # ESM target
67
+ └── Cargo.toml # Rust dependencies
68
+ └── package.json # NPM package configuration
19
69
  ```
70
+
71
+ ### Making Changes
72
+
73
+ 1. Edit Rust code in `src/lib.rs`
74
+ 2. Run `pnpm build` to compile
75
+ 3. Add tests in `tests/` directory
76
+ 4. Run `pnpm test` to verify changes
@@ -1,13 +1,26 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
+ * Well-known ids of types utilized in the rollup.
4
5
  */
5
6
  export enum KnownTypeId {
7
+ /**
8
+ * The type id of the transaction.
9
+ */
6
10
  Transaction = 0,
11
+ /**
12
+ * The type id of the unsigned transaction.
13
+ */
7
14
  UnsignedTransaction = 1,
15
+ /**
16
+ * The type id of the runtime call.
17
+ */
8
18
  RuntimeCall = 2,
9
19
  }
10
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.
11
24
  */
12
25
  export class Schema {
13
26
  free(): void;
@@ -37,4 +50,8 @@ export class Schema {
37
50
  * @returns {number}
38
51
  */
39
52
  knownTypeIndex(known_type_id: KnownTypeId): number;
53
+ /**
54
+ * Returns the JSON descriptor that was used to create this schema instance.
55
+ */
56
+ readonly descriptor: string;
40
57
  }
@@ -128,13 +128,29 @@ function passArray8ToWasm0(arg, malloc) {
128
128
  return ptr;
129
129
  }
130
130
  /**
131
+ * Well-known ids of types utilized in the rollup.
131
132
  */
132
- module.exports.KnownTypeId = Object.freeze({ Transaction:0,"0":"Transaction",UnsignedTransaction:1,"1":"UnsignedTransaction",RuntimeCall:2,"2":"RuntimeCall", });
133
+ 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", });
133
146
 
134
147
  const SchemaFinalization = (typeof FinalizationRegistry === 'undefined')
135
148
  ? { register: () => {}, unregister: () => {} }
136
149
  : new FinalizationRegistry(ptr => wasm.__wbg_schema_free(ptr >>> 0, 1));
137
150
  /**
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.
138
154
  */
139
155
  class Schema {
140
156
 
@@ -180,6 +196,26 @@ class Schema {
180
196
  }
181
197
  }
182
198
  /**
199
+ * Returns the JSON descriptor that was used to create this schema instance.
200
+ * @returns {string}
201
+ */
202
+ get descriptor() {
203
+ let deferred1_0;
204
+ let deferred1_1;
205
+ 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);
213
+ } finally {
214
+ wasm.__wbindgen_add_to_stack_pointer(16);
215
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
216
+ }
217
+ }
218
+ /**
183
219
  * Converts the provided JSON to borsh according to the provided schema.
184
220
  * @param {number} type_index
185
221
  * @param {string} input
Binary file
@@ -3,6 +3,7 @@
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_descriptor(a: number, b: number): void;
6
7
  export function schema_jsonToBorsh(a: number, b: number, c: number, d: number, e: number): void;
7
8
  export function schema_display(a: number, b: number, c: number, d: number, e: number): void;
8
9
  export function schema_knownTypeIndex(a: number, b: number, c: number): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sovereign-sdk/universal-wallet-wasm",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "files": [
5
5
  "dist/**/*",
6
6
  "!dist/**/.gitignore",