Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64f0d7b2a6 | ||
|
|
4a1e504ca2 | ||
|
|
ebf3f4491e | ||
|
|
849f519efe | ||
|
|
accc2b4f7d | ||
|
|
01abc030f9 | ||
|
|
e041946de5 | ||
|
|
502e54ce5c | ||
|
|
12986f0cda | ||
|
|
83d780220c | ||
|
|
ec7848ae92 | ||
|
|
2b5be7eaab | ||
|
|
21f4e3107a | ||
|
|
8a152ea4c0 | ||
|
|
fd7b38e781 | ||
|
|
5df22835f6 | ||
|
|
6a828eb11a | ||
|
|
ad2b1abdc9 | ||
|
|
d3dc2cb00a | ||
|
|
921e55a82e | ||
|
|
fde076152a | ||
|
|
6e535b0502 | ||
|
|
1ddad84d7e | ||
|
|
1e975c68ee | ||
|
|
5c962cf093 | ||
|
|
07f55af202 |
+2
-1
@@ -5,5 +5,6 @@ exclude_patterns:
|
||||
- "**/*.test.ts"
|
||||
- "docs/**/*.js"
|
||||
- "packages/api/src/types/augment/"
|
||||
- "packages/typegen/scripts"
|
||||
- "packages/typegen/src"
|
||||
- "packages/types/src/interfaces/"
|
||||
- "packages/types/src/scripts/"
|
||||
|
||||
@@ -14,6 +14,16 @@ jobs:
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: Config yarn cache
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
- uses: actions/cache@v1
|
||||
id: yarn-cache
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
- name: lint
|
||||
run: |
|
||||
yarn install --frozen-lockfile
|
||||
@@ -31,6 +41,16 @@ jobs:
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: Config yarn cache
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
- uses: actions/cache@v1
|
||||
id: yarn-cache
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
- name: test
|
||||
run: |
|
||||
yarn install --frozen-lockfile
|
||||
@@ -48,6 +68,16 @@ jobs:
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: Config yarn cache
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
- uses: actions/cache@v1
|
||||
id: yarn-cache
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
- name: build
|
||||
run: |
|
||||
yarn install --frozen-lockfile
|
||||
@@ -65,6 +95,16 @@ jobs:
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: Config yarn cache
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
- uses: actions/cache@v1
|
||||
id: yarn-cache
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
- name: build
|
||||
run: |
|
||||
yarn install --frozen-lockfile
|
||||
|
||||
@@ -20,6 +20,16 @@ jobs:
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: Config yarn cache
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
- uses: actions/cache@v1
|
||||
id: yarn-cache
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
- name: build
|
||||
env:
|
||||
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
||||
@@ -44,6 +54,16 @@ jobs:
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: Config yarn cache
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
- uses: actions/cache@v1
|
||||
id: yarn-cache
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
- name: build
|
||||
env:
|
||||
GH_PAT: ${{ secrets.GH_PAT }}
|
||||
|
||||
+9
-1
@@ -1,3 +1,11 @@
|
||||
# 1.3.1 Feb 18, 2020
|
||||
|
||||
- Add `@types/bn.js` as a normal dependency, exposed in `*.d.ts` ((Thanks to https://github.com/monitz87)
|
||||
- Type generation scripts (including `polkadot-types-from-{chain,defs}`) has been moved to the `@polkadot/typegen` package
|
||||
- The `@polkadot/types/codec/create` has been moved to `@polkadot/types/create`, imports from `@polkadot/types` are unaffected
|
||||
- Expose chain properies on registry (and use for API type formatting)
|
||||
- Add `toHuman(isExtended?: boolean)` to all codec types, formatting into a human-readable structure
|
||||
|
||||
# 1.2.1 Feb 16, 2020
|
||||
|
||||
- **Important** Update RPC status codes (latest Substrate 2), with the `isInBlock` (`isFinalized` now indicates finality)
|
||||
@@ -11,7 +19,7 @@
|
||||
- Applied the latest types for Polkadot parachains
|
||||
- `registry.findMetaError` now can take in a `DispatchErrorModule` object for error lookups (from `asModule` in `DispatchError`)
|
||||
- Metadata now correctly serializes to the original input data via `toHex()` & `toU8a()`
|
||||
- Metadata dcocumentation generation rework, including the output of errors from metadata
|
||||
- Metadata documentation generation rework, including the output of errors from metadata
|
||||
- Update all examples and comments to use latest `system.account` queries (instead of `system.accountNonce` and `balances.freeBalance`/`balances.reservedBalance`)
|
||||
- Cleanup `codec/Date` tests to make it run properly on all timezones
|
||||
- Add explicit dependencies to all packages and move TypeScript `@types/*` to dev deps
|
||||
|
||||
@@ -27,7 +27,7 @@ The API is split up into a number of internal packages -
|
||||
|
||||
Type definitions for interfaces as exposed by Polkadot & Substrate clients -
|
||||
|
||||
- [@polkadot/jsonrpc](packages/type-jsonrpc/) Definitions for JSONRPC endpoints
|
||||
- [@polkadot/jsonrpc](packages/jsonrpc/) Definitions for JSONRPC endpoints
|
||||
- [@polkadot/types](packages/types/) Codecs for all Polkadot and Substrate primitives
|
||||
|
||||
## development
|
||||
|
||||
+1
-3
@@ -1,3 +1 @@
|
||||
module.exports = {
|
||||
extends: '@polkadot/dev/config/babel'
|
||||
};
|
||||
module.exports = require('@polkadot/dev/config/babel');
|
||||
|
||||
+3
-1
@@ -36,6 +36,8 @@ The length for this transaction validity is set to 50 blocks, which translates t
|
||||
|
||||
## My chain does not support system.account queries
|
||||
|
||||
The API always tracks the latest Substrate master in terms of examples. This means that nonce & balance queries are done via the `api.query.system.account(<account>)` which returns a Tuple `(Index, AccountData)` where the first is the nonce, the second a struct containing the free and reserved balances. As with all `api.query.*` endpoint, this is decorated based on what the chain you connect to support.
|
||||
The API always tracks the latest Substrate master in terms of examples. This means that nonce & balance queries are done via the `api.query.system.account(<account>)` which returns a Tuple `(Index, AccountData)` where the first is the nonce, the second a struct containing the free and reserved balances. As with all `api.query.*` endpoints, this is decorated based on what the chain you connect to support, via the metadata exchange.
|
||||
|
||||
It is possible that you are connecting to an older chain that has not been upgraded yet. For these chains, this storage entry won't be available (yet). To query the nonce on older chains, you can do a query to `api.query.system.accountNonce(<account>)` and balances can be retrieved via `api.query.balances.freeBalance(<account>)`.
|
||||
|
||||
Likewise, if your chain has been upgraded recently and you are still using the old `system.accountNonce` or `balances.freeBalance` queries in your code (which is now not available in the chain metadata), you need to update it to query the new location.
|
||||
|
||||
@@ -28,7 +28,7 @@ The result for this call (we will deal with subscriptions in a short while), is
|
||||
|
||||
Despite the single-line format of `signAndSend`, there is a lot happening under the hood (and all of this can be manually provided) -
|
||||
|
||||
- Based on the sender, the API will retrieve the `system.accountNonce` to determine the next nonce to use
|
||||
- Based on the sender, the API will query `system.account` (or `system.accountNonce` on older chains) to determine the next nonce to use
|
||||
- The API will retrieve the current block hash and use it to create a mortal transaction, i.e. the transaction will only be valid for a limited number of blocks (by default this is 5 mins at 6s block times)
|
||||
- It will construct a payload and sign this, this includes the `genesisHash`, the `blockHash` for the start of the mortal era as well as the current chain `specVersion`
|
||||
- The transaction is submitted to the node
|
||||
|
||||
@@ -68,6 +68,12 @@ await api.isReady;
|
||||
console.log(api.genesisHash.toHex());
|
||||
```
|
||||
|
||||
## Failures
|
||||
|
||||
In all cases the API will handle reconnections automatically. This means that when you connect and the endpoint is not (yet) ready, the promise will not resolve immediately, but rather when connected. The same applies to when connection is lost, the API will manage re-connections.
|
||||
|
||||
In cases where the API does not support the chain being connected to, such as it using an unknown metadata version, the ready promise will fail to resolve and instead reject.
|
||||
|
||||
## Advanced creation
|
||||
|
||||
There are more advanced cases where you would prefer to use the longer version, for instance: if you want to explicitly listen to events emitted, you probably want to attach to the API even before connecting to the chain. All API instances implement an `EventEmitter` interface, with `on` handlers, which emit `connected`, `disconnected`, `ready` and `error` events, allowing you to listen to events on the transport layer.
|
||||
|
||||
+2
-2
@@ -7,19 +7,19 @@ 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/jsonrpc(.*)$': '<rootDir>/packages/type-jsonrpc/src/$1',
|
||||
'@polkadot/types(.*)$': '<rootDir>/packages/types/src/$1'
|
||||
},
|
||||
modulePathIgnorePatterns: [
|
||||
'<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/type-jsonrpc/build',
|
||||
'<rootDir>/packages/types/build'
|
||||
],
|
||||
globals: {
|
||||
|
||||
+1
-1
@@ -9,5 +9,5 @@
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "1.2.1"
|
||||
"version": "1.3.1"
|
||||
}
|
||||
|
||||
+8
-8
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "1.2.1",
|
||||
"version": "1.3.1",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"yarn": "^1.10.1"
|
||||
@@ -11,11 +11,10 @@
|
||||
"typescript": "^3.7.5"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn build:interfaces && polkadot-dev-build-ts",
|
||||
"build:interfaces": "node packages/types/src/scripts/interfacesTsWrapper.js",
|
||||
"circular": "madge --circular --extensions ts ./",
|
||||
"docs": "node packages/types/src/scripts/MetadataMdWrapper.js && polkadot-dev-build-docs",
|
||||
"chain:info": "node packages/types/src/scripts/extractChainWrapper.js",
|
||||
"build": "yarn build:interfaces && polkadot-dev-build-ts && (cd packages/typegen && copyfiles scripts/* build)",
|
||||
"build:interfaces": "polkadot-types-internal-interfaces",
|
||||
"docs": "polkadot-types-internal-metadata && polkadot-dev-build-docs",
|
||||
"chain:info": "polkadot-types-chain-info",
|
||||
"lint": "polkadot-dev-run-lint",
|
||||
"clean": "polkadot-dev-clean-build",
|
||||
"postinstall": "polkadot-dev-yarn-only",
|
||||
@@ -27,7 +26,8 @@
|
||||
"@babel/core": "^7.8.4",
|
||||
"@babel/register": "^7.8.3",
|
||||
"@babel/runtime": "^7.8.4",
|
||||
"@polkadot/dev": "^0.40.16",
|
||||
"@polkadot/ts": "^0.2.3"
|
||||
"@polkadot/dev": "^0.40.18",
|
||||
"@polkadot/ts": "^0.2.3",
|
||||
"copyfiles": "^2.2.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-contract",
|
||||
"version": "1.2.1",
|
||||
"version": "1.3.1",
|
||||
"description": "Interfaces for interacting with contracts and contract ABIs",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,10 +27,10 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.4",
|
||||
"@polkadot/api": "^1.2.1",
|
||||
"@polkadot/rpc-core": "^1.2.1",
|
||||
"@polkadot/types": "^1.2.1",
|
||||
"@polkadot/util": "^2.3.1",
|
||||
"@polkadot/api": "^1.3.1",
|
||||
"@polkadot/rpc-core": "^1.3.1",
|
||||
"@polkadot/types": "^1.3.1",
|
||||
"@polkadot/util": "^2.4.1",
|
||||
"bn.js": "^5.1.1",
|
||||
"rxjs": "^6.5.4"
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiTypes, DecorateMethod, SubmittableResultImpl } from '@polkadot/api/types';
|
||||
import { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import { AccountId, Address, Hash } from '@polkadot/types/interfaces';
|
||||
import { IKeyringPair } from '@polkadot/types/types';
|
||||
import { IKeyringPair, ISubmittableResult } from '@polkadot/types/types';
|
||||
import { ApiObject, ContractABIPre } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
@@ -27,7 +27,7 @@ export interface BlueprintCreate<ApiType extends ApiTypes> {
|
||||
class BlueprintCreateResult<ApiType extends ApiTypes> extends SubmittableResult {
|
||||
public readonly contract?: Contract<ApiType>;
|
||||
|
||||
constructor (result: SubmittableResultImpl, contract?: Contract<ApiType>) {
|
||||
constructor (result: ISubmittableResult, contract?: Contract<ApiType>) {
|
||||
super(result);
|
||||
|
||||
this.contract = contract;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiTypes, DecorateMethod, SubmittableResultImpl } from '@polkadot/api/types';
|
||||
import { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import { AccountId, Address, Hash } from '@polkadot/types/interfaces';
|
||||
import { IKeyringPair } from '@polkadot/types/types';
|
||||
import { IKeyringPair, ISubmittableResult } from '@polkadot/types/types';
|
||||
import { ApiObject, ContractABIPre } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
@@ -27,7 +27,7 @@ export interface CodePutCode<ApiType extends ApiTypes> {
|
||||
class CodePutCodeResult<ApiType extends ApiTypes> extends SubmittableResult {
|
||||
public readonly blueprint?: Blueprint<ApiType>;
|
||||
|
||||
constructor (result: SubmittableResultImpl, blueprint?: Blueprint<ApiType>) {
|
||||
constructor (result: ISubmittableResult, blueprint?: Blueprint<ApiType>) {
|
||||
super(result);
|
||||
|
||||
this.blueprint = blueprint;
|
||||
@@ -55,7 +55,7 @@ export default class Code<ApiType extends ApiTypes> extends BaseWithTx<ApiType>
|
||||
};
|
||||
}
|
||||
|
||||
private createResult = (result: SubmittableResultImpl): CodePutCodeResult<ApiType> => {
|
||||
private createResult = (result: ISubmittableResult): CodePutCodeResult<ApiType> => {
|
||||
let blueprint: Blueprint<ApiType> | undefined;
|
||||
|
||||
if (result.isInBlock) {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import { AccountId, Address, ContractExecResult } from '@polkadot/types/interfaces';
|
||||
import { Codec, CodecArg } from '@polkadot/types/types';
|
||||
import { MetaRegistryJson, StringIndex, TypeIndex, TypeDef } from '@polkadot/types/codec/create/types';
|
||||
import { MetaRegistryJson, StringIndex, TypeIndex, TypeDef } from '@polkadot/types/create/types';
|
||||
|
||||
// import { Observable } from 'rxjs';
|
||||
import { ApiPromise, ApiRx } from '@polkadot/api';
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
|
||||
import { Codec, Registry, TypeDefInfo, TypeDef } from '@polkadot/types/types';
|
||||
|
||||
import { Option, Raw, createClass } from '@polkadot/types';
|
||||
import { createTypeUnsafe } from '@polkadot/types/codec';
|
||||
import { Option, Raw, createClass, createTypeUnsafe } from '@polkadot/types';
|
||||
|
||||
export function formatData (registry: Registry, data: Raw, { info, type }: TypeDef): Codec {
|
||||
if (info === TypeDefInfo.Option) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-derive",
|
||||
"version": "1.2.1",
|
||||
"version": "1.3.1",
|
||||
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -28,17 +28,17 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.4",
|
||||
"@polkadot/api": "^1.2.1",
|
||||
"@polkadot/rpc-core": "^1.2.1",
|
||||
"@polkadot/rpc-provider": "^1.2.1",
|
||||
"@polkadot/types": "^1.2.1",
|
||||
"@polkadot/util": "^2.3.1",
|
||||
"@polkadot/util-crypto": "^2.3.1",
|
||||
"@polkadot/api": "^1.3.1",
|
||||
"@polkadot/rpc-core": "^1.3.1",
|
||||
"@polkadot/rpc-provider": "^1.3.1",
|
||||
"@polkadot/types": "^1.3.1",
|
||||
"@polkadot/util": "^2.4.1",
|
||||
"@polkadot/util-crypto": "^2.4.1",
|
||||
"bn.js": "^5.1.1",
|
||||
"memoizee": "^0.4.14",
|
||||
"rxjs": "^6.5.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^2.3.1"
|
||||
"@polkadot/keyring": "^2.4.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +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 { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { AccountId, Exposure, Keys, Nominations, RewardDestination, ValidatorPrefs } from '@polkadot/types/interfaces';
|
||||
import { DerivedStakingStash } from '../types';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Option } from '@polkadot/types';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type Result = [Option<AccountId>, Nominations, RewardDestination, Exposure, ValidatorPrefs, Option<Keys>];
|
||||
|
||||
function parse (stashId: AccountId, [_controllerId, nominators, rewardDestination, stakers, validatorPrefs, _nextKeys]: Result): DerivedStakingStash {
|
||||
return {
|
||||
controllerId: _controllerId.unwrapOr(undefined),
|
||||
nextKeys: _nextKeys.unwrapOr(undefined),
|
||||
nominators: nominators.targets,
|
||||
nominateAt: nominators.submittedIn,
|
||||
rewardDestination,
|
||||
stakers,
|
||||
stashId,
|
||||
validatorPrefs
|
||||
};
|
||||
}
|
||||
|
||||
function query (api: ApiInterfaceRx, stashId: AccountId): Observable<Result> {
|
||||
return api.queryMulti<Result>([
|
||||
[api.query.staking.bonded, stashId],
|
||||
[api.query.staking.nominators, stashId],
|
||||
[api.query.staking.payee, stashId],
|
||||
[api.query.staking.stakers, stashId],
|
||||
[api.query.staking.validators, stashId],
|
||||
[api.query.session.nextKeys, [api.consts.session.dedupKeyPrefix, stashId]]
|
||||
]);
|
||||
}
|
||||
|
||||
export function infoStash (api: ApiInterfaceRx): (stashId: AccountId) => Observable<DerivedStakingStash> {
|
||||
return memo((stashId: AccountId): Observable<DerivedStakingStash> =>
|
||||
query(api, stashId).pipe(
|
||||
map((result): DerivedStakingStash => parse(stashId, result))
|
||||
));
|
||||
}
|
||||
+10
-10
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api",
|
||||
"version": "1.2.1",
|
||||
"version": "1.3.1",
|
||||
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,19 +27,19 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.4",
|
||||
"@polkadot/api-derive": "^1.2.1",
|
||||
"@polkadot/keyring": "^2.3.1",
|
||||
"@polkadot/metadata": "^1.2.1",
|
||||
"@polkadot/rpc-core": "^1.2.1",
|
||||
"@polkadot/rpc-provider": "^1.2.1",
|
||||
"@polkadot/types": "^1.2.1",
|
||||
"@polkadot/util": "^2.3.1",
|
||||
"@polkadot/util-crypto": "^2.3.1",
|
||||
"@polkadot/api-derive": "^1.3.1",
|
||||
"@polkadot/keyring": "^2.4.1",
|
||||
"@polkadot/metadata": "^1.3.1",
|
||||
"@polkadot/rpc-core": "^1.3.1",
|
||||
"@polkadot/rpc-provider": "^1.3.1",
|
||||
"@polkadot/types": "^1.3.1",
|
||||
"@polkadot/util": "^2.4.1",
|
||||
"@polkadot/util-crypto": "^2.4.1",
|
||||
"bn.js": "^5.1.1",
|
||||
"eventemitter3": "^4.0.0",
|
||||
"rxjs": "^6.5.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^2.3.1"
|
||||
"@polkadot/keyring": "^2.4.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,11 @@ import { SignedBlock } from '@polkadot/types/interfaces';
|
||||
import { ApiBase, ApiOptions, ApiTypes, DecorateMethod } from '../types';
|
||||
|
||||
import DecoratedMeta from '@polkadot/metadata/Decorated';
|
||||
import { Metadata, u32 as U32 } from '@polkadot/types';
|
||||
import { Metadata } from '@polkadot/types';
|
||||
import { getChainTypes, getMetadataTypes } from '@polkadot/types/known';
|
||||
import { LATEST_EXTRINSIC_VERSION } from '@polkadot/types/primitive/Extrinsic/Extrinsic';
|
||||
import { logger } from '@polkadot/util';
|
||||
import { cryptoWaitReady, setSS58Format } from '@polkadot/util-crypto';
|
||||
import addressDefaults from '@polkadot/util-crypto/address/defaults';
|
||||
import { cryptoWaitReady } from '@polkadot/util-crypto';
|
||||
|
||||
import Decorate from './Decorate';
|
||||
|
||||
@@ -73,6 +72,7 @@ export default abstract class Init<ApiType extends ApiTypes> extends Decorate<Ap
|
||||
this._extrinsicType = source.extrinsicVersion;
|
||||
this._runtimeVersion = source.runtimeVersion;
|
||||
this._genesisHash = source.genesisHash;
|
||||
this.registry.setChainProperties(source.registry.getChainProperties());
|
||||
|
||||
const methods: string[] = [];
|
||||
|
||||
@@ -100,6 +100,7 @@ export default abstract class Init<ApiType extends ApiTypes> extends Decorate<Ap
|
||||
|
||||
// based on the node spec & chain, inject specific type overrides
|
||||
this.registerTypes(getChainTypes(chain, runtimeVersion, typesChain, typesSpec));
|
||||
this.registry.setChainProperties(chainProps);
|
||||
|
||||
// filter the RPC methods (this does an rpc-methods call)
|
||||
await this.filterRpc();
|
||||
@@ -114,9 +115,6 @@ export default abstract class Init<ApiType extends ApiTypes> extends Decorate<Ap
|
||||
this._genesisHash = genesisHash;
|
||||
this._runtimeVersion = runtimeVersion;
|
||||
|
||||
// set the global ss58Format as detected by the chain
|
||||
setSS58Format(chainProps.ss58Format.unwrapOr(new U32(this.registry, addressDefaults.prefix)).toNumber());
|
||||
|
||||
// get unique types & validate
|
||||
metadata.getUniqTypes(false);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import { IExtrinsic, IMethod } from '@polkadot/types/types';
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import { HeaderExtended } from '@polkadot/api-derive';
|
||||
import testKeyring, { TestKeyringMap } from '@polkadot/keyring/testingPairs';
|
||||
import { createType, createTypeUnsafe, TypeRegistry } from '@polkadot/types/codec';
|
||||
import { createType, createTypeUnsafe, TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import { SubmittableResult } from './';
|
||||
|
||||
|
||||
@@ -4,13 +4,8 @@
|
||||
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
// eslint-disable-next-line no-useless-catch
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
detectPackage(require('./package.json'), __dirname);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
detectPackage(require('./package.json'), __dirname);
|
||||
|
||||
export { Keyring } from '@polkadot/keyring';
|
||||
export { WsProvider } from '@polkadot/rpc-provider';
|
||||
|
||||
@@ -17,7 +17,8 @@ describe('ApiPromise', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
const keyring = testKeyring({ type: 'ed25519' });
|
||||
const aliceEd = keyring.addPair(
|
||||
createPair('ed25519', {
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
createPair({ toSS58: keyring.encodeAddress, type: 'ed25519' }, {
|
||||
secretKey: hexToU8a('0xabf8e5bdbe30c65656c0a3cbd181ff8a56294a69dfedd27982aace4a7690911588dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee'),
|
||||
publicKey: hexToU8a('0x88dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee')
|
||||
})
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ExtrinsicStatus, EventRecord } from '@polkadot/types/interfaces';
|
||||
import { SubmittableResultImpl, SubmittableResultValue } from './types';
|
||||
import { ISubmittableResult } from '@polkadot/types/types';
|
||||
import { SubmittableResultValue } from './types';
|
||||
|
||||
export default class SubmittableResult implements SubmittableResultImpl {
|
||||
export default class SubmittableResult implements ISubmittableResult {
|
||||
public readonly events: EventRecord[];
|
||||
|
||||
public readonly status: ExtrinsicStatus;
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountData, Address, Call, ExtrinsicEra, ExtrinsicStatus, Hash, Header, Index, RuntimeDispatchInfo } from '@polkadot/types/interfaces';
|
||||
import { Callback, Codec, Constructor, IKeyringPair, ITuple, Registry, SignatureOptions } from '@polkadot/types/types';
|
||||
import { Callback, Codec, Constructor, IKeyringPair, ITuple, Registry, SignatureOptions, ISubmittableResult } from '@polkadot/types/types';
|
||||
import { ApiInterfaceRx, ApiTypes, SignerResult } from '../types';
|
||||
import { AddressOrPair, SignerOptions, SubmittableExtrinsic, SubmittablePaymentResult, SubmittableResultImpl, SubmittableResultResult, SubmittableResultSubscription, SubmittableThis } from './types';
|
||||
import { AddressOrPair, SignerOptions, SubmittableExtrinsic, SubmittablePaymentResult, SubmittableResultResult, SubmittableResultSubscription, SubmittableThis } from './types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { first, map, mapTo, mergeMap, switchMap, tap } from 'rxjs/operators';
|
||||
@@ -93,20 +93,20 @@ export default function createClass <ApiType extends ApiTypes> ({ api, apiType,
|
||||
public signAndSend (account: AddressOrPair, options?: Partial<SignerOptions>): SubmittableResultResult<ApiType>;
|
||||
|
||||
// signAndSend with a subscription, i.e. callback provided
|
||||
public signAndSend (account: AddressOrPair, statusCb: Callback<SubmittableResultImpl>): SubmittableResultSubscription<ApiType>;
|
||||
public signAndSend (account: AddressOrPair, statusCb: Callback<ISubmittableResult>): SubmittableResultSubscription<ApiType>;
|
||||
|
||||
// signAndSend with options and a callback
|
||||
public signAndSend (account: AddressOrPair, options: Partial<SignerOptions>, statusCb?: Callback<SubmittableResultImpl>): SubmittableResultSubscription<ApiType>;
|
||||
public signAndSend (account: AddressOrPair, options: Partial<SignerOptions>, statusCb?: Callback<ISubmittableResult>): SubmittableResultSubscription<ApiType>;
|
||||
|
||||
// signAndSend implementation for all 3 cases above
|
||||
public signAndSend (account: AddressOrPair, optionsOrStatus?: Partial<SignerOptions> | Callback<SubmittableResultImpl>, optionalStatusCb?: Callback<SubmittableResultImpl>): SubmittableResultResult<ApiType> | SubmittableResultSubscription<ApiType> {
|
||||
public signAndSend (account: AddressOrPair, optionsOrStatus?: Partial<SignerOptions> | Callback<ISubmittableResult>, optionalStatusCb?: Callback<ISubmittableResult>): SubmittableResultResult<ApiType> | SubmittableResultSubscription<ApiType> {
|
||||
const [options, statusCb] = this._makeSignAndSendOptions(optionsOrStatus, optionalStatusCb);
|
||||
const isSubscription = this._api.hasSubscriptions && (this._ignoreStatusCb || !!statusCb);
|
||||
|
||||
return this._decorateMethod(
|
||||
(): Observable<Codec> => (
|
||||
this._signObservable(account, options).pipe(
|
||||
switchMap((updateId: number | undefined): Observable<SubmittableResultImpl> | Observable<Hash> =>
|
||||
switchMap((updateId: number | undefined): Observable<ISubmittableResult> | Observable<Hash> =>
|
||||
isSubscription
|
||||
? this._subscribeObservable(updateId)
|
||||
: this._sendObservable(updateId)
|
||||
@@ -119,10 +119,10 @@ export default function createClass <ApiType extends ApiTypes> ({ api, apiType,
|
||||
public send (): SubmittableResultResult<ApiType>;
|
||||
|
||||
// send with a status callback
|
||||
public send (statusCb: Callback<SubmittableResultImpl>): SubmittableResultSubscription<ApiType>;
|
||||
public send (statusCb: Callback<ISubmittableResult>): SubmittableResultSubscription<ApiType>;
|
||||
|
||||
// send implementation for both immediate Hash and statusCb variants
|
||||
public send (statusCb?: Callback<SubmittableResultImpl>): SubmittableResultResult<ApiType> | SubmittableResultSubscription<ApiType> {
|
||||
public send (statusCb?: Callback<ISubmittableResult>): SubmittableResultResult<ApiType> | SubmittableResultSubscription<ApiType> {
|
||||
const isSubscription = this._api.hasSubscriptions && (this._ignoreStatusCb || !!statusCb);
|
||||
|
||||
return this._decorateMethod(
|
||||
@@ -132,7 +132,7 @@ export default function createClass <ApiType extends ApiTypes> ({ api, apiType,
|
||||
)(statusCb);
|
||||
}
|
||||
|
||||
private _makeSignAndSendOptions (optionsOrStatus?: Partial<SignerOptions> | Callback<SubmittableResultImpl>, statusCb?: Callback<SubmittableResultImpl>): [Partial<SignerOptions>, Callback<SubmittableResultImpl>?] {
|
||||
private _makeSignAndSendOptions (optionsOrStatus?: Partial<SignerOptions> | Callback<ISubmittableResult>, statusCb?: Callback<ISubmittableResult>): [Partial<SignerOptions>, Callback<ISubmittableResult>?] {
|
||||
let options: Partial<SignerOptions> = {};
|
||||
|
||||
if (isFunction(optionsOrStatus)) {
|
||||
@@ -249,13 +249,13 @@ export default function createClass <ApiType extends ApiTypes> ({ api, apiType,
|
||||
]);
|
||||
}
|
||||
|
||||
private _updateSigner (updateId: number, status: Hash | SubmittableResultImpl): void {
|
||||
private _updateSigner (updateId: number, status: Hash | ISubmittableResult): void {
|
||||
if ((updateId !== -1) && this._api.signer && this._api.signer.update) {
|
||||
this._api.signer.update(updateId, status);
|
||||
}
|
||||
}
|
||||
|
||||
private _statusObservable (status: ExtrinsicStatus): Observable<SubmittableResultImpl> {
|
||||
private _statusObservable (status: ExtrinsicStatus): Observable<ISubmittableResult> {
|
||||
if (!status.isFinalized && !status.isInBlock) {
|
||||
return of(new SubmittableResult({ status }));
|
||||
}
|
||||
@@ -268,7 +268,7 @@ export default function createClass <ApiType extends ApiTypes> ({ api, apiType,
|
||||
this._api.rpc.chain.getBlock(blockHash),
|
||||
this._api.query.system.events.at(blockHash)
|
||||
]).pipe(
|
||||
map(([signedBlock, allEvents]): SubmittableResultImpl =>
|
||||
map(([signedBlock, allEvents]): ISubmittableResult =>
|
||||
new SubmittableResult({
|
||||
events: filterEvents(this.hash, signedBlock, allEvents),
|
||||
status
|
||||
@@ -287,11 +287,11 @@ export default function createClass <ApiType extends ApiTypes> ({ api, apiType,
|
||||
);
|
||||
}
|
||||
|
||||
private _subscribeObservable = (updateId = -1): Observable<SubmittableResultImpl> => {
|
||||
private _subscribeObservable = (updateId = -1): Observable<ISubmittableResult> => {
|
||||
return this._api.rpc.author
|
||||
.submitAndWatchExtrinsic(this)
|
||||
.pipe(
|
||||
switchMap((status): Observable<SubmittableResultImpl> =>
|
||||
switchMap((status): Observable<ISubmittableResult> =>
|
||||
this._statusObservable(status)
|
||||
),
|
||||
tap((status): void => {
|
||||
|
||||
@@ -3,23 +3,11 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId, Address, ExtrinsicStatus, EventRecord, Hash, RuntimeDispatchInfo } from '@polkadot/types/interfaces';
|
||||
import { AnyNumber, AnyU8a, Callback, Codec, IExtrinsic, IExtrinsicEra, IKeyringPair, SignatureOptions } from '@polkadot/types/types';
|
||||
import { ApiTypes, Signer } from '../types';
|
||||
import { AnyNumber, AnyU8a, Callback, Codec, IExtrinsic, IExtrinsicEra, IKeyringPair, SignatureOptions, Signer, ISubmittableResult } from '@polkadot/types/types';
|
||||
import { ApiTypes } from '../types';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
export interface SubmittableResultImpl {
|
||||
readonly events: EventRecord[];
|
||||
readonly status: ExtrinsicStatus;
|
||||
readonly isCompleted: boolean;
|
||||
readonly isError: boolean;
|
||||
readonly isFinalized: boolean;
|
||||
readonly isInBlock: boolean;
|
||||
|
||||
filterRecords (section: string, method: string): EventRecord[];
|
||||
findRecord (section: string, method: string): EventRecord | undefined;
|
||||
}
|
||||
|
||||
export interface SubmittableResultValue {
|
||||
events?: EventRecord[];
|
||||
status: ExtrinsicStatus;
|
||||
@@ -32,12 +20,12 @@ export type SubmittablePaymentResult<ApiType extends ApiTypes> =
|
||||
|
||||
export type SubmittableResultResult<ApiType extends ApiTypes> =
|
||||
ApiType extends 'rxjs'
|
||||
? Observable<SubmittableResultImpl>
|
||||
? Observable<ISubmittableResult>
|
||||
: Promise<Hash>;
|
||||
|
||||
export type SubmittableResultSubscription<ApiType extends ApiTypes> =
|
||||
ApiType extends 'rxjs'
|
||||
? Observable<SubmittableResultImpl>
|
||||
? Observable<ISubmittableResult>
|
||||
: Promise<() => void>;
|
||||
|
||||
export type SubmittableThis<ApiType extends ApiTypes, THIS> =
|
||||
@@ -60,7 +48,7 @@ export interface SubmittableExtrinsic<ApiType extends ApiTypes> extends IExtrins
|
||||
|
||||
send(): SubmittableResultResult<ApiType>;
|
||||
|
||||
send(statusCb: Callback<SubmittableResultImpl>): SubmittableResultSubscription<ApiType>;
|
||||
send(statusCb: Callback<ISubmittableResult>): SubmittableResultSubscription<ApiType>;
|
||||
|
||||
sign(account: IKeyringPair, _options: Partial<SignatureOptions>): this;
|
||||
|
||||
@@ -68,7 +56,7 @@ export interface SubmittableExtrinsic<ApiType extends ApiTypes> extends IExtrins
|
||||
|
||||
signAndSend(account: AddressOrPair, options?: Partial<SignerOptions>): SubmittableResultResult<ApiType>;
|
||||
|
||||
signAndSend(account: AddressOrPair, statusCb: Callback<SubmittableResultImpl>): SubmittableResultSubscription<ApiType>;
|
||||
signAndSend(account: AddressOrPair, statusCb: Callback<ISubmittableResult>): SubmittableResultSubscription<ApiType>;
|
||||
|
||||
signAndSend(account: AddressOrPair, options: Partial<SignerOptions>, statusCb?: Callback<SubmittableResultImpl>): SubmittableResultSubscription<ApiType>;
|
||||
signAndSend(account: AddressOrPair, options: Partial<SignerOptions>, statusCb?: Callback<ISubmittableResult>): SubmittableResultSubscription<ApiType>;
|
||||
}
|
||||
|
||||
@@ -11,10 +11,9 @@ import { Constants } from '@polkadot/metadata/Decorated/types';
|
||||
import { RpcInterface, UserRpc } from '@polkadot/rpc-core/types';
|
||||
import { Metadata } from '@polkadot/types';
|
||||
import { Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import { RegistryTypes, SignatureOptions, SignerPayloadJSON, SignerPayloadRaw, Registry } from '@polkadot/types/types';
|
||||
import { RegistryTypes, Signer, SignerResult, SignatureOptions, Registry } from '@polkadot/types/types';
|
||||
|
||||
import ApiBase from '../base';
|
||||
import { SubmittableResultImpl } from '../submittable/types';
|
||||
import { DeriveAllSections } from '../util/decorate';
|
||||
import { DecoratedRpc } from './rpc';
|
||||
import { QueryableStorage, QueryableStorageMulti } from './storage';
|
||||
@@ -98,33 +97,4 @@ export interface SignerOptions extends SignatureOptions {
|
||||
genesisHash: Hash;
|
||||
}
|
||||
|
||||
export interface SignerResult {
|
||||
/**
|
||||
* @description The id for this request
|
||||
*/
|
||||
id: number;
|
||||
|
||||
/**
|
||||
* @description The resulting signature in hex
|
||||
*/
|
||||
signature: string;
|
||||
}
|
||||
|
||||
export interface Signer {
|
||||
/**
|
||||
* @description signs an extrinsic payload from a serialized form
|
||||
*/
|
||||
signPayload?: (payload: SignerPayloadJSON) => Promise<SignerResult>;
|
||||
|
||||
/**
|
||||
* @description signs a raw payload, only the bytes data as supplied
|
||||
*/
|
||||
signRaw?: (raw: SignerPayloadRaw) => Promise<SignerResult>;
|
||||
|
||||
/**
|
||||
* @description Receives an update for the extrinsic signed by a `signer.sign`
|
||||
*/
|
||||
update?: (id: number, status: Hash | SubmittableResultImpl) => void;
|
||||
}
|
||||
|
||||
export { ApiBase };
|
||||
export { ApiBase, Signer, SignerResult };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/jsonrpc",
|
||||
"version": "1.2.1",
|
||||
"version": "1.3.1",
|
||||
"description": "Method definitions for the Polkadot RPC layer",
|
||||
"main": "index.js",
|
||||
"publishConfig": {
|
||||
@@ -24,10 +24,10 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/polkadot-js/api/issues"
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-jsonrpc#readme",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/jsonrpc#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.4",
|
||||
"@polkadot/types": "^1.2.1",
|
||||
"@polkadot/util": "^2.3.1"
|
||||
"@polkadot/types": "^1.3.1",
|
||||
"@polkadot/util": "^2.4.1"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/metadata",
|
||||
"version": "1.2.1",
|
||||
"version": "1.3.1",
|
||||
"description": "Helpers to extract information from runtime metadata",
|
||||
"main": "index.js",
|
||||
"publishConfig": {
|
||||
@@ -27,12 +27,12 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.4",
|
||||
"@polkadot/types": "^1.2.1",
|
||||
"@polkadot/util": "^2.3.1",
|
||||
"@polkadot/util-crypto": "^2.3.1",
|
||||
"@polkadot/types": "^1.3.1",
|
||||
"@polkadot/util": "^2.4.1",
|
||||
"@polkadot/util-crypto": "^2.4.1",
|
||||
"bn.js": "^5.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^2.3.1"
|
||||
"@polkadot/keyring": "^2.4.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 { ClassOf, createType, TypeRegistry } from '@polkadot/types/codec/create';
|
||||
import { ClassOf, createType, TypeRegistry } from '@polkadot/types/create';
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
import Decorated from './Decorated';
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
import { Constants, ConstantCodec, ModuleConstants } from '../../types';
|
||||
|
||||
import { createTypeUnsafe } from '@polkadot/types/codec';
|
||||
import { createTypeUnsafe } from '@polkadot/types/create';
|
||||
import { stringCamelCase } from '@polkadot/util';
|
||||
|
||||
import Metadata from '../../../Metadata';
|
||||
|
||||
@@ -6,8 +6,8 @@ import { Call } from '@polkadot/types/interfaces';
|
||||
import { AnyJsonObject, CallFunction, Registry, RegistryMetadataCall } from '@polkadot/types/types';
|
||||
|
||||
// we do a direct import here to remove all circular dependencies (importing from
|
||||
// /types, /types/codec or /types/codec/create makes all hell break loose)
|
||||
import { createType } from '@polkadot/types/codec/create/createType';
|
||||
// /types, /types/codec or /types/create makes all hell break loose)
|
||||
import { createType } from '@polkadot/types/create/createType';
|
||||
import { assert, stringCamelCase } from '@polkadot/util';
|
||||
|
||||
/** @internal */
|
||||
|
||||
@@ -6,7 +6,8 @@ import { StorageEntryMetadataLatest } from '@polkadot/types/interfaces/metadata'
|
||||
import { Codec, Registry } from '@polkadot/types/types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Compact, Raw, createType, createTypeUnsafe } from '@polkadot/types/codec';
|
||||
import { Compact, Raw } from '@polkadot/types/codec';
|
||||
import { createType, createTypeUnsafe } from '@polkadot/types/create';
|
||||
import StorageKey, { StorageEntry } from '@polkadot/types/primitive/StorageKey';
|
||||
import { assert, compactStripLength, isNull, isUndefined, stringLowerFirst, stringToU8a, u8aConcat } from '@polkadot/util';
|
||||
import { xxhashAsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
@@ -6,7 +6,7 @@ import { StorageEntryMetadataLatest } from '@polkadot/types/interfaces/metadata'
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { StorageEntry } from '@polkadot/types/primitive/StorageKey';
|
||||
import { createType } from '@polkadot/types/codec';
|
||||
import { createType } from '@polkadot/types/create';
|
||||
|
||||
import createFunction from './createFunction';
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { MetadataAll, MetadataLatest, MetadataV0, MetadataV1, MetadataV2, MetadataV3, MetadataV4, MetadataV5, MetadataV6, MetadataV7, MetadataV8, MetadataV9, MetadataV10, MetadataV11 } from '@polkadot/types/interfaces/metadata';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { createType } from '@polkadot/types/codec/create/createType';
|
||||
import { createType } from '@polkadot/types/create/createType';
|
||||
import Struct from '@polkadot/types/codec/Struct';
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { Codec, Registry } from '@polkadot/types/types';
|
||||
import { MetadataInterface } from '../types';
|
||||
|
||||
import { createTypeUnsafe } from '@polkadot/types/codec/create';
|
||||
import { createTypeUnsafe } from '@polkadot/types/create';
|
||||
import { unwrapStorageType } from '@polkadot/types/primitive/StorageKey';
|
||||
|
||||
import getUniqTypes from './getUniqTypes';
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { MetadataLatest } from '@polkadot/types/interfaces/metadata';
|
||||
import { AnyJsonObject, Registry } from '@polkadot/types/types';
|
||||
|
||||
import { createType } from '@polkadot/types/codec';
|
||||
import { createType } from '@polkadot/types/create';
|
||||
|
||||
/** @internal */
|
||||
export default function toCallsOnly (registry: Registry, { extrinsic, modules }: MetadataLatest): AnyJsonObject | string {
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
import { TypeDef, TypeDefInfo, TypeDefExtVecFixed } from '@polkadot/types/codec/types';
|
||||
import { Registry, TypeDef, TypeDefInfo, TypeDefExtVecFixed } from '@polkadot/types/types';
|
||||
|
||||
import { getTypeDef } from '@polkadot/types/codec/create';
|
||||
import { getTypeDef } from '@polkadot/types/create';
|
||||
|
||||
import flattenUniq from './flattenUniq';
|
||||
|
||||
|
||||
@@ -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 { TypeRegistry } from '@polkadot/types/codec';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
import Metadata from '../';
|
||||
import latestSubstrateV0 from './static-substrate.json';
|
||||
|
||||
@@ -8,7 +8,8 @@ import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { stringUpperFirst } from '@polkadot/util';
|
||||
|
||||
import { createType, Option, Vec } from '@polkadot/types/codec';
|
||||
import { createType } from '@polkadot/types/create';
|
||||
import { Option, Vec } from '@polkadot/types/codec';
|
||||
import { Text } from '@polkadot/types/primitive';
|
||||
|
||||
/** @internal */
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { MetadataV1, MetadataV2 } from '@polkadot/types/interfaces/metadata';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { createType } from '@polkadot/types/codec';
|
||||
import { createType } from '@polkadot/types/create';
|
||||
|
||||
/** @internal */
|
||||
export default function toV2 (registry: Registry, metadataV1: MetadataV1): MetadataV2 {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { MetadataV10, MetadataV11 } from '@polkadot/types/interfaces/metadata';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { createType } from '@polkadot/types/codec';
|
||||
import { createType } from '@polkadot/types/create';
|
||||
|
||||
/** @internal */
|
||||
export default function toV11 (registry: Registry, { modules }: MetadataV10): MetadataV11 {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { FunctionMetadataV11, FunctionMetadataLatest, MetadataV11, MetadataLates
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { getModuleTypes } from '@polkadot/types/known';
|
||||
import { createType } from '@polkadot/types/codec';
|
||||
import { createType } from '@polkadot/types/create';
|
||||
import { Type } from '@polkadot/types/primitive';
|
||||
import { stringCamelCase } from '@polkadot/util';
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { MetadataV2, MetadataV3 } from '@polkadot/types/interfaces/metadata';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { createType } from '@polkadot/types/codec';
|
||||
import { createType } from '@polkadot/types/create';
|
||||
|
||||
/** @internal */
|
||||
export default function toV3 (registry: Registry, metadataV2: MetadataV2): MetadataV3 {
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
import { MetadataV3, MetadataV4, ModuleMetadataV4, StorageFunctionMetadataV3, StorageFunctionMetadataV4 } from '@polkadot/types/interfaces/metadata';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { createType, Option } from '@polkadot/types/codec';
|
||||
import { createType } from '@polkadot/types/create';
|
||||
import { Option } from '@polkadot/types/codec';
|
||||
|
||||
/** @internal */
|
||||
function toV4StorageFunction (registry: Registry, storageFn: StorageFunctionMetadataV3): StorageFunctionMetadataV4 {
|
||||
|
||||
@@ -7,7 +7,8 @@ import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import { createType, Option } from '@polkadot/types/codec';
|
||||
import { Option } from '@polkadot/types/codec';
|
||||
import { createType } from '@polkadot/types/create';
|
||||
import Text from '@polkadot/types/primitive/Text';
|
||||
|
||||
const hasherMap: Map<string, string> = new Map([
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { MetadataV5, MetadataV6, ModuleMetadataV6 } from '@polkadot/types/interfaces/metadata';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { createType } from '@polkadot/types/codec';
|
||||
import { createType } from '@polkadot/types/create';
|
||||
|
||||
/** @internal */
|
||||
export default function toV6 (registry: Registry, { modules }: MetadataV5): MetadataV6 {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { MetadataV6, MetadataV7, ModuleMetadataV7 } from '@polkadot/types/interfaces/metadata';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { createType } from '@polkadot/types/codec';
|
||||
import { createType } from '@polkadot/types/create';
|
||||
|
||||
/** @internal */
|
||||
export default function toV7 (registry: Registry, { modules }: MetadataV6): MetadataV7 {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { MetadataV7, MetadataV8, ModuleMetadataV8 } from '@polkadot/types/interfaces/metadata';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { createType } from '@polkadot/types/codec';
|
||||
import { createType } from '@polkadot/types/create';
|
||||
|
||||
/** @internal */
|
||||
export default function toV8 (registry: Registry, { modules }: MetadataV7): MetadataV8 {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { MetadataV8, MetadataV9 } from '@polkadot/types/interfaces/metadata';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { createType } from '@polkadot/types/codec';
|
||||
import { createType } from '@polkadot/types/create';
|
||||
|
||||
/** @internal */
|
||||
export default function toV9 (registry: Registry, { modules }: MetadataV8): MetadataV9 {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { MetadataV9, MetadataV10, ModuleMetadataV9, ModuleMetadataV10, StorageEntryMetadataV9, StorageEntryTypeV9, StorageHasherV9, StorageHasherV10 } from '@polkadot/types/interfaces/metadata';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { createType } from '@polkadot/types/codec';
|
||||
import { createType } from '@polkadot/types/create';
|
||||
|
||||
// migrate a storage hasher type
|
||||
// see https://github.com/paritytech/substrate/pull/4462
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-core",
|
||||
"version": "1.2.1",
|
||||
"version": "1.3.1",
|
||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,15 +27,15 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.4",
|
||||
"@polkadot/jsonrpc": "^1.2.1",
|
||||
"@polkadot/metadata": "^1.2.1",
|
||||
"@polkadot/rpc-provider": "^1.2.1",
|
||||
"@polkadot/types": "^1.2.1",
|
||||
"@polkadot/util": "^2.3.1",
|
||||
"@polkadot/jsonrpc": "^1.3.1",
|
||||
"@polkadot/metadata": "^1.3.1",
|
||||
"@polkadot/rpc-provider": "^1.3.1",
|
||||
"@polkadot/types": "^1.3.1",
|
||||
"@polkadot/util": "^2.4.1",
|
||||
"memoizee": "^0.4.14",
|
||||
"rxjs": "^6.5.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^2.3.1"
|
||||
"@polkadot/keyring": "^2.4.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,7 @@ import { catchError, map, publishReplay, refCount, switchMap } from 'rxjs/operat
|
||||
import jsonrpc from '@polkadot/jsonrpc';
|
||||
import jsonrpcMethod from '@polkadot/jsonrpc/create/method';
|
||||
import jsonrpcParam from '@polkadot/jsonrpc/create/param';
|
||||
import { Option, StorageKey, Vec, createClass } from '@polkadot/types';
|
||||
import { createTypeUnsafe } from '@polkadot/types/codec';
|
||||
import { Option, StorageKey, Vec, createClass, createTypeUnsafe } from '@polkadot/types';
|
||||
import { assert, isFunction, isNull, isNumber, isUndefined, logger, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { drr } from './rxjs';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-provider",
|
||||
"version": "1.2.1",
|
||||
"version": "1.3.1",
|
||||
"description": "Transport providers for the API",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,18 +27,18 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.4",
|
||||
"@polkadot/jsonrpc": "^1.2.1",
|
||||
"@polkadot/metadata": "^1.2.1",
|
||||
"@polkadot/types": "^1.2.1",
|
||||
"@polkadot/util": "^2.3.1",
|
||||
"@polkadot/util-crypto": "^2.3.1",
|
||||
"@polkadot/jsonrpc": "^1.3.1",
|
||||
"@polkadot/metadata": "^1.3.1",
|
||||
"@polkadot/types": "^1.3.1",
|
||||
"@polkadot/util": "^2.4.1",
|
||||
"@polkadot/util-crypto": "^2.4.1",
|
||||
"bn.js": "^5.1.1",
|
||||
"eventemitter3": "^4.0.0",
|
||||
"isomorphic-fetch": "^2.2.1",
|
||||
"websocket": "^1.0.31"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^2.3.1",
|
||||
"@polkadot/keyring": "^2.4.1",
|
||||
"mock-socket": "^9.0.3",
|
||||
"nock": "^11.8.2"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
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.
|
||||
@@ -0,0 +1,3 @@
|
||||
# @polkadot/typegen
|
||||
|
||||
A collection of type generation scripts, allowing the input of metadata and definitions for the creation of TS outputs.
|
||||
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"name": "@polkadot/typegen",
|
||||
"version": "1.3.1",
|
||||
"description": "Type generation scripts",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
"polkadot-types-chain-info": "./scripts/polkadot-types-chain-info.js",
|
||||
"polkadot-types-from-chain": "./scripts/polkadot-types-from-chain.js",
|
||||
"polkadot-types-from-defs": "./scripts/polkadot-types-from-defs.js",
|
||||
"polkadot-types-internal-interfaces": "./scripts/polkadot-types-internal-interfaces.js",
|
||||
"polkadot-types-internal-metadata": "./scripts/polkadot-types-internal-metadata.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/typegen#readme",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.8.3",
|
||||
"@babel/register": "^7.8.3",
|
||||
"@babel/runtime": "^7.8.4",
|
||||
"@polkadot/api": "^1.3.1",
|
||||
"@polkadot/jsonrpc": "^1.3.1",
|
||||
"@polkadot/metadata": "^1.3.1",
|
||||
"@polkadot/types": "^1.3.1",
|
||||
"@polkadot/util": "^2.4.1",
|
||||
"websocket": "^1.0.31",
|
||||
"yargs": "^15.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/yargs": "^15.0.3"
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env node
|
||||
// Copyright 2017-2020 @polkadot/typegen authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
|
||||
let main;
|
||||
|
||||
try {
|
||||
main = require('../extractChain').default;
|
||||
} catch (error) {
|
||||
require('@babel/register')({
|
||||
extensions: ['.js', '.ts'],
|
||||
plugins: [
|
||||
['module-resolver', {
|
||||
alias: {
|
||||
'^@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'
|
||||
}
|
||||
}]
|
||||
]
|
||||
});
|
||||
|
||||
main = require('../src/extractChain.ts').default;
|
||||
}
|
||||
|
||||
main();
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env node
|
||||
// Copyright 2017-2020 @polkadot/typegen authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
|
||||
let main;
|
||||
|
||||
try {
|
||||
main = require('../fromChain').default;
|
||||
} catch (error) {
|
||||
require('@babel/register')({
|
||||
extensions: ['.js', '.ts'],
|
||||
plugins: [
|
||||
['module-resolver', {
|
||||
alias: {
|
||||
'^@polkadot/metadata(.*)': './packages/metadata/src\\1',
|
||||
'^@polkadot/types(.*)': './packages/types/src\\1'
|
||||
}
|
||||
}]
|
||||
]
|
||||
});
|
||||
|
||||
main = require('../src/fromChain').default;
|
||||
}
|
||||
|
||||
main();
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env node
|
||||
// Copyright 2017-2020 @polkadot/typegen authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
|
||||
let main;
|
||||
|
||||
try {
|
||||
main = require('../fromDefs').default;
|
||||
} catch (error) {
|
||||
require('@babel/register')({
|
||||
extensions: ['.js', '.ts'],
|
||||
plugins: [
|
||||
['module-resolver', {
|
||||
alias: {
|
||||
'^@polkadot/metadata(.*)': './packages/metadata/src\\1',
|
||||
'^@polkadot/typegen(.*)': './packages/typegen/src\\1',
|
||||
'^@polkadot/types(.*)': './packages/types/src\\1'
|
||||
}
|
||||
}]
|
||||
]
|
||||
});
|
||||
|
||||
main = require('../sr/fromDefs.ts').default;
|
||||
}
|
||||
|
||||
main();
|
||||
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env node
|
||||
// Copyright 2017-2020 @polkadot/typegen authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
|
||||
let main;
|
||||
|
||||
try {
|
||||
main = require('../interfacesTs').default;
|
||||
} catch (error) {
|
||||
require('@babel/register')({
|
||||
extensions: ['.js', '.ts'],
|
||||
plugins: [
|
||||
['module-resolver', {
|
||||
alias: {
|
||||
'^@polkadot/jsonrpc(.*)': './packages/jsonrpc/src\\1',
|
||||
'^@polkadot/metadata(.*)': './packages/metadata/src\\1',
|
||||
'^@polkadot/types(.*)': './packages/types/src\\1'
|
||||
}
|
||||
}]
|
||||
]
|
||||
});
|
||||
|
||||
main = require('../src/interfacesTs.ts').default;
|
||||
}
|
||||
|
||||
main();
|
||||
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env node
|
||||
// Copyright 2017-2020 @polkadot/typegen authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
|
||||
let main;
|
||||
|
||||
try {
|
||||
main = require('../metadataMd').default;
|
||||
} catch (error) {
|
||||
require('@babel/register')({
|
||||
extensions: ['.js', '.ts'],
|
||||
plugins: [
|
||||
['module-resolver', {
|
||||
alias: {
|
||||
'^@polkadot/jsonrpc(.*)': './packages/jsonrpc/src\\1',
|
||||
'^@polkadot/metadata(.*)': './packages/metadata/src\\1',
|
||||
'^@polkadot/types(.*)': './packages/types/src\\1'
|
||||
}
|
||||
}]
|
||||
]
|
||||
});
|
||||
|
||||
main = require('../src/metadataMd.ts').default;
|
||||
}
|
||||
|
||||
main();
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/typegen authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -9,21 +9,8 @@ import process from 'process';
|
||||
import yargs from 'yargs';
|
||||
import { ApiPromise, WsProvider } from '@polkadot/api/index';
|
||||
|
||||
// retrieve and parse arguments - we do this globally, since this is a single command
|
||||
const { argv: { ws } } = yargs
|
||||
.usage('Usage: [options]')
|
||||
.wrap(120)
|
||||
.options({
|
||||
ws: {
|
||||
default: 'ws://127.0.0.1:9944',
|
||||
description: 'The API endpoint to connect to, e.g. wss://poc3-rpc.polkadot.io',
|
||||
type: 'string',
|
||||
required: true
|
||||
}
|
||||
});
|
||||
|
||||
/** @internal */
|
||||
async function main (): Promise<void> {
|
||||
async function run (ws: string): Promise<void> {
|
||||
const provider = new WsProvider(ws);
|
||||
const api = await ApiPromise.create({ provider });
|
||||
const [chain, props] = await Promise.all([
|
||||
@@ -38,11 +25,26 @@ async function main (): Promise<void> {
|
||||
api.runtimeMetadata.getUniqTypes(false);
|
||||
}
|
||||
|
||||
main()
|
||||
.then((): void => {
|
||||
process.exit(0);
|
||||
})
|
||||
.catch((error: Error) => {
|
||||
console.error('FATAL:', error.message);
|
||||
process.exit(-1);
|
||||
});
|
||||
export default function main (): void {
|
||||
// retrieve and parse arguments - we do this globally, since this is a single command
|
||||
const { ws } = yargs
|
||||
.usage('Usage: [options]')
|
||||
.wrap(120)
|
||||
.options({
|
||||
ws: {
|
||||
default: 'ws://127.0.0.1:9944',
|
||||
description: 'The API endpoint to connect to, e.g. wss://poc3-rpc.polkadot.io',
|
||||
type: 'string',
|
||||
required: true
|
||||
}
|
||||
}).argv;
|
||||
|
||||
run(ws)
|
||||
.then((): void => {
|
||||
process.exit(0);
|
||||
})
|
||||
.catch((error: Error) => {
|
||||
console.error('FATAL:', error.message);
|
||||
process.exit(-1);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
// Copyright 2017-2020 @polkadot/typegen 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 path from 'path';
|
||||
import yargs from 'yargs';
|
||||
import { formatNumber } from '@polkadot/util';
|
||||
|
||||
import generateConst from './generate/consts';
|
||||
import generateQuery from './generate/query';
|
||||
import generateTx from './generate/tx';
|
||||
|
||||
if (typeof WebSocket === 'undefined') {
|
||||
(global as any).WebSocket = require('websocket').w3cwebsocket;
|
||||
}
|
||||
|
||||
let websocket: any = null;
|
||||
|
||||
function generate (metaHex: string, pkg: string | undefined, output: string, isStrict?: boolean): void {
|
||||
console.log(`Generating from metadata, ${formatNumber((metaHex.length - 2) / 2)} bytes`);
|
||||
|
||||
const extraTypes = pkg
|
||||
? { [pkg]: require(path.join(process.cwd(), output, 'definitions')) }
|
||||
: {};
|
||||
|
||||
generateConst(path.join(process.cwd(), output, 'augment.consts.ts'), metaHex, extraTypes, isStrict);
|
||||
generateQuery(path.join(process.cwd(), output, 'augment.query.ts'), metaHex, extraTypes, isStrict);
|
||||
generateTx(path.join(process.cwd(), output, 'augment.tx.ts'), metaHex, extraTypes, isStrict);
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
function onSocketClose (event: any): void {
|
||||
console.error(`disconnected, code: '${event.code}' reason: '${event.reason}'`);
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
function onSocketError (event: any): void {
|
||||
console.error(event);
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
function onSocketOpen (): boolean {
|
||||
console.log('connected');
|
||||
|
||||
websocket.send('{"id":"1","jsonrpc":"2.0","method":"state_getMetadata","params":[]}');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export default function main (): void {
|
||||
const { endpoint, output, package: pkg, strict: isStrict } = yargs.strict().options({
|
||||
endpoint: {
|
||||
description: 'The endpoint to connect to, e.g. wss://kusama-rpc.polkadot.io or relative file to JSON output',
|
||||
type: 'string',
|
||||
required: true
|
||||
},
|
||||
output: {
|
||||
description: 'The target directory to write the data to',
|
||||
type: 'string',
|
||||
required: true
|
||||
},
|
||||
package: {
|
||||
description: 'Optional package in output location (for extra definitions)',
|
||||
type: 'string'
|
||||
},
|
||||
strict: {
|
||||
description: 'Turns on stirct mode, not outputting genric versions',
|
||||
type: 'boolean'
|
||||
}
|
||||
}).argv;
|
||||
|
||||
if (endpoint.startsWith('wss://') || endpoint.startsWith('ws://')) {
|
||||
websocket = new WebSocket(endpoint);
|
||||
websocket.onclose = onSocketClose;
|
||||
websocket.onerror = onSocketError;
|
||||
websocket.onopen = onSocketOpen;
|
||||
websocket.onmessage = (message: any): void => {
|
||||
generate(JSON.parse(message.data).result, pkg, output, isStrict);
|
||||
};
|
||||
} else {
|
||||
generate(require(path.join(process.cwd(), endpoint)).result, pkg, output, isStrict);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
// Copyright 2017-2020 @polkadot/typegen 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 path from 'path';
|
||||
import yargs from 'yargs';
|
||||
import * as substrateDefs from '@polkadot/types/interfaces/definitions';
|
||||
|
||||
import { generateInterfaceRegistry } from './generate/interfaceRegistry';
|
||||
import { generateTsDef } from './generate/tsDef';
|
||||
|
||||
export default function main (): void {
|
||||
const { input, package: pkg } = yargs.strict().options({
|
||||
input: {
|
||||
description: 'The directory to use for the user definitions',
|
||||
type: 'string',
|
||||
required: true
|
||||
},
|
||||
package: {
|
||||
description: 'The package name & path to use for the user types',
|
||||
type: 'string',
|
||||
required: true
|
||||
}
|
||||
}).argv;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const userDefs = require(path.join(process.cwd(), input, 'definitions.ts'));
|
||||
const userKeys = Object.keys(userDefs);
|
||||
const filteredBase = Object
|
||||
.entries(substrateDefs)
|
||||
.filter(([key]) => {
|
||||
if (userKeys.includes(key)) {
|
||||
console.warn(`Override found for ${key} in user types, ignoring in @polkadot/types`);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.reduce((defs: any, [key, value]) => {
|
||||
defs[key] = value;
|
||||
|
||||
return defs;
|
||||
}, {});
|
||||
|
||||
const allDefs = {
|
||||
'@polkadot/types/interfaces': filteredBase,
|
||||
[pkg]: userDefs
|
||||
};
|
||||
|
||||
generateTsDef(allDefs, path.join(process.cwd(), input), pkg);
|
||||
generateInterfaceRegistry(allDefs, path.join(process.cwd(), input, 'interfaceRegistry.ts'));
|
||||
}
|
||||
+4
-4
@@ -1,15 +1,15 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/typegen 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 { ModuleMetadataLatest } from '../../interfaces/metadata';
|
||||
import * as defaultDefs from '../../interfaces/definitions';
|
||||
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 { stringCamelCase } from '@polkadot/util';
|
||||
|
||||
import { TypeRegistry } from '../../codec';
|
||||
import { FOOTER, HEADER, TypeImports, createDocComments, createImportCode, createImports, indent, setImports, writeFile } from '../util';
|
||||
|
||||
// Generate types for one module
|
||||
+5
-4
@@ -1,10 +1,11 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/typegen 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 Raw from '../../codec/Raw';
|
||||
import * as defaultDefinitions from '../../interfaces/definitions';
|
||||
import * as defaultPrimitives from '../../primitive';
|
||||
import Raw from '@polkadot/types/codec/Raw';
|
||||
import * as defaultDefinitions from '@polkadot/types/interfaces/definitions';
|
||||
import * as defaultPrimitives from '@polkadot/types/primitive';
|
||||
|
||||
import { FOOTER, HEADER, createImportCode, createImports, getDerivedTypes, indent, setImports, writeFile } from '../util';
|
||||
|
||||
const primitiveClasses = {
|
||||
+5
-5
@@ -1,16 +1,16 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/typegen 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 { ModuleMetadataLatest, StorageEntryMetadataLatest } from '../../interfaces/metadata';
|
||||
import { Registry } from '../../types';
|
||||
import * as defaultDefs from '../../interfaces/definitions';
|
||||
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 { TypeRegistry } from '@polkadot/types/create';
|
||||
import { stringLowerFirst } from '@polkadot/util';
|
||||
|
||||
import { TypeRegistry } from '../../codec';
|
||||
import { FOOTER, HEADER, TypeImports, createDocComments, createImportCode, createImports, formatType, getSimilarTypes, indent, setImports, writeFile } from '../util';
|
||||
|
||||
// If the StorageEntry returns T, output `Option<T>` if the modifier is optional
|
||||
@@ -1,10 +1,11 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/typegen 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 '../../../../type-jsonrpc/src';
|
||||
import * as definitions from '../../interfaces/definitions';
|
||||
import { TypeRegistry } from '../../codec/create';
|
||||
import interfaces from '@polkadot/jsonrpc';
|
||||
import * as definitions from '@polkadot/types/interfaces/definitions';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
import { FOOTER, HEADER, createDocComments, createImportCode, createImports, getSimilarTypes, setImports, writeFile, indent } from '../util';
|
||||
|
||||
/** @internal */
|
||||
+4
-4
@@ -1,15 +1,15 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/typegen 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 { TypeDef, TypeDefInfo, TypeDefExtVecFixed } from '../../codec/types';
|
||||
import { TypeDef, TypeDefInfo, TypeDefExtVecFixed } 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';
|
||||
import { isString, stringCamelCase, stringUpperFirst } from '@polkadot/util';
|
||||
|
||||
import { getTypeDef } from '../../codec/create';
|
||||
import * as defaultDefinitions from '../../interfaces/definitions';
|
||||
import { FOOTER, HEADER, TypeImports, createImportCode, createImports, exportInterface, exportType, formatType, setImports, writeFile } from '../util';
|
||||
|
||||
interface Imports extends TypeImports {
|
||||
@@ -1,17 +1,17 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/typegen 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 { ModuleMetadataLatest } from '../../interfaces/metadata';
|
||||
import * as defaultDefs from '../../interfaces/definitions';
|
||||
import { Registry } from '../../types';
|
||||
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 { Text } from '@polkadot/types';
|
||||
import { Text } from '@polkadot/types/primitive';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
import { stringCamelCase } from '@polkadot/util';
|
||||
|
||||
import { TypeRegistry } from '../../codec';
|
||||
import { FOOTER, HEADER, TypeImports, createDocComments, createImportCode, createImports, formatType, getSimilarTypes, indent, setImports, writeFile } from '../util';
|
||||
|
||||
const MAPPED_NAMES: Record<string, string> = {
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/typegen authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export * from './create/types';
|
||||
export { formatType } from './util/formatting';
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/typegen authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -9,11 +9,13 @@ import generateRpcTypes from './generate/rpc';
|
||||
import generateTsDef from './generate/tsDef';
|
||||
import generateTxTypes from './generate/tx';
|
||||
|
||||
generateInterfaceRegistry();
|
||||
export default function main (): void {
|
||||
generateInterfaceRegistry();
|
||||
|
||||
generateConstsTypes();
|
||||
generateQueryTypes();
|
||||
generateTxTypes();
|
||||
generateRpcTypes();
|
||||
generateConstsTypes();
|
||||
generateQueryTypes();
|
||||
generateTxTypes();
|
||||
generateRpcTypes();
|
||||
|
||||
generateTsDef();
|
||||
generateTsDef();
|
||||
}
|
||||
@@ -1,19 +1,32 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/typegen 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 { MetadataLatest, ModuleMetadataLatest } from '../interfaces/metadata';
|
||||
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 { unwrapStorageType } from '@polkadot/types/primitive/StorageKey';
|
||||
import Call from '@polkadot/types/primitive/Generic/Call';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
import { Vec } from '@polkadot/types/codec';
|
||||
import { Text } from '@polkadot/types/primitive';
|
||||
import { stringCamelCase, stringLowerFirst } from '@polkadot/util';
|
||||
|
||||
import interfaces from '../../../type-jsonrpc/src';
|
||||
import { unwrapStorageType } from '../primitive/StorageKey';
|
||||
import Call from '../primitive/Generic/Call';
|
||||
import { TypeRegistry, Vec } from '../codec';
|
||||
import { Text } from '../primitive';
|
||||
interface Page {
|
||||
title: string;
|
||||
description: string;
|
||||
sections: {
|
||||
name: string;
|
||||
description?: string;
|
||||
items: {
|
||||
name: string;
|
||||
[bullet: string]: string | Vec<Text>;
|
||||
}[];
|
||||
}[];
|
||||
}
|
||||
|
||||
const STATIC_TEXT = '\n\n(NOTE: These were generated from a static/snapshot view of a recent Substrate master node. Some items may not be available in older nodes, or in any customized implementations.)';
|
||||
|
||||
@@ -27,10 +40,12 @@ const DESC_STORAGE = `The following sections contain Storage methods are part of
|
||||
/** @internal */
|
||||
function documentationVecToMarkdown (docLines: Vec<Text>, indent = 0): string {
|
||||
const md = docLines
|
||||
.map(docLine => docLine && docLine.substring(1)) // trim the leading space
|
||||
.map((docLine) => docLine && docLine.substring(1)) // trim the leading space
|
||||
.reduce((md, docLine): string => // generate paragraphs
|
||||
!docLine.trim().length ? `${md}\n\n` // empty line
|
||||
: /^[*-]/.test(docLine.trimStart()) && !md.endsWith('\n\n') ? `${md}\n\n${docLine}` // line calling for a preceding linebreak
|
||||
!docLine.trim().length
|
||||
? `${md}\n\n` // empty line
|
||||
: /^[*-]/.test(docLine.trimStart()) && !md.endsWith('\n\n')
|
||||
? `${md}\n\n${docLine}` // line calling for a preceding linebreak
|
||||
: `${md}${docLine // line continuing the preceding line
|
||||
.replace(/^# <weight>$/g, '\\# \\<weight>\n\n')
|
||||
.replace(/^# <\/weight>$/g, '\n\n\\# \\</weight>')
|
||||
@@ -40,19 +55,6 @@ function documentationVecToMarkdown (docLines: Vec<Text>, indent = 0): string {
|
||||
return md && md.split('\n\n').map(line => `${' '.repeat(indent)}${line}`).join('\n\n');
|
||||
}
|
||||
|
||||
interface Page {
|
||||
title: string;
|
||||
description: string;
|
||||
sections: {
|
||||
name: string;
|
||||
description?: string;
|
||||
items: {
|
||||
name: string;
|
||||
[bullet: string]: string | Vec<Text>;
|
||||
}[];
|
||||
}[];
|
||||
}
|
||||
|
||||
function renderPage (page: Page): string {
|
||||
let md = `## ${page.title}\n\n`;
|
||||
|
||||
@@ -84,16 +86,9 @@ function renderPage (page: Page): string {
|
||||
return md;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort object by their `.name`
|
||||
*/
|
||||
/** @internal */
|
||||
function sortByName<T extends { name: any }> (a: T, b: T): number {
|
||||
// ignore upper and lowercase
|
||||
const nameA = a.name.toString().toUpperCase();
|
||||
const nameB = b.name.toString().toUpperCase();
|
||||
|
||||
return nameA.localeCompare(nameB);
|
||||
// case insensitive (all-uppercase) sorting
|
||||
return a.name.toString().toUpperCase().localeCompare(b.name.toString().toUpperCase());
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
@@ -101,28 +96,32 @@ function addRpc (): string {
|
||||
return renderPage({
|
||||
title: 'JSON-RPC',
|
||||
description: DESC_RPC,
|
||||
sections: Object.keys(interfaces).sort().map(sectionName => {
|
||||
const section = interfaces[sectionName];
|
||||
sections: Object.keys(interfaces)
|
||||
.sort()
|
||||
.map((sectionName) => {
|
||||
const section = interfaces[sectionName];
|
||||
|
||||
return {
|
||||
name: sectionName,
|
||||
description: section.description,
|
||||
items: Object.keys(section.methods).sort().map(methodName => {
|
||||
const method = section.methods[methodName];
|
||||
const args = method.params.map(({ name, isOptional, type }): string => {
|
||||
return name + (isOptional ? '?' : '') + ': `' + type + '`';
|
||||
}).join(', ');
|
||||
const type = '`' + method.type + '`';
|
||||
return {
|
||||
name: sectionName,
|
||||
description: section.description,
|
||||
items: Object.keys(section.methods)
|
||||
.sort()
|
||||
.map((methodName) => {
|
||||
const method = section.methods[methodName];
|
||||
const args = method.params.map(({ name, isOptional, type }): string => {
|
||||
return name + (isOptional ? '?' : '') + ': `' + type + '`';
|
||||
}).join(', ');
|
||||
const type = '`' + method.type + '`';
|
||||
|
||||
return {
|
||||
name: `${methodName}(${args}): ${type}`,
|
||||
jsonrpc: `${sectionName}_${methodName}`,
|
||||
interface: `api.rpc.${sectionName}.${methodName}`,
|
||||
...(method.description && { summary: method.description })
|
||||
};
|
||||
})
|
||||
};
|
||||
})
|
||||
return {
|
||||
name: `${methodName}(${args}): ${type}`,
|
||||
jsonrpc: `${sectionName}_${methodName}`,
|
||||
interface: `api.rpc.${sectionName}.${methodName}`,
|
||||
...(method.description && { summary: method.description })
|
||||
};
|
||||
})
|
||||
};
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -131,56 +130,61 @@ function addConstants (metadata: MetadataLatest): string {
|
||||
return renderPage({
|
||||
title: 'Constants',
|
||||
description: DESC_CONSTANTS,
|
||||
sections: metadata.modules.sort(sortByName).filter(moduleMetadata => !moduleMetadata.constants.isEmpty).map(moduleMetadata => {
|
||||
const sectionName = stringLowerFirst(moduleMetadata.name.toString());
|
||||
sections: metadata.modules
|
||||
.sort(sortByName)
|
||||
.filter((moduleMetadata) => !moduleMetadata.constants.isEmpty)
|
||||
.map((moduleMetadata) => {
|
||||
const sectionName = stringLowerFirst(moduleMetadata.name.toString());
|
||||
|
||||
return {
|
||||
name: sectionName,
|
||||
items: moduleMetadata.constants.sort(sortByName).map(func => {
|
||||
const methodName = stringCamelCase(func.name.toString());
|
||||
return {
|
||||
name: sectionName,
|
||||
items: moduleMetadata.constants
|
||||
.sort(sortByName)
|
||||
.map((func) => {
|
||||
const methodName = stringCamelCase(func.name.toString());
|
||||
|
||||
return {
|
||||
name: `${methodName}: ` + '`' + func.type + '`',
|
||||
interface: `api.consts.${sectionName}.${methodName}`,
|
||||
...(func.documentation.length && { summary: func.documentation })
|
||||
};
|
||||
})
|
||||
};
|
||||
})
|
||||
return {
|
||||
name: `${methodName}: ` + '`' + func.type + '`',
|
||||
interface: `api.consts.${sectionName}.${methodName}`,
|
||||
...(func.documentation.length && { summary: func.documentation })
|
||||
};
|
||||
})
|
||||
};
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function addStorage (metadata: MetadataLatest): string {
|
||||
const moduleSections = metadata.modules.sort(sortByName)
|
||||
.filter(moduleMetadata => !moduleMetadata.storage.isNone)
|
||||
.map(moduleMetadata => {
|
||||
const moduleSections = metadata.modules
|
||||
.sort(sortByName)
|
||||
.filter((moduleMetadata) => !moduleMetadata.storage.isNone)
|
||||
.map((moduleMetadata) => {
|
||||
const sectionName = stringLowerFirst(moduleMetadata.name.toString());
|
||||
|
||||
return {
|
||||
name: sectionName,
|
||||
items: moduleMetadata.storage.unwrap().items.sort(sortByName).map(func => {
|
||||
const arg =
|
||||
func.type.isMap
|
||||
items: moduleMetadata.storage.unwrap().items
|
||||
.sort(sortByName)
|
||||
.map((func) => {
|
||||
const arg = func.type.isMap
|
||||
? ('`' + func.type.asMap.key.toString() + '`')
|
||||
: func.type.isDoubleMap
|
||||
? ('`' + func.type.asDoubleMap.key1.toString() + ', ' + func.type.asDoubleMap.key2.toString() + '`')
|
||||
: '';
|
||||
const methodName = stringLowerFirst(func.name.toString());
|
||||
let result = unwrapStorageType(func.type);
|
||||
|
||||
const methodName = stringLowerFirst(func.name.toString());
|
||||
if (func.modifier.isOptional) {
|
||||
result = `Option<${result}>`;
|
||||
}
|
||||
|
||||
let result = unwrapStorageType(func.type);
|
||||
|
||||
if (func.modifier.isOptional) {
|
||||
result = `Option<${result}>`;
|
||||
}
|
||||
|
||||
return {
|
||||
name: `${methodName}(${arg}): ` + '`' + result + '`',
|
||||
interface: `api.query.${sectionName}.${methodName}`,
|
||||
...(func.documentation.length && { summary: func.documentation })
|
||||
};
|
||||
})
|
||||
return {
|
||||
name: `${methodName}(${arg}): ` + '`' + result + '`',
|
||||
interface: `api.query.${sectionName}.${methodName}`,
|
||||
...(func.documentation.length && { summary: func.documentation })
|
||||
};
|
||||
})
|
||||
};
|
||||
});
|
||||
|
||||
@@ -199,23 +203,28 @@ function addExtrinsics (metadata: MetadataLatest): string {
|
||||
return renderPage({
|
||||
title: 'Extrinsics',
|
||||
description: DESC_EXTRINSICS,
|
||||
sections: metadata.modules.map((i): ModuleMetadataLatest => i).sort(sortByName).filter(meta => !meta.calls.isNone && meta.calls.unwrap().length).map(meta => {
|
||||
const sectionName = stringCamelCase(meta.name.toString());
|
||||
sections: metadata.modules
|
||||
.sort(sortByName)
|
||||
.filter((meta) => !meta.calls.isNone && meta.calls.unwrap().length)
|
||||
.map((meta) => {
|
||||
const sectionName = stringCamelCase(meta.name.toString());
|
||||
|
||||
return {
|
||||
name: sectionName,
|
||||
items: meta.calls.unwrap().sort(sortByName).map(func => {
|
||||
const methodName = stringCamelCase(func.name.toString());
|
||||
const args = Call.filterOrigin(func).map(({ name, type }): string => `${name}: ` + '`' + type + '`').join(', ');
|
||||
return {
|
||||
name: sectionName,
|
||||
items: meta.calls.unwrap()
|
||||
.sort(sortByName)
|
||||
.map((func) => {
|
||||
const methodName = stringCamelCase(func.name.toString());
|
||||
const args = Call.filterOrigin(func).map(({ name, type }): string => `${name}: ` + '`' + type + '`').join(', ');
|
||||
|
||||
return {
|
||||
name: `${methodName}(${args})`,
|
||||
interface: `api.tx.${sectionName}.${methodName}`,
|
||||
...(func.documentation.length && { summary: func.documentation })
|
||||
};
|
||||
})
|
||||
};
|
||||
})
|
||||
return {
|
||||
name: `${methodName}(${args})`,
|
||||
interface: `api.tx.${sectionName}.${methodName}`,
|
||||
...(func.documentation.length && { summary: func.documentation })
|
||||
};
|
||||
})
|
||||
};
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -224,22 +233,23 @@ function addEvents (metadata: MetadataLatest): string {
|
||||
return renderPage({
|
||||
title: 'Events',
|
||||
description: DESC_EVENTS,
|
||||
sections: metadata.modules.sort(sortByName).filter(meta => !meta.events.isNone && meta.events.unwrap().length).map(meta => {
|
||||
const sectionName = stringCamelCase(meta.name.toString());
|
||||
sections: metadata.modules
|
||||
.sort(sortByName)
|
||||
.filter((meta) => !meta.events.isNone && meta.events.unwrap().length)
|
||||
.map((meta) => ({
|
||||
name: stringCamelCase(meta.name.toString()),
|
||||
items: meta.events.unwrap()
|
||||
.sort(sortByName)
|
||||
.map((func) => {
|
||||
const methodName = func.name.toString();
|
||||
const args = func.args.map((type): string => '`' + type + '`').join(', ');
|
||||
|
||||
return {
|
||||
name: sectionName,
|
||||
items: meta.events.unwrap().sort(sortByName).map(func => {
|
||||
const methodName = func.name.toString();
|
||||
const args = func.args.map((type): string => '`' + type + '`').join(', ');
|
||||
|
||||
return {
|
||||
name: `${methodName}(${args})`,
|
||||
...(func.documentation.length && { summary: func.documentation })
|
||||
};
|
||||
})
|
||||
};
|
||||
})
|
||||
return {
|
||||
name: `${methodName}(${args})`,
|
||||
...(func.documentation.length && { summary: func.documentation })
|
||||
};
|
||||
})
|
||||
}))
|
||||
});
|
||||
}
|
||||
|
||||
@@ -248,19 +258,18 @@ function addErrors (metadata: MetadataLatest): string {
|
||||
return renderPage({
|
||||
title: 'Errors',
|
||||
description: DESC_ERRORS,
|
||||
sections: metadata.modules.sort(sortByName).filter(moduleMetadata => !moduleMetadata.errors.isEmpty).map(moduleMetadata => {
|
||||
const sectionName = stringLowerFirst(moduleMetadata.name.toString());
|
||||
|
||||
return {
|
||||
name: sectionName,
|
||||
items: moduleMetadata.errors.sort(sortByName).map(error => {
|
||||
return {
|
||||
sections: metadata.modules
|
||||
.sort(sortByName)
|
||||
.filter((moduleMetadata) => !moduleMetadata.errors.isEmpty)
|
||||
.map((moduleMetadata) => ({
|
||||
name: stringLowerFirst(moduleMetadata.name.toString()),
|
||||
items: moduleMetadata.errors
|
||||
.sort(sortByName)
|
||||
.map((error) => ({
|
||||
name: error.name.toString(),
|
||||
...(error.documentation.length && { summary: error.documentation })
|
||||
};
|
||||
})
|
||||
};
|
||||
})
|
||||
}))
|
||||
}))
|
||||
});
|
||||
}
|
||||
|
||||
@@ -280,43 +289,14 @@ function writeFile (name: string, ...chunks: any[]): void {
|
||||
writeStream.end();
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function writeToRpcMd (): void {
|
||||
export default function main (): void {
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Decorated(registry, rpcdata).metadata.asLatest;
|
||||
|
||||
writeFile('docs/substrate/rpc.md', addRpc());
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function writeToConstantsMd (metadata: MetadataLatest): void {
|
||||
writeFile('docs/substrate/constants.md', addConstants(metadata));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function writeToStorageMd (metadata: MetadataLatest): void {
|
||||
writeFile('docs/substrate/storage.md', addStorage(metadata));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function writeToExtrinsicsMd (metadata: MetadataLatest): void {
|
||||
writeFile('docs/substrate/extrinsics.md', addExtrinsics(metadata));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function writeToEventsMd (metadata: MetadataLatest): void {
|
||||
writeFile('docs/substrate/events.md', addEvents(metadata));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function writeToErrorsMd (metadata: MetadataLatest): void {
|
||||
writeFile('docs/substrate/errors.md', addErrors(metadata));
|
||||
}
|
||||
|
||||
const registry = new TypeRegistry();
|
||||
const decorated = new Decorated(registry, rpcdata);
|
||||
const latest = decorated.metadata.asLatest;
|
||||
|
||||
writeToRpcMd();
|
||||
writeToConstantsMd(latest);
|
||||
writeToStorageMd(latest);
|
||||
writeToExtrinsicsMd(latest);
|
||||
writeToEventsMd(latest);
|
||||
writeToErrorsMd(latest);
|
||||
@@ -1,10 +1,10 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/typegen 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 { Constructor } from '../../types';
|
||||
import { Constructor } from '@polkadot/types/types';
|
||||
|
||||
import UInt from '../../codec/UInt';
|
||||
import UInt from '@polkadot/types/codec/UInt';
|
||||
|
||||
// See if a class is child of another class
|
||||
// FIMXE This could go in util some day
|
||||
@@ -2,23 +2,24 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { TypeDef, TypeDefInfo } from '../../codec/types';
|
||||
import { Constructor, Registry } from '../../types';
|
||||
import { TypeDef, TypeDefInfo } from '@polkadot/types/create/types';
|
||||
import { Constructor, Registry } from '@polkadot/types/types';
|
||||
|
||||
import { stringLowerFirst } from '@polkadot/util';
|
||||
import { isChildClass, isCompactEncodable } from './class';
|
||||
import { ClassOf, ClassOfUnsafe, getTypeDef } from '../../codec/create';
|
||||
import AbstractInt from '../../codec/AbstractInt';
|
||||
import Compact from '../../codec/Compact';
|
||||
import Enum from '../../codec/Enum';
|
||||
import Option from '../../codec/Option';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vec from '../../codec/Vec';
|
||||
import GenericAccountId from '../../primitive/Generic/AccountId';
|
||||
import GenericAddress from '../../primitive/Generic/Address';
|
||||
import Vote, { convictionNames as _voteConvictions } from '../../primitive/Generic/Vote';
|
||||
import Null from '../../primitive/Null';
|
||||
import * as primitiveClasses from '../../primitive';
|
||||
import { ClassOf, ClassOfUnsafe, getTypeDef } from '@polkadot/types/create';
|
||||
import AbstractInt from '@polkadot/types/codec/AbstractInt';
|
||||
import Compact from '@polkadot/types/codec/Compact';
|
||||
import Enum from '@polkadot/types/codec/Enum';
|
||||
import Option from '@polkadot/types/codec/Option';
|
||||
import Struct from '@polkadot/types/codec/Struct';
|
||||
import Vec from '@polkadot/types/codec/Vec';
|
||||
import GenericAccountId from '@polkadot/types/primitive/Generic/AccountId';
|
||||
import GenericAddress from '@polkadot/types/primitive/Generic/Address';
|
||||
import Vote, { convictionNames as _voteConvictions } from '@polkadot/types/primitive/Generic/Vote';
|
||||
import Null from '@polkadot/types/primitive/Null';
|
||||
import * as primitiveClasses from '@polkadot/types/primitive';
|
||||
|
||||
import { formatType } from './formatting';
|
||||
import { setImports, TypeImports } from './imports';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/typegen authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/typegen authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/typegen authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+5
-4
@@ -1,11 +1,12 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/typegen 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 { TypeDef, TypeDefInfo, TypeDefExtVecFixed } from '../../codec/types';
|
||||
import { TypeDef, TypeDefInfo, TypeDefExtVecFixed } from '@polkadot/types/create/types';
|
||||
|
||||
import { getTypeDef } from '@polkadot/types/create';
|
||||
import { paramsNotation } from '@polkadot/types/codec/utils';
|
||||
|
||||
import { getTypeDef } from '../../codec/create';
|
||||
import { paramsNotation } from '../../codec/utils';
|
||||
import { setImports, TypeImports } from './imports';
|
||||
|
||||
export const HEADER = '// Auto-generated via `yarn polkadot-types-from-defs`, do not edit\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\n';
|
||||
@@ -1,11 +1,12 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/typegen 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 * as codecClasses from '../../codec';
|
||||
import { getTypeDef } from '../../codec/create';
|
||||
import { TypeDefInfo } from '../../codec/types';
|
||||
import * as primitiveClasses from '../../primitive';
|
||||
import { TypeDefInfo } from '@polkadot/types/create/types';
|
||||
|
||||
import * as codecClasses from '@polkadot/types/codec';
|
||||
import { getTypeDef } from '@polkadot/types/create';
|
||||
import * as primitiveClasses from '@polkadot/types/primitive';
|
||||
|
||||
// these map all the codec and primitive types for import, see the TypeImports below. If
|
||||
// we have an unseen type, it is `undefined`/`false`, if we need to import it, it is `true`
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/typegen authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
{
|
||||
"name": "@polkadot/types",
|
||||
"version": "1.2.1",
|
||||
"version": "1.3.1",
|
||||
"description": "Implementation of the Parity codec",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
"polkadot-types-from-chain": "./scripts/polkadot-types-from-chain.js",
|
||||
"polkadot-types-from-defs": "./scripts/polkadot-types-from-defs.js"
|
||||
},
|
||||
"keywords": [
|
||||
"Polkadot",
|
||||
"JsonRPC"
|
||||
@@ -30,23 +26,17 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.8.4",
|
||||
"@babel/register": "^7.8.3",
|
||||
"@babel/runtime": "^7.8.4",
|
||||
"@polkadot/api": "^1.2.1",
|
||||
"@polkadot/metadata": "^1.2.1",
|
||||
"@polkadot/util": "^2.3.1",
|
||||
"@polkadot/util-crypto": "^2.3.1",
|
||||
"@polkadot/metadata": "^1.3.1",
|
||||
"@polkadot/util": "^2.4.1",
|
||||
"@polkadot/util-crypto": "^2.4.1",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"bn.js": "^5.1.1",
|
||||
"memoizee": "^0.4.14",
|
||||
"rxjs": "^6.5.4",
|
||||
"websocket": "^1.0.31",
|
||||
"yargs": "^15.1.0"
|
||||
"rxjs": "^6.5.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^2.3.1",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"@types/memoizee": "^0.4.3",
|
||||
"@types/yargs": "^15.0.3"
|
||||
"@polkadot/keyring": "^2.4.1",
|
||||
"@types/memoizee": "^0.4.3"
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user