Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb3e7a0740 | ||
|
|
2071de517d | ||
|
|
205ae40f20 | ||
|
|
aa37e372dd | ||
|
|
8cdac77a8e | ||
|
|
7a7d6e9b8a | ||
|
|
7a1bdb18a8 | ||
|
|
39f22ca403 | ||
|
|
b3c6a5acc5 | ||
|
|
b3a6b3dcb5 | ||
|
|
0c0e4c4d7c | ||
|
|
9d67d711d4 | ||
|
|
f45d03fa17 | ||
|
|
af11444b72 | ||
|
|
f412a5ac86 | ||
|
|
c9dcd51ba6 | ||
|
|
5dca826429 | ||
|
|
8dc53e6339 | ||
|
|
5867f8ab0c | ||
|
|
6d3db2fb3f | ||
|
|
3a1634d67f | ||
|
|
53d18d874d | ||
|
|
044efbc6de | ||
|
|
27e3fbfd0f | ||
|
|
b7af4781ea | ||
|
|
c51e351117 | ||
|
|
e6afed9bb1 | ||
|
|
4b07d5511e | ||
|
|
a613308bdb | ||
|
|
a863e5eb95 |
+12
-1
@@ -1,6 +1,17 @@
|
||||
# 1.8.1 Mar 22, 2020
|
||||
|
||||
- **Breaking change** The format for any custom RPCs have been changed alongside API-internal changes to allow for better RPC management. If you are currently using custom RPCs (or planning to do so), look at the [updated documentation](https://polkadot.js.org/api/start/rpc.custom.html)
|
||||
- **Breaking change** Alongside API RPC changes, the `@polkadot/jsonrpc` package has been removed. Since it was never documented and only used internally, this should not have adverse impacts. All RPC definitions itself has now been moved to the relevant modules inside `@polkadot/types/interfaces`
|
||||
- **Important** Substrate has an updated democracy module. If using an older chain add the `ReferendumInfo: 'ReferendumInfoTo239'` type when using referendums
|
||||
- The `isRetracted` Extrinsic status is now a warning, not a fatal error, correctly aligning with Polkadot/Substrate
|
||||
- The Substrate extrinsic phase definitions has been expanded with `Initialization` to align with the latest versions
|
||||
- Add support for all known substrate RPC methods
|
||||
- Extend account derives to include status flags, e.g. `isCouncil`, `isSudo`, ...
|
||||
- Adjusted referendum derives to cater for bot new/old democracy. Derived `referendumInfo` now includes `status` field, not `info`
|
||||
|
||||
# 1.7.1 Mar 17, 2020
|
||||
|
||||
- **Important** Current versions of Polkadot/Substrate have dropped support for linked maps on storage entries. If you are using these queries to retriev all entries, for instance `staking.{nominators,validators}()` and using an upgraded chain, you need to swap to retrieving entries via `.entries()` or `.keys()` for the keys.
|
||||
- **Important** Current versions of Polkadot/Substrate have dropped support for linked maps on storage entries. If you are using these queries to retrieve all entries, for instance `staking.{nominators,validators}()` and using an upgraded chain, you need to swap to retrieving entries via `.entries()` or `.keys()` for the keys.
|
||||
- Pull in support and types for latest Polkadot/Substrate
|
||||
- Add support for the new Substrate `state_getKeysPaged` RPC, including use in storage keys
|
||||
- Move `derive.staking.controllers` to `derive.staking.stashes`, reflecting actual content
|
||||
|
||||
@@ -18,6 +18,5 @@ copy_folder "api-derive"
|
||||
copy_folder "metadata"
|
||||
copy_folder "rpc-core"
|
||||
copy_folder "rpc-provider"
|
||||
copy_folder "jsonrpc"
|
||||
copy_folder "types"
|
||||
copy_folder "typegen"
|
||||
|
||||
@@ -43,6 +43,7 @@ module.exports = {
|
||||
['start/api.tx.wrap.md', 'Complex transactions'],
|
||||
['start/types.basics.md', 'Type basics'],
|
||||
['start/types.extend.md', 'Extending types'],
|
||||
['start/rpc.custom.md', 'Custom RPC'],
|
||||
['start/types.create.md', 'Creating types'],
|
||||
['start/typescript.md', 'TypeScript interfaces'],
|
||||
['start/typescript.user.md', 'TypeScript user generated'],
|
||||
|
||||
@@ -24,7 +24,7 @@ async function main () {
|
||||
if (validators && validators.length > 0) {
|
||||
// Retrieve the balances for all validators
|
||||
const validatorBalances = await Promise.all(
|
||||
validators.map(authorityId =>
|
||||
validators.map((authorityId) =>
|
||||
api.query.system.account(authorityId)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -22,7 +22,7 @@ function main () {
|
||||
// In the next step, we're checking if the node has active validators.
|
||||
// If it does, we're making another call to the api to get the balances for all validators
|
||||
const balances = (validators && validators.length > 0)
|
||||
? combineLatest(validators.map(authorityId => api.query.system.account(authorityId).pipe(first())))
|
||||
? combineLatest(validators.map((authorityId) => api.query.system.account(authorityId).pipe(first())))
|
||||
: of(null);
|
||||
|
||||
// We're combining the results together with the emitted value 'validators',
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
... somewhere also need a signer injection section, something along the lines of the singlesigner or this https://github.com/polkadot-js/tools/blob/master/packages/signer-cli/src/cmdSubmit.ts#L12
|
||||
|
||||
... DoubleMap & LinkedMap examples
|
||||
|
||||
... api.derive
|
||||
@@ -0,0 +1,51 @@
|
||||
# Custom RPC
|
||||
|
||||
In previous sections we looked at the injection of types, as in use and defined in modules from the node. Another area that can be customized is RC definitions, and like with the types, the API provides the capability to add user-defined RPCs (in addition to the Polkadot/Substrate base) to allow use of these RPCs via the API.
|
||||
|
||||
## Custom definitions
|
||||
|
||||
RPCs are exposed as a method on a specific module, this means that once available you can call any rpc via the `api.rpc.<module>.<method>(...params[])` endpoints. To extend with user-defined RPCs, the injection can happen at the time of API creation with the addition of the `rpc` key (in addition to any other params, such as `types` or `provider`) -
|
||||
|
||||
```js
|
||||
...
|
||||
const api = await ApiPromise.create({
|
||||
rpc: {
|
||||
firstModule: {
|
||||
testMethod: {
|
||||
description: 'Just a test method',
|
||||
params: [
|
||||
{
|
||||
name: 'index',
|
||||
type: 'u64'
|
||||
}
|
||||
],
|
||||
type: 'Balance'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
In the above example we have defined a new method, which is now available on the RPCs as `api.rpc.firstModule.testMethod(u64) => Promise<Balance>`. Do be aware that while defined, the method will only appear if it is in the list as returned by `api.rpc.rpc.methods()`, which is the list of known RPCs the node exposes. When making changes to the node, always ensure that it does expose the RPC method correctly, otherwise it will not be decorated.
|
||||
|
||||
## Definition breakdown
|
||||
|
||||
While the above example should be self-explanatory, it is important to understand teh structure. The `rpc: { ... }` definitions are keyed first and foremost by the name of the module exposing the RPC. This means that when we have 2 modules `firstModule` & `testModule`, the first-level structure would follow the following pattern,
|
||||
|
||||
```js
|
||||
...
|
||||
const api = await ApiPromise.create({
|
||||
rpc: {
|
||||
firstModule: { ... },
|
||||
testModule: { ... }
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Inside the specific module definitions, the key is the actual expose RPC method. As we have seen in the first example, we expose a `testMethod` on `firstModule`. For the method definitions, apart from the description, we have definitions for the params and return a single result `type`.
|
||||
|
||||
Params itself, as an array, contains fields for `name`, `type` and an optional flag `isOptional` that indicates that the field is not required when making the call. (And example of this use would be in cases such as `state.getStorage(key, blockHash?)` where the last param is optional)
|
||||
|
||||
## Type creation
|
||||
|
||||
While the API always converts all the inputs into the underlying type required by the operation, be it for RPC, query or transaction, in some cases you may want to [create an instance of a type](types.create.md) yourself.
|
||||
@@ -201,6 +201,6 @@ const api = await ApiPromise.create({
|
||||
|
||||
Always look at customization and understand the impacts, replicating these changes between the node and the API. For the above the `Address` type is used in the construction of the `UncheckedExtrinsic` type, while the lookup type is applicable on transactions such as `balances.transfer(to: LookupSource, value: Balance)`
|
||||
|
||||
## Type creation
|
||||
## Custom RPC
|
||||
|
||||
While the API always converts all the inputs into the underlying type required by the operation, in some cases you may want to [create an instance of a type](types.create.md) yourself.
|
||||
In addition to customizing modules and types on your node, you can also add custom RPC definitions. Like the type definitions in ths section, [these can be defined and passed to the API](rpc.custom.md) for decoration.
|
||||
|
||||
@@ -7,7 +7,6 @@ module.exports = Object.assign({}, config, {
|
||||
'@polkadot/api-contract(.*)$': '<rootDir>/packages/api-contract/src/$1',
|
||||
'@polkadot/api-derive(.*)$': '<rootDir>/packages/api-derive/src/$1',
|
||||
'@polkadot/api(.*)$': '<rootDir>/packages/api/src/$1',
|
||||
'@polkadot/jsonrpc(.*)$': '<rootDir>/packages/jsonrpc/src/$1',
|
||||
'@polkadot/metadata(.*)$': '<rootDir>/packages/metadata/src/$1',
|
||||
'@polkadot/rpc-(core|provider)(.*)$': '<rootDir>/packages/rpc-$1/src/$2',
|
||||
'@polkadot/types(.*)$': '<rootDir>/packages/types/src/$1'
|
||||
@@ -16,21 +15,10 @@ module.exports = Object.assign({}, config, {
|
||||
'<rootDir>/packages/api/build',
|
||||
'<rootDir>/packages/api-derive/build',
|
||||
'<rootDir>/packages/api-contract/build',
|
||||
'<rootDir>/packages/jsonrpc/build',
|
||||
'<rootDir>/packages/metadata/build',
|
||||
'<rootDir>/packages/rpc-core/build',
|
||||
'<rootDir>/packages/rpc-provider/build',
|
||||
'<rootDir>/packages/types/build'
|
||||
],
|
||||
globals: {
|
||||
ws_local: 'ws://127.0.0.1:9944/',
|
||||
ws_local_substrate_master: 'ws://127.0.0.1:9945/',
|
||||
ws_local_substrate_1: 'ws://127.0.0.1:9946/',
|
||||
ws_local_substrate_2: 'ws://127.0.0.1:9947/',
|
||||
ws_local_polkadot_master: 'ws://127.0.0.1:9948/',
|
||||
ws_local_polkadot_alex: 'ws://127.0.0.1:9949/',
|
||||
ws_substrate_1: 'wss://substrate-rpc.parity.io/',
|
||||
ws_polkadot_alex: 'wss://poc3-rpc.polkadot.io/'
|
||||
},
|
||||
resolver: './jest.resolver.js'
|
||||
});
|
||||
|
||||
+1
-1
@@ -9,5 +9,5 @@
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "1.7.1"
|
||||
"version": "1.8.1"
|
||||
}
|
||||
|
||||
+5
-5
@@ -24,11 +24,11 @@
|
||||
"test:watch": "polkadot-dev-run-test --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.8.7",
|
||||
"@babel/register": "^7.8.6",
|
||||
"@babel/runtime": "^7.8.7",
|
||||
"@polkadot/dev": "^0.51.5",
|
||||
"@polkadot/ts": "^0.3.13",
|
||||
"@babel/core": "^7.9.0",
|
||||
"@babel/register": "^7.9.0",
|
||||
"@babel/runtime": "^7.9.2",
|
||||
"@polkadot/dev": "^0.51.7",
|
||||
"@polkadot/ts": "^0.3.14",
|
||||
"@polkadot/typegen": "workspace:packages/typegen",
|
||||
"@types/jest": "^25.1.4",
|
||||
"copyfiles": "^2.2.0"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-contract",
|
||||
"version": "1.7.1",
|
||||
"version": "1.8.1",
|
||||
"description": "Interfaces for interacting with contracts and contract ABIs",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -26,10 +26,10 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.7",
|
||||
"@polkadot/api": "1.7.1",
|
||||
"@polkadot/rpc-core": "1.7.1",
|
||||
"@polkadot/types": "1.7.1",
|
||||
"@babel/runtime": "^7.9.2",
|
||||
"@polkadot/api": "1.8.1",
|
||||
"@polkadot/rpc-core": "1.8.1",
|
||||
"@polkadot/types": "1.8.1",
|
||||
"@polkadot/util": "^2.6.2",
|
||||
"bn.js": "^5.1.1",
|
||||
"rxjs": "^6.5.4"
|
||||
|
||||
@@ -158,10 +158,10 @@ export default class ContractRegistry extends MetaRegistry {
|
||||
public convertContract ({ constructors, messages, name, events, ...contract }: ContractABIContractPre): ContractABIContract {
|
||||
return {
|
||||
constructors: this.convertConstructors(constructors),
|
||||
messages: messages.map(message => this.convertMessage(message)),
|
||||
messages: messages.map((message) => this.convertMessage(message)),
|
||||
name: this.stringAt(name),
|
||||
...(events
|
||||
? { events: events.map(event => this.convertEvent(event)) }
|
||||
? { events: events.map((event) => this.convertEvent(event)) }
|
||||
: {}),
|
||||
...contract
|
||||
};
|
||||
|
||||
@@ -275,7 +275,7 @@ export default class MetaRegistry extends MetadataRegistryLookup {
|
||||
case 'Result':
|
||||
return this.typeDefForResult(id, typeIndex);
|
||||
default: {
|
||||
const sub = def['enum.variants'].map(variant => this.typeDefForEnumVariant(variant));
|
||||
const sub = def['enum.variants'].map((variant) => this.typeDefForEnumVariant(variant));
|
||||
|
||||
return {
|
||||
info: TypeDefInfo.Enum,
|
||||
|
||||
@@ -7,7 +7,6 @@ import { AccountId, Address, ContractExecResult } from '@polkadot/types/interfac
|
||||
import { Codec, CodecArg } from '@polkadot/types/types';
|
||||
import { MetaRegistryJson, StringIndex, TypeIndex, TypeDef } from '@polkadot/types/create/types';
|
||||
|
||||
// import { Observable } from 'rxjs';
|
||||
import { ApiPromise, ApiRx } from '@polkadot/api';
|
||||
|
||||
export type ApiObject<ApiType extends ApiTypes> = ApiType extends 'rxjs'
|
||||
|
||||
@@ -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 { Codec, Registry, TypeDefInfo, TypeDef } from '@polkadot/types/types';
|
||||
import { Codec, Registry, TypeDef, TypeDefInfo } from '@polkadot/types/types';
|
||||
|
||||
import { Option, Raw, createClass, createTypeUnsafe } from '@polkadot/types';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-derive",
|
||||
"version": "1.7.1",
|
||||
"version": "1.8.1",
|
||||
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,11 +27,11 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.7",
|
||||
"@polkadot/api": "1.7.1",
|
||||
"@polkadot/rpc-core": "1.7.1",
|
||||
"@polkadot/rpc-provider": "1.7.1",
|
||||
"@polkadot/types": "1.7.1",
|
||||
"@babel/runtime": "^7.9.2",
|
||||
"@polkadot/api": "1.8.1",
|
||||
"@polkadot/rpc-core": "1.8.1",
|
||||
"@polkadot/rpc-provider": "1.8.1",
|
||||
"@polkadot/types": "1.8.1",
|
||||
"@polkadot/util": "^2.6.2",
|
||||
"@polkadot/util-crypto": "^2.6.2",
|
||||
"bn.js": "^5.1.1",
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { AccountId, AccountIndex, Address, Balance, Registration } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { DeriveAccountInfo, DeriveAccountRegistration } from '../types';
|
||||
import { DeriveAccountFlags, DeriveAccountInfo, DeriveAccountRegistration } from '../types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { Bytes, Data, Option, u32 } from '@polkadot/types';
|
||||
import { Bytes, Data, Option, u32, Vec } from '@polkadot/types';
|
||||
import { u8aToString } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
@@ -22,6 +22,12 @@ function dataAsString (data: Data): string | undefined {
|
||||
: undefined;
|
||||
}
|
||||
|
||||
function includedWrapper (accountId?: AccountId): (_: AccountId) => boolean {
|
||||
return function (id: AccountId): boolean {
|
||||
return id.eq(accountId);
|
||||
};
|
||||
}
|
||||
|
||||
function retrieveNick (api: ApiInterfaceRx, accountId?: AccountId): Observable<string | undefined> {
|
||||
return ((
|
||||
accountId && api.query.nicks?.nameOf
|
||||
@@ -109,6 +115,39 @@ function retrieveIdentity (api: ApiInterfaceRx, accountId?: AccountId): Observab
|
||||
);
|
||||
}
|
||||
|
||||
function retrieveFlags (api: ApiInterfaceRx, accountId?: AccountId): Observable<DeriveAccountFlags> {
|
||||
const councilSection = api.query.electionsPhragmen ? 'electionsPhragmen' : 'elections';
|
||||
|
||||
return combineLatest([
|
||||
api.query[councilSection]?.members
|
||||
? api.query[councilSection].members<Vec<ITuple<[AccountId, Balance]>>>()
|
||||
: of(undefined),
|
||||
api.query.council?.members
|
||||
? api.query.council.members()
|
||||
: of([]),
|
||||
api.query.technicalCommittee?.members
|
||||
? api.query.technicalCommittee.members()
|
||||
: of([]),
|
||||
api.query.society?.members
|
||||
? api.query.society.members()
|
||||
: of([]),
|
||||
api.query.sudo?.key
|
||||
? api.query.sudo.key()
|
||||
: of(undefined)
|
||||
]).pipe(
|
||||
map(([electionsMembers, councilMembers, technicalCommitteeMembers, societyMembers, sudoKey]): DeriveAccountFlags => {
|
||||
const checkIncluded = includedWrapper(accountId);
|
||||
|
||||
return {
|
||||
isCouncil: (electionsMembers?.map(([id]) => id) || councilMembers || []).some(checkIncluded),
|
||||
isTechCommittee: technicalCommitteeMembers.some(checkIncluded),
|
||||
isSociety: societyMembers.some(checkIncluded),
|
||||
isSudo: !!sudoKey && sudoKey.eq(accountId)
|
||||
};
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name info
|
||||
* @description Returns aux. info with regards to an account, current that includes the accountId, accountIndex and nickname
|
||||
@@ -116,15 +155,16 @@ function retrieveIdentity (api: ApiInterfaceRx, accountId?: AccountId): Observab
|
||||
export function info (api: ApiInterfaceRx): (address?: AccountIndex | AccountId | Address | string | null) => Observable<DeriveAccountInfo> {
|
||||
return memo((address?: AccountIndex | AccountId | Address | string | null): Observable<DeriveAccountInfo> =>
|
||||
api.derive.accounts.idAndIndex(address).pipe(
|
||||
switchMap(([accountId, accountIndex]): Observable<[Partial<DeriveAccountInfo>, DeriveAccountRegistration, string?]> =>
|
||||
switchMap(([accountId, accountIndex]): Observable<[Partial<DeriveAccountInfo>, DeriveAccountFlags, DeriveAccountRegistration, string?]> =>
|
||||
combineLatest([
|
||||
of({ accountId, accountIndex }),
|
||||
retrieveFlags(api, accountId),
|
||||
retrieveIdentity(api, accountId),
|
||||
retrieveNick(api, accountId)
|
||||
])
|
||||
),
|
||||
map(([{ accountId, accountIndex }, identity, nickname]): DeriveAccountInfo => ({
|
||||
accountId, accountIndex, identity, nickname
|
||||
map(([{ accountId, accountIndex }, flags, identity, nickname]): DeriveAccountInfo => ({
|
||||
accountId, accountIndex, ...flags, identity, nickname
|
||||
}))
|
||||
));
|
||||
}
|
||||
|
||||
@@ -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 { ReferendumInfo } from '@polkadot/types/interfaces/democracy';
|
||||
import { ReferendumInfo, ReferendumInfoTo239, ReferendumStatus } from '@polkadot/types/interfaces';
|
||||
import { DerivedReferendum } from '../types';
|
||||
import { PreImage } from './proposals';
|
||||
|
||||
@@ -14,20 +14,35 @@ import { Option } from '@polkadot/types';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
function constructInfo (api: ApiInterfaceRx, index: BN | number, _info: Option<ReferendumInfo>, _preimage?: PreImage): DerivedReferendum | null {
|
||||
const preImage = _preimage?.isSome
|
||||
? _preimage.unwrap()
|
||||
: null;
|
||||
const info = _info.unwrapOr(null);
|
||||
function isOld (info: ReferendumInfo | ReferendumInfoTo239): info is ReferendumInfoTo239 {
|
||||
return !!(info as ReferendumInfoTo239).proposalHash;
|
||||
}
|
||||
|
||||
if (!info) {
|
||||
function getStatus (info: Option<ReferendumInfo | ReferendumInfoTo239>): ReferendumStatus | ReferendumInfoTo239 | null {
|
||||
if (info.isNone) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const unwrapped = info.unwrap();
|
||||
|
||||
if (isOld(unwrapped)) {
|
||||
return unwrapped;
|
||||
} else if (unwrapped.isOngoing) {
|
||||
return unwrapped.asOngoing;
|
||||
}
|
||||
|
||||
// done, we don't include it here... only currently active
|
||||
return null;
|
||||
}
|
||||
|
||||
function constructInfo (api: ApiInterfaceRx, index: BN | number, status: ReferendumStatus | ReferendumInfoTo239, _preimage?: PreImage): DerivedReferendum | null {
|
||||
const preImage = _preimage?.isSome
|
||||
? _preimage.unwrap()
|
||||
: null;
|
||||
|
||||
return {
|
||||
index: api.registry.createType('PropIndex', index),
|
||||
info,
|
||||
hash: info.proposalHash,
|
||||
hash: status.proposalHash,
|
||||
proposal: preImage
|
||||
? api.registry.createType('Proposal', preImage[0].toU8a(true))
|
||||
: undefined,
|
||||
@@ -37,25 +52,26 @@ function constructInfo (api: ApiInterfaceRx, index: BN | number, _info: Option<R
|
||||
balance: preImage[2],
|
||||
proposer: preImage[1]
|
||||
}
|
||||
: undefined
|
||||
: undefined,
|
||||
status
|
||||
};
|
||||
}
|
||||
|
||||
export function retrieveInfo (api: ApiInterfaceRx, index: BN | number, info: Option<ReferendumInfo>): Observable<DerivedReferendum | null> {
|
||||
return ((
|
||||
info?.isSome
|
||||
? api.query.democracy.preimages(info.unwrap().proposalHash)
|
||||
: of(undefined)
|
||||
) as Observable<PreImage | undefined>).pipe(
|
||||
map((preimage?: PreImage): DerivedReferendum | null =>
|
||||
constructInfo(api, index, info, preimage)
|
||||
export function retrieveInfo (api: ApiInterfaceRx, index: BN | number, info: Option<ReferendumInfo | ReferendumInfoTo239>): Observable<DerivedReferendum | null> {
|
||||
const status = getStatus(info);
|
||||
|
||||
return status
|
||||
? api.query.democracy.preimages(status.proposalHash).pipe(
|
||||
map((preimage?: PreImage): DerivedReferendum | null =>
|
||||
constructInfo(api, index, status, preimage)
|
||||
)
|
||||
)
|
||||
);
|
||||
: of(null);
|
||||
}
|
||||
|
||||
export function referendumInfo (api: ApiInterfaceRx): (index: BN | number) => Observable<DerivedReferendum | null> {
|
||||
return memo((index: BN | number): Observable<DerivedReferendum | null> =>
|
||||
api.query.democracy.referendumInfoOf<Option<ReferendumInfo>>(index).pipe(
|
||||
api.query.democracy.referendumInfoOf<Option<ReferendumInfo | ReferendumInfoTo239>>(index).pipe(
|
||||
switchMap((info): Observable<DerivedReferendum | null> =>
|
||||
retrieveInfo(api, index, info)
|
||||
)
|
||||
|
||||
@@ -13,7 +13,7 @@ import { Option, Vec } from '@polkadot/types';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type MultiResult = [Option<AccountId>, Option<ITuple<[Nominations]>>, RewardDestination, ITuple<[ValidatorPrefs]>, Option<Keys>, Exposure];
|
||||
type MultiResult = [Option<AccountId>, Option<ITuple<[Nominations]> | Nominations>, RewardDestination, ITuple<[ValidatorPrefs]> | ValidatorPrefs, Option<Keys>, Exposure];
|
||||
|
||||
function unwrapSessionIds (stashId: AccountId, queuedKeys: [AccountId, Keys][], nextKeys: Option<Keys>): { nextSessionIds: AccountId[]; sessionIds: AccountId[] } {
|
||||
const sessionIds = (queuedKeys.find(([currentId]): boolean =>
|
||||
@@ -55,8 +55,9 @@ function retrieveCurr (api: ApiInterfaceRx, stashId: AccountId): Observable<Mult
|
||||
);
|
||||
}
|
||||
|
||||
function retrieveController (api: ApiInterfaceRx, stashId: AccountId, [queuedKeys, [controllerIdOpt, nominatorsOpt, rewardDestination, [validatorPrefs], nextKeys, exposure]]: [Vec<ITuple<[AccountId, Keys]>>, MultiResult]): Observable<DerivedStakingQuery> {
|
||||
function retrieveController (api: ApiInterfaceRx, stashId: AccountId, [queuedKeys, [controllerIdOpt, nominatorsOpt, rewardDestination, validatorPrefs, nextKeys, exposure]]: [Vec<ITuple<[AccountId, Keys]>>, MultiResult]): Observable<DerivedStakingQuery> {
|
||||
const controllerId = controllerIdOpt.unwrapOr(null);
|
||||
const nominators = nominatorsOpt.unwrapOr(null);
|
||||
|
||||
return controllerId
|
||||
? api.query.staking.ledger(controllerId).pipe(
|
||||
@@ -64,11 +65,17 @@ function retrieveController (api: ApiInterfaceRx, stashId: AccountId, [queuedKey
|
||||
accountId: stashId,
|
||||
controllerId,
|
||||
exposure,
|
||||
nominators: nominatorsOpt.unwrapOr([{ targets: [] }])[0].targets,
|
||||
nominators: nominators
|
||||
? Array.isArray(nominators)
|
||||
? nominators[0].targets
|
||||
: nominators.targets
|
||||
: [],
|
||||
rewardDestination,
|
||||
stakingLedger: stakingLedgerOpt.unwrapOr(undefined),
|
||||
stashId,
|
||||
validatorPrefs,
|
||||
validatorPrefs: Array.isArray(validatorPrefs)
|
||||
? validatorPrefs[0]
|
||||
: validatorPrefs,
|
||||
...unwrapSessionIds(stashId, queuedKeys, nextKeys)
|
||||
}))
|
||||
)
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive 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 { ReferendumIndex, ReferendumInfo } from '@polkadot/types/interfaces/democracy';
|
||||
import { AnyJson, Constructor, Registry } from '@polkadot/types/types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import democracyTypes from '@polkadot/types/interfaces/democracy/definitions';
|
||||
import { Struct } from '@polkadot/types';
|
||||
|
||||
// We can ignore the properties, added via Struct.with
|
||||
const _ReferendumInfo: Constructor<ReferendumInfo> = Struct.with(democracyTypes.types.ReferendumInfo as any) as any;
|
||||
|
||||
/**
|
||||
* @name ReferendumInfoExtended
|
||||
* @description
|
||||
* A [[ReferendumInfo]] with an additional `index` field
|
||||
*/
|
||||
export default class ReferendumInfoExtended extends _ReferendumInfo {
|
||||
readonly #index: ReferendumIndex;
|
||||
|
||||
constructor (registry: Registry, value: ReferendumInfo | ReferendumInfoExtended, index?: BN | number) {
|
||||
super(registry, value);
|
||||
|
||||
this.#index = value instanceof ReferendumInfoExtended
|
||||
? value.index
|
||||
: registry.createType('ReferendumIndex', index);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Convenience getter, returns the referendumIndex
|
||||
*/
|
||||
public get index (): ReferendumIndex {
|
||||
return this.#index;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Creates a human-friendly JSON representation
|
||||
*/
|
||||
public toHuman (isExtended?: boolean): AnyJson {
|
||||
return {
|
||||
...super.toHuman(isExtended) as { [index: string]: AnyJson },
|
||||
index: this.index.toHuman(isExtended)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Creates the JSON representation
|
||||
*/
|
||||
public toJSON (): AnyJson {
|
||||
return {
|
||||
...super.toJSON() as { [index: string]: AnyJson },
|
||||
index: this.index.toJSON()
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -3,4 +3,3 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export { default as HeaderExtended } from './HeaderExtended';
|
||||
export { default as ReferendumInfoExtended } from './ReferendumInfoExtended';
|
||||
|
||||
@@ -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 { AccountId, AccountIndex, Balance, BalanceLock, BalanceLockTo212, BalanceOf, Bid, BidKind, BlockNumber, Hash, Index, Proposal, PropIndex, ProposalIndex, ReferendumInfo, RegistrationJudgement, SetIndex, SocietyVote, StrikeCount, TreasuryProposal, Vote, Votes, VoteIndex, VouchingStatus } from '@polkadot/types/interfaces';
|
||||
import { AccountId, AccountIndex, Balance, BalanceLock, BalanceLockTo212, BalanceOf, Bid, BidKind, BlockNumber, Hash, Index, Proposal, PropIndex, ProposalIndex, ReferendumInfoTo239, ReferendumStatus, RegistrationJudgement, SetIndex, SocietyVote, StrikeCount, TreasuryProposal, Vote, Votes, VoteIndex, VouchingStatus } from '@polkadot/types/interfaces';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { u32, Vec } from '@polkadot/types';
|
||||
@@ -28,7 +28,14 @@ export interface DeriveAccountRegistration {
|
||||
judgements: RegistrationJudgement[];
|
||||
}
|
||||
|
||||
export interface DeriveAccountInfo {
|
||||
export interface DeriveAccountFlags {
|
||||
isCouncil: boolean;
|
||||
isSociety: boolean;
|
||||
isSudo: boolean;
|
||||
isTechCommittee: boolean;
|
||||
}
|
||||
|
||||
export interface DeriveAccountInfo extends DeriveAccountFlags {
|
||||
accountId?: AccountId;
|
||||
accountIndex?: AccountIndex;
|
||||
identity: DeriveAccountRegistration;
|
||||
@@ -131,9 +138,9 @@ export interface DeriveProposal {
|
||||
export interface DerivedReferendum {
|
||||
hash: Hash;
|
||||
index: PropIndex;
|
||||
info: ReferendumInfo;
|
||||
preimage?: DeriveProposalPreImage;
|
||||
proposal?: Proposal;
|
||||
status: ReferendumStatus | ReferendumInfoTo239;
|
||||
}
|
||||
|
||||
export type DerivedRecentlyOffline = Record<string, RecentlyOffline[]>;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api",
|
||||
"version": "1.7.1",
|
||||
"version": "1.8.1",
|
||||
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -26,13 +26,13 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.7",
|
||||
"@polkadot/api-derive": "1.7.1",
|
||||
"@babel/runtime": "^7.9.2",
|
||||
"@polkadot/api-derive": "1.8.1",
|
||||
"@polkadot/keyring": "^2.6.2",
|
||||
"@polkadot/metadata": "1.7.1",
|
||||
"@polkadot/rpc-core": "1.7.1",
|
||||
"@polkadot/rpc-provider": "1.7.1",
|
||||
"@polkadot/types": "1.7.1",
|
||||
"@polkadot/metadata": "1.8.1",
|
||||
"@polkadot/rpc-core": "1.8.1",
|
||||
"@polkadot/rpc-provider": "1.8.1",
|
||||
"@polkadot/types": "1.8.1",
|
||||
"@polkadot/util": "^2.6.2",
|
||||
"@polkadot/util-crypto": "^2.6.2",
|
||||
"bn.js": "^5.1.1",
|
||||
|
||||
@@ -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,19 @@
|
||||
// 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 { HashMap, Option, Vec } from '@polkadot/types/codec';
|
||||
import { Bytes, Null, StorageKey, Text, bool, u32, u64 } from '@polkadot/types/primitive';
|
||||
import { Metadata } from '@polkadot/types';
|
||||
import { EpochAuthorship } from '@polkadot/types/interfaces/babe';
|
||||
import { AuthorityId } from '@polkadot/types/interfaces/consensus';
|
||||
import { ContractCallRequest, ContractExecResult } from '@polkadot/types/interfaces/contracts';
|
||||
import { CreatedBlock } from '@polkadot/types/interfaces/engine';
|
||||
import { Extrinsic } from '@polkadot/types/interfaces/extrinsics';
|
||||
import { StorageKind } from '@polkadot/types/interfaces/offchain';
|
||||
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, KeyValue, SignedBlock, StorageData } from '@polkadot/types/interfaces/runtime';
|
||||
import { NodeRole } from '@polkadot/types/interfaces/system';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
@@ -53,6 +58,12 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
**/
|
||||
submitExtrinsic: AugmentedRpc<(extrinsic: IExtrinsic) => Observable<Hash>>;
|
||||
};
|
||||
babe: {
|
||||
/**
|
||||
* Returns data about which slots (primary or secondary) can be claimed in the current epoch with the keys in the keystore
|
||||
**/
|
||||
epochAuthorship: AugmentedRpc<() => Observable<HashMap<AuthorityId, EpochAuthorship>>>;
|
||||
};
|
||||
chain: {
|
||||
/**
|
||||
* Get header and body of a relay chain block
|
||||
@@ -92,6 +103,30 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
* Returns the value under a specified storage key in a contract
|
||||
**/
|
||||
getStorage: AugmentedRpc<(address: AccountId | string | Uint8Array, key: H256 | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<Option<Bytes>>>;
|
||||
/**
|
||||
* Returns the projected time a given contract will be able to sustain paying its rent
|
||||
**/
|
||||
rentProjection: AugmentedRpc<(address: AccountId | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<Option<BlockNumber>>>;
|
||||
};
|
||||
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>>;
|
||||
};
|
||||
offchain: {
|
||||
/**
|
||||
* Get offchain local storage under given key and prefix
|
||||
**/
|
||||
localStorageGet: AugmentedRpc<(kind: StorageKind | ('__UNUSED' | 'PERSISTENT' | 'LOCAL') | number | Uint8Array, key: Bytes | string | Uint8Array) => Observable<Option<Bytes>>>;
|
||||
/**
|
||||
* Set offchain local storage under given key and prefix
|
||||
**/
|
||||
localStorageSet: AugmentedRpc<(kind: StorageKind | ('__UNUSED' | 'PERSISTENT' | 'LOCAL') | number | Uint8Array, key: Bytes | string | Uint8Array, value: Bytes | string | Uint8Array) => Observable<Null>>;
|
||||
};
|
||||
payment: {
|
||||
/**
|
||||
@@ -138,6 +173,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
* Returns the runtime metadata
|
||||
**/
|
||||
getMetadata: AugmentedRpc<(at?: BlockHash | string | Uint8Array) => Observable<Metadata>>;
|
||||
/**
|
||||
* Returns the keys with prefix, leave empty to get all the keys
|
||||
**/
|
||||
getPairs: AugmentedRpc<(prefix: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array) => Observable<Vec<KeyValue>>>;
|
||||
/**
|
||||
* Get the runtime version
|
||||
**/
|
||||
@@ -168,6 +207,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
subscribeStorage: AugmentedRpc<<T = Codec[]>(keys: Vec<StorageKey> | (StorageKey | string | Uint8Array | any)[]) => Observable<T>>;
|
||||
};
|
||||
system: {
|
||||
/**
|
||||
* Adds a reserved peer
|
||||
**/
|
||||
addReservedPeer: AugmentedRpc<(peer: Text | string) => Observable<Text>>;
|
||||
/**
|
||||
* Retrieves the chain
|
||||
**/
|
||||
@@ -184,6 +227,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
* Returns current state of the network
|
||||
**/
|
||||
networkState: AugmentedRpc<() => Observable<NetworkState>>;
|
||||
/**
|
||||
* Returns the roles the node is running as
|
||||
**/
|
||||
nodeRoles: AugmentedRpc<() => Observable<Vec<NodeRole>>>;
|
||||
/**
|
||||
* Returns the currently connected peers
|
||||
**/
|
||||
@@ -192,6 +239,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
* Get a custom set of properties as a JSON object, defined in the chain spec
|
||||
**/
|
||||
properties: AugmentedRpc<() => Observable<ChainProperties>>;
|
||||
/**
|
||||
* Remove a reserved peer
|
||||
**/
|
||||
removeReservedPeer: AugmentedRpc<(peerId: Text | string) => Observable<Text>>;
|
||||
/**
|
||||
* Retrieves the version of the node
|
||||
**/
|
||||
|
||||
@@ -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 => {
|
||||
|
||||
@@ -217,7 +217,9 @@ export default abstract class Init<ApiType extends ApiTypes> extends Decorate<Ap
|
||||
try {
|
||||
const [hasMeta, cryptoReady] = await Promise.all([
|
||||
this.loadMeta(),
|
||||
cryptoWaitReady()
|
||||
this._options.initWasm === false
|
||||
? Promise.resolve(true)
|
||||
: cryptoWaitReady()
|
||||
]);
|
||||
|
||||
if (hasMeta && !this._isReady && cryptoReady) {
|
||||
|
||||
@@ -21,7 +21,7 @@ export default class SubmittableResult implements ISubmittableResult {
|
||||
}
|
||||
|
||||
public get isError (): boolean {
|
||||
return this.status.isDropped || this.status.isFinalityTimeout || this.status.isInvalid || this.status.isRetracted || this.status.isUsurped;
|
||||
return this.status.isDropped || this.status.isFinalityTimeout || this.status.isInvalid || this.status.isUsurped;
|
||||
}
|
||||
|
||||
public get isFinalized (): boolean {
|
||||
@@ -32,6 +32,10 @@ export default class SubmittableResult implements ISubmittableResult {
|
||||
return this.status.isInBlock;
|
||||
}
|
||||
|
||||
public get isWarning (): boolean {
|
||||
return this.status.isRetracted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Filters EventRecords for the specified method & section (there could be multiple)
|
||||
*/
|
||||
|
||||
@@ -166,9 +166,9 @@ export default function createClass <ApiType extends ApiTypes> ({ api, apiType,
|
||||
#makeSignOptions = (options: Partial<SignerOptions>, extras: { blockHash?: Hash; era?: ExtrinsicEra; nonce?: Index }): SignatureOptions => {
|
||||
return {
|
||||
blockHash: api.genesisHash,
|
||||
genesisHash: api.genesisHash,
|
||||
...options,
|
||||
...extras,
|
||||
genesisHash: api.genesisHash,
|
||||
runtimeVersion: api.runtimeVersion,
|
||||
version: api.extrinsicType
|
||||
} as SignatureOptions;
|
||||
|
||||
@@ -8,18 +8,20 @@ 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, SignatureOptions, Registry, RegisteredTypes } from '@polkadot/types/types';
|
||||
|
||||
import ApiBase from '../base';
|
||||
import { DeriveAllSections } from '../util/decorate';
|
||||
import ApiBase from '../base';
|
||||
import { DecoratedRpc } from './rpc';
|
||||
import { QueryableStorage, QueryableStorageMulti } from './storage';
|
||||
import { SubmittableExtrinsics } from './submittable';
|
||||
import { ProviderInterface, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types';
|
||||
|
||||
export { Signer, SignerResult } from '@polkadot/types/types';
|
||||
export { default as ApiBase } from '../base';
|
||||
export * from '../submittable/types';
|
||||
export * from './base';
|
||||
export * from './rpc';
|
||||
@@ -31,6 +33,10 @@ export interface ApiOptions extends RegisteredTypes {
|
||||
* @description Add custom derives to be injected
|
||||
*/
|
||||
derives?: DeriveCustom;
|
||||
/**
|
||||
* @description Control the initialization of the wasm libraries. When not specified, it defaults to `true`, initializing the wasm libraries, set to `false` to not initialize wasm. (No sr25519 support)
|
||||
*/
|
||||
initWasm?: boolean;
|
||||
/**
|
||||
* @description pre-bundles is a map of 'genesis hash and runtime spec version' as key to a metadata hex string
|
||||
* if genesis hash and runtime spec version matches, then use metadata, else fetch it from chain
|
||||
@@ -48,7 +54,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
|
||||
*/
|
||||
@@ -83,5 +89,3 @@ export interface SignerOptions extends SignatureOptions {
|
||||
blockNumber: BN;
|
||||
genesisHash: Hash;
|
||||
}
|
||||
|
||||
export { ApiBase, Signer, SignerResult };
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
import { StorageEntry } from '@polkadot/types/primitive/StorageKey';
|
||||
import { Type } from '@polkadot/types';
|
||||
|
||||
import { assert, isUndefined } from '@polkadot/util';
|
||||
|
||||
function sig ({ method, section }: StorageEntry, ...args: Type[]): string {
|
||||
|
||||
@@ -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.7.1",
|
||||
"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.7.1",
|
||||
"@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>;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/metadata",
|
||||
"version": "1.7.1",
|
||||
"version": "1.8.1",
|
||||
"description": "Helpers to extract information from runtime metadata",
|
||||
"main": "index.js",
|
||||
"publishConfig": {
|
||||
@@ -26,8 +26,8 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.7",
|
||||
"@polkadot/types": "1.7.1",
|
||||
"@babel/runtime": "^7.9.2",
|
||||
"@polkadot/types": "1.8.1",
|
||||
"@polkadot/util": "^2.6.2",
|
||||
"@polkadot/util-crypto": "^2.6.2",
|
||||
"bn.js": "^5.1.1"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -15,7 +15,7 @@ export default class MagicNumber extends U32 {
|
||||
super(registry, value);
|
||||
|
||||
if (!this.isEmpty) {
|
||||
const magic = new U32(registry, MAGIC_NUMBER);
|
||||
const magic = registry.createType('u32', MAGIC_NUMBER);
|
||||
|
||||
assert(this.eq(magic), `MagicNumber mismatch: expected ${magic.toHex()}, found ${this.toHex()}`);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-core",
|
||||
"version": "1.7.1",
|
||||
"version": "1.8.1",
|
||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -26,11 +26,10 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.7",
|
||||
"@polkadot/jsonrpc": "1.7.1",
|
||||
"@polkadot/metadata": "1.7.1",
|
||||
"@polkadot/rpc-provider": "1.7.1",
|
||||
"@polkadot/types": "1.7.1",
|
||||
"@babel/runtime": "^7.9.2",
|
||||
"@polkadot/metadata": "1.8.1",
|
||||
"@polkadot/rpc-provider": "1.8.1",
|
||||
"@polkadot/types": "1.8.1",
|
||||
"@polkadot/util": "^2.6.2",
|
||||
"memoizee": "^0.4.14",
|
||||
"rxjs": "^6.5.4"
|
||||
|
||||
@@ -17,44 +17,28 @@ describe('Api', (): void => {
|
||||
).toThrow(/Expected Provider/);
|
||||
});
|
||||
|
||||
it('creates an instance with all sections', (): void => {
|
||||
const rpc = new Rpc(registry, new MockProvider(registry));
|
||||
|
||||
expect(
|
||||
Object.keys(rpc).filter((key): boolean => !key.startsWith('_'))
|
||||
).toEqual([
|
||||
'mapping', 'provider', 'registry', 'sections',
|
||||
'account', 'author', 'chain', 'contracts', '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;
|
||||
|
||||
@@ -84,10 +79,16 @@ export default class Rpc implements RpcInterface {
|
||||
|
||||
public readonly author!: RpcInterface['author'];
|
||||
|
||||
public readonly babe!: RpcInterface['babe'];
|
||||
|
||||
public readonly chain!: RpcInterface['chain'];
|
||||
|
||||
public readonly contracts!: RpcInterface['contracts'];
|
||||
|
||||
public readonly engine!: RpcInterface['engine'];
|
||||
|
||||
public readonly offchain!: RpcInterface['offchain'];
|
||||
|
||||
public readonly payment!: RpcInterface['payment'];
|
||||
|
||||
public readonly rpc!: RpcInterface['rpc'];
|
||||
@@ -101,14 +102,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 +119,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 +152,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 +168,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 +178,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 +188,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 +222,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 +240,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 +252,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 +285,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 +303,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 +322,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 +333,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 => {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { catchError, distinctUntilChanged, publishReplay, tap, refCount } from 'rxjs/operators';
|
||||
import { logger } from '@polkadot/util';
|
||||
|
||||
|
||||
@@ -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[]>;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-provider",
|
||||
"version": "1.7.1",
|
||||
"version": "1.8.1",
|
||||
"description": "Transport providers for the API",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -26,10 +26,9 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.7",
|
||||
"@polkadot/jsonrpc": "1.7.1",
|
||||
"@polkadot/metadata": "1.7.1",
|
||||
"@polkadot/types": "1.7.1",
|
||||
"@babel/runtime": "^7.9.2",
|
||||
"@polkadot/metadata": "1.8.1",
|
||||
"@polkadot/types": "1.8.1",
|
||||
"@polkadot/util": "^2.6.2",
|
||||
"@polkadot/util-crypto": "^2.6.2",
|
||||
"bn.js": "^5.1.1",
|
||||
@@ -40,6 +39,6 @@
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^2.6.2",
|
||||
"mock-socket": "^9.0.3",
|
||||
"nock": "^12.0.2"
|
||||
"nock": "^12.0.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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')
|
||||
)
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/typegen",
|
||||
"version": "1.7.1",
|
||||
"version": "1.8.1",
|
||||
"description": "Type generation scripts",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
@@ -33,17 +33,16 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/typegen#readme",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.8.7",
|
||||
"@babel/register": "^7.8.6",
|
||||
"@babel/runtime": "^7.8.7",
|
||||
"@polkadot/api": "1.7.1",
|
||||
"@polkadot/jsonrpc": "1.7.1",
|
||||
"@polkadot/metadata": "1.7.1",
|
||||
"@polkadot/rpc-provider": "1.7.1",
|
||||
"@polkadot/types": "1.7.1",
|
||||
"@babel/core": "^7.9.0",
|
||||
"@babel/register": "^7.9.0",
|
||||
"@babel/runtime": "^7.9.2",
|
||||
"@polkadot/api": "1.8.1",
|
||||
"@polkadot/metadata": "1.8.1",
|
||||
"@polkadot/rpc-provider": "1.8.1",
|
||||
"@polkadot/types": "1.8.1",
|
||||
"@polkadot/util": "^2.6.2",
|
||||
"websocket": "^1.0.31",
|
||||
"yargs": "^15.3.0"
|
||||
"yargs": "^15.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/websocket": "^1.0.0",
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ModuleMetadataLatest } from '@polkadot/types/interfaces/metadata';
|
||||
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
|
||||
|
||||
import staticData from '@polkadot/metadata/Metadata/static';
|
||||
import Metadata from '@polkadot/metadata/Metadata';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
|
||||
import { stringCamelCase } from '@polkadot/util';
|
||||
|
||||
import { FOOTER, HEADER, TypeImports, createDocComments, createImportCode, createImports, indent, registerDefinitions, setImports, writeFile } from '../util';
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
|
||||
import { ModuleMetadataLatest, StorageEntryMetadataLatest } from '@polkadot/types/interfaces/metadata';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
|
||||
|
||||
import staticData from '@polkadot/metadata/Metadata/static';
|
||||
import Metadata from '@polkadot/metadata/Metadata';
|
||||
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
|
||||
import { unwrapStorageType } from '@polkadot/types/primitive/StorageKey';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
import { stringLowerFirst } from '@polkadot/util';
|
||||
|
||||
@@ -2,9 +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 interfaces from '@polkadot/jsonrpc';
|
||||
import * as definitions from '@polkadot/types/interfaces/definitions';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
import * as definitions from '@polkadot/types/interfaces/definitions';
|
||||
|
||||
import { FOOTER, HEADER, createDocComments, createImportCode, createImports, getSimilarTypes, setImports, writeFile, indent } from '../util';
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ModuleMetadataLatest } from '@polkadot/types/interfaces/metadata';
|
||||
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import staticData from '@polkadot/metadata/Metadata/static';
|
||||
import Metadata from '@polkadot/metadata/Metadata';
|
||||
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
|
||||
import { Text } from '@polkadot/types/primitive';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
import { stringCamelCase } from '@polkadot/util';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -52,7 +52,7 @@ function documentationVecToMarkdown (docLines: Vec<Text>, indent = 0): string {
|
||||
.replace(/^#{1,3} /, '#### ')} `
|
||||
, '');
|
||||
// prefix each line with indentation
|
||||
return md && md.split('\n\n').map(line => `${' '.repeat(indent)}${line}`).join('\n\n');
|
||||
return md && md.split('\n\n').map((line) => `${' '.repeat(indent)}${line}`).join('\n\n');
|
||||
}
|
||||
|
||||
function renderPage (page: Page): string {
|
||||
@@ -68,7 +68,7 @@ function renderPage (page: Page): string {
|
||||
});
|
||||
|
||||
// contents
|
||||
page.sections.forEach(section => {
|
||||
page.sections.forEach((section) => {
|
||||
md += `\n___\n\n\n## ${section.name}\n`;
|
||||
|
||||
if (section.description) {
|
||||
@@ -78,7 +78,7 @@ function renderPage (page: Page): string {
|
||||
section.items.forEach((item) => {
|
||||
md += ` \n### ${item.name}`;
|
||||
|
||||
Object.keys(item).filter(i => i !== 'name').forEach(bullet => {
|
||||
Object.keys(item).filter((i) => i !== 'name').forEach((bullet) => {
|
||||
md += `\n- **${bullet}**: ${
|
||||
item[bullet] instanceof Vec
|
||||
? documentationVecToMarkdown(item[bullet] as Vec<Text>, 2)
|
||||
@@ -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 */
|
||||
@@ -60,7 +61,8 @@ export function getDerivedTypes (definitions: object, type: string, primitiveNam
|
||||
});
|
||||
}
|
||||
|
||||
const result = types.map(t => formatType(definitions, t, imports)).map(t => `'${t}': ${t};`);
|
||||
const result = types.map((t) => formatType(definitions, t, imports)).map((t) => `'${t}': ${t};`);
|
||||
|
||||
result.unshift(`${type}: ${type};`);
|
||||
|
||||
return result;
|
||||
|
||||
@@ -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,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/types",
|
||||
"version": "1.7.1",
|
||||
"version": "1.8.1",
|
||||
"description": "Implementation of the Parity codec",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -26,8 +26,8 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.7",
|
||||
"@polkadot/metadata": "1.7.1",
|
||||
"@babel/runtime": "^7.9.2",
|
||||
"@polkadot/metadata": "1.8.1",
|
||||
"@polkadot/util": "^2.6.2",
|
||||
"@polkadot/util-crypto": "^2.6.2",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
// 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';
|
||||
import { BlockAttestations, IncludedBlocks, MoreAttestations } from '@polkadot/types/interfaces/attestations';
|
||||
import { RawAuraPreDigest } from '@polkadot/types/interfaces/aura';
|
||||
import { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
|
||||
import { BabeAuthorityWeight, BabeBlockWeight, BabeWeight, MaybeVrf, RawBabePreDigest, RawBabePreDigestCompat, RawBabePreDigestPrimary, RawBabePreDigestPrimaryTo159, RawBabePreDigestSecondary, RawBabePreDigestSecondaryTo159, RawBabePreDigestTo159, SlotNumber, VrfData, VrfProof } from '@polkadot/types/interfaces/babe';
|
||||
import { BabeAuthorityWeight, BabeBlockWeight, BabeWeight, EpochAuthorship, MaybeVrf, RawBabePreDigest, RawBabePreDigestCompat, RawBabePreDigestPrimary, RawBabePreDigestPrimaryTo159, RawBabePreDigestSecondary, RawBabePreDigestSecondaryTo159, RawBabePreDigestTo159, SlotNumber, VrfData, VrfProof } from '@polkadot/types/interfaces/babe';
|
||||
import { AccountData, BalanceLock, BalanceLockTo212, Reasons, ReleasesBalances, VestingSchedule, WithdrawReasons } from '@polkadot/types/interfaces/balances';
|
||||
import { EthereumAddress } from '@polkadot/types/interfaces/claims';
|
||||
import { MemberCount, ProposalIndex, Votes, VotesTo230 } from '@polkadot/types/interfaces/collective';
|
||||
import { AuthorityId } from '@polkadot/types/interfaces/consensus';
|
||||
import { AliveContractInfo, CodeHash, ContractCallRequest, ContractExecResult, ContractExecResultSuccess, ContractInfo, ContractStorageKey, Gas, PrefabWasmModule, PrefabWasmModuleReserved, Schedule, ScheduleTo212, SeedOf, TombstoneContractInfo, TrieId } from '@polkadot/types/interfaces/contracts';
|
||||
import { Conviction, PropIndex, Proposal, ProxyState, ReferendumIndex, ReferendumInfo } from '@polkadot/types/interfaces/democracy';
|
||||
import { AccountVote, AccountVoteSplit, AccountVoteStandard, Conviction, Delegations, PriorLock, PropIndex, Proposal, ProxyState, ReferendumIndex, ReferendumInfo, ReferendumInfoFinished, ReferendumInfoTo239, ReferendumStatus, Tally, Voting, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces/democracy';
|
||||
import { ApprovalFlag, SetIndex, Vote, VoteIndex, VoteThreshold, VoterInfo } from '@polkadot/types/interfaces/elections';
|
||||
import { CreatedBlock, ImportedAux } from '@polkadot/types/interfaces/engine';
|
||||
import { Account, Log } from '@polkadot/types/interfaces/evm';
|
||||
@@ -22,6 +22,7 @@ import { AuthorityIndex, AuthorityList, AuthorityWeight, NextAuthority, PendingP
|
||||
import { IdentityFields, IdentityInfo, IdentityInfoAdditional, IdentityJudgement, RegistrarIndex, RegistrarInfo, Registration, RegistrationJudgement } from '@polkadot/types/interfaces/identity';
|
||||
import { AuthIndex, AuthoritySignature, Heartbeat, OpaqueMultiaddr, OpaqueNetworkState, OpaquePeerId } from '@polkadot/types/interfaces/imOnline';
|
||||
import { CallMetadataV0, DoubleMapTypeLatest, DoubleMapTypeV10, DoubleMapTypeV11, DoubleMapTypeV3, DoubleMapTypeV4, DoubleMapTypeV5, DoubleMapTypeV6, DoubleMapTypeV7, DoubleMapTypeV8, DoubleMapTypeV9, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV8, ErrorMetadataV9, EventMetadataLatest, EventMetadataV0, EventMetadataV1, EventMetadataV10, EventMetadataV11, EventMetadataV2, EventMetadataV3, EventMetadataV4, EventMetadataV5, EventMetadataV6, EventMetadataV7, EventMetadataV8, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV0, FunctionArgumentMetadataV1, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV2, FunctionArgumentMetadataV3, FunctionArgumentMetadataV4, FunctionArgumentMetadataV5, FunctionArgumentMetadataV6, FunctionArgumentMetadataV7, FunctionArgumentMetadataV8, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV0, FunctionMetadataV1, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV2, FunctionMetadataV3, FunctionMetadataV4, FunctionMetadataV5, FunctionMetadataV6, FunctionMetadataV7, FunctionMetadataV8, FunctionMetadataV9, MapTypeLatest, MapTypeV0, MapTypeV10, MapTypeV11, MapTypeV2, MapTypeV3, MapTypeV4, MapTypeV5, MapTypeV6, MapTypeV7, MapTypeV8, MapTypeV9, MetadataAll, MetadataLatest, MetadataV0, MetadataV1, MetadataV10, MetadataV11, MetadataV2, MetadataV3, MetadataV4, MetadataV5, MetadataV6, MetadataV7, MetadataV8, MetadataV9, ModuleConstantMetadataLatest, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV6, ModuleConstantMetadataV7, ModuleConstantMetadataV8, ModuleConstantMetadataV9, ModuleMetadataLatest, ModuleMetadataV0, ModuleMetadataV1, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV2, ModuleMetadataV3, ModuleMetadataV4, ModuleMetadataV5, ModuleMetadataV6, ModuleMetadataV7, ModuleMetadataV8, ModuleMetadataV9, OuterDispatchCallV0, OuterDispatchMetadataV0, OuterEventEventMetadataEventsV0, OuterEventEventMetadataV0, OuterEventMetadataV0, PlainTypeLatest, PlainTypeV0, PlainTypeV10, PlainTypeV11, PlainTypeV2, PlainTypeV3, PlainTypeV4, PlainTypeV5, PlainTypeV6, PlainTypeV7, PlainTypeV8, PlainTypeV9, RuntimeModuleMetadataV0, StorageEntryMetadataLatest, StorageEntryMetadataV10, StorageEntryMetadataV11, StorageEntryMetadataV6, StorageEntryMetadataV7, StorageEntryMetadataV8, StorageEntryMetadataV9, StorageEntryModifierLatest, StorageEntryModifierV10, StorageEntryModifierV11, StorageEntryModifierV6, StorageEntryModifierV7, StorageEntryModifierV8, StorageEntryModifierV9, StorageEntryTypeLatest, StorageEntryTypeV10, StorageEntryTypeV11, StorageEntryTypeV6, StorageEntryTypeV7, StorageEntryTypeV8, StorageEntryTypeV9, StorageFunctionMetadataV0, StorageFunctionMetadataV1, StorageFunctionMetadataV2, StorageFunctionMetadataV3, StorageFunctionMetadataV4, StorageFunctionMetadataV5, StorageFunctionModifierV0, StorageFunctionModifierV1, StorageFunctionModifierV2, StorageFunctionModifierV3, StorageFunctionModifierV4, StorageFunctionModifierV5, StorageFunctionTypeV0, StorageFunctionTypeV1, StorageFunctionTypeV2, StorageFunctionTypeV3, StorageFunctionTypeV4, StorageFunctionTypeV5, StorageHasher, StorageHasherV10, StorageHasherV11, StorageHasherV4, StorageHasherV5, StorageHasherV6, StorageHasherV7, StorageHasherV8, StorageHasherV9, StorageMetadataLatest, StorageMetadataV0, StorageMetadataV10, StorageMetadataV11, StorageMetadataV7, StorageMetadataV8, StorageMetadataV9 } from '@polkadot/types/interfaces/metadata';
|
||||
import { StorageKind } from '@polkadot/types/interfaces/offchain';
|
||||
import { Kind, OffenceDetails, Offender, OpaqueTimeSlot, ReportIdOf, Reporter } from '@polkadot/types/interfaces/offences';
|
||||
import { AttestedCandidate, AuctionIndex, Bidder, CandidateReceipt, CollatorId, CollatorSignature, EgressQueueRoot, HeadData, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, LeasePeriod, LeasePeriodOf, NewBidder, ParaId, ParaIdOf, ParaInfo, ParaScheduling, ParachainDispatchOrigin, Retriable, SlotRange, SubId, UpwardMessage, ValidityAttestation, WinningData, WinningDataEntry } from '@polkadot/types/interfaces/parachains';
|
||||
import { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
|
||||
@@ -30,7 +31,7 @@ import { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, Balanc
|
||||
import { FullIdentification, IdentificationTuple, Keys, SessionIndex, SessionKeys1, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6 } from '@polkadot/types/interfaces/session';
|
||||
import { Bid, BidKind, SocietyJudgement, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
|
||||
import { ActiveEraInfo, CompactAssignments, CompactScore, ElectionCompute, ElectionResult, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, PhragmenScore, Points, ReleasesStaking, RewardDestination, RewardPoint, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196 } from '@polkadot/types/interfaces/staking';
|
||||
import { AccountInfo, DigestOf, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, EventRecordTo76, Key, LastRuntimeUpgradeInfo, Phase, RefCount } from '@polkadot/types/interfaces/system';
|
||||
import { AccountInfo, DigestOf, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, EventRecordTo76, Key, LastRuntimeUpgradeInfo, NodeRole, Phase, RefCount } from '@polkadot/types/interfaces/system';
|
||||
import { OpenTip, OpenTipFinder, OpenTipTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
|
||||
import { Multiplier } from '@polkadot/types/interfaces/txpayment';
|
||||
import { Multisig, Timepoint } from '@polkadot/types/interfaces/utility';
|
||||
@@ -291,6 +292,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Compact<BabeWeight>': Compact<BabeWeight>;
|
||||
'Option<BabeWeight>': Option<BabeWeight>;
|
||||
'Vec<BabeWeight>': Vec<BabeWeight>;
|
||||
EpochAuthorship: EpochAuthorship;
|
||||
'Option<EpochAuthorship>': Option<EpochAuthorship>;
|
||||
'Vec<EpochAuthorship>': Vec<EpochAuthorship>;
|
||||
RawBabePreDigest: RawBabePreDigest;
|
||||
'Option<RawBabePreDigest>': Option<RawBabePreDigest>;
|
||||
'Vec<RawBabePreDigest>': Vec<RawBabePreDigest>;
|
||||
@@ -406,9 +410,24 @@ declare module '@polkadot/types/types/registry' {
|
||||
TrieId: TrieId;
|
||||
'Option<TrieId>': Option<TrieId>;
|
||||
'Vec<TrieId>': Vec<TrieId>;
|
||||
AccountVote: AccountVote;
|
||||
'Option<AccountVote>': Option<AccountVote>;
|
||||
'Vec<AccountVote>': Vec<AccountVote>;
|
||||
AccountVoteSplit: AccountVoteSplit;
|
||||
'Option<AccountVoteSplit>': Option<AccountVoteSplit>;
|
||||
'Vec<AccountVoteSplit>': Vec<AccountVoteSplit>;
|
||||
AccountVoteStandard: AccountVoteStandard;
|
||||
'Option<AccountVoteStandard>': Option<AccountVoteStandard>;
|
||||
'Vec<AccountVoteStandard>': Vec<AccountVoteStandard>;
|
||||
Conviction: Conviction;
|
||||
'Option<Conviction>': Option<Conviction>;
|
||||
'Vec<Conviction>': Vec<Conviction>;
|
||||
Delegations: Delegations;
|
||||
'Option<Delegations>': Option<Delegations>;
|
||||
'Vec<Delegations>': Vec<Delegations>;
|
||||
PriorLock: PriorLock;
|
||||
'Option<PriorLock>': Option<PriorLock>;
|
||||
'Vec<PriorLock>': Vec<PriorLock>;
|
||||
PropIndex: PropIndex;
|
||||
'Compact<PropIndex>': Compact<PropIndex>;
|
||||
'Option<PropIndex>': Option<PropIndex>;
|
||||
@@ -423,9 +442,33 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Compact<ReferendumIndex>': Compact<ReferendumIndex>;
|
||||
'Option<ReferendumIndex>': Option<ReferendumIndex>;
|
||||
'Vec<ReferendumIndex>': Vec<ReferendumIndex>;
|
||||
ReferendumInfoTo239: ReferendumInfoTo239;
|
||||
'Option<ReferendumInfoTo239>': Option<ReferendumInfoTo239>;
|
||||
'Vec<ReferendumInfoTo239>': Vec<ReferendumInfoTo239>;
|
||||
ReferendumInfo: ReferendumInfo;
|
||||
'Option<ReferendumInfo>': Option<ReferendumInfo>;
|
||||
'Vec<ReferendumInfo>': Vec<ReferendumInfo>;
|
||||
ReferendumInfoFinished: ReferendumInfoFinished;
|
||||
'Option<ReferendumInfoFinished>': Option<ReferendumInfoFinished>;
|
||||
'Vec<ReferendumInfoFinished>': Vec<ReferendumInfoFinished>;
|
||||
ReferendumStatus: ReferendumStatus;
|
||||
'Option<ReferendumStatus>': Option<ReferendumStatus>;
|
||||
'Vec<ReferendumStatus>': Vec<ReferendumStatus>;
|
||||
Tally: Tally;
|
||||
'Option<Tally>': Option<Tally>;
|
||||
'Vec<Tally>': Vec<Tally>;
|
||||
Voting: Voting;
|
||||
'Option<Voting>': Option<Voting>;
|
||||
'Vec<Voting>': Vec<Voting>;
|
||||
VotingDirect: VotingDirect;
|
||||
'Option<VotingDirect>': Option<VotingDirect>;
|
||||
'Vec<VotingDirect>': Vec<VotingDirect>;
|
||||
VotingDirectVote: VotingDirectVote;
|
||||
'Option<VotingDirectVote>': Option<VotingDirectVote>;
|
||||
'Vec<VotingDirectVote>': Vec<VotingDirectVote>;
|
||||
VotingDelegating: VotingDelegating;
|
||||
'Option<VotingDelegating>': Option<VotingDelegating>;
|
||||
'Vec<VotingDelegating>': Vec<VotingDelegating>;
|
||||
ApprovalFlag: ApprovalFlag;
|
||||
'Compact<ApprovalFlag>': Compact<ApprovalFlag>;
|
||||
'Option<ApprovalFlag>': Option<ApprovalFlag>;
|
||||
@@ -853,6 +896,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
LastRuntimeUpgradeInfo: LastRuntimeUpgradeInfo;
|
||||
'Option<LastRuntimeUpgradeInfo>': Option<LastRuntimeUpgradeInfo>;
|
||||
'Vec<LastRuntimeUpgradeInfo>': Vec<LastRuntimeUpgradeInfo>;
|
||||
NodeRole: NodeRole;
|
||||
'Option<NodeRole>': Option<NodeRole>;
|
||||
'Vec<NodeRole>': Vec<NodeRole>;
|
||||
Phase: Phase;
|
||||
'Option<Phase>': Option<Phase>;
|
||||
'Vec<Phase>': Vec<Phase>;
|
||||
@@ -1565,5 +1611,8 @@ declare module '@polkadot/types/types/registry' {
|
||||
StorageChangeSet: StorageChangeSet;
|
||||
'Option<StorageChangeSet>': Option<StorageChangeSet>;
|
||||
'Vec<StorageChangeSet>': Vec<StorageChangeSet>;
|
||||
StorageKind: StorageKind;
|
||||
'Option<StorageKind>': Option<StorageKind>;
|
||||
'Vec<StorageKind>': Vec<StorageKind>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { H256 } from '../interfaces/runtime';
|
||||
import { AnyJson, BareOpts, Codec, Constructor, ConstructorDef, InterfaceTypes, Registry } from '../types';
|
||||
|
||||
import { hexToU8a, isBoolean, isHex, isObject, isU8a, isUndefined, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
import { hexToU8a, isBoolean, isFunction, isHex, isObject, isU8a, isUndefined, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Raw from './Raw';
|
||||
@@ -290,13 +290,16 @@ export default class Struct<
|
||||
const entries = [...this.entries()] as [string, Codec][];
|
||||
|
||||
return u8aConcat(
|
||||
...entries.map(([key, value]): Uint8Array =>
|
||||
value.toU8a(
|
||||
!isBare || isBoolean(isBare)
|
||||
? isBare
|
||||
: isBare[key]
|
||||
...entries
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
.filter(([, value]) => isFunction(value?.toU8a))
|
||||
.map(([key, value]): Uint8Array =>
|
||||
value.toU8a(
|
||||
!isBare || isBoolean(isBare)
|
||||
? isBare
|
||||
: isBare[key]
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +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 { isString, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { AnyU8a, Constructor, Registry } from '../types';
|
||||
|
||||
import { isString, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import Raw from './Raw';
|
||||
|
||||
// The 520 here is a weird one - it is explicitly for a [u8; 65] as found as a EcdsaSignature
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Codec } from '../types';
|
||||
|
||||
import AbstractArray from './AbstractArray';
|
||||
|
||||
/**
|
||||
|
||||
@@ -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,13 +2,26 @@
|
||||
// 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: {
|
||||
epochAuthorship: {
|
||||
description: 'Returns data about which slots (primary or secondary) can be claimed in the current epoch with the keys in the keystore',
|
||||
params: [],
|
||||
type: 'HashMap<AuthorityId, EpochAuthorship>'
|
||||
}
|
||||
},
|
||||
types: {
|
||||
BabeAuthorityWeight: 'u64',
|
||||
BabeBlockWeight: 'u32',
|
||||
MaybeVrf: 'Option<VrfData>',
|
||||
// TODO Remove as soon as merged and metadata static updated
|
||||
BabeWeight: 'u64',
|
||||
EpochAuthorship: {
|
||||
primary: 'Vec<u64>',
|
||||
secondary: 'Vec<u64>'
|
||||
},
|
||||
RawBabePreDigest: {
|
||||
_enum: {
|
||||
Phantom: 'Null', // index starts at 1... empty slot at 0
|
||||
@@ -59,4 +72,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,7 +1,7 @@
|
||||
// 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 { Enum, Option, Struct, U8aFixed, Vec } from '@polkadot/types/codec';
|
||||
import { u32, u64 } from '@polkadot/types/primitive';
|
||||
|
||||
/** @name BabeAuthorityWeight */
|
||||
@@ -13,6 +13,12 @@ export interface BabeBlockWeight extends u32 {}
|
||||
/** @name BabeWeight */
|
||||
export interface BabeWeight extends u64 {}
|
||||
|
||||
/** @name EpochAuthorship */
|
||||
export interface EpochAuthorship extends Struct {
|
||||
readonly primary: Vec<u64>;
|
||||
readonly secondary: Vec<u64>;
|
||||
}
|
||||
|
||||
/** @name MaybeVrf */
|
||||
export interface MaybeVrf extends Option<VrfData> {}
|
||||
|
||||
@@ -81,3 +87,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;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user