@parity/truapi-provider 0.1.1-dev-20260806.0 → 0.1.1-dev-20260825.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.
- package/README.md +11 -37
- package/dist/truapi_provider.d.ts +12 -6
- package/dist/truapi_provider.js +26 -20
- package/dist/truapi_provider_bg.wasm +0 -0
- package/dist/truapi_provider_bg.wasm.d.ts +6 -6
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Network transport for the TrUAPI `ChainProvider` contract: an embedded
|
|
4
4
|
[smoldot](https://github.com/smol-dot/smoldot) light client, or a remote
|
|
5
|
-
WebSocket JSON-RPC node, behind one API. This is the WebAssembly build,
|
|
6
|
-
browser and desktop (webview) hosts.
|
|
7
|
-
crate natively over UniFFI, so network access works the same everywhere.
|
|
5
|
+
WebSocket JSON-RPC node, behind one API. This package is the WebAssembly build,
|
|
6
|
+
for browser and desktop (webview) hosts.
|
|
8
7
|
|
|
9
8
|
You connect to a network by its genesis hash, and everything else is handled for
|
|
10
9
|
you: the bundled catalog provides the spec and relay wiring, so clients never
|
|
@@ -29,7 +28,7 @@ import wasmUrl from "@parity/truapi-provider/truapi_provider_bg.wasm?url";
|
|
|
29
28
|
|
|
30
29
|
await init({ module_or_path: wasmUrl });
|
|
31
30
|
|
|
32
|
-
const genesis = "
|
|
31
|
+
const genesis = "0x3740…";
|
|
33
32
|
const builder = new ChainProviderBuilder();
|
|
34
33
|
|
|
35
34
|
// Resume from the state saved by the previous run, when there is one.
|
|
@@ -47,41 +46,16 @@ connection.close();
|
|
|
47
46
|
localStorage.setItem(`chain-db:${genesis}`, await provider.snapshot(genesis));
|
|
48
47
|
```
|
|
49
48
|
|
|
50
|
-
Warm start is
|
|
51
|
-
persist the string
|
|
52
|
-
|
|
49
|
+
Warm start is driven by the host: call `snapshot()` once the light client has
|
|
50
|
+
synced, persist the string, and hand it back through `setDatabase()` before
|
|
51
|
+
`build()` on the next launch.
|
|
53
52
|
|
|
54
|
-
|
|
53
|
+
## Native hosts
|
|
55
54
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
val provider = ChainProvider()
|
|
61
|
-
|
|
62
|
-
val connection = provider.connect(genesisHash, object : ChainMessageListener {
|
|
63
|
-
override fun onMessage(message: String) { /* JSON-RPC response */ }
|
|
64
|
-
override fun onClosed() {}
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
connection.send("""{"jsonrpc":"2.0","id":1,"method":"chainSpec_v1_genesisHash","params":[]}""")
|
|
68
|
-
connection.close()
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
#### iOS (Swift)
|
|
72
|
-
|
|
73
|
-
```swift
|
|
74
|
-
let provider = ChainProvider()
|
|
75
|
-
|
|
76
|
-
final class Responses: ChainMessageListener {
|
|
77
|
-
func onMessage(message: String) { /* JSON-RPC response */ }
|
|
78
|
-
func onClosed() {}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
let connection = try provider.connect(genesisHash: genesis, listener: Responses())
|
|
82
|
-
connection.send(request: #"{"jsonrpc":"2.0","id":1,"method":"chainSpec_v1_genesisHash","params":[]}"#)
|
|
83
|
-
connection.close()
|
|
84
|
-
```
|
|
55
|
+
Android and iOS do not consume this package. The same `truapi-provider` crate is
|
|
56
|
+
published for them as its own artifacts over UniFFI — a `TrUAPIProvider` Swift
|
|
57
|
+
package and a `truapi-provider-android` AAR — exposing the same `ChainProvider`
|
|
58
|
+
contract with the same bundled catalog, so the wiring differs only in language.
|
|
85
59
|
|
|
86
60
|
## Building
|
|
87
61
|
|
|
@@ -78,6 +78,12 @@ export class Connection {
|
|
|
78
78
|
/**
|
|
79
79
|
* Resolve with the next JSON-RPC response or notification, or
|
|
80
80
|
* `undefined` once the connection is closed or dead.
|
|
81
|
+
*
|
|
82
|
+
* Calling this in a loop is not optional: it is the only thing that drains
|
|
83
|
+
* the connection. Frames queue until they are taken, and once the backlog
|
|
84
|
+
* reaches the connection's budget further [`send`](Connection::send) calls
|
|
85
|
+
* come back as JSON-RPC errors instead of being queued, so a caller that
|
|
86
|
+
* sends without reading eventually gets nothing but errors.
|
|
81
87
|
*/
|
|
82
88
|
nextResponse(): Promise<string | undefined>;
|
|
83
89
|
/**
|
|
@@ -144,12 +150,12 @@ export interface InitOutput {
|
|
|
144
150
|
readonly networkchains_people: (a: number, b: number) => void;
|
|
145
151
|
readonly networkchains_relay: (a: number, b: number) => void;
|
|
146
152
|
readonly setLogLevel: (a: number, b: number) => void;
|
|
147
|
-
readonly
|
|
148
|
-
readonly
|
|
149
|
-
readonly
|
|
150
|
-
readonly
|
|
151
|
-
readonly
|
|
152
|
-
readonly
|
|
153
|
+
readonly __wasm_bindgen_func_elem_19126: (a: number, b: number, c: number, d: number) => void;
|
|
154
|
+
readonly __wasm_bindgen_func_elem_19128: (a: number, b: number, c: number, d: number) => void;
|
|
155
|
+
readonly __wasm_bindgen_func_elem_3731: (a: number, b: number, c: number) => void;
|
|
156
|
+
readonly __wasm_bindgen_func_elem_3731_2: (a: number, b: number, c: number) => void;
|
|
157
|
+
readonly __wasm_bindgen_func_elem_3731_3: (a: number, b: number, c: number) => void;
|
|
158
|
+
readonly __wasm_bindgen_func_elem_7146: (a: number, b: number) => void;
|
|
153
159
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
154
160
|
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
155
161
|
readonly __wbindgen_export3: (a: number) => void;
|
package/dist/truapi_provider.js
CHANGED
|
@@ -221,6 +221,12 @@ export class Connection {
|
|
|
221
221
|
/**
|
|
222
222
|
* Resolve with the next JSON-RPC response or notification, or
|
|
223
223
|
* `undefined` once the connection is closed or dead.
|
|
224
|
+
*
|
|
225
|
+
* Calling this in a loop is not optional: it is the only thing that drains
|
|
226
|
+
* the connection. Frames queue until they are taken, and once the backlog
|
|
227
|
+
* reaches the connection's budget further [`send`](Connection::send) calls
|
|
228
|
+
* come back as JSON-RPC errors instead of being queued, so a caller that
|
|
229
|
+
* sends without reading eventually gets nothing but errors.
|
|
224
230
|
* @returns {Promise<string | undefined>}
|
|
225
231
|
*/
|
|
226
232
|
nextResponse() {
|
|
@@ -472,7 +478,7 @@ function __wbg_get_imports() {
|
|
|
472
478
|
const a = state0.a;
|
|
473
479
|
state0.a = 0;
|
|
474
480
|
try {
|
|
475
|
-
return
|
|
481
|
+
return __wasm_bindgen_func_elem_19128(a, state0.b, arg0, arg1);
|
|
476
482
|
} finally {
|
|
477
483
|
state0.a = a;
|
|
478
484
|
}
|
|
@@ -589,28 +595,28 @@ function __wbg_get_imports() {
|
|
|
589
595
|
console.warn(getObject(arg0));
|
|
590
596
|
},
|
|
591
597
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
592
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
593
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
598
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1830, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
599
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_19126);
|
|
594
600
|
return addHeapObject(ret);
|
|
595
601
|
},
|
|
596
602
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
597
603
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("CloseEvent")], shim_idx: 20, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
598
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
604
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_3731);
|
|
599
605
|
return addHeapObject(ret);
|
|
600
606
|
},
|
|
601
607
|
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
602
608
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 20, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
603
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
609
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_3731_2);
|
|
604
610
|
return addHeapObject(ret);
|
|
605
611
|
},
|
|
606
612
|
__wbindgen_cast_0000000000000004: function(arg0, arg1) {
|
|
607
613
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 20, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
608
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
614
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_3731_3);
|
|
609
615
|
return addHeapObject(ret);
|
|
610
616
|
},
|
|
611
617
|
__wbindgen_cast_0000000000000005: function(arg0, arg1) {
|
|
612
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx:
|
|
613
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
618
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 668, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
619
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_7146);
|
|
614
620
|
return addHeapObject(ret);
|
|
615
621
|
},
|
|
616
622
|
__wbindgen_cast_0000000000000006: function(arg0, arg1) {
|
|
@@ -637,26 +643,26 @@ function __wbg_get_imports() {
|
|
|
637
643
|
};
|
|
638
644
|
}
|
|
639
645
|
|
|
640
|
-
function
|
|
641
|
-
wasm.
|
|
646
|
+
function __wasm_bindgen_func_elem_7146(arg0, arg1) {
|
|
647
|
+
wasm.__wasm_bindgen_func_elem_7146(arg0, arg1);
|
|
642
648
|
}
|
|
643
649
|
|
|
644
|
-
function
|
|
645
|
-
wasm.
|
|
650
|
+
function __wasm_bindgen_func_elem_3731(arg0, arg1, arg2) {
|
|
651
|
+
wasm.__wasm_bindgen_func_elem_3731(arg0, arg1, addHeapObject(arg2));
|
|
646
652
|
}
|
|
647
653
|
|
|
648
|
-
function
|
|
649
|
-
wasm.
|
|
654
|
+
function __wasm_bindgen_func_elem_3731_2(arg0, arg1, arg2) {
|
|
655
|
+
wasm.__wasm_bindgen_func_elem_3731_2(arg0, arg1, addHeapObject(arg2));
|
|
650
656
|
}
|
|
651
657
|
|
|
652
|
-
function
|
|
653
|
-
wasm.
|
|
658
|
+
function __wasm_bindgen_func_elem_3731_3(arg0, arg1, arg2) {
|
|
659
|
+
wasm.__wasm_bindgen_func_elem_3731_3(arg0, arg1, addHeapObject(arg2));
|
|
654
660
|
}
|
|
655
661
|
|
|
656
|
-
function
|
|
662
|
+
function __wasm_bindgen_func_elem_19126(arg0, arg1, arg2) {
|
|
657
663
|
try {
|
|
658
664
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
659
|
-
wasm.
|
|
665
|
+
wasm.__wasm_bindgen_func_elem_19126(retptr, arg0, arg1, addHeapObject(arg2));
|
|
660
666
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
661
667
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
662
668
|
if (r1) {
|
|
@@ -667,8 +673,8 @@ function __wasm_bindgen_func_elem_12921(arg0, arg1, arg2) {
|
|
|
667
673
|
}
|
|
668
674
|
}
|
|
669
675
|
|
|
670
|
-
function
|
|
671
|
-
wasm.
|
|
676
|
+
function __wasm_bindgen_func_elem_19128(arg0, arg1, arg2, arg3) {
|
|
677
|
+
wasm.__wasm_bindgen_func_elem_19128(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
672
678
|
}
|
|
673
679
|
|
|
674
680
|
|
|
Binary file
|
|
@@ -21,12 +21,12 @@ export const networkchains_bulletin: (a: number, b: number) => void;
|
|
|
21
21
|
export const networkchains_people: (a: number, b: number) => void;
|
|
22
22
|
export const networkchains_relay: (a: number, b: number) => void;
|
|
23
23
|
export const setLogLevel: (a: number, b: number) => void;
|
|
24
|
-
export const
|
|
25
|
-
export const
|
|
26
|
-
export const
|
|
27
|
-
export const
|
|
28
|
-
export const
|
|
29
|
-
export const
|
|
24
|
+
export const __wasm_bindgen_func_elem_19126: (a: number, b: number, c: number, d: number) => void;
|
|
25
|
+
export const __wasm_bindgen_func_elem_19128: (a: number, b: number, c: number, d: number) => void;
|
|
26
|
+
export const __wasm_bindgen_func_elem_3731: (a: number, b: number, c: number) => void;
|
|
27
|
+
export const __wasm_bindgen_func_elem_3731_2: (a: number, b: number, c: number) => void;
|
|
28
|
+
export const __wasm_bindgen_func_elem_3731_3: (a: number, b: number, c: number) => void;
|
|
29
|
+
export const __wasm_bindgen_func_elem_7146: (a: number, b: number) => void;
|
|
30
30
|
export const __wbindgen_export: (a: number, b: number) => number;
|
|
31
31
|
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
32
32
|
export const __wbindgen_export3: (a: number) => void;
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parity/truapi-provider",
|
|
3
|
-
"version": "0.1.1-dev-
|
|
3
|
+
"version": "0.1.1-dev-20260825.0",
|
|
4
4
|
"description": "Network provider backends for the TrUAPI ChainProvider: an embedded smoldot light client and remote WebSocket JSON-RPC nodes, compiled to WebAssembly for browser hosts",
|
|
5
5
|
"license": "MIT AND Apache-2.0",
|
|
6
6
|
"author": "Parity Technologies <admin@parity.io>",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/paritytech/
|
|
9
|
+
"url": "git+https://github.com/paritytech/host-rust-core.git",
|
|
10
10
|
"directory": "js/packages/truapi-provider"
|
|
11
11
|
},
|
|
12
|
-
"homepage": "https://github.com/paritytech/
|
|
12
|
+
"homepage": "https://github.com/paritytech/host-rust-core#readme",
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/paritytech/
|
|
14
|
+
"url": "https://github.com/paritytech/host-rust-core/issues"
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"main": "dist/truapi_provider.js",
|