Compare commits

...
71 Commits
Author SHA1 Message Date
Github Actions eb3e7a0740 [CI Skip] 1.8.1
skip-checks: true
2020-03-22 17:58:16 +00:00
Jaco Greeff 2071de517d 1.8 (#2079) 2020-03-22 18:47:04 +01:00
Github Actions 205ae40f20 [CI Skip] 1.8.0-beta.12
skip-checks: true
2020-03-22 17:27:07 +00:00
Keith IngramandJaco Greeff aa37e372dd Derived account info flags (#2068)
* Derived account info flags

* Update packages/api-derive/src/accounts/info.ts

Co-Authored-By: Jaco Greeff <jacogr@gmail.com>

* Apply suggestions from code review

* Cleanups

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
2020-03-22 18:16:43 +01:00
Github Actions 8cdac77a8e [CI Skip] 1.8.0-beta.11
skip-checks: true
2020-03-22 10:15:48 +00:00
Jaco Greeff 7a7d6e9b8a New democracy types (#2078)
* New democracy types

* ReferendumInfo

* Adjust democracy derives

* Spring cleaning

* Remove ReferendumInfoExtended
2020-03-22 11:05:57 +01:00
Github Actions 7a1bdb18a8 [CI Skip] 1.8.0-beta.10
skip-checks: true
2020-03-22 06:57:07 +00:00
Jaco Greeff 39f22ca403 Control wasm initialization via initWasm: false flag (#2076) 2020-03-22 07:45:22 +01:00
Github Actions b3c6a5acc5 [CI Skip] 1.8.0-beta.9
skip-checks: true
2020-03-22 06:43:14 +00:00
Jaco Greeff b3a6b3dcb5 Bump dev, arrow functions (#2077) 2020-03-22 07:31:55 +01:00
Github Actions 0c0e4c4d7c [CI Skip] 1.8.0-beta.8
skip-checks: true
2020-03-21 08:51:26 +00:00
Jaco Greeff 9d67d711d4 Bump deps, type import on generated (#2075)
* Bump deps, type import on generated

* type imports in types/types

* Re-export defs

* Split imports/exports

* Additional type import

* Remove import type

* Remove dupes
2020-03-21 09:40:59 +01:00
Github Actions f45d03fa17 [CI Skip] 1.8.0-beta.7
skip-checks: true
2020-03-21 07:00:35 +00:00
Jaco Greeff af11444b72 Update RPCs (babe, contracts) (#2074)
* Update RPCs (babe, contracts)

* Babe in rpc-core
2020-03-21 07:50:56 +01:00
Github Actions f412a5ac86 [CI Skip] 1.8.0-beta.6
skip-checks: true
2020-03-20 16:50:04 +00:00
Jaco Greeff c9dcd51ba6 is isWarning to ISubmittableResult (#2073) 2020-03-20 17:40:09 +01:00
Jaco Greeff 5dca826429 Retracted status to isWarning 2020-03-20 17:27:18 +01:00
Github Actions 8dc53e6339 [CI Skip] 1.8.0-beta.5
skip-checks: true
2020-03-20 15:41:13 +00:00
Jaco Greeff 5867f8ab0c Allow unknown struct fields (i.e. on Map, non-codec) (#2071) 2020-03-20 16:30:29 +01:00
Github Actions 6d3db2fb3f [CI Skip] 1.8.0-beta.4
skip-checks: true
2020-03-20 12:52:46 +00:00
Jaco Greeff 3a1634d67f Add all missing RPC endpoints (#2070)
* Add all missing RPC endpoints

* Rework RPC return types

* rpc-core interface

* Remove crap test, checked anyway
2020-03-20 13:42:18 +01:00
Github Actions 53d18d874d [CI Skip] 1.8.0-beta.3
skip-checks: true
2020-03-19 13:51:15 +00:00
Jaco Greeff 044efbc6de Convert jsonrpc & typings to definitions (#2064)
* Convert jsonrpc & typings to definitions

* Handle empty interface generation (no types)

* Move jsonrpc/create to rpc-core/create

* Create imports

* Remove jsonrpc package, generate rpc-core from defs

* Debug :)

* Generate RPC definitions via interfaces

* Generate md docs

* Remove @polkadot/jsonrpc refs (at least packages)

* No empty types

* Add PAHNTOM "cleanup" gen

* *sigh* regex loop

* Update mock for no jsonrpc

* Add definition export types

* Cleanup linting

* Mocking 1 fix

* Mocking 2 fix

* rpc-core tests updates

* CHANGELOG & docs

* Add jsonrpc (already mapped) to interfaces

* Add aliasses for RPCs

* Fix rpc-core tests
2020-03-19 14:40:54 +01:00
Github Actions 27e3fbfd0f [CI Skip] 1.8.0-beta.2
skip-checks: true
2020-03-18 21:50:49 +00:00
Jaco Greeff b7af4781ea Add Initialization to extrinsic phases (#2063) 2020-03-18 22:40:53 +01:00
Github Actions c51e351117 [CI Skip] 1.8.0-beta.1
skip-checks: true
2020-03-17 23:18:54 +00:00
Jaco Greeff e6afed9bb1 Allow electedInfo commition with/without linked maps (#2060) 2020-03-18 00:08:49 +01:00
Github Actions 4b07d5511e [CI Skip] 1.8.0-beta.0
skip-checks: true
2020-03-17 18:46:06 +00:00
Jaco Greeff a613308bdb Update 2020-03-17 19:34:51 +01:00
Jaco Greeff a863e5eb95 Non-array nominators 2020-03-17 19:22:16 +01:00
Github Actions 623420ca3d [CI Skip] 1.7.1
skip-checks: true
2020-03-17 13:49:41 +00:00
Jaco Greeff 9ea6053a42 1.7 (#2059) 2020-03-17 14:39:20 +01:00
Github Actions 73dce6bfd1 [CI Skip] 1.7.0-beta.19
skip-checks: true
2020-03-17 09:48:02 +00:00
Jaco Greeff 5a7811c80f Bump metadata (#2058)
* Bump metadata

* Add missing @types/jest

* Update tests for new metadata

* CHANGELOG for linked map removals

* expand re-added check
2020-03-17 10:37:24 +01:00
Github Actions 1c529bdc6a [CI Skip] 1.7.0-beta.18
skip-checks: true
2020-03-16 14:47:43 +00:00
Jaco Greeff 3f4576f524 Add yarn matrix (#2057) 2020-03-16 15:37:23 +01:00
Github Actions 2619489ec3 [CI Skip] 1.7.0-beta.17
skip-checks: true
2020-03-16 13:59:34 +00:00
Jaco Greeff f165845cc3 Collapse actions matrix (#2056) 2020-03-16 14:49:31 +01:00
Github Actions 897f03e4c1 [CI Skip] 1.7.0-beta.16
skip-checks: true
2020-03-16 10:24:34 +00:00
Jaco Greeff 82c1e3f35a Cater for new non-linked map validator queries (#2055)
* Cater for new non-linked map validator queries

* Update staking tests

* stakers -> stashes
2020-03-16 11:13:46 +01:00
Github Actions c06f260d3c [CI Skip] 1.7.0-beta.15
skip-checks: true
2020-03-16 07:23:55 +00:00
Jaco Greeff 63573ca0de Add ownExposure & ownSlashes (#2054) 2020-03-16 08:15:00 +01:00
Github Actions bf1a5f0d91 [CI Skip] 1.7.0-beta.14
skip-checks: true
2020-03-15 19:39:52 +00:00
Wei Tang 1750522cb6 Use /usr/bin/env bash instead of /bin/bash (#2053) 2020-03-15 20:29:45 +01:00
Github Actions ed3b507ea6 [CI Skip] 1.7.0-beta.13
skip-checks: true
2020-03-15 17:00:01 +00:00
Jaco Greeff f942510309 Expose stakerSlahes & eraSlashes (#2052) 2020-03-15 17:49:15 +01:00
Github Actions 09a9153645 [CI Skip] 1.7.0-beta.12
skip-checks: true
2020-03-15 09:03:36 +00:00
Jaco Greeff 908d0fcf52 Add missing commission to payout calculations (#2051)
* Add missing comission to payout calcs

* yarn

* Bump dev with version update fix
2020-03-15 09:51:52 +01:00
Github Actions 707c93a557 [CI Skip] 1.7.0-beta.11
skip-checks: true
2020-03-15 07:36:51 +00:00
Jaco Greeff 82addc4f6a Remove non-working CI cache (#2050) 2020-03-15 08:26:34 +01:00
Github Actions d595eb440c [CI Skip] 1.7.0-beta.10
skip-checks: true
2020-03-14 08:49:03 +00:00
Jaco Greeff e86fe5bab0 Bump deps (#2048) 2020-03-14 09:37:28 +01:00
Github Actions 7187dca2f7 [CI Skip] 1.7.0-beta.9
skip-checks: true
2020-03-13 20:17:16 +00:00
Jaco Greeff 94a3b1f09a eraPoints args (#2047) 2020-03-13 21:05:40 +01:00
Github Actions d88b300a6d [CI Skip] 1.7.0-beta.8
skip-checks: true
2020-03-13 18:52:54 +00:00
Jaco Greeff dd217f82b2 Chunk keys & values retrievals on keys()/entries() (#2046)
* Chunk keys & values retrievals on keys()/entries()

* Bump chunk sizes

* Fix concatMap index

* Update mock
2020-03-13 19:40:57 +01:00
Github Actions 3b4cee08e2 [CI Skip] 1.7.0-beta.7
skip-checks: true
2020-03-13 17:07:31 +00:00
Joshy Orndorff 34be2399eb Couple little typo fixes (#2045) 2020-03-13 17:54:29 +01:00
Github Actions 27d879a325 [CI Skip] 1.7.0-beta.6
skip-checks: true
2020-03-13 12:51:33 +00:00
Jaco Greeff 4093ef9ffa Add Identity hasher (#2044)
* Add Identity hasher

* Expand new V11 storage types

* Cleanups, use actual enum keys

* Sort augmented output (fy-by enhancement)

* Map get

* DEFAULT_FN
2020-03-13 13:39:34 +01:00
Github Actions 261eebee03 [CI Skip] 1.7.0-beta.5
skip-checks: true
2020-03-13 11:45:14 +00:00
Jaco Greeff d9dad3566a Use asyncScheduler for all derives (#2043) 2020-03-13 12:32:42 +01:00
Github Actions 3d0fdbd6da [CI Skip] 1.7.0-beta.4
skip-checks: true
2020-03-13 07:56:43 +00:00
Jaco Greeff affa5d390c Expose derive staking.nextElected (#2042) 2020-03-13 08:45:28 +01:00
Github Actions 1659e672ae [CI Skip] 1.7.0-beta.3
skip-checks: true
2020-03-13 07:05:20 +00:00
Jaco Greeff 0fa6b99c9e Query docs with entries & keys, submittable with paymentInfo (#2041) 2020-03-13 07:52:53 +01:00
Github Actions ef9db7bf78 [CI Skip] 1.7.0-beta.2
skip-checks: true
2020-03-13 05:45:54 +00:00
Jaco Greeff 8c6505d870 Map signs directly to H512 (no indirection) (#2038) 2020-03-13 06:34:46 +01:00
Github Actions 48f83c7d5b [CI Skip] 1.7.0-beta.1
skip-checks: true
2020-03-12 21:11:11 +00:00
Jaco Greeff f3c2c5c084 Re-enable argument checks (dropped in 1.6.2) (#2035)
* Re-enable argument checks (dropped in 1.6.2)

* typo

* Bump to preminor
2020-03-12 21:58:57 +01:00
Jaco Greeff 98e1cc3f73 Add staking.eraExposure derive (#2036) 2020-03-12 21:57:17 +01:00
261 changed files with 5793 additions and 5475 deletions
+7 -99
View File
@@ -2,110 +2,18 @@ name: PR
on: [pull_request]
jobs:
lint:
name: Linting
runs-on: ubuntu-latest
pr:
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
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 --immutable | grep -v 'YN0013'
yarn lint
test:
name: Testing
step: ['lint', 'test', 'build', 'docs']
name: ${{ matrix.step }}
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
- 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
node-version: '12.x'
- name: ${{ matrix.step }}
run: |
yarn install --immutable | grep -v 'YN0013'
yarn test
build_code:
name: Build Code
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
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 --immutable | grep -v 'YN0013'
yarn build
build_docs:
name: Build Docs
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
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 --immutable | grep -v 'YN0013'
yarn docs
yarn ${{ matrix.step }}
+10 -56
View File
@@ -5,82 +5,36 @@ on:
- master
jobs:
build_code:
name: Build Code
if: "! contains(github.event.head_commit.message, '[CI Skip]')"
runs-on: ubuntu-latest
master:
strategy:
matrix:
node-version: [12.x]
step: ['build:release', 'docs:release']
name: ${{ matrix.step }}
if: "! contains(github.event.head_commit.message, '[CI Skip]')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
token: ${{ secrets.GH_PAT }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
- 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
node-version: '12.x'
- name: ${{ matrix.step }}
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
GH_PAGES_SRC: build-docs
GH_PAT: ${{ secrets.GH_PAT }}
GH_TOKEN: ${{ secrets.GH_PAT }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
yarn install --immutable | grep -v 'YN0013'
yarn polkadot-ci-ghact-build
build_docs:
name: Build Docs
if: "! contains(github.event.head_commit.message, '[CI Skip]')"
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
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 }}
GH_TOKEN: ${{ secrets.GH_PAT }}
GH_PAGES_SRC: build-docs
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
yarn install --immutable | grep -v 'YN0013'
yarn polkadot-ci-ghact-docs
yarn ${{ matrix.step }}
dummy:
name: Dummy
if: "contains(github.event.head_commit.message, '[CI Skip]')"
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- name: dummy
run: |
-58
View File
File diff suppressed because one or more lines are too long
Vendored Executable
+50
View File
File diff suppressed because one or more lines are too long
+2 -1
View File
@@ -1,4 +1,5 @@
enableImmutableInstalls: false
enableProgressBars: false
nodeLinker: node-modules
@@ -7,4 +8,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.js
spec: "@yarnpkg/plugin-interactive-tools"
yarnPath: .yarn/releases/yarn-berry.js
yarnPath: .yarn/releases/yarn-rc.js
+23 -2
View File
@@ -1,6 +1,27 @@
# 1.6.2 Feb 27, 2020
# 1.8.1 Mar 22, 2020
- Revert checks for arg, not working on `.at()` queries (proper fix in next version)
- **Breaking change** The format for any custom RPCs have been changed alongside API-internal changes to allow for better RPC management. If you are currently using custom RPCs (or planning to do so), look at the [updated documentation](https://polkadot.js.org/api/start/rpc.custom.html)
- **Breaking change** Alongside API RPC changes, the `@polkadot/jsonrpc` package has been removed. Since it was never documented and only used internally, this should not have adverse impacts. All RPC definitions itself has now been moved to the relevant modules inside `@polkadot/types/interfaces`
- **Important** Substrate has an updated democracy module. If using an older chain add the `ReferendumInfo: 'ReferendumInfoTo239'` type when using referendums
- The `isRetracted` Extrinsic status is now a warning, not a fatal error, correctly aligning with Polkadot/Substrate
- The Substrate extrinsic phase definitions has been expanded with `Initialization` to align with the latest versions
- Add support for all known substrate RPC methods
- Extend account derives to include status flags, e.g. `isCouncil`, `isSudo`, ...
- Adjusted referendum derives to cater for bot new/old democracy. Derived `referendumInfo` now includes `status` field, not `info`
# 1.7.1 Mar 17, 2020
- **Important** Current versions of Polkadot/Substrate have dropped support for linked maps on storage entries. If you are using these queries to retrieve all entries, for instance `staking.{nominators,validators}()` and using an upgraded chain, you need to swap to retrieving entries via `.entries()` or `.keys()` for the keys.
- Pull in support and types for latest Polkadot/Substrate
- Add support for the new Substrate `state_getKeysPaged` RPC, including use in storage keys
- Move `derive.staking.controllers` to `derive.staking.stashes`, reflecting actual content
- Cater for adjusted storage (non-linked mapped) for `derive.staking.stashes` queries (with old-compat)
- Expanded `derive.staking.*` derives, including addition of `derive.staking.own*`
- Re-add fixed (with tests) checks for query args, previously disabled in 1.6.2
# 1.6.2 Mar 12, 2020
- Revert checks for query args, not working on `.at()` queries (proper fix in next version)
# 1.6.1 Mar 12, 2020
+1 -2
View File
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
function copy_folder () {
SRC="packages/$1/build"
@@ -18,6 +18,5 @@ copy_folder "api-derive"
copy_folder "metadata"
copy_folder "rpc-core"
copy_folder "rpc-provider"
copy_folder "jsonrpc"
copy_folder "types"
copy_folder "typegen"
+1
View File
@@ -43,6 +43,7 @@ module.exports = {
['start/api.tx.wrap.md', 'Complex transactions'],
['start/types.basics.md', 'Type basics'],
['start/types.extend.md', 'Extending types'],
['start/rpc.custom.md', 'Custom RPC'],
['start/types.create.md', 'Creating types'],
['start/typescript.md', 'TypeScript interfaces'],
['start/typescript.user.md', 'TypeScript user generated'],
@@ -24,7 +24,7 @@ async function main () {
if (validators && validators.length > 0) {
// Retrieve the balances for all validators
const validatorBalances = await Promise.all(
validators.map(authorityId =>
validators.map((authorityId) =>
api.query.system.account(authorityId)
)
);
+1 -1
View File
@@ -22,7 +22,7 @@ function main () {
// In the next step, we're checking if the node has active validators.
// If it does, we're making another call to the api to get the balances for all validators
const balances = (validators && validators.length > 0)
? combineLatest(validators.map(authorityId => api.query.system.account(authorityId).pipe(first())))
? combineLatest(validators.map((authorityId) => api.query.system.account(authorityId).pipe(first())))
: of(null);
// We're combining the results together with the emitted value 'validators',
-5
View File
@@ -1,5 +0,0 @@
... somewhere also need a signer injection section, something along the lines of the singlesigner or this https://github.com/polkadot-js/tools/blob/master/packages/signer-cli/src/cmdSubmit.ts#L12
... DoubleMap & LinkedMap examples
... api.derive
+1 -1
View File
@@ -34,7 +34,7 @@ To submit these transactions, it needs to be send as a [wrapped transaction](api
## How do I call a function with a Tuple input
Tuples, as defined in the Polkadot/Substrate types appear as `(TypeA, TypeB)`. For instance we may have an `(AccountId, u64)` input as defined in the metadata or as part of the user types. To specify a Tuple as an input, wrap it is an array format, for instance to call `query.module.get((u32, u64))` where a `(u32, u64)` Tuple input is expected, you would do `query.module.get([123, 456])`
Tuples, as defined in the Polkadot/Substrate types appear as `(TypeA, TypeB)`. For instance we may have an `(AccountId, u64)` input as defined in the metadata or as part of the user types. To specify a Tuple as an input, wrap it in an array format, for instance to call `query.module.get((u32, u64))` where a `(u32, u64)` Tuple input is expected, you would do `query.module.get([123, 456])`
## How long do transactions live
+41 -1
View File
@@ -22,7 +22,7 @@ const [{ data: balanceNow }, { data: balancePrev }] = await Promise.all([
console.log(`The delta was ${balanceNow.free.sub(balancePrev.free)}`);
```
In the above example, we introduce the `.at(<hash>[, ...params])` query. For all `.at` queries, the first parameter is always the block hash at which we want to make the query, in our example we use both the last retrieved block and the parent thereof. The params are optional as per the type of query made, for instance to retrieve the timestamp for a previous block, it would be -
In the above example, we introduce the `.at(<hash>[, ...params]): Type` query. For all `.at` queries, the first parameter is always the block hash at which we want to make the query, in our example we use both the last retrieved block and the parent thereof. The params are optional as per the type of query made, for instance to retrieve the timestamp for a previous block, it would be -
```js
...
@@ -35,6 +35,46 @@ The `.at` queries are all single-shot, i.e. there are no subscription option to
An additional point to take care of (briefly mentioned above), is state pruning. By default a Polkadot/Substrate node will only keep state for the last 256 blocks, unless it is explicitly run in archive mode. This means that querying state further back than the pruning period will result in an error returned from the Node. (Generally most public RPC nodes only run with default settings, which includes aggressive state pruning)
## State for a range of blocks
In addition to the `.at` queries, you can also query state starting at a specific historic block and up to either a specified or the latest blocks. This is done via the `.range([from, to?], <...opt params>): [Hash, Type][]` query. As an example -
```js
...
// Retrieve the current block header
const lastHdr = await api.rpc.chain.getHeader();
const startHdr = await api.rpc.chain.getBlockHash(lastHdr.number.unwrap().subn(500));
// retrieve the range of changes
const changes = await api.query.system.account.range([startHdr]);
changes.forEach(([hash, value]) => {
console.log(hash.toHex(), value.toHuman());
});
```
## Map keys & entries
When working maps and double-maps, it is possible to retrieve a list of all the keys and entries for the map. For this we can use the `.entries(<args>): [StorageKey, Type][]` queries. For example we may want to know the current list of validator exposures at a current era in the staking module -
```js
...
// Retrieve the active era
const activeEra = await api.query.staking.activeEra();
// retrieve all exposures int the active era
const exposures = await api.query.staking.erasStakers.entries(activeEra.index);
exposures.forEach(([key, exposure]) => {
console.log('key arguments:', key.args.map((k) => k.toHuman()));
console.log(' exposure:', exposure.toHuman());
});
```
Here we are querying a double-map, so we supply 1 argument. No arguments on double-maps will be very costly, retrieving all the eras and associated entries. Additionally when `twox64_concat` & `blake2_concat` is used, the key `.args` will contain decoded values of the params, in this case it will contain the actual `AccountId` of the staker. (Since that was not supplied)
In the same way as above we can simply do `.keys(activeEra.index): StorageKey[]` to retrieve all the keys here, including the individual keys args decoding, as available on maps with decodable hashing functions.
## State entries
In addition to using `api.query` to make actual on-chain queries, it can also be used to retrieve some information on the state entries. For instance to retrieve both the hash and size of an existing entry, we can make the following calls -
+17
View File
@@ -62,6 +62,23 @@ const unsub = await api.tx.balances
Be aware that when a transaction status is `isFinalized`, it means it is included, but it may still have failed - for instance if you try to send a larger amount that you have free, the transaction is included in a block, however from a end-user perspective the transaction failed since the transfer did not occur. In these cases a `system.ExtrinsicFailed` event will be available in the events array.
## Payment information
The Polkadot/Substrate RPC endpoints exposes weight/payment information that takes an encoded extrinsic and calculates the on-chain weight fees for it. A wrapper for this is available on the tx itself, taking exactly the same parameters as you would pass to a normal `.signAndSend` operation, specifically `.paymentInfo(sender, <any options>)`. To expand on our previous example -
```js
// construct a transaction
const transfer = api.tx.balances.transfer(BOB, 12345);
// retrieve the payment info
const { partialFee, weight } = await transfer.paymentInfo(alice);
console.log(`transaction will have a weight of ${weight}, with ${partialFee.toHuman()} weight fees`);
// send the tx
transfer.signAndSend(alice, ({ events = [], status }) => { ... });
```
## Complex transactions
In many cases transactions can carry quite complex information, be it for passing objects or proposing changes. In the next section we will take a dive [into complex transactions, including those wrapped for sudo](api.tx.wrap.md).
+51
View File
@@ -0,0 +1,51 @@
# Custom RPC
In previous sections we looked at the injection of types, as in use and defined in modules from the node. Another area that can be customized is RC definitions, and like with the types, the API provides the capability to add user-defined RPCs (in addition to the Polkadot/Substrate base) to allow use of these RPCs via the API.
## Custom definitions
RPCs are exposed as a method on a specific module, this means that once available you can call any rpc via the `api.rpc.<module>.<method>(...params[])` endpoints. To extend with user-defined RPCs, the injection can happen at the time of API creation with the addition of the `rpc` key (in addition to any other params, such as `types` or `provider`) -
```js
...
const api = await ApiPromise.create({
rpc: {
firstModule: {
testMethod: {
description: 'Just a test method',
params: [
{
name: 'index',
type: 'u64'
}
],
type: 'Balance'
}
}
}
});
```
In the above example we have defined a new method, which is now available on the RPCs as `api.rpc.firstModule.testMethod(u64) => Promise<Balance>`. Do be aware that while defined, the method will only appear if it is in the list as returned by `api.rpc.rpc.methods()`, which is the list of known RPCs the node exposes. When making changes to the node, always ensure that it does expose the RPC method correctly, otherwise it will not be decorated.
## Definition breakdown
While the above example should be self-explanatory, it is important to understand teh structure. The `rpc: { ... }` definitions are keyed first and foremost by the name of the module exposing the RPC. This means that when we have 2 modules `firstModule` & `testModule`, the first-level structure would follow the following pattern,
```js
...
const api = await ApiPromise.create({
rpc: {
firstModule: { ... },
testModule: { ... }
}
});
```
Inside the specific module definitions, the key is the actual expose RPC method. As we have seen in the first example, we expose a `testMethod` on `firstModule`. For the method definitions, apart from the description, we have definitions for the params and return a single result `type`.
Params itself, as an array, contains fields for `name`, `type` and an optional flag `isOptional` that indicates that the field is not required when making the call. (And example of this use would be in cases such as `state.getStorage(key, blockHash?)` where the last param is optional)
## Type creation
While the API always converts all the inputs into the underlying type required by the operation, be it for RPC, query or transaction, in some cases you may want to [create an instance of a type](types.create.md) yourself.
+2 -2
View File
@@ -201,6 +201,6 @@ const api = await ApiPromise.create({
Always look at customization and understand the impacts, replicating these changes between the node and the API. For the above the `Address` type is used in the construction of the `UncheckedExtrinsic` type, while the lookup type is applicable on transactions such as `balances.transfer(to: LookupSource, value: Balance)`
## Type creation
## Custom RPC
While the API always converts all the inputs into the underlying type required by the operation, in some cases you may want to [create an instance of a type](types.create.md) yourself.
In addition to customizing modules and types on your node, you can also add custom RPC definitions. Like the type definitions in ths section, [these can be defined and passed to the API](rpc.custom.md) for decoration.
+1 -1
View File
@@ -1,6 +1,6 @@
# TypeScript user generated
In the previous section we looked at the TypeScript definitions that are available and is generated from both the chain and definitions. Here we will expand upon the use of the infrastructure created to define types as part of the `@polkadot/types` library and see how to use them to generate your onw definitions and chain types.
In the previous section we looked at the TypeScript definitions that are available and is generated from both the chain and definitions. Here we will expand upon the use of the infrastructure created to define types as part of the `@polkadot/types` library and see how to use them to generate your own definitions and chain types.
## Definitions
-12
View File
@@ -7,7 +7,6 @@ module.exports = Object.assign({}, config, {
'@polkadot/api-contract(.*)$': '<rootDir>/packages/api-contract/src/$1',
'@polkadot/api-derive(.*)$': '<rootDir>/packages/api-derive/src/$1',
'@polkadot/api(.*)$': '<rootDir>/packages/api/src/$1',
'@polkadot/jsonrpc(.*)$': '<rootDir>/packages/jsonrpc/src/$1',
'@polkadot/metadata(.*)$': '<rootDir>/packages/metadata/src/$1',
'@polkadot/rpc-(core|provider)(.*)$': '<rootDir>/packages/rpc-$1/src/$2',
'@polkadot/types(.*)$': '<rootDir>/packages/types/src/$1'
@@ -16,21 +15,10 @@ module.exports = Object.assign({}, config, {
'<rootDir>/packages/api/build',
'<rootDir>/packages/api-derive/build',
'<rootDir>/packages/api-contract/build',
'<rootDir>/packages/jsonrpc/build',
'<rootDir>/packages/metadata/build',
'<rootDir>/packages/rpc-core/build',
'<rootDir>/packages/rpc-provider/build',
'<rootDir>/packages/types/build'
],
globals: {
ws_local: 'ws://127.0.0.1:9944/',
ws_local_substrate_master: 'ws://127.0.0.1:9945/',
ws_local_substrate_1: 'ws://127.0.0.1:9946/',
ws_local_substrate_2: 'ws://127.0.0.1:9947/',
ws_local_polkadot_master: 'ws://127.0.0.1:9948/',
ws_local_polkadot_alex: 'ws://127.0.0.1:9949/',
ws_substrate_1: 'wss://substrate-rpc.parity.io/',
ws_polkadot_alex: 'wss://poc3-rpc.polkadot.io/'
},
resolver: './jest.resolver.js'
});
+1 -1
View File
@@ -9,5 +9,5 @@
"packages": [
"packages/*"
],
"version": "1.6.2"
"version": "1.8.1"
}
+8 -5
View File
@@ -12,7 +12,9 @@
"scripts": {
"build": "yarn build:interfaces && polkadot-dev-build-ts && (cd packages/typegen && copyfiles scripts/* build)",
"build:interfaces": "polkadot-types-internal-interfaces",
"build:release": "polkadot-ci-ghact-build",
"docs": "polkadot-types-internal-metadata && polkadot-dev-build-docs",
"docs:release": "polkadot-ci-ghact-docs",
"chain:info": "polkadot-types-chain-info",
"lint": "polkadot-dev-run-lint",
"clean": "polkadot-dev-clean-build",
@@ -22,12 +24,13 @@
"test:watch": "polkadot-dev-run-test --watch"
},
"devDependencies": {
"@babel/core": "^7.8.4",
"@babel/register": "^7.8.3",
"@babel/runtime": "^7.8.4",
"@polkadot/dev": "^0.50.30",
"@polkadot/ts": "^0.3.7",
"@babel/core": "^7.9.0",
"@babel/register": "^7.9.0",
"@babel/runtime": "^7.9.2",
"@polkadot/dev": "^0.51.7",
"@polkadot/ts": "^0.3.14",
"@polkadot/typegen": "workspace:packages/typegen",
"@types/jest": "^25.1.4",
"copyfiles": "^2.2.0"
}
}
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-contract",
"version": "1.6.2",
"version": "1.8.1",
"description": "Interfaces for interacting with contracts and contract ABIs",
"main": "index.js",
"keywords": [
@@ -26,10 +26,10 @@
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
"dependencies": {
"@babel/runtime": "^7.8.4",
"@polkadot/api": "1.6.2",
"@polkadot/rpc-core": "1.6.2",
"@polkadot/types": "1.6.2",
"@babel/runtime": "^7.9.2",
"@polkadot/api": "1.8.1",
"@polkadot/rpc-core": "1.8.1",
"@polkadot/types": "1.8.1",
"@polkadot/util": "^2.6.2",
"bn.js": "^5.1.1",
"rxjs": "^6.5.4"
@@ -158,10 +158,10 @@ export default class ContractRegistry extends MetaRegistry {
public convertContract ({ constructors, messages, name, events, ...contract }: ContractABIContractPre): ContractABIContract {
return {
constructors: this.convertConstructors(constructors),
messages: messages.map(message => this.convertMessage(message)),
messages: messages.map((message) => this.convertMessage(message)),
name: this.stringAt(name),
...(events
? { events: events.map(event => this.convertEvent(event)) }
? { events: events.map((event) => this.convertEvent(event)) }
: {}),
...contract
};
+1 -1
View File
@@ -275,7 +275,7 @@ export default class MetaRegistry extends MetadataRegistryLookup {
case 'Result':
return this.typeDefForResult(id, typeIndex);
default: {
const sub = def['enum.variants'].map(variant => this.typeDefForEnumVariant(variant));
const sub = def['enum.variants'].map((variant) => this.typeDefForEnumVariant(variant));
return {
info: TypeDefInfo.Enum,
-1
View File
@@ -7,7 +7,6 @@ import { AccountId, Address, ContractExecResult } from '@polkadot/types/interfac
import { Codec, CodecArg } from '@polkadot/types/types';
import { MetaRegistryJson, StringIndex, TypeIndex, TypeDef } from '@polkadot/types/create/types';
// import { Observable } from 'rxjs';
import { ApiPromise, ApiRx } from '@polkadot/api';
export type ApiObject<ApiType extends ApiTypes> = ApiType extends 'rxjs'
+1 -1
View File
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Codec, Registry, TypeDefInfo, TypeDef } from '@polkadot/types/types';
import { Codec, Registry, TypeDef, TypeDefInfo } from '@polkadot/types/types';
import { Option, Raw, createClass, createTypeUnsafe } from '@polkadot/types';
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-derive",
"version": "1.6.2",
"version": "1.8.1",
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
"main": "index.js",
"keywords": [
@@ -27,11 +27,11 @@
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"dependencies": {
"@babel/runtime": "^7.8.4",
"@polkadot/api": "1.6.2",
"@polkadot/rpc-core": "1.6.2",
"@polkadot/rpc-provider": "1.6.2",
"@polkadot/types": "1.6.2",
"@babel/runtime": "^7.9.2",
"@polkadot/api": "1.8.1",
"@polkadot/rpc-core": "1.8.1",
"@polkadot/rpc-provider": "1.8.1",
"@polkadot/types": "1.8.1",
"@polkadot/util": "^2.6.2",
"@polkadot/util-crypto": "^2.6.2",
"bn.js": "^5.1.1",
@@ -7,7 +7,6 @@ import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { createType } from '@polkadot/types';
import { isU8a } from '@polkadot/util';
import { decodeAddress } from '@polkadot/util-crypto';
@@ -23,14 +22,14 @@ function retrieve (api: ApiInterfaceRx, address: Address | AccountId | AccountIn
: decodeAddress((address || '').toString());
if (decoded.length === 32) {
const accountId = createType(api.registry, 'AccountId', decoded);
const accountId = api.registry.createType('AccountId', decoded);
return api.derive.accounts.idToIndex(accountId).pipe(
map((accountIndex): AccountIdAndIndex => [accountId, accountIndex])
);
}
const accountIndex = createType(api.registry, 'AccountIndex', decoded);
const accountIndex = api.registry.createType('AccountIndex', decoded);
return api.derive.accounts.indexToId(accountIndex).pipe(
map((accountId): AccountIdAndIndex => [accountId, accountIndex])
@@ -9,14 +9,14 @@ import { Observable, of } from 'rxjs';
import { map, startWith } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { ENUMSET_SIZE } from '@polkadot/types/generic/AccountIndex';
import { Option, Vec, createType } from '@polkadot/types';
import { Option, Vec } from '@polkadot/types';
import { memo } from '../util';
function queryEnumSet (api: ApiInterfaceRx, _accountIndex: AccountIndex | string): Observable<AccountId | undefined> {
const accountIndex = _accountIndex instanceof api.registry.createClass('AccountIndex')
? _accountIndex
: createType(api.registry, 'AccountIndex', _accountIndex);
: api.registry.createType('AccountIndex', _accountIndex);
return api.query.indices.enumSet<Vec<AccountId>>(accountIndex.div(ENUMSET_SIZE)).pipe(
startWith([]),
+2 -2
View File
@@ -9,7 +9,7 @@ import { AccountIndexes } from '../types';
import { Observable, of } from 'rxjs';
import { map, startWith, switchMap } from 'rxjs/operators';
import { ENUMSET_SIZE } from '@polkadot/types/generic/AccountIndex';
import { Vec, createType } from '@polkadot/types';
import { Vec } from '@polkadot/types';
import { memo } from '../util';
@@ -31,7 +31,7 @@ function queryEnumSet (api: ApiInterfaceRx): Observable<AccountIndexes> {
// 64 (0..63 in first) is [1][0] (the first index value in set 2)
const index = (outerIndex * enumsetSize) + innerIndex;
indexes[accountId.toString()] = createType(api.registry, 'AccountIndex', index);
indexes[accountId.toString()] = api.registry.createType('AccountIndex', index);
});
return indexes;
+45 -5
View File
@@ -5,11 +5,11 @@
import { ApiInterfaceRx } from '@polkadot/api/types';
import { AccountId, AccountIndex, Address, Balance, Registration } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
import { DeriveAccountInfo, DeriveAccountRegistration } from '../types';
import { DeriveAccountFlags, DeriveAccountInfo, DeriveAccountRegistration } from '../types';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { Bytes, Data, Option, u32 } from '@polkadot/types';
import { Bytes, Data, Option, u32, Vec } from '@polkadot/types';
import { u8aToString } from '@polkadot/util';
import { memo } from '../util';
@@ -22,6 +22,12 @@ function dataAsString (data: Data): string | undefined {
: undefined;
}
function includedWrapper (accountId?: AccountId): (_: AccountId) => boolean {
return function (id: AccountId): boolean {
return id.eq(accountId);
};
}
function retrieveNick (api: ApiInterfaceRx, accountId?: AccountId): Observable<string | undefined> {
return ((
accountId && api.query.nicks?.nameOf
@@ -109,6 +115,39 @@ function retrieveIdentity (api: ApiInterfaceRx, accountId?: AccountId): Observab
);
}
function retrieveFlags (api: ApiInterfaceRx, accountId?: AccountId): Observable<DeriveAccountFlags> {
const councilSection = api.query.electionsPhragmen ? 'electionsPhragmen' : 'elections';
return combineLatest([
api.query[councilSection]?.members
? api.query[councilSection].members<Vec<ITuple<[AccountId, Balance]>>>()
: of(undefined),
api.query.council?.members
? api.query.council.members()
: of([]),
api.query.technicalCommittee?.members
? api.query.technicalCommittee.members()
: of([]),
api.query.society?.members
? api.query.society.members()
: of([]),
api.query.sudo?.key
? api.query.sudo.key()
: of(undefined)
]).pipe(
map(([electionsMembers, councilMembers, technicalCommitteeMembers, societyMembers, sudoKey]): DeriveAccountFlags => {
const checkIncluded = includedWrapper(accountId);
return {
isCouncil: (electionsMembers?.map(([id]) => id) || councilMembers || []).some(checkIncluded),
isTechCommittee: technicalCommitteeMembers.some(checkIncluded),
isSociety: societyMembers.some(checkIncluded),
isSudo: !!sudoKey && sudoKey.eq(accountId)
};
})
);
}
/**
* @name info
* @description Returns aux. info with regards to an account, current that includes the accountId, accountIndex and nickname
@@ -116,15 +155,16 @@ function retrieveIdentity (api: ApiInterfaceRx, accountId?: AccountId): Observab
export function info (api: ApiInterfaceRx): (address?: AccountIndex | AccountId | Address | string | null) => Observable<DeriveAccountInfo> {
return memo((address?: AccountIndex | AccountId | Address | string | null): Observable<DeriveAccountInfo> =>
api.derive.accounts.idAndIndex(address).pipe(
switchMap(([accountId, accountIndex]): Observable<[Partial<DeriveAccountInfo>, DeriveAccountRegistration, string?]> =>
switchMap(([accountId, accountIndex]): Observable<[Partial<DeriveAccountInfo>, DeriveAccountFlags, DeriveAccountRegistration, string?]> =>
combineLatest([
of({ accountId, accountIndex }),
retrieveFlags(api, accountId),
retrieveIdentity(api, accountId),
retrieveNick(api, accountId)
])
),
map(([{ accountId, accountIndex }, identity, nickname]): DeriveAccountInfo => ({
accountId, accountIndex, identity, nickname
map(([{ accountId, accountIndex }, flags, identity, nickname]): DeriveAccountInfo => ({
accountId, accountIndex, ...flags, identity, nickname
}))
));
}
+4 -5
View File
@@ -6,10 +6,9 @@ import { AccountId, AccountData, AccountIndex, AccountInfo, Address, Balance, In
import { ITuple } from '@polkadot/types/types';
import { DerivedBalancesAccount } from '../types';
import { combineLatest, of, Observable } from 'rxjs';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { createType } from '@polkadot/types';
import { memo } from '../util';
@@ -23,7 +22,7 @@ function calcBalances (api: ApiInterfaceRx, [accountId, [freeBalance, reservedBa
frozenFee,
frozenMisc,
reservedBalance,
votingBalance: createType(api.registry, 'Balance', freeBalance.add(reservedBalance))
votingBalance: api.registry.createType('Balance', freeBalance.add(reservedBalance))
};
}
@@ -35,7 +34,7 @@ function queryBalancesFree (api: ApiInterfaceRx, accountId: AccountId): Observab
[api.query.system.accountNonce, accountId]
]).pipe(
map(([freeBalance, reservedBalance, accountNonce]): Result =>
[freeBalance, reservedBalance, createType(api.registry, 'Balance'), createType(api.registry, 'Balance'), accountNonce]
[freeBalance, reservedBalance, api.registry.createType('Balance'), api.registry.createType('Balance'), accountNonce]
)
);
}
@@ -93,7 +92,7 @@ export function account (api: ApiInterfaceRx): (address: AccountIndex | AccountI
? queryBalancesAccount(api, accountId)
: queryBalancesFree(api, accountId)
])
: of([createType(api.registry, 'AccountId'), [createType(api.registry, 'Balance'), createType(api.registry, 'Balance'), createType(api.registry, 'Balance'), createType(api.registry, 'Balance'), createType(api.registry, 'Index')]])
: of([api.registry.createType('AccountId'), [api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Index')]])
)
),
map((result): DerivedBalancesAccount => calcBalances(api, result))
+10 -10
View File
@@ -6,10 +6,10 @@ import { AccountId, AccountIndex, Address, Balance, BalanceLock, BalanceLockTo21
import { DerivedBalancesAccount, DerivedBalancesAll } from '../types';
import BN from 'bn.js';
import { combineLatest, of, Observable } from 'rxjs';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Option, Vec, createType } from '@polkadot/types';
import { Option, Vec } from '@polkadot/types';
import { bnMax } from '@polkadot/util';
import { memo } from '../util';
@@ -18,7 +18,7 @@ type ResultBalance = [VestingInfo | null, (BalanceLock | BalanceLockTo212)[]];
type Result = [DerivedBalancesAccount, BlockNumber, ResultBalance];
function calcBalances (api: ApiInterfaceRx, [{ accountId, accountNonce, freeBalance, frozenFee, frozenMisc, reservedBalance, votingBalance }, bestNumber, [vesting, locks]]: Result): DerivedBalancesAll {
let lockedBalance = createType(api.registry, 'Balance');
let lockedBalance = api.registry.createType('Balance');
let lockedBreakdown: (BalanceLock | BalanceLockTo212)[] = [];
let allLocked = false;
@@ -32,16 +32,16 @@ function calcBalances (api: ApiInterfaceRx, [{ accountId, accountNonce, freeBala
// get the maximum of the locks according to https://github.com/paritytech/substrate/blob/master/srml/balances/src/lib.rs#L699
if (notAll.length) {
lockedBalance = createType(api.registry, 'Balance', bnMax(...notAll.map(({ amount }): Balance => amount)));
lockedBalance = api.registry.createType('Balance', bnMax(...notAll.map(({ amount }): Balance => amount)));
}
}
// Calculate the vesting balances,
// - offset = balance locked at startingBlock
// - perBlock is the unlock amount
const { locked: vestingTotal, perBlock, startingBlock } = vesting || createType(api.registry, 'VestingInfo');
const { locked: vestingTotal, perBlock, startingBlock } = vesting || api.registry.createType('VestingInfo');
const isStarted = bestNumber.gt(startingBlock);
const vestedBalance = createType(api.registry, 'Balance', isStarted ? perBlock.mul(bestNumber.sub(startingBlock)) : 0);
const vestedBalance = api.registry.createType('Balance', isStarted ? perBlock.mul(bestNumber.sub(startingBlock)) : 0);
const isVesting = isStarted && vestedBalance.lt(vestingTotal);
// The available balance & vested has an interplay here
@@ -53,7 +53,7 @@ function calcBalances (api: ApiInterfaceRx, [{ accountId, accountNonce, freeBala
// ""
const floating = freeBalance.sub(lockedBalance);
const extraReceived = isVesting ? freeBalance.sub(vestingTotal) : new BN(0);
const availableBalance = createType(api.registry, 'Balance', allLocked ? 0 : bnMax(new BN(0), isVesting && floating.gt(vestedBalance) ? vestedBalance.add(extraReceived) : floating));
const availableBalance = api.registry.createType('Balance', allLocked ? 0 : bnMax(new BN(0), isVesting && floating.gt(vestedBalance) ? vestedBalance.add(extraReceived) : floating));
return {
accountId,
@@ -84,7 +84,7 @@ function queryOld (api: ApiInterfaceRx, accountId: AccountId): Observable<Result
if (optVesting.isSome) {
const { offset: locked, perBlock, startingBlock } = optVesting.unwrap();
vestingNew = createType(api.registry, 'VestingInfo', { locked, perBlock, startingBlock });
vestingNew = api.registry.createType('VestingInfo', { locked, perBlock, startingBlock });
}
return [vestingNew, locks];
@@ -102,7 +102,7 @@ function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Re
])
: api.query.balances.locks(accountId).pipe(
map((locks): [Vec<BalanceLock>, Option<VestingInfo>] =>
[locks, createType(api.registry, 'Option<VestingInfo>')]
[locks, api.registry.createType('Option<VestingInfo>')]
)
)
).pipe(
@@ -139,7 +139,7 @@ export function all (api: ApiInterfaceRx): (address: AccountIndex | AccountId |
? queryCurrent(api, account.accountId)
: queryOld(api, account.accountId)
])
: of([account, createType(api.registry, 'BlockNumber'), [null, createType(api.registry, 'Vec<BalanceLock>')]])
: of([account, api.registry.createType('BlockNumber'), [null, api.registry.createType('Vec<BalanceLock>')]])
)
),
map((result): DerivedBalancesAll => calcBalances(api, result))
+5 -6
View File
@@ -8,7 +8,6 @@ import { DerivedFees } from '../types';
import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { createType } from '@polkadot/types';
import { memo } from '../util';
@@ -29,13 +28,13 @@ export function fees (api: ApiInterfaceRx): () => Observable<DerivedFees> {
return memo((): Observable<DerivedFees> =>
of([
// deprecated - remove
(api.consts.balances?.creationFee as Balance) || createType(api.registry, 'Balance'),
(api.consts.balances?.transferFee as Balance) || createType(api.registry, 'Balance'),
(api.consts.balances?.creationFee as Balance) || api.registry.createType('Balance'),
(api.consts.balances?.transferFee as Balance) || api.registry.createType('Balance'),
// current
(api.consts.balances?.existentialDeposit as Balance) || createType(api.registry, 'Balance'),
(api.consts.transactionPayment?.transactionBaseFee as Balance) || createType(api.registry, 'Balance'),
(api.consts.transactionPayment?.transactionByteFee as Balance) || createType(api.registry, 'Balance')
(api.consts.balances?.existentialDeposit as Balance) || api.registry.createType('Balance'),
(api.consts.transactionPayment?.transactionBaseFee as Balance) || api.registry.createType('Balance'),
(api.consts.transactionPayment?.transactionByteFee as Balance) || api.registry.createType('Balance')
]).pipe(
map(([creationFee, transferFee, existentialDeposit, transactionBaseFee, transactionByteFee]): DerivedFees => ({
creationFee,
@@ -5,7 +5,7 @@
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
import { DerivedBalancesAccount } from '../types';
import { combineLatest, Observable, of } from 'rxjs';
import { Observable, combineLatest, of } from 'rxjs';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { memo } from '../util';
@@ -16,7 +16,8 @@ export function votingBalances (api: ApiInterfaceRx): (addresses?: (AccountId |
? of([] as DerivedBalancesAccount[])
: combineLatest(
addresses.map((accountId): Observable<DerivedBalancesAccount> =>
api.derive.balances.account(accountId))
api.derive.balances.account(accountId)
)
)
);
}
@@ -7,7 +7,6 @@ import { BlockNumber } from '@polkadot/types/interfaces';
import { Observable, combineLatest } from 'rxjs';
import { map } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { createType } from '@polkadot/types';
import { memo } from '../util';
@@ -31,7 +30,7 @@ export function bestNumberLag (api: ApiInterfaceRx): () => Observable<BlockNumbe
api.derive.chain.bestNumberFinalized()
]).pipe(
map(([bestNumber, bestNumberFinalized]): BlockNumber =>
createType(api.registry, 'BlockNumber', bestNumber.sub(bestNumberFinalized))
api.registry.createType('BlockNumber', bestNumber.sub(bestNumberFinalized))
)
));
}
@@ -6,7 +6,7 @@ import { ApiInterfaceRx } from '@polkadot/api/types';
import { Hash, Proposal, Votes } from '@polkadot/types/interfaces';
import { DerivedCollectiveProposal } from '../types';
import { combineLatest, Observable, of } from 'rxjs';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { Option } from '@polkadot/types';
+2 -3
View File
@@ -8,7 +8,6 @@ import { DerivedContractFees } from '../types';
import BN from 'bn.js';
import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { createType } from '@polkadot/types';
import { memo } from '../util';
@@ -18,8 +17,8 @@ type ResultV2 = [BN, BN, BN, BN, BN, BN, BN, BN, BN];
function queryConstants (api: ApiInterfaceRx): Observable<ResultV2> {
return of([
// deprecated
api.consts.contracts.creationFee || createType(api.registry, 'Balance'),
api.consts.contracts.transferFee || createType(api.registry, 'Balance'),
api.consts.contracts.creationFee || api.registry.createType('Balance'),
api.consts.contracts.transferFee || api.registry.createType('Balance'),
// current
api.consts.contracts.callBaseFee,
@@ -9,7 +9,7 @@ import { DeriveProposal } from '../types';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Bytes, Option, Vec, createType } from '@polkadot/types';
import { Bytes, Option, Vec } from '@polkadot/types';
import { memo } from '../util';
@@ -37,7 +37,7 @@ function parse (api: ApiInterfaceRx, { depositors, proposals, preimages }: Resul
// we could end up in a situation where the proposal is non-decodable, e.g. after an upgrade
if (preimage) {
try {
proposal = createType(api.registry, 'Proposal', preimage[0].toU8a(true));
proposal = api.registry.createType('Proposal', preimage[0].toU8a(true));
} catch (error) {
console.error(error);
}
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { ReferendumInfo } from '@polkadot/types/interfaces/democracy';
import { ReferendumInfo, ReferendumInfoTo239, ReferendumStatus } from '@polkadot/types/interfaces';
import { DerivedReferendum } from '../types';
import { PreImage } from './proposals';
@@ -10,26 +10,41 @@ import BN from 'bn.js';
import { Observable, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Option, createType } from '@polkadot/types';
import { Option } from '@polkadot/types';
import { memo } from '../util';
function constructInfo (api: ApiInterfaceRx, index: BN | number, _info: Option<ReferendumInfo>, _preimage?: PreImage): DerivedReferendum | null {
const preImage = _preimage?.isSome
? _preimage.unwrap()
: null;
const info = _info.unwrapOr(null);
function isOld (info: ReferendumInfo | ReferendumInfoTo239): info is ReferendumInfoTo239 {
return !!(info as ReferendumInfoTo239).proposalHash;
}
if (!info) {
function getStatus (info: Option<ReferendumInfo | ReferendumInfoTo239>): ReferendumStatus | ReferendumInfoTo239 | null {
if (info.isNone) {
return null;
}
const unwrapped = info.unwrap();
if (isOld(unwrapped)) {
return unwrapped;
} else if (unwrapped.isOngoing) {
return unwrapped.asOngoing;
}
// done, we don't include it here... only currently active
return null;
}
function constructInfo (api: ApiInterfaceRx, index: BN | number, status: ReferendumStatus | ReferendumInfoTo239, _preimage?: PreImage): DerivedReferendum | null {
const preImage = _preimage?.isSome
? _preimage.unwrap()
: null;
return {
index: createType(api.registry, 'PropIndex', index),
info,
hash: info.proposalHash,
index: api.registry.createType('PropIndex', index),
hash: status.proposalHash,
proposal: preImage
? createType(api.registry, 'Proposal', preImage[0].toU8a(true))
? api.registry.createType('Proposal', preImage[0].toU8a(true))
: undefined,
preimage: preImage
? {
@@ -37,25 +52,26 @@ function constructInfo (api: ApiInterfaceRx, index: BN | number, _info: Option<R
balance: preImage[2],
proposer: preImage[1]
}
: undefined
: undefined,
status
};
}
export function retrieveInfo (api: ApiInterfaceRx, index: BN | number, info: Option<ReferendumInfo>): Observable<DerivedReferendum | null> {
return ((
info?.isSome
? api.query.democracy.preimages(info.unwrap().proposalHash)
: of(undefined)
) as Observable<PreImage | undefined>).pipe(
map((preimage?: PreImage): DerivedReferendum | null =>
constructInfo(api, index, info, preimage)
export function retrieveInfo (api: ApiInterfaceRx, index: BN | number, info: Option<ReferendumInfo | ReferendumInfoTo239>): Observable<DerivedReferendum | null> {
const status = getStatus(info);
return status
? api.query.democracy.preimages(status.proposalHash).pipe(
map((preimage?: PreImage): DerivedReferendum | null =>
constructInfo(api, index, status, preimage)
)
)
);
: of(null);
}
export function referendumInfo (api: ApiInterfaceRx): (index: BN | number) => Observable<DerivedReferendum | null> {
return memo((index: BN | number): Observable<DerivedReferendum | null> =>
api.query.democracy.referendumInfoOf<Option<ReferendumInfo>>(index).pipe(
api.query.democracy.referendumInfoOf<Option<ReferendumInfo | ReferendumInfoTo239>>(index).pipe(
switchMap((info): Observable<DerivedReferendum | null> =>
retrieveInfo(api, index, info)
)
@@ -23,7 +23,7 @@ export function referendumInfos (api: ApiInterfaceRx): (ids?: (BN | number)[]) =
).pipe(
switchMap((infos): Observable<(DerivedReferendum | null)[]> =>
combineLatest(
...ids.map((id, index): Observable<DerivedReferendum | null> =>
ids.map((id, index): Observable<DerivedReferendum | null> =>
retrieveInfo(api, id, infos[index])
)
)
@@ -5,10 +5,10 @@
import { AccountId, Vote } from '@polkadot/types/interfaces';
import BN from 'bn.js';
import { combineLatest, Observable, of } from 'rxjs';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Vec, createType } from '@polkadot/types';
import { Vec } from '@polkadot/types';
import { DerivedBalancesAccount, DerivedReferendumVote } from '../types';
import { memo } from '../util';
@@ -26,8 +26,8 @@ export function referendumVotesFor (api: ApiInterfaceRx): (referendumId: BN | nu
map(([votersFor, votes, balances]): DerivedReferendumVote[] =>
votersFor.map((accountId, index): DerivedReferendumVote => ({
accountId,
balance: balances[index].votingBalance || createType(api.registry, 'Balance'),
vote: votes[index] || createType(api.registry, 'Vote')
balance: balances[index].votingBalance || api.registry.createType('Balance'),
vote: votes[index] || api.registry.createType('Vote')
} as DerivedReferendumVote))
)
));
+3 -3
View File
@@ -8,7 +8,7 @@ import { ITuple } from '@polkadot/types/types';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { createType, Vec, u32 } from '@polkadot/types';
import { Vec, u32 } from '@polkadot/types';
import { DerivedElectionsInfo } from '../types';
import { memo } from '../util';
@@ -28,12 +28,12 @@ function queryElections (api: ApiInterfaceRx): Observable<DerivedElectionsInfo>
]).pipe(
map(([councilMembers, candidates, members, runnersUp]): DerivedElectionsInfo => ({
candidates,
candidateCount: createType(api.registry, 'u32', candidates.length),
candidateCount: api.registry.createType('u32', candidates.length),
candidacyBond: api.consts[section].candidacyBond as Balance,
desiredSeats: api.consts[section].desiredMembers as u32,
members: members.length
? members.sort(sortAccounts)
: councilMembers.map((accountId): [AccountId, Balance] => [accountId, createType(api.registry, 'Balance')]),
: councilMembers.map((accountId): [AccountId, Balance] => [accountId, api.registry.createType('Balance')]),
runnersUp: runnersUp.sort(sortAccounts),
termDuration: api.consts[section].termDuration as BlockNumber,
votingBond: api.consts[section].votingBond as Balance
@@ -5,7 +5,7 @@
import { AccountId } from '@polkadot/types/interfaces';
import { DerivedHeartbeats } from '../types';
import { of, Observable, combineLatest } from 'rxjs';
import { Observable, of, combineLatest } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Bytes, Option, u32 } from '@polkadot/types';
+1 -1
View File
@@ -61,7 +61,7 @@ describe('derive', (): void => {
testFunction(api)('session', 'sessionProgress', []);
testFunction(api)('staking', 'account', []);
testFunction(api)('staking', 'controllers', []);
testFunction(api)('staking', 'stashes', []);
});
describe('custom', (): void => {
+1 -2
View File
@@ -9,7 +9,6 @@ import { Active, DidUpdate, Heads, ParaInfoResult, PendingSwap, RelayDispatchQue
import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { createType } from '@polkadot/types';
import { memo } from '../util';
@@ -92,7 +91,7 @@ export function info (api: ApiInterfaceRx): (id: ParaId | number) => Observable<
])
.pipe(
map((result: Result): DeriveParachainFull | null =>
parse(createType(api.registry, 'ParaId', id), result)
parse(api.registry.createType('ParaId', id), result)
)
)
: of(null)
+8 -8
View File
@@ -8,7 +8,7 @@ import { DeriveSessionIndexes } from '../types';
import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { createType, Option, u32 } from '@polkadot/types';
import { Option, u32 } from '@polkadot/types';
import { memo } from '../util';
@@ -34,7 +34,7 @@ function queryNoActive (api: ApiInterfaceRx): Observable<Result> {
]).pipe(
map(([currentEra, currentIndex, validatorCount]): Result => [
currentEra,
createType(api.registry, 'Option<Moment>'),
api.registry.createType('Option<Moment>'),
currentEra,
currentIndex,
validatorCount
@@ -56,7 +56,7 @@ function query (api: ApiInterfaceRx): Observable<Result> {
return [
activeEra,
activeEraStart,
currentEra.unwrapOr(createType(api.registry, 'EraIndex')),
currentEra.unwrapOr(api.registry.createType('EraIndex')),
currentIndex,
validatorCount
];
@@ -67,11 +67,11 @@ function query (api: ApiInterfaceRx): Observable<Result> {
// empty set when none is available
function empty (api: ApiInterfaceRx): Observable<Result> {
return of([
createType(api.registry, 'EraIndex'),
createType(api.registry, 'Option<Moment>'),
createType(api.registry, 'EraIndex'),
createType(api.registry, 'SessionIndex', 1),
createType(api.registry, 'u32')
api.registry.createType('EraIndex'),
api.registry.createType('Option<Moment>'),
api.registry.createType('EraIndex'),
api.registry.createType('SessionIndex', 1),
api.registry.createType('u32')
]);
}
+11 -11
View File
@@ -8,7 +8,7 @@ import { DerivedSessionInfo, DeriveSessionIndexes } from '../types';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { createType, Option, u64 } from '@polkadot/types';
import { Option, u64 } from '@polkadot/types';
import { memo } from '../util';
@@ -27,12 +27,12 @@ function createDerived (api: ApiInterfaceRx, [[hasBabe, epochDuration, sessionsP
activeEraStart,
currentEra,
currentIndex,
eraLength: createType(api.registry, 'BlockNumber', sessionsPerEra.mul(epochDuration)),
eraProgress: createType(api.registry, 'BlockNumber', eraProgress),
eraLength: api.registry.createType('BlockNumber', sessionsPerEra.mul(epochDuration)),
eraProgress: api.registry.createType('BlockNumber', eraProgress),
isEpoch: hasBabe,
sessionLength: epochDuration,
sessionsPerEra,
sessionProgress: createType(api.registry, 'BlockNumber', sessionProgress),
sessionProgress: api.registry.createType('BlockNumber', sessionProgress),
validatorCount
};
}
@@ -43,15 +43,15 @@ function queryAura (api: ApiInterfaceRx): Observable<DerivedSessionInfo> {
createDerived(api, [
[
false,
createType(api.registry, 'u64', 1),
api.consts.staking?.sessionsPerEra || createType(api.registry, 'SessionIndex', 1)
api.registry.createType('u64', 1),
api.consts.staking?.sessionsPerEra || api.registry.createType('SessionIndex', 1)
],
indexes,
[
createType(api.registry, 'u64', 1),
createType(api.registry, 'u64', 1),
createType(api.registry, 'u64', 1),
createType(api.registry, 'SessionIndex', 1)
api.registry.createType('u64', 1),
api.registry.createType('u64', 1),
api.registry.createType('u64', 1),
api.registry.createType('SessionIndex', 1)
]
])
)
@@ -72,7 +72,7 @@ function queryBabe (api: ApiInterfaceRx): Observable<[DeriveSessionIndexes, Resu
])
),
map(([indexes, [currentSlot, epochIndex, genesisSlot, optStartIndex]]): [DeriveSessionIndexes, ResultSlotsFlat] => [
indexes, [currentSlot, epochIndex, genesisSlot, optStartIndex.unwrapOr(createType(api.registry, 'SessionIndex', 1))]
indexes, [currentSlot, epochIndex, genesisSlot, optStartIndex.unwrapOr(api.registry.createType('SessionIndex', 1))]
])
);
}
@@ -7,7 +7,7 @@ import { AccountId, BalanceOf, Bid, BidKind } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
import { DeriveSocietyCandidate } from '../types';
import { combineLatest, of, Observable } from 'rxjs';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { Option, Vec } from '@polkadot/types';
+6 -4
View File
@@ -6,7 +6,7 @@ import { ApiInterfaceRx } from '@polkadot/api/types';
import { AccountId } from '@polkadot/types/interfaces';
import { DeriveSocietyMember } from '../types';
import { combineLatest, Observable } from 'rxjs';
import { Observable, combineLatest } from 'rxjs';
import { switchMap } from 'rxjs/operators';
import { memo } from '../util';
@@ -18,9 +18,11 @@ export function members (api: ApiInterfaceRx): () => Observable<DeriveSocietyMem
return memo((): Observable<DeriveSocietyMember[]> =>
api.query.society.members<AccountId[]>().pipe(
switchMap((members): Observable<DeriveSocietyMember[]> =>
combineLatest(members.map((accountId): Observable<DeriveSocietyMember> =>
api.derive.society.member(accountId)
))
combineLatest(
members.map((accountId): Observable<DeriveSocietyMember> =>
api.derive.society.member(accountId)
)
)
)
)
);
+5 -6
View File
@@ -7,9 +7,8 @@ import { Balance, BlockNumber, StakingLedger, UnlockChunk } from '@polkadot/type
import { DerivedSessionInfo, DerivedStakingAccount, DerivedStakingQuery, DerivedUnlocking } from '../types';
import BN from 'bn.js';
import { combineLatest, Observable } from 'rxjs';
import { Observable, combineLatest } from 'rxjs';
import { map } from 'rxjs/operators';
import { createType } from '@polkadot/types';
import { isUndefined } from '@polkadot/util';
@@ -33,7 +32,7 @@ function remainingBlocks (api: ApiInterfaceRx, era: BN, sessionInfo: DerivedSess
const remaining = era.sub(sessionInfo.currentEra);
// on the Rust side the current-era >= era-for-unlock (removal done on >)
return createType(api.registry, 'BlockNumber', remaining.gtn(0)
return api.registry.createType('BlockNumber', remaining.gtn(0)
? remaining
.subn(1)
.mul(sessionInfo.eraLength)
@@ -58,7 +57,7 @@ function calculateUnlocking (api: ApiInterfaceRx, stakingLedger: StakingLedger |
// group the unlock chunks that have the same era and sum their values
const groupedResult = groupByEra(unlockingChunks);
const results = Object.entries(groupedResult).map(([eraString, value]): DerivedUnlocking => ({
value: createType(api.registry, 'Balance', value),
value: api.registry.createType('Balance', value),
remainingBlocks: remainingBlocks(api, new BN(eraString), sessionInfo)
}));
@@ -67,10 +66,10 @@ function calculateUnlocking (api: ApiInterfaceRx, stakingLedger: StakingLedger |
function redeemableSum (api: ApiInterfaceRx, stakingLedger: StakingLedger | undefined, sessionInfo: DerivedSessionInfo): Balance {
if (isUndefined(stakingLedger)) {
return createType(api.registry, 'Balance');
return api.registry.createType('Balance');
}
return createType(api.registry, 'Balance', stakingLedger.unlocking.reduce((total, { era, value }): BN => {
return api.registry.createType('Balance', stakingLedger.unlocking.reduce((total, { era, value }): BN => {
return remainingBlocks(api, era.unwrap(), sessionInfo).eqn(0)
? total.add(value.unwrap())
: total;
@@ -1,33 +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, ValidatorPrefs } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
import { Observable, combineLatest, of } from 'rxjs';
import { switchMap } from 'rxjs/operators';
import { Option, Vec } from '@polkadot/types';
import { memo } from '../util';
type DeriveControllers = [AccountId[], Option<AccountId>[]];
/**
* @description From the list of stash accounts, retrieve the list of controllers
*/
export function controllers (api: ApiInterfaceRx): () => Observable<DeriveControllers> {
return memo((): Observable<[AccountId[], Option<AccountId>[]]> =>
api.query.staking.validators<ITuple<[Vec<AccountId>, Vec<ValidatorPrefs>]>>().pipe(
switchMap(([stashIds]): Observable<DeriveControllers> =>
combineLatest([
of(stashIds),
// for V2, don't return all the controllers, we call bonded at a later point
api.consts.session
? of([])
: api.query.staking.bonded.multi<Option<AccountId>>(stashIds)
])
)
));
}
@@ -17,9 +17,11 @@ export function electedInfo (api: ApiInterfaceRx): () => Observable<DerivedStaki
switchMap(({ nextElected }): Observable<[AccountId[], DerivedStakingQuery[]]> =>
combineLatest([
of(nextElected),
combineLatest(nextElected.map((accountId): Observable<DerivedStakingQuery> =>
api.derive.staking.query(accountId)
))
combineLatest(
nextElected.map((accountId): Observable<DerivedStakingQuery> =>
api.derive.staking.query(accountId)
)
)
])
),
map(([nextElected, info]): DerivedStakingElected => ({
+18 -20
View File
@@ -8,12 +8,14 @@ import { DeriveEraExposure, DeriveEraNominatorExposure, DeriveEraValidatorExposu
import BN from 'bn.js';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap, take } from 'rxjs/operators';
import { map, switchMap } from 'rxjs/operators';
import { StorageKey } from '@polkadot/types';
import { memo } from '../util';
function mapStakers (era: EraIndex, stakers: [StorageKey, Exposure][]): DeriveEraExposure {
type KeysAndExposures = [StorageKey, Exposure][];
function mapStakers (era: EraIndex, stakers: KeysAndExposures): DeriveEraExposure {
const nominators: DeriveEraNominatorExposure = {};
const validators: DeriveEraValidatorExposure = {};
@@ -33,27 +35,23 @@ function mapStakers (era: EraIndex, stakers: [StorageKey, Exposure][]): DeriveEr
return { era, nominators, validators };
}
export function eraExposure (api: ApiInterfaceRx): (era: EraIndex) => Observable<DeriveEraExposure> {
return memo((era: EraIndex): Observable<DeriveEraExposure> =>
api.query.staking.erasStakersClipped.entries(era).pipe(
map((stakers) => mapStakers(era, stakers))
)
);
}
export function erasExposure (api: ApiInterfaceRx): (withActive?: boolean | BN | number) => Observable<DeriveEraExposure[]> {
return memo((withActive?: boolean | BN | number): Observable<DeriveEraExposure[]> =>
api.derive.staking.erasHistoric(withActive).pipe(
switchMap((eras): Observable<[EraIndex[], [StorageKey, Exposure][][]]> =>
combineLatest([
of(eras),
eras.length
? combineLatest(
// we could just do entries over the full set, however the set can be quite large - split it into
// batches - may need to re-visit this, or alternatively use pages keys for exceptionally large sets
eras.map((era): Observable<[StorageKey, Exposure][]> =>
api.query.staking.erasStakersClipped.entries(era).pipe(take(1))
)
)
: of([])
])
),
map(([eras, erasStakers]): DeriveEraExposure[] =>
eras.map((era, index): DeriveEraExposure =>
mapStakers(era, erasStakers[index])
)
switchMap((eras): Observable<DeriveEraExposure[]> =>
eras.length
? combineLatest(
eras.map((era) => api.derive.staking.eraExposure(era))
)
: of([])
)
)
);
@@ -0,0 +1,46 @@
// 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 { EraIndex, ValidatorPrefs } from '@polkadot/types/interfaces';
import { DeriveEraPrefs, DeriveEraValPrefs } from '../types';
import BN from 'bn.js';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { StorageKey } from '@polkadot/types';
import { memo } from '../util';
function mapPrefs (era: EraIndex, all: [StorageKey, ValidatorPrefs][]): DeriveEraPrefs {
const validators: DeriveEraValPrefs = {};
all.forEach(([key, prefs]): void => {
validators[key.args[1].toString()] = prefs;
});
return { era, validators };
}
export function eraPrefs (api: ApiInterfaceRx): (era: EraIndex) => Observable<DeriveEraPrefs> {
return memo((era: EraIndex): Observable<DeriveEraPrefs> =>
api.query.staking.erasValidatorPrefs.entries(era).pipe(
map((prefs) => mapPrefs(era, prefs))
)
);
}
export function erasPrefs (api: ApiInterfaceRx): (withActive?: boolean | BN | number) => Observable<DeriveEraPrefs[]> {
return memo((withActive?: boolean | BN | number): Observable<DeriveEraPrefs[]> =>
api.derive.staking.erasHistoric(withActive).pipe(
switchMap((eras): Observable<DeriveEraPrefs[]> =>
eras.length
? combineLatest(
eras.map((era) => api.derive.staking.eraPrefs(era))
)
: of([])
)
)
);
}
@@ -0,0 +1,55 @@
// 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 { BalanceOf, EraIndex, Perbill } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
import { DeriveEraSlashes, DeriveEraValSlash } from '../types';
import BN from 'bn.js';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { Option, StorageKey } from '@polkadot/types';
import { memo } from '../util';
function mapSlashes (era: EraIndex, noms: [StorageKey, Option<BalanceOf>][], vals: [StorageKey, Option<ITuple<[Perbill, BalanceOf]>>][]): DeriveEraSlashes {
const nominators: DeriveEraValSlash = {};
const validators: DeriveEraValSlash = {};
noms.forEach(([key, optBalance]): void => {
nominators[key.args[1].toString()] = optBalance.unwrap();
});
vals.forEach(([key, optRes]): void => {
validators[key.args[1].toString()] = optRes.unwrapOrDefault()[1];
});
return { era, nominators, validators };
}
export function eraSlashes (api: ApiInterfaceRx): (era: EraIndex) => Observable<DeriveEraSlashes> {
return memo((era: EraIndex): Observable<DeriveEraSlashes> =>
combineLatest([
api.query.staking.nominatorSlashInEra.entries(era),
api.query.staking.validatorSlashInEra.entries(era)
]).pipe(
map(([noms, vals]) => mapSlashes(era, noms, vals))
)
);
}
export function erasSlashes (api: ApiInterfaceRx): (withActive?: boolean | BN | number) => Observable<DeriveEraSlashes[]> {
return memo((withActive?: boolean | BN | number): Observable<DeriveEraSlashes[]> =>
api.derive.staking.erasHistoric(withActive).pipe(
switchMap((eras): Observable<DeriveEraSlashes[]> =>
eras.length
? combineLatest(
eras.map((era) => api.derive.staking.eraSlashes(era))
)
: of([])
)
)
);
}
+6 -1
View File
@@ -6,12 +6,17 @@ export * from './account';
export * from './erasExposure';
export * from './erasHistoric';
export * from './erasPoints';
export * from './erasPrefs';
export * from './erasRewards';
export * from './controllers';
export * from './erasSlashes';
export * from './electedInfo';
export * from './overview';
export * from './ownExposure';
export * from './ownSlashes';
export * from './query';
export * from './stakerExposure';
export * from './stakerPoints';
export * from './stakerRewards';
export * from './stakerSlashes';
export * from './stashes';
export * from './validators';
+7 -8
View File
@@ -2,24 +2,23 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, EraIndex, EraPoints, EraRewardPoints, RewardPoint } from '@polkadot/types/interfaces';
import { AccountId, EraPoints, EraRewardPoints, RewardPoint } from '@polkadot/types/interfaces';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { DerivedStakingOverview } from '../types';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { createType } from '@polkadot/types';
import { memo } from '../util';
function retrievePointsPrev (api: ApiInterfaceRx, activeEra: EraIndex, currentElected: AccountId[]): Observable<EraRewardPoints> {
return api.query.staking.currentEraPointsEarned<EraPoints>(activeEra).pipe(
function retrievePointsPrev (api: ApiInterfaceRx, currentElected: AccountId[]): Observable<EraRewardPoints> {
return api.query.staking.currentEraPointsEarned<EraPoints>().pipe(
map(({ individual, total }): EraRewardPoints =>
createType(api.registry, 'EraRewardPoints', {
api.registry.createType('EraRewardPoints', {
total,
individual: new Map<AccountId, RewardPoint>(
individual
.map((points): RewardPoint => createType(api.registry, 'RewardPoint', points))
.map((points): RewardPoint => api.registry.createType('RewardPoint', points))
.map((points, index): [AccountId, RewardPoint] => [currentElected[index], points])
)
})
@@ -42,8 +41,8 @@ export function overview (api: ApiInterfaceRx): () => Observable<DerivedStakingO
api.query.staking.erasRewardPoints
? api.query.staking.erasRewardPoints<EraRewardPoints>(indexes.activeEra)
: api.query.staking.currentEraPointsEarned
? retrievePointsPrev(api, indexes.activeEra, nextElected)
: of(createType(api.registry, 'EraRewardPoints'))
? retrievePointsPrev(api, nextElected)
: of(api.registry.createType('EraRewardPoints'))
])
),
map(([info, eraPoints]): DerivedStakingOverview => ({
@@ -0,0 +1,37 @@
// 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 { DeriveOwnExposure } from '../types';
import BN from 'bn.js';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { memo } from '../util';
export function ownExposure (api: ApiInterfaceRx): (accountId: Uint8Array | string, withActive?: boolean | BN | number) => Observable<DeriveOwnExposure[]> {
return memo((accountId: Uint8Array | string, withActive?: boolean | BN | number): Observable<DeriveOwnExposure[]> => {
return api.derive.staking.erasHistoric(withActive).pipe(
switchMap((eras) =>
eras.length
? combineLatest(
eras.map((era) => combineLatest([
of(era),
api.query.staking.erasStakersClipped(era, accountId),
api.query.staking.erasStakers(era, accountId)
]))
)
: of([])
),
map((result): DeriveOwnExposure[] =>
result.map(([era, clipped, exposure]): DeriveOwnExposure => ({
clipped,
era,
exposure
}))
)
);
});
}
@@ -0,0 +1,40 @@
// 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 { DeriveStakerSlashes } from '../types';
import BN from 'bn.js';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { memo } from '../util';
export function ownSlashes (api: ApiInterfaceRx): (accountId: Uint8Array | string, withActive?: boolean | BN | number) => Observable<DeriveStakerSlashes[]> {
return memo((accountId: Uint8Array | string, withActive?: boolean | BN | number): Observable<DeriveStakerSlashes[]> => {
return api.derive.staking.erasHistoric(withActive).pipe(
switchMap((eras) =>
eras.length
? combineLatest(
eras.map((era) => combineLatest([
of(era),
api.query.staking.nominatorSlashInEra(era, accountId),
api.query.staking.validatorSlashInEra(era, accountId)
]))
)
: of([])
),
map((result): DeriveStakerSlashes[] =>
result.map(([era, optNom, optVal]): DeriveStakerSlashes => ({
era,
total: optVal.isSome
? optVal.unwrap()[1]
: optNom.isSome
? optNom.unwrap()
: api.registry.createType('Balance')
}))
)
);
});
}
+14 -7
View File
@@ -7,13 +7,13 @@ import { AccountId, Exposure, Keys, Nominations, RewardDestination, ValidatorPre
import { ITuple } from '@polkadot/types/types';
import { DerivedStakingQuery } from '../types';
import { combineLatest, Observable, of } from 'rxjs';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { createType, Option, Vec } from '@polkadot/types';
import { Option, Vec } from '@polkadot/types';
import { memo } from '../util';
type MultiResult = [Option<AccountId>, Option<ITuple<[Nominations]>>, RewardDestination, ITuple<[ValidatorPrefs]>, Option<Keys>, Exposure];
type MultiResult = [Option<AccountId>, Option<ITuple<[Nominations]> | Nominations>, RewardDestination, ITuple<[ValidatorPrefs]> | ValidatorPrefs, Option<Keys>, Exposure];
function unwrapSessionIds (stashId: AccountId, queuedKeys: [AccountId, Keys][], nextKeys: Option<Keys>): { nextSessionIds: AccountId[]; sessionIds: AccountId[] } {
const sessionIds = (queuedKeys.find(([currentId]): boolean =>
@@ -55,8 +55,9 @@ function retrieveCurr (api: ApiInterfaceRx, stashId: AccountId): Observable<Mult
);
}
function retrieveController (api: ApiInterfaceRx, stashId: AccountId, [queuedKeys, [controllerIdOpt, nominatorsOpt, rewardDestination, [validatorPrefs], nextKeys, exposure]]: [Vec<ITuple<[AccountId, Keys]>>, MultiResult]): Observable<DerivedStakingQuery> {
function retrieveController (api: ApiInterfaceRx, stashId: AccountId, [queuedKeys, [controllerIdOpt, nominatorsOpt, rewardDestination, validatorPrefs, nextKeys, exposure]]: [Vec<ITuple<[AccountId, Keys]>>, MultiResult]): Observable<DerivedStakingQuery> {
const controllerId = controllerIdOpt.unwrapOr(null);
const nominators = nominatorsOpt.unwrapOr(null);
return controllerId
? api.query.staking.ledger(controllerId).pipe(
@@ -64,11 +65,17 @@ function retrieveController (api: ApiInterfaceRx, stashId: AccountId, [queuedKey
accountId: stashId,
controllerId,
exposure,
nominators: nominatorsOpt.unwrapOr([{ targets: [] }])[0].targets,
nominators: nominators
? Array.isArray(nominators)
? nominators[0].targets
: nominators.targets
: [],
rewardDestination,
stakingLedger: stakingLedgerOpt.unwrapOr(undefined),
stashId,
validatorPrefs,
validatorPrefs: Array.isArray(validatorPrefs)
? validatorPrefs[0]
: validatorPrefs,
...unwrapSessionIds(stashId, queuedKeys, nextKeys)
}))
)
@@ -80,7 +87,7 @@ function retrieveController (api: ApiInterfaceRx, stashId: AccountId, [queuedKey
*/
export function query (api: ApiInterfaceRx): (accountId: Uint8Array | string) => Observable<DerivedStakingQuery> {
return memo((accountId: Uint8Array | string): Observable<DerivedStakingQuery> => {
const stashId = createType(api.registry, 'AccountId', accountId);
const stashId = api.registry.createType('AccountId', accountId);
return combineLatest([
api.query.session.queuedKeys<Vec<ITuple<[AccountId, Keys]>>>(),
@@ -4,7 +4,7 @@
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Balance } from '@polkadot/types/interfaces';
import { DeriveEraPoints, DeriveEraRewards, DeriveStakerExposure, DeriveStakerReward } from '../types';
import { DeriveEraPoints, DeriveEraPrefs, DeriveEraRewards, DeriveEraValPrefs, DeriveStakerExposure, DeriveStakerReward } from '../types';
import BN from 'bn.js';
import { Observable, combineLatest } from 'rxjs';
@@ -12,18 +12,24 @@ import { map } from 'rxjs/operators';
import { memo } from '../util';
type Result = [DeriveEraPoints[], DeriveEraRewards[], DeriveStakerExposure[]];
const ZERO = new BN(0);
type Result = [DeriveEraPoints[], DeriveEraPrefs[], DeriveEraRewards[], DeriveStakerExposure[]];
function parseRewards (api: ApiInterfaceRx, stakerId: string, [erasPoints, erasRewards, exposures]: Result): DeriveStakerReward[] {
const ZERO = new BN(0);
const COMM_DIV = new BN(1_000_000_000);
function parseRewards (api: ApiInterfaceRx, stakerId: string, [erasPoints, erasPrefs, erasRewards, exposures]: Result): DeriveStakerReward[] {
return exposures.map(({ era, isEmpty, isValidator, nominating, validators: eraValidators }): DeriveStakerReward => {
const { eraPoints, validators: allValPoints } = erasPoints.find((p) => p.era.eq(era)) || { eraPoints: new BN(0), validators: {} };
const { eraReward } = erasRewards.find((r) => r.era.eq(era)) || { eraReward: new BN(0) };
const { eraReward } = erasRewards.find((r) => r.era.eq(era)) || { eraReward: ZERO };
const { validators: allValPrefs } = erasPrefs.find((p) => p.era.eq(era)) || { validators: {} as DeriveEraValPrefs };
const validators: Record<string, Balance> = {};
let total = ZERO;
Object.entries(eraValidators).forEach(([validatorId, exposure]): void => {
const valPoints = allValPoints[validatorId] || new BN(0);
const valPoints = allValPoints[validatorId] || ZERO;
const valComm = allValPrefs[validatorId]?.commission.unwrap() || ZERO;
const avail = eraReward.mul(valPoints).div(eraPoints);
const valCut = valComm.mul(avail).div(COMM_DIV);
const expTotal = exposure.total.unwrap();
let value: BN | undefined;
@@ -40,7 +46,7 @@ function parseRewards (api: ApiInterfaceRx, stakerId: string, [erasPoints, erasR
: ZERO;
}
value = eraReward.mul(valPoints).mul(staked).div(eraPoints).div(expTotal);
value = avail.sub(valCut).mul(staked).div(expTotal).add(validatorId === stakerId ? valCut : ZERO);
total = total.add(value);
}
@@ -64,6 +70,7 @@ export function stakerRewards (api: ApiInterfaceRx): (accountId: Uint8Array | st
return combineLatest([
api.derive.staking.erasPoints(startEra),
api.derive.staking.erasPrefs(startEra),
api.derive.staking.erasRewards(startEra),
api.derive.staking.stakerExposure(stakerId, startEra)
]).pipe(
@@ -0,0 +1,27 @@
// 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 { DeriveStakerSlashes } from '../types';
import BN from 'bn.js';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { memo } from '../util';
export function stakerSlashes (api: ApiInterfaceRx): (accountId: Uint8Array | string, withActive?: boolean | BN | number) => Observable<DeriveStakerSlashes[]> {
return memo((accountId: Uint8Array | string, withActive?: boolean | BN | number): Observable<DeriveStakerSlashes[]> => {
const stakerId = api.registry.createType('AccountId', accountId).toString();
return api.derive.staking.erasSlashes(withActive).pipe(
map((slashes): DeriveStakerSlashes[] =>
slashes.map(({ era, nominators, validators }): DeriveStakerSlashes => ({
era,
total: nominators[stakerId] || validators[stakerId] || api.registry.createType('Balance')
}))
)
);
});
}
@@ -0,0 +1,28 @@
// 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, ValidatorPrefs } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { Vec } from '@polkadot/types';
import { memo } from '../util';
/**
* @description Retrieve the list of all validator stashes
*/
export function stashes (api: ApiInterfaceRx): () => Observable<AccountId[]> {
return memo((): Observable<AccountId[]> =>
api.query.staking.validators.creator.meta.type.asMap.linked.isTrue
? api.query.staking.validators<ITuple<[Vec<AccountId>, Vec<ValidatorPrefs>]>>().pipe(
map(([stashIds]) => stashIds)
)
: api.query.staking.validators.keys().pipe(
map((keys) => keys.map((key) => key.args[0] as AccountId))
)
);
}
+28
View File
@@ -7,17 +7,32 @@ import { DeriveSessionIndexes } from '../session/types';
export type DeriveEraValPoints = Record<string, RewardPoint>;
export type DeriveEraValPrefs = Record<string, ValidatorPrefs>;
export type DeriveEraValSlash = Record<string, Balance>;
export interface DeriveEraPoints {
era: EraIndex;
eraPoints: RewardPoint;
validators: DeriveEraValPoints;
}
export interface DeriveEraPrefs {
era: EraIndex;
validators: DeriveEraValPrefs;
}
export interface DeriveEraRewards {
era: EraIndex;
eraReward: Balance;
}
export interface DeriveEraSlashes {
era: EraIndex;
nominators: DeriveEraValSlash;
validators: DeriveEraValSlash;
}
export interface DeriveStakerPoints {
era: EraIndex;
eraPoints: RewardPoint;
@@ -34,6 +49,14 @@ export interface DeriveEraExposure {
validators: DeriveEraValidatorExposure;
}
export interface DeriveOwnExposure {
clipped: Exposure;
era: EraIndex;
exposure: Exposure;
}
export type DeriveOwnSlashes = DeriveStakerSlashes;
export interface DeriveStakerExposure {
era: EraIndex;
isEmpty: boolean;
@@ -51,6 +74,11 @@ export interface DeriveStakerReward {
total: Balance;
}
export interface DeriveStakerSlashes {
era: EraIndex;
total: Balance;
}
export interface DerivedStakingElected {
nextElected: AccountId[];
info: DerivedStakingQuery[];
+16 -14
View File
@@ -7,21 +7,25 @@ import { AccountId } from '@polkadot/types/interfaces';
import { DeriveStakingValidators } from '../types';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap, take } from 'rxjs/operators';
import { map, switchMap } from 'rxjs/operators';
import { StorageKey } from '@polkadot/types';
import { memo } from '../util';
function queryNextStakers (api: ApiInterfaceRx): Observable<AccountId[]> {
// only populate for next era in the last session, so track both here - entries are not
// subscriptions, so we need a trigger - currentIndex acts as that trigger to refresh
return api.derive.session.indexes().pipe(
switchMap(({ activeEra }): Observable<StorageKey[]> =>
api.query.staking.erasStakers.keys(activeEra.addn(1)).pipe(take(1))
),
map((keys): AccountId[] =>
keys.map((key): AccountId => key.args[1] as AccountId)
)
export function nextElected (api: ApiInterfaceRx): () => Observable<AccountId[]> {
return memo((): Observable<AccountId[]> =>
api.query.staking.erasStakers
? api.derive.session.indexes().pipe(
// only populate for next era in the last session, so track both here - entries are not
// subscriptions, so we need a trigger - currentIndex acts as that trigger to refresh
switchMap(({ currentEra }): Observable<StorageKey[]> =>
api.query.staking.erasStakers.keys(currentEra)
),
map((keys): AccountId[] =>
keys.map((key): AccountId => key.args[1] as AccountId)
)
)
: api.query.staking.currentElected<AccountId[]>()
);
}
@@ -38,9 +42,7 @@ export function validators (api: ApiInterfaceRx): () => Observable<DeriveStaking
? api.query.session.validators()
: of([]),
api.query.staking
? api.query.staking.erasStakers
? queryNextStakers(api)
: api.query.staking.currentElected<AccountId[]>()
? api.derive.staking.nextElected()
: of([])
]).pipe(
map(([validators, nextElected]): DeriveStakingValidators => ({
@@ -8,7 +8,7 @@ import { DerivedCollectiveProposals, DerivedTreasuryProposal, DerivedTreasuryPro
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { createType, Option } from '@polkadot/types';
import { Option } from '@polkadot/types';
import { memo } from '../util';
@@ -55,7 +55,7 @@ function retrieveProposals (api: ApiInterfaceRx, proposalCount: ProposalIndex, a
const isApproval = approvalIds.some((id): boolean => id.eqn(index));
if (!isApproval) {
proposalIds.push(createType(api.registry, 'ProposalIndex', index));
proposalIds.push(api.registry.createType('ProposalIndex', index));
}
}
@@ -87,7 +87,7 @@ export function proposals (api: ApiInterfaceRx): () => Observable<DerivedTreasur
)
: of({
approvals: [],
proposalCount: createType(api.registry, 'ProposalIndex'),
proposalCount: api.registry.createType('ProposalIndex'),
proposals: []
} as DerivedTreasuryProposals)
);
@@ -1,57 +0,0 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { ReferendumIndex, ReferendumInfo } from '@polkadot/types/interfaces/democracy';
import { AnyJson, Constructor, Registry } from '@polkadot/types/types';
import BN from 'bn.js';
import democracyTypes from '@polkadot/types/interfaces/democracy/definitions';
import { Struct } from '@polkadot/types';
// We can ignore the properties, added via Struct.with
const _ReferendumInfo: Constructor<ReferendumInfo> = Struct.with(democracyTypes.types.ReferendumInfo as any) as any;
/**
* @name ReferendumInfoExtended
* @description
* A [[ReferendumInfo]] with an additional `index` field
*/
export default class ReferendumInfoExtended extends _ReferendumInfo {
readonly #index: ReferendumIndex;
constructor (registry: Registry, value: ReferendumInfo | ReferendumInfoExtended, index?: BN | number) {
super(registry, value);
this.#index = value instanceof ReferendumInfoExtended
? value.index
: registry.createType('ReferendumIndex', index);
}
/**
* @description Convenience getter, returns the referendumIndex
*/
public get index (): ReferendumIndex {
return this.#index;
}
/**
* @description Creates a human-friendly JSON representation
*/
public toHuman (isExtended?: boolean): AnyJson {
return {
...super.toHuman(isExtended) as { [index: string]: AnyJson },
index: this.index.toHuman(isExtended)
};
}
/**
* @description Creates the JSON representation
*/
public toJSON (): AnyJson {
return {
...super.toJSON() as { [index: string]: AnyJson },
index: this.index.toJSON()
};
}
}
-1
View File
@@ -3,4 +3,3 @@
// of the Apache-2.0 license. See the LICENSE file for details.
export { default as HeaderExtended } from './HeaderExtended';
export { default as ReferendumInfoExtended } from './ReferendumInfoExtended';
+10 -3
View File
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, AccountIndex, Balance, BalanceLock, BalanceLockTo212, BalanceOf, Bid, BidKind, BlockNumber, Hash, Index, Proposal, PropIndex, ProposalIndex, ReferendumInfo, RegistrationJudgement, SetIndex, SocietyVote, StrikeCount, TreasuryProposal, Vote, Votes, VoteIndex, VouchingStatus } from '@polkadot/types/interfaces';
import { AccountId, AccountIndex, Balance, BalanceLock, BalanceLockTo212, BalanceOf, Bid, BidKind, BlockNumber, Hash, Index, Proposal, PropIndex, ProposalIndex, ReferendumInfoTo239, ReferendumStatus, RegistrationJudgement, SetIndex, SocietyVote, StrikeCount, TreasuryProposal, Vote, Votes, VoteIndex, VouchingStatus } from '@polkadot/types/interfaces';
import BN from 'bn.js';
import { u32, Vec } from '@polkadot/types';
@@ -28,7 +28,14 @@ export interface DeriveAccountRegistration {
judgements: RegistrationJudgement[];
}
export interface DeriveAccountInfo {
export interface DeriveAccountFlags {
isCouncil: boolean;
isSociety: boolean;
isSudo: boolean;
isTechCommittee: boolean;
}
export interface DeriveAccountInfo extends DeriveAccountFlags {
accountId?: AccountId;
accountIndex?: AccountIndex;
identity: DeriveAccountRegistration;
@@ -131,9 +138,9 @@ export interface DeriveProposal {
export interface DerivedReferendum {
hash: Hash;
index: PropIndex;
info: ReferendumInfo;
preimage?: DeriveProposalPreImage;
proposal?: Proposal;
status: ReferendumStatus | ReferendumInfoTo239;
}
export type DerivedRecentlyOffline = Record<string, RecentlyOffline[]>;
+7 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api",
"version": "1.6.2",
"version": "1.8.1",
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
"main": "index.js",
"keywords": [
@@ -26,13 +26,13 @@
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
"dependencies": {
"@babel/runtime": "^7.8.4",
"@polkadot/api-derive": "1.6.2",
"@babel/runtime": "^7.9.2",
"@polkadot/api-derive": "1.8.1",
"@polkadot/keyring": "^2.6.2",
"@polkadot/metadata": "1.6.2",
"@polkadot/rpc-core": "1.6.2",
"@polkadot/rpc-provider": "1.6.2",
"@polkadot/types": "1.6.2",
"@polkadot/metadata": "1.8.1",
"@polkadot/rpc-core": "1.8.1",
"@polkadot/rpc-provider": "1.8.1",
"@polkadot/types": "1.8.1",
"@polkadot/util": "^2.6.2",
"@polkadot/util-crypto": "^2.6.2",
"bn.js": "^5.1.1",
+147 -155
View File
@@ -1,8 +1,8 @@
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
/* eslint-disable @typescript-eslint/no-empty-interface */
/* eslint-disable */
import { Codec } from '@polkadot/types/types';
import { Bytes, u32, u64 } from '@polkadot/types/primitive';
import { u32, u64 } from '@polkadot/types/primitive';
import { Gas } from '@polkadot/types/interfaces/contracts';
import { Balance, BalanceOf, BlockNumber, Moment, Percent, Permill } from '@polkadot/types/interfaces/runtime';
import { SessionIndex } from '@polkadot/types/interfaces/session';
@@ -27,16 +27,6 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
**/
expectedBlockTime: AugmentedConst<Moment>;
};
timestamp: {
[index: string]: AugmentedConst<object & Codec>;
/**
* The minimum period between blocks. Beware that this is different to the *expected* period
* that the block production apparatus provides. Your chosen consensus system will generally
* work with this to determine a sensible block time. e.g. For Aura, it will be double this
* period on default settings.
**/
minimumPeriod: AugmentedConst<Moment>;
};
balances: {
[index: string]: AugmentedConst<object & Codec>;
/**
@@ -44,8 +34,70 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
**/
existentialDeposit: AugmentedConst<Balance>;
};
transactionPayment: {
contracts: {
[index: string]: AugmentedConst<object & Codec>;
/**
* The maximum amount of gas that could be expended per block. A reasonable
* default value is 10_000_000.
**/
blockGasLimit: AugmentedConst<Gas>;
/**
* The base fee charged for calling into a contract. A reasonable default
* value is 135.
**/
callBaseFee: AugmentedConst<Gas>;
/**
* The fee required to instantiate a contract instance. A reasonable default value
* is 21.
**/
contractFee: AugmentedConst<BalanceOf>;
/**
* The base fee charged for instantiating a contract. A reasonable default value
* is 175.
**/
instantiateBaseFee: AugmentedConst<Gas>;
/**
* The maximum nesting level of a call/instantiate stack. A reasonable default
* value is 100.
**/
maxDepth: AugmentedConst<u32>;
/**
* The maximum size of a storage value in bytes. A reasonable default is 16 KiB.
**/
maxValueSize: AugmentedConst<u32>;
/**
* Price of a byte of storage per one block interval. Should be greater than 0.
**/
rentByteFee: AugmentedConst<BalanceOf>;
/**
* The amount of funds a contract should deposit in order to offset
* the cost of one byte.
* Let's suppose the deposit is 1,000 BU (balance units)/byte and the rent is 1 BU/byte/day,
* then a contract with 1,000,000 BU that uses 1,000 bytes of storage would pay no rent.
* But if the balance reduced to 500,000 BU and the storage stayed the same at 1,000,
* then it would pay 500 BU/day.
**/
rentDepositOffset: AugmentedConst<BalanceOf>;
/**
* Number of block delay an extrinsic claim surcharge has.
* When claim surcharge is called by an extrinsic the rent is checked
* for current_block - delay
**/
signedClaimHandicap: AugmentedConst<BlockNumber>;
/**
* Size of a contract at the time of instantiation. This is a simple way to ensure that
* empty contracts eventually gets deleted.
**/
storageSizeOffset: AugmentedConst<u32>;
/**
* Reward that is received by the party whose touch has led
* to removal of a contract.
**/
surchargeReward: AugmentedConst<BalanceOf>;
/**
* The minimum amount required to generate a tombstone.
**/
tombstoneDeposit: AugmentedConst<BalanceOf>;
/**
* The fee to be paid for making a transaction; the base.
**/
@@ -55,27 +107,16 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
**/
transactionByteFee: AugmentedConst<BalanceOf>;
};
staking: {
[index: string]: AugmentedConst<object & Codec>;
/**
* Number of sessions per era.
**/
sessionsPerEra: AugmentedConst<SessionIndex>;
/**
* Number of eras that staked funds must remain bonded for.
**/
bondingDuration: AugmentedConst<EraIndex>;
};
session: {
[index: string]: AugmentedConst<object & Codec>;
/**
* Used as first key for `NextKeys` and `KeyOwner` to put all the data into the same branch
* of the trie.
**/
dedupKeyPrefix: AugmentedConst<Bytes>;
};
democracy: {
[index: string]: AugmentedConst<object & Codec>;
/**
* Period in blocks where an external proposal may not be re-submitted after being vetoed.
**/
cooloffPeriod: AugmentedConst<BlockNumber>;
/**
* Minimum voting period allowed for an emergency referendum.
**/
emergencyVotingPeriod: AugmentedConst<BlockNumber>;
/**
* The minimum period of locking and the period between a proposal being approved and enacted.
* It should generally be a little more than the unstake period to ensure that
@@ -87,48 +128,105 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
* How often (in blocks) new public referenda are launched.
**/
launchPeriod: AugmentedConst<BlockNumber>;
/**
* How often (in blocks) to check for new votes.
**/
votingPeriod: AugmentedConst<BlockNumber>;
/**
* The minimum amount to be used as a deposit for a public referendum proposal.
**/
minimumDeposit: AugmentedConst<BalanceOf>;
/**
* Minimum voting period allowed for an emergency referendum.
**/
emergencyVotingPeriod: AugmentedConst<BlockNumber>;
/**
* Period in blocks where an external proposal may not be re-submitted after being vetoed.
**/
cooloffPeriod: AugmentedConst<BlockNumber>;
/**
* The amount of balance that must be deposited per byte of preimage stored.
**/
preimageByteDeposit: AugmentedConst<BalanceOf>;
/**
* How often (in blocks) to check for new votes.
**/
votingPeriod: AugmentedConst<BlockNumber>;
};
elections: {
[index: string]: AugmentedConst<object & Codec>;
candidacyBond: AugmentedConst<BalanceOf>;
votingBond: AugmentedConst<BalanceOf>;
desiredMembers: AugmentedConst<u32>;
desiredRunnersUp: AugmentedConst<u32>;
termDuration: AugmentedConst<BlockNumber>;
votingBond: AugmentedConst<BalanceOf>;
};
finalityTracker: {
[index: string]: AugmentedConst<object & Codec>;
/**
* The number of recent samples to keep from this chain. Default is 101.
**/
windowSize: AugmentedConst<BlockNumber>;
/**
* The delay after which point things become suspicious. Default is 1000.
**/
reportLatency: AugmentedConst<BlockNumber>;
/**
* The number of recent samples to keep from this chain. Default is 101.
**/
windowSize: AugmentedConst<BlockNumber>;
};
society: {
[index: string]: AugmentedConst<object & Codec>;
/**
* The minimum amount of a deposit required for a bid to be made.
**/
candidateDeposit: AugmentedConst<BalanceOf>;
/**
* The number of blocks between membership challenges.
**/
challengePeriod: AugmentedConst<BlockNumber>;
/**
* The number of times a member may vote the wrong way (or not at all, when they are a skeptic)
* before they become suspended.
**/
maxStrikes: AugmentedConst<u32>;
/**
* The amount of incentive paid within each period. Doesn't include VoterTip.
**/
periodSpend: AugmentedConst<BalanceOf>;
/**
* The number of blocks between candidate/membership rotation periods.
**/
rotationPeriod: AugmentedConst<BlockNumber>;
/**
* The amount of the unpaid reward that gets deducted in the case that either a skeptic
* doesn't vote or someone votes in the wrong way.
**/
wrongSideDeduction: AugmentedConst<BalanceOf>;
};
staking: {
[index: string]: AugmentedConst<object & Codec>;
/**
* Number of eras that staked funds must remain bonded for.
**/
bondingDuration: AugmentedConst<EraIndex>;
/**
* Number of sessions per era.
**/
sessionsPerEra: AugmentedConst<SessionIndex>;
};
timestamp: {
[index: string]: AugmentedConst<object & Codec>;
/**
* The minimum period between blocks. Beware that this is different to the *expected* period
* that the block production apparatus provides. Your chosen consensus system will generally
* work with this to determine a sensible block time. e.g. For Aura, it will be double this
* period on default settings.
**/
minimumPeriod: AugmentedConst<Moment>;
};
transactionPayment: {
[index: string]: AugmentedConst<object & Codec>;
/**
* The fee to be paid for making a transaction; the base.
**/
transactionBaseFee: AugmentedConst<BalanceOf>;
/**
* The fee to be paid for making a transaction; the per-byte portion.
**/
transactionByteFee: AugmentedConst<BalanceOf>;
};
treasury: {
[index: string]: AugmentedConst<object & Codec>;
/**
* Percentage of spare funds (if any) that are burnt per spend period.
**/
burn: AugmentedConst<Permill>;
/**
* Fraction of a proposal's value that should be bonded in order to place the proposal.
* An accepted proposal gets these back. A rejected proposal does not.
@@ -142,10 +240,6 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
* Period between successive spends.
**/
spendPeriod: AugmentedConst<BlockNumber>;
/**
* Percentage of spare funds (if any) that are burnt per spend period.
**/
burn: AugmentedConst<Permill>;
/**
* The period for which a tip remains open after is has achieved threshold tippers.
**/
@@ -163,108 +257,6 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
**/
tipReportDepositPerByte: AugmentedConst<BalanceOf>;
};
contracts: {
[index: string]: AugmentedConst<object & Codec>;
/**
* Number of block delay an extrinsic claim surcharge has.
* When claim surcharge is called by an extrinsic the rent is checked
* for current_block - delay
**/
signedClaimHandicap: AugmentedConst<BlockNumber>;
/**
* The minimum amount required to generate a tombstone.
**/
tombstoneDeposit: AugmentedConst<BalanceOf>;
/**
* Size of a contract at the time of instantiation. This is a simple way to ensure that
* empty contracts eventually gets deleted.
**/
storageSizeOffset: AugmentedConst<u32>;
/**
* Price of a byte of storage per one block interval. Should be greater than 0.
**/
rentByteFee: AugmentedConst<BalanceOf>;
/**
* The amount of funds a contract should deposit in order to offset
* the cost of one byte.
* Let's suppose the deposit is 1,000 BU (balance units)/byte and the rent is 1 BU/byte/day,
* then a contract with 1,000,000 BU that uses 1,000 bytes of storage would pay no rent.
* But if the balance reduced to 500,000 BU and the storage stayed the same at 1,000,
* then it would pay 500 BU/day.
**/
rentDepositOffset: AugmentedConst<BalanceOf>;
/**
* Reward that is received by the party whose touch has led
* to removal of a contract.
**/
surchargeReward: AugmentedConst<BalanceOf>;
/**
* The fee to be paid for making a transaction; the base.
**/
transactionBaseFee: AugmentedConst<BalanceOf>;
/**
* The fee to be paid for making a transaction; the per-byte portion.
**/
transactionByteFee: AugmentedConst<BalanceOf>;
/**
* The fee required to instantiate a contract instance. A reasonable default value
* is 21.
**/
contractFee: AugmentedConst<BalanceOf>;
/**
* The base fee charged for calling into a contract. A reasonable default
* value is 135.
**/
callBaseFee: AugmentedConst<Gas>;
/**
* The base fee charged for instantiating a contract. A reasonable default value
* is 175.
**/
instantiateBaseFee: AugmentedConst<Gas>;
/**
* The maximum nesting level of a call/instantiate stack. A reasonable default
* value is 100.
**/
maxDepth: AugmentedConst<u32>;
/**
* The maximum size of a storage value in bytes. A reasonable default is 16 KiB.
**/
maxValueSize: AugmentedConst<u32>;
/**
* The maximum amount of gas that could be expended per block. A reasonable
* default value is 10_000_000.
**/
blockGasLimit: AugmentedConst<Gas>;
};
society: {
[index: string]: AugmentedConst<object & Codec>;
/**
* The minimum amount of a deposit required for a bid to be made.
**/
candidateDeposit: AugmentedConst<BalanceOf>;
/**
* The amount of the unpaid reward that gets deducted in the case that either a skeptic
* doesn't vote or someone votes in the wrong way.
**/
wrongSideDeduction: AugmentedConst<BalanceOf>;
/**
* The number of times a member may vote the wrong way (or not at all, when they are a skeptic)
* before they become suspended.
**/
maxStrikes: AugmentedConst<u32>;
/**
* The amount of incentive paid within each period. Doesn't include VoterTip.
**/
periodSpend: AugmentedConst<BalanceOf>;
/**
* The number of blocks between candidate/membership rotation periods.
**/
rotationPeriod: AugmentedConst<BlockNumber>;
/**
* The number of blocks between membership challenges.
**/
challengePeriod: AugmentedConst<BlockNumber>;
};
vesting: {
[index: string]: AugmentedConst<object & Codec>;
/**
File diff suppressed because it is too large Load Diff
+59 -4
View File
@@ -1,14 +1,19 @@
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
/* eslint-disable @typescript-eslint/no-empty-interface */
/* eslint-disable */
import { AnyNumber, Codec, IExtrinsic } from '@polkadot/types/types';
import { Option, Vec } from '@polkadot/types/codec';
import { Bytes, StorageKey, Text, bool, u32, u64 } from '@polkadot/types/primitive';
import { HashMap, Option, Vec } from '@polkadot/types/codec';
import { Bytes, Null, StorageKey, Text, bool, u32, u64 } from '@polkadot/types/primitive';
import { Metadata } from '@polkadot/types';
import { EpochAuthorship } from '@polkadot/types/interfaces/babe';
import { AuthorityId } from '@polkadot/types/interfaces/consensus';
import { ContractCallRequest, ContractExecResult } from '@polkadot/types/interfaces/contracts';
import { CreatedBlock } from '@polkadot/types/interfaces/engine';
import { Extrinsic } from '@polkadot/types/interfaces/extrinsics';
import { StorageKind } from '@polkadot/types/interfaces/offchain';
import { BlockHash, ChainProperties, ExtrinsicOrHash, ExtrinsicStatus, Health, NetworkState, PeerInfo, RpcMethods, RuntimeDispatchInfo, RuntimeVersion } from '@polkadot/types/interfaces/rpc';
import { AccountId, BlockNumber, H256, Hash, Header, Index, SignedBlock, StorageData } from '@polkadot/types/interfaces/runtime';
import { AccountId, BlockNumber, H256, Hash, Header, Index, Justification, KeyValue, SignedBlock, StorageData } from '@polkadot/types/interfaces/runtime';
import { NodeRole } from '@polkadot/types/interfaces/system';
import { Observable } from 'rxjs';
declare module '@polkadot/rpc-core/types.jsonrpc' {
@@ -53,6 +58,12 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
**/
submitExtrinsic: AugmentedRpc<(extrinsic: IExtrinsic) => Observable<Hash>>;
};
babe: {
/**
* Returns data about which slots (primary or secondary) can be claimed in the current epoch with the keys in the keystore
**/
epochAuthorship: AugmentedRpc<() => Observable<HashMap<AuthorityId, EpochAuthorship>>>;
};
chain: {
/**
* Get header and body of a relay chain block
@@ -92,6 +103,30 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
* Returns the value under a specified storage key in a contract
**/
getStorage: AugmentedRpc<(address: AccountId | string | Uint8Array, key: H256 | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<Option<Bytes>>>;
/**
* Returns the projected time a given contract will be able to sustain paying its rent
**/
rentProjection: AugmentedRpc<(address: AccountId | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<Option<BlockNumber>>>;
};
engine: {
/**
* Instructs the manual-seal authorship task to create a new block
**/
createBlock: AugmentedRpc<(createEmpty: bool | boolean | Uint8Array, finalize: bool | boolean | Uint8Array, parentHash?: BlockHash | string | Uint8Array) => Observable<CreatedBlock>>;
/**
* Instructs the manual-seal authorship task to finalize a block
**/
finalizeBlock: AugmentedRpc<(hash: BlockHash | string | Uint8Array, justification?: Justification | string | Uint8Array) => Observable<bool>>;
};
offchain: {
/**
* Get offchain local storage under given key and prefix
**/
localStorageGet: AugmentedRpc<(kind: StorageKind | ('__UNUSED' | 'PERSISTENT' | 'LOCAL') | number | Uint8Array, key: Bytes | string | Uint8Array) => Observable<Option<Bytes>>>;
/**
* Set offchain local storage under given key and prefix
**/
localStorageSet: AugmentedRpc<(kind: StorageKind | ('__UNUSED' | 'PERSISTENT' | 'LOCAL') | number | Uint8Array, key: Bytes | string | Uint8Array, value: Bytes | string | Uint8Array) => Observable<Null>>;
};
payment: {
/**
@@ -130,10 +165,18 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
* Retrieves the keys with a certain prefix
**/
getKeys: AugmentedRpc<(key: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array) => Observable<Vec<StorageKey>>>;
/**
* Returns the keys with prefix with pagination support.
**/
getKeysPaged: AugmentedRpc<(key: StorageKey | string | Uint8Array | any, count: u32 | AnyNumber | Uint8Array, startKey?: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array) => Observable<Vec<StorageKey>>>;
/**
* Returns the runtime metadata
**/
getMetadata: AugmentedRpc<(at?: BlockHash | string | Uint8Array) => Observable<Metadata>>;
/**
* Returns the keys with prefix, leave empty to get all the keys
**/
getPairs: AugmentedRpc<(prefix: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array) => Observable<Vec<KeyValue>>>;
/**
* Get the runtime version
**/
@@ -164,6 +207,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
subscribeStorage: AugmentedRpc<<T = Codec[]>(keys: Vec<StorageKey> | (StorageKey | string | Uint8Array | any)[]) => Observable<T>>;
};
system: {
/**
* Adds a reserved peer
**/
addReservedPeer: AugmentedRpc<(peer: Text | string) => Observable<Text>>;
/**
* Retrieves the chain
**/
@@ -180,6 +227,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
* Returns current state of the network
**/
networkState: AugmentedRpc<() => Observable<NetworkState>>;
/**
* Returns the roles the node is running as
**/
nodeRoles: AugmentedRpc<() => Observable<Vec<NodeRole>>>;
/**
* Returns the currently connected peers
**/
@@ -188,6 +239,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
* Get a custom set of properties as a JSON object, defined in the chain spec
**/
properties: AugmentedRpc<() => Observable<ChainProperties>>;
/**
* Remove a reserved peer
**/
removeReservedPeer: AugmentedRpc<(peerId: Text | string) => Observable<Text>>;
/**
* Retrieves the version of the node
**/
File diff suppressed because it is too large Load Diff
+95 -36
View File
@@ -10,8 +10,8 @@ import { SubmittableExtrinsic } from '../submittable/types';
import { ApiInterfaceRx, ApiOptions, ApiTypes, DecorateMethod, DecoratedRpc, DecoratedRpcSection, QueryableModuleStorage, QueryableStorage, QueryableStorageEntry, QueryableStorageMulti, QueryableStorageMultiArg, SubmittableExtrinsicFunction, SubmittableExtrinsics, SubmittableModuleExtrinsics } from '../types';
import BN from 'bn.js';
import { BehaviorSubject, Observable, combineLatest, of } from 'rxjs';
import { map, switchMap, take } from 'rxjs/operators';
import { BehaviorSubject, Observable, combineLatest, from, of } from 'rxjs';
import { concatMap, map, switchMap, take, tap, toArray } from 'rxjs/operators';
import decorateDerive, { ExactDerive } from '@polkadot/api-derive';
import { memo } from '@polkadot/api-derive/util';
import DecoratedMeta from '@polkadot/metadata/Decorated';
@@ -22,7 +22,7 @@ import { Metadata, Null, Option, Raw, Text, TypeRegistry, u64 } from '@polkadot/
import Linkage, { LinkageResult } from '@polkadot/types/codec/Linkage';
import { DEFAULT_VERSION as EXTRINSIC_DEFAULT_VERSION } from '@polkadot/types/extrinsic/constants';
import StorageKey, { StorageEntry, unwrapStorageType } from '@polkadot/types/primitive/StorageKey';
import { assert, compactStripLength, isNull, isUndefined, u8aConcat, u8aToHex } from '@polkadot/util';
import { assert, compactStripLength, isNull, isUndefined, logger, u8aConcat, u8aToHex } from '@polkadot/util';
import { createSubmittable } from '../submittable';
import augmentObject from '../util/augmentObject';
@@ -40,6 +40,11 @@ interface MetaDecoration {
type LinkageData = ITuple<[Codec, Linkage<Codec>]>;
const PAGE_SIZE_KEYS = 256;
const PAGE_SIZE_VALS = PAGE_SIZE_KEYS / 2;
const l = logger('api/init');
export default abstract class Decorate<ApiType extends ApiTypes> extends Events {
public readonly registry: Registry;
@@ -210,17 +215,35 @@ export default abstract class Decorate<ApiType extends ApiTypes> extends Events
this.filterRpcMethods(methods);
}
protected filterRpcMethods (methods: string[]): void {
// this is true when the RPC has entries
const hasResults = methods.length !== 0;
protected filterRpcMethods (exposed: string[]): void {
const hasResults = exposed.length !== 0;
const allKnown = [...this._rpcCore.mapping.entries()];
const allKeys = allKnown.reduce((allKeys: string[], [, { alias, method, section, pubsub }]): string[] => {
allKeys.push(`${section}_${method}`);
if (pubsub) {
allKeys.push(`${section}_${pubsub[1]}`);
allKeys.push(`${section}_${pubsub[2]}`);
}
if (alias) {
allKeys.push(...alias);
}
return allKeys;
}, []);
const unknown = exposed.filter((key) => !allKeys.includes(key));
if (unknown.length) {
l.warn(`RPC methods not decorated: ${unknown.join(', ')}}`);
}
// loop through all entries we have (populated in decorate) and filter as required
[...this._rpcCore.mapping.entries()]
.filter(([key, { isOptional }]): boolean =>
// only remove when we have results and method missing, or with no results if optional
hasResults
? !methods.includes(key) && key !== 'rpc_methods' // rpc_methods doesn't appear, v1
: isOptional || key === 'rpc_methods' // we didn't find this one, remove
// only remove when we have results and method missing, or with no results if optional
allKnown
.filter(([key]): boolean => hasResults
? !exposed.includes(key) && key !== 'rpc_methods' // rpc_methods doesn't appear, v1
: key === 'rpc_methods' // we didn't find this one, remove
)
// eslint-disable-next-line @typescript-eslint/no-unused-vars
.forEach(([_, { method, section }]): void => {
@@ -433,43 +456,79 @@ export default abstract class Decorate<ApiType extends ApiTypes> extends Events
private retrieveMapKeys ({ iterKey, meta }: StorageEntry, arg?: Arg): Observable<StorageKey[]> {
assert(iterKey && (meta.type.isMap || meta.type.isDoubleMap), 'keys can only be retrieved on maps, linked maps and double maps');
const startKey = this.createType('Raw', u8aConcat(
const headKey = this.createType('Raw', u8aConcat(
iterKey,
meta.type.isDoubleMap && !isUndefined(arg) && !isNull(arg)
? getHasher(meta.type.asDoubleMap.hasher)(
this.createType(meta.type.asDoubleMap.key1.toString() as 'Raw', arg).toU8a()
)
: new Uint8Array([])
));
)).toHex();
const startSubject = new BehaviorSubject<string>(headKey);
return this._rpcCore.state.getKeys(startKey).pipe(
map((keys): StorageKey[] =>
keys.map((key) => key.decodeArgsFromMeta(meta))
return this._rpcCore.state.getKeysPaged
? startSubject.pipe(
switchMap((startKey) =>
this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE_KEYS, startKey).pipe(
map((keys): StorageKey[] =>
keys.map((key) => key.decodeArgsFromMeta(meta))
)
)
),
tap((keys): void => {
keys.length === PAGE_SIZE_KEYS
? startSubject.next(keys[PAGE_SIZE_KEYS - 1].toHex())
: startSubject.complete();
}),
toArray(), // toArray since we want to startSubject to be completed
map((keysArr: StorageKey[][]): StorageKey[] =>
keysArr.reduce((result: StorageKey[], keys): StorageKey[] =>
result.concat(keys), []
)
)
)
);
: this._rpcCore.state.getKeys(headKey).pipe(
map((keys): StorageKey[] =>
keys.map((key) => key.decodeArgsFromMeta(meta))
)
);
}
private retrieveMapEntries (entry: StorageEntry, arg?: Arg): Observable<[StorageKey, Codec][]> {
const outputType = unwrapStorageType(entry.meta.type, entry.meta.modifier.isOptional);
return this.retrieveMapKeys(entry, arg)
.pipe(
switchMap((keys): Observable<[StorageKey[], Option<Raw>[]]> =>
combineLatest([
of(keys),
// Since we have a default constructed key, we have Option<Raw> as the result
// Don't keep the subscription here active, retrieve and get out of Dodge
// TODO Once we have a multiple key RPC available, use that via fallback
this._rpcCore.state.subscribeStorage<Option<Raw>[]>(keys).pipe(take(1))
])
),
map(([keys, values]): [StorageKey, Codec][] =>
keys.map((key, index): [StorageKey, Codec] => [
key,
this.createType(outputType, values[index].isSome ? values[index].unwrap().toHex() : undefined)
])
)
);
return this.retrieveMapKeys(entry, arg).pipe(
switchMap((keys): Observable<[StorageKey[], Option<Raw>[]]> =>
combineLatest([
of(keys),
from(Array(Math.ceil(keys.length / PAGE_SIZE_VALS)).fill(0)).pipe(
// FIXME New RPC to take care of this in the works...
concatMap((_, index): Observable<Option<Raw>[]> =>
this._rpcCore.state.subscribeStorage<Option<Raw>[]>(
keys.slice(index * PAGE_SIZE_VALS, (index * PAGE_SIZE_VALS) + PAGE_SIZE_VALS)
).pipe(take(1))
),
toArray(),
map((valsArr: Option<Raw>[][]): Option<Raw>[] =>
valsArr.reduce((result: Option<Raw>[], vals): Option<Raw>[] =>
result.concat(vals), []
)
)
)
])
),
map(([keys, vals]): [StorageKey, Codec][] =>
keys.map((key, index): [StorageKey, Codec] => [
key,
this.createType(
outputType,
vals[index].isSome
? vals[index].unwrap().toHex()
: undefined
)
])
)
);
}
protected decorateDeriveRx (decorateMethod: DecorateMethod<ApiType>): DeriveAllSections<'rxjs', ExactDerive> {
+3 -1
View File
@@ -217,7 +217,9 @@ export default abstract class Init<ApiType extends ApiTypes> extends Decorate<Ap
try {
const [hasMeta, cryptoReady] = await Promise.all([
this.loadMeta(),
cryptoWaitReady()
this._options.initWasm === false
? Promise.resolve(true)
: cryptoWaitReady()
]);
if (hasMeta && !this._isReady && cryptoReady) {
+5 -1
View File
@@ -21,7 +21,7 @@ export default class SubmittableResult implements ISubmittableResult {
}
public get isError (): boolean {
return this.status.isDropped || this.status.isFinalityTimeout || this.status.isInvalid || this.status.isRetracted || this.status.isUsurped;
return this.status.isDropped || this.status.isFinalityTimeout || this.status.isInvalid || this.status.isUsurped;
}
public get isFinalized (): boolean {
@@ -32,6 +32,10 @@ export default class SubmittableResult implements ISubmittableResult {
return this.status.isInBlock;
}
public get isWarning (): boolean {
return this.status.isRetracted;
}
/**
* @description Filters EventRecords for the specified method & section (there could be multiple)
*/
+1 -1
View File
@@ -166,9 +166,9 @@ export default function createClass <ApiType extends ApiTypes> ({ api, apiType,
#makeSignOptions = (options: Partial<SignerOptions>, extras: { blockHash?: Hash; era?: ExtrinsicEra; nonce?: Index }): SignatureOptions => {
return {
blockHash: api.genesisHash,
genesisHash: api.genesisHash,
...options,
...extras,
genesisHash: api.genesisHash,
runtimeVersion: api.runtimeVersion,
version: api.extrinsicType
} as SignatureOptions;
+10 -6
View File
@@ -8,18 +8,20 @@ import '@polkadot/api/augment';
import BN from 'bn.js';
import { DeriveCustom, ExactDerive } from '@polkadot/api-derive';
import { Constants } from '@polkadot/metadata/Decorated/types';
import { RpcInterface, UserRpc } from '@polkadot/rpc-core/types';
import { RpcInterface } from '@polkadot/rpc-core/types';
import { Metadata } from '@polkadot/types';
import { Hash, RuntimeVersion } from '@polkadot/types/interfaces';
import { Signer, SignerResult, SignatureOptions, Registry, RegisteredTypes } from '@polkadot/types/types';
import { DefinitionRpc, DefinitionRpcSub, Signer, SignatureOptions, Registry, RegisteredTypes } from '@polkadot/types/types';
import ApiBase from '../base';
import { DeriveAllSections } from '../util/decorate';
import ApiBase from '../base';
import { DecoratedRpc } from './rpc';
import { QueryableStorage, QueryableStorageMulti } from './storage';
import { SubmittableExtrinsics } from './submittable';
import { ProviderInterface, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types';
export { Signer, SignerResult } from '@polkadot/types/types';
export { default as ApiBase } from '../base';
export * from '../submittable/types';
export * from './base';
export * from './rpc';
@@ -31,6 +33,10 @@ export interface ApiOptions extends RegisteredTypes {
* @description Add custom derives to be injected
*/
derives?: DeriveCustom;
/**
* @description Control the initialization of the wasm libraries. When not specified, it defaults to `true`, initializing the wasm libraries, set to `false` to not initialize wasm. (No sr25519 support)
*/
initWasm?: boolean;
/**
* @description pre-bundles is a map of 'genesis hash and runtime spec version' as key to a metadata hex string
* if genesis hash and runtime spec version matches, then use metadata, else fetch it from chain
@@ -48,7 +54,7 @@ export interface ApiOptions extends RegisteredTypes {
/**
* @description User-defined RPC methods
*/
rpc?: UserRpc;
rpc?: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>;
/**
* @description An external signer which will be used to sign extrinsic when account passed in is not KeyringPair
*/
@@ -83,5 +89,3 @@ export interface SignerOptions extends SignatureOptions {
blockNumber: BN;
genesisHash: Hash;
}
export { ApiBase, Signer, SignerResult };
+11 -4
View File
@@ -11,7 +11,7 @@ import { TypeRegistry } from '@polkadot/types';
import { extractStorageArgs } from './validate';
describe.skip('extractStorageArgs', (): void => {
describe('extractStorageArgs', (): void => {
const registry = new TypeRegistry();
let storage: Storage;
@@ -27,6 +27,12 @@ describe.skip('extractStorageArgs', (): void => {
).toEqual([storage.timestamp.now]);
});
it('validates no-arg plain (with undefined, undefined)', (): void => {
expect(
extractStorageArgs(storage.timestamp.now, [undefined, undefined])
).toEqual([storage.timestamp.now]);
});
it('validates no-arg plain (failing when there are args)', (): void => {
expect(
(): any[] =>
@@ -74,19 +80,20 @@ describe.skip('extractStorageArgs', (): void => {
).toThrow('staking.erasStakers(EraIndex, AccountId) is a doublemap, requiring 2 arguments, 1 found');
});
it('validates linked map, no args', (): void => {
// Linked maps have been removed
it.skip('validates linked map, no args', (): void => {
expect(
extractStorageArgs(storage.staking.validators, [])
).toEqual([storage.staking.validators]);
});
it('validates linked map, single arg', (): void => {
it.skip('validates linked map, single arg', (): void => {
expect(
extractStorageArgs(storage.staking.validators, [123])
).toEqual([storage.staking.validators, 123]);
});
it('validates linked map (failing with extra args)', (): void => {
it.skip('validates linked map (failing with extra args)', (): void => {
expect(
(): any[] =>
extractStorageArgs(storage.staking.validators, [123, 456])
+31 -35
View File
@@ -3,53 +3,49 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { StorageEntry } from '@polkadot/types/primitive/StorageKey';
import { Type } from '@polkadot/types';
// FIXME This breaks with .at(hash, ...)
import { assert, isUndefined } from '@polkadot/util';
// import { Type } from '@polkadot/types';
// import { assert } from '@polkadot/util';
function sig ({ method, section }: StorageEntry, ...args: Type[]): string {
return `${section}.${method}(${args.join(', ')})`;
}
// function sig ({ method, section }: StorageEntry, ...args: Type[]): string {
// return `${section}.${method}(${args.join(', ')})`;
// }
function doDoubleMap (creator: StorageEntry, args: any[]): [StorageEntry, [any, any]] {
const { key1, key2 } = creator.meta.type.asDoubleMap;
// function doDoubleMap (creator: StorageEntry, args: any[]): [StorageEntry, [any, any]] {
// const { key1, key2 } = creator.meta.type.asDoubleMap;
assert(args.length === 2, `${sig(creator, key1, key2)} is a doublemap, requiring 2 arguments, ${args.length} found`);
// assert(args.length === 2, `${sig(creator, key1, key2)} is a doublemap, requiring 2 arguments, ${args.length} found`);
// pass as tuple
return [creator, args as [any, any]];
}
// // pass as tuple
// return [creator, args as [any, any]];
// }
function doMap (creator: StorageEntry, args: any[]): [StorageEntry] | [StorageEntry, any] {
const { key, linked } = creator.meta.type.asMap;
// function doMap (creator: StorageEntry, args: any[]): [StorageEntry] | [StorageEntry, any] {
// const { key, linked } = creator.meta.type.asMap;
linked.isTrue
? assert(args.length <= 1, `${sig(creator, key)} is a linked map, requiring either 0 arguments (retrieving all) or 1 argument, ${args.length} found`)
: assert(args.length === 1, `${sig(creator, key)} is a map, requiring 1 argument, ${args.length} found`);
// linked.isTrue
// ? assert(args.length <= 1, `${sig(creator, key)} is a linked map, requiring either 0 arguments (retrieving all) or 1 argument, ${args.length} found`)
// : assert(args.length === 1, `${sig(creator, key)} is a map, requiring 1 argument, ${args.length} found`);
// // expand
// return args.length
// ? [creator, args[0]]
// : [creator];
// }
// expand
return args.length
? [creator, args[0]]
: [creator];
}
// sets up the arguments in the form of [creator, args] ready to be used in a storage
// call. Additionally, it verifies that the correct number of arguments have been passed
export function extractStorageArgs (creator: StorageEntry, args: any[]): any[] {
return creator.meta.type.isDoubleMap
? [creator, args]
: [creator, ...args];
export function extractStorageArgs (creator: StorageEntry, _args: any[]): any[] {
const args = _args.filter((arg) => !isUndefined(arg));
// if (creator.meta.type.isDoubleMap) {
// return doDoubleMap(creator, args);
// } else if (creator.meta.type.isMap) {
// return doMap(creator, args);
// }
if (creator.meta.type.isDoubleMap) {
return doDoubleMap(creator, args);
} else if (creator.meta.type.isMap) {
return doMap(creator, args);
}
// assert(args.length === 0, `${sig(creator)} does not take any arguments, ${args.length} found`);
assert(args.length === 0, `${sig(creator)} does not take any arguments, ${args.length} found`);
// // no args
// return [creator, ...args];
// no args
return [creator];
}
+20 -3
View File
@@ -5,6 +5,7 @@
import { ApiPromise, WsProvider } from '@polkadot/api';
function createApi (): Promise<ApiPromise> {
jest.setTimeout(30000);
process.env.NODE_ENV = 'test';
const provider = new WsProvider('wss://kusama-rpc.polkadot.io');
@@ -24,12 +25,28 @@ describe.skip('misc quick tests', (): void => {
));
});
it.skip('handles map keys', async (): Promise<void> => {
const api = await createApi();
console.time('map.keys');
const keys = await api.query.system.account.keys();
console.error('# keys', keys.length);
console.timeEnd('map.keys');
});
it.skip('handles map entries', async (): Promise<void> => {
const api = await createApi();
console.error(JSON.stringify(
await api.query.indices.accounts.entries()
));
console.time('map.entries');
const entries = await api.query.system.account.entries(); // api.query.indices.accounts.entries();
console.error('# entries', entries.length);
console.timeEnd('map.entries');
});
it.skip('handles doublemap entries', async (): Promise<void> => {
-201
View File
@@ -1,201 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-24
View File
@@ -1,24 +0,0 @@
# @polkadot/jsonrpc
A definition of all the methods exposed in a general Polkadot client application. These are used not only to provide a comprehensive code-generated document of the available methods, but are also used in the API to auto-generate endpoints with the required type-checking.
For a list of currently exposed methods, see the [method documentation](docs/substrate/rpc.md).
## Usage
Installation -
```
yarn add @polkadot/jsonrpc
```
## Adding methods
As methods are added, simply adding the name, inputs & output will prepare it for use.
- Add the method to the correct file in [src/rpc/](src/rpc/) (Input/Output types as cross-referenced from the canonical implementation and match one-to-one)
- Should a new type be required, add it to the type list, [src/types.js](src/types.js) (Required for TSLint type checking)
## Classes
[Classes](SUMMARY.md)
-33
View File
@@ -1,33 +0,0 @@
{
"name": "@polkadot/jsonrpc",
"version": "1.6.2",
"description": "Method definitions for the Polkadot RPC layer",
"main": "index.js",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
},
"repository": {
"type": "git",
"url": "git+https://github.com/polkadot-js/api.git"
},
"keywords": [
"Polkadot",
"JsonRPC"
],
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [
"Jaco Greeff <jacogr@gmail.com>"
],
"contributors": [],
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/polkadot-js/api/issues"
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/jsonrpc#readme",
"dependencies": {
"@babel/runtime": "^7.8.4",
"@polkadot/types": "1.6.2",
"@polkadot/util": "^2.6.2"
}
}
-34
View File
@@ -1,34 +0,0 @@
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { RpcMethodOpt } from './types';
import createMethod from './create/method';
import createParam from './create/param';
// NOTE order here is the same as in Rust, alphabetical below
const nextIndex: RpcMethodOpt = {
description: 'Retrieves the next accountIndex as available on the node',
isOptional: true,
params: [
createParam('accountId', 'AccountId')
],
type: 'Index'
};
const section = 'account';
/**
* @summary Calls to account-specific information.
*/
export default {
isDeprecated: false,
isHidden: false,
description: '(Optional) Methods that retrieves account-specific information',
section,
methods: {
nextIndex: createMethod(section, 'nextIndex', nextIndex)
}
};
-100
View File
@@ -1,100 +0,0 @@
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { RpcMethodOpt } from './types';
import createMethod from './create/method';
import createParam from './create/param';
const hasKey: RpcMethodOpt = {
description: 'Returns true if the keystore has private keys for the given public key and key type.',
params: [
createParam('publicKey', 'Bytes'),
createParam('keyType', 'Text')
],
type: 'bool'
};
const hasSessionKeys: RpcMethodOpt = {
description: 'Returns true if the keystore has private keys for the given session public keys.',
params: [
createParam('sessionKeys', 'Bytes')
],
type: 'bool'
};
const removeExtrinsic: RpcMethodOpt = {
description: 'Remove given extrinsic from the pool and temporarily ban it to prevent reimporting',
params: [
createParam('bytesOrHash', 'Vec<ExtrinsicOrHash>')
],
type: 'Vec<Hash>'
};
const insertKey: RpcMethodOpt = {
description: 'Insert a key into the keystore.',
params: [
createParam('keyType', 'Text'),
createParam('suri', 'Text'),
createParam('publicKey', 'Bytes')
],
type: 'Bytes'
};
const rotateKeys: RpcMethodOpt = {
description: 'Generate new session keys and returns the corresponding public keys',
params: [],
type: 'Bytes'
};
const pendingExtrinsics: RpcMethodOpt = {
description: 'Returns all pending extrinsics, potentially grouped by sender',
params: [],
type: 'Vec<Extrinsic>'
};
const submitExtrinsic: RpcMethodOpt = {
isSigned: true,
description: 'Submit a fully formatted extrinsic for block inclusion',
params: [
createParam('extrinsic', 'Extrinsic')
],
type: 'Hash'
};
const submitAndWatchExtrinsic: RpcMethodOpt = {
description: 'Submit and subscribe to watch an extrinsic until unsubscribed',
isSigned: true,
params: [
createParam('extrinsic', 'Extrinsic')
],
pubsub: [
'extrinsicUpdate',
'submitAndWatchExtrinsic',
'unwatchExtrinsic'
],
type: 'ExtrinsicStatus'
};
const section = 'author';
/**
* @summary Calls to work with authors & contributors.
*/
export default {
isDeprecated: false,
isHidden: false,
description: 'Authoring of network items',
section,
methods: {
hasKey: createMethod(section, 'hasKey', hasKey),
hasSessionKeys: createMethod(section, 'hasSessionKeys', hasSessionKeys),
insertKey: createMethod(section, 'insertKey', insertKey),
removeExtrinsic: createMethod(section, 'removeExtrinsic', removeExtrinsic),
rotateKeys: createMethod(section, 'rotateKeys', rotateKeys),
pendingExtrinsics: createMethod(section, 'pendingExtrinsics', pendingExtrinsics),
submitExtrinsic: createMethod(section, 'submitExtrinsic', submitExtrinsic),
submitAndWatchExtrinsic: createMethod(section, 'submitAndWatchExtrinsic', submitAndWatchExtrinsic)
}
};
-95
View File
@@ -1,95 +0,0 @@
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { RpcMethodOpt } from './types';
import createMethod from './create/method';
import createParam from './create/param';
// NOTE Order is the same as in Rust
const getHeader: RpcMethodOpt = {
description: 'Retrieves the header for a specific block',
params: [
createParam('hash', 'BlockHash', { isOptional: true })
],
type: 'Header'
};
const getBlock: RpcMethodOpt = {
description: 'Get header and body of a relay chain block',
params: [
createParam('hash', 'BlockHash', { isOptional: true })
],
type: 'SignedBlock'
};
const getBlockHash: RpcMethodOpt = {
description: 'Get the block hash for a specific block',
params: [
createParam('blockNumber', 'BlockNumber', { isOptional: true })
],
type: 'BlockHash'
};
const getFinalizedHead: RpcMethodOpt = {
description: 'Get hash of the last finalized block in the canon chain',
params: [],
type: 'BlockHash'
};
const subscribeNewHeads: RpcMethodOpt = {
description: 'Retrieves the best header via subscription',
params: [],
// NOTE These still has the aliassed version, compatible with 1.x
pubsub: [
'newHead',
'subscribeNewHead',
'unsubscribeNewHead'
],
type: 'Header'
};
const subscribeFinalizedHeads: RpcMethodOpt = {
description: 'Retrieves the best finalized header via subscription',
params: [],
pubsub: [
'finalizedHead',
'subscribeFinalizedHeads',
'unsubscribeFinalizedHeads'
],
type: 'Header'
};
const subscribeAllHeads: RpcMethodOpt = {
description: 'Retrieves the newest header via subscription',
params: [],
pubsub: [
'allHead',
'subscribeAllHeads',
'unsubscribeAllHeads'
],
type: 'Header'
};
const section = 'chain';
/**
* @summary Calls to retrieve chain data.
*/
export default {
isDeprecated: false,
isHidden: false,
description: 'Retrieval of chain data',
section,
methods: {
getBlock: createMethod(section, 'getBlock', getBlock),
getBlockHash: createMethod(section, 'getBlockHash', getBlockHash),
getFinalizedHead: createMethod(section, 'getFinalizedHead', getFinalizedHead),
getHeader: createMethod(section, 'getHeader', getHeader),
subscribeFinalizedHeads: createMethod(section, 'subscribeFinalizedHeads', subscribeFinalizedHeads),
subscribeNewHeads: createMethod(section, 'subscribeNewHeads', subscribeNewHeads),
subscribeAllHeads: createMethod(section, 'subscribeAllHeads', subscribeAllHeads)
}
};
-47
View File
@@ -1,47 +0,0 @@
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { RpcMethodOpt } from './types';
import createMethod from './create/method';
import createParam from './create/param';
// NOTE order here is the same as in Rust, alphabetical below
const call: RpcMethodOpt = {
description: 'Executes a call to a contract',
isOptional: true,
params: [
createParam('callRequest', 'ContractCallRequest'),
createParam('at', 'BlockHash', { isOptional: true })
],
type: 'ContractExecResult'
};
const getStorage: RpcMethodOpt = {
description: 'Returns the value under a specified storage key in a contract',
isOptional: true,
params: [
createParam('address', 'AccountId'),
createParam('key', 'H256'),
createParam('at', 'BlockHash', { isOptional: true })
],
type: 'Option<Bytes>'
};
const section = 'contracts';
/**
* @summary Calls to retrieve system info.
*/
export default {
isDeprecated: false,
isHidden: false,
description: '(Optional) Methods that performs actions on contracts',
section,
methods: {
call: createMethod(section, 'call', call),
getStorage: createMethod(section, 'getStorage', getStorage)
}
};
-24
View File
@@ -1,24 +0,0 @@
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { RpcMethodOpt, RpcMethod } from '../types';
import { isUndefined } from '@polkadot/util';
/** @internal */
export default function createMethod (section: string, method: string, { description, isDeprecated = false, isHidden = false, isOptional = false, isSigned = false, params, pubsub, type }: RpcMethodOpt): RpcMethod {
return {
description,
isDeprecated,
isHidden,
isOptional,
isSigned,
isSubscription: !isUndefined(pubsub),
method,
params,
pubsub: pubsub || ['', '', ''],
section,
type
};
}
-19
View File
@@ -1,19 +0,0 @@
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { InterfaceTypes } from '@polkadot/types/types';
import { RpcParam } from '../types';
interface RpcParamOptions {
isOptional?: boolean;
}
/** @internal */
export default function createParam (name: string, type: keyof InterfaceTypes, { isOptional = false }: RpcParamOptions = { isOptional: false }): RpcParam {
return {
isOptional,
name,
type
};
}
-43
View File
@@ -1,43 +0,0 @@
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { RpcMethodOpt } from './types';
import createMethod from './create/method';
import createParam from './create/param';
const createBlock: RpcMethodOpt = {
description: 'Instructs the manual-seal authorship task to create a new block',
params: [
createParam('createEmpty', 'bool'),
createParam('finalize', 'bool'),
createParam('parentHash', 'Option<BlockHash>')
],
type: 'CreatedBlock'
};
const finalizeBlock: RpcMethodOpt = {
description: 'Instructs the manual-seal authorship task to finalize a block',
params: [
createParam('hash', 'BlockHash'),
createParam('justification', 'Option<Justification>')
],
type: 'bool'
};
const section = 'engine';
/**
* @summary Calls to interact with the block production engine
*/
export default {
isDeprecated: false,
isHidden: false,
description: 'Block production engine',
section,
methods: {
createBlock: createMethod(section, 'createBlock', createBlock),
finalizeBlock: createMethod(section, 'finalizeBlock', finalizeBlock)
}
};
-12
View File
@@ -1,12 +0,0 @@
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import interfaces from './';
describe('jsonrpc', (): void => {
it('exports the available interfaces', (): void => {
expect(interfaces).toBeDefined();
expect(Object.keys(interfaces).length).toBeGreaterThan(0);
});
});
-27
View File
@@ -1,27 +0,0 @@
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { RpcSection } from './types';
import account from './account';
import author from './author';
import chain from './chain';
import contracts from './contracts';
import payment from './payment';
import rpc from './rpc';
import state from './state';
import system from './system';
const interfaces: Record<string, RpcSection> = {
account,
author,
chain,
contracts,
payment,
rpc,
state,
system
};
export default interfaces;
-35
View File
@@ -1,35 +0,0 @@
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { RpcMethodOpt } from './types';
import createMethod from './create/method';
import createParam from './create/param';
// NOTE order here is the same as in Rust, alphabetical below
const queryInfo: RpcMethodOpt = {
description: 'Retrieves the fee information for an encoded extrinsic',
isOptional: true,
params: [
createParam('extrinsic', 'Bytes'),
createParam('at', 'BlockHash', { isOptional: true })
],
type: 'RuntimeDispatchInfo'
};
const section = 'payment';
/**
* @summary Calls to retrieve payment information.
*/
export default {
isDeprecated: false,
isHidden: false,
description: 'Methods that retrieves payment information, e.g. fee calculations',
section,
methods: {
queryInfo: createMethod(section, 'queryInfo', queryInfo)
}
};
-30
View File
@@ -1,30 +0,0 @@
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { RpcMethodOpt } from './types';
import createMethod from './create/method';
// NOTE order here is the same as in Rust, alphabetical below
const methods: RpcMethodOpt = {
description: 'Retrieves the list of RPC methods that are exposed by the node',
params: [],
type: 'RpcMethods'
};
const section = 'rpc';
/**
* @summary Calls to retrieve system info.
*/
export default {
isDeprecated: false,
isHidden: false,
description: 'Retrieves information about the RPC endpoints',
section,
methods: {
methods: createMethod(section, 'methods', methods)
}
};
-160
View File
@@ -1,160 +0,0 @@
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { RpcMethodOpt } from './types';
import createMethod from './create/method';
import createParam from './create/param';
// NOTE Order here is the same as in the Rust code
const call: RpcMethodOpt = {
description: 'Perform a call to a builtin on the chain',
params: [
createParam('method', 'Text'),
createParam('data', 'Bytes'),
createParam('at', 'BlockHash', { isOptional: true })
],
type: 'Bytes'
};
const KEY_QUERY_PARAMS = [
createParam('key', 'StorageKey'),
createParam('at', 'BlockHash', { isOptional: true })
];
const getKeys: RpcMethodOpt = {
description: 'Retrieves the keys with a certain prefix',
params: KEY_QUERY_PARAMS,
type: 'Vec<StorageKey>'
};
const getStorage: RpcMethodOpt = {
description: 'Retrieves the storage for a key',
params: KEY_QUERY_PARAMS,
type: 'StorageData'
};
const getStorageHash: RpcMethodOpt = {
description: 'Retrieves the storage hash',
params: KEY_QUERY_PARAMS,
type: 'Hash'
};
const getStorageSize: RpcMethodOpt = {
description: 'Retrieves the storage size',
params: KEY_QUERY_PARAMS,
type: 'u64'
};
const CHILD_QUERY_PARAMS = [
createParam('childStorageKey', 'StorageKey'),
createParam('childDefinition', 'StorageKey'),
createParam('childType', 'u32'),
createParam('key', 'StorageKey'),
createParam('at', 'BlockHash', { isOptional: true })
];
const getChildKeys: RpcMethodOpt = {
description: 'Retrieves the keys with prefix of a specific child storage',
params: CHILD_QUERY_PARAMS,
type: 'Vec<StorageKey>'
};
const getChildStorage: RpcMethodOpt = {
description: 'Retrieves the child storage for a key',
params: CHILD_QUERY_PARAMS,
type: 'StorageData'
};
const getChildStorageHash: RpcMethodOpt = {
description: 'Retrieves the child storage hash',
params: CHILD_QUERY_PARAMS,
type: 'Hash'
};
const getChildStorageSize: RpcMethodOpt = {
description: 'Retrieves the child storage size',
params: CHILD_QUERY_PARAMS,
type: 'u64'
};
const getMetadata: RpcMethodOpt = {
description: 'Returns the runtime metadata',
params: [
createParam('at', 'BlockHash', { isOptional: true })
],
// This is not part of keyof InterfaceTypes
type: 'Metadata' as any
};
const getRuntimeVersion: RpcMethodOpt = {
description: 'Get the runtime version',
params: [
createParam('at', 'BlockHash', { isOptional: true })
],
type: 'RuntimeVersion'
};
const queryStorage: RpcMethodOpt = {
description: 'Query historical storage entries (by key) starting from a start block',
params: [
createParam('keys', 'Vec<StorageKey>'),
createParam('startBlock', 'Hash'),
createParam('at', 'BlockHash', { isOptional: true })
],
type: 'Vec<StorageChangeSet>'
};
const subscribeRuntimeVersion: RpcMethodOpt = {
description: 'Retrieves the runtime version via subscription',
params: [],
pubsub: [
'runtimeVersion',
'subscribeRuntimeVersion',
'unsubscribeRuntimeVersion'
],
type: 'RuntimeVersion'
};
const subscribeStorage: RpcMethodOpt = {
description: 'Subscribes to storage changes for the provided keys',
params: [
createParam('keys', 'Vec<StorageKey>')
],
pubsub: [
'storage',
'subscribeStorage',
'unsubscribeStorage'
],
type: 'StorageChangeSet'
};
const section = 'state';
/**
* @summary Query the state and state storage.
*/
export default {
isDeprecated: false,
isHidden: false,
description: 'Query of state',
section,
methods: {
call: createMethod(section, 'call', call),
getChildKeys: createMethod(section, 'getChildKeys', getChildKeys),
getChildStorage: createMethod(section, 'getChildStorage', getChildStorage),
getChildStorageHash: createMethod(section, 'getChildStorageHash', getChildStorageHash),
getChildStorageSize: createMethod(section, 'getChildStorageSize', getChildStorageSize),
getKeys: createMethod(section, 'getKeys', getKeys),
getMetadata: createMethod(section, 'getMetadata', getMetadata),
getRuntimeVersion: createMethod(section, 'getRuntimeVersion', getRuntimeVersion),
getStorage: createMethod(section, 'getStorage', getStorage),
getStorageHash: createMethod(section, 'getStorageHash', getStorageHash),
getStorageSize: createMethod(section, 'getStorageSize', getStorageSize),
queryStorage: createMethod(section, 'queryStorage', queryStorage),
subscribeRuntimeVersion: createMethod(section, 'subscribeRuntimeVersion', subscribeRuntimeVersion),
subscribeStorage: createMethod(section, 'subscribeStorage', subscribeStorage)
}
};
-72
View File
@@ -1,72 +0,0 @@
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { RpcMethodOpt } from './types';
import createMethod from './create/method';
// NOTE order here is the same as in Rust, alphabetical below
const name: RpcMethodOpt = {
description: 'Retrieves the node name',
params: [],
type: 'Text'
};
const version: RpcMethodOpt = {
description: 'Retrieves the version of the node',
params: [],
type: 'Text'
};
const chain: RpcMethodOpt = {
description: 'Retrieves the chain',
params: [],
type: 'Text'
};
const properties: RpcMethodOpt = {
description: 'Get a custom set of properties as a JSON object, defined in the chain spec',
params: [],
type: 'ChainProperties'
};
const health: RpcMethodOpt = {
description: 'Return health status of the node',
params: [],
type: 'Health'
};
const peers: RpcMethodOpt = {
description: 'Returns the currently connected peers',
params: [],
type: 'Vec<PeerInfo>'
};
const networkState: RpcMethodOpt = {
description: 'Returns current state of the network',
params: [],
type: 'NetworkState'
};
const section = 'system';
/**
* @summary Calls to retrieve system info.
*/
export default {
isDeprecated: false,
isHidden: false,
description: 'Calls to retrieve system info',
section,
methods: {
chain: createMethod(section, 'chain', chain),
health: createMethod(section, 'health', health),
name: createMethod(section, 'name', name),
networkState: createMethod(section, 'networkState', networkState),
peers: createMethod(section, 'peers', peers),
properties: createMethod(section, 'properties', properties),
version: createMethod(section, 'version', version)
}
};
-48
View File
@@ -1,48 +0,0 @@
// Copyright 2017-2020 @polkadot/jsonrpc authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { InterfaceTypes } from '@polkadot/types/types';
type PubSub = [string, string, string];
export interface RpcParam {
isOptional: boolean;
name: string;
type: keyof InterfaceTypes;
}
export interface RpcMethodOpt {
description: string;
isDeprecated?: boolean;
isHidden?: boolean;
isOptional?: boolean;
isSigned?: boolean;
isSubscription?: boolean;
params: RpcParam[];
pubsub?: PubSub;
type: keyof InterfaceTypes;
}
export interface RpcMethod {
alias?: string;
description: string;
isDeprecated: boolean;
isHidden: boolean;
isOptional: boolean;
isSigned: boolean;
isSubscription: boolean;
method: string;
params: RpcParam[];
pubsub: PubSub;
section: string;
type: keyof InterfaceTypes;
}
export interface RpcSection {
isDeprecated: boolean;
isHidden: boolean;
description: string;
section: string;
methods: Record<string, RpcMethod>;
}
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/metadata",
"version": "1.6.2",
"version": "1.8.1",
"description": "Helpers to extract information from runtime metadata",
"main": "index.js",
"publishConfig": {
@@ -26,8 +26,8 @@
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
"dependencies": {
"@babel/runtime": "^7.8.4",
"@polkadot/types": "1.6.2",
"@babel/runtime": "^7.9.2",
"@polkadot/types": "1.8.1",
"@polkadot/util": "^2.6.2",
"@polkadot/util-crypto": "^2.6.2",
"bn.js": "^5.1.1"

Some files were not shown because too many files have changed in this diff Show More