@parity/truapi-provider 0.1.1-dev-20260806.0 → 0.1.1-dev-20260814.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 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, for
6
- browser and desktop (webview) hosts. Android and iOS hosts use the same Rust
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 = "0x77af…";
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 yours to drive: call `snapshot()` once the light client has synced,
51
- persist the string wherever you like, and hand it back through `setDatabase()`
52
- before `build()` on the next launch.
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
- #### Android (Kotlin)
53
+ ## Native hosts
55
54
 
56
- Native targets deliver responses to a listener instead of a pull loop, and take
57
- the genesis hash as 32 raw bytes.
58
-
59
- ```kotlin
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 __wasm_bindgen_func_elem_12921: (a: number, b: number, c: number, d: number) => void;
148
- readonly __wasm_bindgen_func_elem_12923: (a: number, b: number, c: number, d: number) => void;
149
- readonly __wasm_bindgen_func_elem_3701: (a: number, b: number, c: number) => void;
150
- readonly __wasm_bindgen_func_elem_3701_2: (a: number, b: number, c: number) => void;
151
- readonly __wasm_bindgen_func_elem_3701_3: (a: number, b: number, c: number) => void;
152
- readonly __wasm_bindgen_func_elem_7079: (a: number, b: number) => void;
153
+ readonly __wasm_bindgen_func_elem_19082: (a: number, b: number, c: number, d: number) => void;
154
+ readonly __wasm_bindgen_func_elem_19084: (a: number, b: number, c: number, d: number) => void;
155
+ readonly __wasm_bindgen_func_elem_3717: (a: number, b: number, c: number) => void;
156
+ readonly __wasm_bindgen_func_elem_3717_2: (a: number, b: number, c: number) => void;
157
+ readonly __wasm_bindgen_func_elem_3717_3: (a: number, b: number, c: number) => void;
158
+ readonly __wasm_bindgen_func_elem_7114: (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;
@@ -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 __wasm_bindgen_func_elem_12923(a, state0.b, arg0, arg1);
481
+ return __wasm_bindgen_func_elem_19084(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: 979, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
593
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_12921);
598
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1825, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
599
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_19082);
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, __wasm_bindgen_func_elem_3701);
604
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_3717);
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, __wasm_bindgen_func_elem_3701_2);
609
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_3717_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, __wasm_bindgen_func_elem_3701_3);
614
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_3717_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: 672, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
613
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_7079);
618
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 675, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
619
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_7114);
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 __wasm_bindgen_func_elem_7079(arg0, arg1) {
641
- wasm.__wasm_bindgen_func_elem_7079(arg0, arg1);
646
+ function __wasm_bindgen_func_elem_7114(arg0, arg1) {
647
+ wasm.__wasm_bindgen_func_elem_7114(arg0, arg1);
642
648
  }
643
649
 
644
- function __wasm_bindgen_func_elem_3701(arg0, arg1, arg2) {
645
- wasm.__wasm_bindgen_func_elem_3701(arg0, arg1, addHeapObject(arg2));
650
+ function __wasm_bindgen_func_elem_3717(arg0, arg1, arg2) {
651
+ wasm.__wasm_bindgen_func_elem_3717(arg0, arg1, addHeapObject(arg2));
646
652
  }
647
653
 
648
- function __wasm_bindgen_func_elem_3701_2(arg0, arg1, arg2) {
649
- wasm.__wasm_bindgen_func_elem_3701_2(arg0, arg1, addHeapObject(arg2));
654
+ function __wasm_bindgen_func_elem_3717_2(arg0, arg1, arg2) {
655
+ wasm.__wasm_bindgen_func_elem_3717_2(arg0, arg1, addHeapObject(arg2));
650
656
  }
651
657
 
652
- function __wasm_bindgen_func_elem_3701_3(arg0, arg1, arg2) {
653
- wasm.__wasm_bindgen_func_elem_3701_3(arg0, arg1, addHeapObject(arg2));
658
+ function __wasm_bindgen_func_elem_3717_3(arg0, arg1, arg2) {
659
+ wasm.__wasm_bindgen_func_elem_3717_3(arg0, arg1, addHeapObject(arg2));
654
660
  }
655
661
 
656
- function __wasm_bindgen_func_elem_12921(arg0, arg1, arg2) {
662
+ function __wasm_bindgen_func_elem_19082(arg0, arg1, arg2) {
657
663
  try {
658
664
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
659
- wasm.__wasm_bindgen_func_elem_12921(retptr, arg0, arg1, addHeapObject(arg2));
665
+ wasm.__wasm_bindgen_func_elem_19082(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 __wasm_bindgen_func_elem_12923(arg0, arg1, arg2, arg3) {
671
- wasm.__wasm_bindgen_func_elem_12923(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
676
+ function __wasm_bindgen_func_elem_19084(arg0, arg1, arg2, arg3) {
677
+ wasm.__wasm_bindgen_func_elem_19084(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 __wasm_bindgen_func_elem_12921: (a: number, b: number, c: number, d: number) => void;
25
- export const __wasm_bindgen_func_elem_12923: (a: number, b: number, c: number, d: number) => void;
26
- export const __wasm_bindgen_func_elem_3701: (a: number, b: number, c: number) => void;
27
- export const __wasm_bindgen_func_elem_3701_2: (a: number, b: number, c: number) => void;
28
- export const __wasm_bindgen_func_elem_3701_3: (a: number, b: number, c: number) => void;
29
- export const __wasm_bindgen_func_elem_7079: (a: number, b: number) => void;
24
+ export const __wasm_bindgen_func_elem_19082: (a: number, b: number, c: number, d: number) => void;
25
+ export const __wasm_bindgen_func_elem_19084: (a: number, b: number, c: number, d: number) => void;
26
+ export const __wasm_bindgen_func_elem_3717: (a: number, b: number, c: number) => void;
27
+ export const __wasm_bindgen_func_elem_3717_2: (a: number, b: number, c: number) => void;
28
+ export const __wasm_bindgen_func_elem_3717_3: (a: number, b: number, c: number) => void;
29
+ export const __wasm_bindgen_func_elem_7114: (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,6 +1,6 @@
1
1
  {
2
2
  "name": "@parity/truapi-provider",
3
- "version": "0.1.1-dev-20260806.0",
3
+ "version": "0.1.1-dev-20260814.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>",