@dedot/api 0.0.1-alpha.32
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/LICENSE +201 -0
- package/README.md +1 -0
- package/chaintypes/index.d.ts +1 -0
- package/chaintypes/index.js +1 -0
- package/chaintypes/substrate/consts.d.ts +2132 -0
- package/chaintypes/substrate/consts.js +2 -0
- package/chaintypes/substrate/errors.d.ts +3490 -0
- package/chaintypes/substrate/errors.js +2 -0
- package/chaintypes/substrate/events.d.ts +5187 -0
- package/chaintypes/substrate/events.js +2 -0
- package/chaintypes/substrate/index.d.ts +22 -0
- package/chaintypes/substrate/index.js +2 -0
- package/chaintypes/substrate/json-rpc.d.ts +3 -0
- package/chaintypes/substrate/json-rpc.js +2 -0
- package/chaintypes/substrate/query.d.ts +3829 -0
- package/chaintypes/substrate/query.js +2 -0
- package/chaintypes/substrate/runtime.d.ts +850 -0
- package/chaintypes/substrate/runtime.js +2 -0
- package/chaintypes/substrate/tx.d.ts +14269 -0
- package/chaintypes/substrate/tx.js +2 -0
- package/chaintypes/substrate/types.d.ts +30457 -0
- package/chaintypes/substrate/types.js +2 -0
- package/cjs/chaintypes/index.js +17 -0
- package/cjs/chaintypes/substrate/consts.js +3 -0
- package/cjs/chaintypes/substrate/errors.js +3 -0
- package/cjs/chaintypes/substrate/events.js +3 -0
- package/cjs/chaintypes/substrate/index.js +18 -0
- package/cjs/chaintypes/substrate/json-rpc.js +3 -0
- package/cjs/chaintypes/substrate/query.js +3 -0
- package/cjs/chaintypes/substrate/runtime.js +3 -0
- package/cjs/chaintypes/substrate/tx.js +3 -0
- package/cjs/chaintypes/substrate/types.js +3 -0
- package/cjs/client/BaseSubstrateClient.js +257 -0
- package/cjs/client/Dedot.js +250 -0
- package/cjs/client/DedotClient.js +186 -0
- package/cjs/client/index.js +18 -0
- package/cjs/executor/ConstantExecutor.js +20 -0
- package/cjs/executor/ErrorExecutor.js +46 -0
- package/cjs/executor/EventExecutor.js +52 -0
- package/cjs/executor/Executor.js +42 -0
- package/cjs/executor/RuntimeApiExecutor.js +121 -0
- package/cjs/executor/StorageQueryExecutor.js +115 -0
- package/cjs/executor/TxExecutor.js +55 -0
- package/cjs/executor/index.js +26 -0
- package/cjs/executor/v2/RuntimeApiExecutorV2.js +21 -0
- package/cjs/executor/v2/StorageQueryExecutorV2.js +65 -0
- package/cjs/executor/v2/TxExecutorV2.js +20 -0
- package/cjs/extrinsic/extensions/ExtraSignedExtension.js +87 -0
- package/cjs/extrinsic/extensions/SignedExtension.js +41 -0
- package/cjs/extrinsic/extensions/index.js +19 -0
- package/cjs/extrinsic/extensions/known/ChargeAssetTxPayment.js +43 -0
- package/cjs/extrinsic/extensions/known/ChargeTransactionPayment.js +16 -0
- package/cjs/extrinsic/extensions/known/CheckGenesis.js +19 -0
- package/cjs/extrinsic/extensions/known/CheckMortality.js +90 -0
- package/cjs/extrinsic/extensions/known/CheckNonZeroSender.js +10 -0
- package/cjs/extrinsic/extensions/known/CheckNonce.js +33 -0
- package/cjs/extrinsic/extensions/known/CheckSpecVersion.js +19 -0
- package/cjs/extrinsic/extensions/known/CheckTxVersion.js +19 -0
- package/cjs/extrinsic/extensions/known/CheckWeight.js +10 -0
- package/cjs/extrinsic/extensions/known/PrevalidateAttests.js +11 -0
- package/cjs/extrinsic/extensions/known/index.js +25 -0
- package/cjs/extrinsic/index.js +18 -0
- package/cjs/extrinsic/submittable/BaseSubmittableExtrinsic.js +70 -0
- package/cjs/extrinsic/submittable/SubmittableExtrinsic.js +47 -0
- package/cjs/extrinsic/submittable/SubmittableExtrinsicV2.js +204 -0
- package/cjs/extrinsic/submittable/SubmittableResult.js +33 -0
- package/cjs/extrinsic/submittable/errors.js +16 -0
- package/cjs/extrinsic/submittable/fakeSigner.js +13 -0
- package/cjs/extrinsic/submittable/index.js +20 -0
- package/cjs/extrinsic/submittable/utils.js +20 -0
- package/cjs/index.js +21 -0
- package/cjs/json-rpc/JsonRpcClient.js +165 -0
- package/cjs/json-rpc/group/ChainHead/BlockUsage.js +24 -0
- package/cjs/json-rpc/group/ChainHead/ChainHead.js +603 -0
- package/cjs/json-rpc/group/ChainHead/error.js +59 -0
- package/cjs/json-rpc/group/ChainHead/index.js +18 -0
- package/cjs/json-rpc/group/ChainSpec.js +19 -0
- package/cjs/json-rpc/group/JsonRpcGroup.js +89 -0
- package/cjs/json-rpc/group/Transaction.js +25 -0
- package/cjs/json-rpc/group/TransactionWatch.js +17 -0
- package/cjs/json-rpc/group/index.js +21 -0
- package/cjs/json-rpc/index.js +20 -0
- package/cjs/json-rpc/scaledResponses.js +15 -0
- package/cjs/json-rpc/subscriptionsInfo.js +20 -0
- package/cjs/package.json +1 -0
- package/cjs/proxychain.js +27 -0
- package/cjs/storage/QueryableStorage.js +161 -0
- package/cjs/storage/index.js +17 -0
- package/cjs/types.js +2 -0
- package/client/BaseSubstrateClient.d.ts +65 -0
- package/client/BaseSubstrateClient.js +252 -0
- package/client/Dedot.d.ts +131 -0
- package/client/Dedot.js +246 -0
- package/client/DedotClient.d.ts +61 -0
- package/client/DedotClient.js +182 -0
- package/client/index.d.ts +2 -0
- package/client/index.js +2 -0
- package/executor/ConstantExecutor.d.ts +10 -0
- package/executor/ConstantExecutor.js +16 -0
- package/executor/ErrorExecutor.d.ts +10 -0
- package/executor/ErrorExecutor.js +42 -0
- package/executor/EventExecutor.d.ts +10 -0
- package/executor/EventExecutor.js +48 -0
- package/executor/Executor.d.ts +149 -0
- package/executor/Executor.js +38 -0
- package/executor/RuntimeApiExecutor.d.ts +27 -0
- package/executor/RuntimeApiExecutor.js +117 -0
- package/executor/StorageQueryExecutor.d.ts +14 -0
- package/executor/StorageQueryExecutor.js +111 -0
- package/executor/TxExecutor.d.ts +10 -0
- package/executor/TxExecutor.js +51 -0
- package/executor/index.d.ts +10 -0
- package/executor/index.js +10 -0
- package/executor/v2/RuntimeApiExecutorV2.d.ts +14 -0
- package/executor/v2/RuntimeApiExecutorV2.js +17 -0
- package/executor/v2/StorageQueryExecutorV2.d.ts +17 -0
- package/executor/v2/StorageQueryExecutorV2.js +61 -0
- package/executor/v2/TxExecutorV2.d.ts +11 -0
- package/executor/v2/TxExecutorV2.js +16 -0
- package/extrinsic/extensions/ExtraSignedExtension.d.ts +14 -0
- package/extrinsic/extensions/ExtraSignedExtension.js +60 -0
- package/extrinsic/extensions/SignedExtension.d.ts +40 -0
- package/extrinsic/extensions/SignedExtension.js +37 -0
- package/extrinsic/extensions/index.d.ts +3 -0
- package/extrinsic/extensions/index.js +3 -0
- package/extrinsic/extensions/known/ChargeAssetTxPayment.d.ts +14 -0
- package/extrinsic/extensions/known/ChargeAssetTxPayment.js +39 -0
- package/extrinsic/extensions/known/ChargeTransactionPayment.d.ts +6 -0
- package/extrinsic/extensions/known/ChargeTransactionPayment.js +12 -0
- package/extrinsic/extensions/known/CheckGenesis.d.ts +10 -0
- package/extrinsic/extensions/known/CheckGenesis.js +15 -0
- package/extrinsic/extensions/known/CheckMortality.d.ts +15 -0
- package/extrinsic/extensions/known/CheckMortality.js +86 -0
- package/extrinsic/extensions/known/CheckNonZeroSender.d.ts +6 -0
- package/extrinsic/extensions/known/CheckNonZeroSender.js +6 -0
- package/extrinsic/extensions/known/CheckNonce.d.ts +10 -0
- package/extrinsic/extensions/known/CheckNonce.js +29 -0
- package/extrinsic/extensions/known/CheckSpecVersion.d.ts +9 -0
- package/extrinsic/extensions/known/CheckSpecVersion.js +15 -0
- package/extrinsic/extensions/known/CheckTxVersion.d.ts +9 -0
- package/extrinsic/extensions/known/CheckTxVersion.js +15 -0
- package/extrinsic/extensions/known/CheckWeight.d.ts +6 -0
- package/extrinsic/extensions/known/CheckWeight.js +6 -0
- package/extrinsic/extensions/known/PrevalidateAttests.d.ts +7 -0
- package/extrinsic/extensions/known/PrevalidateAttests.js +7 -0
- package/extrinsic/extensions/known/index.d.ts +3 -0
- package/extrinsic/extensions/known/index.js +22 -0
- package/extrinsic/index.d.ts +2 -0
- package/extrinsic/index.js +2 -0
- package/extrinsic/submittable/BaseSubmittableExtrinsic.d.ts +17 -0
- package/extrinsic/submittable/BaseSubmittableExtrinsic.js +66 -0
- package/extrinsic/submittable/SubmittableExtrinsic.d.ts +12 -0
- package/extrinsic/submittable/SubmittableExtrinsic.js +43 -0
- package/extrinsic/submittable/SubmittableExtrinsicV2.d.ts +15 -0
- package/extrinsic/submittable/SubmittableExtrinsicV2.js +200 -0
- package/extrinsic/submittable/SubmittableResult.d.ts +19 -0
- package/extrinsic/submittable/SubmittableResult.js +29 -0
- package/extrinsic/submittable/errors.d.ts +11 -0
- package/extrinsic/submittable/errors.js +12 -0
- package/extrinsic/submittable/fakeSigner.d.ts +2 -0
- package/extrinsic/submittable/fakeSigner.js +10 -0
- package/extrinsic/submittable/index.d.ts +4 -0
- package/extrinsic/submittable/index.js +4 -0
- package/extrinsic/submittable/utils.d.ts +10 -0
- package/extrinsic/submittable/utils.js +15 -0
- package/index.d.ts +6 -0
- package/index.js +5 -0
- package/json-rpc/JsonRpcClient.d.ts +50 -0
- package/json-rpc/JsonRpcClient.js +160 -0
- package/json-rpc/group/ChainHead/BlockUsage.d.ts +11 -0
- package/json-rpc/group/ChainHead/BlockUsage.js +20 -0
- package/json-rpc/group/ChainHead/ChainHead.d.ts +70 -0
- package/json-rpc/group/ChainHead/ChainHead.js +599 -0
- package/json-rpc/group/ChainHead/error.d.ts +47 -0
- package/json-rpc/group/ChainHead/error.js +48 -0
- package/json-rpc/group/ChainHead/index.d.ts +2 -0
- package/json-rpc/group/ChainHead/index.js +2 -0
- package/json-rpc/group/ChainSpec.d.ts +10 -0
- package/json-rpc/group/ChainSpec.js +15 -0
- package/json-rpc/group/JsonRpcGroup.d.ts +74 -0
- package/json-rpc/group/JsonRpcGroup.js +85 -0
- package/json-rpc/group/Transaction.d.ts +11 -0
- package/json-rpc/group/Transaction.js +21 -0
- package/json-rpc/group/TransactionWatch.d.ts +10 -0
- package/json-rpc/group/TransactionWatch.js +13 -0
- package/json-rpc/group/index.d.ts +5 -0
- package/json-rpc/group/index.js +5 -0
- package/json-rpc/index.d.ts +4 -0
- package/json-rpc/index.js +4 -0
- package/json-rpc/scaledResponses.d.ts +2 -0
- package/json-rpc/scaledResponses.js +12 -0
- package/json-rpc/subscriptionsInfo.d.ts +2 -0
- package/json-rpc/subscriptionsInfo.js +17 -0
- package/package.json +54 -0
- package/proxychain.d.ts +14 -0
- package/proxychain.js +23 -0
- package/storage/QueryableStorage.d.ts +35 -0
- package/storage/QueryableStorage.js +157 -0
- package/storage/index.d.ts +1 -0
- package/storage/index.js +1 -0
- package/types.d.ts +120 -0
- package/types.js +1 -0
package/types.d.ts
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { BlockHash, Hash, Metadata, PortableRegistry } from '@dedot/codecs';
|
|
2
|
+
import type { ConnectionStatus, JsonRpcProvider, ProviderEvent } from '@dedot/providers';
|
|
3
|
+
import type { AnyShape } from '@dedot/shape';
|
|
4
|
+
import type { IStorage } from '@dedot/storage';
|
|
5
|
+
import type { GenericSubstrateApi, RpcVersion, RuntimeApiName, RuntimeApiSpec, Unsub } from '@dedot/types';
|
|
6
|
+
import type { HashFn, HexString, IEventEmitter } from '@dedot/utils';
|
|
7
|
+
import type { AnySignedExtension } from './extrinsic/index.js';
|
|
8
|
+
export type MetadataKey = `RAW_META/${string}`;
|
|
9
|
+
export type SubscribeMethod = string;
|
|
10
|
+
export type UnsubscribeMethod = string;
|
|
11
|
+
export type NotificationMethod = string;
|
|
12
|
+
export type SubscriptionsInfo = Record<SubscribeMethod, [NotificationMethod, UnsubscribeMethod]>;
|
|
13
|
+
export interface JsonRpcClientOptions {
|
|
14
|
+
/**
|
|
15
|
+
* @description A JSON-RPC provider instance, it could be a `WsProvider` or `SmoldotProvider`
|
|
16
|
+
*/
|
|
17
|
+
provider: JsonRpcProvider;
|
|
18
|
+
subscriptions?: SubscriptionsInfo;
|
|
19
|
+
scaledResponses?: Record<string, AnyShape>;
|
|
20
|
+
}
|
|
21
|
+
export interface ApiOptions extends JsonRpcClientOptions {
|
|
22
|
+
cacheMetadata?: boolean;
|
|
23
|
+
cacheStorage?: IStorage;
|
|
24
|
+
/**
|
|
25
|
+
* @description Metadata is usually downloaded from chain via RPC upon API initialization,
|
|
26
|
+
* We can supply the metadata directly via this option to skip the download metadata step.
|
|
27
|
+
*
|
|
28
|
+
* Metadata Key format: `RAW_META/{genesisHash}/{runtimeSpecVersion}`
|
|
29
|
+
*
|
|
30
|
+
* If the `genesisHash` & `runtimeSpecVersion` of the supplied metadata key match with connected chain,
|
|
31
|
+
* then use the provided metadata, else we fetch it anew from chain.
|
|
32
|
+
*/
|
|
33
|
+
metadata?: Record<MetadataKey, HexString>;
|
|
34
|
+
/**
|
|
35
|
+
* @description User-defined chain-specific signed extensions
|
|
36
|
+
*/
|
|
37
|
+
signedExtensions?: Record<string, AnySignedExtension>;
|
|
38
|
+
/**
|
|
39
|
+
* @description Custom runtime api definitions/specs
|
|
40
|
+
*
|
|
41
|
+
* You probably don't need to use this with the latest Metadata V15,
|
|
42
|
+
* unless you're connecting to a chain supports only Metadata V14
|
|
43
|
+
*/
|
|
44
|
+
runtimeApis?: Record<RuntimeApiName, RuntimeApiSpec[]>;
|
|
45
|
+
/**
|
|
46
|
+
* By default, an `UnknownApiError` error will be thrown out if an api is known (e.g: `api.query.pallet.unknown`) upon evaluation.
|
|
47
|
+
* When set this to `false`, the api evaluation will simply return `undefined`
|
|
48
|
+
*
|
|
49
|
+
* @default true
|
|
50
|
+
*/
|
|
51
|
+
throwOnUnknownApi?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Customize hashing algorithm used
|
|
54
|
+
*
|
|
55
|
+
* @default blake2_256
|
|
56
|
+
*/
|
|
57
|
+
hasher?: HashFn;
|
|
58
|
+
}
|
|
59
|
+
export type ApiEvent = ProviderEvent | 'ready';
|
|
60
|
+
export interface SubstrateRuntimeVersion {
|
|
61
|
+
specName: string;
|
|
62
|
+
implName: string;
|
|
63
|
+
specVersion: number;
|
|
64
|
+
implVersion: number;
|
|
65
|
+
apis: Record<string, number>;
|
|
66
|
+
transactionVersion: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A generic interface for JSON-RPC clients
|
|
70
|
+
*/
|
|
71
|
+
export interface IJsonRpcClient<ChainApi extends GenericSubstrateApi = GenericSubstrateApi, Events extends string = ProviderEvent> extends IEventEmitter<Events> {
|
|
72
|
+
options: JsonRpcClientOptions;
|
|
73
|
+
status: ConnectionStatus;
|
|
74
|
+
provider: JsonRpcProvider;
|
|
75
|
+
connect(): Promise<this>;
|
|
76
|
+
disconnect(): Promise<void>;
|
|
77
|
+
rpc: ChainApi['rpc'];
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A generic interface for Substrate clients at a specific block
|
|
81
|
+
*/
|
|
82
|
+
export interface ISubstrateClientAt<ChainApi extends GenericSubstrateApi = GenericSubstrateApi> {
|
|
83
|
+
atBlockHash?: BlockHash;
|
|
84
|
+
rpcVersion: RpcVersion;
|
|
85
|
+
options: ApiOptions;
|
|
86
|
+
genesisHash: Hash;
|
|
87
|
+
runtimeVersion: SubstrateRuntimeVersion;
|
|
88
|
+
metadata: Metadata;
|
|
89
|
+
registry: PortableRegistry;
|
|
90
|
+
rpc: ChainApi['rpc'];
|
|
91
|
+
consts: ChainApi['consts'];
|
|
92
|
+
query: ChainApi['query'];
|
|
93
|
+
call: ChainApi['call'];
|
|
94
|
+
events: ChainApi['events'];
|
|
95
|
+
errors: ChainApi['errors'];
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* A generic interface for Substrate clients
|
|
99
|
+
*/
|
|
100
|
+
export interface ISubstrateClient<ChainApi extends GenericSubstrateApi = GenericSubstrateApi, Events extends string = ApiEvent> extends IJsonRpcClient<ChainApi, Events>, ISubstrateClientAt<ChainApi> {
|
|
101
|
+
options: ApiOptions;
|
|
102
|
+
tx: ChainApi['tx'];
|
|
103
|
+
at<ChainApiAt extends GenericSubstrateApi = ChainApi>(hash: BlockHash): Promise<ISubstrateClientAt<ChainApiAt>>;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* A generic interface for broadcasting transactions
|
|
107
|
+
*/
|
|
108
|
+
export interface TxBroadcaster {
|
|
109
|
+
/**
|
|
110
|
+
* Broadcast a transaction to the network
|
|
111
|
+
* @param tx
|
|
112
|
+
* @returns {Unsub} A function to stop broadcasting the transaction
|
|
113
|
+
*/
|
|
114
|
+
broadcastTx(tx: HexString): Promise<Unsub>;
|
|
115
|
+
/**
|
|
116
|
+
* Check if this broadcaster is supported,
|
|
117
|
+
* We should check this before broadcasting a transaction
|
|
118
|
+
*/
|
|
119
|
+
supported(): Promise<boolean>;
|
|
120
|
+
}
|
package/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|