Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e6b533539 | ||
|
|
224803f4c4 | ||
|
|
9fbf4bf478 | ||
|
|
385150bd81 | ||
|
|
14216a42a3 | ||
|
|
0055cb594f | ||
|
|
63e08d8357 | ||
|
|
c9f9e2ec8a | ||
|
|
019f1f761f | ||
|
|
c91e72b60b | ||
|
|
e4cf97d71e | ||
|
|
dcdbd2ca40 | ||
|
|
13ae360c7a | ||
|
|
6c0d683235 | ||
|
|
6fc35d641a | ||
|
|
d79c0ea28d | ||
|
|
486412d051 | ||
|
|
f3f1807013 | ||
|
|
d9e581fbdc | ||
|
|
89ebae9d78 | ||
|
|
071d872adf | ||
|
|
1b6d6d970c | ||
|
|
9f5be747e7 | ||
|
|
86cb0962bc | ||
|
|
75884d22a3 | ||
|
|
a4d09f799d | ||
|
|
85a29de479 | ||
|
|
ed2e44ac93 | ||
|
|
c88d284a5c | ||
|
|
daaa16523d | ||
|
|
116714a8f9 | ||
|
|
5c1f7fb527 | ||
|
|
8a69bc4458 | ||
|
|
a8dd059097 | ||
|
|
1204ac37f6 | ||
|
|
b2f03e500e | ||
|
|
de90242456 | ||
|
|
a7ffe44ae6 | ||
|
|
ac5bfeda39 | ||
|
|
73a184ec7d | ||
|
|
e4371684b6 | ||
|
|
382e903b8f | ||
|
|
6b6b7fe145 | ||
|
|
1f4e7638d5 | ||
|
|
4d95d622a9 | ||
|
|
327c20ddea | ||
|
|
04f6d352d9 | ||
|
|
c14a071b74 | ||
|
|
f103863fdd | ||
|
|
3c7c79f18f | ||
|
|
4e30fab9d6 |
@@ -0,0 +1 @@
|
||||
5
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = require('./babel.config.js');
|
||||
@@ -1,86 +0,0 @@
|
||||
<!--
|
||||
|
||||
For general support, howto, coding and bundling questions, please
|
||||
use the Substrate & Polkadot StackExchange at
|
||||
|
||||
https://substrate.stackexchange.com/
|
||||
|
||||
and get other ecosystem developers involved. This issues in this
|
||||
repository are meant for the tracking of feature requests and bug
|
||||
reports.
|
||||
|
||||
While all issues are looked at non-bug and non-features would take
|
||||
quite a bit longer to get to and may yield less than satisfactory
|
||||
responses in this format.
|
||||
|
||||
Additionally, please ensure you have done a search on the existing
|
||||
and closed issues before logging a new request. This saves time on
|
||||
all sides.
|
||||
|
||||
-->
|
||||
|
||||
|
||||
* **I'm submitting a ...**
|
||||
|
||||
<!---
|
||||
|
||||
REQUIRED:
|
||||
|
||||
Classify the type of report your are submitting
|
||||
|
||||
-->
|
||||
|
||||
- [ ] Bug report
|
||||
- [ ] Feature request
|
||||
- [ ] Support request
|
||||
- [ ] Other
|
||||
|
||||
|
||||
* **What is the current behavior and expected behavior?**
|
||||
|
||||
<!---
|
||||
|
||||
REQUIRED:
|
||||
|
||||
If you're describing a bug, tell us what should happen. If you're
|
||||
suggesting a change/improvement, tell us how it should work.
|
||||
|
||||
-->
|
||||
|
||||
|
||||
* **What is the motivation for changing the behavior?**
|
||||
|
||||
<!---
|
||||
|
||||
OPTIONAL:
|
||||
|
||||
Suggest a motivation for the request or ideas how to implement the
|
||||
addition or change
|
||||
|
||||
-->
|
||||
|
||||
|
||||
* **Please tell us about your environment:**
|
||||
|
||||
<!---
|
||||
|
||||
REQUIRED:
|
||||
|
||||
Include as many relevant details about the environment in which you
|
||||
experienced the issue. Also ensure that you have tested against the
|
||||
latest stable releases if you believe this to be a bug
|
||||
|
||||
-->
|
||||
|
||||
- Version:
|
||||
- Environment:
|
||||
|
||||
- [ ] Node.js
|
||||
- [ ] Browser
|
||||
- [ ] Other (limited support for other environments)
|
||||
|
||||
- Language:
|
||||
|
||||
- [ ] JavaScript
|
||||
- [ ] TypeScript (include tsc --version)
|
||||
- [ ] Other
|
||||
@@ -1,16 +0,0 @@
|
||||
name: bot
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [labeled]
|
||||
|
||||
jobs:
|
||||
approve:
|
||||
if: "! startsWith(github.event.head_commit.message, '[CI Skip]') && (!github.event.pull_request || github.event.pull_request.head.repo.full_name == github.repository)"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: jacogr/action-approve@795afd1dd096a2071d7ec98740661af4e853b7da
|
||||
with:
|
||||
authors: jacogr
|
||||
labels: -auto
|
||||
token: ${{ secrets.GH_PAT_BOT }}
|
||||
@@ -1,16 +0,0 @@
|
||||
name: bot
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [labeled]
|
||||
|
||||
jobs:
|
||||
merge:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: jacogr/action-merge@d2d64b4545acd93b0a9575177d3d215ae3f92029
|
||||
with:
|
||||
checks: pr (build),pr (lint),pr (test)
|
||||
labels: -auto
|
||||
strategy: squash
|
||||
token: ${{ secrets.GH_PAT_BOT }}
|
||||
@@ -1,25 +0,0 @@
|
||||
name: 'Lock Threads'
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '10 1/3 * * *'
|
||||
|
||||
jobs:
|
||||
lock:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
YARN_ENABLE_SCRIPTS: false
|
||||
steps:
|
||||
- uses: dessant/lock-threads@c1b35aecc5cdb1a34539d14196df55838bb2f836
|
||||
with:
|
||||
github-token: ${{ secrets.GH_PAT_BOT }}
|
||||
issue-inactive-days: '7'
|
||||
issue-comment: >
|
||||
This thread has been automatically locked since there has not been
|
||||
any recent activity after it was closed. Please open a new issue
|
||||
if you think you have a related problem or query.
|
||||
pr-inactive-days: '2'
|
||||
pr-comment: >
|
||||
This pull request has been automatically locked since there
|
||||
has not been any recent activity after it was closed.
|
||||
Please open a new issue for related bugs.
|
||||
@@ -1,25 +0,0 @@
|
||||
name: PR
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
pr:
|
||||
continue-on-error: true
|
||||
strategy:
|
||||
matrix:
|
||||
step: ['lint', 'test', 'build', 'deno']
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
YARN_ENABLE_SCRIPTS: false
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
- uses: denoland/setup-deno@v1
|
||||
with:
|
||||
deno-version: vx.x.x
|
||||
- name: ${{ matrix.step }}
|
||||
if: always()
|
||||
run: |
|
||||
yarn install --immutable
|
||||
yarn ${{ matrix.step }}
|
||||
@@ -1,31 +0,0 @@
|
||||
name: Master
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
master:
|
||||
if: "! startsWith(github.event.head_commit.message, '[CI Skip]')"
|
||||
strategy:
|
||||
matrix:
|
||||
step: ['build:release']
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
YARN_ENABLE_SCRIPTS: false
|
||||
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
||||
GH_PAT: ${{ secrets.GH_PAT_BOT }}
|
||||
GH_RELEASE_GITHUB_API_TOKEN: ${{ secrets.GH_PAT_BOT }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GH_PAT_BOT }}
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
- name: ${{ matrix.step }}
|
||||
run: |
|
||||
yarn install --immutable
|
||||
yarn ${{ matrix.step }}
|
||||
+3
-12
@@ -1,28 +1,19 @@
|
||||
_book/
|
||||
build/
|
||||
build-*/
|
||||
build-docs/
|
||||
coverage/
|
||||
docs/.vuepress/dist/
|
||||
node_modules/
|
||||
tmp/
|
||||
/import_map.json
|
||||
/mod.ts
|
||||
NOTES.md
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.npmrc
|
||||
.rpt2_cache
|
||||
.yarn/*
|
||||
!.yarn/releases
|
||||
!.yarn/plugins
|
||||
.pnp.*
|
||||
.vscode/
|
||||
cc-test-reporter
|
||||
lerna-debug.log*
|
||||
npm-debug.log*
|
||||
package-lock.json
|
||||
tsconfig*buildinfo
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
package-lock.json
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
Jaco <jacogr@gmail.com>
|
||||
github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> <action@github.com>
|
||||
github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Github Actions <action@github.com>
|
||||
@@ -1,3 +0,0 @@
|
||||
build
|
||||
coverage
|
||||
packages
|
||||
@@ -1,4 +0,0 @@
|
||||
// Copyright 2017-2023 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
module.exports = require('@polkadot/dev/config/prettier.cjs');
|
||||
-363
File diff suppressed because one or more lines are too long
-550
File diff suppressed because one or more lines are too long
Vendored
-785
File diff suppressed because one or more lines are too long
-18
@@ -1,18 +0,0 @@
|
||||
enableImmutableInstalls: false
|
||||
|
||||
enableProgressBars: false
|
||||
|
||||
logFilters:
|
||||
# Discard any "cannot be found in cache" messages
|
||||
- code: YN0013
|
||||
level: discard
|
||||
|
||||
nodeLinker: node-modules
|
||||
|
||||
plugins:
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
|
||||
spec: "@yarnpkg/plugin-interactive-tools"
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
|
||||
spec: "@yarnpkg/plugin-version"
|
||||
|
||||
yarnPath: .yarn/releases/yarn-3.2.0.cjs
|
||||
+34
-3739
File diff suppressed because it is too large
Load Diff
-122
@@ -1,122 +0,0 @@
|
||||
3467 Jaco 10.7.3 (#5660)
|
||||
83 Amaury Martiny StatementKind: Regular and Saft (#2303)
|
||||
37 Keith Ingram Update contract types and rpc (#4541)
|
||||
35 Stefanie Doll Updated child storage parameters (#1709)
|
||||
20 Luke Schoen fix: Fixes TypeError: Cannot read property 'vesting' of undefined (#1970)
|
||||
19 Xiliang Chen no warm for unknown signed extensions (#5601)
|
||||
15 Jeremías Díaz feat(types): add correct tuple type to storage key (#3054)
|
||||
14 Nikos Kontakis Bump substrate connect to 0.7.16 (#5307)
|
||||
11 Ian He HttpProvider support clone() (#3949)
|
||||
10 Axel Chalon Make Enum/Tuple constructor use value directly if instance (#1954)
|
||||
5 Chevdor Fix metadata package link (#3458)
|
||||
5 Jake Naviasky Fixing approvalFlagsToBools. (#1250)
|
||||
5 Julien Eluard General WsProvider extensibility improvements (#5467)
|
||||
4 Alex D Use derive customAccount and customLocks for balance overrides (#3248)
|
||||
4 Alex Wang fix issue that creates duplicate providers (#983)
|
||||
4 Alexander Popiak Add asset id in signing (#4009)
|
||||
4 Andreea Eftene add type overrides (#5506)
|
||||
4 Joshy Orndorff spelling; efect -> effect (#2295)
|
||||
4 Nantian fix bigint type (#3869)
|
||||
4 Scott Twiname Add support for historical BlockNumber rpc methods (#4574)
|
||||
4 Thibaut Sardan no subscription for http (#3127)
|
||||
3 André Silva add support for ValidationCodeHash (#3640)
|
||||
3 Antoine Estienne Adapted to display moonbeam author (#3108)
|
||||
3 Arjan Zijderveld Added `Emergency` to `ElectionPhase` (#3707)
|
||||
3 Ewa Kowalska Handle no council for bounties proposals (#3062)
|
||||
3 hamidra add support for n key entries for NMaps (#3886)
|
||||
3 Hamza Tokuchi more typos (#2532)
|
||||
3 Josep M Sobrepere docs: improve rpc-provider README (#4719)
|
||||
3 KarishmaBothara Backward compatibility thing (#3511)
|
||||
3 Miguel Hervas Adding RT4 Types (#3007)
|
||||
3 Shawn Tabrizi Add `isReadyOrError` when connecting to API (#2577)
|
||||
3 YJ feat: Vote interface as U8a (#1061)
|
||||
2 Alexander Krupenkin Add [u8; 33] type width for U8aFixed type (#2391)
|
||||
2 Branan Riley Add proxy type for Centrifuge (#3940)
|
||||
2 Branislav Kontur Fungibles runtime api for statemine/statemint/westmint (#5592)
|
||||
2 Caio Add `Range` and `RangeInclusive` types (#3791)
|
||||
2 HackFisher Update maxExtrinsic definition (#4703)
|
||||
2 Jakub Pánik All heads subscription (#1899)
|
||||
2 James Lefrère Add `.eq()` usage to docs and fix docs typos (#1405)
|
||||
2 Keith Yeung Allow keyPrefix to accept an additional argument for double maps (#2230)
|
||||
2 MOZGIII Follow-up fix after #4665 (#4666)
|
||||
2 Paweł Nguyen Fix a minor typo in cookbook blocks docs (#2294)
|
||||
2 rob thijssen nimbus author mapping correction (#5590)
|
||||
2 sung wu Update tx.md (#2485)
|
||||
2 Veliko Abi constructor takes different parameters (#3347)
|
||||
2 Wei Tang Use /usr/bin/env bash instead of /bin/bash (#2053)
|
||||
2 Yaroslav Bolyukin feat: allow objects to be supplied as map keys (#5128)
|
||||
2 Zannis Kalampoukis fix: Typegen handles structs and vectors of structs without erroring (#4743)
|
||||
2 扩散性百万甜面包 Typo, deocrateMethod -> decorateMethod (#1594)
|
||||
1 Alan Sapede Adds Eth feeHistory & maxPriorityFeePerGas rpc (#4956)
|
||||
1 Aleš Ferlan fix: use H160 for address in getTransactionCount (#5472)
|
||||
1 Brad Larson [NEW] Support for custom headers with providers (#2423)
|
||||
1 Btwiuse Arch Add side effect check workaround (#4994) (#5009)
|
||||
1 chriswmercer little readme tweak (#279)
|
||||
1 codingsh #2182 - add: search for docs (#2232)
|
||||
1 coolcorexix Investigate 4559 v2 (#4608)
|
||||
1 Dan Forbes Add WeightToFeeCoefficient type (#2296)
|
||||
1 Daniel Maricic Fixed typo in README (#2402)
|
||||
1 Daniel Savu fix: Generate custom type definitions (#4224)
|
||||
1 David Don't log full error (#2952)
|
||||
1 David Duong Avoid reserved words during named enum fields augmentation (#5203)
|
||||
1 Denis Tsai realign AccountKey20Junction to polkadot xcm's Junction enum (#3770)
|
||||
1 djuanito.eth Update fees to current constants (#2320)
|
||||
1 Drew Stone Update evm definitions to include vicinity (#2279)
|
||||
1 Dylan Galea Updated users of the polkadot-js/api (#2027)
|
||||
1 flex Change BeefySignedCommitment signatures type to EcdsaSignature (#4204)
|
||||
1 Florian Franzen metadataMd: use endpoint for rpc and runtime details too (#5628)
|
||||
1 Furqan A fix: fixed 404 to the docs from the api readme (#3985)
|
||||
1 Gérard Dethier Fix LRUCache memory leak. (#4520)
|
||||
1 Gerben van de Wiel Adding some extra notes on changes in the specname (#2329)
|
||||
1 HackFisher fix OutboundLaneData types (#3992)
|
||||
1 Hoani Bryson Multiple Endpoint support for WsProvider (#2234)
|
||||
1 Hyungsuk Kang Update fees.ts (#1014)
|
||||
1 icodezjb Update SessionKeys (#3035)
|
||||
1 iiiiiiii Make unknownTypes externally accessible (#3263)
|
||||
1 Jeeyong Um Fix inaccessible yargs instance error (#5531)
|
||||
1 JesseAbram added 07 Example showing how to make a transfer with allowed block permissions folder in docs (#1062)
|
||||
1 Joey don't throw error at `onSocketClose` (#4363)
|
||||
1 Jordan Allow typegen for custom RPCs (#2876)
|
||||
1 JQQQ Allow rpc expose definition/ metadata (#3488)
|
||||
1 Jun Jiang Update contract' gas to Weight type (#5324)
|
||||
1 Ken Vu Expose `blockNumber` via filterEvents function (#5394)
|
||||
1 Kian Paimani Update definitions.ts (#2514)
|
||||
1 Krzysztof Jelski Derive for bounties and descriptions (#2925)
|
||||
1 Lae Make sure awaiting on an api object won't stuck forever on error (#1763)
|
||||
1 Lezek123 BTreeSet and BTreeMap - encoding and serialization fixes (#3789)
|
||||
1 Lovesh Harchandani Fix name of "getBlock" in package "api-derive" and export it in "index.ts" (#2857)
|
||||
1 Mario Neises fix usage with typescript (#405)
|
||||
1 Mario Pino Add PolkaStats to API users (#1593)
|
||||
1 Mark Robert Henderson Update warnings.ts to have the latest URLs (#2720)
|
||||
1 Matej Nemček added Kodadot to @polkadot/api users section (#2220)
|
||||
1 Mokhtar Naamani Disable websocket outgoing message fragmentation for w3cwebsocket (#2738)
|
||||
1 Nazar Mokrynskyi Performance tweaks (#4143)
|
||||
1 Nikhil Ranjan add vestingPerBlock and vestingEndBlock in DeriveBalancesAll when doing calcBalances (#2563)
|
||||
1 Nikolay Volf Fix typo (#1730)
|
||||
1 Noah Corona Add rpc error fields (#4637)
|
||||
1 Oleksandr Mykhailenko Add more complex namespaced contracts & test cases for them (#4472)
|
||||
1 Paul M Fox Basic BTreeMaps codec support (#1474)
|
||||
1 philipstanislaus Update types for centrifuge chain v1.2.0 (#2424)
|
||||
1 Pierre Krieger Update substrate/connect to 0.7.6 (#4940)
|
||||
1 polymath-eric Allow unset external signer (#5649)
|
||||
1 Qinxuan Chen Add fp_account::AccountId20 mapping (#5551)
|
||||
1 qiuhao update DeriveCustom type (#2581)
|
||||
1 r0t0r-r0t0r Fix memory leak on raw rpc call (#4505)
|
||||
1 Raphael Flechtner fix: typegen disconnect ws on success (#4901)
|
||||
1 Robert Hambrock update MMR API (#5479)
|
||||
1 Rocco Musolino remove broken link (#2671)
|
||||
1 sander2 fix: type generation for nested tuples (#5395)
|
||||
1 satellitex Add BTreeSet<V> Codec (#1639)
|
||||
1 satellitex Add traits replace rules. for invalid cases `::<type>` and `<type>::`. (#885)
|
||||
1 Satyam Agrawal update as per the 0.97.0-beta.38 release (#1617)
|
||||
1 Sean Young Solang requires u256 and i256 types (#2752)
|
||||
1 serge make WS provider timeout configurable (#4758)
|
||||
1 Sergei Pepyakin INK! -> ink! (#1347)
|
||||
1 Shunji Zhan small polish (#5276)
|
||||
1 Stephen Shelton Add transaction-payment runtime API V3 (#5430)
|
||||
1 Tarik Gul Update .nvmrc (#5624)
|
||||
1 WoeOm adapt Darwinia, Crab Network types (#3498)
|
||||
1 Xat_MassacrE Fix packages/types/src/codec/utils/encodeTypes.ts encodeSubTypes bug (#1544)
|
||||
1 yjh fix MetadataVersioned.asV12 (#2983)
|
||||
1 Yuri fixes #3693 Fix uniques return types (#3694)
|
||||
1 Zeke Mostov fix: Allow sudo for polkadot indexed proxy enum (#3286)
|
||||
@@ -1,9 +1,42 @@
|
||||
# @polkadot/api
|
||||
# @plugnet/api
|
||||
|
||||
This library provides a clean wrapper around all the methods exposed by a Polkadot/Substrate network client and defines all the types exposed by a node. For complete documentation around the interfaces and their use, visit the [documentation portal](https://polkadot.js.org/docs/api/).
|
||||
_This repo is a fork of [@polkadot/api](https://github.com/polkadot-js/api), up to the version which works with current plug-node_
|
||||
|
||||
If you are an existing user, please be sure to track the [CHANGELOG](CHANGELOG.md) when changing versions.
|
||||
This library provides a clean wrapper around all the methods exposed by a Plugnet/Subtrate network client and defines all the types exposed by a node. For complete documentation around the classes, interfaces and their use, visit the [documentation portal](https://www.poweredbyplug.com/).
|
||||
|
||||
## tutorials
|
||||
|
||||
Looking for tutorials to get started? Look at [examples](https://polkadot.js.org/docs/api/examples/promise/) for guides on how to use the API to make queries and submit transactions.
|
||||
Looking for tutorials to get started? Look at [examples](https://www.poweredbyplug.com/) for guides on how to use the API to make queries and submit transactions.
|
||||
|
||||
## overview
|
||||
|
||||
The API is split up into a number of internal packages -
|
||||
|
||||
- [@plugnet/api](packages/api/) The API library, providing both Promise and RxJS Observable-based interfaces. This is the main user-facing entry point.
|
||||
- [@plugnet/api-derive](packages/api-derive/) Derived results that are injected into the API, allowing for combinations of various query results (only used internally and exposed on the Api instances via `api.derive.*`)
|
||||
- [@plugnet/rpc-core](packages/rpc-core/) Wrapper around all [JSON-RPC methods](https://www.poweredbyplug.com/) exposed by a Plugnet network client
|
||||
- [@plugnet/rpc-provider](packages/rpc-provider/) Providers for connecting to nodes, including WebSockets and Http
|
||||
- [@plugnet/rpc-rx](packages/rpc-rx/) A RxJs Observable wrapper around [@plugnet/rpc-provider](packages/rpc-provider)
|
||||
|
||||
Type definitions for interfaces as exposed by Plugnet & Substrate clients -
|
||||
|
||||
- [@plugnet/extrinsics](packages/type-extrinsics/) Base extrinsic definitions & codecs
|
||||
- [@plugnet/jsonrpc](packages/type-jsonrpc/) Definitions for JSONRPC endpoints
|
||||
- [@plugnet/storage](packages/type-storage/) Definitions for storage entries
|
||||
- [@plugnet/types](packages/types/) Codecs for all Plugnet primitives
|
||||
|
||||
## development
|
||||
|
||||
Contributions are welcome!
|
||||
|
||||
To start off, this repo (along with others in the [@plugnet](https://github.com/plugblockchain/) family) uses yarn workspaces to organise the code. As such, after cloning, its dependencies _should_ be installed via `yarn`, not via npm; the latter will result in broken dependencies.
|
||||
|
||||
To get started -
|
||||
|
||||
1. Clone the repo locally, via `git clone https://github.com/plugblockchain/api.js <optional local path>`
|
||||
2. Ensure that you have a recent version of Node.js, for development purposes [Node 10](https://nodejs.org/en/) is recommended.
|
||||
3. Ensure that you have a recent version of Yarn, for development purposes [Yarn >=1.10.1](https://yarnpkg.com/docs/install) is required.
|
||||
4. Install the dependencies by running `yarn`
|
||||
5. Build the everything via `yarn run build`
|
||||
6. You can also launch the API Docs, via `yarn vuepress dev docs`
|
||||
7. Access the docs via [http://localhost:8080](http://localhost:8080)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
extends: '@plugnet/dev/config/babel'
|
||||
};
|
||||
@@ -1,12 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="initial-scale=0.5, maximum-scale=1">
|
||||
<meta http-equiv="refresh" content="0;URL='https://polkadot.js.org/docs/api/'" />
|
||||
<title>Redirecting to https://polkadot.js.org/docs/api/</title>
|
||||
</head>
|
||||
<body>
|
||||
Redirecting to <a href="https://polkadot.js.org/docs/api/">https://polkadot.js.org/docs/api/</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,214 @@
|
||||
## Events
|
||||
|
||||
Events are emitted for certain operations on the runtime. The following sections describe the events that are part of the default Substrate runtime.
|
||||
- **[balances](#balances)**
|
||||
|
||||
- **[contract](#contract)**
|
||||
|
||||
- **[council](#council)**
|
||||
|
||||
- **[councilMotions](#councilMotions)**
|
||||
|
||||
- **[councilVoting](#councilVoting)**
|
||||
|
||||
- **[democracy](#democracy)**
|
||||
|
||||
- **[grandpa](#grandpa)**
|
||||
|
||||
- **[indices](#indices)**
|
||||
|
||||
- **[session](#session)**
|
||||
|
||||
- **[staking](#staking)**
|
||||
|
||||
- **[sudo](#sudo)**
|
||||
|
||||
- **[system](#system)**
|
||||
|
||||
- **[treasury](#treasury)**
|
||||
|
||||
|
||||
___
|
||||
|
||||
|
||||
### balances
|
||||
|
||||
▸ **NewAccount**(`AccountId`, `Balance`)
|
||||
- **summary**: A new account was created.
|
||||
|
||||
▸ **ReapedAccount**(`AccountId`)
|
||||
- **summary**: An account was reaped.
|
||||
|
||||
▸ **Transfer**(`AccountId`, `AccountId`, `Balance`, `Balance`)
|
||||
- **summary**: Transfer succeeded (from, to, value, fees).
|
||||
|
||||
___
|
||||
|
||||
|
||||
### contract
|
||||
|
||||
▸ **CodeStored**(`Hash`)
|
||||
- **summary**: Code with the specified hash has been stored.
|
||||
|
||||
▸ **Dispatched**(`AccountId`, `bool`)
|
||||
- **summary**: A call was dispatched from the given account. The bool signals whether it was successful execution or not.
|
||||
|
||||
▸ **Instantiated**(`AccountId`, `AccountId`)
|
||||
- **summary**: Contract deployed by address at the specified address.
|
||||
|
||||
▸ **ScheduleUpdated**(`u32`)
|
||||
- **summary**: Triggered when the current schedule is updated.
|
||||
|
||||
▸ **Transfer**(`AccountId`, `AccountId`, `Balance`)
|
||||
- **summary**: Transfer happened `from` to `to` with given `value` as part of a `call` or `create`.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### council
|
||||
|
||||
▸ **BadReaperSlashed**(`AccountId`)
|
||||
- **summary**: slashed reaper
|
||||
|
||||
▸ **TallyFinalized**(`Vec<AccountId>`, `Vec<AccountId>`)
|
||||
- **summary**: A tally (for approval votes of council seat(s)) has ended (with one or more new members).
|
||||
|
||||
▸ **TallyStarted**(`u32`)
|
||||
- **summary**: A tally (for approval votes of council seat(s)) has started.
|
||||
|
||||
▸ **VoterReaped**(`AccountId`, `AccountId`)
|
||||
- **summary**: reaped voter, reaper
|
||||
|
||||
___
|
||||
|
||||
|
||||
### councilMotions
|
||||
|
||||
▸ **Approved**(`Hash`)
|
||||
- **summary**: A motion was approved by the required threshold.
|
||||
|
||||
▸ **Disapproved**(`Hash`)
|
||||
- **summary**: A motion was not approved by the required threshold.
|
||||
|
||||
▸ **Executed**(`Hash`, `bool`)
|
||||
- **summary**: A motion was executed; `bool` is true if returned without error.
|
||||
|
||||
▸ **Proposed**(`AccountId`, `ProposalIndex`, `Hash`, `u32`)
|
||||
- **summary**: A motion (given hash) has been proposed (by given account) with a threshold (given u32).
|
||||
|
||||
▸ **Voted**(`AccountId`, `Hash`, `bool`, `u32`, `u32`)
|
||||
- **summary**: A motion (given hash) has been voted on by given account, leaving a tally (yes votes and no votes given as u32s respectively).
|
||||
|
||||
___
|
||||
|
||||
|
||||
### councilVoting
|
||||
|
||||
▸ **TallyCancelation**(`Hash`, `u32`, `u32`, `u32`)
|
||||
- **summary**: A voting tally has happened for a referendum cancellation vote. Last three are yes, no, abstain counts.
|
||||
|
||||
▸ **TallyReferendum**(`Hash`, `u32`, `u32`, `u32`)
|
||||
- **summary**: A voting tally has happened for a referendum vote. Last three are yes, no, abstain counts.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### democracy
|
||||
|
||||
▸ **Cancelled**(`ReferendumIndex`)
|
||||
|
||||
▸ **Delegated**(`AccountId`, `AccountId`)
|
||||
|
||||
▸ **Executed**(`ReferendumIndex`, `bool`)
|
||||
|
||||
▸ **NotPassed**(`ReferendumIndex`)
|
||||
|
||||
▸ **Passed**(`ReferendumIndex`)
|
||||
|
||||
▸ **Proposed**(`PropIndex`, `Balance`)
|
||||
|
||||
▸ **Started**(`ReferendumIndex`, `VoteThreshold`)
|
||||
|
||||
▸ **Tabled**(`PropIndex`, `Balance`, `Vec<AccountId>`)
|
||||
|
||||
▸ **Undelegated**(`AccountId`)
|
||||
|
||||
___
|
||||
|
||||
|
||||
### grandpa
|
||||
|
||||
▸ **NewAuthorities**(`Vec<(SessionKey,u64)>`)
|
||||
- **summary**: New authority set has been applied.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### indices
|
||||
|
||||
▸ **NewAccountIndex**(`AccountId`, `AccountIndex`)
|
||||
- **summary**: A new account index was assigned. This event is not triggered when an existing index is reassigned to another `AccountId`.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### session
|
||||
|
||||
▸ **NewSession**(`BlockNumber`)
|
||||
- **summary**: New session has happened. Note that the argument is the session index, not the block number as the type might suggest.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### staking
|
||||
|
||||
▸ **OfflineSlash**(`AccountId`, `Balance`)
|
||||
- **summary**: One validator (and their nominators) has been slashed by the given amount.
|
||||
|
||||
▸ **OfflineWarning**(`AccountId`, `u32`)
|
||||
- **summary**: One validator (and their nominators) has been given a offline-warning (they're still within their grace). The accrued number of slashes is recorded, too.
|
||||
|
||||
▸ **Reward**(`Balance`)
|
||||
- **summary**: All validators have been rewarded by the given balance.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### sudo
|
||||
|
||||
▸ **KeyChanged**(`AccountId`)
|
||||
- **summary**: The sudoer just switched identity; the old key is supplied.
|
||||
|
||||
▸ **Sudid**(`bool`)
|
||||
- **summary**: A sudo just took place.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### system
|
||||
|
||||
▸ **ExtrinsicFailed**()
|
||||
- **summary**: An extrinsic failed.
|
||||
|
||||
▸ **ExtrinsicSuccess**()
|
||||
- **summary**: An extrinsic completed successfully.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### treasury
|
||||
|
||||
▸ **Awarded**(`ProposalIndex`, `Balance`, `AccountId`)
|
||||
- **summary**: Some funds have been allocated.
|
||||
|
||||
▸ **Burnt**(`Balance`)
|
||||
- **summary**: Some of our funds have been burnt.
|
||||
|
||||
▸ **Proposed**(`ProposalIndex`)
|
||||
- **summary**: New proposal.
|
||||
|
||||
▸ **Rollover**(`Balance`)
|
||||
- **summary**: Spending has finished; this is the amount that rolls over until next spend.
|
||||
|
||||
▸ **Spending**(`Balance`)
|
||||
- **summary**: We have ended a spend period and will now allocate funds.
|
||||
@@ -0,0 +1,287 @@
|
||||
## Extrinsics
|
||||
|
||||
_The following sections contain Extrinsics methods are part of the default Substrate runtime._
|
||||
- **[balances](#balances)**
|
||||
|
||||
- **[consensus](#consensus)**
|
||||
|
||||
- **[contract](#contract)**
|
||||
|
||||
- **[council](#council)**
|
||||
|
||||
- **[councilMotions](#councilMotions)**
|
||||
|
||||
- **[councilVoting](#councilVoting)**
|
||||
|
||||
- **[democracy](#democracy)**
|
||||
|
||||
- **[finalityTracker](#finalityTracker)**
|
||||
|
||||
- **[grandpa](#grandpa)**
|
||||
|
||||
- **[session](#session)**
|
||||
|
||||
- **[staking](#staking)**
|
||||
|
||||
- **[sudo](#sudo)**
|
||||
|
||||
- **[timestamp](#timestamp)**
|
||||
|
||||
- **[treasury](#treasury)**
|
||||
|
||||
|
||||
___
|
||||
|
||||
|
||||
### balances
|
||||
|
||||
▸ **setBalance**(who: `Address`, free: `Compact<Balance>`, reserved: `Compact<Balance>`)
|
||||
- **summary**: Set the balances of a given account. This will alter `FreeBalance` and `ReservedBalance` in storage. If the new free or reserved balance is below the existential deposit, it will also decrease the total issuance of the system (`TotalIssuance`) and reset the account nonce (`system::AccountNonce`). The dispatch origin for this call is `root`.
|
||||
|
||||
▸ **transfer**(dest: `Address`, value: `Compact<Balance>`)
|
||||
- **summary**: Transfer some liquid free balance to another account. `transfer` will set the `FreeBalance` of the sender and receiver. It will decrease the total issuance of the system by the `TransferFee`. If the sender's account is below the existential deposit as a result of the transfer, the account will be reaped. The dispatch origin for this call must be `Signed` by the transactor.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### consensus
|
||||
|
||||
▸ **killStorage**(keys: `Vec<Key>`)
|
||||
- **summary**: Kill some items from storage.
|
||||
|
||||
▸ **noteOffline**(offline: `InherentOfflineReport`)
|
||||
- **summary**: Note the previous block's validator missed their opportunity to propose a block.
|
||||
|
||||
▸ **remark**(_remark: `Bytes`)
|
||||
- **summary**: Make some on-chain remark.
|
||||
|
||||
▸ **reportMisbehavior**(_report: `Bytes`)
|
||||
- **summary**: Report some misbehavior.
|
||||
|
||||
▸ **setCode**(new: `Bytes`)
|
||||
- **summary**: Set the new code.
|
||||
|
||||
▸ **setHeapPages**(pages: `u64`)
|
||||
- **summary**: Set the number of pages in the WebAssembly environment's heap.
|
||||
|
||||
▸ **setStorage**(items: `Vec<KeyValue>`)
|
||||
- **summary**: Set some items of storage.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### contract
|
||||
|
||||
▸ **call**(dest: `Address`, value: `Compact<BalanceOf>`, gas_limit: `Compact<Gas>`, data: `Bytes`)
|
||||
- **summary**: Makes a call to an account, optionally transferring some balance. * If the account is a smart-contract account, the associated code will be executed and any value will be transferred. * If the account is a regular account, any value will be transferred. * If no account exists and the call value is not less than `existential_deposit`, a regular account will be created and any value will be transferred.
|
||||
|
||||
▸ **create**(endowment: `Compact<BalanceOf>`, gas_limit: `Compact<Gas>`, code_hash: `CodeHash`, data: `Bytes`)
|
||||
- **summary**: Creates a new contract from the `codehash` generated by `put_code`, optionally transferring some balance. Creation is executed as follows: - the destination address is computed based on the sender and hash of the code. - the smart-contract account is created at the computed address. - the `ctor_code` is executed in the context of the newly created account. Buffer returned after the execution is saved as the `code` of the account. That code will be invoked upon any call received by this account. - The contract is initialized.
|
||||
|
||||
▸ **putCode**(gas_limit: `Compact<Gas>`, code: `Bytes`)
|
||||
- **summary**: Stores the given binary Wasm code into the chains storage and returns its `codehash`. You can instantiate contracts only with stored code.
|
||||
|
||||
▸ **updateSchedule**(schedule: `Schedule`)
|
||||
- **summary**: Updates the schedule for metering contracts. The schedule must have a greater version than the stored schedule.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### council
|
||||
|
||||
▸ **presentWinner**(candidate: `Address`, total: `Compact<BalanceOf>`, index: `Compact<VoteIndex>`)
|
||||
- **summary**: Claim that `signed` is one of the top Self::carry_count() + current_vote().1 candidates. Only works if the `block_number >= current_vote().0` and `< current_vote().0 + presentation_duration()`` `signed` should have at least
|
||||
|
||||
▸ **reapInactiveVoter**(reporter_index: `Compact<u32>`, who: `Address`, who_index: `Compact<u32>`, assumed_vote_index: `Compact<VoteIndex>`)
|
||||
- **summary**: Remove a voter. For it not to be a bond-consuming no-op, all approved candidate indices must now be either unregistered or registered to a candidate that registered the slot after the voter gave their last approval set. May be called by anyone. Returns the voter deposit to `signed`.
|
||||
|
||||
▸ **removeMember**(who: `Address`)
|
||||
- **summary**: Remove a particular member. A tally will happen instantly (if not already in a presentation period) to fill the seat if removal means that the desired members are not met. This is effective immediately.
|
||||
|
||||
▸ **retractVoter**(index: `Compact<u32>`)
|
||||
- **summary**: Remove a voter. All votes are cancelled and the voter deposit is returned.
|
||||
|
||||
▸ **setApprovals**(votes: `Vec<bool>`, index: `Compact<VoteIndex>`)
|
||||
- **summary**: Set candidate approvals. Approval slots stay valid as long as candidates in those slots are registered.
|
||||
|
||||
▸ **setDesiredSeats**(count: `Compact<u32>`)
|
||||
- **summary**: Set the desired member count; if lower than the current count, then seats will not be up election when they expire. If more, then a new vote will be started if one is not already in progress.
|
||||
|
||||
▸ **setPresentationDuration**(count: `Compact<BlockNumber>`)
|
||||
- **summary**: Set the presentation duration. If there is currently a vote being presented for, will invoke `finalize_vote`.
|
||||
|
||||
▸ **setTermDuration**(count: `Compact<BlockNumber>`)
|
||||
- **summary**: Set the presentation duration. If there is current a vote being presented for, will invoke `finalize_vote`.
|
||||
|
||||
▸ **submitCandidacy**(slot: `Compact<u32>`)
|
||||
- **summary**: Submit oneself for candidacy. Account must have enough transferrable funds in it to pay the bond.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### councilMotions
|
||||
|
||||
▸ **propose**(threshold: `Compact<u32>`, proposal: `Proposal`)
|
||||
|
||||
▸ **vote**(proposal: `Hash`, index: `Compact<ProposalIndex>`, approve: `bool`)
|
||||
|
||||
___
|
||||
|
||||
|
||||
### councilVoting
|
||||
|
||||
▸ **propose**(proposal: `Proposal`)
|
||||
|
||||
▸ **setCooloffPeriod**(blocks: `Compact<BlockNumber>`)
|
||||
|
||||
▸ **setVotingPeriod**(blocks: `Compact<BlockNumber>`)
|
||||
|
||||
▸ **veto**(proposal_hash: `Hash`)
|
||||
|
||||
▸ **vote**(proposal: `Hash`, approve: `bool`)
|
||||
|
||||
___
|
||||
|
||||
|
||||
### democracy
|
||||
|
||||
▸ **cancelQueued**(when: `Compact<BlockNumber>`, which: `Compact<u32>`)
|
||||
- **summary**: Cancel a proposal queued for enactment.
|
||||
|
||||
▸ **cancelReferendum**(ref_index: `Compact<ReferendumIndex>`)
|
||||
- **summary**: Remove a referendum.
|
||||
|
||||
▸ **delegate**(to: `AccountId`, lock_periods: `LockPeriods`)
|
||||
- **summary**: Delegate vote.
|
||||
|
||||
▸ **propose**(proposal: `Proposal`, value: `Compact<BalanceOf>`)
|
||||
- **summary**: Propose a sensitive action to be taken.
|
||||
|
||||
▸ **second**(proposal: `Compact<PropIndex>`)
|
||||
- **summary**: Propose a sensitive action to be taken.
|
||||
|
||||
▸ **startReferendum**(proposal: `Proposal`, threshold: `VoteThreshold`, delay: `BlockNumber`)
|
||||
- **summary**: Start a referendum.
|
||||
|
||||
▸ **undelegate**()
|
||||
- **summary**: Undelegate vote.
|
||||
|
||||
▸ **vote**(ref_index: `Compact<ReferendumIndex>`, vote: `Vote`)
|
||||
- **summary**: Vote in a referendum. If `vote.is_aye()`, the vote is to enact the proposal; otherwise it is a vote to keep the status quo.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### finalityTracker
|
||||
|
||||
▸ **finalHint**(hint: `Compact<BlockNumber>`)
|
||||
- **summary**: Hint that the author of this block thinks the best finalized block is the given number.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### grandpa
|
||||
|
||||
▸ **reportMisbehavior**(_report: `Bytes`)
|
||||
- **summary**: Report some misbehavior.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### session
|
||||
|
||||
▸ **forceNewSession**(apply_rewards: `bool`)
|
||||
- **summary**: Forces a new session.
|
||||
|
||||
▸ **setKey**(key: `SessionKey`)
|
||||
- **summary**: Sets the session key of `_validator` to `_key`. This doesn't take effect until the next session.
|
||||
|
||||
▸ **setLength**(new: `Compact<BlockNumber>`)
|
||||
- **summary**: Set a new session length. Won't kick in until the next session change (at current length).
|
||||
|
||||
___
|
||||
|
||||
|
||||
### staking
|
||||
|
||||
▸ **bond**(controller: `Address`, value: `Compact<BalanceOf>`, payee: `RewardDestination`)
|
||||
- **summary**: Take the origin account as a stash and lock up `value` of its balance. `controller` will be the account that controls it. The dispatch origin for this call must be _Signed_.
|
||||
|
||||
▸ **bondExtra**(max_additional: `Compact<BalanceOf>`)
|
||||
- **summary**: Add some extra amount that have appeared in the stash `free_balance` into the balance up for staking. Use this if there are additional funds in your stash account that you wish to bond. The dispatch origin for this call must be _Signed_ by the stash, not the controller.
|
||||
|
||||
▸ **chill**()
|
||||
- **summary**: Declare no desire to either validate or nominate. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the controller, not the stash.
|
||||
|
||||
▸ **forceNewEra**(apply_rewards: `bool`)
|
||||
- **summary**: Force there to be a new era. This also forces a new session immediately after. `apply_rewards` should be true for validators to get the session reward.
|
||||
|
||||
▸ **nominate**(targets: `Vec<Address>`)
|
||||
- **summary**: Declare the desire to nominate `targets` for the origin controller. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the controller, not the stash.
|
||||
|
||||
▸ **setBondingDuration**(new: `Compact<BlockNumber>`)
|
||||
- **summary**: The length of the bonding duration in eras.
|
||||
|
||||
▸ **setController**(controller: `Address`)
|
||||
- **summary**: (Re-)set the payment target for a controller. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the stash, not the controller.
|
||||
|
||||
▸ **setInvulnerables**(validators: `Vec<AccountId>`)
|
||||
- **summary**: Set the validators who cannot be slashed (if any).
|
||||
|
||||
▸ **setOfflineSlashGrace**(new: `Compact<u32>`)
|
||||
- **summary**: Set the offline slash grace period.
|
||||
|
||||
▸ **setPayee**(payee: `RewardDestination`)
|
||||
- **summary**: (Re-)set the payment target for a controller. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the controller, not the stash.
|
||||
|
||||
▸ **setSessionsPerEra**(new: `Compact<BlockNumber>`)
|
||||
- **summary**: Set the number of sessions in an era.
|
||||
|
||||
▸ **setValidatorCount**(new: `Compact<u32>`)
|
||||
- **summary**: The ideal number of validators.
|
||||
|
||||
▸ **unbond**(value: `Compact<BalanceOf>`)
|
||||
- **summary**: Schedule a portion of the stash to be unlocked ready for transfer out after the bond period ends. If this leaves an amount actively bonded less than T::Currency::existential_deposit(), then it is increased to the full amount. Once the unlock period is done, you can call `withdraw_unbonded` to actually move the funds out of management ready for transfer. The dispatch origin for this call must be _Signed_ by the controller, not the stash. See also [`Call::withdraw_unbonded`].
|
||||
|
||||
▸ **validate**(prefs: `ValidatorPrefs`)
|
||||
- **summary**: Declare the desire to validate for the origin controller. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the controller, not the stash.
|
||||
|
||||
▸ **withdrawUnbonded**()
|
||||
- **summary**: Remove any unlocked chunks from the `unlocking` queue from our management. This essentially frees up that balance to be used by the stash account to do whatever it wants. The dispatch origin for this call must be _Signed_ by the controller, not the stash. See also [`Call::unbond`].
|
||||
|
||||
___
|
||||
|
||||
|
||||
### sudo
|
||||
|
||||
▸ **setKey**(new: `Address`)
|
||||
|
||||
▸ **sudo**(proposal: `Proposal`)
|
||||
|
||||
___
|
||||
|
||||
|
||||
### timestamp
|
||||
|
||||
▸ **set**(now: `Compact<Moment>`)
|
||||
- **summary**: Set the current time. This call should be invoked exactly once per block. It will panic at the finalization phase, if this call hasn't been invoked by that time. The timestamp should be greater than the previous one by the amount specified by `minimum_period`. The dispatch origin for this call must be `Inherent`.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### treasury
|
||||
|
||||
▸ **approveProposal**(proposal_id: `Compact<ProposalIndex>`)
|
||||
- **summary**: Approve a proposal. At a later time, the proposal will be allocated to the beneficiary and the original deposit will be returned.
|
||||
|
||||
▸ **configure**(proposal_bond: `Compact<Permill>`, proposal_bond_minimum: `Compact<BalanceOf>`, spend_period: `Compact<BlockNumber>`, burn: `Compact<Permill>`)
|
||||
- **summary**: (Re-)configure this module.
|
||||
|
||||
▸ **proposeSpend**(value: `Compact<BalanceOf>`, beneficiary: `Address`)
|
||||
- **summary**: Put forward a suggestion for spending. A deposit proportional to the value is reserved and slashed if the proposal is rejected. It is returned once the proposal is awarded.
|
||||
|
||||
▸ **rejectProposal**(proposal_id: `Compact<ProposalIndex>`)
|
||||
- **summary**: Reject a proposed spend. The original deposit will be slashed.
|
||||
|
||||
▸ **setPot**(new_pot: `Compact<BalanceOf>`)
|
||||
- **summary**: Set the balance of funds available to spend.
|
||||
@@ -0,0 +1,117 @@
|
||||
## JSON-RPC
|
||||
|
||||
_The following sections contain RPC methods that are Remote Calls available by default and allow you to interact with the actual node, query, and submit. The RPCs are provided by Substrate itself._
|
||||
- **[author](#author)**
|
||||
|
||||
- **[chain](#chain)**
|
||||
|
||||
- **[state](#state)**
|
||||
|
||||
- **[system](#system)**
|
||||
|
||||
|
||||
___
|
||||
|
||||
|
||||
### author
|
||||
|
||||
_Authoring of network items_
|
||||
|
||||
▸ **pendingExtrinsics**(): `PendingExtrinsics`
|
||||
- **summary**: Returns all pending extrinsics, potentially grouped by sender
|
||||
|
||||
▸ **submitAndWatchExtrinsic**(extrinsic: `Extrinsic`): `ExtrinsicStatus`
|
||||
- **summary**: Subscribe and watch an extrinsic until unsubscribed
|
||||
|
||||
▸ **submitExtrinsic**(extrinsic: `Extrinsic`): `Hash`
|
||||
- **summary**: Submit a fully formatted extrinsic for block inclusion
|
||||
|
||||
___
|
||||
|
||||
|
||||
### chain
|
||||
|
||||
_Retrieval of chain data_
|
||||
|
||||
▸ **getBlock**(hash?: `Hash`): `SignedBlock`
|
||||
- **summary**: Get header and body of a relay chain block
|
||||
|
||||
▸ **getBlockHash**(blockNumber?: `BlockNumber`): `Hash`
|
||||
- **summary**: Get the block hash for a specific block
|
||||
|
||||
▸ **getFinalizedHead**(): `Hash`
|
||||
- **summary**: Get hash of the last finalised block in the canon chain
|
||||
|
||||
▸ **getHeader**(hash?: `Hash`): `Header`
|
||||
- **summary**: Retrieves the header for a specific block
|
||||
|
||||
▸ **getRuntimeVersion**(hash?: `Hash`): `RuntimeVersion`
|
||||
- **summary**: Get the runtime version (alias of state_getRuntimeVersion)
|
||||
|
||||
▸ **subscribeFinalizedHeads**(): `Header`
|
||||
- **summary**: Retrieves the best finalized header via subscription
|
||||
|
||||
▸ **subscribeNewHead**(): `Header`
|
||||
- **summary**: Retrieves the best header via subscription
|
||||
|
||||
▸ **subscribeRuntimeVersion**(): `RuntimeVersion`
|
||||
- **summary**: Retrieves the runtime version via subscription
|
||||
|
||||
___
|
||||
|
||||
|
||||
### state
|
||||
|
||||
_Query of state_
|
||||
|
||||
▸ **call**(method: `Text`, data: `Bytes`, block?: `Hash`): `Bytes`
|
||||
- **summary**: Perform a call to a builtin on the chain
|
||||
|
||||
▸ **getMetadata**(block?: `Hash`): `Metadata`
|
||||
- **summary**: Returns the runtime metadata
|
||||
|
||||
▸ **getRuntimeVersion**(hash?: `Hash`): `RuntimeVersion`
|
||||
- **summary**: Get the runtime version
|
||||
|
||||
▸ **getStorage**(key: `StorageKey`, block?: `Hash`): `StorageData`
|
||||
- **summary**: Retrieves the storage for a key
|
||||
|
||||
▸ **getStorageHash**(key: `StorageKey`, block?: `Hash`): `Hash`
|
||||
- **summary**: Retrieves the storage hash
|
||||
|
||||
▸ **getStorageSize**(key: `StorageKey`, block?: `Hash`): `u64`
|
||||
- **summary**: Retrieves the storage size
|
||||
|
||||
▸ **queryStorage**(keys: `Vec<StorageKey>`, startBlock: `Hash`, block?: `Hash`): `Vec<StorageChangeSet>`
|
||||
- **summary**: Query historical storage entries (by key) starting from a start block
|
||||
|
||||
▸ **subscribeStorage**(keys: `Vec<StorageKey>`): `StorageChangeSet`
|
||||
- **summary**: Subscribes to storage changes for the provided keys
|
||||
|
||||
___
|
||||
|
||||
|
||||
### system
|
||||
|
||||
_Methods to retrieve system info_
|
||||
|
||||
▸ **chain**(): `Text`
|
||||
- **summary**: Retrieves the chain
|
||||
|
||||
▸ **health**(): `Health`
|
||||
- **summary**: Return health status of the node
|
||||
|
||||
▸ **name**(): `Text`
|
||||
- **summary**: Retrieves the node name
|
||||
|
||||
▸ **networkState**(): `NetworkState`
|
||||
- **summary**: Returns current state of the network
|
||||
|
||||
▸ **peers**(): `Vec<PeerInfo>`
|
||||
- **summary**: Returns the currently connected peers
|
||||
|
||||
▸ **properties**(): `ChainProperties`
|
||||
- **summary**: Get a custom set of properties as a JSON object, defined in the chain spec
|
||||
|
||||
▸ **version**(): `Text`
|
||||
- **summary**: Retrieves the version of the node
|
||||
@@ -0,0 +1,529 @@
|
||||
## Storage
|
||||
|
||||
_The following sections contain Storage methods are part of the default Substrate runtime._
|
||||
- **[balances](#balances)**
|
||||
|
||||
- **[consensus](#consensus)**
|
||||
|
||||
- **[contract](#contract)**
|
||||
|
||||
- **[council](#council)**
|
||||
|
||||
- **[councilMotions](#councilMotions)**
|
||||
|
||||
- **[councilVoting](#councilVoting)**
|
||||
|
||||
- **[democracy](#democracy)**
|
||||
|
||||
- **[grandpaFinality](#grandpaFinality)**
|
||||
|
||||
- **[indices](#indices)**
|
||||
|
||||
- **[session](#session)**
|
||||
|
||||
- **[staking](#staking)**
|
||||
|
||||
- **[sudo](#sudo)**
|
||||
|
||||
- **[system](#system)**
|
||||
|
||||
- **[timestamp](#timestamp)**
|
||||
|
||||
- **[treasury](#treasury)**
|
||||
|
||||
- **[substrate](#substrate)**
|
||||
|
||||
|
||||
___
|
||||
|
||||
|
||||
### balances
|
||||
|
||||
▸ **creationFee**(): `Balance`
|
||||
- **summary**: The fee required to create an account.
|
||||
|
||||
▸ **existentialDeposit**(): `Balance`
|
||||
- **summary**: The minimum amount required to keep an account open.
|
||||
|
||||
▸ **freeBalance**(`AccountId`): `Balance`
|
||||
- **summary**: The 'free' balance of a given account. This is the only balance that matters in terms of most operations on tokens. It alone is used to determine the balance when in the contract execution environment. When this balance falls below the value of `ExistentialDeposit`, then the 'current account' is deleted: specifically `FreeBalance`. Further, the `OnFreeBalanceZero` callback is invoked, giving a chance to external modules to clean up data associated with the deleted account. `system::AccountNonce` is also deleted if `ReservedBalance` is also zero (it also gets collapsed to zero if it ever becomes less than `ExistentialDeposit`.
|
||||
|
||||
▸ **locks**(`AccountId`): `Vec<BalanceLock>`
|
||||
- **summary**: Any liquidity locks on some account balances.
|
||||
|
||||
▸ **reservedBalance**(`AccountId`): `Balance`
|
||||
- **summary**: The amount of the balance of a given account that is externally reserved; this can still get slashed, but gets slashed last of all. This balance is a 'reserve' balance that other subsystems use in order to set aside tokens that are still 'owned' by the account holder, but which are suspendable. When this balance falls below the value of `ExistentialDeposit`, then this 'reserve account' is deleted: specifically, `ReservedBalance`. `system::AccountNonce` is also deleted if `FreeBalance` is also zero (it also gets collapsed to zero if it ever becomes less than `ExistentialDeposit`.)
|
||||
|
||||
▸ **totalIssuance**(): `Balance`
|
||||
- **summary**: The total units issued in the system.
|
||||
|
||||
▸ **transactionBaseFee**(): `Balance`
|
||||
- **summary**: The fee to be paid for making a transaction; the base.
|
||||
|
||||
▸ **transactionByteFee**(): `Balance`
|
||||
- **summary**: The fee to be paid for making a transaction; the per-byte portion.
|
||||
|
||||
▸ **transferFee**(): `Balance`
|
||||
- **summary**: The fee required to make a transfer.
|
||||
|
||||
▸ **vesting**(`AccountId`): `Option<VestingSchedule>`
|
||||
- **summary**: Information regarding the vesting of a given account.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### consensus
|
||||
|
||||
▸ **originalAuthorities**(): `Option<Vec<SessionKey>>`
|
||||
|
||||
___
|
||||
|
||||
|
||||
### contract
|
||||
|
||||
▸ **accountCounter**(): `u64`
|
||||
- **summary**: The subtrie counter
|
||||
|
||||
▸ **accountInfoOf**(`AccountId`): `Option<AccountInfo>`
|
||||
- **summary**: The code associated with a given account.
|
||||
|
||||
▸ **blockGasLimit**(): `Gas`
|
||||
- **summary**: The maximum amount of gas that could be expended per block.
|
||||
|
||||
▸ **callBaseFee**(): `Gas`
|
||||
- **summary**: The base fee charged for calling into a contract.
|
||||
|
||||
▸ **codeHashOf**(`AccountId`): `Option<CodeHash>`
|
||||
- **summary**: The code associated with a given account.
|
||||
|
||||
▸ **codeStorage**(`CodeHash`): `Option<PrefabWasmModule>`
|
||||
- **summary**: A mapping between an original code hash and instrumented wasm code, ready for the execution.
|
||||
|
||||
▸ **contractFee**(): `BalanceOf`
|
||||
- **summary**: The fee required to create a contract instance.
|
||||
|
||||
▸ **createBaseFee**(): `Gas`
|
||||
- **summary**: The base fee charged for creating a contract.
|
||||
|
||||
▸ **creationFee**(): `BalanceOf`
|
||||
- **summary**: The fee required to create an account.
|
||||
|
||||
▸ **currentSchedule**(): `Schedule`
|
||||
- **summary**: Current cost schedule for contracts.
|
||||
|
||||
▸ **gasPrice**(): `BalanceOf`
|
||||
- **summary**: The price of one unit of gas.
|
||||
|
||||
▸ **gasSpent**(): `Gas`
|
||||
- **summary**: Gas spent so far in this block.
|
||||
|
||||
▸ **maxDepth**(): `u32`
|
||||
- **summary**: The maximum nesting level of a call/create stack.
|
||||
|
||||
▸ **pristineCode**(`CodeHash`): `Option<Bytes>`
|
||||
- **summary**: A mapping from an original code hash to the original code, untouched by instrumentation.
|
||||
|
||||
▸ **transactionBaseFee**(): `BalanceOf`
|
||||
- **summary**: The fee to be paid for making a transaction; the base.
|
||||
|
||||
▸ **transactionByteFee**(): `BalanceOf`
|
||||
- **summary**: The fee to be paid for making a transaction; the per-byte portion.
|
||||
|
||||
▸ **transferFee**(): `BalanceOf`
|
||||
- **summary**: The fee required to make a transfer.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### council
|
||||
|
||||
▸ **activeCouncil**(): `Vec<(AccountId,BlockNumber)>`
|
||||
- **summary**: The current council. When there's a vote going on, this should still be used for executive matters. The block number (second element in the tuple) is the block that their position is active until (calculated by the sum of the block number when the council member was elected and their term duration).
|
||||
|
||||
▸ **approvalsOf**(`AccountId`): `Vec<bool>`
|
||||
- **summary**: A list of votes for each voter, respecting the last cleared vote index that this voter was last active at.
|
||||
|
||||
▸ **candidacyBond**(): `BalanceOf`
|
||||
- **summary**: How much should be locked up in order to submit one's candidacy.
|
||||
|
||||
▸ **candidateCount**(): `u32`
|
||||
|
||||
▸ **candidates**(): `Vec<AccountId>`
|
||||
- **summary**: The present candidate list.
|
||||
|
||||
▸ **carryCount**(): `u32`
|
||||
- **summary**: How many runners-up should have their approvals persist until the next vote.
|
||||
|
||||
▸ **desiredSeats**(): `u32`
|
||||
- **summary**: Number of accounts that should be sitting on the council.
|
||||
|
||||
▸ **inactiveGracePeriod**(): `VoteIndex`
|
||||
- **summary**: How many vote indexes need to go by after a target voter's last vote before they can be reaped if their approvals are moot.
|
||||
|
||||
▸ **lastActiveOf**(`AccountId`): `Option<VoteIndex>`
|
||||
- **summary**: The last cleared vote index that this voter was last active at.
|
||||
|
||||
▸ **leaderboard**(): `Option<Vec<(BalanceOf,AccountId)>>`
|
||||
- **summary**: Get the leaderboard if we;re in the presentation phase.
|
||||
|
||||
▸ **nextFinalize**(): `Option<(BlockNumber,u32,Vec<AccountId>)>`
|
||||
- **summary**: The accounts holding the seats that will become free on the next tally.
|
||||
|
||||
▸ **presentSlashPerVoter**(): `BalanceOf`
|
||||
- **summary**: The punishment, per voter, if you provide an invalid presentation.
|
||||
|
||||
▸ **presentationDuration**(): `BlockNumber`
|
||||
- **summary**: How long to give each top candidate to present themselves after the vote ends.
|
||||
|
||||
▸ **registerInfoOf**(`AccountId`): `Option<(VoteIndex,u32)>`
|
||||
- **summary**: The vote index and list slot that the candidate `who` was registered or `None` if they are not currently registered.
|
||||
|
||||
▸ **snapshotedStakes**(): `Vec<BalanceOf>`
|
||||
- **summary**: The stakes as they were at the point that the vote ended.
|
||||
|
||||
▸ **termDuration**(): `BlockNumber`
|
||||
- **summary**: How long each position is active for.
|
||||
|
||||
▸ **voteCount**(): `VoteIndex`
|
||||
- **summary**: The total number of votes that have happened or are in progress.
|
||||
|
||||
▸ **voters**(): `Vec<AccountId>`
|
||||
- **summary**: The present voter list.
|
||||
|
||||
▸ **votingBond**(): `BalanceOf`
|
||||
- **summary**: How much should be locked up in order to be able to submit votes.
|
||||
|
||||
▸ **votingPeriod**(): `BlockNumber`
|
||||
- **summary**: How often (in blocks) to check for new votes.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### councilMotions
|
||||
|
||||
▸ **proposalCount**(): `u32`
|
||||
- **summary**: Proposals so far.
|
||||
|
||||
▸ **proposalOf**(`Hash`): `Option<Proposal>`
|
||||
- **summary**: Actual proposal for a given hash, if it's current.
|
||||
|
||||
▸ **proposals**(): `Vec<Hash>`
|
||||
- **summary**: The (hashes of) the active proposals.
|
||||
|
||||
▸ **voting**(`Hash`): `Option<(ProposalIndex,u32,Vec<AccountId>,Vec<AccountId>)>`
|
||||
- **summary**: Votes for a given proposal: (required_yes_votes, yes_voters, no_voters).
|
||||
|
||||
___
|
||||
|
||||
|
||||
### councilVoting
|
||||
|
||||
▸ **cooloffPeriod**(): `BlockNumber`
|
||||
|
||||
▸ **councilVoteOf**(`(Hash,AccountId)`): `Option<bool>`
|
||||
|
||||
▸ **enactDelayPeriod**(): `BlockNumber`
|
||||
- **summary**: Number of blocks by which to delay enactment of successful, non-unanimous-council-instigated referendum proposals.
|
||||
|
||||
▸ **proposalOf**(`Hash`): `Option<Proposal>`
|
||||
|
||||
▸ **proposalVoters**(`Hash`): `Vec<AccountId>`
|
||||
|
||||
▸ **proposals**(): `Vec<(BlockNumber,Hash)>`
|
||||
|
||||
▸ **vetoedProposal**(`Hash`): `Option<(BlockNumber,Vec<AccountId>)>`
|
||||
|
||||
▸ **votingPeriod**(): `BlockNumber`
|
||||
|
||||
___
|
||||
|
||||
|
||||
### democracy
|
||||
|
||||
▸ **delegations**(`AccountId`): `((AccountId,LockPeriods), Linkage<AccountId>)`
|
||||
- **summary**: Get the account (and lock periods) to which another account is delegating vote.
|
||||
|
||||
▸ **depositOf**(`PropIndex`): `Option<(BalanceOf,Vec<AccountId>)>`
|
||||
- **summary**: Those who have locked a deposit.
|
||||
|
||||
▸ **dispatchQueue**(`BlockNumber`): `Vec<Option<(Proposal,ReferendumIndex)>>`
|
||||
- **summary**: Queue of successful referenda to be dispatched.
|
||||
|
||||
▸ **launchPeriod**(): `BlockNumber`
|
||||
- **summary**: How often (in blocks) new public referenda are launched.
|
||||
|
||||
▸ **maxLockPeriods**(): `LockPeriods`
|
||||
- **summary**: The maximum number of additional lock periods a voter may offer to strengthen their vote. Multiples of `PublicDelay`.
|
||||
|
||||
▸ **minimumDeposit**(): `BalanceOf`
|
||||
- **summary**: The minimum amount to be used as a deposit for a public referendum proposal.
|
||||
|
||||
▸ **nextTally**(): `ReferendumIndex`
|
||||
- **summary**: The next referendum index that should be tallied.
|
||||
|
||||
▸ **publicDelay**(): `BlockNumber`
|
||||
- **summary**: The delay before enactment for all public referenda.
|
||||
|
||||
▸ **publicPropCount**(): `PropIndex`
|
||||
- **summary**: The number of (public) proposals that have been made so far.
|
||||
|
||||
▸ **publicProps**(): `Vec<(PropIndex,Proposal,AccountId)>`
|
||||
- **summary**: The public proposals. Unsorted.
|
||||
|
||||
▸ **referendumCount**(): `ReferendumIndex`
|
||||
- **summary**: The next free referendum index, aka the number of referendums started so far.
|
||||
|
||||
▸ **referendumInfoOf**(`ReferendumIndex`): `Option<ReferendumInfo>`
|
||||
- **summary**: Information concerning any given referendum.
|
||||
|
||||
▸ **voteOf**(`(ReferendumIndex,AccountId)`): `Vote`
|
||||
- **summary**: Get the vote in a given referendum of a particular voter. The result is meaningful only if `voters_for` includes the voter when called with the referendum (you'll get the default `Vote` value otherwise). If you don't want to check `voters_for`, then you can also check for simple existence with `VoteOf::exists` first.
|
||||
|
||||
▸ **votersFor**(`ReferendumIndex`): `Vec<AccountId>`
|
||||
- **summary**: Get the voters for the current proposal.
|
||||
|
||||
▸ **votingPeriod**(): `BlockNumber`
|
||||
- **summary**: How often (in blocks) to check for new votes.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### grandpaFinality
|
||||
|
||||
▸ **nextForced**(): `Option<BlockNumber>`
|
||||
|
||||
▸ **pendingChange**(): `Option<StoredPendingChange>`
|
||||
|
||||
___
|
||||
|
||||
|
||||
### indices
|
||||
|
||||
▸ **enumSet**(`AccountIndex`): `Vec<AccountId>`
|
||||
- **summary**: The enumeration sets.
|
||||
|
||||
▸ **nextEnumSet**(): `AccountIndex`
|
||||
- **summary**: The next free enumeration set.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### session
|
||||
|
||||
▸ **currentIndex**(): `BlockNumber`
|
||||
- **summary**: Current index of the session.
|
||||
|
||||
▸ **currentStart**(): `Moment`
|
||||
- **summary**: Timestamp when current session started.
|
||||
|
||||
▸ **forcingNewSession**(): `Option<bool>`
|
||||
- **summary**: New session is being forced is this entry exists; in which case, the boolean value is whether the new session should be considered a normal rotation (rewardable) or exceptional (slashable).
|
||||
|
||||
▸ **lastLengthChange**(): `Option<BlockNumber>`
|
||||
- **summary**: Block at which the session length last changed.
|
||||
|
||||
▸ **nextKeyFor**(`AccountId`): `Option<SessionKey>`
|
||||
- **summary**: The next key for a given validator.
|
||||
|
||||
▸ **nextSessionLength**(): `Option<BlockNumber>`
|
||||
- **summary**: The next session length.
|
||||
|
||||
▸ **sessionLength**(): `BlockNumber`
|
||||
- **summary**: Current length of the session.
|
||||
|
||||
▸ **validators**(): `Vec<AccountId>`
|
||||
- **summary**: The current set of validators.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### staking
|
||||
|
||||
▸ **bonded**(`AccountId`): `Option<AccountId>`
|
||||
- **summary**: Map from all locked "stash" accounts to the controller account.
|
||||
|
||||
▸ **bondingDuration**(): `BlockNumber`
|
||||
- **summary**: The length of the bonding duration in blocks.
|
||||
|
||||
▸ **currentElected**(): `Vec<AccountId>`
|
||||
- **summary**: The currently elected validator set keyed by stash account ID.
|
||||
|
||||
▸ **currentEra**(): `BlockNumber`
|
||||
- **summary**: The current era index.
|
||||
|
||||
▸ **currentEraReward**(): `BalanceOf`
|
||||
- **summary**: The accumulated reward for the current era. Reset to zero at the beginning of the era and increased for every successfully finished session.
|
||||
|
||||
▸ **currentSessionReward**(): `BalanceOf`
|
||||
- **summary**: Maximum reward, per validator, that is provided per acceptable session.
|
||||
|
||||
▸ **forcingNewEra**(): `Option<Null>`
|
||||
- **summary**: We are forcing a new era.
|
||||
|
||||
▸ **invulnerables**(): `Vec<AccountId>`
|
||||
- **summary**: Any validators that may never be slashed or forcibly kicked. It's a Vec since they're easy to initialize and the performance hit is minimal (we expect no more than four invulnerables) and restricted to testnets.
|
||||
|
||||
▸ **lastEraLengthChange**(): `BlockNumber`
|
||||
- **summary**: The session index at which the era length last changed.
|
||||
|
||||
▸ **ledger**(`AccountId`): `Option<StakingLedger>`
|
||||
- **summary**: Map from all (unlocked) "controller" accounts to the info regarding the staking.
|
||||
|
||||
▸ **minimumValidatorCount**(): `u32`
|
||||
- **summary**: Minimum number of staking participants before emergency conditions are imposed.
|
||||
|
||||
▸ **nextSessionsPerEra**(): `Option<BlockNumber>`
|
||||
- **summary**: The next value of sessions per era.
|
||||
|
||||
▸ **nominators**(`AccountId`): `(Vec<AccountId>, Linkage<AccountId>)`
|
||||
- **summary**: The map from nominator stash key to the set of stash keys of all validators to nominate.
|
||||
|
||||
▸ **offlineSlash**(): `Perbill`
|
||||
- **summary**: Slash, per validator that is taken for the first time they are found to be offline.
|
||||
|
||||
▸ **offlineSlashGrace**(): `u32`
|
||||
- **summary**: Number of instances of offline reports before slashing begins for validators.
|
||||
|
||||
▸ **payee**(`AccountId`): `RewardDestination`
|
||||
- **summary**: Where the reward payment should be made. Keyed by stash.
|
||||
|
||||
▸ **recentlyOffline**(): `Vec<(AccountId,BlockNumber,u32)>`
|
||||
- **summary**: Most recent `RECENT_OFFLINE_COUNT` instances. (who it was, when it was reported, how many instances they were offline for).
|
||||
|
||||
▸ **sessionReward**(): `Perbill`
|
||||
- **summary**: Maximum reward, per validator, that is provided per acceptable session.
|
||||
|
||||
▸ **sessionsPerEra**(): `BlockNumber`
|
||||
- **summary**: The length of a staking era in sessions.
|
||||
|
||||
▸ **slashCount**(`AccountId`): `u32`
|
||||
- **summary**: The number of times a given validator has been reported offline. This gets decremented by one each era that passes.
|
||||
|
||||
▸ **slotStake**(): `BalanceOf`
|
||||
- **summary**: The amount of balance actively at stake for each validator slot, currently. This is used to derive rewards and punishments.
|
||||
|
||||
▸ **stakers**(`AccountId`): `Exposure`
|
||||
- **summary**: Nominators for a particular account that is in action right now. You can't iterate through validators here, but you can find them in the `sessions` module. This is keyed by the stash account.
|
||||
|
||||
▸ **validatorCount**(): `u32`
|
||||
- **summary**: The ideal number of staking participants.
|
||||
|
||||
▸ **validators**(`AccountId`): `(ValidatorPrefs, Linkage<AccountId>)`
|
||||
- **summary**: The map from (wannabe) validator stash key to the preferences of that validator.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### sudo
|
||||
|
||||
▸ **key**(): `AccountId`
|
||||
|
||||
___
|
||||
|
||||
|
||||
### system
|
||||
|
||||
▸ **accountNonce**(`AccountId`): `Index`
|
||||
- **summary**: Extrinsics nonce for accounts.
|
||||
|
||||
▸ **allExtrinsicsLen**(): `Option<u32>`
|
||||
- **summary**: Total length in bytes for all extrinsics put together, for the current block.
|
||||
|
||||
▸ **blockHash**(`BlockNumber`): `Hash`
|
||||
- **summary**: Map of block numbers to block hashes.
|
||||
|
||||
▸ **digest**(): `Digest`
|
||||
- **summary**: Digest of the current block, also part of the block header.
|
||||
|
||||
▸ **events**(): `Vec<EventRecord>`
|
||||
- **summary**: Events deposited for the current block.
|
||||
|
||||
▸ **extrinsicCount**(): `Option<u32>`
|
||||
- **summary**: Total extrinsics count for the current block.
|
||||
|
||||
▸ **extrinsicData**(`u32`): `Bytes`
|
||||
- **summary**: Extrinsics data for the current block (maps extrinsic's index to its data).
|
||||
|
||||
▸ **extrinsicsRoot**(): `Hash`
|
||||
- **summary**: Extrinsics root of the current block, also part of the block header.
|
||||
|
||||
▸ **number**(): `BlockNumber`
|
||||
- **summary**: The current block number being processed. Set by `execute_block`.
|
||||
|
||||
▸ **parentHash**(): `Hash`
|
||||
- **summary**: Hash of the previous block.
|
||||
|
||||
▸ **randomSeed**(): `Hash`
|
||||
- **summary**: Random seed of the current block.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### timestamp
|
||||
|
||||
▸ **blockPeriod**(): `Option<Moment>`
|
||||
- **summary**: Old storage item provided for compatibility. Remove after all networks upgraded.
|
||||
|
||||
▸ **didUpdate**(): `bool`
|
||||
- **summary**: Did the timestamp get updated in this block?
|
||||
|
||||
▸ **minimumPeriod**(): `Moment`
|
||||
- **summary**: 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.
|
||||
|
||||
▸ **now**(): `Moment`
|
||||
- **summary**: Current time for the current block.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### treasury
|
||||
|
||||
▸ **approvals**(): `Vec<ProposalIndex>`
|
||||
- **summary**: Proposal indices that have been approved but not yet awarded.
|
||||
|
||||
▸ **burn**(): `Permill`
|
||||
- **summary**: Percentage of spare funds (if any) that are burnt per spend period.
|
||||
|
||||
▸ **pot**(): `BalanceOf`
|
||||
- **summary**: Total funds available to this module for spending.
|
||||
|
||||
▸ **proposalBond**(): `Permill`
|
||||
- **summary**: Proportion of funds that should be bonded in order to place a proposal. An accepted proposal gets these back. A rejected proposal doesn't.
|
||||
|
||||
▸ **proposalBondMinimum**(): `BalanceOf`
|
||||
- **summary**: Minimum amount of funds that should be placed in a deposit for making a proposal.
|
||||
|
||||
▸ **proposalCount**(): `ProposalIndex`
|
||||
- **summary**: Number of proposals that have been made.
|
||||
|
||||
▸ **proposals**(`ProposalIndex`): `Option<TreasuryProposal>`
|
||||
- **summary**: Proposals that have been made.
|
||||
|
||||
▸ **spendPeriod**(): `BlockNumber`
|
||||
- **summary**: Period between successive spends.
|
||||
|
||||
---
|
||||
|
||||
### substrate
|
||||
|
||||
_These are keys that are always available to the runtime implementation_
|
||||
|
||||
▸ **authorityCount**(): `u32`
|
||||
- **summary**: Number of authorities.
|
||||
|
||||
▸ **authorityPrefix**(): `u32`
|
||||
- **summary**: Prefix under which authorities are stored.
|
||||
|
||||
▸ **changesTrieConfig**(): `u32`
|
||||
- **summary**: Changes trie configuration is stored under this key.
|
||||
|
||||
▸ **code**(): `Bytes`
|
||||
- **summary**: Wasm code of the runtime.
|
||||
|
||||
▸ **extrinsicIndex**(): `u32`
|
||||
- **summary**: Current extrinsic index (u32) is stored under this key.
|
||||
|
||||
▸ **heapPages**(): `u64`
|
||||
- **summary**: Number of wasm linear memory pages required for execution of the runtime.
|
||||
|
||||
---
|
||||
@@ -0,0 +1 @@
|
||||
yarn.lock
|
||||
@@ -0,0 +1,5 @@
|
||||
# Simple Connect
|
||||
|
||||
The following example shows how to instantiate a Plugnet API object and use it to connect to a node using ApiPromise.
|
||||
|
||||
<<< @/docs/examples/promise/01_simple_connect/index.js
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// @ts-check
|
||||
// Required imports
|
||||
const { ApiPromise, WsProvider } = require('@plugnet/api');
|
||||
|
||||
async function main () {
|
||||
// Initialise the provider to connect to the local node
|
||||
const provider = new WsProvider('ws://127.0.0.1:9944');
|
||||
|
||||
// Create the API and wait until ready
|
||||
const api = await ApiPromise.create(provider);
|
||||
|
||||
// Retrieve the chain & node information information via rpc calls
|
||||
const [chain, nodeName, nodeVersion] = await Promise.all([
|
||||
api.rpc.system.chain(),
|
||||
api.rpc.system.name(),
|
||||
api.rpc.system.version()
|
||||
]);
|
||||
|
||||
console.log(`You are connected to chain ${chain} using ${nodeName} v${nodeVersion}`);
|
||||
}
|
||||
|
||||
main().catch(console.error).finally(() => process.exit());
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "01_simple_connect",
|
||||
"version": "0.2.0",
|
||||
"description": "Example showing how to connect using a WebSocket",
|
||||
"main": "index.js",
|
||||
"author": "chevdor",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
|
||||
"dependencies": {
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
# Listen to new blocks
|
||||
This example shows how to subscribe to new blocks.
|
||||
|
||||
It displays the block number every time a new block is seen by the node you are connected to.
|
||||
|
||||
NOTE: The example runs until you stop it with CTRL+C
|
||||
|
||||
<<< @/docs/examples/promise/02_listen_to_blocks/index.js
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// @ts-check
|
||||
// Import the API
|
||||
const { ApiPromise } = require('@plugnet/api');
|
||||
|
||||
async function main () {
|
||||
// Here we don't pass the (optional) provider, connecting directly to the default
|
||||
// node/port, i.e. `ws://127.0.0.1:9944`. Await for the isReady promise to ensure
|
||||
// the API has connected to the node and completed the initialisation process
|
||||
const api = await ApiPromise.create();
|
||||
|
||||
// Subscribe to the new headers on-chain. The callback is fired when new headers
|
||||
// are found, the call itself returns a promise with a subscription that can be
|
||||
// used to unsubscribe from the newHead subscription
|
||||
const unsubscribe = await api.rpc.chain.subscribeNewHead((header) => {
|
||||
console.log(`Chain is at block: #${header.blockNumber}`);
|
||||
});
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "02_listen_to_blocks",
|
||||
"version": "0.2.0",
|
||||
"description": "Example showing how to use subscriptions",
|
||||
"main": "index.js",
|
||||
"author": "chevdor",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# Listen to balance changes
|
||||
|
||||
This example shows how to instantiate a Plugnet API object and use it to connect to a node and retrieve balance updates.
|
||||
|
||||
<<< @/docs/examples/promise/03_listen_to_balance_change/index.js
|
||||
@@ -0,0 +1,33 @@
|
||||
// @ts-check
|
||||
// Import the API
|
||||
const { ApiPromise } = require('@plugnet/api');
|
||||
|
||||
// Known account we want to use (available on dev chain, with funds)
|
||||
const Alice = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
|
||||
async function main () {
|
||||
// Create an await for the API
|
||||
const api = await ApiPromise.create();
|
||||
|
||||
// Retrieve the initial balance. Since the call has no callback, it is simply a promise
|
||||
// that resolves to the current on-chain value
|
||||
let previous = await api.query.balances.freeBalance(Alice);
|
||||
|
||||
console.log(`${Alice} has a balance of ${previous}`);
|
||||
console.log(`You may leave this example running and start example 06 or transfer any value to ${Alice}`);
|
||||
|
||||
// Here we subscribe to any balance changes and update the on-screen value
|
||||
api.query.balances.freeBalance(Alice, (current) => {
|
||||
// Calculate the delta
|
||||
const change = current.sub(previous);
|
||||
|
||||
// Only display positive value changes (Since we are pulling `previous` above already,
|
||||
// the initial balance change will also be zero)
|
||||
if (!change.isZero()) {
|
||||
previous = current;
|
||||
console.log(`New balance change of: ${change}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "03_listen_to_balance_change",
|
||||
"version": "0.2.0",
|
||||
"description": "Example showing how to subscribe to balance change",
|
||||
"main": "index.js",
|
||||
"author": "chevdor",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
# Unsubscribe from listening to updates
|
||||
|
||||
This example shows how to subscribe to and later unsubscribe from listening to block updates.
|
||||
|
||||
In this example we're calling the built-in unsubscribe() function after a timeOut of 20s to cleanup and unsubscribe from listening to updates.
|
||||
|
||||
<<< @/docs/examples/promise/04_unsubscribe/index.js
|
||||
@@ -0,0 +1,23 @@
|
||||
// @ts-check
|
||||
// Import the API
|
||||
const { ApiPromise } = require('@plugnet/api');
|
||||
|
||||
async function main () {
|
||||
|
||||
// Create a new instance of the api
|
||||
const api = await ApiPromise.create();
|
||||
|
||||
// Subscribe to chain updates and log the current block number on update.
|
||||
const unsubscribe = await api.rpc.chain.subscribeNewHead((header) => {
|
||||
console.log(`Chain is at block: #${header.blockNumber}`);
|
||||
});
|
||||
|
||||
// In this example we're calling the unsubscribe() function that is being
|
||||
// returned by the api call function after 20s.
|
||||
setTimeout(() => {
|
||||
unsubscribe();
|
||||
console.log('Unsubscribed')
|
||||
}, 20000);
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "04_unsubscribe",
|
||||
"version": "0.2.0",
|
||||
"description": "Example showing how to unsubscribe from a subscription",
|
||||
"main": "index.js",
|
||||
"author": "Stefie",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# Read storage
|
||||
|
||||
Many important variables are available through the storage API. This example shows how to call a few of those APIs.
|
||||
|
||||
<<< @/docs/examples/promise/05_read_storage/index.js
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
// @ts-check
|
||||
// Import the API
|
||||
const { ApiPromise } = require('@plugnet/api');
|
||||
|
||||
// Our address for Alice on the dev chain
|
||||
const Alice = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
|
||||
async function main () {
|
||||
// Create our API with a default connection to the local node
|
||||
const api = await ApiPromise.create();
|
||||
|
||||
// Make our basic chain state/storage queries, all in one go
|
||||
const [accountNonce, blockPeriod, validators] = await Promise.all([
|
||||
api.query.system.accountNonce(Alice),
|
||||
api.query.timestamp.blockPeriod(),
|
||||
api.query.session.validators()
|
||||
]);
|
||||
|
||||
console.log(`accountNonce(${Alice}) ${accountNonce}`);
|
||||
console.log(`blockPeriod ${blockPeriod.toNumber()} seconds`);
|
||||
|
||||
if (validators && validators.length > 0) {
|
||||
// Retrieve the balances for all validators
|
||||
const validatorBalances = await Promise.all(
|
||||
validators.map(authorityId =>
|
||||
api.query.balances.freeBalance(authorityId)
|
||||
)
|
||||
);
|
||||
|
||||
// Print out the authorityIds and balances of all validators
|
||||
console.log('validators', validators.map((authorityId, index) => ({
|
||||
address: authorityId.toString(),
|
||||
balance: validatorBalances[index].toString()
|
||||
})));
|
||||
}
|
||||
}
|
||||
|
||||
main().catch(console.error).finally(_ => process.exit());
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "05_read_storage",
|
||||
"version": "0.2.0",
|
||||
"description": "Example showing how to query storage",
|
||||
"main": "index.js",
|
||||
"author": "chevdor",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# Make a simple transfer
|
||||
|
||||
This sample shows how to create a transaction to make a transfer from one an account to another.
|
||||
|
||||
<<< @/docs/examples/promise/06_make_transfer/index.js
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// @ts-check
|
||||
// Import the API, Keyring and some utility functions
|
||||
const { ApiPromise } = require('@plugnet/api');
|
||||
const { Keyring } = require('@plugnet/keyring');
|
||||
|
||||
const BOB = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty';
|
||||
|
||||
async function main () {
|
||||
// Instantiate the API
|
||||
const api = await ApiPromise.create();
|
||||
|
||||
// Constuct the keying after the API (crypto has an async init)
|
||||
const keyring = new Keyring({ type: 'sr25519' });
|
||||
|
||||
// Add alice to our keyring with a hard-deived path (empty phrase, so uses dev)
|
||||
const alice = keyring.addFromUri('//Alice');
|
||||
|
||||
// Create a extrinsic, transferring 12345 units to Bob
|
||||
const transfer = api.tx.balances.transfer(BOB, 12345);
|
||||
|
||||
// Sign and send the transaction using our account
|
||||
const hash = await transfer.signAndSend(alice);
|
||||
|
||||
console.log('Transfer sent with hash', hash.toHex());
|
||||
}
|
||||
|
||||
main().catch(console.error).finally(() => process.exit());
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "06_make_transfer",
|
||||
"version": "0.2.0",
|
||||
"description": "Example showing how to make a transfer",
|
||||
"main": "index.js",
|
||||
"author": "chevdor",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# Traverse events
|
||||
|
||||
Query the system events and extract information from them. This example runs until exited via Ctrl-C
|
||||
|
||||
<<< @/docs/examples/promise/08_system_events/index.js
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
// @ts-check
|
||||
// Import the API
|
||||
const { ApiPromise } = require('@plugnet/api');
|
||||
|
||||
async function main () {
|
||||
// Create our API with a default connection to the local node
|
||||
const api = await ApiPromise.create();
|
||||
|
||||
// subscribe to system events via storage
|
||||
api.query.system.events((events) => {
|
||||
console.log(`\nReceived ${events.length} events:`);
|
||||
|
||||
// loop through the Vec<EventRecord>
|
||||
events.forEach((record) => {
|
||||
// extract the phase, event and the event types
|
||||
const { event, phase } = record;
|
||||
const types = event.typeDef;
|
||||
|
||||
// show what we are busy with
|
||||
console.log(`\t${event.section}:${event.method}:: (phase=${phase.toString()})`);
|
||||
console.log(`\t\t${event.meta.documentation.toString()}`);
|
||||
|
||||
// loop through each of the parameters, displaying the type and data
|
||||
event.data.forEach((data, index) => {
|
||||
console.log(`\t\t\t${types[index].type}: ${data.toString()}`);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(-1);
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "08_system_events",
|
||||
"version": "0.1.0",
|
||||
"description": "Example showing how to query and parse events",
|
||||
"main": "index.js",
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# Transfer events
|
||||
|
||||
Display the events that occur during a transfer by sending a value to a random account
|
||||
|
||||
<<< @/docs/examples/promise/09_transfer_events/index.js
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
// @ts-check
|
||||
// Import the API & Provider and some utility functions
|
||||
const { ApiPromise } = require('@plugnet/api');
|
||||
|
||||
// import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
|
||||
const testKeyring = require('@plugnet/keyring/testing');
|
||||
|
||||
// utility function for random values
|
||||
const { randomAsU8a } = require('@plugnet/util-crypto');
|
||||
|
||||
// some constants we are using in this sample
|
||||
const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
const AMOUNT = 10000;
|
||||
|
||||
async function main () {
|
||||
// Create the API and wait until ready
|
||||
const api = await ApiPromise.create();
|
||||
|
||||
// create an instance of our testing keyring
|
||||
// If you're using ES6 module imports instead of require, just change this line to:
|
||||
// const keyring = testKeyring();
|
||||
const keyring = testKeyring.default();
|
||||
|
||||
// get the nonce for the admin key
|
||||
const nonce = await api.query.system.accountNonce(ALICE);
|
||||
|
||||
// find the actual keypair in the keyring
|
||||
const alicePair = keyring.getPair(ALICE);
|
||||
|
||||
// create a new random recipient
|
||||
const recipient = keyring.addFromSeed(randomAsU8a(32)).address();
|
||||
|
||||
console.log('Sending', AMOUNT, 'from', alicePair.address(), 'to', recipient, 'with nonce', nonce.toString());
|
||||
|
||||
// Do the transfer and track the actual status
|
||||
api.tx.balances
|
||||
.transfer(recipient, AMOUNT)
|
||||
.sign(alicePair, { nonce })
|
||||
.send(({ events = [], status }) => {
|
||||
console.log('Transaction status:', status.type);
|
||||
|
||||
if (status.isFinalized) {
|
||||
console.log('Completed at block hash', status.asFinalized.toHex());
|
||||
console.log('Events:');
|
||||
|
||||
events.forEach(({ phase, event: { data, method, section } }) => {
|
||||
console.log('\t', phase.toString(), `: ${section}.${method}`, data.toString());
|
||||
});
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "09_transfer_events",
|
||||
"version": "0.1.0",
|
||||
"description": "Example showing how to transfer DOTs (with events)",
|
||||
"main": "index.js",
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# Chain upgrade
|
||||
|
||||
Performs a chain upgrade using the `sudo` module. This may brick your chain, so us it as an educational sample. (use `substrate --dev purge-chain` to remove DB and recover).
|
||||
|
||||
<<< @/docs/examples/promise/10_upgrade_chain/index.js
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
// @ts-check
|
||||
// Import the API & Provider and some utility functions
|
||||
const { ApiPromise, WsProvider } = require('@plugnet/api');
|
||||
|
||||
// import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
|
||||
const testKeyring = require('@plugnet/keyring/testing');
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
async function main () {
|
||||
// Initialise the provider to connect to the local node
|
||||
const provider = new WsProvider('ws://127.0.0.1:9944');
|
||||
|
||||
// Create the API and wait until ready (optional provider passed through)
|
||||
const api = await ApiPromise.create(provider);
|
||||
|
||||
// retrieve the upgrade key from the chain state
|
||||
const adminId = await api.query.sudo.key();
|
||||
|
||||
// find the actual keypair in the keyring (if this is an changed value, the key
|
||||
// needs to be added to the keyring before - this assumes we have defaults, i.e.
|
||||
// Alice as the key - and this already exists on the test keyring)
|
||||
const keyring = testKeyring.default();
|
||||
const adminPair = keyring.getPair(adminId.toString());
|
||||
|
||||
// retrieve the runtime to upgrade to
|
||||
const code = fs.readFileSync('./test.wasm').toString('hex');
|
||||
const proposal = api.tx.consensus.setCode(`0x${code}`);
|
||||
|
||||
console.log(`Upgrading from ${adminId}, ${code.length / 2} bytes`);
|
||||
|
||||
// preform the actual chain upgrade via the sudo module
|
||||
api.tx.sudo
|
||||
.sudo(proposal)
|
||||
.signAndSend(adminPair, ({ events = [], status }) => {
|
||||
console.log('Proposal status:', status.type);
|
||||
|
||||
if (status.isFinalized) {
|
||||
console.error('You have just upgraded your chain');
|
||||
|
||||
console.log('Completed at block hash', status.asFinalized.toHex());
|
||||
console.log('Events:');
|
||||
|
||||
events.forEach(({ phase, event: { data, method, section } }) => {
|
||||
console.log('\t', phase.toString(), `: ${section}.${method}`, data.toString());
|
||||
});
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(-1);
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "10_upgrade_chain",
|
||||
"version": "0.2.0",
|
||||
"description": "Example showing how to upgrade via upgradeKey",
|
||||
"main": "index.js",
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,26 @@
|
||||
# ApiPromise Examples
|
||||
|
||||
Here you will find a list of examples that takes you through the basics of connecting to a local node, retrieving data from the Node and chain and execute transactions on the chain. It uses the [[ApiPromise]] interface.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
For the following examples, you need a local node. It is usually convenient testing with:
|
||||
|
||||
```
|
||||
substrate --dev
|
||||
```
|
||||
|
||||
## Running the examples
|
||||
|
||||
From each folder, run `yarn` to install the required dependencies and then run `yarn start` to execute the example against the running node.
|
||||
|
||||
## Development accounts
|
||||
|
||||
Some of the examples use the following accounts:
|
||||
|
||||
- Alice: `5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaDtZ`
|
||||
- Bob: `5Gw3s7q4QLkSWwknsiPtjujPv3XM4Trxi5d4PgKMMk3gfGTE`
|
||||
|
||||
Those accounts are easy to add if you don't have/see them. The seed of Alice's account is `Alice␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣` and the seed of Bob is... well you guess...
|
||||
|
||||
NOTE: Note the spaces padding Alice's key up to 32 chars.
|
||||
@@ -0,0 +1,5 @@
|
||||
# Simple Connect
|
||||
|
||||
The following example shows how to instantiate a Plugnet API object and use it to connect to a node using ApiRx.
|
||||
|
||||
<<< @/docs/examples/rx/01_simple_connect/index.js
|
||||
@@ -0,0 +1,26 @@
|
||||
// Required imports
|
||||
const { zip } = require('rxjs');
|
||||
const { ApiRx } = require('@plugnet/api');
|
||||
const { WsProvider } = require('@plugnet/rpc-provider');
|
||||
|
||||
function main () {
|
||||
// Initialise the provider to connect to the local node
|
||||
const provider = new WsProvider('ws://127.0.0.1:9944');
|
||||
|
||||
// Create the API and wait until ready
|
||||
const api = await ApiRx.create(provider).toPromise();
|
||||
|
||||
// We're using RxJs 'zip()' combination operator to get the emitted values
|
||||
// of multiple observables as an array
|
||||
zip(
|
||||
api.rpc.system.chain(),
|
||||
api.rpc.system.name(),
|
||||
api.rpc.system.version()
|
||||
)
|
||||
// Then we subscribe to the result
|
||||
.subscribe(([chain, nodeName, nodeVersion]) => {
|
||||
console.log(`You are connected to chain ${chain} using ${nodeName} v${nodeVersion}`);
|
||||
});
|
||||
}
|
||||
|
||||
main().catch(console.error).finally(() => process.exit());
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "rx_01_simple_connect",
|
||||
"version": "0.2.0",
|
||||
"description": "Example showing how to connect using a WebSocket",
|
||||
"main": "index.js",
|
||||
"author": "Stefie",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
|
||||
"dependencies": {
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
# Listen to new blocks
|
||||
|
||||
This example shows how to subscribe to new blocks.
|
||||
|
||||
It displays the block number every time a new block is seen by the node you are connected to.
|
||||
|
||||
NOTE: The example runs until you stop it with CTRL+C
|
||||
|
||||
<<< @/docs/examples/rx/02_listen_to_blocks/index.js
|
||||
@@ -0,0 +1,19 @@
|
||||
// Import the API
|
||||
const { ApiRx } = require('@plugnet/api');
|
||||
const { switchMap } = require('rxjs/operators');
|
||||
|
||||
async function main () {
|
||||
// Here we don't pass the (optional) provider, connecting directly to the default
|
||||
// node/port, i.e. `ws://127.0.0.1:9944`. Await for the isReady promise to ensure
|
||||
// the API has connected to the node and completed the initialisation process
|
||||
new ApiRx().isReady
|
||||
.pipe(
|
||||
switchMap((api) =>
|
||||
api.rpc.chain.subscribeNewHead()
|
||||
))
|
||||
.subscribe((header) => {
|
||||
console.log(`Chain is at block: #${header.blockNumber}`);
|
||||
});
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "rx_02_listen_to_blocks",
|
||||
"version": "0.2.0",
|
||||
"description": "Example showing how to use subscriptions",
|
||||
"main": "index.js",
|
||||
"author": "Stefie",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# Listen to balance changes
|
||||
|
||||
This example shows how to instantiate a Plugnet API object and use it to connect to a node and retrieve balance updates.
|
||||
|
||||
<<< @/docs/examples/rx/03_listent_to_balance_change/index.js
|
||||
@@ -0,0 +1,38 @@
|
||||
// Import the API and operators from RxJs
|
||||
const { ApiRx } = require('@plugnet/api');
|
||||
const { pairwise, startWith } = require('rxjs/operators');
|
||||
|
||||
// Known account we want to use (available on dev chain, with funds)
|
||||
const Alice = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
|
||||
async function main () {
|
||||
// Create an await for the API
|
||||
const api = await ApiRx.create().toPromise();
|
||||
|
||||
// Here we subscribe to any balance changes and update the on-screen value.
|
||||
// We're using RxJs pairwise() operator to get the previous and current values as an array.
|
||||
api.query.balances.freeBalance(Alice)
|
||||
.pipe(
|
||||
// since pairwise only starts emitting values on the second emission, we prepend an
|
||||
// initial value with the startWith() operator to be able to also receive the first value
|
||||
startWith('first'),
|
||||
pairwise()
|
||||
)
|
||||
.subscribe((balance) => {
|
||||
if (balance[0] === 'first') {
|
||||
// Now we know that if the previous value emitted as balance[0] is `first`,
|
||||
// then balance[1] is the initial value of Alice account.
|
||||
console.log(`Alice ${Alice} has a balance of ${balance[1]}`);
|
||||
console.log('You may leave this example running and start the "Make a transfer" example or transfer any value to Alice address');
|
||||
return;
|
||||
}
|
||||
|
||||
const change = balance[1].sub(balance[0]);
|
||||
// Only display value changes
|
||||
if (!change.isZero()) {
|
||||
console.log(`New balance change of: ${change}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "rx_03_listen_to_balance_change",
|
||||
"version": "0.2.0",
|
||||
"description": "Example showing how to subscribe to balance change",
|
||||
"main": "index.js",
|
||||
"author": "Stefie",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
# Unsubscribe from listening to updates
|
||||
|
||||
This example shows how to subscribe to and later unsubscribe from listening to block updates.
|
||||
|
||||
In this example we're calling the built-in unsubscribe() function after a timeOut of 20s to cleanup and unsubscribe from listening to updates.
|
||||
|
||||
<<< @/docs/examples/rx/04_unsubscribe/index.js
|
||||
@@ -0,0 +1,25 @@
|
||||
// Import the API
|
||||
const { ApiRx } = require('@plugnet/api');
|
||||
const { switchMap } = require('rxjs/operators');
|
||||
|
||||
async function main () {
|
||||
// Create a new instance of the api
|
||||
// Subscribe to chain updates and log the current block number on update.
|
||||
const subscription = new ApiRx().isReady
|
||||
.pipe(
|
||||
switchMap((api) =>
|
||||
api.rpc.chain.subscribeNewHead()
|
||||
))
|
||||
.subscribe((header) => {
|
||||
console.log(`Chain is at block: #${header.blockNumber}`);
|
||||
});
|
||||
|
||||
// In this example we're calling the Overvables unsubscribe() //
|
||||
// function after 20s.
|
||||
setTimeout(() => {
|
||||
subscription.unsubscribe();
|
||||
console.log('Unsubscribed');
|
||||
}, 20000);
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "rx_04_unsubscribe",
|
||||
"version": "0.2.0",
|
||||
"description": "Example showing how to unsubscribe from a subscription",
|
||||
"main": "index.js",
|
||||
"author": "Stefie",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# Read storage
|
||||
|
||||
Many important variables are available through the storage API. This example shows how to call a few of those APIs.
|
||||
|
||||
<<< @/docs/examples/rx/05_read_storage/index.js
|
||||
@@ -0,0 +1,51 @@
|
||||
// Import the API
|
||||
const { ApiRx } = require('@plugnet/api');
|
||||
// Import dependencies from RxJs
|
||||
const { combineLatest, of } = require('rxjs');
|
||||
const { first, switchMap } = require('rxjs/operators');
|
||||
|
||||
// Our address for Alice on the dev chain
|
||||
const Alice = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
|
||||
function main () {
|
||||
// Create our API with a default connection to the local node
|
||||
new ApiRx(provider).isReady
|
||||
.pipe(
|
||||
// Here we ake our basic chain state/storage queries
|
||||
switchMap((api) => combineLatest(
|
||||
of(api),
|
||||
api.query.session.validators().pipe(first())
|
||||
)),
|
||||
switchMap(([api, validators]) => {
|
||||
// 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.balances.freeBalance(authorityId).pipe(first())))
|
||||
: of(null);
|
||||
|
||||
// We're combining the results together with the emitted value 'validators',
|
||||
// which we're turning back into an observable using of()
|
||||
return combineLatest(
|
||||
api.query.system.accountNonce(Alice).pipe(first()),
|
||||
api.query.timestamp.blockPeriod().pipe(first()),
|
||||
of(validators),
|
||||
balances
|
||||
);
|
||||
})
|
||||
)
|
||||
// Then we're subscribing to the emitted results
|
||||
.subscribe(([accountNonce, blockPeriod, validators, validatorBalances]) => {
|
||||
console.log(`accountNonce(${Alice}) ${accountNonce}`);
|
||||
console.log(`blockPeriod ${blockPeriod.toNumber()} seconds`);
|
||||
|
||||
if (validatorBalances) {
|
||||
// And lastly we print out the authorityIds and balances of all validators
|
||||
console.log('validators', validators.map((authorityId, index) => ({
|
||||
address: authorityId.toString(),
|
||||
balance: validatorBalances[index].toString()
|
||||
})));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
main().catch(console.error).finally(_ => process.exit());
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "rx_05_read_storage",
|
||||
"version": "0.2.0",
|
||||
"description": "Example showing how to query storage",
|
||||
"main": "index.js",
|
||||
"author": "Stefie",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# Make a simple transfer
|
||||
|
||||
This sample shows how to create a transaction to make a transfer from one an account to another.
|
||||
|
||||
<<< @/docs/examples/rx/06_make_transfer/index.js
|
||||
@@ -0,0 +1,33 @@
|
||||
// Import the API, Keyring and some utility functions
|
||||
const { ApiRx } = require('@plugnet/api');
|
||||
const { Keyring } = require('@plugnet/keyring');
|
||||
|
||||
const BOB = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty';
|
||||
|
||||
async function main () {
|
||||
// Instantiate the API
|
||||
const api = await ApiRx.create().toPromise();
|
||||
|
||||
// Create an instance of the keyring
|
||||
const keyring = new Keyring({ type: 's25519' });
|
||||
|
||||
// Add Alice to our keyring (with the known seed for the account)
|
||||
const alice = keyring.addFomUri('//Alice');
|
||||
|
||||
// Create a extrinsic, transferring 12345 units to Bob.
|
||||
api.tx.balances
|
||||
// create transfer
|
||||
.transfer(BOB, randomAmount)
|
||||
// Sign and send the transcation
|
||||
.signAndSend(alice)
|
||||
// Subscribe to the status updates of the transfer
|
||||
.subscribe(({ status }) => {
|
||||
if (status.isFinalized) {
|
||||
console.log(`Successful transfer of 12345 from Alice to Bob with hash ${status.asFinalized.toHex()}`);
|
||||
} else {
|
||||
console.log(`Staus of transfer: ${status.type}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
main().catch(console.error).finally(_ => process.exit());
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "rx_06_make_transfer",
|
||||
"version": "0.2.0",
|
||||
"description": "Example showing how to make a transfer",
|
||||
"main": "index.js",
|
||||
"author": "Stefie",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# Traverse events
|
||||
|
||||
Query the system events and extract information from them. This example runs until exited via Ctrl-C
|
||||
|
||||
<<< @/docs/examples/rx/08_system_events/index.js
|
||||
@@ -0,0 +1,37 @@
|
||||
// Import the API and selected RxJs operators
|
||||
const { switchMap } = require('rxjs/operators');
|
||||
const { ApiRx } = require('@plugnet/api');
|
||||
|
||||
async function main () {
|
||||
// Create our API with a default connection to the local node
|
||||
ApiRx.create()
|
||||
.pipe(
|
||||
switchMap((api) =>
|
||||
// subscribe to system events via storage
|
||||
api.query.system.events()
|
||||
))
|
||||
// Then we're subscribing to the emitted results
|
||||
.subscribe((events) => {
|
||||
console.log(`\nReceived ${events.length} events:`);
|
||||
// loop through the Vec<EventRecord>
|
||||
events.forEach((record) => {
|
||||
// extract the phase, event and the event types
|
||||
const { event, phase } = record;
|
||||
const types = event.typeDef;
|
||||
|
||||
// show what we are busy with
|
||||
console.log(`\t${event.section}:${event.method}:: (phase=${phase.toString()})`);
|
||||
console.log(`\t\t${event.meta.documentation.toString()}`);
|
||||
|
||||
// loop through each of the parameters, displaying the type and data
|
||||
event.data.forEach((data, index) => {
|
||||
console.log(`\t\t\t${types[index].type}: ${data.toString()}`);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
main().catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(-1);
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "rx_08_system_events",
|
||||
"version": "0.1.0",
|
||||
"description": "Example showing how to query and parse events",
|
||||
"main": "index.js",
|
||||
"author": "Stefie",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# Transfer events
|
||||
|
||||
Display the events that occur during a transfer by sending a value to a random account
|
||||
|
||||
<<< @/docs/examples/rx/09_transfer_events/index.js
|
||||
@@ -0,0 +1,55 @@
|
||||
// Import the API and some utility functions
|
||||
const { ApiRx } = require('@plugnet/api');
|
||||
|
||||
// import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
|
||||
const testKeyring = require('@plugnet/keyring/testing');
|
||||
|
||||
// utility function for random values
|
||||
const { randomAsU8a } = require('@plugnet/util-crypto');
|
||||
|
||||
// some constants we are using in this sample
|
||||
const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
const AMOUNT = 10000;
|
||||
|
||||
async function main () {
|
||||
// Create our API with a connection to the node
|
||||
const api = await ApiRx.create().toPromise();
|
||||
|
||||
// create an instance of our testign keyring
|
||||
// If you're using ES6 module imports instead of require, just change this line to:
|
||||
// const keyring = testKeyring();
|
||||
const keyring = testKeyring.default();
|
||||
|
||||
// find the actual keypair in the keyring
|
||||
const alicePair = keyring.getPair(ALICE);
|
||||
|
||||
// create a new random recipient
|
||||
const recipient = keyring.addFromSeed(randomAsU8a(32)).address();
|
||||
|
||||
console.log('Sending', AMOUNT, 'from', alicePair.address(), 'to', recipient);
|
||||
|
||||
// get the nonce for the admin key
|
||||
// Create a extrinsic, transferring 12345 units to Bob.
|
||||
api.tx.balances
|
||||
// Do the transfer
|
||||
.transfer(recipient, AMOUNT)
|
||||
// Sign and send it
|
||||
.signAndSend(alicePair)
|
||||
// And subscribe to the actual status
|
||||
.subscribe(({ events = [], status }) => {
|
||||
// Log transfer events
|
||||
console.log('Transfer status:', status.type);
|
||||
|
||||
// Log system events once the transfer is finalised
|
||||
if (status.isFinalized) {
|
||||
console.log('Completed at block hash', status.asFinalized.toHex());
|
||||
console.log('Events:');
|
||||
|
||||
events.forEach(({ phase, event: { data, method, section } }) => {
|
||||
console.log('\t', phase.toString(), `: ${section}.${method}`, data.toString());
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "rx_09_transfer_events",
|
||||
"version": "0.1.0",
|
||||
"description": "Example showing how to transfer DOTs (with events)",
|
||||
"main": "index.js",
|
||||
"author": "Stefie",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# Chain upgrade
|
||||
|
||||
Performs a chain upgrade using the `sudo` module. This may brick your chain, so us it as an educational sample. (use `substrate --dev purge-chain` to remove DB and recover).
|
||||
|
||||
<<< @/docs/examples/rx/10_upgrade_chain/index.js
|
||||
@@ -0,0 +1,58 @@
|
||||
// Import the API & Provider and some utility functions
|
||||
const { ApiRx, WsPovider } = require('@plugnet/api');
|
||||
// import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
|
||||
const testKeyring = require('@plugnet/keyring/testing');
|
||||
const fs = require('fs');
|
||||
|
||||
async function main () {
|
||||
// Initialise the provider to connect to the local node
|
||||
const provider = new WsProvider('ws://127.0.0.1:9944');
|
||||
|
||||
// Create the API and wait until ready (optional provider passed through)
|
||||
const api = await ApiRx.create(provider).toPromise();
|
||||
|
||||
// retrieve the upgrade key from the chain state
|
||||
const adminId = await api.query.sudo.key().toPromise();
|
||||
|
||||
// find the actual keypair in the keyring (if this is an changed value, the key
|
||||
// needs to be added to the keyring before - this assumes we have defaults, i.e.
|
||||
// Alice as the key - and this already exists on the test keyring)
|
||||
const keyring = testKeyring.default();
|
||||
const adminPair = keyring.getPair(adminId.toString());
|
||||
|
||||
// retrieve the runtime to upgrade to
|
||||
const code = fs.readFileSync('./test.wasm').toString('hex');
|
||||
const proposal = api.tx.consensus.setCode(`0x${code}`);
|
||||
|
||||
console.log(`Upgrading chain runtime from ${adminId}`);
|
||||
|
||||
api.tx.sudo
|
||||
// preform the actual chain upgrade via the sudo module
|
||||
.sudo(proposal)
|
||||
// sign and send the proposal
|
||||
.signAndSend(adminPair)
|
||||
// subscribe to overall result
|
||||
.subscribe(({ events = [], status }) => {
|
||||
// Log transfer events
|
||||
console.log('Proposal status:', status.type);
|
||||
|
||||
if (status.isFinalized) {
|
||||
console.error('You have just upgraded your chain');
|
||||
|
||||
console.log('Completed at block hash', status.asFinalized.toHex());
|
||||
console.log('Events:');
|
||||
|
||||
// Log system events once the chain update is finalised
|
||||
events.forEach(({ phase, event: { data, method, section } }) => {
|
||||
console.log('\t', phase.toString(), `: ${section}.${method}`, data.toString());
|
||||
});
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(-1);
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "rx_10_upgrade_chain",
|
||||
"version": "0.2.0",
|
||||
"description": "Example showing how to upgrade via upgradeKey",
|
||||
"main": "index.js",
|
||||
"author": "Stefie",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,26 @@
|
||||
# ApiRx Examples
|
||||
|
||||
Here you will find a list of examples that takes you through the basics of connecting to a local node, retrieving data from the Node and chain and execute transactions on the chain. It uses the [[ApiRx]] interface.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
For the following examples, you need a local node. It is usually convenient testing with:
|
||||
|
||||
```
|
||||
substrate --dev
|
||||
```
|
||||
|
||||
## Running the examples
|
||||
|
||||
From each folder, run `yarn` to install the required dependencies and then run `yarn start` to execute the example against the running node.
|
||||
|
||||
## Development accounts
|
||||
|
||||
Some of the examples use the following accounts:
|
||||
|
||||
- Alice: `5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaDtZ`
|
||||
- Bob: `5Gw3s7q4QLkSWwknsiPtjujPv3XM4Trxi5d4PgKMMk3gfGTE`
|
||||
|
||||
Those accounts are easy to add if you don't have/see them. The seed of Alice's account is `Alice␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣` and the seed of Bob is... well you guess...
|
||||
|
||||
NOTE: Note the spaces padding Alice's key up to 32 chars.
|
||||
@@ -1,12 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="initial-scale=0.5, maximum-scale=1">
|
||||
<meta http-equiv="refresh" content="0;URL='https://polkadot.js.org/docs/api/'" />
|
||||
<title>Redirecting to https://polkadot.js.org/docs/api/</title>
|
||||
</head>
|
||||
<body>
|
||||
Redirecting to <a href="https://polkadot.js.org/docs/api/">https://polkadot.js.org/docs/api/</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,16 +0,0 @@
|
||||
// Copyright 2017-2023 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import baseConfig from '@polkadot/dev/config/eslint';
|
||||
|
||||
export default [
|
||||
...baseConfig,
|
||||
{
|
||||
rules: {
|
||||
// add override for any (a metric ton of them, initial conversion)
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
// we generally use this in isFunction, not via calling
|
||||
'@typescript-eslint/unbound-method': 'off'
|
||||
}
|
||||
}
|
||||
];
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"imports": {
|
||||
"https://esm.sh/v90/@types/bn.js@~5.2/index.d.ts": "https://esm.sh/v90/@types/bn.js@5.1.0/index.d.ts"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
const config = require('@plugnet/dev/config/jest');
|
||||
|
||||
module.exports = Object.assign({}, config, {
|
||||
moduleNameMapper: {
|
||||
'@plugnet/api-derive(.*)$': '<rootDir>/packages/api-derive/src/$1',
|
||||
'@plugnet/api(.*)$': '<rootDir>/packages/api/src/$1',
|
||||
'@plugnet/rpc-(core|provider|rx)(.*)$': '<rootDir>/packages/rpc-$1/src/$2',
|
||||
'@plugnet/extrinsics(.*)$': '<rootDir>/packages/type-extrinsics/src/$1',
|
||||
'@plugnet/jsonrpc(.*)$': '<rootDir>/packages/type-jsonrpc/src/$1',
|
||||
'@plugnet/storage(.*)$': '<rootDir>/packages/type-storage/src/$1',
|
||||
'@plugnet/types(.*)$': '<rootDir>/packages/types/src/$1'
|
||||
},
|
||||
modulePathIgnorePatterns: [
|
||||
'<rootDir>/packages/api/build',
|
||||
'<rootDir>/packages/api-derive/build',
|
||||
'<rootDir>/packages/rpc-core/build',
|
||||
'<rootDir>/packages/rpc-provider/build',
|
||||
'<rootDir>/packages/rpc-rx/build',
|
||||
'<rootDir>/packages/type-extrinsics/build',
|
||||
'<rootDir>/packages/type-jsonrpc/build',
|
||||
'<rootDir>/packages/type-storage/build/',
|
||||
'<rootDir>/packages/types/build'
|
||||
]
|
||||
});
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"npmClient": "yarn",
|
||||
"useWorkspaces": true,
|
||||
"command": {
|
||||
"publish": {
|
||||
"allowBranch": "master"
|
||||
}
|
||||
},
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "0.78.103"
|
||||
}
|
||||
+22
-39
@@ -1,50 +1,33 @@
|
||||
{
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"engines": {
|
||||
"node": ">=18.14"
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api#readme",
|
||||
"license": "Apache-2.0",
|
||||
"packageManager": "yarn@3.2.0",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/polkadot-js/api.git"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "10.7.3",
|
||||
"versions": {
|
||||
"git": "10.7.3",
|
||||
"npm": "10.7.3"
|
||||
"engines": {
|
||||
"node": ">=10.13.0",
|
||||
"yarn": "^1.10.1"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
],
|
||||
"resolutions": {
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"typescript": "~3.4.5"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn build:interfaces && polkadot-dev-build-ts",
|
||||
"build:before": "polkadot-dev-copy-dir --cd packages/typegen scripts build",
|
||||
"build:interfaces": "node --loader @polkadot/dev-ts packages/typegen/scripts/polkadot-types-internal-interfaces.mjs",
|
||||
"build:metadata": "yarn build:interfaces && polkadot-dev-run-test packages/types/src/metadata/v14",
|
||||
"build:release": "polkadot-ci-ghact-build",
|
||||
"build:rollup": "polkadot-exec-rollup --config",
|
||||
"build:upgrades": "polkadot-dev-run-test upgrades/e2e",
|
||||
"chain:info": "polkadot-types-chain-info",
|
||||
"clean": "polkadot-dev-clean-build",
|
||||
"deno": "yarn polkadot-dev-deno-map && yarn build && deno check --import-map=import_map.json mod.ts",
|
||||
"lint": "polkadot-dev-run-lint",
|
||||
"postinstall": "polkadot-dev-yarn-only",
|
||||
"test": "polkadot-dev-run-test --env node ^e2e",
|
||||
"test:node": "polkadot-dev-run-test --env node ^e2e",
|
||||
"test:one": "polkadot-dev-run-test --env node"
|
||||
"build": "plugnet-dev-build-ts && yarn run build:methodsdoc",
|
||||
"build:htmldoc": "yarn clean && typedoc --theme default --out docs/html",
|
||||
"build:methodsdoc": "node packages/types/src/scripts/MetadataMdWrapper.js",
|
||||
"check": "yarn lint",
|
||||
"lint": "tslint --project . && tsc --noEmit --pretty",
|
||||
"clean": "plugnet-dev-clean-build",
|
||||
"postinstall": "plugnet-dev-yarn-only",
|
||||
"test": "jest --coverage"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/dev": "^0.75.10",
|
||||
"@polkadot/typegen": "workspace:packages/typegen",
|
||||
"@types/node": "^20.2.5"
|
||||
},
|
||||
"resolutions": {
|
||||
"typescript": "^5.0.4"
|
||||
"@babel/core": "^7.4.4",
|
||||
"@babel/register": "^7.4.4",
|
||||
"@babel/runtime": "^7.4.4",
|
||||
"@plugnet/dev": "^0.30.4",
|
||||
"@polkadot/ts": "^0.1.56",
|
||||
"gh-pages": "^2.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
# @polkadot/api-augment
|
||||
|
||||
Generated augmentation.
|
||||
@@ -1,32 +0,0 @@
|
||||
{
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"description": "API generated augmentation",
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-augment#readme",
|
||||
"license": "Apache-2.0",
|
||||
"name": "@polkadot/api-augment",
|
||||
"repository": {
|
||||
"directory": "packages/api-augment",
|
||||
"type": "git",
|
||||
"url": "https://github.com/polkadot-js/api.git"
|
||||
},
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "10.7.3",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@polkadot/api-base": "10.7.3",
|
||||
"@polkadot/rpc-augment": "10.7.3",
|
||||
"@polkadot/types": "10.7.3",
|
||||
"@polkadot/types-augment": "10.7.3",
|
||||
"@polkadot/types-codec": "10.7.3",
|
||||
"@polkadot/util": "^12.2.1",
|
||||
"tslib": "^2.5.2"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
// Copyright 2017-2023 @polkadot/api-augment authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// for the API, we decorate not only the endpoints, but all types
|
||||
import '@polkadot/rpc-augment';
|
||||
import '@polkadot/types-augment';
|
||||
@@ -1,6 +0,0 @@
|
||||
// Copyright 2017-2023 @polkadot/api-augment authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './substrate/index.js';
|
||||
|
||||
export { packageInfo } from './packageInfo.js';
|
||||
@@ -1,8 +0,0 @@
|
||||
// Copyright 2017-2023 @polkadot/api-augment authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { packageInfo as baseInfo } from '@polkadot/api-base/packageInfo';
|
||||
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||
import { packageInfo as codecInfo } from '@polkadot/types-codec/packageInfo';
|
||||
|
||||
export default [baseInfo, typesInfo, codecInfo];
|
||||
@@ -1,11 +0,0 @@
|
||||
// Copyright 2017-2023 @polkadot/api-augment authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import others from './detectOther.js';
|
||||
import { packageInfo } from './packageInfo.js';
|
||||
|
||||
detectPackage(packageInfo, null, others);
|
||||
@@ -1,6 +0,0 @@
|
||||
// Copyright 2017-2023 @polkadot/api-augment authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './detectPackage.js';
|
||||
|
||||
export * from './bundle.js';
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user