Files
Satoshi Qazi Muhammed 5835a5383c Move to @pezkuwi/dev 0.86 (eslint 10 toolchain)
- @pezkuwi/dev, dev-test, dev-ts ^0.86.3; disable directives renamed
  for the new rule names, or removed where the rule no longer reports
- rethrown errors carry the original as `cause` (13 sites)
- optional chains where a guard expression tested the same value
- Init: the registry cache settles with the creator's own promise,
  dropping the entry in finally(), instead of re-wrapping it
- Combinator: a typed call instead of `Function`
- checkTypes.manual: synchronous checks run outside Promise.all
- sortValues, createTypeUnsafe: initial values that were never read
- typegen util: load docs.js for its side effect (it registers the
  `docs` Handlebars partial) now that its types are re-exported
  type-only
- MockProvider keeps its Header assertion: the package's own build
  does not load api-augment, so createType returns a plain Codec there
- Decorate keeps `delete queue[i]`: the hole marks a fired queue and
  later indexes must not shift
2026-10-09 16:32:37 +04:00
..
2026-10-08 23:32:40 +04:00

@pezkuwi/rpc-provider

Generic transport providers to handle the transport of method calls to and from Pezkuwi clients from applications interacting with it. It provides an interface to making RPC calls and is generally, unless you are operating at a low-level and taking care of encoding and decoding of parameters/results, it won't be directly used, rather only passed to a higher-level interface.

Provider Selection

There are three flavours of the providers provided, one allowing for using HTTP as a transport mechanism, the other using WebSockets, and the third one uses bizinikiwi light-client through @bizinikiwi/connect. It is generally recommended to use the WsProvider since in addition to standard calls, it allows for subscriptions where all changes to state can be pushed from the node to the client.

All providers are usable (as is the API), in both browser-based and Node.js environments. Polyfills for unsupported functionality are automatically applied based on feature-detection.

Usage

Installation -

yarn add @pezkuwi/rpc-provider

WebSocket Initialization -

import { WsProvider } from '@pezkuwi/rpc-provider';

// this is the actual default endpoint
const provider = new WsProvider('ws://127.0.0.1:9944');
const version = await provider.send('client_version', []);

console.log('client version', version);

HTTP Initialization -

import { HttpProvider } from '@pezkuwi/rpc-provider';

// this is the actual default endpoint
const provider = new HttpProvider('http://127.0.0.1:9933');
const version = await provider.send('chain_getBlockHash', []);

console.log('latest block Hash', hash);

@bizinikiwi/connect Initialization -

Instantiating a Provider for the Pezkuwi Relay Chain:

import { ScProvider } from '@pezkuwi/rpc-provider';
import * as Sc from '@bizinikiwi/connect';

const provider = new ScProvider(Sc, Sc.WellKnownChain.pezkuwi);

await provider.connect();

const version = await provider.send('chain_getBlockHash', []);

Instantiating a Provider for a Pezkuwi teyrchain:

import { ScProvider } from '@pezkuwi/rpc-provider';
import * as Sc from '@bizinikiwi/connect';

const pezkuwiProvider = new ScProvider(Sc, Sc.WellKnownChain.pezkuwi);
const teyrchainProvider = new ScProvider(Sc, teyrchainSpec, pezkuwiProvider);

await teyrchainProvider.connect();

const version = await teyrchainProvider.send('chain_getBlockHash', []);