Convert jsonrpc & typings to definitions (#2064)
* Convert jsonrpc & typings to definitions * Handle empty interface generation (no types) * Move jsonrpc/create to rpc-core/create * Create imports * Remove jsonrpc package, generate rpc-core from defs * Debug :) * Generate RPC definitions via interfaces * Generate md docs * Remove @polkadot/jsonrpc refs (at least packages) * No empty types * Add PAHNTOM "cleanup" gen * *sigh* regex loop * Update mock for no jsonrpc * Add definition export types * Cleanup linting * Mocking 1 fix * Mocking 2 fix * rpc-core tests updates * CHANGELOG & docs * Add jsonrpc (already mapped) to interfaces * Add aliasses for RPCs * Fix rpc-core tests
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
import { Codec } from '@polkadot/types/types';
|
||||
import { u32, u64 } from '@polkadot/types/primitive';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
import { AnyNumber, ITuple } from '@polkadot/types/types';
|
||||
import { Option, U8aFixed, Vec } from '@polkadot/types/codec';
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
import { AnyNumber, Codec, IExtrinsic } from '@polkadot/types/types';
|
||||
import { Option, Vec } from '@polkadot/types/codec';
|
||||
import { Bytes, StorageKey, Text, bool, u32, u64 } from '@polkadot/types/primitive';
|
||||
import { Metadata } from '@polkadot/types';
|
||||
import { ContractCallRequest, ContractExecResult } from '@polkadot/types/interfaces/contracts';
|
||||
import { CreatedBlock } from '@polkadot/types/interfaces/engine';
|
||||
import { Extrinsic } from '@polkadot/types/interfaces/extrinsics';
|
||||
import { BlockHash, ChainProperties, ExtrinsicOrHash, ExtrinsicStatus, Health, NetworkState, PeerInfo, RpcMethods, RuntimeDispatchInfo, RuntimeVersion } from '@polkadot/types/interfaces/rpc';
|
||||
import { AccountId, BlockNumber, H256, Hash, Header, Index, SignedBlock, StorageData } from '@polkadot/types/interfaces/runtime';
|
||||
import { AccountId, BlockNumber, H256, Hash, Header, Index, Justification, SignedBlock, StorageData } from '@polkadot/types/interfaces/runtime';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
@@ -93,6 +94,16 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
**/
|
||||
getStorage: AugmentedRpc<(address: AccountId | string | Uint8Array, key: H256 | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<Option<Bytes>>>;
|
||||
};
|
||||
engine: {
|
||||
/**
|
||||
* Instructs the manual-seal authorship task to create a new block
|
||||
**/
|
||||
createBlock: AugmentedRpc<(createEmpty: bool | boolean | Uint8Array, finalize: bool | boolean | Uint8Array, parentHash?: BlockHash | string | Uint8Array) => Observable<CreatedBlock>>;
|
||||
/**
|
||||
* Instructs the manual-seal authorship task to finalize a block
|
||||
**/
|
||||
finalizeBlock: AugmentedRpc<(hash: BlockHash | string | Uint8Array, justification?: Justification | string | Uint8Array) => Observable<bool>>;
|
||||
};
|
||||
payment: {
|
||||
/**
|
||||
* Retrieves the fee information for an encoded extrinsic
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
import { AnyNumber, ITuple } from '@polkadot/types/types';
|
||||
import { Compact, Option, U8aFixed, Vec } from '@polkadot/types/codec';
|
||||
|
||||
@@ -22,7 +22,7 @@ import { Metadata, Null, Option, Raw, Text, TypeRegistry, u64 } from '@polkadot/
|
||||
import Linkage, { LinkageResult } from '@polkadot/types/codec/Linkage';
|
||||
import { DEFAULT_VERSION as EXTRINSIC_DEFAULT_VERSION } from '@polkadot/types/extrinsic/constants';
|
||||
import StorageKey, { StorageEntry, unwrapStorageType } from '@polkadot/types/primitive/StorageKey';
|
||||
import { assert, compactStripLength, isNull, isUndefined, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
import { assert, compactStripLength, isNull, isUndefined, logger, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { createSubmittable } from '../submittable';
|
||||
import augmentObject from '../util/augmentObject';
|
||||
@@ -43,6 +43,8 @@ type LinkageData = ITuple<[Codec, Linkage<Codec>]>;
|
||||
const PAGE_SIZE_KEYS = 256;
|
||||
const PAGE_SIZE_VALS = PAGE_SIZE_KEYS / 2;
|
||||
|
||||
const l = logger('api/init');
|
||||
|
||||
export default abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
public readonly registry: Registry;
|
||||
|
||||
@@ -213,17 +215,35 @@ export default abstract class Decorate<ApiType extends ApiTypes> extends Events
|
||||
this.filterRpcMethods(methods);
|
||||
}
|
||||
|
||||
protected filterRpcMethods (methods: string[]): void {
|
||||
// this is true when the RPC has entries
|
||||
const hasResults = methods.length !== 0;
|
||||
protected filterRpcMethods (exposed: string[]): void {
|
||||
const hasResults = exposed.length !== 0;
|
||||
const allKnown = [...this._rpcCore.mapping.entries()];
|
||||
const allKeys = allKnown.reduce((allKeys: string[], [, { alias, method, section, pubsub }]): string[] => {
|
||||
allKeys.push(`${section}_${method}`);
|
||||
|
||||
if (pubsub) {
|
||||
allKeys.push(`${section}_${pubsub[1]}`);
|
||||
allKeys.push(`${section}_${pubsub[2]}`);
|
||||
}
|
||||
|
||||
if (alias) {
|
||||
allKeys.push(...alias);
|
||||
}
|
||||
|
||||
return allKeys;
|
||||
}, []);
|
||||
const unknown = exposed.filter((key) => !allKeys.includes(key));
|
||||
|
||||
if (unknown.length) {
|
||||
l.warn(`RPC methods not decorated: ${unknown.join(', ')}}`);
|
||||
}
|
||||
|
||||
// loop through all entries we have (populated in decorate) and filter as required
|
||||
[...this._rpcCore.mapping.entries()]
|
||||
.filter(([key, { isOptional }]): boolean =>
|
||||
// only remove when we have results and method missing, or with no results if optional
|
||||
hasResults
|
||||
? !methods.includes(key) && key !== 'rpc_methods' // rpc_methods doesn't appear, v1
|
||||
: isOptional || key === 'rpc_methods' // we didn't find this one, remove
|
||||
// only remove when we have results and method missing, or with no results if optional
|
||||
allKnown
|
||||
.filter(([key]): boolean => hasResults
|
||||
? !exposed.includes(key) && key !== 'rpc_methods' // rpc_methods doesn't appear, v1
|
||||
: key === 'rpc_methods' // we didn't find this one, remove
|
||||
)
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
.forEach(([_, { method, section }]): void => {
|
||||
|
||||
@@ -8,10 +8,10 @@ import '@polkadot/api/augment';
|
||||
import BN from 'bn.js';
|
||||
import { DeriveCustom, ExactDerive } from '@polkadot/api-derive';
|
||||
import { Constants } from '@polkadot/metadata/Decorated/types';
|
||||
import { RpcInterface, UserRpc } from '@polkadot/rpc-core/types';
|
||||
import { RpcInterface } from '@polkadot/rpc-core/types';
|
||||
import { Metadata } from '@polkadot/types';
|
||||
import { Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import { Signer, SignerResult, SignatureOptions, Registry, RegisteredTypes } from '@polkadot/types/types';
|
||||
import { DefinitionRpc, DefinitionRpcSub, Signer, SignerResult, SignatureOptions, Registry, RegisteredTypes } from '@polkadot/types/types';
|
||||
|
||||
import ApiBase from '../base';
|
||||
import { DeriveAllSections } from '../util/decorate';
|
||||
@@ -48,7 +48,7 @@ export interface ApiOptions extends RegisteredTypes {
|
||||
/**
|
||||
* @description User-defined RPC methods
|
||||
*/
|
||||
rpc?: UserRpc;
|
||||
rpc?: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>;
|
||||
/**
|
||||
* @description An external signer which will be used to sign extrinsic when account passed in is not KeyringPair
|
||||
*/
|
||||
|
||||
@@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -1,24 +0,0 @@
|
||||
# @polkadot/jsonrpc
|
||||
|
||||
A definition of all the methods exposed in a general Polkadot client application. These are used not only to provide a comprehensive code-generated document of the available methods, but are also used in the API to auto-generate endpoints with the required type-checking.
|
||||
|
||||
For a list of currently exposed methods, see the [method documentation](docs/substrate/rpc.md).
|
||||
|
||||
## Usage
|
||||
|
||||
Installation -
|
||||
|
||||
```
|
||||
yarn add @polkadot/jsonrpc
|
||||
```
|
||||
|
||||
## Adding methods
|
||||
|
||||
As methods are added, simply adding the name, inputs & output will prepare it for use.
|
||||
|
||||
- Add the method to the correct file in [src/rpc/](src/rpc/) (Input/Output types as cross-referenced from the canonical implementation and match one-to-one)
|
||||
- Should a new type be required, add it to the type list, [src/types.js](src/types.js) (Required for TSLint type checking)
|
||||
|
||||
## Classes
|
||||
|
||||
[Classes](SUMMARY.md)
|
||||
@@ -1,33 +0,0 @@
|
||||
{
|
||||
"name": "@polkadot/jsonrpc",
|
||||
"version": "1.8.0-beta.2",
|
||||
"description": "Method definitions for the Polkadot RPC layer",
|
||||
"main": "index.js",
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"registry": "https://registry.npmjs.org"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/polkadot-js/api.git"
|
||||
},
|
||||
"keywords": [
|
||||
"Polkadot",
|
||||
"JsonRPC"
|
||||
],
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [
|
||||
"Jaco Greeff <jacogr@gmail.com>"
|
||||
],
|
||||
"contributors": [],
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/polkadot-js/api/issues"
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/jsonrpc#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.7",
|
||||
"@polkadot/types": "1.8.0-beta.2",
|
||||
"@polkadot/util": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { RpcMethodOpt } from './types';
|
||||
|
||||
import createMethod from './create/method';
|
||||
import createParam from './create/param';
|
||||
|
||||
// NOTE order here is the same as in Rust, alphabetical below
|
||||
|
||||
const nextIndex: RpcMethodOpt = {
|
||||
description: 'Retrieves the next accountIndex as available on the node',
|
||||
isOptional: true,
|
||||
params: [
|
||||
createParam('accountId', 'AccountId')
|
||||
],
|
||||
type: 'Index'
|
||||
};
|
||||
|
||||
const section = 'account';
|
||||
|
||||
/**
|
||||
* @summary Calls to account-specific information.
|
||||
*/
|
||||
export default {
|
||||
isDeprecated: false,
|
||||
isHidden: false,
|
||||
description: '(Optional) Methods that retrieves account-specific information',
|
||||
section,
|
||||
methods: {
|
||||
nextIndex: createMethod(section, 'nextIndex', nextIndex)
|
||||
}
|
||||
};
|
||||
@@ -1,100 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { RpcMethodOpt } from './types';
|
||||
|
||||
import createMethod from './create/method';
|
||||
import createParam from './create/param';
|
||||
|
||||
const hasKey: RpcMethodOpt = {
|
||||
description: 'Returns true if the keystore has private keys for the given public key and key type.',
|
||||
params: [
|
||||
createParam('publicKey', 'Bytes'),
|
||||
createParam('keyType', 'Text')
|
||||
],
|
||||
type: 'bool'
|
||||
};
|
||||
|
||||
const hasSessionKeys: RpcMethodOpt = {
|
||||
description: 'Returns true if the keystore has private keys for the given session public keys.',
|
||||
params: [
|
||||
createParam('sessionKeys', 'Bytes')
|
||||
],
|
||||
type: 'bool'
|
||||
};
|
||||
|
||||
const removeExtrinsic: RpcMethodOpt = {
|
||||
description: 'Remove given extrinsic from the pool and temporarily ban it to prevent reimporting',
|
||||
params: [
|
||||
createParam('bytesOrHash', 'Vec<ExtrinsicOrHash>')
|
||||
],
|
||||
type: 'Vec<Hash>'
|
||||
};
|
||||
|
||||
const insertKey: RpcMethodOpt = {
|
||||
description: 'Insert a key into the keystore.',
|
||||
params: [
|
||||
createParam('keyType', 'Text'),
|
||||
createParam('suri', 'Text'),
|
||||
createParam('publicKey', 'Bytes')
|
||||
],
|
||||
type: 'Bytes'
|
||||
};
|
||||
|
||||
const rotateKeys: RpcMethodOpt = {
|
||||
description: 'Generate new session keys and returns the corresponding public keys',
|
||||
params: [],
|
||||
type: 'Bytes'
|
||||
};
|
||||
|
||||
const pendingExtrinsics: RpcMethodOpt = {
|
||||
description: 'Returns all pending extrinsics, potentially grouped by sender',
|
||||
params: [],
|
||||
type: 'Vec<Extrinsic>'
|
||||
};
|
||||
|
||||
const submitExtrinsic: RpcMethodOpt = {
|
||||
isSigned: true,
|
||||
description: 'Submit a fully formatted extrinsic for block inclusion',
|
||||
params: [
|
||||
createParam('extrinsic', 'Extrinsic')
|
||||
],
|
||||
type: 'Hash'
|
||||
};
|
||||
|
||||
const submitAndWatchExtrinsic: RpcMethodOpt = {
|
||||
description: 'Submit and subscribe to watch an extrinsic until unsubscribed',
|
||||
isSigned: true,
|
||||
params: [
|
||||
createParam('extrinsic', 'Extrinsic')
|
||||
],
|
||||
pubsub: [
|
||||
'extrinsicUpdate',
|
||||
'submitAndWatchExtrinsic',
|
||||
'unwatchExtrinsic'
|
||||
],
|
||||
type: 'ExtrinsicStatus'
|
||||
};
|
||||
|
||||
const section = 'author';
|
||||
|
||||
/**
|
||||
* @summary Calls to work with authors & contributors.
|
||||
*/
|
||||
export default {
|
||||
isDeprecated: false,
|
||||
isHidden: false,
|
||||
description: 'Authoring of network items',
|
||||
section,
|
||||
methods: {
|
||||
hasKey: createMethod(section, 'hasKey', hasKey),
|
||||
hasSessionKeys: createMethod(section, 'hasSessionKeys', hasSessionKeys),
|
||||
insertKey: createMethod(section, 'insertKey', insertKey),
|
||||
removeExtrinsic: createMethod(section, 'removeExtrinsic', removeExtrinsic),
|
||||
rotateKeys: createMethod(section, 'rotateKeys', rotateKeys),
|
||||
pendingExtrinsics: createMethod(section, 'pendingExtrinsics', pendingExtrinsics),
|
||||
submitExtrinsic: createMethod(section, 'submitExtrinsic', submitExtrinsic),
|
||||
submitAndWatchExtrinsic: createMethod(section, 'submitAndWatchExtrinsic', submitAndWatchExtrinsic)
|
||||
}
|
||||
};
|
||||
@@ -1,95 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { RpcMethodOpt } from './types';
|
||||
|
||||
import createMethod from './create/method';
|
||||
import createParam from './create/param';
|
||||
|
||||
// NOTE Order is the same as in Rust
|
||||
|
||||
const getHeader: RpcMethodOpt = {
|
||||
description: 'Retrieves the header for a specific block',
|
||||
params: [
|
||||
createParam('hash', 'BlockHash', { isOptional: true })
|
||||
],
|
||||
type: 'Header'
|
||||
};
|
||||
|
||||
const getBlock: RpcMethodOpt = {
|
||||
description: 'Get header and body of a relay chain block',
|
||||
params: [
|
||||
createParam('hash', 'BlockHash', { isOptional: true })
|
||||
],
|
||||
type: 'SignedBlock'
|
||||
};
|
||||
|
||||
const getBlockHash: RpcMethodOpt = {
|
||||
description: 'Get the block hash for a specific block',
|
||||
params: [
|
||||
createParam('blockNumber', 'BlockNumber', { isOptional: true })
|
||||
],
|
||||
type: 'BlockHash'
|
||||
};
|
||||
|
||||
const getFinalizedHead: RpcMethodOpt = {
|
||||
description: 'Get hash of the last finalized block in the canon chain',
|
||||
params: [],
|
||||
type: 'BlockHash'
|
||||
};
|
||||
|
||||
const subscribeNewHeads: RpcMethodOpt = {
|
||||
description: 'Retrieves the best header via subscription',
|
||||
params: [],
|
||||
// NOTE These still has the aliassed version, compatible with 1.x
|
||||
pubsub: [
|
||||
'newHead',
|
||||
'subscribeNewHead',
|
||||
'unsubscribeNewHead'
|
||||
],
|
||||
type: 'Header'
|
||||
};
|
||||
|
||||
const subscribeFinalizedHeads: RpcMethodOpt = {
|
||||
description: 'Retrieves the best finalized header via subscription',
|
||||
params: [],
|
||||
pubsub: [
|
||||
'finalizedHead',
|
||||
'subscribeFinalizedHeads',
|
||||
'unsubscribeFinalizedHeads'
|
||||
],
|
||||
type: 'Header'
|
||||
};
|
||||
|
||||
const subscribeAllHeads: RpcMethodOpt = {
|
||||
description: 'Retrieves the newest header via subscription',
|
||||
params: [],
|
||||
pubsub: [
|
||||
'allHead',
|
||||
'subscribeAllHeads',
|
||||
'unsubscribeAllHeads'
|
||||
],
|
||||
type: 'Header'
|
||||
};
|
||||
|
||||
const section = 'chain';
|
||||
|
||||
/**
|
||||
* @summary Calls to retrieve chain data.
|
||||
*/
|
||||
export default {
|
||||
isDeprecated: false,
|
||||
isHidden: false,
|
||||
description: 'Retrieval of chain data',
|
||||
section,
|
||||
methods: {
|
||||
getBlock: createMethod(section, 'getBlock', getBlock),
|
||||
getBlockHash: createMethod(section, 'getBlockHash', getBlockHash),
|
||||
getFinalizedHead: createMethod(section, 'getFinalizedHead', getFinalizedHead),
|
||||
getHeader: createMethod(section, 'getHeader', getHeader),
|
||||
subscribeFinalizedHeads: createMethod(section, 'subscribeFinalizedHeads', subscribeFinalizedHeads),
|
||||
subscribeNewHeads: createMethod(section, 'subscribeNewHeads', subscribeNewHeads),
|
||||
subscribeAllHeads: createMethod(section, 'subscribeAllHeads', subscribeAllHeads)
|
||||
}
|
||||
};
|
||||
@@ -1,47 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { RpcMethodOpt } from './types';
|
||||
|
||||
import createMethod from './create/method';
|
||||
import createParam from './create/param';
|
||||
|
||||
// NOTE order here is the same as in Rust, alphabetical below
|
||||
|
||||
const call: RpcMethodOpt = {
|
||||
description: 'Executes a call to a contract',
|
||||
isOptional: true,
|
||||
params: [
|
||||
createParam('callRequest', 'ContractCallRequest'),
|
||||
createParam('at', 'BlockHash', { isOptional: true })
|
||||
],
|
||||
type: 'ContractExecResult'
|
||||
};
|
||||
|
||||
const getStorage: RpcMethodOpt = {
|
||||
description: 'Returns the value under a specified storage key in a contract',
|
||||
isOptional: true,
|
||||
params: [
|
||||
createParam('address', 'AccountId'),
|
||||
createParam('key', 'H256'),
|
||||
createParam('at', 'BlockHash', { isOptional: true })
|
||||
],
|
||||
type: 'Option<Bytes>'
|
||||
};
|
||||
|
||||
const section = 'contracts';
|
||||
|
||||
/**
|
||||
* @summary Calls to retrieve system info.
|
||||
*/
|
||||
export default {
|
||||
isDeprecated: false,
|
||||
isHidden: false,
|
||||
description: '(Optional) Methods that performs actions on contracts',
|
||||
section,
|
||||
methods: {
|
||||
call: createMethod(section, 'call', call),
|
||||
getStorage: createMethod(section, 'getStorage', getStorage)
|
||||
}
|
||||
};
|
||||
@@ -1,24 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { RpcMethodOpt, RpcMethod } from '../types';
|
||||
|
||||
import { isUndefined } from '@polkadot/util';
|
||||
|
||||
/** @internal */
|
||||
export default function createMethod (section: string, method: string, { description, isDeprecated = false, isHidden = false, isOptional = false, isSigned = false, params, pubsub, type }: RpcMethodOpt): RpcMethod {
|
||||
return {
|
||||
description,
|
||||
isDeprecated,
|
||||
isHidden,
|
||||
isOptional,
|
||||
isSigned,
|
||||
isSubscription: !isUndefined(pubsub),
|
||||
method,
|
||||
params,
|
||||
pubsub: pubsub || ['', '', ''],
|
||||
section,
|
||||
type
|
||||
};
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { InterfaceTypes } from '@polkadot/types/types';
|
||||
import { RpcParam } from '../types';
|
||||
|
||||
interface RpcParamOptions {
|
||||
isOptional?: boolean;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export default function createParam (name: string, type: keyof InterfaceTypes, { isOptional = false }: RpcParamOptions = { isOptional: false }): RpcParam {
|
||||
return {
|
||||
isOptional,
|
||||
name,
|
||||
type
|
||||
};
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { RpcMethodOpt } from './types';
|
||||
|
||||
import createMethod from './create/method';
|
||||
import createParam from './create/param';
|
||||
|
||||
const createBlock: RpcMethodOpt = {
|
||||
description: 'Instructs the manual-seal authorship task to create a new block',
|
||||
params: [
|
||||
createParam('createEmpty', 'bool'),
|
||||
createParam('finalize', 'bool'),
|
||||
createParam('parentHash', 'Option<BlockHash>')
|
||||
],
|
||||
type: 'CreatedBlock'
|
||||
};
|
||||
|
||||
const finalizeBlock: RpcMethodOpt = {
|
||||
description: 'Instructs the manual-seal authorship task to finalize a block',
|
||||
params: [
|
||||
createParam('hash', 'BlockHash'),
|
||||
createParam('justification', 'Option<Justification>')
|
||||
],
|
||||
type: 'bool'
|
||||
};
|
||||
|
||||
const section = 'engine';
|
||||
|
||||
/**
|
||||
* @summary Calls to interact with the block production engine
|
||||
*/
|
||||
export default {
|
||||
isDeprecated: false,
|
||||
isHidden: false,
|
||||
description: 'Block production engine',
|
||||
section,
|
||||
methods: {
|
||||
createBlock: createMethod(section, 'createBlock', createBlock),
|
||||
finalizeBlock: createMethod(section, 'finalizeBlock', finalizeBlock)
|
||||
}
|
||||
};
|
||||
@@ -1,12 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import interfaces from './';
|
||||
|
||||
describe('jsonrpc', (): void => {
|
||||
it('exports the available interfaces', (): void => {
|
||||
expect(interfaces).toBeDefined();
|
||||
expect(Object.keys(interfaces).length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
@@ -1,27 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { RpcSection } from './types';
|
||||
|
||||
import account from './account';
|
||||
import author from './author';
|
||||
import chain from './chain';
|
||||
import contracts from './contracts';
|
||||
import payment from './payment';
|
||||
import rpc from './rpc';
|
||||
import state from './state';
|
||||
import system from './system';
|
||||
|
||||
const interfaces: Record<string, RpcSection> = {
|
||||
account,
|
||||
author,
|
||||
chain,
|
||||
contracts,
|
||||
payment,
|
||||
rpc,
|
||||
state,
|
||||
system
|
||||
};
|
||||
|
||||
export default interfaces;
|
||||
@@ -1,35 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { RpcMethodOpt } from './types';
|
||||
|
||||
import createMethod from './create/method';
|
||||
import createParam from './create/param';
|
||||
|
||||
// NOTE order here is the same as in Rust, alphabetical below
|
||||
|
||||
const queryInfo: RpcMethodOpt = {
|
||||
description: 'Retrieves the fee information for an encoded extrinsic',
|
||||
isOptional: true,
|
||||
params: [
|
||||
createParam('extrinsic', 'Bytes'),
|
||||
createParam('at', 'BlockHash', { isOptional: true })
|
||||
],
|
||||
type: 'RuntimeDispatchInfo'
|
||||
};
|
||||
|
||||
const section = 'payment';
|
||||
|
||||
/**
|
||||
* @summary Calls to retrieve payment information.
|
||||
*/
|
||||
export default {
|
||||
isDeprecated: false,
|
||||
isHidden: false,
|
||||
description: 'Methods that retrieves payment information, e.g. fee calculations',
|
||||
section,
|
||||
methods: {
|
||||
queryInfo: createMethod(section, 'queryInfo', queryInfo)
|
||||
}
|
||||
};
|
||||
@@ -1,30 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { RpcMethodOpt } from './types';
|
||||
|
||||
import createMethod from './create/method';
|
||||
|
||||
// NOTE order here is the same as in Rust, alphabetical below
|
||||
|
||||
const methods: RpcMethodOpt = {
|
||||
description: 'Retrieves the list of RPC methods that are exposed by the node',
|
||||
params: [],
|
||||
type: 'RpcMethods'
|
||||
};
|
||||
|
||||
const section = 'rpc';
|
||||
|
||||
/**
|
||||
* @summary Calls to retrieve system info.
|
||||
*/
|
||||
export default {
|
||||
isDeprecated: false,
|
||||
isHidden: false,
|
||||
description: 'Retrieves information about the RPC endpoints',
|
||||
section,
|
||||
methods: {
|
||||
methods: createMethod(section, 'methods', methods)
|
||||
}
|
||||
};
|
||||
@@ -1,172 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { RpcMethodOpt } from './types';
|
||||
|
||||
import createMethod from './create/method';
|
||||
import createParam from './create/param';
|
||||
|
||||
// NOTE Order here is the same as in the Rust code
|
||||
|
||||
const call: RpcMethodOpt = {
|
||||
description: 'Perform a call to a builtin on the chain',
|
||||
params: [
|
||||
createParam('method', 'Text'),
|
||||
createParam('data', 'Bytes'),
|
||||
createParam('at', 'BlockHash', { isOptional: true })
|
||||
],
|
||||
type: 'Bytes'
|
||||
};
|
||||
|
||||
const KEY_QUERY_PARAMS = [
|
||||
createParam('key', 'StorageKey'),
|
||||
createParam('at', 'BlockHash', { isOptional: true })
|
||||
];
|
||||
|
||||
const getKeys: RpcMethodOpt = {
|
||||
description: 'Retrieves the keys with a certain prefix',
|
||||
params: KEY_QUERY_PARAMS,
|
||||
type: 'Vec<StorageKey>'
|
||||
};
|
||||
|
||||
const getKeysPaged: RpcMethodOpt = {
|
||||
description: 'Returns the keys with prefix with pagination support.',
|
||||
params: [
|
||||
createParam('key', 'StorageKey'),
|
||||
createParam('count', 'u32'),
|
||||
createParam('startKey', 'StorageKey', { isOptional: true }),
|
||||
createParam('at', 'BlockHash', { isOptional: true })
|
||||
],
|
||||
type: 'Vec<StorageKey>'
|
||||
};
|
||||
|
||||
const getStorage: RpcMethodOpt = {
|
||||
description: 'Retrieves the storage for a key',
|
||||
params: KEY_QUERY_PARAMS,
|
||||
type: 'StorageData'
|
||||
};
|
||||
|
||||
const getStorageHash: RpcMethodOpt = {
|
||||
description: 'Retrieves the storage hash',
|
||||
params: KEY_QUERY_PARAMS,
|
||||
type: 'Hash'
|
||||
};
|
||||
|
||||
const getStorageSize: RpcMethodOpt = {
|
||||
description: 'Retrieves the storage size',
|
||||
params: KEY_QUERY_PARAMS,
|
||||
type: 'u64'
|
||||
};
|
||||
|
||||
const CHILD_QUERY_PARAMS = [
|
||||
createParam('childStorageKey', 'StorageKey'),
|
||||
createParam('childDefinition', 'StorageKey'),
|
||||
createParam('childType', 'u32'),
|
||||
createParam('key', 'StorageKey'),
|
||||
createParam('at', 'BlockHash', { isOptional: true })
|
||||
];
|
||||
|
||||
const getChildKeys: RpcMethodOpt = {
|
||||
description: 'Retrieves the keys with prefix of a specific child storage',
|
||||
params: CHILD_QUERY_PARAMS,
|
||||
type: 'Vec<StorageKey>'
|
||||
};
|
||||
|
||||
const getChildStorage: RpcMethodOpt = {
|
||||
description: 'Retrieves the child storage for a key',
|
||||
params: CHILD_QUERY_PARAMS,
|
||||
type: 'StorageData'
|
||||
};
|
||||
|
||||
const getChildStorageHash: RpcMethodOpt = {
|
||||
description: 'Retrieves the child storage hash',
|
||||
params: CHILD_QUERY_PARAMS,
|
||||
type: 'Hash'
|
||||
};
|
||||
|
||||
const getChildStorageSize: RpcMethodOpt = {
|
||||
description: 'Retrieves the child storage size',
|
||||
params: CHILD_QUERY_PARAMS,
|
||||
type: 'u64'
|
||||
};
|
||||
|
||||
const getMetadata: RpcMethodOpt = {
|
||||
description: 'Returns the runtime metadata',
|
||||
params: [
|
||||
createParam('at', 'BlockHash', { isOptional: true })
|
||||
],
|
||||
// This is not part of keyof InterfaceTypes
|
||||
type: 'Metadata' as any
|
||||
};
|
||||
|
||||
const getRuntimeVersion: RpcMethodOpt = {
|
||||
description: 'Get the runtime version',
|
||||
params: [
|
||||
createParam('at', 'BlockHash', { isOptional: true })
|
||||
],
|
||||
type: 'RuntimeVersion'
|
||||
};
|
||||
|
||||
const queryStorage: RpcMethodOpt = {
|
||||
description: 'Query historical storage entries (by key) starting from a start block',
|
||||
params: [
|
||||
createParam('keys', 'Vec<StorageKey>'),
|
||||
createParam('startBlock', 'Hash'),
|
||||
createParam('at', 'BlockHash', { isOptional: true })
|
||||
],
|
||||
type: 'Vec<StorageChangeSet>'
|
||||
};
|
||||
|
||||
const subscribeRuntimeVersion: RpcMethodOpt = {
|
||||
description: 'Retrieves the runtime version via subscription',
|
||||
params: [],
|
||||
pubsub: [
|
||||
'runtimeVersion',
|
||||
'subscribeRuntimeVersion',
|
||||
'unsubscribeRuntimeVersion'
|
||||
],
|
||||
type: 'RuntimeVersion'
|
||||
};
|
||||
|
||||
const subscribeStorage: RpcMethodOpt = {
|
||||
description: 'Subscribes to storage changes for the provided keys',
|
||||
params: [
|
||||
createParam('keys', 'Vec<StorageKey>')
|
||||
],
|
||||
pubsub: [
|
||||
'storage',
|
||||
'subscribeStorage',
|
||||
'unsubscribeStorage'
|
||||
],
|
||||
type: 'StorageChangeSet'
|
||||
};
|
||||
|
||||
const section = 'state';
|
||||
|
||||
/**
|
||||
* @summary Query the state and state storage.
|
||||
*/
|
||||
export default {
|
||||
isDeprecated: false,
|
||||
isHidden: false,
|
||||
description: 'Query of state',
|
||||
section,
|
||||
methods: {
|
||||
call: createMethod(section, 'call', call),
|
||||
getChildKeys: createMethod(section, 'getChildKeys', getChildKeys),
|
||||
getChildStorage: createMethod(section, 'getChildStorage', getChildStorage),
|
||||
getChildStorageHash: createMethod(section, 'getChildStorageHash', getChildStorageHash),
|
||||
getChildStorageSize: createMethod(section, 'getChildStorageSize', getChildStorageSize),
|
||||
getKeys: createMethod(section, 'getKeys', getKeys),
|
||||
getKeysPaged: createMethod(section, 'getKeysPaged', getKeysPaged),
|
||||
getMetadata: createMethod(section, 'getMetadata', getMetadata),
|
||||
getRuntimeVersion: createMethod(section, 'getRuntimeVersion', getRuntimeVersion),
|
||||
getStorage: createMethod(section, 'getStorage', getStorage),
|
||||
getStorageHash: createMethod(section, 'getStorageHash', getStorageHash),
|
||||
getStorageSize: createMethod(section, 'getStorageSize', getStorageSize),
|
||||
queryStorage: createMethod(section, 'queryStorage', queryStorage),
|
||||
subscribeRuntimeVersion: createMethod(section, 'subscribeRuntimeVersion', subscribeRuntimeVersion),
|
||||
subscribeStorage: createMethod(section, 'subscribeStorage', subscribeStorage)
|
||||
}
|
||||
};
|
||||
@@ -1,72 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { RpcMethodOpt } from './types';
|
||||
|
||||
import createMethod from './create/method';
|
||||
|
||||
// NOTE order here is the same as in Rust, alphabetical below
|
||||
|
||||
const name: RpcMethodOpt = {
|
||||
description: 'Retrieves the node name',
|
||||
params: [],
|
||||
type: 'Text'
|
||||
};
|
||||
|
||||
const version: RpcMethodOpt = {
|
||||
description: 'Retrieves the version of the node',
|
||||
params: [],
|
||||
type: 'Text'
|
||||
};
|
||||
|
||||
const chain: RpcMethodOpt = {
|
||||
description: 'Retrieves the chain',
|
||||
params: [],
|
||||
type: 'Text'
|
||||
};
|
||||
|
||||
const properties: RpcMethodOpt = {
|
||||
description: 'Get a custom set of properties as a JSON object, defined in the chain spec',
|
||||
params: [],
|
||||
type: 'ChainProperties'
|
||||
};
|
||||
|
||||
const health: RpcMethodOpt = {
|
||||
description: 'Return health status of the node',
|
||||
params: [],
|
||||
type: 'Health'
|
||||
};
|
||||
|
||||
const peers: RpcMethodOpt = {
|
||||
description: 'Returns the currently connected peers',
|
||||
params: [],
|
||||
type: 'Vec<PeerInfo>'
|
||||
};
|
||||
|
||||
const networkState: RpcMethodOpt = {
|
||||
description: 'Returns current state of the network',
|
||||
params: [],
|
||||
type: 'NetworkState'
|
||||
};
|
||||
|
||||
const section = 'system';
|
||||
|
||||
/**
|
||||
* @summary Calls to retrieve system info.
|
||||
*/
|
||||
export default {
|
||||
isDeprecated: false,
|
||||
isHidden: false,
|
||||
description: 'Calls to retrieve system info',
|
||||
section,
|
||||
methods: {
|
||||
chain: createMethod(section, 'chain', chain),
|
||||
health: createMethod(section, 'health', health),
|
||||
name: createMethod(section, 'name', name),
|
||||
networkState: createMethod(section, 'networkState', networkState),
|
||||
peers: createMethod(section, 'peers', peers),
|
||||
properties: createMethod(section, 'properties', properties),
|
||||
version: createMethod(section, 'version', version)
|
||||
}
|
||||
};
|
||||
@@ -1,48 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { InterfaceTypes } from '@polkadot/types/types';
|
||||
|
||||
type PubSub = [string, string, string];
|
||||
|
||||
export interface RpcParam {
|
||||
isOptional: boolean;
|
||||
name: string;
|
||||
type: keyof InterfaceTypes;
|
||||
}
|
||||
|
||||
export interface RpcMethodOpt {
|
||||
description: string;
|
||||
isDeprecated?: boolean;
|
||||
isHidden?: boolean;
|
||||
isOptional?: boolean;
|
||||
isSigned?: boolean;
|
||||
isSubscription?: boolean;
|
||||
params: RpcParam[];
|
||||
pubsub?: PubSub;
|
||||
type: keyof InterfaceTypes;
|
||||
}
|
||||
|
||||
export interface RpcMethod {
|
||||
alias?: string;
|
||||
description: string;
|
||||
isDeprecated: boolean;
|
||||
isHidden: boolean;
|
||||
isOptional: boolean;
|
||||
isSigned: boolean;
|
||||
isSubscription: boolean;
|
||||
method: string;
|
||||
params: RpcParam[];
|
||||
pubsub: PubSub;
|
||||
section: string;
|
||||
type: keyof InterfaceTypes;
|
||||
}
|
||||
|
||||
export interface RpcSection {
|
||||
isDeprecated: boolean;
|
||||
isHidden: boolean;
|
||||
description: string;
|
||||
section: string;
|
||||
methods: Record<string, RpcMethod>;
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import metadataDefs from '@polkadot/types/interfaces/metadata/definitions';
|
||||
import { AllHashers } from '@polkadot/types/interfaces/metadata/definitions';
|
||||
import { StorageHasher } from '@polkadot/types/interfaces';
|
||||
import { u8aConcat, u8aToU8a } from '@polkadot/util';
|
||||
import { blake2AsU8a, xxhashAsU8a } from '@polkadot/util-crypto';
|
||||
@@ -13,7 +13,7 @@ export type HasherFunction = (data: HasherInput) => Uint8Array;
|
||||
|
||||
const DEFAULT_FN = (data: HasherInput): Uint8Array => xxhashAsU8a(data, 128);
|
||||
|
||||
const HASHERS: Record<keyof typeof metadataDefs.types.StorageHasherV11._enum, HasherFunction> = {
|
||||
const HASHERS: Record<keyof typeof AllHashers, HasherFunction> = {
|
||||
Blake2_128: (data: HasherInput): Uint8Array => // eslint-disable-line @typescript-eslint/camelcase
|
||||
blake2AsU8a(data, 128),
|
||||
Blake2_128Concat: (data: HasherInput): Uint8Array => // eslint-disable-line @typescript-eslint/camelcase
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.7",
|
||||
"@polkadot/jsonrpc": "1.8.0-beta.2",
|
||||
"@polkadot/metadata": "1.8.0-beta.2",
|
||||
"@polkadot/rpc-provider": "1.8.0-beta.2",
|
||||
"@polkadot/types": "1.8.0-beta.2",
|
||||
|
||||
@@ -24,37 +24,32 @@ describe('Api', (): void => {
|
||||
Object.keys(rpc).filter((key): boolean => !key.startsWith('_'))
|
||||
).toEqual([
|
||||
'mapping', 'provider', 'registry', 'sections',
|
||||
'account', 'author', 'chain', 'contracts', 'payment', 'rpc', 'state', 'system'
|
||||
'account', 'author', 'chain', 'contracts', 'engine', 'payment', 'rpc', 'state', 'system'
|
||||
]);
|
||||
});
|
||||
|
||||
it('allows for the definition of user RPCs', (): void => {
|
||||
const rpc = new Rpc(registry, new MockProvider(registry), {
|
||||
testing: [
|
||||
{
|
||||
name: 'foo',
|
||||
testing: {
|
||||
foo: {
|
||||
description: 'foo',
|
||||
params: [{ name: 'bar', type: 'u32' }],
|
||||
type: 'Balance'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
expect(isFunction((rpc as any).testing.foo)).toBe(true);
|
||||
expect(rpc.sections.includes('testing')).toBe(true);
|
||||
expect(rpc.mapping.get('testing_foo')).toEqual({
|
||||
description: 'User defined',
|
||||
isDeprecated: false,
|
||||
isHidden: false,
|
||||
isOptional: false,
|
||||
isSigned: false,
|
||||
description: 'foo',
|
||||
isSubscription: false,
|
||||
jsonrpc: 'testing_foo',
|
||||
method: 'foo',
|
||||
params: [{
|
||||
isOptional: false,
|
||||
name: 'bar',
|
||||
type: 'u32'
|
||||
}],
|
||||
pubsub: ['', '', ''],
|
||||
section: 'testing',
|
||||
type: 'Balance'
|
||||
});
|
||||
|
||||
@@ -3,24 +3,19 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ProviderInterface, ProviderInterfaceCallback } from '@polkadot/rpc-provider/types';
|
||||
import { RpcMethod, RpcSection, RpcParam } from '@polkadot/jsonrpc/types';
|
||||
import { Hash } from '@polkadot/types/interfaces';
|
||||
import { AnyJson, Codec, Registry } from '@polkadot/types/types';
|
||||
import { RpcInterface, RpcInterfaceMethod, UserRpc } from './types';
|
||||
import { AnyJson, Codec, DefinitionRpc, DefinitionRpcExt, DefinitionRpcSub, Registry } from '@polkadot/types/types';
|
||||
import { RpcInterface, RpcInterfaceMethod } from './types';
|
||||
|
||||
import memoizee from 'memoizee';
|
||||
import { combineLatest, from, Observable, Observer, of, throwError } from 'rxjs';
|
||||
import { catchError, map, publishReplay, refCount, switchMap } from 'rxjs/operators';
|
||||
import jsonrpc from '@polkadot/jsonrpc';
|
||||
import jsonrpcMethod from '@polkadot/jsonrpc/create/method';
|
||||
import jsonrpcParam from '@polkadot/jsonrpc/create/param';
|
||||
import jsonrpc from '@polkadot/types/interfaces/jsonrpc';
|
||||
import { Option, StorageKey, Vec, createClass, createTypeUnsafe } from '@polkadot/types';
|
||||
import { assert, isFunction, isNull, isNumber, isUndefined, logger, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { drr } from './rxjs';
|
||||
|
||||
type UserRpcConverted = Record<string, Record<string, RpcMethod>>;
|
||||
|
||||
const l = logger('rpc-core');
|
||||
|
||||
const EMPTY_META = {
|
||||
@@ -34,7 +29,7 @@ const EMPTY_META = {
|
||||
|
||||
// utility method to create a nicely-formatted error
|
||||
/** @internal */
|
||||
function createErrorMessage ({ method, params, type }: RpcMethod, error: Error): string {
|
||||
function createErrorMessage (method: string, { params, type }: DefinitionRpc, error: Error): string {
|
||||
const inputs = params.map(({ isOptional, name, type }): string =>
|
||||
`${name}${isOptional ? '?' : ''}: ${type}`
|
||||
).join(', ');
|
||||
@@ -68,7 +63,7 @@ function createErrorMessage ({ method, params, type }: RpcMethod, error: Error):
|
||||
export default class Rpc implements RpcInterface {
|
||||
readonly #storageCache = new Map<string, string | null>();
|
||||
|
||||
public readonly mapping: Map<string, RpcMethod> = new Map();
|
||||
public readonly mapping: Map<string, DefinitionRpcExt> = new Map();
|
||||
|
||||
public readonly provider: ProviderInterface;
|
||||
|
||||
@@ -88,6 +83,8 @@ export default class Rpc implements RpcInterface {
|
||||
|
||||
public readonly contracts!: RpcInterface['contracts'];
|
||||
|
||||
public readonly engine!: RpcInterface['engine'];
|
||||
|
||||
public readonly payment!: RpcInterface['payment'];
|
||||
|
||||
public readonly rpc!: RpcInterface['rpc'];
|
||||
@@ -101,14 +98,14 @@ export default class Rpc implements RpcInterface {
|
||||
* Default constructor for the Api Object
|
||||
* @param {ProviderInterface} provider An API provider using HTTP or WebSocket
|
||||
*/
|
||||
constructor (registry: Registry, provider: ProviderInterface, userRpc: UserRpc = {}) {
|
||||
constructor (registry: Registry, provider: ProviderInterface, userRpc: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>> = {}) {
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
assert(provider && isFunction(provider.send), 'Expected Provider to API create');
|
||||
|
||||
this.registry = registry;
|
||||
this.provider = provider;
|
||||
|
||||
this.createInterfaces(jsonrpc, userRpc);
|
||||
this.createInterfaces(userRpc);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,47 +115,32 @@ export default class Rpc implements RpcInterface {
|
||||
this.provider.disconnect();
|
||||
}
|
||||
|
||||
private createInterfaces<Section extends keyof RpcInterface> (interfaces: Record<string, RpcSection>, userBare: UserRpc): void {
|
||||
private createInterfaces<Section extends keyof RpcInterface> (userRpc: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>): void {
|
||||
const sectionNames = Object.keys(jsonrpc);
|
||||
|
||||
// these are the base keys (i.e. part of jsonrpc)
|
||||
this.sections.push(...Object.keys(interfaces));
|
||||
this.sections.push(...sectionNames);
|
||||
|
||||
// add any extra user-defined sections
|
||||
this.sections.push(...Object.keys(userBare).filter((key): boolean => !this.sections.includes(key)));
|
||||
|
||||
// convert the user inputs into the same format as used in jsonrpc
|
||||
const user = Object.entries(userBare).reduce((user: UserRpcConverted, [sectionName, methods]): UserRpcConverted => {
|
||||
user[sectionName] = methods.reduce((section: Record<string, RpcMethod>, def): Record<string, RpcMethod> => {
|
||||
const { description = 'User defined', name, params, type } = def;
|
||||
|
||||
section[name] = jsonrpcMethod(sectionName, name, {
|
||||
description,
|
||||
params: params.map(({ isOptional, name, type }): RpcParam =>
|
||||
jsonrpcParam(name, type as any, { isOptional })),
|
||||
type: type as any
|
||||
});
|
||||
|
||||
return section;
|
||||
}, {});
|
||||
|
||||
return user;
|
||||
}, {});
|
||||
this.sections.push(...Object.keys(userRpc).filter((key): boolean => !this.sections.includes(key)));
|
||||
|
||||
// decorate the sections with base and user methods
|
||||
this.sections.forEach((sectionName): void => {
|
||||
(this as any)[sectionName as Section] = {
|
||||
...this.createInterface(sectionName, interfaces[sectionName] ? interfaces[sectionName].methods : {}),
|
||||
...this.createInterface(sectionName, user[sectionName] || {})
|
||||
...this.createInterface(sectionName, jsonrpc[sectionName as 'babe'] || {}),
|
||||
...this.createInterface(sectionName, userRpc[sectionName] || {})
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private createInterface<Section extends keyof RpcInterface> (section: string, methods: Record<string, RpcMethod>): RpcInterface[Section] {
|
||||
private createInterface<Section extends keyof RpcInterface> (section: string, methods: Record<string, DefinitionRpc | DefinitionRpcSub>): RpcInterface[Section] {
|
||||
return Object
|
||||
.keys(methods)
|
||||
.reduce((exposed, method): RpcInterface[Section] => {
|
||||
const def = methods[method];
|
||||
const isSubscription = !!(def as DefinitionRpcSub).pubsub;
|
||||
|
||||
this.mapping.set(`${section}_${method}`, def);
|
||||
this.mapping.set(`${section}_${method}`, { ...def, isSubscription, jsonrpc: `${section}_${method}`, method, section });
|
||||
|
||||
// FIXME Remove any here
|
||||
// To do so, remove `RpcInterfaceMethod` from './types.ts', and refactor
|
||||
@@ -166,9 +148,9 @@ export default class Rpc implements RpcInterface {
|
||||
// `<S extends keyof RpcInterface, M extends keyof RpcInterface[S]>`
|
||||
// Not doing so, because it makes this class a little bit less readable,
|
||||
// and leaving it as-is doesn't harm much
|
||||
(exposed as any)[method] = def.isSubscription
|
||||
? this.createMethodSubscribe(def)
|
||||
: this.createMethodSend(def);
|
||||
(exposed as any)[method] = isSubscription
|
||||
? this.createMethodSubscribe(section, method, def as DefinitionRpcSub)
|
||||
: this.createMethodSend(section, method, def);
|
||||
|
||||
return exposed;
|
||||
}, {} as RpcInterface[Section]);
|
||||
@@ -182,11 +164,9 @@ export default class Rpc implements RpcInterface {
|
||||
return call as RpcInterfaceMethod;
|
||||
}
|
||||
|
||||
private createMethodSend (method: RpcMethod): RpcInterfaceMethod {
|
||||
const rpcName = `${method.section}_${method.method}`;
|
||||
private createMethodSend (section: string, method: string, def: DefinitionRpc): RpcInterfaceMethod {
|
||||
const rpcName = `${section}_${method}`;
|
||||
const creator = (isRaw: boolean) => (...values: any[]): Observable<any> => {
|
||||
// TODO Warn on deprecated methods
|
||||
|
||||
// Here, logically, it should be `of(this.formatInputs(method, values))`.
|
||||
// However, formatInputs can throw, and when it does, the above way
|
||||
// doesn't throw in the "Observable loop" (which is internally wrapped in
|
||||
@@ -194,7 +174,7 @@ export default class Rpc implements RpcInterface {
|
||||
// - first do `of(1)` - won't throw
|
||||
// - then do `map(()=>this.formatInputs)` - might throw, but inside Observable.
|
||||
return of(1).pipe(
|
||||
map((): Codec[] => this.formatInputs(method, values)),
|
||||
map((): Codec[] => this.formatInputs(def, values)),
|
||||
switchMap((params): Observable<[Codec[], any]> =>
|
||||
combineLatest([
|
||||
of(params),
|
||||
@@ -204,10 +184,10 @@ export default class Rpc implements RpcInterface {
|
||||
map(([params, result]): any =>
|
||||
isRaw
|
||||
? this.registry.createType('Raw', result)
|
||||
: this.formatOutput(method, params, result)
|
||||
: this.formatOutput(def, params, result)
|
||||
),
|
||||
catchError((error): any => {
|
||||
const message = createErrorMessage(method, error);
|
||||
const message = createErrorMessage(method, def, error);
|
||||
|
||||
// don't scare with old nodes, this is handled transparently
|
||||
rpcName !== 'rpc_methods' && l.error(message);
|
||||
@@ -238,17 +218,17 @@ export default class Rpc implements RpcInterface {
|
||||
});
|
||||
}
|
||||
|
||||
private createMethodSubscribe (method: RpcMethod): RpcInterfaceMethod {
|
||||
const [updateType, subMethod, unsubMethod] = method.pubsub;
|
||||
const subName = `${method.section}_${subMethod}`;
|
||||
const unsubName = `${method.section}_${unsubMethod}`;
|
||||
const subType = `${method.section}_${updateType}`;
|
||||
private createMethodSubscribe (section: string, method: string, def: DefinitionRpcSub): RpcInterfaceMethod {
|
||||
const [updateType, subMethod, unsubMethod] = def.pubsub;
|
||||
const subName = `${section}_${subMethod}`;
|
||||
const unsubName = `${section}_${unsubMethod}`;
|
||||
const subType = `${section}_${updateType}`;
|
||||
const creator = (isRaw: boolean) => (...values: any[]): Observable<any> => {
|
||||
return new Observable((observer: Observer<any>): VoidCallback => {
|
||||
// Have at least an empty promise, as used in the unsubscribe
|
||||
let subscriptionPromise: Promise<number | void> = Promise.resolve();
|
||||
const errorHandler = (error: Error): void => {
|
||||
const message = createErrorMessage(method, error);
|
||||
const message = createErrorMessage(method, def, error);
|
||||
|
||||
l.error(message);
|
||||
|
||||
@@ -256,11 +236,11 @@ export default class Rpc implements RpcInterface {
|
||||
};
|
||||
|
||||
try {
|
||||
const params = this.formatInputs(method, values);
|
||||
const params = this.formatInputs(def, values);
|
||||
const paramsJson = params.map((param): AnyJson => param.toJSON());
|
||||
const update = (error?: Error | null, result?: any): void => {
|
||||
if (error) {
|
||||
l.error(createErrorMessage(method, error));
|
||||
l.error(createErrorMessage(method, def, error));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -268,7 +248,7 @@ export default class Rpc implements RpcInterface {
|
||||
observer.next(
|
||||
isRaw
|
||||
? this.registry.createType('Raw', result)
|
||||
: this.formatOutput(method, params, result)
|
||||
: this.formatOutput(def, params, result)
|
||||
);
|
||||
} catch (error) {
|
||||
observer.error(error);
|
||||
@@ -301,7 +281,7 @@ export default class Rpc implements RpcInterface {
|
||||
? this.provider.unsubscribe(subType, unsubName, subscriptionId)
|
||||
: Promise.resolve(false)
|
||||
)
|
||||
.catch((error: Error): void => l.error(createErrorMessage(method, error)));
|
||||
.catch((error: Error): void => l.error(createErrorMessage(method, def, error)));
|
||||
};
|
||||
}).pipe(drr());
|
||||
};
|
||||
@@ -319,16 +299,16 @@ export default class Rpc implements RpcInterface {
|
||||
return memoized;
|
||||
}
|
||||
|
||||
private formatInputs (method: RpcMethod, inputs: any[]): Codec[] {
|
||||
const reqArgCount = method.params.filter(({ isOptional }): boolean => !isOptional).length;
|
||||
const optText = reqArgCount === method.params.length
|
||||
private formatInputs (def: DefinitionRpc, inputs: any[]): Codec[] {
|
||||
const reqArgCount = def.params.filter(({ isOptional }): boolean => !isOptional).length;
|
||||
const optText = reqArgCount === def.params.length
|
||||
? ''
|
||||
: ` (${method.params.length - reqArgCount} optional)`;
|
||||
: ` (${def.params.length - reqArgCount} optional)`;
|
||||
|
||||
assert(inputs.length >= reqArgCount && inputs.length <= method.params.length, `Expected ${method.params.length} parameters${optText}, ${inputs.length} found instead`);
|
||||
assert(inputs.length >= reqArgCount && inputs.length <= def.params.length, `Expected ${def.params.length} parameters${optText}, ${inputs.length} found instead`);
|
||||
|
||||
return inputs.map((input, index): Codec =>
|
||||
createTypeUnsafe(this.registry, method.params[index].type, [input])
|
||||
createTypeUnsafe(this.registry, def.params[index].type, [input])
|
||||
);
|
||||
}
|
||||
|
||||
@@ -338,8 +318,8 @@ export default class Rpc implements RpcInterface {
|
||||
return ['0x3a636f6465'].includes(key.toHex());
|
||||
}
|
||||
|
||||
private formatOutput (method: RpcMethod, params: Codec[], result?: any): Codec | Codec[] {
|
||||
if (method.type === 'StorageData') {
|
||||
private formatOutput (rpc: DefinitionRpc, params: Codec[], result?: any): Codec | Codec[] {
|
||||
if (rpc.type === 'StorageData') {
|
||||
const key = params[0] as StorageKey;
|
||||
|
||||
try {
|
||||
@@ -349,16 +329,16 @@ export default class Rpc implements RpcInterface {
|
||||
|
||||
throw error;
|
||||
}
|
||||
} else if (method.type === 'StorageChangeSet') {
|
||||
} else if (rpc.type === 'StorageChangeSet') {
|
||||
return this.formatStorageSet(params[0] as Vec<StorageKey>, result.changes);
|
||||
} else if (method.type === 'Vec<StorageChangeSet>') {
|
||||
} else if (rpc.type === 'Vec<StorageChangeSet>') {
|
||||
return result.map(({ block, changes }: { block: string; changes: [string, string | null][] }): [Hash, Codec[]] => [
|
||||
this.registry.createType('Hash', block),
|
||||
this.formatStorageSet(params[0] as Vec<StorageKey>, changes)
|
||||
]);
|
||||
}
|
||||
|
||||
return createTypeUnsafe(this.registry, method.type, [result]);
|
||||
return createTypeUnsafe(this.registry, rpc.type, [result]);
|
||||
}
|
||||
|
||||
private formatStorageData (key: StorageKey, value: string | null): Codec {
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { DefinitionRpc } from '@polkadot/types/types';
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import Rpc from '.';
|
||||
@@ -9,23 +11,21 @@ import Rpc from '.';
|
||||
describe('methodSend', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
let rpc: Rpc;
|
||||
let methods: any;
|
||||
let methods: Record<string, DefinitionRpc>;
|
||||
let provider: any;
|
||||
|
||||
beforeEach((): void => {
|
||||
methods = {
|
||||
blah: {
|
||||
method: 'blah',
|
||||
description: 'test',
|
||||
params: [
|
||||
{ name: 'foo', type: 'Bytes' }
|
||||
],
|
||||
section: 'test',
|
||||
type: 'Bytes'
|
||||
},
|
||||
bleh: {
|
||||
method: 'bleh',
|
||||
description: 'test',
|
||||
params: [],
|
||||
section: 'test',
|
||||
type: 'Bytes'
|
||||
}
|
||||
};
|
||||
@@ -41,7 +41,7 @@ describe('methodSend', (): void => {
|
||||
|
||||
it('wraps errors with the call signature', (done): void => {
|
||||
// private access
|
||||
const method = (rpc as any).createMethodSend(methods.blah);
|
||||
const method = (rpc as any).createMethodSend('test', 'blah', methods.blah);
|
||||
|
||||
method().subscribe(
|
||||
(): void => undefined,
|
||||
@@ -54,7 +54,7 @@ describe('methodSend', (): void => {
|
||||
|
||||
it('checks for mismatched parameters', (done): void => {
|
||||
// private method
|
||||
const method = (rpc as any).createMethodSend(methods.bleh);
|
||||
const method = (rpc as any).createMethodSend('test', 'bleh', methods.bleh);
|
||||
|
||||
method(1).subscribe(
|
||||
(): void => undefined,
|
||||
@@ -66,7 +66,7 @@ describe('methodSend', (): void => {
|
||||
|
||||
it('calls the provider with the correct parameters', (done): void => {
|
||||
// private method
|
||||
const method = (rpc as any).createMethodSend(methods.blah);
|
||||
const method = (rpc as any).createMethodSend('test', 'blah', methods.blah);
|
||||
|
||||
// Args are length-prefixed, because it's a Bytes
|
||||
method(new Uint8Array([2 << 2, 0x12, 0x34])).subscribe((): void => {
|
||||
|
||||
@@ -10,12 +10,3 @@ export interface RpcInterfaceMethod {
|
||||
(...params: any[]): Observable<any>;
|
||||
raw (...params: any[]): Observable<any>;
|
||||
}
|
||||
|
||||
export interface UserRpcMethod {
|
||||
description?: string;
|
||||
name: string;
|
||||
params: { isOptional?: boolean; name: string; type: string }[];
|
||||
type: string;
|
||||
}
|
||||
|
||||
export type UserRpc = Record<string, UserRpcMethod[]>;
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.7",
|
||||
"@polkadot/jsonrpc": "1.8.0-beta.2",
|
||||
"@polkadot/metadata": "1.8.0-beta.2",
|
||||
"@polkadot/types": "1.8.0-beta.2",
|
||||
"@polkadot/util": "^2.6.2",
|
||||
|
||||
@@ -12,7 +12,7 @@ import BN from 'bn.js';
|
||||
import EventEmitter from 'eventemitter3';
|
||||
import Metadata from '@polkadot/metadata/Decorated';
|
||||
import rpcMetadata from '@polkadot/metadata/Metadata/static';
|
||||
import interfaces from '@polkadot/jsonrpc';
|
||||
import jsonrpc from '@polkadot/types/interfaces/jsonrpc';
|
||||
import testKeyring from '@polkadot/keyring/testing';
|
||||
import rpcHeader from '@polkadot/types/json/Header.004.json';
|
||||
import rpcSignedBlock from '@polkadot/types/json/SignedBlock.004.immortal.json';
|
||||
@@ -21,15 +21,11 @@ import { randomAsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
const INTERVAL = 1000;
|
||||
const SUBSCRIPTIONS: string[] = Array.prototype.concat.apply(
|
||||
[], Object.values(interfaces).map((area): string[] =>
|
||||
[], Object.values(jsonrpc).map((section): string[] =>
|
||||
Object
|
||||
.values(area.methods)
|
||||
.filter((method): boolean =>
|
||||
method.isSubscription
|
||||
)
|
||||
.map(({ method, section }): string =>
|
||||
`${section}_${method}`
|
||||
)
|
||||
.values(section)
|
||||
.filter(({ isSubscription }) => isSubscription)
|
||||
.map(({ jsonrpc }) => jsonrpc)
|
||||
.concat('chain_subscribeNewHead')
|
||||
)
|
||||
);
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
"@babel/register": "^7.8.6",
|
||||
"@babel/runtime": "^7.8.7",
|
||||
"@polkadot/api": "1.8.0-beta.2",
|
||||
"@polkadot/jsonrpc": "1.8.0-beta.2",
|
||||
"@polkadot/metadata": "1.8.0-beta.2",
|
||||
"@polkadot/rpc-provider": "1.8.0-beta.2",
|
||||
"@polkadot/types": "1.8.0-beta.2",
|
||||
|
||||
@@ -17,7 +17,6 @@ try {
|
||||
'^@polkadot/api-derive(.*)': './packages/api-derive/src\\1',
|
||||
'^@polkadot/metadata(.*)': './packages/metadata/src\\1',
|
||||
'^@polkadot/api(.*)': './packages/api/src/\\1',
|
||||
'^@polkadot/jsonrpc(.*)': './packages/jsonrpc/src\\1',
|
||||
'^@polkadot/rpc-core(.*)': './packages/rpc-core/src\\1',
|
||||
'^@polkadot/rpc-provider(.*)': './packages/rpc-provider/src\\1',
|
||||
'^@polkadot/types(.*)': './packages/types/src\\1'
|
||||
|
||||
@@ -14,7 +14,6 @@ try {
|
||||
plugins: [
|
||||
['module-resolver', {
|
||||
alias: {
|
||||
'^@polkadot/jsonrpc(.*)': './packages/jsonrpc/src\\1',
|
||||
'^@polkadot/metadata(.*)': './packages/metadata/src\\1',
|
||||
'^@polkadot/types(.*)': './packages/types/src\\1'
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ try {
|
||||
plugins: [
|
||||
['module-resolver', {
|
||||
alias: {
|
||||
'^@polkadot/jsonrpc(.*)': './packages/jsonrpc/src\\1',
|
||||
'^@polkadot/metadata(.*)': './packages/metadata/src\\1',
|
||||
'^@polkadot/types(.*)': './packages/types/src\\1'
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import interfaces from '@polkadot/jsonrpc';
|
||||
import * as definitions from '@polkadot/types/interfaces/definitions';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
@@ -19,26 +18,30 @@ export default function generateRpcTypes (dest = 'packages/api/src/augment/rpc.t
|
||||
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
||||
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
||||
}, {});
|
||||
const body = Object.keys(interfaces).sort().reduce<string[]>((allSections, section): string[] => {
|
||||
const allMethods = Object.keys(interfaces[section].methods).sort().map((key): string => {
|
||||
const method = interfaces[section].methods[key];
|
||||
const rpcKeys = Object
|
||||
.keys(definitions)
|
||||
.filter((key) => Object.keys(definitions[key as 'babe'].rpc || {}).length !== 0)
|
||||
.sort();
|
||||
const body = rpcKeys.reduce<string[]>((allSections, section): string[] => {
|
||||
const allMethods = Object.keys(definitions[section as 'babe'].rpc).sort().map((methodName): string => {
|
||||
const def = definitions[section as 'babe'].rpc[methodName];
|
||||
|
||||
// These are too hard to type with generics, do manual overrides
|
||||
if (section === 'state') {
|
||||
setImports(allDefs, imports, ['Codec', 'Hash', 'StorageKey', 'Vec']);
|
||||
|
||||
if (method.method === 'getStorage') {
|
||||
return createDocComments(6, [method.description]) + indent(6)(`getStorage: AugmentedRpc<<T = Codec>(key: ${StorageKeyTye}, block?: Hash | Uint8Array | string) => Observable<T>>;`);
|
||||
} else if (method.method === 'queryStorage') {
|
||||
return createDocComments(6, [method.description]) + indent(6)(`queryStorage: AugmentedRpc<<T = Codec[]>(keys: Vec<StorageKey> | (${StorageKeyTye})[], fromBlock?: Hash | Uint8Array | string, toBlock?: Hash | Uint8Array | string) => Observable<[Hash, T][]>>;`);
|
||||
} else if (method.method === 'subscribeStorage') {
|
||||
return createDocComments(6, [method.description]) + indent(6)(`subscribeStorage: AugmentedRpc<<T = Codec[]>(keys: Vec<StorageKey> | (${StorageKeyTye})[]) => Observable<T>>;`);
|
||||
if (methodName === 'getStorage') {
|
||||
return createDocComments(6, [def.description]) + indent(6)(`getStorage: AugmentedRpc<<T = Codec>(key: ${StorageKeyTye}, block?: Hash | Uint8Array | string) => Observable<T>>;`);
|
||||
} else if (methodName === 'queryStorage') {
|
||||
return createDocComments(6, [def.description]) + indent(6)(`queryStorage: AugmentedRpc<<T = Codec[]>(keys: Vec<StorageKey> | (${StorageKeyTye})[], fromBlock?: Hash | Uint8Array | string, toBlock?: Hash | Uint8Array | string) => Observable<[Hash, T][]>>;`);
|
||||
} else if (methodName === 'subscribeStorage') {
|
||||
return createDocComments(6, [def.description]) + indent(6)(`subscribeStorage: AugmentedRpc<<T = Codec[]>(keys: Vec<StorageKey> | (${StorageKeyTye})[]) => Observable<T>>;`);
|
||||
}
|
||||
}
|
||||
|
||||
setImports(allDefs, imports, [method.type]);
|
||||
setImports(allDefs, imports, [def.type]);
|
||||
|
||||
const args = method.params.map((param): string => {
|
||||
const args = def.params.map((param: any): string => {
|
||||
const similarTypes = getSimilarTypes(definitions, registry, param.type, imports);
|
||||
|
||||
setImports(allDefs, imports, [param.type, ...similarTypes]);
|
||||
@@ -46,7 +49,7 @@ export default function generateRpcTypes (dest = 'packages/api/src/augment/rpc.t
|
||||
return `${param.name}${param.isOptional ? '?' : ''}: ${similarTypes.join(' | ')}`;
|
||||
});
|
||||
|
||||
return createDocComments(6, [method.description]) + indent(6)(`${method.method}: AugmentedRpc<(${args.join(', ')}) => Observable<${method.type}>>;`);
|
||||
return createDocComments(6, [def.description]) + indent(6)(`${methodName}: AugmentedRpc<(${args.join(', ')}) => Observable<${def.type}>>;`);
|
||||
});
|
||||
|
||||
return allSections.concat(
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
import { TypeDef, TypeDefInfo } from '@polkadot/types/create/types';
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { getTypeDef } from '@polkadot/types/create';
|
||||
import * as defaultDefinitions from '@polkadot/types/interfaces/definitions';
|
||||
@@ -194,8 +193,8 @@ function generateTsDefFor (importDefinitions: { [importPath: string]: object },
|
||||
}))
|
||||
]);
|
||||
|
||||
fs.writeFileSync(path.join(outputDir, defName, 'types.ts'), header.concat(sortedDefs).concat(FOOTER), { flag: 'w' });
|
||||
fs.writeFileSync(path.join(outputDir, defName, 'index.ts'), HEADER('defs').concat('export * from \'./types\';').concat(FOOTER), { flag: 'w' });
|
||||
writeFile(path.join(outputDir, defName, 'types.ts'), () => header.concat(sortedDefs).concat(`\n\nexport type PHANTOM_${defName.toUpperCase()} = '${defName}';`).concat(FOOTER), true);
|
||||
writeFile(path.join(outputDir, defName, 'index.ts'), () => HEADER('defs').concat('export * from \'./types\';').concat(FOOTER), true);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
@@ -219,7 +218,7 @@ export function generateTsDef (importDefinitions: { [importPath: string]: object
|
||||
.concat(FOOTER);
|
||||
});
|
||||
|
||||
fs.writeFileSync(path.join(outputDir, 'index.ts'), HEADER('defs').concat('export * from \'./types\';').concat(FOOTER), { flag: 'w' });
|
||||
writeFile(path.join(outputDir, 'index.ts'), () => HEADER('defs').concat('export * from \'./types\';').concat(FOOTER), true);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
import { MetadataLatest } from '@polkadot/types/interfaces/metadata';
|
||||
|
||||
import fs from 'fs';
|
||||
import interfaces from '@polkadot/jsonrpc';
|
||||
import Decorated from '@polkadot/metadata/Decorated';
|
||||
import rpcdata from '@polkadot/metadata/Metadata/static';
|
||||
import Call from '@polkadot/types/generic/Call';
|
||||
import { unwrapStorageType } from '@polkadot/types/primitive/StorageKey';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
import { Vec } from '@polkadot/types/codec';
|
||||
import * as definitions from '@polkadot/types/interfaces/definitions';
|
||||
import { Text } from '@polkadot/types/primitive';
|
||||
import { stringCamelCase, stringLowerFirst } from '@polkadot/util';
|
||||
|
||||
@@ -100,22 +100,26 @@ function sortByName<T extends { name: any }> (a: T, b: T): number {
|
||||
|
||||
/** @internal */
|
||||
function addRpc (): string {
|
||||
const sections = Object
|
||||
.keys(definitions)
|
||||
.filter((key) => Object.keys(definitions[key as 'babe'].rpc || {}).length !== 0);
|
||||
|
||||
return renderPage({
|
||||
title: 'JSON-RPC',
|
||||
description: DESC_RPC,
|
||||
sections: Object.keys(interfaces)
|
||||
sections: sections
|
||||
.sort()
|
||||
.map((sectionName) => {
|
||||
const section = interfaces[sectionName];
|
||||
const section = definitions[sectionName as 'babe'];
|
||||
|
||||
return {
|
||||
name: sectionName,
|
||||
description: section.description,
|
||||
items: Object.keys(section.methods)
|
||||
// description: section.description,
|
||||
items: Object.keys(section.rpc)
|
||||
.sort()
|
||||
.map((methodName) => {
|
||||
const method = section.methods[methodName];
|
||||
const args = method.params.map(({ name, isOptional, type }): string => {
|
||||
const method = section.rpc[methodName];
|
||||
const args = method.params.map(({ name, isOptional, type }: any): string => {
|
||||
return name + (isOptional ? '?' : '') + ': `' + type + '`';
|
||||
}).join(', ');
|
||||
const type = '`' + method.type + '`';
|
||||
|
||||
@@ -14,9 +14,10 @@ import Struct from '@polkadot/types/codec/Struct';
|
||||
import UInt from '@polkadot/types/codec/UInt';
|
||||
import Vec from '@polkadot/types/codec/Vec';
|
||||
import Tuple from '@polkadot/types/codec/Tuple';
|
||||
import { AllConvictions } from '@polkadot/types/interfaces/democracy/definitions';
|
||||
import GenericAccountId from '@polkadot/types/generic/AccountId';
|
||||
import GenericAddress from '@polkadot/types/generic/Address';
|
||||
import Vote, { convictionNames as _voteConvictions } from '@polkadot/types/generic/Vote';
|
||||
import Vote from '@polkadot/types/generic/Vote';
|
||||
import Null from '@polkadot/types/primitive/Null';
|
||||
import * as primitiveClasses from '@polkadot/types/primitive';
|
||||
import { isChildClass, stringLowerFirst } from '@polkadot/util';
|
||||
@@ -29,7 +30,7 @@ function arrayToStrType (arr: string[]): string {
|
||||
return `(${arr.map((c): string => `'${c}'`).join(' | ')})`;
|
||||
}
|
||||
|
||||
const voteConvictions = arrayToStrType(_voteConvictions);
|
||||
const voteConvictions = arrayToStrType(AllConvictions);
|
||||
|
||||
// From `T`, generate `Compact<T>, Option<T>, Vec<T>`
|
||||
/** @internal */
|
||||
|
||||
@@ -4,14 +4,18 @@
|
||||
|
||||
import fs from 'fs';
|
||||
|
||||
export function writeFile (dest: string, generator: () => string): void {
|
||||
console.log(`${dest}\n\tGenerating`);
|
||||
export function writeFile (dest: string, generator: () => string, noLog?: boolean): void {
|
||||
!noLog && console.log(`${dest}\n\tGenerating`);
|
||||
|
||||
const generated = generator();
|
||||
let generated = generator();
|
||||
|
||||
console.log('\tWriting');
|
||||
while (generated.includes('\n\n\n')) {
|
||||
generated = generated.replace(/\n\n\n/g, '\n\n');
|
||||
}
|
||||
|
||||
!noLog && console.log('\tWriting');
|
||||
|
||||
fs.writeFileSync(dest, generated, { flag: 'w' });
|
||||
|
||||
console.log('');
|
||||
!noLog && console.log('');
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import { paramsNotation } from '@polkadot/types/codec/utils';
|
||||
|
||||
import { setImports, TypeImports } from './imports';
|
||||
|
||||
export const HEADER = (type: 'chain' | 'defs'): string => `// Auto-generated via \`yarn polkadot-types-from-${type}\`, do not edit\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\n`;
|
||||
export const HEADER = (type: 'chain' | 'defs'): string => `// Auto-generated via \`yarn polkadot-types-from-${type}\`, do not edit\n/* eslint-disable */\n\n`;
|
||||
export const FOOTER = '\n';
|
||||
|
||||
const TYPES_NON_PRIMITIVE = ['Metadata'];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
import { Compact, Option, Raw, Vec } from '@polkadot/types/codec';
|
||||
import { BitVec, Bytes, Data, Null, StorageKey, Text, Type, U256, Unconstructable, bool, i128, i16, i256, i32, i64, i8, u128, u16, u256, u32, u64, u8, usize } from '@polkadot/types/primitive';
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AnyJson, ArrayElementType, Registry } from '../types';
|
||||
import democracyDef from '../interfaces/democracy/definitions';
|
||||
import { AllConvictions } from '../interfaces/democracy/definitions';
|
||||
import { Conviction } from '../interfaces/democracy';
|
||||
|
||||
import { isBoolean, isNumber, isU8a, isUndefined } from '@polkadot/util';
|
||||
@@ -11,12 +11,10 @@ import { isBoolean, isNumber, isU8a, isUndefined } from '@polkadot/util';
|
||||
import U8aFixed from '../codec/U8aFixed';
|
||||
import Bool from '../primitive/Bool';
|
||||
|
||||
export const convictionNames = democracyDef.types.Conviction._enum;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
type InputTypes = boolean | number | Boolean | Uint8Array | {
|
||||
aye: boolean;
|
||||
conviction?: number | ArrayElementType<typeof convictionNames>;
|
||||
conviction?: number | ArrayElementType<typeof AllConvictions>;
|
||||
};
|
||||
|
||||
// For votes, the topmost bit indicated aye/nay, the lower bits indicate the conviction
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Definitions } from '../../types';
|
||||
|
||||
export default {
|
||||
rpc: {
|
||||
nextIndex: {
|
||||
alias: ['system_accountNextIndex'],
|
||||
description: 'Retrieves the next accountIndex as available on the node',
|
||||
params: [
|
||||
{
|
||||
name: 'accountId',
|
||||
type: 'AccountId'
|
||||
}
|
||||
],
|
||||
type: 'Index'
|
||||
}
|
||||
},
|
||||
types: {}
|
||||
} as Definitions;
|
||||
@@ -0,0 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable */
|
||||
|
||||
export * from './types';
|
||||
@@ -0,0 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable */
|
||||
|
||||
export type PHANTOM_ACCOUNT = 'account';
|
||||
@@ -2,7 +2,10 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Definitions } from '../../types';
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
types: {
|
||||
BlockAttestations: {
|
||||
receipt: 'CandidateReceipt',
|
||||
@@ -18,4 +21,4 @@ export default {
|
||||
},
|
||||
MoreAttestations: {}
|
||||
}
|
||||
};
|
||||
} as Definitions;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
export * from './types';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
import { Struct, Vec } from '@polkadot/types/codec';
|
||||
import { CandidateReceipt, ParaId } from '@polkadot/types/interfaces/parachains';
|
||||
@@ -24,3 +24,5 @@ export interface IncludedBlocks extends Struct {
|
||||
|
||||
/** @name MoreAttestations */
|
||||
export interface MoreAttestations extends Struct {}
|
||||
|
||||
export type PHANTOM_ATTESTATIONS = 'attestations';
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Definitions } from '../../types';
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
types: {
|
||||
RawAuraPreDigest: {
|
||||
slotNumber: 'u64'
|
||||
}
|
||||
}
|
||||
};
|
||||
} as Definitions;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
export * from './types';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
import { Struct } from '@polkadot/types/codec';
|
||||
import { u64 } from '@polkadot/types/primitive';
|
||||
@@ -8,3 +8,5 @@ import { u64 } from '@polkadot/types/primitive';
|
||||
export interface RawAuraPreDigest extends Struct {
|
||||
readonly slotNumber: u64;
|
||||
}
|
||||
|
||||
export type PHANTOM_AURA = 'aura';
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Definitions } from '../../types';
|
||||
|
||||
export default {
|
||||
rpc: {
|
||||
hasKey: {
|
||||
description: 'Returns true if the keystore has private keys for the given public key and key type.',
|
||||
params: [
|
||||
{
|
||||
name: 'publicKey',
|
||||
type: 'Bytes'
|
||||
},
|
||||
{
|
||||
name: 'keyType',
|
||||
type: 'Text'
|
||||
}
|
||||
],
|
||||
type: 'bool'
|
||||
},
|
||||
hasSessionKeys: {
|
||||
description: 'Returns true if the keystore has private keys for the given session public keys.',
|
||||
params: [
|
||||
{
|
||||
name: 'sessionKeys',
|
||||
type: 'Bytes'
|
||||
}
|
||||
],
|
||||
type: 'bool'
|
||||
},
|
||||
removeExtrinsic: {
|
||||
description: 'Remove given extrinsic from the pool and temporarily ban it to prevent reimporting',
|
||||
params: [
|
||||
{
|
||||
name: 'bytesOrHash',
|
||||
type: 'Vec<ExtrinsicOrHash>'
|
||||
}
|
||||
],
|
||||
type: 'Vec<Hash>'
|
||||
},
|
||||
insertKey: {
|
||||
description: 'Insert a key into the keystore.',
|
||||
params: [
|
||||
{
|
||||
name: 'keyType',
|
||||
type: 'Text'
|
||||
},
|
||||
{
|
||||
name: 'suri',
|
||||
type: 'Text'
|
||||
},
|
||||
{
|
||||
name: 'publicKey',
|
||||
type: 'Bytes'
|
||||
}
|
||||
],
|
||||
type: 'Bytes'
|
||||
},
|
||||
rotateKeys: {
|
||||
description: 'Generate new session keys and returns the corresponding public keys',
|
||||
params: [],
|
||||
type: 'Bytes'
|
||||
},
|
||||
pendingExtrinsics: {
|
||||
description: 'Returns all pending extrinsics, potentially grouped by sender',
|
||||
params: [],
|
||||
type: 'Vec<Extrinsic>'
|
||||
},
|
||||
submitExtrinsic: {
|
||||
isSigned: true,
|
||||
description: 'Submit a fully formatted extrinsic for block inclusion',
|
||||
params: [
|
||||
{
|
||||
name: 'extrinsic',
|
||||
type: 'Extrinsic'
|
||||
}
|
||||
],
|
||||
type: 'Hash'
|
||||
},
|
||||
submitAndWatchExtrinsic: {
|
||||
description: 'Submit and subscribe to watch an extrinsic until unsubscribed',
|
||||
isSigned: true,
|
||||
params: [
|
||||
{
|
||||
name: 'extrinsic',
|
||||
type: 'Extrinsic'
|
||||
}
|
||||
],
|
||||
pubsub: [
|
||||
'extrinsicUpdate',
|
||||
'submitAndWatchExtrinsic',
|
||||
'unwatchExtrinsic'
|
||||
],
|
||||
type: 'ExtrinsicStatus'
|
||||
}
|
||||
},
|
||||
types: {}
|
||||
} as Definitions;
|
||||
@@ -0,0 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable */
|
||||
|
||||
export * from './types';
|
||||
@@ -0,0 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable */
|
||||
|
||||
export type PHANTOM_AUTHOR = 'author';
|
||||
@@ -2,7 +2,10 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Definitions } from '../../types';
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
types: {
|
||||
UncleEntryItem: {
|
||||
_enum: {
|
||||
@@ -11,4 +14,4 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
} as Definitions;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
export * from './types';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { Enum, Option } from '@polkadot/types/codec';
|
||||
@@ -12,3 +12,5 @@ export interface UncleEntryItem extends Enum {
|
||||
readonly isUncle: boolean;
|
||||
readonly asUncle: ITuple<[Hash, Option<AccountId>]>;
|
||||
}
|
||||
|
||||
export type PHANTOM_AUTHORSHIP = 'authorship';
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Definitions } from '../../types';
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
types: {
|
||||
BabeAuthorityWeight: 'u64',
|
||||
BabeBlockWeight: 'u32',
|
||||
@@ -59,4 +62,4 @@ export default {
|
||||
VrfData: '[u8; 32]',
|
||||
VrfProof: '[u8; 64]'
|
||||
}
|
||||
};
|
||||
} as Definitions;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
export * from './types';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
import { Enum, Option, Struct, U8aFixed } from '@polkadot/types/codec';
|
||||
import { u32, u64 } from '@polkadot/types/primitive';
|
||||
@@ -81,3 +81,5 @@ export interface VrfData extends U8aFixed {}
|
||||
|
||||
/** @name VrfProof */
|
||||
export interface VrfProof extends U8aFixed {}
|
||||
|
||||
export type PHANTOM_BABE = 'babe';
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Definitions } from '../../types';
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
types: {
|
||||
AccountData: {
|
||||
free: 'Balance',
|
||||
@@ -42,4 +45,4 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
} as Definitions;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
export * from './types';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
import { Enum, Set, Struct } from '@polkadot/types/codec';
|
||||
import { Balance, BlockNumber, LockIdentifier } from '@polkadot/types/interfaces/runtime';
|
||||
@@ -55,3 +55,5 @@ export interface WithdrawReasons extends Set {
|
||||
readonly isFee: boolean;
|
||||
readonly isTip: boolean;
|
||||
}
|
||||
|
||||
export type PHANTOM_BALANCES = 'balances';
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Definitions } from '../../types';
|
||||
|
||||
export default {
|
||||
rpc: {
|
||||
getHeader: {
|
||||
alias: ['chain_getHead'],
|
||||
description: 'Retrieves the header for a specific block',
|
||||
params: [
|
||||
{
|
||||
name: 'hash',
|
||||
type: 'BlockHash',
|
||||
isOptional: true
|
||||
}
|
||||
],
|
||||
type: 'Header'
|
||||
},
|
||||
getBlock: {
|
||||
description: 'Get header and body of a relay chain block',
|
||||
params: [
|
||||
{
|
||||
name: 'hash',
|
||||
type: 'BlockHash',
|
||||
isOptional: true
|
||||
}
|
||||
],
|
||||
type: 'SignedBlock'
|
||||
},
|
||||
getBlockHash: {
|
||||
description: 'Get the block hash for a specific block',
|
||||
params: [
|
||||
{
|
||||
name: 'blockNumber',
|
||||
type: 'BlockNumber',
|
||||
isOptional: true
|
||||
}
|
||||
],
|
||||
type: 'BlockHash'
|
||||
},
|
||||
getFinalizedHead: {
|
||||
alias: ['chain_getFinalisedHead'],
|
||||
description: 'Get hash of the last finalized block in the canon chain',
|
||||
params: [],
|
||||
type: 'BlockHash'
|
||||
},
|
||||
subscribeNewHeads: {
|
||||
alias: ['chain_unsubscribeNewHeads', 'subscribe_newHead', 'unsubscribe_newHead'],
|
||||
description: 'Retrieves the best header via subscription',
|
||||
params: [],
|
||||
// NOTE These still has the aliassed version, compatible with 1.x
|
||||
pubsub: [
|
||||
'newHead',
|
||||
'subscribeNewHead',
|
||||
'unsubscribeNewHead'
|
||||
],
|
||||
type: 'Header'
|
||||
},
|
||||
subscribeFinalizedHeads: {
|
||||
alias: ['chain_subscribeFinalisedHeads', 'chain_unsubscribeFinalisedHeads'],
|
||||
description: 'Retrieves the best finalized header via subscription',
|
||||
params: [],
|
||||
pubsub: [
|
||||
'finalizedHead',
|
||||
'subscribeFinalizedHeads',
|
||||
'unsubscribeFinalizedHeads'
|
||||
],
|
||||
type: 'Header'
|
||||
},
|
||||
subscribeAllHeads: {
|
||||
description: 'Retrieves the newest header via subscription',
|
||||
params: [],
|
||||
pubsub: [
|
||||
'allHead',
|
||||
'subscribeAllHeads',
|
||||
'unsubscribeAllHeads'
|
||||
],
|
||||
type: 'Header'
|
||||
}
|
||||
},
|
||||
types: {}
|
||||
} as Definitions;
|
||||
@@ -0,0 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable */
|
||||
|
||||
export * from './types';
|
||||
@@ -0,0 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable */
|
||||
|
||||
export type PHANTOM_CHAIN = 'chain';
|
||||
@@ -2,8 +2,11 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Definitions } from '../../types';
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
types: {
|
||||
EthereumAddress: 'H160'
|
||||
}
|
||||
};
|
||||
} as Definitions;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
export * from './types';
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
import { H160 } from '@polkadot/types/interfaces/runtime';
|
||||
|
||||
/** @name EthereumAddress */
|
||||
export interface EthereumAddress extends H160 {}
|
||||
|
||||
export type PHANTOM_CLAIMS = 'claims';
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Definitions } from '../../types';
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
types: {
|
||||
MemberCount: 'u32',
|
||||
ProposalIndex: 'u32',
|
||||
@@ -20,4 +23,4 @@ export default {
|
||||
end: 'BlockNumber'
|
||||
}
|
||||
}
|
||||
};
|
||||
} as Definitions;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
export * from './types';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
import { Struct, Vec } from '@polkadot/types/codec';
|
||||
import { u32 } from '@polkadot/types/primitive';
|
||||
@@ -27,3 +27,5 @@ export interface VotesTo230 extends Struct {
|
||||
readonly ayes: Vec<AccountId>;
|
||||
readonly nays: Vec<AccountId>;
|
||||
}
|
||||
|
||||
export type PHANTOM_COLLECTIVE = 'collective';
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Definitions } from '../../types';
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
types: {
|
||||
AuthorityId: 'AccountId'
|
||||
}
|
||||
};
|
||||
} as Definitions;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
export * from './types';
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
import { AccountId } from '@polkadot/types/interfaces/runtime';
|
||||
|
||||
/** @name AuthorityId */
|
||||
export interface AuthorityId extends AccountId {}
|
||||
|
||||
export type PHANTOM_CONSENSUS = 'consensus';
|
||||
|
||||
@@ -2,7 +2,45 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Definitions } from '../../types';
|
||||
|
||||
export default {
|
||||
rpc: {
|
||||
call: {
|
||||
description: 'Executes a call to a contract',
|
||||
params: [
|
||||
{
|
||||
name: 'callRequest',
|
||||
type: 'ContractCallRequest'
|
||||
},
|
||||
{
|
||||
name: 'at',
|
||||
type: 'BlockHash',
|
||||
isOptional: true
|
||||
}
|
||||
],
|
||||
type: 'ContractExecResult'
|
||||
},
|
||||
getStorage: {
|
||||
description: 'Returns the value under a specified storage key in a contract',
|
||||
params: [
|
||||
{
|
||||
name: 'address',
|
||||
type: 'AccountId'
|
||||
},
|
||||
{
|
||||
name: 'key',
|
||||
type: 'H256'
|
||||
},
|
||||
{
|
||||
name: 'at',
|
||||
type: 'BlockHash',
|
||||
isOptional: true
|
||||
}
|
||||
],
|
||||
type: 'Option<Bytes>'
|
||||
}
|
||||
},
|
||||
types: {
|
||||
AliveContractInfo: {
|
||||
trieId: 'TrieId',
|
||||
@@ -85,4 +123,4 @@ export default {
|
||||
TombstoneContractInfo: 'Hash',
|
||||
TrieId: 'Bytes'
|
||||
}
|
||||
};
|
||||
} as Definitions;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
export * from './types';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
import { Compact, Enum, Option, Raw, Struct, U8aFixed } from '@polkadot/types/codec';
|
||||
import { Bytes, Null, bool, u32, u64, u8 } from '@polkadot/types/primitive';
|
||||
@@ -113,3 +113,5 @@ export interface TombstoneContractInfo extends Hash {}
|
||||
|
||||
/** @name TrieId */
|
||||
export interface TrieId extends Bytes {}
|
||||
|
||||
export type PHANTOM_CONTRACTS = 'contracts';
|
||||
|
||||
@@ -41,3 +41,10 @@ export { default as parachains } from './parachains/definitions';
|
||||
// pull in metadata & rpc last, assuming that is uses info from above
|
||||
export { default as metadata } from './metadata/definitions';
|
||||
export { default as rpc } from './rpc/definitions';
|
||||
|
||||
// rpc-only definitions
|
||||
export { default as account } from './account/definitions';
|
||||
export { default as author } from './author/definitions';
|
||||
export { default as chain } from './chain/definitions';
|
||||
export { default as payment } from './payment/definitions';
|
||||
export { default as state } from './state/definitions';
|
||||
|
||||
@@ -2,25 +2,32 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Definitions } from '../../types';
|
||||
|
||||
const AllConvictions = [
|
||||
// 0.1x votes, unlocked.
|
||||
'None',
|
||||
// 1x votes, locked for an enactment period following a successful vote.
|
||||
'Locked1x',
|
||||
// 2x votes, locked for 2x enactment periods following a successful vote.
|
||||
'Locked2x',
|
||||
// 3x votes, locked for 4x...
|
||||
'Locked3x',
|
||||
// 4x votes, locked for 8x...
|
||||
'Locked4x',
|
||||
// 5x votes, locked for 16x...
|
||||
'Locked5x',
|
||||
/// 6x votes, locked for 32x...
|
||||
'Locked6x'
|
||||
];
|
||||
|
||||
export { AllConvictions };
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
types: {
|
||||
Conviction: {
|
||||
_enum: [
|
||||
// 0.1x votes, unlocked.
|
||||
'None',
|
||||
// 1x votes, locked for an enactment period following a successful vote.
|
||||
'Locked1x',
|
||||
// 2x votes, locked for 2x enactment periods following a successful vote.
|
||||
'Locked2x',
|
||||
// 3x votes, locked for 4x...
|
||||
'Locked3x',
|
||||
// 4x votes, locked for 8x...
|
||||
'Locked4x',
|
||||
// 5x votes, locked for 16x...
|
||||
'Locked5x',
|
||||
/// 6x votes, locked for 32x...
|
||||
'Locked6x'
|
||||
]
|
||||
_enum: AllConvictions
|
||||
},
|
||||
PropIndex: 'u32',
|
||||
Proposal: 'Call',
|
||||
@@ -36,4 +43,4 @@ export default {
|
||||
delay: 'BlockNumber'
|
||||
}
|
||||
}
|
||||
};
|
||||
} as Definitions;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
export * from './types';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
import { Enum, Struct } from '@polkadot/types/codec';
|
||||
import { u32 } from '@polkadot/types/primitive';
|
||||
@@ -39,3 +39,5 @@ export interface ReferendumInfo extends Struct {
|
||||
readonly threshold: VoteThreshold;
|
||||
readonly delay: BlockNumber;
|
||||
}
|
||||
|
||||
export type PHANTOM_DEMOCRACY = 'democracy';
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Definitions } from '../../types';
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
types: {
|
||||
ApprovalFlag: 'u32',
|
||||
SetIndex: 'u32',
|
||||
@@ -22,4 +25,4 @@ export default {
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
} as Definitions;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
export * from './types';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
import { Enum, Struct } from '@polkadot/types/codec';
|
||||
import { GenericVote } from '@polkadot/types/generic';
|
||||
@@ -32,3 +32,5 @@ export interface VoteThreshold extends Enum {
|
||||
readonly isSupermajorityrejection: boolean;
|
||||
readonly isSimplemajority: boolean;
|
||||
}
|
||||
|
||||
export type PHANTOM_ELECTIONS = 'elections';
|
||||
|
||||
@@ -2,7 +2,45 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Definitions } from '../../types';
|
||||
|
||||
export default {
|
||||
rpc: {
|
||||
createBlock: {
|
||||
description: 'Instructs the manual-seal authorship task to create a new block',
|
||||
params: [
|
||||
{
|
||||
name: 'createEmpty',
|
||||
type: 'bool'
|
||||
},
|
||||
{
|
||||
name: 'finalize',
|
||||
type: 'bool'
|
||||
},
|
||||
{
|
||||
name: 'parentHash',
|
||||
type: 'BlockHash',
|
||||
isOptional: true
|
||||
}
|
||||
],
|
||||
type: 'CreatedBlock'
|
||||
},
|
||||
finalizeBlock: {
|
||||
description: 'Instructs the manual-seal authorship task to finalize a block',
|
||||
params: [
|
||||
{
|
||||
name: 'hash',
|
||||
type: 'BlockHash'
|
||||
},
|
||||
{
|
||||
name: 'justification',
|
||||
type: 'Justification',
|
||||
isOptional: true
|
||||
}
|
||||
],
|
||||
type: 'bool'
|
||||
}
|
||||
},
|
||||
types: {
|
||||
CreatedBlock: {
|
||||
hash: 'BlockHash',
|
||||
@@ -17,4 +55,4 @@ export default {
|
||||
isNewBest: 'bool'
|
||||
}
|
||||
}
|
||||
};
|
||||
} as Definitions;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
export * from './types';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
import { Struct } from '@polkadot/types/codec';
|
||||
import { bool } from '@polkadot/types/primitive';
|
||||
@@ -20,3 +20,5 @@ export interface ImportedAux extends Struct {
|
||||
readonly needsFinalityProof: bool;
|
||||
readonly isNewBest: bool;
|
||||
}
|
||||
|
||||
export type PHANTOM_ENGINE = 'engine';
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Definitions } from '../../types';
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
types: {
|
||||
Account: {
|
||||
nonce: 'U256',
|
||||
@@ -14,4 +17,4 @@ export default {
|
||||
data: 'Bytes'
|
||||
}
|
||||
}
|
||||
};
|
||||
} as Definitions;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
export * from './types';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
import { Struct, Vec } from '@polkadot/types/codec';
|
||||
import { Bytes, U256 } from '@polkadot/types/primitive';
|
||||
@@ -17,3 +17,5 @@ export interface Log extends Struct {
|
||||
readonly topics: Vec<H256>;
|
||||
readonly data: Bytes;
|
||||
}
|
||||
|
||||
export type PHANTOM_EVM = 'evm';
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Definitions } from '../../types';
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
types: {
|
||||
Extrinsic: 'GenericExtrinsic',
|
||||
ExtrinsicEra: 'GenericExtrinsicEra',
|
||||
@@ -40,4 +43,4 @@ export default {
|
||||
Ed25519Signature: 'H512',
|
||||
Sr25519Signature: 'H512'
|
||||
}
|
||||
};
|
||||
} as Definitions;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
export * from './types';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
import { Enum, U8aFixed } from '@polkadot/types/codec';
|
||||
import { GenericExtrinsic, GenericExtrinsicEra, GenericExtrinsicPayload, GenericExtrinsicPayloadUnknown, GenericExtrinsicPayloadV1, GenericExtrinsicPayloadV2, GenericExtrinsicPayloadV3, GenericExtrinsicPayloadV4, GenericExtrinsicSignatureV1, GenericExtrinsicSignatureV2, GenericExtrinsicSignatureV3, GenericExtrinsicSignatureV4, GenericExtrinsicUnknown, GenericExtrinsicV1, GenericExtrinsicV2, GenericExtrinsicV3, GenericExtrinsicV4, GenericImmortalEra, GenericMortalEra, GenericSignerPayload } from '@polkadot/types/extrinsic';
|
||||
@@ -86,3 +86,5 @@ export interface SignerPayload extends GenericSignerPayload {}
|
||||
|
||||
/** @name Sr25519Signature */
|
||||
export interface Sr25519Signature extends H512 {}
|
||||
|
||||
export type PHANTOM_EXTRINSICS = 'extrinsics';
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Definitions } from '../../types';
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
types: {
|
||||
AssetOptions: {
|
||||
initalIssuance: 'Compact<Balance>',
|
||||
@@ -26,4 +29,4 @@ export default {
|
||||
},
|
||||
PermissionLatest: 'PermissionsV1'
|
||||
}
|
||||
};
|
||||
} as Definitions;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
export * from './types';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
import { Compact, Enum, Struct } from '@polkadot/types/codec';
|
||||
import { AccountId, Balance } from '@polkadot/types/interfaces/runtime';
|
||||
@@ -32,3 +32,5 @@ export interface PermissionVersions extends Enum {
|
||||
readonly isV1: boolean;
|
||||
readonly asV1: PermissionsV1;
|
||||
}
|
||||
|
||||
export type PHANTOM_GENERICASSET = 'genericAsset';
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Definitions } from '../../types';
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
types: {
|
||||
AuthorityIndex: 'u64',
|
||||
AuthorityList: 'Vec<NextAuthority>',
|
||||
@@ -39,4 +42,4 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
} as Definitions;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
/* eslint-disable */
|
||||
|
||||
export * from './types';
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user