@pezkuwi/rpc-core 16.5.5

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 ADDED
@@ -0,0 +1,3 @@
1
+ # @pezkuwi/rpc-core
2
+
3
+ This library provides a clean wrapper around all the methods exposed by a Pezkuwi network client. It is only used internally to the API.
@@ -0,0 +1,91 @@
1
+ import type { ProviderInterface } from '@pezkuwi/rpc-provider/types';
2
+ import type { AnyNumber, DefinitionRpc, DefinitionRpcExt, DefinitionRpcSub, Registry } from '@pezkuwi/types/types';
3
+ import type { RpcCoreStats } from './types/index.js';
4
+ export { packageInfo } from './packageInfo.js';
5
+ export * from './util/index.js';
6
+ interface Options {
7
+ isPedantic?: boolean;
8
+ provider: ProviderInterface;
9
+ /**
10
+ * Custom size of the rpc LRUCache capacity. Defaults to `RPC_CORE_DEFAULT_CAPACITY` (1024 * 10 * 10)
11
+ */
12
+ rpcCacheCapacity?: number;
13
+ ttl?: number | null;
14
+ userRpc?: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>;
15
+ }
16
+ /**
17
+ * @name Rpc
18
+ * @summary The API may use a HTTP or WebSockets provider.
19
+ * @description It allows for querying a Polkadot Client Node.
20
+ * WebSockets provider is recommended since HTTP provider only supports basic querying.
21
+ *
22
+ * ```mermaid
23
+ * graph LR;
24
+ * A[Api] --> |WebSockets| B[WsProvider];
25
+ * B --> |endpoint| C[ws://127.0.0.1:9944]
26
+ * ```
27
+ *
28
+ * @example
29
+ * <BR>
30
+ *
31
+ * ```javascript
32
+ * import Rpc from '@pezkuwi/rpc-core';
33
+ * import { WsProvider } from '@pezkuwi/rpc-provider/ws';
34
+ *
35
+ * const provider = new WsProvider('ws://127.0.0.1:9944');
36
+ * const rpc = new Rpc(provider);
37
+ * ```
38
+ */
39
+ export declare class RpcCore {
40
+ #private;
41
+ readonly mapping: Map<string, DefinitionRpcExt>;
42
+ readonly provider: ProviderInterface;
43
+ readonly sections: string[];
44
+ /**
45
+ * @constructor
46
+ * Default constructor for the core RPC handler
47
+ * @param {Registry} registry Type Registry
48
+ * @param {ProviderInterface} options.provider An API provider using any of the supported providers (HTTP, SC or WebSocket)
49
+ * @param {number} [options.rpcCacheCapacity] Custom size of the rpc LRUCache capacity. Defaults to `RPC_CORE_DEFAULT_CAPACITY` (1024 * 10 * 10)
50
+ */
51
+ constructor(instanceId: string, registry: Registry, { isPedantic, provider, rpcCacheCapacity, ttl, userRpc }: Options);
52
+ /**
53
+ * @description Returns the connected status of a provider
54
+ */
55
+ get isConnected(): boolean;
56
+ /**
57
+ * @description Manually connect from the attached provider
58
+ */
59
+ connect(): Promise<void>;
60
+ /**
61
+ * @description Manually disconnect from the attached provider
62
+ */
63
+ disconnect(): Promise<void>;
64
+ /**
65
+ * @description Returns the underlying core stats, including those from teh provider
66
+ */
67
+ get stats(): RpcCoreStats | undefined;
68
+ /**
69
+ * @description Sets a registry swap (typically from Api)
70
+ */
71
+ setRegistrySwap(registrySwap: (blockHash: Uint8Array) => Promise<{
72
+ registry: Registry;
73
+ }>): void;
74
+ /**
75
+ * @description Sets a function to resolve block hash from block number
76
+ */
77
+ setResolveBlockHash(resolveBlockHash: (blockNumber: AnyNumber) => Promise<Uint8Array>): void;
78
+ addUserInterfaces(userRpc: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>): void;
79
+ private _memomize;
80
+ private _formatResult;
81
+ private _createMethodSend;
82
+ private _createSubscriber;
83
+ private _createMethodSubscribe;
84
+ private _formatParams;
85
+ private _formatOutput;
86
+ private _formatStorageData;
87
+ private _formatStorageSet;
88
+ private _formatStorageSetEntry;
89
+ private _setToCache;
90
+ private _newType;
91
+ }
@@ -0,0 +1,2 @@
1
+ import './packageDetect.js';
2
+ export * from './bundle.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ export declare const packageInfo: {
2
+ name: string;
3
+ path: string;
4
+ type: string;
5
+ version: string;
6
+ };
@@ -0,0 +1,22 @@
1
+ import type { Observable } from 'rxjs';
2
+ import type { ProviderInterface } from '@pezkuwi/rpc-provider/types';
3
+ import type { AnyFunction, Codec, DefinitionRpc } from '@pezkuwi/types/types';
4
+ export interface RpcInterfaceMethod {
5
+ <T extends Codec>(...params: unknown[]): Observable<T>;
6
+ raw(...params: unknown[]): Observable<unknown>;
7
+ meta: DefinitionRpc;
8
+ }
9
+ export type AugmentedRpc<F extends AnyFunction> = F & {
10
+ raw: <T>(...params: Parameters<F>) => Observable<T>;
11
+ meta: DefinitionRpc;
12
+ };
13
+ /** Stats from the rpc-core layer, including the provider stats */
14
+ export interface RpcCoreStats extends NonNullable<ProviderInterface['stats']> {
15
+ /** Internal stats for the rpc-core layer */
16
+ core: {
17
+ /** The number of values retrieved from the core cache */
18
+ cacheHits: number;
19
+ /** The number of entries in the core cache */
20
+ cacheSize: number;
21
+ };
22
+ }
@@ -0,0 +1,2 @@
1
+ export * from '@pezkuwi/rpc-core/types/jsonrpc';
2
+ export * from './base.js';
@@ -0,0 +1,2 @@
1
+ export interface RpcInterface {
2
+ }
@@ -0,0 +1,15 @@
1
+ import type { Observable } from 'rxjs';
2
+ export type DrrResult = <T>(source$: Observable<T>) => Observable<T>;
3
+ interface Options {
4
+ delay?: number;
5
+ skipChange?: boolean;
6
+ skipTimeout?: boolean;
7
+ }
8
+ /**
9
+ * Shorthand for distinctUntilChanged(), publishReplay(1) and refCount().
10
+ *
11
+ * @ignore
12
+ * @internal
13
+ */
14
+ export declare function drr({ delay, skipChange, skipTimeout }?: Options): DrrResult;
15
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from './drr.js';
2
+ export * from './memo.js';
3
+ export * from './refCountDelay.js';
@@ -0,0 +1,6 @@
1
+ import type { Memoized } from '@pezkuwi/util/types';
2
+ import { Observable } from 'rxjs';
3
+ type ObsFn<T> = (...params: unknown[]) => Observable<T>;
4
+ /** @internal */
5
+ export declare function memo<T>(instanceId: string, inner: Function): Memoized<ObsFn<T>>;
6
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { MonoTypeOperatorFunction } from 'rxjs';
2
+ /** @internal */
3
+ export declare function refCountDelay<T>(delay?: number): MonoTypeOperatorFunction<T>;
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "author": "Jaco Greeff <jacogr@gmail.com>",
3
+ "bugs": "https://github.com/pezkuwichain/pezkuwi-api/issues",
4
+ "description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
5
+ "engines": {
6
+ "node": ">=18"
7
+ },
8
+ "homepage": "https://github.com/pezkuwichain/pezkuwi-api/tree/master/packages/rpc-core#readme",
9
+ "license": "Apache-2.0",
10
+ "name": "@pezkuwi/rpc-core",
11
+ "repository": {
12
+ "directory": "packages/rpc-core",
13
+ "type": "git",
14
+ "url": "https://github.com/pezkuwichain/pezkuwi-api.git"
15
+ },
16
+ "sideEffects": [
17
+ "./packageDetect.js",
18
+ "./packageDetect.cjs"
19
+ ],
20
+ "type": "module",
21
+ "version": "16.5.5",
22
+ "main": "index.js",
23
+ "dependencies": {
24
+ "@pezkuwi/rpc-augment": "16.5.5",
25
+ "@pezkuwi/rpc-provider": "16.5.5",
26
+ "@pezkuwi/types": "16.5.5",
27
+ "@pezkuwi/util": "14.0.5",
28
+ "rxjs": "^7.8.1",
29
+ "tslib": "^2.8.1"
30
+ },
31
+ "devDependencies": {
32
+ "@pezkuwi/keyring": "14.0.5",
33
+ "@pezkuwi/rpc-augment": "16.5.5"
34
+ }
35
+ }