Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
05a62ad89e | ||
|
|
3cd81fc691 | ||
|
|
ef805165d8 | ||
|
|
591253ff31 | ||
|
|
548cfbefb8 | ||
|
|
1827c34b69 | ||
|
|
e4400f0a26 | ||
|
|
8de8e3511c | ||
|
|
018c63b641 | ||
|
|
249c120e42 | ||
|
|
51ed24bf5e | ||
|
|
7b9fa97788 | ||
|
|
195469892e | ||
|
|
1ce536008d | ||
|
|
e8624244ea | ||
|
|
773b8654eb | ||
|
|
069fddee64 | ||
|
|
fb9c900d17 | ||
|
|
57adf72347 | ||
|
|
a304e0d35d | ||
|
|
61b49acb51 | ||
|
|
62e7fe8623 | ||
|
|
3cce0902de | ||
|
|
e61f1634ab | ||
|
|
572c0905b8 | ||
|
|
10d0215e69 | ||
|
|
27c63b709f | ||
|
|
5968647a05 | ||
|
|
022b938f00 | ||
|
|
f9318fe013 | ||
|
|
0aefc24bc2 | ||
|
|
f50922dd38 | ||
|
|
53ab0127cd | ||
|
|
a487bda3bd | ||
|
|
47cc0647d5 | ||
|
|
1bf40ceeab | ||
|
|
e16a4652e6 | ||
|
|
b5d5084b55 | ||
|
|
3b92be5284 | ||
|
|
2699dcfc9c | ||
|
|
194077033a | ||
|
|
0e5906473b | ||
|
|
f070b637f7 | ||
|
|
7c8ec1f7f5 | ||
|
|
a0a741d886 | ||
|
|
9f1499f435 | ||
|
|
4c925d9d4b | ||
|
|
fca5fb7110 | ||
|
|
bbc474432e | ||
|
|
2630f378a4 | ||
|
|
e0994f3c5a | ||
|
|
a0b1205258 | ||
|
|
fbbe7625b1 | ||
|
|
b573531ebf | ||
|
|
67de525077 | ||
|
|
f55732af51 | ||
|
|
5b6a6d4431 | ||
|
|
1857d8d521 | ||
|
|
afcc7fb701 | ||
|
|
be617df21f | ||
|
|
abc11890f7 | ||
|
|
5728e45261 | ||
|
|
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 |
@@ -1,9 +0,0 @@
|
||||
exclude_patterns:
|
||||
- "**/*.spec.js"
|
||||
- "**/*.spec.ts"
|
||||
- "**/*.test.js"
|
||||
- "**/*.test.ts"
|
||||
- "docs/**/*.js"
|
||||
- "packages/api/src/query.types.ts"
|
||||
- "packages/types/src/interfaces/"
|
||||
- "packages/types/src/scripts/"
|
||||
@@ -1,3 +0,0 @@
|
||||
**/build/*
|
||||
**/coverage/*
|
||||
**/node_modules/*
|
||||
@@ -1,18 +0,0 @@
|
||||
const base = require('@polkadot/dev/config/eslint');
|
||||
|
||||
module.exports = {
|
||||
...base,
|
||||
parserOptions: {
|
||||
...base.parserOptions,
|
||||
project: [
|
||||
'./tsconfig.json'
|
||||
]
|
||||
},
|
||||
rules: {
|
||||
...base.rules,
|
||||
// add override for any (a metric ton of them, initial conversion)
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
// these should be removed, there are 8 of them as errors
|
||||
'@typescript-eslint/no-non-null-assertion': 'off'
|
||||
}
|
||||
};
|
||||
@@ -1,71 +0,0 @@
|
||||
name: PR
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: Linting
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [12.x]
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: lint
|
||||
run: |
|
||||
yarn install --frozen-lockfile
|
||||
yarn lint
|
||||
|
||||
test:
|
||||
name: Testing
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [12.x]
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: test
|
||||
run: |
|
||||
yarn install --frozen-lockfile
|
||||
yarn test
|
||||
|
||||
build_code:
|
||||
name: Build Code
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [12.x]
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: build
|
||||
run: |
|
||||
yarn install --frozen-lockfile
|
||||
yarn build
|
||||
|
||||
build_docs:
|
||||
name: Build Docs
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [12.x]
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: build
|
||||
run: |
|
||||
yarn install --frozen-lockfile
|
||||
yarn docs
|
||||
@@ -1,53 +0,0 @@
|
||||
name: Master
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build_code:
|
||||
name: Build Code
|
||||
if: "! contains(github.event.head_commit.message, '[CI Skip]')"
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [12.x]
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: build
|
||||
env:
|
||||
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
||||
GH_PAT: ${{ secrets.GH_PAT }}
|
||||
GH_TOKEN: ${{ secrets.GH_PAT }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
yarn install --frozen-lockfile
|
||||
CI_NO_BETA=true yarn polkadot-dev-ghact-build
|
||||
|
||||
build_docs:
|
||||
name: Build Docs
|
||||
if: "! contains(github.event.head_commit.message, '[CI Skip]')"
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [12.x]
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: build
|
||||
env:
|
||||
GH_PAT: ${{ secrets.GH_PAT }}
|
||||
GH_TOKEN: ${{ secrets.GH_PAT }}
|
||||
GH_PAGES_SRC: build-docs
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
yarn install --frozen-lockfile
|
||||
yarn polkadot-dev-ghact-docs
|
||||
@@ -11,7 +11,6 @@ tmp/
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.npmrc
|
||||
.rpt2_cache
|
||||
cc-test-reporter
|
||||
lerna-debug.log*
|
||||
npm-debug.log*
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "10"
|
||||
cache:
|
||||
yarn: true
|
||||
directories:
|
||||
- node_modules
|
||||
before_install:
|
||||
- curl -o- -L https://yarnpkg.com/install.sh | bash
|
||||
- export PATH=$HOME/.yarn/bin::$(yarn global bin):$(yarn global dir):$PATH
|
||||
- yarn global add @plugnet/dev
|
||||
script:
|
||||
- plugnet-dev-travis-build
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
+12
-149
@@ -1,114 +1,3 @@
|
||||
# 0.95.1
|
||||
|
||||
- Support Extrinsic V4 with additional signature indicator (Latest Polkadot/Substrate/Kusama)
|
||||
- Adjust subscription update checks to avoid duplicated data updates
|
||||
- Support Metadata V8 (exposes per-module `decl_error` definitions)
|
||||
- Support next generation contracts ABI (with additional type definitions)
|
||||
- Support for `BTreeMap<K, V>` types and definitions
|
||||
- All latest Polkadot & Substrate types (as per master branches)
|
||||
- **Breaking change** `Call.injectMethods` is moved to `Call.injectMetadata` to align with `Events` (This _should_ not be used externally, however mentioned as breaking here)
|
||||
|
||||
# 0.94.1
|
||||
|
||||
- Add handling of `Result<Ok, Error>` definitions
|
||||
- Adjust API cloning now takes RPC filters from source into account
|
||||
- Simplification of isPedantic checks and less overhead on StorageData types
|
||||
- Cleanups and fixes around RPC and derive type definitions
|
||||
- Fix `derive.imOnline.receivedHeatbeats` to query via indexes
|
||||
- Adjustment of `api.derive.elections.{approvalsOf|approvalsOfAt}` to allow ss58 address input
|
||||
- Cleanup `Enum` `.eq` handling to be more exhaustive
|
||||
- Add documentation for custom extrinsic formats (advanced chains)
|
||||
- Update to latest substrate master metadata
|
||||
|
||||
# 0.93.1
|
||||
|
||||
- Support for Kusama CC2
|
||||
- In extrinsic submission, use `rpc.account.nextIndex` to retrieve the nonce when available
|
||||
- For TypeScript users `api.query.*.*` is now properly typed for default Substrate calls, i.e. `api.query.balances.freeBalance(...)` will return a `Balance` type. Additionally the `api.queryMulti` and `.multi` on queries not allow generic type params.
|
||||
- Add `api.rpc.accounts.nextIndex`, `api.rpc.contracts.call` and `api.rpc.rpc.methods` calls. Optional calls (such as account/contracts) is decorated based on the results from `rpc.methods`, so they don't show up on nodes where they are not active.
|
||||
- Updated types to support the latest Polkadot/Substrate master changes
|
||||
- Support recursive type registration (self-referencing via `Box`) in addition to better sanitation of user-defined-types
|
||||
- Documentation and example updates (thanks mostly to contributions)
|
||||
|
||||
# 0.92.1
|
||||
|
||||
- The API now correctly sets the ss58 prefix as retrieved from the chain properties via `ss58Format`
|
||||
- Bump to `@polkadot/util` 1.4.1, removing use of `ExtError`
|
||||
- The `Keyring` from `@polkadot/keyring` is now exposed on the API as well. You can do `import { Keyring } from '@polkadot/api'` - this alleviates the need for extra dependencies (apart from `@polkadot/api`), and since the keyring is critical for signing operations, aligns everything in one bundle
|
||||
- Support the latest Polkadot & Substrate master branches (incl. metadata updates)
|
||||
- Getting started documentation has been made available
|
||||
|
||||
# 0.91.1
|
||||
|
||||
- This release was focussed on stability, with a number of cleanups and bug-fixes
|
||||
- Adjustments for Substrate 1.x chain detection (with auto-types) and Substrate 2.x support has been extended with all latest types
|
||||
- The `getRuntimeVersion` and `subscribeRuntimeVersion` RPCs are now only available on the `rpc.state.*` endpoints. This aligns with the Substrate implementation.
|
||||
- The `author_insertKey` RPC's last argument `publicKey` is now required, as to reflect Substrate implementation.
|
||||
- Support for extrinsics with versions that is not in the base Substrate implementation (V1-V3) can now be done by providing an implementation for `ExtrinsicUnknown`
|
||||
- Redeemed balance calculation if `api.derive` now returns the correct values again (bug fix)
|
||||
- added the `yarn chain:info [--ws URL]` utility to extract a calls-only metadata version
|
||||
- Missing types are now logged via a `console.warn`, not via `.error`
|
||||
- `Extrinsic`, `ExtrinsicPayload` & `SignerPayload` is registered in the type registry and can be overriden now
|
||||
- **Breaking change** `SignerPayload` is renamed to `SignerPayloadJSON`
|
||||
- **Breaking change** `SignerPayloadJSON`, `SignerPayloadRawBase` and `SignerPayloadRaw` are all moved to `@polkadot/types`
|
||||
|
||||
# 0.90.1
|
||||
|
||||
If you are upgrading form an older version, use the CHANGELOG hand-in-hand with the [migration guide](UPGRADING.md).
|
||||
|
||||
- **Breaking change** `api.rpc.chain.subscribeNewHeads` is now available as opposed to the old `subscribeNewHead`. This aligns with the Substrate implementation.
|
||||
- **Breaking change** Substrate 2.x & Polkadot master has moved both `BlockNumber` & `Index` to `u32`. The API tracks these closely. If you are running a chain with `u64` values (for either), pass the type override to the API on creation, e.g. `ApiPromise.create({ types: { BlockNumber: 'u64', Index: 'u64' } })` to avoid getting warnings about mismatched types.
|
||||
- **Breaking change** `Api.create(...)` and `new Api(...)` now only takes an options Object, so if you passed the provider directly previously, you need to swap the use to `Api.create({ provider: ... })`
|
||||
- **Breaking change** Runtime types have been extended and moved to definitions instead of classes
|
||||
- Primitive types for `i*` and `u*` (e.g. `u32`) are now only available in their lowercase versions. Additionally `Vector` is now only available as `Vec`, and `Method` has been renamed to `Call`, in both cases aligning with Rust.
|
||||
- `Moment` now implements as `u64` as per the Substrate codebase. (It it up to the user to interpret, for substrate 2.x it is not ms resolution)
|
||||
- For creation of types, it is recommended to use `createType(<TypeName>, <value>)` instead of e.g. `new Proposal(...)`. When passing these to methods/queries, construction should not be needed, the raw value can be passed.
|
||||
- For moved types, a previous import would have been from `@polkadot/types`, i.e. `import { SetIndex } from '@polkadot/types`, now just the interfaces (TypeScript) are available via `import { SetIndex } from '@polkadot/types/interfaces`
|
||||
- `usize` is now a blacklisted type that will throw on construction. Since it is platform-specific, it creates incompatibilities between native (generally `u64`) and WASM (always `u32`) code. Use one of the `u32` or `u64` types explicitly.
|
||||
- Support substrate v7 metadata
|
||||
- The `Method.findFunction(callIndex)` (allowing decoding of raw data), is now available on `api.findCall(callIndex)`. To keep backwards compatibility, it is still available on `GenericCall.findMethod` but the `api.findCall` is recommended and suggested.
|
||||
- The `types/codec/createType` has been moved to `types/codec/create` with the same exports. If you explicitly imported from here (and not doing the suggested `import { createType } from '@polkadot/types`), the reference needs to be updated
|
||||
|
||||
|
||||
# 0.82.0-beta.x
|
||||
|
||||
- Support for substrate 2.x (master) has been extended,
|
||||
- Additional types have been addedd for the modules
|
||||
- `api.derive.contract` is now `api.derive.contracts` to align with the substrate 2.x rename. (Feture detection is used so it supports both 1.x and 2.x chains)
|
||||
- Addition of `api.derive.elections`
|
||||
|
||||
- Support latest substrate 2 v6 metadata with module constants using `api.consts`.
|
||||
- The api now uses the module name for the storage methods, aligning module names for consistency with transactions. The methods of the grandpa module moved from `api.query.grandpaFinality` to `api.query.grandpa`.
|
||||
- Internally the `@polkadot/extrinsics` and `@polkadot/storage` have been moved to `@polkadot/api-metadata` and are now accessible as `@polkadot/api-metadata/extrinsics` and `@polkadot/api-metadata/storage`, respectively.
|
||||
- **Breaking Change** Vote interface extends U8a instead of i8. Vote properties can be accessed via the `isAye`, `isNay`, and `conviction` getters. Votes can still be constructed as before with a raw JS boolean, a SCALE encoded Boolean, an i8 number, or a JS object with properties `aye` and `conviction` defined.
|
||||
|
||||
- Support V2 Extrinsics in addition to V1, v2 includes an optional `tip`
|
||||
- In addition to this support, the `Signer` interface has deprecated the `sign` method and replaced it with `signPayload`
|
||||
- Support for the `sign` interfaces (API detection and calling when `signPayload` is not available) will be removed in subsequent versions.
|
||||
|
||||
- The `ContractsAbi` type has been moved from `@polkadot/types` to `import { Abi } from '@polkadot/api-contract`. This paves the way for an enhanced contracts interface, instead of dealing with low-level API calls.
|
||||
|
||||
|
||||
# 0.81.1
|
||||
|
||||
- The dependency on `@polkadot/keyring` has been removed - if you relied on the API to provide this, you would now need to manually add it
|
||||
- `createType` allows for the creation of `[u8; <length>]` types (opening the door for contract support)
|
||||
- `api.derive.staking.info` now returns the `rewardDestination`
|
||||
- Fix for disconnection when default providers (non-specified) are used
|
||||
- Don't console.log type decoding errors and then throw, only re-throw with additional info
|
||||
- Support latest substrate 2.x v5 metadata
|
||||
- Add `ApprovalFlag`, `SetIndex`, `VoterInfo` types for council as per substrate
|
||||
- Update `ContractInfo` to match substrate master
|
||||
|
||||
- Add support for new inherent digests from substrate.
|
||||
- **Breaking change** Because of the new `Seal`, the old/new Seals are not compatible. If you were using the old `Seal` from the `Digest`s, you would now use `isSealV0` for the pre-substrate 1.0 version and the new `isSeal` for the current version
|
||||
- Update `HeaderExtended` to retrieve author information from substrate 2.x (new `PreRuntime` digests)
|
||||
|
||||
- Cater for `Vec`, `Option`, `Result`, tuples and fixed vectors for contracts ABIs
|
||||
- Additional examples for subscriptions using multi
|
||||
- Add `off` method to `Api` (Base, for both `ApiPromise` & `ApiRx`) to remove an event listener
|
||||
|
||||
|
||||
# 0.80.1
|
||||
|
||||
- Support for mortal transactions
|
||||
@@ -118,19 +7,18 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
|
||||
- Updated metadata for current substrate master
|
||||
- Misc. cleanups and fixes
|
||||
|
||||
|
||||
# 0.79.1
|
||||
|
||||
- DoubleMap query support
|
||||
- Support for mortal transactions via Era
|
||||
- Support latest EventRecord metadata (substrate master)
|
||||
- Introduce RuntimeVersion type overrides in api/nodeCompat.ts
|
||||
- Add `api.queryMulti` and `api.query.<module>.<method>.multi`
|
||||
- Convert `api.derive.*` to use multi queries
|
||||
- `types/codec/Set` now extends the base JS `Set` (**breaking change**: `set.values` -> `set.strings`)
|
||||
- `types/codec/Set` now extends the base JS `Set` (breaking: `set.values` -> `set.strings`)
|
||||
- Breaking: rename `meta.arguments` to `meta.args` in function metadata (`arguments` is a JS reserved word)
|
||||
- Add `toRawType` on all type classes (breakdown into primitive types)
|
||||
|
||||
|
||||
# 0.78.1
|
||||
|
||||
- Fix linked-maps (not working since 0.77.1)
|
||||
@@ -141,12 +29,10 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
|
||||
- Do type assertion on all exposed asXXX getters
|
||||
- Metadata updates for substrate (WithdrawReasons, ContractInfo)
|
||||
|
||||
|
||||
# 0.77.1
|
||||
|
||||
- Support Metadata v4, which introduces the use of a custom hasher to hash storage map keys.
|
||||
- Add TreasuryProposal (not the same as democracy, type aliased)
|
||||
|
||||
- Add TresuryProposal (not the same as democracy, type aliassed)
|
||||
|
||||
# 0.76.1
|
||||
|
||||
@@ -155,22 +41,17 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
|
||||
- Update @polkadot/keyring to enable Alice's stash account on dev chains
|
||||
- Update @polkadot/util-crypto with smaller footprint
|
||||
|
||||
|
||||
# 0.75.1
|
||||
|
||||
- Start journey to 1.0
|
||||
|
||||
|
||||
# 0.53.1
|
||||
|
||||
- Change spelling to US English as per substrate master (1.0-rc1). Breaking changes as a result:
|
||||
- For extrinsic status results, if you have checked the type returns, i.e. `result.type === 'Finalised'` now check on the status for `result.status.isFinalized` or `result.status.isBroadcast`, ... (the `type` property is now accessible only on `result.status.type`)
|
||||
- If using `subscribeFinalisedHeads` update this to `subscribeFinalizedHeads` (likewise `getFinalisedHead` should be updated to `getFinalizedHead` and `derive.bestNumberFinalized`)
|
||||
|
||||
- The underlying ss58 address checksums have changed
|
||||
- The updated keyring with support for this has been made available
|
||||
- All examples have been updated with sr25519 addresses (with the new checksums)
|
||||
|
||||
- The underlying ss58 addess checksums have changed in the keyring along with the latest specs
|
||||
- All examples have been updated with sr25519 addresses (with the new checksums)
|
||||
|
||||
# 0.52.1
|
||||
|
||||
@@ -181,42 +62,35 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
|
||||
- Allow parsing of V3 metadata with DoubleMap support
|
||||
- Check for single instances for api and types as they are loaded (assertSingletonPackage)
|
||||
|
||||
|
||||
# 0.51.1
|
||||
|
||||
- Support metadata V2 as per latest substrate master
|
||||
- Update metadata with new types as per latest substrate master
|
||||
|
||||
- Update metadata with new types as per lastest substrate master
|
||||
|
||||
# 0.50.1
|
||||
|
||||
- Latest util-crypto (usage of WASM with JS fallbacks if not available)
|
||||
- Lastest util-crypto (usage of WASM with JS fallbacks if not available)
|
||||
- Update upstream @polkadot dependencies (for new crypto)
|
||||
|
||||
|
||||
# 0.49.1
|
||||
|
||||
- Fix large message signing on non-known nodes (default is now hashing, there has been enough time between upgrades)
|
||||
|
||||
|
||||
# 0.48.1
|
||||
|
||||
- Pull in new sr25519 capable keyring for dev nodes
|
||||
- When using dev mode, it assumes that the node is the latest with derived sr25519 keys
|
||||
|
||||
|
||||
# 0.47.1
|
||||
|
||||
- Swap to publishing -beta.x on merge (non-breaking testing)
|
||||
|
||||
|
||||
# 0.46.1
|
||||
|
||||
- Extended type registration to now handle internal types as well. Additionally the built-in Extrinsic type can now we overridden with a custom version.
|
||||
- Where `Extrinsic` and `Method` is used as types, consider importing `{ IMethod, IExtrinsic }` from `@polkadot/types/types`, especially in the cases where this is used from a `SubmittableExtrinsic`
|
||||
- Where `Extrinsic` and `Method` is used as types, considder importing `{ IMethod, IExtrinsic }` from `@polkadot/types/types`, especially in the cases where this is uased from a `SubmittableExtrinsic`
|
||||
- The `typeRegistry` constant is now `getTypeRegistry()` as a function
|
||||
|
||||
|
||||
# 0.45.1
|
||||
|
||||
- Storage with option values now correctly return `Option<Type>` and is indicated as such in the documentation
|
||||
@@ -233,10 +107,9 @@ const llo = await api.query.session.lastLengthChange();
|
||||
console.log('llo', llo.unwrapOr('not set') /* Option<BlockNumber> */)
|
||||
```
|
||||
|
||||
|
||||
# 0.44.1
|
||||
|
||||
- Split primitives and types into separate folders. This should not affect external use since the exports remain the same, however does have an impact where classes are referenced directly. e.g.
|
||||
- Split primitives and types into seperate folders. This should not affect external use since the exports remain the same, however does have an impact where classes are referenced directly. e.g.
|
||||
|
||||
```js
|
||||
// old (affected)
|
||||
@@ -251,45 +124,37 @@ import Signature from '@polkadot/types/type/Signature';
|
||||
import { Method, Signature } from '@polkadot/types';
|
||||
```
|
||||
|
||||
|
||||
# 0.43.1
|
||||
|
||||
- Introduces support for the new keyring with sr25519 support in addition to ed25519. While this does not change the exposed API, it is considered breaking since @polkadot/keyring has interface changes. (Unless needed, don't rush the upgrade)
|
||||
|
||||
- Intrduces support for the new keyring with sr25519 support in addition to ed25519. While this does not change the exposed API, it is considerred breaking since @polkadot/keuyring has interface changes. (Unless needed, don't rush the upgrade)
|
||||
|
||||
# 0.42.1
|
||||
|
||||
- Support for substrate hash signing with implVersion >= 18
|
||||
- Changed signatures for Extrinsic signing, this should not have (much) of an impact since it is generally not used directly. SubmittableExtrinsic (as exposed by the API), supports the old-style use.
|
||||
|
||||
|
||||
# 0.41.1
|
||||
|
||||
- Support the V1 metadata specification from Substrate in addition to the currently testnet active V0 version
|
||||
|
||||
- Support the V1 metadata specification from Substrate in addition to the currently testnet-active V0 version
|
||||
|
||||
# 0.40.1
|
||||
|
||||
- The API interfaces now require a WS-compatible provider, e.g. subscription support is a must. Previously the HTTPProvider could be use (although it was very limited in the interactions).
|
||||
|
||||
|
||||
# 0.39.1
|
||||
|
||||
- The Promise API now returns a `Promise<UnsubFunction>` instead of `UnsubFunction` when making subscriptions.
|
||||
|
||||
|
||||
# 0.38.1
|
||||
|
||||
Substrate has been updated with a breaking new transaction format where the Index/Nonce is now encoded as a Compact. This change is being rolled out to both Alexander (Polkadot testnet) as well as Charred Cherry (Substrate testnet) - transactions between old and new are not compatible.
|
||||
|
||||
|
||||
# 0.37.1
|
||||
|
||||
api-observable has been removed. This was only used in /apps and inconsistent with the api/rx and api/promise APIs. Future work will include derives like was included in api-observable into the base.
|
||||
api-observable has been removed. This was only used in /apps and inconsistent with the api/rx and api/promise APIs. Future work will include derivates like was included in api-observable into the base.
|
||||
|
||||
Tuples now return single types when only one type is available, i.e. `(AccountId)` would now resolve as `AccountId`. The extra type wrapper adds no benefit to users here.
|
||||
|
||||
|
||||
# 0.36.1
|
||||
|
||||
Api Promise has been updated in the way we deal with subscriptions. Previously a subscription returned `Promise<number>` where the caller was to keep track of the id and use it in subsequent unsubscribes. Now any subscriptions return an unsubscribe/destroy function `(): void`, that is use for removing the subscriptions, e.g.
|
||||
@@ -300,12 +165,10 @@ const unsubscribe = api.query.balance.freeBalance(Alice, (balance) => {...});
|
||||
unsubscribe(); // here we destroy the subscription
|
||||
```
|
||||
|
||||
|
||||
# 0.35.1
|
||||
|
||||
Swapped to new metadata structures from Substrate. If the API is not working with your node, update Substrate to latest master branch. (Or 0.9.1 for Charred Cherry). Dropped support for old metadata as found as far back as BBQ Birch.
|
||||
|
||||
|
||||
# 0.34.1
|
||||
|
||||
Changed the send signature (for future expansion of eg. events) to return `result: { status: ExtrinsicStatus }` instead of `status: ExtrinsicStatus`. For most cases where only status `type` checks are used, i.e. `status.type === 'Finalised'` this should not be a breaking change. Deep inspection of the status object however will need to adapt.
|
||||
|
||||
@@ -1,44 +1,39 @@
|
||||
[](https://polkadot.js.org)
|
||||

|
||||
[](https://www.npmjs.com/package/@polkadot/api)
|
||||
[](https://www.npmjs.com/package/@polkadot/api)
|
||||
[](https://codeclimate.com/github/polkadot-js/api)
|
||||
[](https://codeclimate.com/github/polkadot-js/api)
|
||||
# @plugnet/api
|
||||
|
||||
# @polkadot/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_
|
||||
|
||||
This library provides a clean wrapper around all the methods exposed by a Polkadot/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://polkadot.js.org/api/).
|
||||
|
||||
If you are an existing user, please be sure to track the [CHANGELOG](CHANGELOG.md) and [UPGRADING](UPGRADING.md) guides 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/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 -
|
||||
|
||||
- [@polkadot/api](packages/api/) The API library, providing both Promise and RxJS Observable-based interfaces. This is the main user-facing entry point.
|
||||
- [@polkadot/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.*`)
|
||||
- [@polkadot/api-metadata](packages/api-metadata/) Base extrinsic, storage and constant injectors for injection
|
||||
- [@polkadot/rpc-core](packages/rpc-core/) Wrapper around all [JSON-RPC methods](https://polkadot.js.org/api/substrate/rpc.html) exposed by a Polkadot network client
|
||||
- [@polkadot/rpc-provider](packages/rpc-provider/) Providers for connecting to nodes, including WebSockets and Http
|
||||
- [@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 Polkadot & Substrate clients -
|
||||
Type definitions for interfaces as exposed by Plugnet & Substrate clients -
|
||||
|
||||
- [@polkadot/jsonrpc](packages/type-jsonrpc/) Definitions for JSONRPC endpoints
|
||||
- [@polkadot/types](packages/types/) Codecs for all Polkadot and Substrate primitives
|
||||
- [@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 [@polkadot](https://github.com/polkadot-js/) 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 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/polkadot-js/api <optional local path>`
|
||||
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`
|
||||
|
||||
-117
@@ -1,117 +0,0 @@
|
||||
# Upgrade guide
|
||||
|
||||
This is an upgrade guide for users of the API. It does not attempt to detail each version (the [CHANGELOG](CHANGELOG.md) has all the changes between versions), but rather tries to explain the rationale behind major breaking changes and how users of the API should handle this.
|
||||
|
||||
While we try to keep the user-facing interfaces as stable as possible, sometimes you just need to make additions to move forward and improve things down the road, as painful as they may be. Like you, we are also users of the API, and eat our own dogfood - and as such, feel any pains introduced first.
|
||||
|
||||
## 0.90.1 (and newer), from 0.81.1 (and older)
|
||||
|
||||
The 0.90.1 release caters for the [Kusama network](https://kusama.network/) and pulls in all the changes to support [Substrate 2.x](https://github.com/paritytech/substrate), all while maintaining backwards compatibility to allow operation on networks such as [Polkadot's Alexander](https://polkadot.network/).
|
||||
|
||||
To support the network and the new transaction formats, a number of changes were made to how extrinsics are handled and signed. In addition, as support for ongoing work where type definitions are to be supplied by the actual node metadata, the foundation has been laid to move to type definitions as opposed to classes for runtime types.
|
||||
|
||||
### Modules
|
||||
|
||||
The first thing to be aware of is breakages when connecting to any new network, here older networks such as Alex are unaffected - the node metadata defines exactly what is available to the chain, so endpoints that worked yesterday still works today.
|
||||
|
||||
There will no doubt be breakages in using calls to now non-existent endpoints (as populated by the metadata) if you are upgrading your nodes to Substrate 2.x. Substrate 2.x has had a number of internal changes, where new modules and features are introduced (such as `babe` and `technicalCommittee`), some modules have been renamed (such as `contract` -> `contracts`) and modules such as `session` has been reworked to a large degree.
|
||||
|
||||
To cater for both 1.x and 2.x support, the [@polkadot/api-derive](packages/api-derive) endpoints, do feature detection for the node type and should continue working as-is. Additionally, a number of new derives have been added, specifically around elections.
|
||||
|
||||
### Type renames
|
||||
|
||||
To better align with the actual types from the metadata, and avoid (too much) context switching, some types from the `@polkadot/types` have been renamed. These include -
|
||||
|
||||
- `Vector` -> `Vec`
|
||||
- `U{8|16|32|64|128|256}` have been removed, only the lowercase version of these remain, i.e. `u32`.
|
||||
|
||||
### Type usage
|
||||
|
||||
The [@polkadot/api](packages/api) has always handled the conversion of types for parameters when making calls or queries. For example, when making a transfer to `BOB` (address), any of the following is valid -
|
||||
|
||||
- `api.tx.balances.transfer(BOB, 12345)` - value specied as a number
|
||||
- `api.tx.balances.transfer(BOB, '12345')` - value specied as a string
|
||||
- `api.tx.balances.transfer(BOB, '0x3039')` - value specied as a hex
|
||||
- `api.tx.balances.transfer(BOB, new BN(12345))` - value specied as a [BN](https://github.com/indutny/bn.js/)
|
||||
|
||||
Internally the API will take the input and convert the value into a `Balance`, serialize it using the SCALE codec and transfer it to the node. In some cases users would construct the `Balance` type manually, by importing the class and calling `new` on it. This last approach has now been removed, and where classes are still available (limited reach), discouraged.
|
||||
|
||||
First the rationale behind this - in all cases Substrate is very flexible, so while Polkadot (and the Substrate base), define `type Balance = u128`, this can be different between chains. (This also applies to the majority of built-in supported types). As such, type construction should be done via the actual registered types.
|
||||
|
||||
```js
|
||||
// this is applicable everywhere, import the type creator, using the registry
|
||||
import { createType } from '@polkadot/types';
|
||||
|
||||
// construct the Balance, of type Balance (type is inferred and available with TS)
|
||||
const value = createType('Balance', 12345);
|
||||
|
||||
// use value here as you normally would
|
||||
...
|
||||
```
|
||||
|
||||
The impact of this will be noticeable, if you have been importing the old-style type classes from `@polkadot/types`, those imports are not available anymore. For creation, just pass everything through the `createType`.
|
||||
|
||||
If a TypeScript user, you can find the updated type (it is a type definition only, not a class), under `@polkadot/types/interfaces`. To do type casting, using interfaces -
|
||||
|
||||
```js
|
||||
// import the TypeScript runtime interfaces we wish to use
|
||||
import { Balance, Hash } from '@polkadot/types/interfaces';
|
||||
|
||||
// import the primitives we wish to use
|
||||
import { createType, Compact, Vec, u32 } from '@polkadot/types';
|
||||
|
||||
// define an interface we want to use inside our code
|
||||
interface MyProps {
|
||||
balance: Compact<Balance>;
|
||||
changes: Vec<Hash>;
|
||||
counter?: u32;
|
||||
}
|
||||
|
||||
// assign something to this structure
|
||||
const props = {
|
||||
balance: createType('Compact<Balance>', 12345),
|
||||
changes: createType('Vec<Hash>', []) // empty for now
|
||||
};
|
||||
```
|
||||
|
||||
### Type definitions
|
||||
|
||||
One of the major pain points in working with a custom Substrate node is the definition of types to cater for chains. There are 2 approaches: defining types via a JSON format or extending your own classes in TypeScript (or JS) and injecting these. For the latter category, there are some impacts in the way you define these.
|
||||
|
||||
If using JSON definitions, nothing changes, your types are still defined as -
|
||||
|
||||
```json
|
||||
{
|
||||
"MyStruct": {
|
||||
"balance": "Compact<Balance>",
|
||||
"values": "Vec<AccountId>",
|
||||
"counter": "u32"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
For the definition of any structures using the Substrate specific types as classes, some adjustments are needed. Since the base modules types are now not available in classes, however it is needed for definitions, the following approach is encouraged -
|
||||
|
||||
```js
|
||||
// import the ClassOf, it works the same as `createType` (along with type detection)
|
||||
// and acts as a replacement for the direct import and use of specific classes
|
||||
import { ClassOf, Struct, u32 } from '@polkadot/types';
|
||||
|
||||
export class MyStruct extends Struct {
|
||||
constructor (value?: any) {
|
||||
super({
|
||||
balance: ClassOf('Compact<Balance>'),
|
||||
values: ClassOf('Vec<AccountId>'),
|
||||
counter: u32
|
||||
}, value);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Internally the [@polkadot/types](packages/types) package now only defines classes where there are specific encoding logic applied. For all other types, the definitions are done via a JSON-like format and then the TypeScript definitions are generated from these. (In a world where nodes inject types and the type definitions are not needed, this functionality will be useful to allow TS devs to auto-generate type definitions based on what the node defines.)
|
||||
|
||||
### Signing transactions (Signer interface)
|
||||
|
||||
For users of the API signer interfaces (such as extensions and mobile signers), the interfaces have undergone some changes to cater for the extrinsic v2 format as defined by Substrate. If you are only supporting current chains (e.g. Alexander), no changes are required, however the old `sign` interface does not support chains such as Kusama, so all users are encouraged to upgrade to the new `signPayload` interface.
|
||||
|
||||
This has already been implemented in both the [polkadot-js extension](https://github.com/polkadot-js/extension/blob/5f22f67d558655c605eb6f6beecef6826ed6c159/packages/extension/src/page/Signer.ts#L16v) as well as the [simple single signer](https://github.com/polkadot-js/api/blob/d56905d1b566be6f17eb570ac01448378fc91b67/packages/api/test/util/SingleAccountSigner.ts#L37).
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
module.exports = {
|
||||
extends: '@polkadot/dev/config/babel'
|
||||
extends: '@plugnet/dev/config/babel'
|
||||
};
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
function copy_folder () {
|
||||
SRC="packages/$1/build"
|
||||
DST="../apps/node_modules/@polkadot/$2"
|
||||
|
||||
echo "** Copying $SRC to $DST"
|
||||
|
||||
rm -rf $DST
|
||||
cp -r $SRC $DST
|
||||
}
|
||||
|
||||
yarn polkadot-dev-build-ts
|
||||
|
||||
copy_folder "api" "api"
|
||||
copy_folder "api-contract" "api-contract"
|
||||
copy_folder "api-derive" "api-derive"
|
||||
copy_folder "api-metadata" "api-metadata"
|
||||
copy_folder "rpc-core" "rpc-core"
|
||||
copy_folder "rpc-provider" "rpc-provider"
|
||||
copy_folder "type-jsonrpc" "jsonrpc"
|
||||
copy_folder "types" "types"
|
||||
@@ -1,102 +0,0 @@
|
||||
# Docker compose file to run Polkadot-JS API e2e test files on supported versions of Polkadot and Substrate
|
||||
#
|
||||
# Setup:
|
||||
# Builds 5 containers with different supported versions of Substrate and Polkadot.
|
||||
# Runs Polkadot-JS API Tests
|
||||
#
|
||||
# Before you can run this script, you need to install Docker and 'Docker Compose' on your machine.
|
||||
# Please follow the steps described here (including the prerequisites): https://docs.docker.com/compose/install/
|
||||
#
|
||||
# Usage:
|
||||
# 1. BUILD: Run `docker-compose pull && docker-compose up -d` to pull the latest docker imaged and run docker-compose in detached mode. This will run the substrate and polkadot containers in the background.
|
||||
# 2. INFO: Run `docker ps` to get a list of Docker containers running in the background including their mapped ports on localhost
|
||||
# 3. TEST: Run `docker-compose logs -f js-api-tests` to run the API tests and print the logs
|
||||
# 4. QUIT: Run `docker-compose down` to stop and remove all running containers.
|
||||
#
|
||||
# Provided Endpoints for localhost:
|
||||
# - Substrate Master: ws://127.0.0.1:9945/
|
||||
# - Substrate 1.0: ws://127.0.0.1:9946/
|
||||
# - Substrate 2.0: ws://127.0.0.1:9947/
|
||||
# - Polkadot Master: ws://127.0.0.1:9948/
|
||||
# - Polkadot Alexander: ws://127.0.0.1:9949/
|
||||
#
|
||||
# Find more Docker images of Substrate https://hub.docker.com/r/parity/substrate/tags
|
||||
# Find more Docker images of Polkadot https://hub.docker.com/r/parity/polkadot/tags
|
||||
|
||||
|
||||
version: "3.7"
|
||||
services:
|
||||
substrate-master:
|
||||
image: parity/substrate:latest
|
||||
ports:
|
||||
- "9945:9944"
|
||||
- "9935:9933"
|
||||
networks:
|
||||
- internet
|
||||
command:
|
||||
- "--dev"
|
||||
- "--ws-external"
|
||||
- "--rpc-external"
|
||||
|
||||
substrate-1.0:
|
||||
image: parity/substrate:v1.0.0
|
||||
ports:
|
||||
- "9946:9944"
|
||||
- "9936:9933"
|
||||
networks:
|
||||
- internet
|
||||
command:
|
||||
- "--dev"
|
||||
- "--ws-external"
|
||||
- "--rpc-external"
|
||||
|
||||
substrate-2.0:
|
||||
image: parity/substrate:2.0.0-b65c315a1
|
||||
ports:
|
||||
- "9947:9944"
|
||||
- "9937:9933"
|
||||
networks:
|
||||
- internet
|
||||
command:
|
||||
- "--dev"
|
||||
- "--ws-external"
|
||||
- "--rpc-external"
|
||||
|
||||
polkadot-master:
|
||||
image: parity/polkadot:latest
|
||||
ports:
|
||||
- "9948:9944"
|
||||
- "9938:9933"
|
||||
networks:
|
||||
- internet
|
||||
command:
|
||||
- "--dev"
|
||||
- "--ws-external"
|
||||
- "--rpc-external"
|
||||
|
||||
polkadot-alexander:
|
||||
image: parity/polkadot:v0.4.4
|
||||
ports:
|
||||
- "9949:9944"
|
||||
- "9939:9933"
|
||||
networks:
|
||||
- internet
|
||||
command:
|
||||
- "--dev"
|
||||
- "--ws-external"
|
||||
- "--rpc-external"
|
||||
|
||||
# This is the container running the API tests
|
||||
js-api-tests:
|
||||
image: node:11
|
||||
volumes:
|
||||
- ./:/polkadot-js/api
|
||||
working_dir: /polkadot-js/api
|
||||
network_mode: host
|
||||
tty: true
|
||||
environment:
|
||||
- TERM=xterm-256color`
|
||||
command: bash -c "NODE_ENV=abc /usr/local/bin/yarn && /usr/local/bin/yarn test:all"
|
||||
|
||||
networks:
|
||||
internet:
|
||||
@@ -1,85 +0,0 @@
|
||||
module.exports = {
|
||||
base: '/api/',
|
||||
title: 'polkadot-js/api',
|
||||
description: 'API libraries and interfaces for communicating with Polkadot and Substrate nodes',
|
||||
markdown: {
|
||||
lineNumbers: true
|
||||
},
|
||||
themeConfig: {
|
||||
displayAllHeaders: true,
|
||||
nav: [
|
||||
{ text: 'Polkadot/Substrate Apps', link: 'https://polkadot.js.org/apps/' },
|
||||
{ text: 'Project family', link: 'https://polkadot.js.org/' },
|
||||
{
|
||||
text: 'Documentation',
|
||||
items: [
|
||||
{ text: 'API Reference (this)', link: 'https://polkadot.js.org/api/' },
|
||||
{ text: 'Utility Reference', link: 'https://polkadot.js.org/common/' },
|
||||
{ text: 'UI Libs Reference', link: 'https://polkadot.js.org/ui/' },
|
||||
]
|
||||
},
|
||||
{ text: 'GitHub', link: 'https://github.com/polkadot-js/api' }
|
||||
],
|
||||
search: false,
|
||||
sidebar: [
|
||||
{
|
||||
title: 'Getting started',
|
||||
path: '/start/',
|
||||
collapsable: false,
|
||||
sidebarDepth: 0,
|
||||
children: [
|
||||
['start/install.md', 'Installation'],
|
||||
['start/basics.md', 'Basics & Metadata'],
|
||||
['start/create.md', 'Creating an instance'],
|
||||
['start/api.consts.md', 'Runtime Constants'],
|
||||
['start/api.query.md', 'State queries'],
|
||||
['start/api.rpc.md', 'RPC calls'],
|
||||
['start/api.query.subs.md', 'Query subscriptions'],
|
||||
['start/api.query.multi.md', 'Multi queries'],
|
||||
['start/api.query.other.md', 'Query extras'],
|
||||
['start/api.tx.md', 'Transactions'],
|
||||
['start/keyring.md', 'Keyring'],
|
||||
['start/api.tx.subs.md', 'Transaction subscriptions'],
|
||||
['start/api.tx.wrap.md', 'Complex transactions'],
|
||||
['start/types.basics.md', 'Type basics'],
|
||||
['start/types.extend.md', 'Extending types'],
|
||||
['start/extrinsic.extend.md', 'Extending extrinsics'],
|
||||
['start/typescript.md', 'TypeScript interfaces'],
|
||||
['start/FAQ.md', 'FAQ']
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'Examples (Promise API)',
|
||||
path: '/examples/promise/',
|
||||
collapsable: false,
|
||||
sidebarDepth: 0,
|
||||
children: [
|
||||
['examples/promise/01_simple_connect/', 'Simple connect'],
|
||||
['examples/promise/02_listen_to_blocks/', 'Listen to blocks'],
|
||||
['examples/promise/03_listen_to_balance_change/', 'Listen to balance change'],
|
||||
['examples/promise/04_unsubscribe/', 'Unsubscribe from listening'],
|
||||
['examples/promise/05_read_storage/', 'Read chain state'],
|
||||
['examples/promise/06_make_transfer/', 'Make a transfer'],
|
||||
['examples/promise/08_system_events/', 'Display system events'],
|
||||
['examples/promise/09_transfer_events/', 'Transaction with events'],
|
||||
['examples/promise/10_upgrade_chain/', 'Upgrade via sudo']
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'Substrate defaults',
|
||||
collapsable: false,
|
||||
sidebarDepth: 0,
|
||||
children: [
|
||||
['substrate/rpc.md', 'Substrate RPC'],
|
||||
['substrate/constants.md', 'Constants'],
|
||||
['substrate/storage.md', 'State storage'],
|
||||
['substrate/extrinsics.md', 'Extrinsics'],
|
||||
['substrate/events.md', 'System events']
|
||||
]
|
||||
},
|
||||
['/api/', '@polkadot/api'],
|
||||
['/types/', '@polkadot/types'],
|
||||
'/CONTRIBUTING.md'
|
||||
]
|
||||
}
|
||||
};
|
||||
@@ -1,9 +0,0 @@
|
||||
$accentColor = #fd8824
|
||||
$textColor = #2c3e50
|
||||
|
||||
.home .hero .description,
|
||||
.home .feature h2,
|
||||
.home .feature p {
|
||||
color: $textColor
|
||||
opacity: 0.75
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
## 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.
|
||||
|
||||
▸ **Contract**(`AccountId`, `Bytes`)
|
||||
- **summary**: An event from contract of account.
|
||||
|
||||
▸ **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 its nominators) has been slashed by the given amount.
|
||||
|
||||
▸ **OfflineWarning**(`AccountId`, `u32`)
|
||||
- **summary**: One validator (and its nominators) has been given an offline-warning (it is still within its 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,310 @@
|
||||
## 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)**
|
||||
|
||||
- **[](#)**
|
||||
|
||||
- **[grandpaFinality](#grandpaFinality)**
|
||||
|
||||
- **[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 that the previous block's validator missed its 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.
|
||||
|
||||
▸ **claimSurcharge**(dest: `AccountId`, aux_sender: `Option<AccountId>`)
|
||||
- **summary**: Allows block producers to claim a small reward for evicting a contract. If a block producer fails to do so, a regular users will be allowed to claim the reward. If contract is not evicted as a result of this call, no actions are taken and the sender is not eligible for the reward.
|
||||
|
||||
▸ **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 chain's storage and returns its `codehash`. You can instantiate contracts only with stored code.
|
||||
|
||||
▸ **restoreTo**(dest: `AccountId`, code_hash: `CodeHash`, rent_allowance: `BalanceOf`, delta: `Vec<ContractStorageKey>`)
|
||||
- **summary**: Allows a contract to restore a tombstone by giving its storage. The contract that wants to restore (i.e. origin of the call, or `msg.sender` in Solidity terms) will compute a tombstone with its storage and the given code_hash. If the computed tombstone match the destination one, the destination contract is restored with the rent_allowance` specified, while the origin sends all its funds to the destination and is removed.
|
||||
|
||||
▸ **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
|
||||
|
||||
▸ **proxySetApprovals**(votes: `Vec<bool>`, index: `Compact<VoteIndex>`)
|
||||
- **summary**: Set candidate approvals from a proxy. Approval slots stay valid as long as candidates in those slots are registered.
|
||||
|
||||
▸ **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.
|
||||
|
||||
▸ **proxyVote**(ref_index: `Compact<ReferendumIndex>`, vote: `Vote`)
|
||||
- **summary**: Vote in a referendum on behalf of a stash. If `vote.is_aye()`, the vote is to enact the proposal; otherwise it is a vote to keep the status quo.
|
||||
|
||||
▸ **removeProxy**(proxy: `AccountId`)
|
||||
- **summary**: Clear the proxy. Called by the stash.
|
||||
|
||||
▸ **resignProxy**()
|
||||
- **summary**: Clear the proxy. Called by the proxy.
|
||||
|
||||
▸ **second**(proposal: `Compact<PropIndex>`)
|
||||
- **summary**: Propose a sensitive action to be taken.
|
||||
|
||||
▸ **setProxy**(proxy: `AccountId`)
|
||||
- **summary**: Specify a proxy. Called by the stash.
|
||||
|
||||
▸ **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.
|
||||
|
||||
___
|
||||
|
||||
|
||||
###
|
||||
|
||||
▸ **finalHint**(hint: `Compact<BlockNumber>`)
|
||||
- **summary**: Hint that the author of this block thinks the best finalized block is the given number.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### grandpaFinality
|
||||
|
||||
▸ **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 a validator (function caller) 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_ by the stash account.
|
||||
|
||||
▸ **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`)
|
||||
- **summary**: Authenticates the current sudo key and sets the given AccountId (`new`) as the new sudo key. The dispatch origin for this call must be _Signed_.
|
||||
|
||||
▸ **sudo**(proposal: `Proposal`)
|
||||
- **summary**: Authenticates the sudo key and dispatches a function call with `Root` origin. The dispatch origin for this call must be _Signed_.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### 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.
|
||||
@@ -1,17 +1,10 @@
|
||||
## 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.
|
||||
|
||||
- **[account](#account)**
|
||||
|
||||
_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)**
|
||||
|
||||
- **[contracts](#contracts)**
|
||||
|
||||
- **[rpc](#rpc)**
|
||||
|
||||
- **[state](#state)**
|
||||
|
||||
- **[system](#system)**
|
||||
@@ -20,34 +13,15 @@ The following sections contain RPC methods that are Remote Calls available by de
|
||||
___
|
||||
|
||||
|
||||
### account
|
||||
|
||||
_(Optional) Methods that retrieves account-specific information_
|
||||
|
||||
▸ **nextIndex**(accountId: `AccountId`): `Index`
|
||||
- **summary**: Retrieves the next accountIndex as available on the node
|
||||
|
||||
___
|
||||
|
||||
|
||||
### author
|
||||
|
||||
_Authoring of network items_
|
||||
|
||||
▸ **insertKey**(keyType: `Text`, suri: `Text`, publicKey: `Bytes`): `Bytes`
|
||||
- **summary**: Insert a key into the keystore.
|
||||
|
||||
▸ **pendingExtrinsics**(): `Vec<Extrinsic>`
|
||||
▸ **pendingExtrinsics**(): `PendingExtrinsics`
|
||||
- **summary**: Returns all pending extrinsics, potentially grouped by sender
|
||||
|
||||
▸ **removeExtrinsic**(bytesOrHash: `Vec<ExtrinsicOrHash>`): `Vec<Hash>`
|
||||
- **summary**: Remove given extrinsic from the pool and temporarily ban it to prevent reimporting
|
||||
|
||||
▸ **rotateKeys**(): `Bytes`
|
||||
- **summary**: Generate new session keys and returns the corresponding public keys
|
||||
|
||||
▸ **submitAndWatchExtrinsic**(extrinsic: `Extrinsic`): `ExtrinsicStatus`
|
||||
- **summary**: Submit and subscribe to watch an extrinsic until unsubscribed
|
||||
- **summary**: Subscribe and watch an extrinsic until unsubscribed
|
||||
|
||||
▸ **submitExtrinsic**(extrinsic: `Extrinsic`): `Hash`
|
||||
- **summary**: Submit a fully formatted extrinsic for block inclusion
|
||||
@@ -71,31 +45,17 @@ _Retrieval of chain data_
|
||||
▸ **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
|
||||
|
||||
▸ **subscribeNewHeads**(): `Header`
|
||||
▸ **subscribeNewHead**(): `Header`
|
||||
- **summary**: Retrieves the best header via subscription
|
||||
|
||||
___
|
||||
|
||||
|
||||
### contracts
|
||||
|
||||
_(Optional) Methods that performs actions on contracts_
|
||||
|
||||
▸ **call**(callRequest: `ContractCallRequest`, at?: `Hash`): `ContractExecResult`
|
||||
- **summary**: Executes a call to a contract
|
||||
|
||||
___
|
||||
|
||||
|
||||
### rpc
|
||||
|
||||
_Retrieves information about the RPC endpoints_
|
||||
|
||||
▸ **methods**(): `RpcMethods`
|
||||
- **summary**: Retrieves the list of RPC methods that are exposed by the node
|
||||
▸ **subscribeRuntimeVersion**(): `RuntimeVersion`
|
||||
- **summary**: Retrieves the runtime version via subscription
|
||||
|
||||
___
|
||||
|
||||
@@ -107,21 +67,6 @@ _Query of state_
|
||||
▸ **call**(method: `Text`, data: `Bytes`, block?: `Hash`): `Bytes`
|
||||
- **summary**: Perform a call to a builtin on the chain
|
||||
|
||||
▸ **getChildKeys**(childStorageKey: `StorageKey`, key: `StorageKey`, block?: `Hash`): `Vec<StorageKey>`
|
||||
- **summary**: Retrieves the keys with prefix of a specific child storage
|
||||
|
||||
▸ **getChildStorage**(childStorageKey: `StorageKey`, key: `StorageKey`, block?: `Hash`): `StorageData`
|
||||
- **summary**: Retrieves the child storage for a key
|
||||
|
||||
▸ **getChildStorageHash**(childStorageKey: `StorageKey`, key: `StorageKey`, block?: `Hash`): `Hash`
|
||||
- **summary**: Retrieves the child storage hash
|
||||
|
||||
▸ **getChildStorageSize**(childStorageKey: `StorageKey`, key: `StorageKey`, block?: `Hash`): `u64`
|
||||
- **summary**: Retrieves the child storage size
|
||||
|
||||
▸ **getKeys**(key: `StorageKey`, block?: `Hash`): `Vec<StorageKey>`
|
||||
- **summary**: Retrieves the keys with a certain prefix
|
||||
|
||||
▸ **getMetadata**(block?: `Hash`): `Metadata`
|
||||
- **summary**: Returns the runtime metadata
|
||||
|
||||
@@ -140,9 +85,6 @@ _Query of state_
|
||||
▸ **queryStorage**(keys: `Vec<StorageKey>`, startBlock: `Hash`, block?: `Hash`): `Vec<StorageChangeSet>`
|
||||
- **summary**: Query historical storage entries (by key) starting from a start block
|
||||
|
||||
▸ **subscribeRuntimeVersion**(): `RuntimeVersion`
|
||||
- **summary**: Retrieves the runtime version via subscription
|
||||
|
||||
▸ **subscribeStorage**(keys: `Vec<StorageKey>`): `StorageChangeSet`
|
||||
- **summary**: Subscribes to storage changes for the provided keys
|
||||
|
||||
@@ -151,7 +93,7 @@ ___
|
||||
|
||||
### system
|
||||
|
||||
_Calls to retrieve system info_
|
||||
_Methods to retrieve system info_
|
||||
|
||||
▸ **chain**(): `Text`
|
||||
- **summary**: Retrieves the chain
|
||||
@@ -0,0 +1,554 @@
|
||||
## 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.
|
||||
|
||||
▸ **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.
|
||||
|
||||
▸ **codeStorage**(`CodeHash`): `Option<PrefabWasmModule>`
|
||||
- **summary**: A mapping between an original code hash and instrumented wasm code, ready for execution.
|
||||
|
||||
▸ **contractFee**(): `BalanceOf`
|
||||
- **summary**: The fee required to create a contract instance.
|
||||
|
||||
▸ **contractInfoOf**(`AccountId`): `Option<ContractInfo>`
|
||||
- **summary**: The code associated with a given account.
|
||||
|
||||
▸ **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.
|
||||
|
||||
▸ **rentByteFee**(): `BalanceOf`
|
||||
- **summary**: Price of a byte of storage per one block interval. Should be greater than 0.
|
||||
|
||||
▸ **rentDepositOffset**(): `BalanceOf`
|
||||
- **summary**: The amount of funds a contract should deposit in order to offset the cost of one byte. Let's suppose the deposit is 1,000 BU (balance units)/byte and the rent is 1 BU/byte/day, then a contract with 1,000,000 BU that uses 1,000 bytes of storage would pay no rent. But if the balance reduced to 500,000 BU and the storage stayed the same at 1,000, then it would pay 500 BU/day.
|
||||
|
||||
▸ **signedClaimHandicap**(): `BlockNumber`
|
||||
- **summary**: Number of block delay an extrinsic claim surcharge has. When claim surchage is called by an extrinsic the rent is checked for current_block - delay
|
||||
|
||||
▸ **storageSizeOffset**(): `u32`
|
||||
- **summary**: Size of a contract at the time of creation. This is a simple way to ensure that empty contracts eventually gets deleted.
|
||||
|
||||
▸ **surchargeReward**(): `BalanceOf`
|
||||
- **summary**: Reward that is received by the party whose touch has led to removal of a contract.
|
||||
|
||||
▸ **tombstoneDeposit**(): `BalanceOf`
|
||||
- **summary**: The minimum amount required to generate a tombstone.
|
||||
|
||||
▸ **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.
|
||||
|
||||
▸ **presentationDuration**(): `BlockNumber`
|
||||
- **summary**: How long to give each top candidate to present themselves after the vote ends.
|
||||
|
||||
▸ **presentSlashPerVoter**(): `BalanceOf`
|
||||
- **summary**: The punishment, per voter, if you provide an invalid presentation.
|
||||
|
||||
▸ **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>`
|
||||
|
||||
▸ **proposals**(): `Vec<(BlockNumber,Hash)>`
|
||||
|
||||
▸ **proposalVoters**(`Hash`): `Vec<AccountId>`
|
||||
|
||||
▸ **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.
|
||||
|
||||
▸ **proxy**(`AccountId`): `Option<AccountId>`
|
||||
- **summary**: Who is able to vote for whom. Value is the fund-holding account, key is the vote-transaction-sending account.
|
||||
|
||||
▸ **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 referenda 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 if this entry exists; in which case, the boolean value is true if the new session should be considered a normal rotation (rewardable) and false if the new session should be considered 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 eras.
|
||||
|
||||
▸ **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 Session 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`
|
||||
- **summary**: The `AccountId` of the sudo key.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### 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.
|
||||
|
||||
▸ **eventCount**(): `EventIndex`
|
||||
- **summary**: The number of events in the `Events<T>` list.
|
||||
|
||||
▸ **events**(): `Vec<EventRecord>`
|
||||
- **summary**: Events deposited for the current block.
|
||||
|
||||
▸ **eventTopics**(): `DoubleMap<Vec<(BlockNumber,EventIndex)>>`
|
||||
- **summary**: Mapping between a topic (represented by T::Hash) and a vector of indexes of events in the `<Events<T>>` list. The first key serves no purpose. This field is declared as double_map just for convenience of using `remove_prefix`. All topic vectors have deterministic storage locations depending on the topic. This allows light-clients to leverage the changes trie storage tracking mechanism and in case of changes fetch the list of events of interest. The value has the type `(T::BlockNumber, EventIndex)` because if we used only just the `EventIndex` then in case if the topic has the same contents on the next block no notification will be triggered thus the event might be lost.
|
||||
|
||||
▸ **extrinsicCount**(): `Option<u32>`
|
||||
- **summary**: Total extrinsics count for the current block.
|
||||
|
||||
▸ **extrinsicData**(`u32`): `Bytes`
|
||||
- **summary**: Extrinsics data for the current block (maps an 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.
|
||||
|
||||
▸ **randomMaterial**(): `(i8,Vec<Hash>)`
|
||||
- **summary**: Series of block headers from the last 81 blocks that acts as random seed material. This is arranged as a ring buffer with the `i8` prefix being the index into the `Vec` of the oldest hash.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### 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.
|
||||
|
||||
---
|
||||
@@ -1,50 +0,0 @@
|
||||
---
|
||||
home: true
|
||||
heroText:
|
||||
tagline:
|
||||
# Bringing JavaScript to the Polkadot world.
|
||||
# actionText: Repository Overview
|
||||
# actionLink: /REPOS.md
|
||||
features:
|
||||
- title: API
|
||||
details: A powerful dynamic API that allows chain interactions with transparent encoding and decoding.
|
||||
- title: Substrate defaults
|
||||
details: An overview of the various default methods, state entries and RPCs for Substrate-based chains.
|
||||
- title: Types
|
||||
details: Various type interfaces to make using returned values from API calls transparent in your code.
|
||||
|
||||
footer: Apache-2 Licensed | Copyright © 2017-2019 polkadot-js authors and contributors
|
||||
---
|
||||
|
||||
## Welcome
|
||||
|
||||
The API provides application developers the ability to query a node and interact with the Polkadot or Substrate chains using Javascript. Here you will find documentation and examples to get you started.
|
||||
|
||||
::: tip Getting started & Examples
|
||||
[Jump right in](/start/) and get an overview on using the API in your projects, from installation all the way through to making it do magic. Already understand how things work and just want the examples? [The ApiPromise examples](/examples/promise/) provide some basic recipies.
|
||||
:::
|
||||
|
||||
## Available packages
|
||||
|
||||
This repository split up into a number of internal packages, namely -
|
||||
|
||||
- [api](api/README.md) Promise and RxJS-based APIs
|
||||
- [types](types/README.md) Type encoding and decoding wrappers
|
||||
|
||||
## The Polkadot Project
|
||||
|
||||
You can read more about the Polkadot Network at [https://polkadot.network/](https://polkadot.network/) and more about the polkadot-js projects at [https://polkadot.js.org](https://polkadot.js.org)
|
||||
|
||||
## Github repositories
|
||||
|
||||
You can find the Polkadot repositories at:
|
||||
|
||||
- [https://github.com/polkadot-js](https://github.com/polkadot-js)
|
||||
- [https://github.com/paritytech/polkadot](https://github.com/paritytech/polkadot)
|
||||
- [https://github.com/paritytech/substrate](https://github.com/paritytech/substrate)
|
||||
|
||||
This documentation is generated from [https://github.com/polkadot-js/api](https://github.com/polkadot-js/api)
|
||||
|
||||
## Contributing
|
||||
|
||||
Contribution to the Polkadot JS API are more than welcome. You can [report issues](https://github.com/polkadot-js/api/issues/new) and [log feature requests](https://github.com/polkadot-js/api/issues/new).
|
||||
@@ -1,61 +0,0 @@
|
||||
## Getting started
|
||||
|
||||
- [Introduction](start/README.md)
|
||||
- [Installation](start/install.md)
|
||||
- [Basics](start/basics.md)
|
||||
- [Creating](start/create.md)
|
||||
- [Constant queries](start/api.consts.md)
|
||||
- [State queries](start/api.query.md)
|
||||
- [RPC queries](start/api.rpc.md)
|
||||
- [State subscriptions](start/api.query.subs.md)
|
||||
- [Multi state retrieval](start/api.query.multi.md)
|
||||
- [State query utilities](start/api.query.other.md)
|
||||
- [Transactions](start/api.tx.md)
|
||||
- [Keyring](start/keyring.md)
|
||||
- [Transaction subscriptions](start/api.tx.subs.md)
|
||||
- [Complex transactions](start/api.tx.wrap.md)
|
||||
- [Type basics](start/types.basics.md)
|
||||
- [Type extension](start/types.extend.md)
|
||||
- [TypeScript interfaces](start/typescript.md)
|
||||
|
||||
## Packages
|
||||
|
||||
- [api](api/README.md)
|
||||
- [ApiPromise](api/classes/_promise_index_.apipromise.md)
|
||||
- [ApiRx](api/classes/_rx_index_.apirx.md)
|
||||
- [rpc-provider](rpc-provider/README.md)
|
||||
- [HttpProvider](rpc-provider/classes/_http_index_.httpprovider.md)
|
||||
- [WsProvider](rpc-provider/classes/_ws_index_.wsprovider.md)
|
||||
- [types (codec implementation)](types/README.md)
|
||||
|
||||
## Interfaces
|
||||
|
||||
- [Substrate](substrate/README.md)
|
||||
- [RPC](substrate/rpc.md)
|
||||
- [Constants (runtime)](substrate/constants.md)
|
||||
- [Chain state (runtime)](substrate/storage.md)
|
||||
- [Extrinsics (runtime)](substrate/extrinsics.md)
|
||||
- [Events (runtime)](substrate/events.md)
|
||||
|
||||
## Examples
|
||||
|
||||
- [ApiPromise](examples/promise/README.md)
|
||||
- [Simple connect](examples/promise/01_simple_connect/README.md)
|
||||
- [Listen to blocks](examples/promise/02_listen_to_blocks/README.md)
|
||||
- [Listen to balance change](examples/promise/03_listen_to_balance_change/README.md)
|
||||
- [Unsubscribe from listening](examples/promise/04_unsubscribe/README.md)
|
||||
- [Read chain state](examples/promise/05_read_storage/README.md)
|
||||
- [Make a transfer](examples/promise/06_make_transfer/README.md)
|
||||
- [Display system events](examples/promise/08_system_events/README.md)
|
||||
- [Transaction with events](examples/promise/09_transfer_events/README.md)
|
||||
- [Upgrade via sudo](examples/promise/10_upgrade_chain/README.md)
|
||||
- [ApiRx](examples/rx/README.md)
|
||||
- [Simple connect](examples/rx/01_simple_connect/README.md)
|
||||
- [Listen to blocks](examples/rx/02_listen_to_blocks/README.md)
|
||||
- [Listen to balance change](examples/rx/03_listen_to_balance_change/README.md)
|
||||
- [Unsubscribe from listening](examples/rx/04_unsubscribe/README.md)
|
||||
- [Read chain state](examples/rx/05_read_storage/README.md)
|
||||
- [Make a transfer](examples/rx/06_make_transfer/README.md)
|
||||
- [Display system events](examples/rx/08_system_events/README.md)(
|
||||
- [Transaction with events](examples/rx/09_transfer_events/README.md)
|
||||
- [Upgrade via sudo](examples/rx/10_upgrade_chain/README.md)
|
||||
@@ -1,5 +1,5 @@
|
||||
# Simple Connect
|
||||
|
||||
The following example shows how to instantiate a Polkadot API object and use it to connect to a node using ApiPromise.
|
||||
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
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// @ts-check
|
||||
// Required imports
|
||||
const { ApiPromise, WsProvider } = require('@polkadot/api');
|
||||
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 });
|
||||
const api = await ApiPromise.create(provider);
|
||||
|
||||
// Retrieve the chain & node information information via rpc calls
|
||||
const [chain, nodeName, nodeVersion] = await Promise.all([
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
},
|
||||
|
||||
"dependencies": {
|
||||
"@polkadot/api": "*"
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// @ts-check
|
||||
// Import the API
|
||||
const { ApiPromise } = require('@polkadot/api');
|
||||
const { ApiPromise } = require('@plugnet/api');
|
||||
|
||||
async function main () {
|
||||
// Here we don't pass the (optional) provider, connecting directly to the default
|
||||
@@ -10,19 +8,11 @@ async function main () {
|
||||
// the API has connected to the node and completed the initialisation process
|
||||
const api = await ApiPromise.create();
|
||||
|
||||
// We only display a couple, then unsubscribe
|
||||
let count = 0;
|
||||
|
||||
// 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.subscribeNewHeads((header) => {
|
||||
console.log(`Chain is at block: #${header.number}`);
|
||||
|
||||
if (++count === 256) {
|
||||
unsubscribe();
|
||||
process.exit(0);
|
||||
}
|
||||
const unsubscribe = await api.rpc.chain.subscribeNewHead((header) => {
|
||||
console.log(`Chain is at block: #${header.blockNumber}`);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "*"
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Listen to balance changes
|
||||
|
||||
This example shows how to instantiate a Polkadot API object and use it to connect to a node and retrieve balance updates.
|
||||
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
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// @ts-check
|
||||
// Import the API
|
||||
const { ApiPromise } = require('@polkadot/api');
|
||||
const { ApiPromise } = require('@plugnet/api');
|
||||
|
||||
// Known account we want to use (available on dev chain, with funds)
|
||||
const Alice = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "*"
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
# Listen to balance changes
|
||||
|
||||
This example shows how to instantiate a Polkadot API object and use it to connect to a node and retrieve balance updates.
|
||||
|
||||
<<< @/docs/examples/promise/03_listen_to_balance_change/index.js
|
||||
@@ -1,23 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// Import the API
|
||||
const { ApiPromise } = require('@polkadot/api');
|
||||
|
||||
// Known account we want to use (available on dev chain, with funds)
|
||||
const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
const BOB = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty';
|
||||
|
||||
async function main () {
|
||||
// Create an await for the API
|
||||
const api = await ApiPromise.create();
|
||||
|
||||
console.log('Tracking balances for:', [ALICE, BOB]);
|
||||
|
||||
// Subscribe and listen to several balance changes
|
||||
api.query.balances.freeBalance.multi([ALICE, BOB], (balances) => {
|
||||
console.log('Change detected, new balances: ', balances);
|
||||
});
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"name": "03_listen_to_multiple_balances_change",
|
||||
"version": "0.2.0",
|
||||
"description": "Example showing how to subscribe to multiple balances change",
|
||||
"main": "index.js",
|
||||
"author": "chevdor",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,22 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// @ts-check
|
||||
// Import the API
|
||||
const { ApiPromise } = require('@polkadot/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.subscribeNewHeads((header) => {
|
||||
console.log(`Chain is at block: #${header.number}`);
|
||||
// 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');
|
||||
console.log('Unsubscribed')
|
||||
}, 20000);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "*"
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -1,25 +1,23 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// @ts-check
|
||||
// Import the API
|
||||
const { ApiPromise } = require('@polkadot/api');
|
||||
const { ApiPromise } = require('@plugnet/api');
|
||||
|
||||
// Our address for Alice on the dev chain
|
||||
const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
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, now, validators] = await Promise.all([
|
||||
api.query.system.accountNonce(ALICE),
|
||||
api.query.timestamp.now(),
|
||||
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(`last block timestamp ${now.toNumber()}`);
|
||||
console.log(`accountNonce(${Alice}) ${accountNonce}`);
|
||||
console.log(`blockPeriod ${blockPeriod.toNumber()} seconds`);
|
||||
|
||||
if (validators && validators.length > 0) {
|
||||
// Retrieve the balances for all validators
|
||||
@@ -37,4 +35,4 @@ async function main () {
|
||||
}
|
||||
}
|
||||
|
||||
main().catch(console.error).finally(() => process.exit());
|
||||
main().catch(console.error).finally(_ => process.exit());
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "*"
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
# Read storage, at a specific blockhash
|
||||
|
||||
In addition to querying the latest storage, you can make storage queries at a specific blockhash. Be aware that the node applies a pruning strategy and typically only keeps the last 256 blocks, unless run in archive mode.
|
||||
|
||||
<<< @/docs/examples/promise/05_read_storage_at/index.js
|
||||
@@ -1,32 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// Import the API
|
||||
const { ApiPromise } = require('@polkadot/api');
|
||||
|
||||
// Our address for Alice on the dev chain
|
||||
const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
const BOB = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty';
|
||||
|
||||
async function main () {
|
||||
// Create our API with a default connection to the local node
|
||||
const api = await ApiPromise.create();
|
||||
|
||||
// Retrieve the last block header, extracting the hash and parentHash
|
||||
const { hash, parentHash } = await api.rpc.chain.getHeader();
|
||||
|
||||
console.log(`last header hash ${hash.toHex()}`);
|
||||
|
||||
// Retrieve the balance at the preceding block for Alice. For at queries
|
||||
// the format is always `.at(<blockhash>, ...params)`
|
||||
const balance = await api.query.balances.freeBalance.at(parentHash, ALICE);
|
||||
|
||||
console.log(`Alice's balance at ${parentHash.toHex()} was ${balance}`);
|
||||
|
||||
// Now perform a multi query, returning multiple balances at once
|
||||
const balances = await api.query.balances.freeBalance.multi([ALICE, BOB]);
|
||||
|
||||
console.log(`Current balances for Alice and Bob are ${balances[0]} and ${balances[1]}`);
|
||||
}
|
||||
|
||||
main().catch(console.error).finally(() => process.exit());
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"name": "05_read_storage_at",
|
||||
"version": "0.2.0",
|
||||
"description": "Example showing how to query storage at a specific block",
|
||||
"main": "index.js",
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// @ts-check
|
||||
// Import the API, Keyring and some utility functions
|
||||
const { ApiPromise } = require('@polkadot/api');
|
||||
const { Keyring } = require('@polkadot/keyring');
|
||||
const { ApiPromise } = require('@plugnet/api');
|
||||
const { Keyring } = require('@plugnet/keyring');
|
||||
|
||||
const BOB = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty';
|
||||
|
||||
@@ -14,7 +12,7 @@ async function main () {
|
||||
// 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)
|
||||
// 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
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "*"
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
# Make a Transfer with allowed block permissions
|
||||
|
||||
This transactions shows you how to add a nonce and a valid length of blocks a transaction is valid for.
|
||||
|
||||
This is important because as an account drops below the exsistential limit (0.1 dots) it gets pruned from the state tree. If it is added back its nonce starts at 0 again and is now vulnerable to replay attacks.
|
||||
@@ -1,45 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// Import the API, Keyring and some utility functions
|
||||
const { ApiPromise } = require('@polkadot/api');
|
||||
const { Keyring } = require('@polkadot/keyring');
|
||||
const { createType } = require('@polkadot/types');
|
||||
|
||||
const BOB = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty';
|
||||
|
||||
async function main () {
|
||||
// Instantiate the API
|
||||
const api = await ApiPromise.create(); // default provider
|
||||
|
||||
// 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-derived path (empty phrase, so uses dev)
|
||||
const alice = keyring.addFromUri('//Alice');
|
||||
|
||||
// Get nonce for account
|
||||
const nonce = await api.query.system.accountNonce(alice.address);
|
||||
|
||||
// Get current block
|
||||
const signedBlock = await api.rpc.chain.getBlock();
|
||||
|
||||
// Get current block height and hash
|
||||
const currentHeight = signedBlock.block.header.number;
|
||||
const blockHash = signedBlock.block.header.hash;
|
||||
|
||||
// NOTE By default the API will send mortal transactions, only explicitly construct
|
||||
// if you wish to override the defaults
|
||||
// construct a mortal era
|
||||
const era = createType('ExtrinsicEra', { current: currentHeight, period: 10 });
|
||||
|
||||
// Create an extrinsic, transferring 12345 units to Bob
|
||||
const transfer = api.tx.balances.transfer(BOB, 12345);
|
||||
|
||||
// Sign and send the transaction using our account with a nonce and the length of blocks the transaction is valid for
|
||||
const hash = await transfer.signAndSend(alice, { blockHash, era, nonce });
|
||||
|
||||
console.log('Transfer sent with hash', hash.toHex());
|
||||
}
|
||||
|
||||
main().catch(console.error).finally(() => process.exit());
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"name": "07_make_transfer_with_allowed_block_permissions_only",
|
||||
"version": "0.1.0",
|
||||
"description": "Example showing how to make a transfer with allowed block permissions",
|
||||
"main": "index.js",
|
||||
"author": "Jesse",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,26 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// @ts-check
|
||||
// Import the API
|
||||
const { ApiPromise } = require('@polkadot/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
|
||||
// subscribe to system events via storage
|
||||
api.query.system.events((events) => {
|
||||
console.log(`\nReceived ${events.length} events:`);
|
||||
|
||||
// Loop through the Vec<EventRecord>
|
||||
// loop through the Vec<EventRecord>
|
||||
events.forEach((record) => {
|
||||
// Extract the phase, event and the event types
|
||||
// extract the phase, event and the event types
|
||||
const { event, phase } = record;
|
||||
const types = event.typeDef;
|
||||
|
||||
// Show what we are busy with
|
||||
// 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
|
||||
// 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()}`);
|
||||
});
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "*"
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// @ts-check
|
||||
// Import the API & Provider and some utility functions
|
||||
const { ApiPromise } = require('@polkadot/api');
|
||||
const { ApiPromise } = require('@plugnet/api');
|
||||
|
||||
// Import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
|
||||
const testKeyring = require('@polkadot/keyring/testing');
|
||||
// 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('@polkadot/util-crypto');
|
||||
// utility function for random values
|
||||
const { randomAsU8a } = require('@plugnet/util-crypto');
|
||||
|
||||
// Some constants we are using in this sample
|
||||
// some constants we are using in this sample
|
||||
const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
const AMOUNT = 10000;
|
||||
|
||||
@@ -18,26 +16,27 @@ async function main () {
|
||||
// Create the API and wait until ready
|
||||
const api = await ApiPromise.create();
|
||||
|
||||
// Create an instance of our testing keyring
|
||||
// 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
|
||||
// get the nonce for the admin key
|
||||
const nonce = await api.query.system.accountNonce(ALICE);
|
||||
|
||||
// Find the actual keypair in the keyring
|
||||
// find the actual keypair in the keyring
|
||||
const alicePair = keyring.getPair(ALICE);
|
||||
|
||||
// Create a new random recipient
|
||||
const recipient = keyring.addFromSeed(randomAsU8a(32)).address;
|
||||
// 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());
|
||||
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)
|
||||
.signAndSend(alicePair, { nonce }, ({ events = [], status }) => {
|
||||
.sign(alicePair, { nonce })
|
||||
.send(({ events = [], status }) => {
|
||||
console.log('Transaction status:', status.type);
|
||||
|
||||
if (status.isFinalized) {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "*"
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// @ts-check
|
||||
// Import the API & Provider and some utility functions
|
||||
const { ApiPromise, WsProvider } = require('@polkadot/api');
|
||||
const { ApiPromise, WsProvider } = require('@plugnet/api');
|
||||
|
||||
// import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
|
||||
const testKeyring = require('@polkadot/keyring/testing');
|
||||
const testKeyring = require('@plugnet/keyring/testing');
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
@@ -14,26 +12,24 @@ async function main () {
|
||||
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 });
|
||||
const api = await ApiPromise.create(provider);
|
||||
|
||||
// Retrieve the upgrade key from the chain state
|
||||
// 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 a changed value, the 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
|
||||
// retrieve the runtime to upgrade to
|
||||
const code = fs.readFileSync('./test.wasm').toString('hex');
|
||||
const proposal = api.tx.system && api.tx.system.setCode
|
||||
? api.tx.system.setCode(`0x${code}`) // For newer versions of Substrate
|
||||
: api.tx.consensus.setCode(`0x${code}`); // For previous versions
|
||||
const proposal = api.tx.consensus.setCode(`0x${code}`);
|
||||
|
||||
console.log(`Upgrading from ${adminId}, ${code.length / 2} bytes`);
|
||||
|
||||
// Perform the actual chain upgrade via the sudo module
|
||||
// preform the actual chain upgrade via the sudo module
|
||||
api.tx.sudo
|
||||
.sudo(proposal)
|
||||
.signAndSend(adminPair, ({ events = [], status }) => {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "*"
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -18,7 +18,9 @@ From each folder, run `yarn` to install the required dependencies and then run `
|
||||
|
||||
Some of the examples use the following accounts:
|
||||
|
||||
- Alice: `5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY`
|
||||
- Bob: `5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty`
|
||||
- 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` (via `keyring.addUri(...)`, dev seed implied) and the seed of Bob is... well you guess...
|
||||
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,5 +1,5 @@
|
||||
# Simple Connect
|
||||
|
||||
The following example shows how to instantiate a Polkadot API object and use it to connect to a node using ApiRx.
|
||||
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
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// Required imports
|
||||
const { zip } = require('rxjs');
|
||||
const { ApiRx } = require('@polkadot/api');
|
||||
const { WsProvider } = require('@polkadot/rpc-provider');
|
||||
const { ApiRx } = require('@plugnet/api');
|
||||
const { WsProvider } = require('@plugnet/rpc-provider');
|
||||
|
||||
async function main () {
|
||||
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();
|
||||
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
|
||||
@@ -19,7 +16,9 @@ async function main () {
|
||||
api.rpc.system.chain(),
|
||||
api.rpc.system.name(),
|
||||
api.rpc.system.version()
|
||||
).subscribe(([chain, nodeName, nodeVersion]) => {
|
||||
)
|
||||
// Then we subscribe to the result
|
||||
.subscribe(([chain, nodeName, nodeVersion]) => {
|
||||
console.log(`You are connected to chain ${chain} using ${nodeName} v${nodeVersion}`);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
},
|
||||
|
||||
"dependencies": {
|
||||
"@polkadot/api": "*"
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// Import the API
|
||||
const { ApiRx } = require('@polkadot/api');
|
||||
const { ApiRx } = require('@plugnet/api');
|
||||
const { switchMap } = require('rxjs/operators');
|
||||
|
||||
async function main () {
|
||||
@@ -12,10 +9,10 @@ async function main () {
|
||||
new ApiRx().isReady
|
||||
.pipe(
|
||||
switchMap((api) =>
|
||||
api.rpc.chain.subscribeNewHeads()
|
||||
api.rpc.chain.subscribeNewHead()
|
||||
))
|
||||
.subscribe((header) => {
|
||||
console.log(`Chain is at block: #${header.number}`);
|
||||
console.log(`Chain is at block: #${header.blockNumber}`);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "*"
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Listen to balance changes
|
||||
|
||||
This example shows how to instantiate a Polkadot API object and use it to connect to a node and retrieve balance updates.
|
||||
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_listen_to_balance_change/index.js
|
||||
<<< @/docs/examples/rx/03_listent_to_balance_change/index.js
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// Import the API and operators from RxJs
|
||||
const { ApiRx } = require('@polkadot/api');
|
||||
const { ApiRx } = require('@plugnet/api');
|
||||
const { pairwise, startWith } = require('rxjs/operators');
|
||||
|
||||
// Known account we want to use (available on dev chain, with funds)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "*"
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// Import the API
|
||||
const { ApiRx } = require('@polkadot/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.
|
||||
// Subscribe to chain updates and log the current block number on update.
|
||||
const subscription = new ApiRx().isReady
|
||||
.pipe(
|
||||
switchMap((api) =>
|
||||
api.rpc.chain.subscribeNewHeads()
|
||||
api.rpc.chain.subscribeNewHead()
|
||||
))
|
||||
.subscribe((header) => {
|
||||
console.log(`Chain is at block: #${header.number}`);
|
||||
console.log(`Chain is at block: #${header.blockNumber}`);
|
||||
});
|
||||
|
||||
// In this example we're calling the Overvables unsubscribe() //
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "*"
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// Import the API
|
||||
const { ApiRx } = require('@polkadot/api');
|
||||
const { ApiRx } = require('@plugnet/api');
|
||||
// Import dependencies from RxJs
|
||||
const { combineLatest, of } = require('rxjs');
|
||||
const { first, switchMap } = require('rxjs/operators');
|
||||
|
||||
@@ -11,7 +9,7 @@ const Alice = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
|
||||
function main () {
|
||||
// Create our API with a default connection to the local node
|
||||
new ApiRx().isReady
|
||||
new ApiRx(provider).isReady
|
||||
.pipe(
|
||||
// Here we ake our basic chain state/storage queries
|
||||
switchMap((api) => combineLatest(
|
||||
@@ -50,4 +48,4 @@ function main () {
|
||||
});
|
||||
}
|
||||
|
||||
main().catch(console.error).finally(() => process.exit());
|
||||
main().catch(console.error).finally(_ => process.exit());
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "*"
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// Import the API, Keyring and some utility functions
|
||||
const { ApiRx } = require('@polkadot/api');
|
||||
const { Keyring } = require('@polkadot/keyring');
|
||||
const { ApiRx } = require('@plugnet/api');
|
||||
const { Keyring } = require('@plugnet/keyring');
|
||||
|
||||
const BOB = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty';
|
||||
|
||||
@@ -12,26 +9,25 @@ async function main () {
|
||||
const api = await ApiRx.create().toPromise();
|
||||
|
||||
// Create an instance of the keyring
|
||||
const keyring = new Keyring({ type: 'sr25519' });
|
||||
const keyring = new Keyring({ type: 's25519' });
|
||||
|
||||
// Add Alice to our keyring (with the known seed for the account)
|
||||
const alice = keyring.addFromUri('//Alice');
|
||||
const alice = keyring.addFomUri('//Alice');
|
||||
|
||||
// Create a extrinsic, transferring 12345 units to Bob.
|
||||
const subscription = api.tx.balances
|
||||
// Create a extrinsic, transferring 12345 units to Bob.
|
||||
api.tx.balances
|
||||
// create transfer
|
||||
.transfer(BOB, 12345)
|
||||
.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()}`);
|
||||
subscription.unsubscribe();
|
||||
} else {
|
||||
console.log(`Status of transfer: ${status.type}`);
|
||||
console.log(`Staus of transfer: ${status.type}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
main().catch(console.error).finally(_ => process.exit());
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "*"
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// Import the API and selected RxJs operators
|
||||
const { switchMap } = require('rxjs/operators');
|
||||
const { ApiRx } = require('@polkadot/api');
|
||||
const { ApiRx } = require('@plugnet/api');
|
||||
|
||||
async function main () {
|
||||
// Create our API with a default connection to the local node
|
||||
@@ -12,9 +9,8 @@ async function main () {
|
||||
switchMap((api) =>
|
||||
// subscribe to system events via storage
|
||||
api.query.system.events()
|
||||
)
|
||||
)
|
||||
// Then we're subscribing to the emitted results
|
||||
))
|
||||
// Then we're subscribing to the emitted results
|
||||
.subscribe((events) => {
|
||||
console.log(`\nReceived ${events.length} events:`);
|
||||
// loop through the Vec<EventRecord>
|
||||
@@ -33,7 +29,7 @@ async function main () {
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
main().catch((error) => {
|
||||
console.error(error);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "*"
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// Import the API and some utility functions
|
||||
const { ApiRx } = require('@polkadot/api');
|
||||
const { ApiRx } = require('@plugnet/api');
|
||||
|
||||
// Import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
|
||||
const testKeyring = require('@polkadot/keyring/testing');
|
||||
// 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('@polkadot/util-crypto');
|
||||
// utility function for random values
|
||||
const { randomAsU8a } = require('@plugnet/util-crypto');
|
||||
|
||||
// Some constants we are using in this sample
|
||||
// some constants we are using in this sample
|
||||
const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
const AMOUNT = 10000;
|
||||
|
||||
@@ -18,21 +15,21 @@ 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
|
||||
// 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
|
||||
// find the actual keypair in the keyring
|
||||
const alicePair = keyring.getPair(ALICE);
|
||||
|
||||
// Create a new random recipient
|
||||
const recipient = keyring.addFromSeed(randomAsU8a(32)).address;
|
||||
// create a new random recipient
|
||||
const recipient = keyring.addFromSeed(randomAsU8a(32)).address();
|
||||
|
||||
console.log('Sending', AMOUNT, 'from', alicePair.address, 'to', recipient);
|
||||
console.log('Sending', AMOUNT, 'from', alicePair.address(), 'to', recipient);
|
||||
|
||||
// Get the nonce for the admin key
|
||||
// Create a extrinsic, transferring 12345 units to Bob.
|
||||
// get the nonce for the admin key
|
||||
// Create a extrinsic, transferring 12345 units to Bob.
|
||||
api.tx.balances
|
||||
// Do the transfer
|
||||
.transfer(recipient, AMOUNT)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "*"
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
// Import the API & Provider and some utility functions
|
||||
const { ApiRx, WsProvider } = require('@polkadot/api');
|
||||
// Import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
|
||||
const testKeyring = require('@polkadot/keyring/testing');
|
||||
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 () {
|
||||
@@ -12,30 +9,29 @@ async function main () {
|
||||
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();
|
||||
const api = await ApiRx.create(provider).toPromise();
|
||||
|
||||
// Retrieve the upgrade key from the chain state
|
||||
// TODO It seems like this promise doesn't resolve
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
// Perform the actual chain upgrade via the sudo module
|
||||
// preform the actual chain upgrade via the sudo module
|
||||
.sudo(proposal)
|
||||
// Sign and send the proposal
|
||||
// sign and send the proposal
|
||||
.signAndSend(adminPair)
|
||||
// Subscribe to overall result
|
||||
// subscribe to overall result
|
||||
.subscribe(({ events = [], status }) => {
|
||||
// Log transfer events
|
||||
console.log('Proposal status:', status.type);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "*"
|
||||
"@plugnet/api": "^0.76.102"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 7.3 KiB |
@@ -1,5 +0,0 @@
|
||||
... somewhere also need a signer injection section, something along the lines of the singlesigner or this https://github.com/polkadot-js/tools/blob/master/packages/signer-cli/src/cmdSubmit.ts#L12
|
||||
|
||||
... DoubleMap & LinkedMap examples
|
||||
|
||||
... api.derive
|
||||
@@ -1,35 +0,0 @@
|
||||
# FAQ
|
||||
|
||||
The list will be updated/expanded as questions come up, dealing with some common issues that API users find.
|
||||
|
||||
## I am getting a "Unknown types found, no types for ..." error
|
||||
|
||||
There are 2 causes for this, both related to the version of the API that you are using and the support of types. As explained in the elsewhere, types on Polkadot/Substrate are continuously evolving - the latest version of the API always tries to support types for the latest Polkadot networks, such as [Kusama](https://kusama.network/). So for Polkadot public chains, ensure that you are using the latest released API version.
|
||||
|
||||
If however you are running against a master branch of either Polkadot or Substrate, you may well be better suited running [a beta version, tracking master](install.md#betas). If you are connected to a customized chain, you would rather want to [register the types](types.extend.md) either on your own, or via packages that the chain vendor provides.
|
||||
|
||||
## I am getting a "Metadata:: failed on MagicNumber" error
|
||||
|
||||
Update your version of the API to the [latest version](install.md). Like types, the [metadata interfaces](basics.md) are continuously evolving. For instance with the Polkadot Alexander network, only metadata v3 is available. By the time Kusama launched, this has been bumped to v7. As these versions are added to the Polkadot/Substrate codebase, they are added to the API.
|
||||
|
||||
## I would like to sign transactions offline
|
||||
|
||||
The API itself is independent on where the signature comes from and how it is injected. Additionally it implements a signer interface, that can be used for external signing - an example of this is the [polkadot-js/apps](https://github.com/polkadot-js/apps) support for signing via extensions and even the [polkadot-js/extension](https://github.com/polkadot-js/extension) support for tools such as the [Parity Signer](https://github.com/paritytech/parity-signer).
|
||||
|
||||
As of this writing we don't have an explicit example of implementing the signer interface in these docs, although we do use one in [our tests](https://github.com/polkadot-js/api/blob/master/packages/api/test/util/SingleAccountSigner.ts). Additionally, the [polkadot-js/tools](https://github.com/polkadot-js/tools) has an implementation of [a very basic offline signer](https://github.com/polkadot-js/tools/tree/master/packages/signer-cli) where transactions are generated in one process and signatures in another non-connected process.
|
||||
|
||||
## I would like to send a root transaction
|
||||
|
||||
Some calls in Polkadot/Substrate can only be submitted as root, these are indicated by `ensure_root(origin)` in the Rust codebase. Root here does not refer to the actual account, i.e. `//Alice` on a `--dev` chain, but rather that it cannot be submitted as a bare user transaction. This restriction applies to chain upgrades, changing balances or anything that modifies the state and/or chain operation.
|
||||
|
||||
To submit these transactions, it needs to be send as a [wrapped transaction](api.tx.wrap.md#sudo-use) via either `sudo.sudo` (assuming you have access on your chain) or `democracy.proposal` (which would allow users of the chain to vote on it).
|
||||
|
||||
## How do I call a function with a Tuple input
|
||||
|
||||
Tuples, as defined in the Polkadot/Substrate types appear as `(TypeA, TypeB)`. For instance we may have an `(AccountId, u64)` input as defined in the metadata or as part of the user types. To specify a Tuple as an input, wrap it is an array format, for instance to call `query.module.get((u32, u64))` where a `(u32, u64)` Tuple input is expected, you would do `query.module.get([123, 456])`
|
||||
|
||||
## How long do transactions live
|
||||
|
||||
Polkadot/Substrate supports both immortal and mortal transactions. For immortal, this means that the transaction has an infinite lifetime, for mortals, the transactions expire after a defined period. By default the API sends mortal transactions when no explicit extrinsic era has been specified. This means that all transaction has a limited lifetime and will expire if not included in the period set.
|
||||
|
||||
The length for this transaction validity is set to 50 blocks, which translates to 5 minutes assuming a default of 6 second blocktimes. (10 blocks per minute in this default configuration).
|
||||
@@ -1,15 +0,0 @@
|
||||
# Getting started
|
||||
|
||||
These sections should provide you with all the information needed to install the `@polkadot/api` package, understand the structure of the interfaces and allow you to start using it. For existing users this really should be titled "Things I wish I knew before I started using the api" - it really aims to close the gap to allow anybody to get to grips with using the packages.
|
||||
|
||||
## What this is not
|
||||
|
||||
This is not line-by-line documentation of all the existing function calls available, nor it is tied to a specific chain. (Although the examples do refer to the base Polkadot & Substrate chains). There will be some things in the API that are probably not covered, which brings us to the next point...
|
||||
|
||||
## Help us help others
|
||||
|
||||
If you spot gaps in the information provided, or are uncertain about any specific area, please do [log an issue](https://github.com/polkadot-js/api/issues) or if you are that way inclined, make a pull-request. We really want to have good documentation in these areas and allow people to be productive right from the start.
|
||||
|
||||
## Ready? Steady? Go!
|
||||
|
||||
If you already have a good grasp on the API and are just looking for a specific answer, you may want to take a look at the [Frequently Asked Questions](FAQ.md). With all that said, let's get started... [What should be installed, and how should we do it?](install.md)
|
||||
@@ -1,34 +0,0 @@
|
||||
# Runtime Constants
|
||||
|
||||
Constant queries will introduce you to the concepts behind the types and the interaction of the API with those types. The same concepts are implemented in the remainder of the API - the runtime constants is just the simplest starting point.
|
||||
|
||||
For some background: constants are values that are defined in the runtime and used as part of chain operations. These constants can be changed as part of an upgrade.
|
||||
|
||||
```js
|
||||
// Initialize the API as per previous sections
|
||||
...
|
||||
|
||||
// The length of an epoch (session) in Babe
|
||||
console.log(api.consts.babe.epochDuration.toNumber());
|
||||
|
||||
// The amount required to create a new account
|
||||
console.log(api.consts.balances.creationFee.toNumber());
|
||||
|
||||
// The amount required per byte on an extrinsic
|
||||
console.log(api.consts.balances.transactionByteFee.toNumber());
|
||||
```
|
||||
|
||||
Since these are constants and defined by the metadata, it is not a call, but rather the values immediately available - as you'll see in subsequent sections, there is no need for `await` on these, it immediately returns the type and value for you to work with.
|
||||
|
||||
## The API and types
|
||||
|
||||
There is some magic applied by the API. For instance as the `createFee` result is returned, the API knows the expected type and makes a `Balance` object available, hence the `toNumber`. This result mapping is consistent in retrieving constants, making queries or even sending transactions:
|
||||
|
||||
- when values are passed to the API, the API will convert whatever is provided into the correct type as required by the call
|
||||
- when a value is retrieved, the API will provide an object of the correct type that wraps this value
|
||||
|
||||
From the last point, this means that a `Balance` will be returned as a number object extending [bn.js](https://github.com/indutny/bn.js/). In a later section we will go through a breakdown of all the commonly-used types and all [the basics available on types](types.basics.md).
|
||||
|
||||
## Making queries
|
||||
|
||||
In the next section we will take an initial dive into [chain state and state queries](api.query.md), allowing the use of the API to retrieve information contained in the chain state.
|
||||
@@ -1,48 +0,0 @@
|
||||
# State queries
|
||||
|
||||
In previous sections, we initialized the API and retrieved runtime constants. This section will walk through the concepts behind making queries to the chain to retrieve current state. The `api.query.<module>.<method>` interfaces, as already described earlier, is populated from the metadata. The API uses the metadata information provided to construct queries based on the location and parameters provided to generate state keys, and then queries these via RPC.
|
||||
|
||||
## Basic queries
|
||||
|
||||
Let's dive right in, connect to a general chain and retrieve some information on the current state. Of interest may be retrieving the nonce of a particular account as well as the current balance, this can be achieved via -
|
||||
|
||||
```js
|
||||
// Initialize the API as in previous sections
|
||||
...
|
||||
|
||||
// The actual address that we will use
|
||||
const ADDR = '5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFabHE';
|
||||
|
||||
// Retrieve the last timestamp
|
||||
const now = await api.query.timestamp.now();
|
||||
|
||||
// Retrieve the account nonce via the system module
|
||||
const nonce = await api.query.system.accountNonce(ADDR);
|
||||
|
||||
// Retrieve the account balance via the balances module
|
||||
const balance = await api.query.balances.freeBalance(ADDR);
|
||||
|
||||
console.log(`${now}: balance of ${balance} and a nonce of ${nonce}`);
|
||||
```
|
||||
|
||||
There have been some additions in the code above comparing with retrieving runtime constants. In these cases, since we are making a query to the actual chain, we use the `await` syntax to retrieve the information. Since the API is Promise-based, this means we can also rewrite the above to follow a Promise pattern,
|
||||
|
||||
```js
|
||||
...
|
||||
// Retrieve last block timestamp, account nonce & balance
|
||||
const [now, nonce, balance] = await Promise.all([
|
||||
api.query.timestamp.now(),
|
||||
api.query.system.accountNonce(ADDR),
|
||||
api.query.balances.freeBalance(ADDR)
|
||||
]);
|
||||
```
|
||||
|
||||
## Parameters & return values
|
||||
|
||||
As indicated in previous sections, any return value is always an object with a consistent interface that reflects the type being returned. In the above example, the timestamp is a `Moment` (a `u64` value), the nonce is an `Index` (a `u32` value) and the `Balance` is an underlying `u128`.
|
||||
|
||||
Additionally we have provided some parameters for the query calls, specifically for the retrieval of the nonce and balance. It is important to note that the API will automatically convert any parameters into the correct type for encoding and making calls, in this case the `AccountId` parameter could be specified as a ss58 address (as it was), an actual `AccountId` (retrieved via another call) or just a plain `Uint8Array` (or even hex-string representation) for a publicKey.
|
||||
|
||||
## Exploring RPCs
|
||||
|
||||
Where all query functions use the underlying RPCs, together with metadata, to construct and retrieve information, the direct node RPCs can be seen as raw calls that enable these (slightly) higher-level operations. Next up we will take a dive into [making RPC calls via the API](api.rpc.md).
|
||||
@@ -1,60 +0,0 @@
|
||||
# Multi queries
|
||||
|
||||
In a number of applications, it is useful to monitor a number of like-queries at the same time. For instance, we may want to track the balances for a list of accounts we have. The `api.query` interfaces allows this via the `.multi` subscription call.
|
||||
|
||||
## Multi queries, same type
|
||||
|
||||
Where possible, the use of multi queries are encouraged since it tracks a number of state entries over a single RPC call, instead of making a call for each single item. In addition it allows you to have a single callback to track changes. For queries of the same type we can use `.multi`, for example to retrieve the balances of a number of accounts at once -
|
||||
|
||||
```js
|
||||
...
|
||||
|
||||
// Subscribe to balance changes for 2 accounts, ADDR1 & ADDR2 (already defined)
|
||||
const unsub = await api.query.balances.freeBalance.multi([ADDR1, ADDR2], (balances) => {
|
||||
const [balance1, balance2] = balances;
|
||||
|
||||
console.log(`The balances are ${balance1} and ${balance2}`);
|
||||
});
|
||||
```
|
||||
|
||||
A couple of items to note in the example above: we don't call `freeBalance` directly, but rather `freeBalance.multi`. We pass the addresses we want to query as an array, and the length thereof would depend on the number of addresses we want to query. As an extended example, we can track the balances of a list of validators,
|
||||
|
||||
```js
|
||||
...
|
||||
|
||||
// Retrieve a snapshot of the validators
|
||||
const validators = await api.query.session.validators();
|
||||
|
||||
// Subscribe to the balances for these accounts
|
||||
const unsub = await api.query.balances.freeBalance.multi(validators, (balances) => {
|
||||
console.log(`The balances are: ${balances}`);
|
||||
});
|
||||
```
|
||||
|
||||
The above example does not subscribe to the validators explicitly, but only gets a snapshot and uses this into the future. It should be trivially extendable to subscribe to the validators, track which one have entered or left and then subscribe to balances as they change through the next blocks.
|
||||
|
||||
## Multi queries, distinct types
|
||||
|
||||
The previous `.multi` examples assumes that we do queries for the same types, i.e. we retrieve the balances for a number of accounts. However, there is also a need to retrieve various distinct types, as an example we would like to track the block timestamp in addition to the nonce and balance of a specific account. To cater for this, the api has a specific `api.queryMulti` interface that can be used to perform this query -
|
||||
|
||||
```js
|
||||
...
|
||||
|
||||
// Subscribe to the timestamp, our index and balance
|
||||
const unsub = await api.queryMulti([
|
||||
api.query.timestamp.now,
|
||||
[api.query.system.accountNonce, ADDR],
|
||||
[api.query.balances.freeBalance, ADDR]
|
||||
], ([now, nonce, balance]) => {
|
||||
console.log(`${now}: balance of ${balance} and a nonce of ${nonce}`);
|
||||
});
|
||||
```
|
||||
|
||||
The above example certainly does not quite look as ergonomic and clean, but the API needs to understand (a) which are all the calls we need to make and (b) the calls and their params (if required). So breaking it down -
|
||||
|
||||
- `api.query.timestamp.now` - the timestamp is passed naked without any params. Also note that we do not call it while passing, but rather only provides a reference to the function, i.e. we do not have the expected `()` at the end. (This could also be of the form `[api.query.timestamp.now]`, aligning with subsequent entries)
|
||||
- `[api.query.system.accountNonce, ADDR]` - the nonce query is passed as an array containing the function (once again naked), followed by the parameters that apply.
|
||||
|
||||
## Rounding out queries
|
||||
|
||||
To round out our query introduction, there are a [number of other utilities and calls available](api.query.other.md) that allows the `api.query` user to perform certain tasks, such as querying state at a specific block. These are covered in the next section.
|
||||
@@ -1,76 +0,0 @@
|
||||
# Query extras
|
||||
|
||||
In previous sections we took a walk through queries, showing how to use one-shot queries, how to subscribe to results and how to combine multiple queries into one. This section will aim to extend that knowledge showing some other features and utilities that are available on the `api.query` interfaces.
|
||||
|
||||
## State at a specific block
|
||||
|
||||
Quite often is is useful (taking pruning into account, more on this later) to retrieve the state at a specific block. For instance we may wish to retrieve the current balance as well as the balance at a previous block for a specific account -
|
||||
|
||||
```js
|
||||
...
|
||||
|
||||
// Retrieve the current block header
|
||||
const lastHdr = await api.rpc.chain.getHeader();
|
||||
|
||||
// Retrieve the balance at both the current and the parent hashes
|
||||
const [balanceNow, balancePrev] = await Promise.all([
|
||||
api.query.balances.freeBalance.at(lastHdr.hash, ADDR),
|
||||
api.query.balances.freeBalance.at(lastHdr.parentHash, ADDR)
|
||||
]);
|
||||
|
||||
// Display the difference
|
||||
console.log(`The delta was ${balanceNow.sub(balancePrev)}`);
|
||||
```
|
||||
|
||||
In the above example, we introduce the `.at(<hash>[, ...params])` query. For all `.at` queries, the first parameter is always the block hash at which we want to make the query, in our example we use both the last retrieved block and the parent thereof. The params are optional as per the type of query made, for instance to retrieve the timestamp for a previous block, it would be -
|
||||
|
||||
```js
|
||||
...
|
||||
|
||||
// Retrieve the timestamp for the previous block
|
||||
const momentPrev = await api.query.timestamp.now.at(lastHdr.parentHash);
|
||||
```
|
||||
|
||||
The `.at` queries are all single-shot, i.e. there are no subscription option to these, since the state for a previous block should be static. (This is true to a certain extent, i.e. when blocks have been finalized).
|
||||
|
||||
An additional point to take care of (briefly mentioned above), is state pruning. By default a Polkadot/Substrate node will only keep state for the last 256 blocks, unless it is explicitly run in archive mode. This means that querying state further back than the pruning period will result in an error returned from the Node. (Generally most public RPC nodes only run with default settings, which includes aggressive state pruning)
|
||||
|
||||
## State entries
|
||||
|
||||
In addition to using `api.query` to make actual on-chain queries, it can also be used to retrieve some information on the state entries. For instance to retrieve both the hash and size of an existing entry, we can make the following calls -
|
||||
|
||||
```js
|
||||
...
|
||||
|
||||
// Retrieve the hash & size of the entry as stored on-chain
|
||||
const [entryHash, entrySize] = await Promise.all([
|
||||
api.query.balances.freeBalance.hash(ADDR),
|
||||
api.query.balances.freeBalance.size(ADDR)
|
||||
]);
|
||||
|
||||
// Output the info
|
||||
console.log(`The current size is ${entrySize} bytes with a hash of ${entryHash}`);
|
||||
```
|
||||
|
||||
As per the previous examples, the params here apply explicitly to the actual needed values to identify an entry. As with `.at` queries, there are no subscription versions for these queries, rather they are seen as one-shot values at a specific point in time.
|
||||
|
||||
## Entry metadata
|
||||
|
||||
It has been explained that the `api.query` interfaces are decorated from the metadata. This also means that there is some information that we can gather from the entry, as decorated -
|
||||
|
||||
```js
|
||||
// Extract the info
|
||||
const { meta, method, section } = api.query.balances.freeBalance;
|
||||
|
||||
// Display some info on a specific entry
|
||||
console.log(`${section}.${method}: ${meta.documentation.join(' ')}`);
|
||||
console.log(`query key: ${api.query.balances.freeBalance.key(ADDR)}`);
|
||||
```
|
||||
|
||||
The `section` & `method` is an indication of where it is exposed on the API. In addition the `meta` holds an array with the metadata documentation for the entry.
|
||||
|
||||
The `key` endpoint requires some explanation. In the chain state, the key values (identified by the module, method & params) are hashed and this is used as a lookup. So underlying a single-shot query would utilize the `api.rpc.state.getStorage` entry, passing the output of `key` (which is a hashed representation of the values). Apart from the hashing, the API also takes care of type formatting, handling optional values and merging results across multiple subscriptions.
|
||||
|
||||
## Let's transact already!
|
||||
|
||||
At this point you are already burning to actually make some transactions. Making queries is cool, but just how do [you actually submit transactions on-chain](api.tx.md).
|
||||
@@ -1,37 +0,0 @@
|
||||
# Query subscriptions
|
||||
|
||||
Previously we explained the concepts between `api.query`. In this section we will expand on that knowledge to introduce subscriptions (akin to what we found in `api.rpc`) to stream results from the state, as it changes between blocks.
|
||||
|
||||
## Subscriptions
|
||||
|
||||
As in the case with `api.rpc` subscriptions, query subscriptions follow exactly the same form - an actual call is augmented with a callback to return the current state value that is updated as the underlying value changes. As an example, we can extend on what we had previously -
|
||||
|
||||
```js
|
||||
...
|
||||
|
||||
// Retrieve the current timestamp via subscription
|
||||
const unsub = await api.query.timestamp.now((moment) => {
|
||||
console.log(`The last block has a timestamp of ${moment}`);
|
||||
});
|
||||
```
|
||||
|
||||
The form is exactly the same as the subscriptions we have seen previously, instead of the `await` returning the actual once-off value, it returns a subscription `unsub()` function that can be used to stop the subscription and clear up any underlying RPC connections. The supplied callback will contain the value as it changes, streamed from the node.
|
||||
|
||||
## Subscriptions with params
|
||||
|
||||
If we had a query with parameters, i.e. where we wish to perform a query for a specific account, the form is exactly the same - the last parameter contains the actual callback, after all other parameters. To retrieve the balances for an account as it changes, we could do the following -
|
||||
|
||||
```js
|
||||
...
|
||||
|
||||
// Subscribe to balance changes for our account
|
||||
const unsub = await api.query.balances.freeBalance(ADDR, (balance) => {
|
||||
console.log(`Your account balance is ${balance}`);
|
||||
});
|
||||
```
|
||||
|
||||
By now this subscription form should be familiar to you, including the usage of `unsub`.
|
||||
|
||||
## Multiple queries
|
||||
|
||||
In most non-trivial applications, it is useful to optimize both our code in terms of callbacks as well as node resources, for instance by [performing multiple queries at once, over the same RPC call](api.query.multi.md).
|
||||
@@ -1,70 +0,0 @@
|
||||
# RPC queries
|
||||
|
||||
The RPC calls provide the backbone for the transmission of data to and from the node. This means that all API endpoints such as `api.query`, `api.tx` or `api.derive` just wrap RPC calls, providing information in the encoded format as expected by the node.
|
||||
|
||||
Since you are already familiar with the `api.query` interface, the `api.rpc` interface follows the same format, for instance -
|
||||
|
||||
```js
|
||||
...
|
||||
|
||||
// Retrieve the chain name
|
||||
const chain = await api.rpc.system.chain();
|
||||
|
||||
// Retrieve the latest header
|
||||
const lastHeader = await api.rpc.chain.getHeader();
|
||||
|
||||
// Log the information
|
||||
console.log(`${chain}: last block #${lastHeader.number} has hash ${lastHeader.hash}`);
|
||||
```
|
||||
|
||||
In this example, you will see the same pattern as with queries: each result is a promise and a simple `await` makes the query and resolves with the result.
|
||||
|
||||
## Subscriptions
|
||||
|
||||
The RPCs lend themselves to using subscriptions, for instance in the above case you would assume that once connected, the chain won't change, however new blocks will come in at intervals and we probably want to keep track of those. We can adapt the previous example to start using subscriptions -
|
||||
|
||||
```js
|
||||
...
|
||||
|
||||
// Subscribe to the new headers
|
||||
await api.rpc.chain.subscribeNewHeads((lastHeader) => {
|
||||
console.log(`${chain}: last block #${lastHeader.number} has hash ${lastHeader.hash}`);
|
||||
});
|
||||
```
|
||||
|
||||
Since we are dealing with a subscription, we now pass a callback into the `subscribeNewHeads` function, and this will be triggered on each header, as they are imported. The same pattern would apply to each of the `api.rpc.subscribe*` functions - as a last parameter a callback is to be provided that streams the latest data, as it becomes available.
|
||||
|
||||
In general, whenever we create a subscription, we would like to cleanup after ourselves and unsubscribe, so assuming we only want to log the first 10 headers, the above example can be adjusted in the following manner -
|
||||
|
||||
```js
|
||||
...
|
||||
let count = 0;
|
||||
|
||||
// Subscribe to the new headers
|
||||
const unsubHeads = await api.rpc.chain.subscribeNewHeads((lastHeader) => {
|
||||
console.log(`${chain}: last block #${lastHeader.number} has hash ${lastHeader.hash}`);
|
||||
|
||||
if (++count === 10) {
|
||||
unsubHeads();
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Unlike single-shot queries, for subscriptions we are `await`-ing a function, taking no parameters (that also returns nothing) that can be used to unsubscribe for the subscription and clear the underlying RPC connection. So in the above example we set `unsubHeads` and then call it when we wish to cancel the subscription.
|
||||
|
||||
## Detour into derives
|
||||
|
||||
The `api.derive` interfaces will be covered in a follow-up section, but since the above example deals with new head subscriptions, a quick detour is warranted. The derives are just helpers that define certain functions and combine results from multiple sources. For new headers, the following information is useful in certain scenarios -
|
||||
|
||||
```js
|
||||
...
|
||||
const unsub = await api.derive.chain.subscribeNewHeads((lastHeader) => {
|
||||
console.log(`#${lastHeader.number} was authored by ${lastHeader.author}`);
|
||||
});
|
||||
```
|
||||
|
||||
In the above case the `subscribeNewHeads` derive augments the header retrieved with an `.author` getter. This is done by parsing the actual header and logs received and filling in the author from the `api.query.session.validators` call.
|
||||
|
||||
## Extended Queries
|
||||
|
||||
As a next step, now that we have understood subscription and RPC basics, we will circle back to the `api.query` interface, [extending our queries with subscriptions](api.query.subs.md).
|
||||
@@ -1,40 +0,0 @@
|
||||
# Transactions
|
||||
|
||||
Transaction endpoints are exposed, as determined by the metadata, on the `api.tx` endpoint. These allow you to submit transactions for inclusion in blocks, be it transfers, setting information or anything else your chain supports.
|
||||
|
||||
## Simple transactions
|
||||
|
||||
To start off, let's make a balance transfer from Alice to Bob.
|
||||
|
||||
```js
|
||||
...
|
||||
|
||||
// Sign and send a transfer from Alice to Bob
|
||||
const txHash = await api.tx.balances
|
||||
.transfer(BOB, 12345)
|
||||
.signAndSend(alice);
|
||||
|
||||
// Show the hash
|
||||
console.log(`Submitted with hash ${txHash}`);
|
||||
```
|
||||
|
||||
We have already become familiar with the `Promise` syntax that is used throughout the API, in this case it is no different. We construct a transaction by calling `balances.transfer(<accountId>, <value>)` with the required params and then as a next step we submit it to the node.
|
||||
|
||||
As with all other API operations, the `to` params just needs to be "account-like" and the value params needs to be "number-like", the API will take care of encoding and conversion into the correct format.
|
||||
|
||||
The result for this call (we will deal with subscriptions in a short while), is the transaction hash. This is a hash of the data and receiving this does not mean that transaction has been included, but rather only that it has been accepted for propagation by the node. (It can still fail on execution, we will handle this in some of our follow-up sections.)
|
||||
|
||||
## Under the hood
|
||||
|
||||
Despite the single-line format of `signAndSend`, there is a lot happening under the hood (and all of this can be manually provided) -
|
||||
|
||||
- Based on the sender, the API will retrieve the `system.accountNonce` to determine the next nonce to use
|
||||
- The API will retrieve the current block hash and use it to create a mortal transaction, i.e. the transaction will only be valid for a limited number of blocks (by default this is 5 mins at 6s block times)
|
||||
- It will construct a payload and sign this, this includes the `genesisHash`, the `blockHash` for the start of the mortal era as well as the current chain `specVersion`
|
||||
- The transaction is submitted to the node
|
||||
|
||||
As suggested, you can override all of this, i.e. by retrieving the nonce yourself and passing that as an option, i.e. `signAndSend(alice, { nonce: aliceNonce })`, this could be useful when manually tracking and submitting transactions in bulk.
|
||||
|
||||
## Into the keyring we go
|
||||
|
||||
With the examples above, the variable `alice` seems to have appeared from thin air. To understand how transactions are signed, we will take a [brief diversion into the keyring](keyring.md) before returning to our regularly scheduled program.
|
||||
@@ -1,65 +0,0 @@
|
||||
# Transaction subscriptions
|
||||
|
||||
Previously we sent simple transactions using the `api.tx` endpoints, in this section we will extend that to monitor the actual transactions for inclusion and also extend the monitoring for transaction events.
|
||||
|
||||
## Transaction inclusion
|
||||
|
||||
To send a transaction and then waiting until it has been included in a block, we will use a subscription interface instead of just waiting for the transaction pool addition to yield the extrinsic hash. For the simplest form, we can do the following -
|
||||
|
||||
```js
|
||||
...
|
||||
|
||||
// Create alice (carry-over from the keyring section)
|
||||
const alice = keyring.addFromUri('//Alice');
|
||||
|
||||
// Make a transfer from Alice to BOB, waiting for inclusion
|
||||
const unsub = await api.tx.balances
|
||||
.transfer(BOB, 12345)
|
||||
.signAndSend(alice, (result) => {
|
||||
console.log(`Current status is ${result.status}`);
|
||||
|
||||
if (result.status.isFinalized) {
|
||||
console.log(`Transaction included at blockHash ${result.status.asFinalized}`);
|
||||
unsub();
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
As per all previous subscriptions, the transaction subscription returns in `unsub()` and the actual method has a subscription callback. The `result` object has 2 parts, `events` (to to covered in the next section) and the `status` enum.
|
||||
|
||||
When the `status` enum is in `Finalized` state (checked via `isFinalized`), the underlying value contains the block hash of the block where the transaction has been included. This does not mean the block is finalized, but rather applies to the transaction state, as no further updates will be received for this subscription.
|
||||
|
||||
## Transaction events
|
||||
|
||||
Any transaction will emit events, as a bare minimum this will always be either a `system.ExtrinsicSuccess` or `system.ExtrinsicFailed` event for the specific transaction. These provide the overall execution result for the transaction, i.e. execution has succeeded or failed.
|
||||
|
||||
Depending on the transaction sent, some other events may however be emitted, for instance for a `balances.transfer` this could include one or more of `Transfer`, `NewAccount` or `ReapedAccount`, as defined in the [substrate balances event defaults](../substrate/events.md#balances).
|
||||
|
||||
To display or act on these events, we can do the following -
|
||||
|
||||
```js
|
||||
...
|
||||
// Make a transfer from Alice to BOB, waiting for inclusion
|
||||
const unsub = await api.tx.balances
|
||||
.transfer(BOB, 12345)
|
||||
.signAndSend(alice, ({ events = [], status }) => {
|
||||
console.log(`Current status is ${status.type}`);
|
||||
|
||||
if (status.isFinalized) {
|
||||
console.log(`Transaction included at blockHash ${status.asFinalized}`);
|
||||
|
||||
// Loop through Vec<EventRecord> to display all events
|
||||
events.forEach(({ phase, event: { data, method, section } }) => {
|
||||
console.log(`\t' ${phase}: ${section}.${method}:: ${data}`);
|
||||
});
|
||||
|
||||
unsub();
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Be aware that when a transaction status is `isFinalized`, it means it is included, but it may still have failed - for instance if you try to send a larger amount that you have free, the transaction is included in a block, however from a end-user perspective the transaction failed since the transfer did not occur. In these cases a `system.ExtrinsicFailed` event will be available in the events array.
|
||||
|
||||
## Complex transactions
|
||||
|
||||
In many cases transactions can carry quite complex information, be it for passing objects or proposing changes. In the next section we will take a dive [into complex transactions, including those wrapped for sudo](api.tx.wrap.md).
|
||||
@@ -1,44 +0,0 @@
|
||||
# Complex transactions
|
||||
|
||||
Up till now we have focussed on the base operation of transactions. There are however some more complex operations that deserve some more information, for instance when doing either democracy proposals or executing sudo calls, in both these cases the transaction wraps a call or proposal to be evaluated.
|
||||
|
||||
## Sudo use
|
||||
|
||||
When running a development chain (Polkadot/Substrate with a `--dev` flag), or in certain testnets a sudo module is available - just like the sudo command found on some systems, it allows root-level access to perform actions. For instance, we can perform a `setBalance(<accountId>, <free>, <reserved>)` on an account -
|
||||
|
||||
```js
|
||||
...
|
||||
// Get the current sudo key in the system
|
||||
const sudoKey = await api.query.sudo.key();
|
||||
|
||||
// Lookup from keyring (assuming we have added all, on --dev this would be `//Alice`)
|
||||
const sudoPair = keyring.getPair(sudoKey);
|
||||
|
||||
// Send the actual sudo transaction
|
||||
const unsub = await api.tx.sudo
|
||||
.sudo(
|
||||
api.tx.balances.setBalance(ADDR, 12345, 678)
|
||||
)
|
||||
.signAndSend(sudoPair, (result) => { ... });
|
||||
```
|
||||
|
||||
The above is really quite straight-forward, the `sudo.sudo(<call>)` call takes 1 parameter, which is a `Call`. We construct this via the `api.tx` and pass it through. The only difference is that the nested call has no actual `.signAndSend` on it, rather it is only used as a container for data.
|
||||
|
||||
Exactly the same would apply to the standard `democracy.propose(<proposal>, <value>)`, for instance we can just swap the above sudo wrapper with a proposal and add the correct fees for the proposal.
|
||||
|
||||
## Complex types
|
||||
|
||||
As indicated in previous sections (we will cover types in more detail next), the API will format the inputs into the actual type required for submission. For primitives such as numbers, this is quite understandable, but it is worth spending at least one example on cases where an object is provided as an input. For instance, making a call to validate -
|
||||
|
||||
```js
|
||||
...
|
||||
const txHash = await api.tx.staking.validate({
|
||||
validatorPayment: 12345
|
||||
});
|
||||
```
|
||||
|
||||
In the above example, all we need to provide is a the fields for the `ValidatorPrefs` object. (Any fields not defined will be set to the default for that type, i.e. all zero). This object maps through to what is defined on the Polkadot/Substrate side, with the [@polkadot/types version](https://github.com/polkadot-js/api/blob/master/packages/types/src/interfaces/staking/definitions.ts) mapping all fields.
|
||||
|
||||
## Understanding types
|
||||
|
||||
As has been very apparent in all the preceding sections, the management of types is what allows the API to communicate with the node. Most values are in a [binary SCALE-encoded format](https://github.com/paritytech/parity-scale-codec) and it is the responsibility of the API is to encode and decode these. In the next section we will [take a look at what interfaces the API provides around types](types.basics.md).
|
||||
@@ -1,34 +0,0 @@
|
||||
# Basics & Metadata
|
||||
|
||||
One of the most important things to understand about the `@polkadot/api` is that most interfaces are actually generated automatically when it connects to a running node. This is quite a departure from other APIs in projects where the interfaces are static. While sounding quite scary, it actually is a powerful concept that exists in both Polkadot and Substrate chains, and allows the API to be used in environments where the chain is customized.
|
||||
|
||||
To unpack this, we will start with the Metadata and explain what it actually provides, since it is critical for understanding how to interact with the API and any underlying chain.
|
||||
|
||||
## Metadata
|
||||
|
||||
When the API connects to a node, one of the first things it does is to retrieve the metadata. The metadata, effectively provides data in the form of `api.<type>.<module>.<section>` that fits into one of the following categories -
|
||||
|
||||
- [consts](../substrate/constants.md) - All runtime constants, e.g. `api.consts.balances.creationFee`. These are not functions, rather accessing the endpoint immediately yields the result as defined.
|
||||
- [query](../substrate/storage.md) - All chain state, e.g. `api.query.balances.freeBalance(<accountId>)`.
|
||||
- [tx](../substrate/extrinsics.md) - All extrinsics, e.g. `api.tx.balances.transfer(<accountId>, <value>)`.
|
||||
|
||||
Additionally the metadata also provides information on [events](../substrate/events.md), these are query-able via the `api.query.system.events()` interface and also appear on transactions... both these cases are detailed later.
|
||||
|
||||
## Types
|
||||
|
||||
The metadata defines the calls with all the type names used in the various interfaces. At the moment (this is undergoing investigations and could improve in future versions of metadata), this also means that the types between the API and the node need to be aligned. For instance, by default Substrate defines a `BlockNumber` type as a `u32` and the API follows the Substrate defaults - if a chain has a different definitions, the API needs to be aware of this so it can actually decode (and encode) the type.
|
||||
|
||||
At this point just be aware of it, we will touch on types, custom chains and their impacts in a later section.
|
||||
|
||||
## Chain Defaults
|
||||
|
||||
In addition to the `api.[consts | query | tx]` detailed above, the API, upon connecting to a chain, fills in some information and makes it available directly on the API interface. These include -
|
||||
|
||||
- `api.genesisHash` - The genesisHash of the connected chain
|
||||
- `api.runtimeMetadata` - The metadata as retrieved from the chain
|
||||
- `api.runtimeVersion` - The chain runtime version (including spec/impl. versions and types)
|
||||
- `api.libraryInfo` - The version of the API, i.e. `@polkadot/api v0.90.1`
|
||||
|
||||
## Let's do something!
|
||||
|
||||
Now that we have covered what the API actually exposes, it is time to [dive in and actually use what we installed earlier](create.md).
|
||||
@@ -1,79 +0,0 @@
|
||||
# Create an instance
|
||||
|
||||
We have the API installed, we have an understanding of what will actually be exposed and how the API knows what to expose. So down the rabbit hole we go - let's create an actual API instance, and then take it from there -
|
||||
|
||||
```js
|
||||
// Import
|
||||
import { ApiPromise, WsProvider } from '@polkadot/api';
|
||||
|
||||
...
|
||||
// Construct
|
||||
const wsProvider = new WsProvider('wss://poc-3.polkadot.io');
|
||||
const api = await ApiPromise.create({ provider: wsProvider });
|
||||
|
||||
// Do something
|
||||
console.log(api.genesisHash.toHex());
|
||||
```
|
||||
|
||||
We will have some explanation on the ES2015 syntax used next, but just a small note on the above - where other code is included (or just some previous boilerplate is used), you will see `...` in most of the examples. This is not due to laziness, but rather just to keep things straight and to the point.
|
||||
|
||||
## ES2015 Usage and examples
|
||||
|
||||
Before we jump into an explanation of the above example, be aware that in all cases we are using ES2015, including using things like `async`/`await`, `import` and others. Depending on your environment, this may require some adjustments.
|
||||
|
||||
While we are using the `await` naked in all examples (this removes boilerplate), it will need to be wrapped in an `async` block, for we could warp all samples inside a `async function main () { ... }` and then just call `main()`.
|
||||
|
||||
In the case of Node.js you would change the `import` into `require`, i.e.
|
||||
|
||||
```js
|
||||
// Import
|
||||
const { ApiPromise, WsProvider } = require('@polkadot/api');
|
||||
...
|
||||
```
|
||||
|
||||
We are basing all our examples on the [ApiPromise](../examples/promise/README.md) version of the API, however there is also an RxJS version available. Since Promises are a part of the ES2015 specification, it covers the greater amount of use and is the one that will be used in 95% of the cases and should be familiar to 100% of all developers. However if you are in an environment where RxJs is recommended or your have a great affinity ot it, you could take a look at the [RxJS examples](../examples/rx/README.md) once you are familiar with the base concepts introduced here.
|
||||
|
||||
For now... just ignore the various flavors and focus on understanding the concepts.
|
||||
|
||||
## Providers
|
||||
|
||||
Focusing on the construction, any API requires a provider and we create one via the `const wsProvider = new WsProvider(...)`. By default, if none is provided to the API it will construct a default `WsProvider` instance to connect to `ws://127.0.0.1:9944`.
|
||||
|
||||
We generally recommend always specifying the endpoint since in most cases we want to connect to an external node and even for local nodes, it is always better being explicit, less magic that can make you wonder in the future.
|
||||
|
||||
At this time the only provider type that is fully supported by the API is the WebSocket version. Polkadot/Substrate really comes alive with possibilities once you have access to bi-directional RPCs such as what WebSockets provide. (It is technically possible to have some limited capability via bare-HTTP, but at this point WebSockets is the only fully-operational and supported version - always remember that it is just "upgraded HTTP".)
|
||||
|
||||
## API Instance
|
||||
|
||||
The API creation is done via the `ApiPromise.create` interface which is a shortcut version for calling `new` and then waiting until the API is connected. Without the `async` syntax, this would be,
|
||||
|
||||
```js
|
||||
ApiPromise
|
||||
.create({ provider: wsProvider })
|
||||
.then((api) =>
|
||||
console.log(api.genesisHash.toHex())
|
||||
);
|
||||
```
|
||||
|
||||
In most cases we would suggest using the `.create` shortcut, which really just takes care of the following boilerplate that otherwise needs to be provided -
|
||||
|
||||
```js
|
||||
// Create the instance
|
||||
const api = new ApiPromise({ provider: wsProvider });
|
||||
|
||||
// Wait until we are ready and connected
|
||||
await api.isReady;
|
||||
|
||||
// Do something
|
||||
console.log(api.genesisHash.toHex());
|
||||
```
|
||||
|
||||
## Advanced creation
|
||||
|
||||
There are more advanced cases where you would prefer to use the longer version, for instance: if you want to explicitly listen to events emitted, you probably want to attach to the API even before connecting to the chain. All API instances implement an `EventEmitter` interface, with `on` handlers, which emit `connected`, `disconnected`, `ready` and `error` events, allowing you to listen to events on the transport layer.
|
||||
|
||||
In these cases, create via `new`, attach listeners and then wait for the `isReady`.
|
||||
|
||||
## Do something
|
||||
|
||||
Now that we have the API initialized, the next step would be to start using it to interact and extract data [starting with chain constants](api.consts.md).
|
||||
@@ -1,158 +0,0 @@
|
||||
# Extending extrinsics
|
||||
|
||||
On some chains, the need may arise to customize the extrinsic format. In this section we will explain what extrinsics and their payloads contain, explain how signed extensions work and provide a walk through of an advanced use-case where extrinsics are customized for a specific Substrate chain.
|
||||
|
||||
## Extensions
|
||||
|
||||
In Substrate (which forms the base of Polkadot and a number of custom chains), an extrinsic has a specific version, flag to indicating if it has been signed, the address, signature, extra data as well as the actual method with params. In addition, the signature is generated over the call and may include values that are not encoded into the final extrinsic.
|
||||
|
||||
For instance, with version 3 extrinsics, the signature payload contains the runtime spec version as well as the `genesisHash` and `blockHash` (the latter being equivalent to the `genesisHash` in case of immortal transactions), however while these 3 fields are signed together with the method data, they do not actually appear in the extrinsic itself. Rather the chain executing the transaction will retrieve this information, add it to the method data and compare the signatures thereof.
|
||||
|
||||
So in both the cases of the `genesisHash` and `specVersion`, if these do not match the signer version, the transaction won't be accepted - however the extrinsic doesn't explicitly carry this information in the data being transmitted, rather only implicitly as part of the signature. And it always forms part of the validation.
|
||||
|
||||
## Default extrinsics
|
||||
|
||||
With the above in-mind, the extrinsic format is explicitly defined as having the following structure in Substrate -
|
||||
|
||||
```rust
|
||||
pub struct UncheckedExtrinsic<Address, Call, Signature, Extra>
|
||||
where Extra: SignedExtension
|
||||
{
|
||||
pub signature: Option<(Address, Signature, Extra)>,
|
||||
pub function: Call,
|
||||
}
|
||||
```
|
||||
|
||||
The `Option` is here encoded such that is conveys both the extrinsic version `0x03` for Substrate 2.x chains (`0x01` for Substrate 1.x chains) as well as a high-bit that indicates if the transaction is signed or unsigned. (For unsigned the `signature` details therefore does not appear). The `SignedExtension` part defined both the data in the actual extrinsic as well as data, i.e. `AdditionalSigned`, that appears in the payload for the signature, but is not explicitly contained in the extrinsic.
|
||||
|
||||
The default `SignedExtension` for Substrate 2.x with extrinsic version 3 is defined as follow -
|
||||
|
||||
```rust
|
||||
pub type SignedExtra = (
|
||||
system::CheckVersion<Runtime>,
|
||||
system::CheckGenesis<Runtime>,
|
||||
system::CheckEra<Runtime>,
|
||||
system::CheckNonce<Runtime>,
|
||||
system::CheckWeight<Runtime>,
|
||||
balances::TakeFees<Runtime>,
|
||||
contracts::CheckBlockGasLimit<Runtime>,
|
||||
);
|
||||
```
|
||||
|
||||
Some of these are only checks, requiring no additional data in the payload or extrinsic itself, i.e. the contracts checks do exactly that. It only applies checks and invalidates when those checks are invalid. This is a powerful concept, for instance on the [initial Kusama chain this was used to limit the types of calls allowed](https://github.com/paritytech/polkadot/blob/f52c714ec3411eea58647d0f5176f4eb81660188/runtime/src/lib.rs#L117-L139).
|
||||
|
||||
## Extension deep-dive
|
||||
|
||||
For each of the default extensions, we will take a look through to understand the implications of the specific extension and how it relates to both the data contained in the extrinsic as well as the signature payload.
|
||||
|
||||
- `system::CheckVersion` - This checks that the spec version matches between the extrinsic and the chain. It takes no parameters which means that these is no explicit data in the extrinsic format for this field, however it has `type AdditionalSigned = u32` which means that a `u32` containing the runtime spec version is part of the signature payload.
|
||||
|
||||
- `system::CheckGenesis` - This checks that the `genesisHash` matches between extrinsic and chain. Like the previous check, no additional data is added to the extrinsic, however with `type AdditionalSigned = T::Hash`, the `genesisHash` is part of the signature payload.
|
||||
|
||||
- `system::CheckEra` - This checks the era (mortal or immortal) for the transaction being sent. It checks both the `era: Era` as part of the actual extrinsic and the `blockHash` via the `type AdditionalSigned = T::Hash`. This means that the extrinsic era is both in the data being signed and the extrinsic itself, while the `blockHash` the era applies to is only available in the signature payload.
|
||||
|
||||
- `system::CheckNonce` - This checks the nonce for the sending account. Unlike the preceding checks, it has no payload-specific data, however the `nonce: Compact<T::Index>` (`Index` is default `u32`) is applicable to both the extrinsic and, therefore, the actual signature payload as well.
|
||||
|
||||
- `system::CheckWeight` - This checks the weight and length of the block and ensure that it does not exceed the limits. It does not have any specific data attached to either the extrinsic nor payload, but rather just does calculations based on the weights and type of transaction received.
|
||||
|
||||
- `balances::TakeFees` - Consumes fees proportional to the length and weight of the transaction. It operates on the `fee: Compact<T::Balance>`, which means this value is included in both the extrinsic and subsequent payload being signed.
|
||||
|
||||
- `contracts::CheckBlockGasLimit` - As explained briefly above, this extension does not add data to the extrinsic, or the signature payload, however it ensures that the transaction does not exceeds the block gas limit.
|
||||
|
||||
## Extrinsic and signature payloads
|
||||
|
||||
With the above extension, the following formats for the extrinsic and payloads are the outcome of the application of the signed extension. For the extrinsic the following data is [always encoded for v3 extrinsics](https://github.com/polkadot-js/api/blob/8b0ef159c05bcb5d9b664546d0e7289e79b5c9d5/packages/types/src/primitive/Extrinsic/v3/Extrinsic.ts#L27) -
|
||||
|
||||
```js
|
||||
class ExtrinsicV3 extends Struct {
|
||||
constructor (value) {
|
||||
super({
|
||||
signer: 'Address',
|
||||
signature: 'Signature',
|
||||
era: 'ExtrinsicEra', // extra via system::CheckEra
|
||||
nonce: 'Compact<Index>', // extra via system::CheckNonce
|
||||
tip: 'Compact<Balance>', // extra via balances::TakeFees
|
||||
method: 'Call'
|
||||
}, value);
|
||||
}
|
||||
...
|
||||
```
|
||||
|
||||
The signature payload will contain the same information as the extrinsic, with the following [additional information](https://github.com/polkadot-js/api/blob/8b0ef159c05bcb5d9b664546d0e7289e79b5c9d5/packages/types/src/primitive/Extrinsic/v3/ExtrinsicPayload.ts#L33) as expected by the `AdditionalSigned` portions of the extensions -
|
||||
|
||||
```js
|
||||
class ExtrinsicPayloadV3 extends Struct {
|
||||
constructor (value) {
|
||||
super({
|
||||
method: 'Bytes',
|
||||
era: 'ExtrinsicEra', // extra via system::CheckEra
|
||||
nonce: 'Compact<Index>', // extra via system::CheckNonce
|
||||
tip: 'Compact<Balance>', // extra via balances::TakeFees
|
||||
specVersion: 'u32', // additional via system::CheckVersion
|
||||
genesisHash: 'Hash', // additional via system::CheckGenesis
|
||||
blockHash: 'Hash' // additional via system::CheckEra
|
||||
}, value);
|
||||
}
|
||||
...
|
||||
```
|
||||
|
||||
As per the above structures, it means that both the extrinsic sent on-chain as well as the data being signed to generate the signature is tied by the hip based on the logic the chain expects via `SignedExtension`. The API is only aware of the version of the extrinsic being used on-chain (it determines this on connection) and therefore only knows about the specific logic that has been coded for the extrinsic version.
|
||||
|
||||
## Extending existing or implementing new
|
||||
|
||||
When the API encodes or decodes an extrinsic, it uses the first `Option` byte to determine the version. Once it has this value, it will create a specific extrinsic via `createType('ExtrinsicV3', value)`. This means that at any point, you can supply your own version of either the `Extrinsic` or `ExtrinsicPayload` and you can do so via 2 avenues -
|
||||
|
||||
- If you are extending/replacing the existing version, you can inject your own types for both `ExtrinsicV3` and `ExtrinsicV3Payload` (assuming you are replacing v3)
|
||||
|
||||
- If you are adding a new version, you can add a handler for both `ExtrinsicUnknown` and `ExtrinsicPayloadUnknown`. These will be constructed when the version the API is aware of does not match with the on-chain version.
|
||||
|
||||
While we will not provide a full example of all the code here, the above links will show the existing implementations. However, assuming we have a chain where neither the nonce or tip is applicable (or we just don't care) and we are ignoring the check to the runtime versioning.
|
||||
|
||||
Additionally assuming that we have made the required `SignedExtension` updates by removing `system::CheckVersion`, `system::CheckNonce` and `balances::TakeFees`, we can do the following -
|
||||
|
||||
```js
|
||||
...
|
||||
class OwnExtrinsic extends Struct {
|
||||
constructor (value) {
|
||||
super({
|
||||
signer: 'Address',
|
||||
signature: 'Signature',
|
||||
era: 'ExtrinsicEra', // extra via system::CheckEra
|
||||
method: 'Call'
|
||||
}, value);
|
||||
}
|
||||
...
|
||||
}
|
||||
|
||||
class OwnExtrinsicPayload extends Struct {
|
||||
constructor (value) {
|
||||
super({
|
||||
method: 'Bytes',
|
||||
era: 'ExtrinsicEra', // extra via system::CheckEra
|
||||
genesisHash: 'Hash', // additional via system::CheckGenesis
|
||||
blockHash: 'Hash' // additional via system::CheckEra
|
||||
}, value);
|
||||
}
|
||||
...
|
||||
// signing logic needs to be included, as per existing
|
||||
}
|
||||
...
|
||||
|
||||
// inject our types at API construction
|
||||
const api = ApiPromise.create({
|
||||
types: {
|
||||
'ExtrinsicV3': OwnExtrinsic,
|
||||
'ExtrinsicV3Payload': OwnExtrinsicPayload,
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
The above example is certainly an advanced example, but it shows that all data types in the API can be adjusted and these adjustment can be provided to the API. In all cases, if you made updates to the formats and types of the actual runtime, you need to ensure that the API is aware of these changes.
|
||||
|
||||
In the above example, should these updates only be made on the node side, without the required API adjustments, the API will generate invalid transactions for the node since it is unaware of the changes and adjusted formats. Making the adjustments on only one side will mean that the signature verification can fail and that the format will not be decodable via the node.
|
||||
|
||||
(These extensions are not exposed via metadata at all, and would be quite difficult to do as well - since each of these have specific logic as well as data types assigned.)
|
||||
|
||||
## Using with TypeScript
|
||||
|
||||
The API is built with TypeScript (as are all projects in the [polkadot-js organization](https://github.com/polkadot-js/)) and as such allows developers using TS to have access to all the type interfaces defined on the chain, as well as having access to typings on interacting with the `api.*` namespaces. In the next section we will provide an overview of [what is available in terms of types and TypeScript](typescript.md).
|
||||
@@ -1,27 +0,0 @@
|
||||
# Installation
|
||||
|
||||
Yes, it really is as simple as [installing from npm](https://www.npmjs.com/package/@polkadot/api), so we are not going to waste too much time with the bare basics, just install the API via
|
||||
|
||||
`yarn add @polkadot/api`
|
||||
|
||||
And it will be added and ready for use. The above will always install the latest stable release, which should allow you to connect to test networks and local nodes that are tracking versioned releases for [Polkadot](https://github.com/paritytech/polkadot) and [Substrate](https://github.com/paritytech/substrate).
|
||||
|
||||
## Betas
|
||||
|
||||
For users who have a slightly higher appetite for risk, or are using bleeding-edge master branches of either Polkadot/Substrate, we also publish a beta version as soon as anything is merged into the API master branch. This version really contains all the latest fixes and features and is the version we actually use inside the polkadot-js projects - eating our own dog food.
|
||||
|
||||
To install a beta version, either to test or for support of a feature that is available in Substrate master (and has not yet made it to a stable api release), you can install it via the `@beta` tag, i.e.
|
||||
|
||||
`yarn add @polkadot/api@beta`
|
||||
|
||||
## Other dependencies
|
||||
|
||||
In most cases, you don't need to do anything else apart from just installing `@polkadot/api` above. It has dependencies such as `@polkadot/types` which are installed automatically alongside. When using `yarn` the dependencies are installed, flattened, available for use and you will never run into issues with mismatched versions.
|
||||
|
||||
This means that by simply installing `@polkadot/api`, you will have access to utilities (crypto and normal), types, providers and even higher-order (derived) API functions. (We will get to all of these in follow-up sections)
|
||||
|
||||
If you do however decide to explicitly install other packages (even though they are dependencies), please make sure that the versions inside the api package always match with your versions, i.e. if you installed `@polkadot/api` `0.91.0-beta.22` and you have your own version of `@polkadot/types`, ensure that it is also `0.91.0-beta.22`.
|
||||
|
||||
## API basics
|
||||
|
||||
So we have it installed. Before we jump into actual real-world usage, [let's understand what the API gives us](basics.md).
|
||||
@@ -1,119 +0,0 @@
|
||||
# Keyring
|
||||
|
||||
This section will give a quick introduction into the Keyring, including the addition of accounts, retrieving pairs and the signing of any data. Unlike the rest of the API, only the core concepts will be covered with the most-used-functions. However, what is covered is enough for 99.9 of the use-cases ... or rather, that is the aim.
|
||||
|
||||
## Installation
|
||||
|
||||
They [@polkadot/keyring](https://github.com/polkadot-js/common/tree/master/packages/keyring) keyring is included directly with the API as a dependency, so it is directly importable (since the 0.92 version) alongside the API.
|
||||
|
||||
If you do opt to install it separately, ensure that the version of `@polkadot/util-crypto` that is included with the API matches with the version of `@polkadot/keyring` installed. So if the API depends on `util-crypto 1.4.1`, it would make sense to include `keyring 1.4.1` as the installed version. (This helps in making sure extra versions of the libraries are not included as duplicates, especially in the case where bundles are created. Additionally, this makes sure that weird side-effects in the WASM initialization is avoided.)
|
||||
|
||||
## Creating a keyring instance
|
||||
|
||||
Once installed, you can create an instance by just creating an instance of the `Keyring` class -
|
||||
|
||||
```js
|
||||
// Import the keyring as required
|
||||
import { Keyring } from '@polkadot/api';
|
||||
|
||||
// Initialize the API as we would normally do
|
||||
...
|
||||
|
||||
// Create a keyring instance
|
||||
const keyring = new Keyring({ type: 'sr25519' });
|
||||
```
|
||||
|
||||
In the above example, the import is self-explanatory. Upon creation we pass through a `type` which can have a value of either `ed25519` or `sr25519`, when not specified this would default to `ed25519`. This type parameter only applies to the default type of account created when no type is specified, it does not mean that the keyring can only store that type of account.
|
||||
|
||||
So effectively, when creating an account and not specifying a type, it will be `sr25519` by default based on the above construction params, however we can also add an `ed25519` account and use it transparently in the same keyring.
|
||||
|
||||
One "trick" that is done implicitly in the above sample is that that keyring is only initialized after the API. In the case of `sr25519` the keyring relies on a [WASM build](https://github.com/polkadot-js/wasm) of the [schnorrkel libraries](https://github.com/w3f/schnorrkel). Since the API inlitialization is already async, it initializes the WASM libraries are part of the setup.
|
||||
|
||||
However, this initialization can also be done explicitly, mostly for more advances use-cases, or in cases where the API won't be attached until much later -
|
||||
|
||||
```js
|
||||
// Crypto promise, package used by keyring internally
|
||||
import { cryptoWaitReady } from '@polkadot/util-crypto';
|
||||
|
||||
// Wait for the promise to resolve, async WASM or `cryptoWaitReady().then(() => { ... })`
|
||||
await cryptoWaitReady();
|
||||
|
||||
// Create a keyring instance
|
||||
const keyring = new Keyring({ type: 'sr25519' });
|
||||
```
|
||||
|
||||
## Adding accounts
|
||||
|
||||
The recommended catch-all approach to adding accounts is via `.addFromUri(<suri>, [meta], [type])` function, where only the `suri` param is required. For instance to add an account via mnemonic, you would do the following -
|
||||
|
||||
```js
|
||||
...
|
||||
|
||||
// Some mnemonic phrase
|
||||
const PHRASE = 'entire material egg meadow latin bargain dutch coral blood melt acoustic thought';
|
||||
|
||||
// Add an account, straight mnemonic
|
||||
const newPair = keyring.addFromUri(PHRASE);
|
||||
|
||||
// (Advanced) add an account with a derivation path (hard & soft)
|
||||
const newDeri = keyring.addFromUri(`${PHRASE}//hard-derived/soft-derived`);
|
||||
|
||||
// (Advanced, development-only) add with an implied dev seed and hard derivation
|
||||
const alice = keyring.addFromUri('//Alice', { name: 'Alice default' });
|
||||
```
|
||||
|
||||
The above additions cater for most of the use cases and aligns with the you would find in the Substrate `subkey`. Be very wary of the last "dev-seed" option, it is explicitly added for `subkey` compatibility and implies using the "known-everywhere" dev seed. It is however useful when running Polkadot/Substrate with a `--dev` flag.
|
||||
|
||||
## Adding accounts with raw seeds
|
||||
|
||||
Since mnemonics are recommended and the defacto standard for current Polkadot/Substrate generations, the only mentioned way of adding keys thus far has been via mnemonic. However, the `addFromUri` method on the keyring is intelligent enough to detect and add from inputs specified as mnemonics, hex seeds and string seeds (appropriately padded).
|
||||
|
||||
With the above in mind, we could extend our examples above for custom raw seed. For instance to add both a hex and string seed, we can follow the following approach -
|
||||
|
||||
```js
|
||||
...
|
||||
// add a hex seed, 32-characters in length
|
||||
const hexPair = keyring.addFromUri('0x1234567890123456789012345678901234567890123456789012345678901234');
|
||||
|
||||
// add a string seed, internally this is padded with ' ' to 32-bytes in length
|
||||
const strPair = keyring.addFromUri('Janice');
|
||||
```
|
||||
|
||||
You could extend derivation from these specified seeds with derivation paths if applicable, i.e. `Janice//hard` will perform a hard derivation with the path `hard` on the pair that is generated from the `Janice` seed. As far as possible, try to stick with mnemonics in your applications, unless you have a good reason to not do so. Humans are generally bad at generating their own entropy and mnemonics has additional properties such as built-in checksums.
|
||||
|
||||
## Working with pairs
|
||||
|
||||
In the previous examples we added a pair to the keyring (and we actually immediately got access to the pair). From this pair there is some information we can retrieve -
|
||||
|
||||
```js
|
||||
...
|
||||
|
||||
// Add our Alice dev account
|
||||
const alice = keyring.addFromUri('//Alice', { name: 'Alice default' });
|
||||
|
||||
// Log some info
|
||||
console.log(`${alice.meta.name}: has address ${alice.address} with publicKey [${alice.publicKey}]`);
|
||||
```
|
||||
|
||||
Additionally you can sign and verify using the pairs. This is the same internally to the API when constructing transactions -
|
||||
|
||||
```js
|
||||
// Some helper functions used here
|
||||
import { stringToU8a, u8aToHex } from '@polkadot/util';
|
||||
|
||||
...
|
||||
|
||||
// Convert message, sign and then verify
|
||||
const message = stringToU8a('this is our message');
|
||||
const signature = alice.sign(message);
|
||||
const isValid = alice.verify(message, signature);
|
||||
|
||||
// Log info
|
||||
console.log(`The signature ${u8aToHex(signature)}, is ${isValid ? '' : 'in'}valid`);
|
||||
```
|
||||
|
||||
This covers the keyring basics, however there are two additional functions here of interest, `keyring.getPairs()` to retrieve a list of all pairs in the keyring and `keyring.getPair(<address or publicKey>)` to retrieve a pair where we have an identifier.
|
||||
|
||||
## Back to transactions
|
||||
|
||||
Now that we have short introduction to the keyring, we can move back to API transactions and find out [how to subscribe and track events](api.tx.subs.md), taking our management of transactions to the next level.
|
||||
@@ -1,84 +0,0 @@
|
||||
# Type basics
|
||||
|
||||
We've touched upon types in most previous sections, i.e. that these are driven by metadata and that they are created and converted to/from automatically by the API. Since they appear in all results, we will divert a bit from the regularly scheduled program in explaining the API interfaces to giving some info on the base types.
|
||||
|
||||
## Everything is a type
|
||||
|
||||
Just to re-iterate from the above. Everything returned by the API is a type and has a consistent interface. This means that a `Vec<u32>` (an array of `u32` values) as well as a `Struct` (an pre-defined object) or an `Enum` has the same consistent base interface. Specific types types will have values, based on the type - decorated and available.
|
||||
|
||||
As a minimum, anything returned by the API, be it a `Vec<...>`, `Option<...>`, `Struct` or any normal type will always have the following methods -
|
||||
|
||||
- `.eq(<other value>)` - checks for equality against the other value. In all cases, it will accept "like" values, i.e. in the case of a number you can pass a primitive (such as `1`), a hex value (such as `0x01`) or even an `Unit8Array`
|
||||
- `toHex()` - returns a hex-base representation of the value, always prefixed by `0x`
|
||||
- `toJSON()` - returns a JSON-like representation of the value, this is generally used when calling `JSON.stringify(...)` on the value
|
||||
- `toString()` - returns a string representation, in some cases this performs additional encoding, i.e. for `Address`, `AccountId` and `AccountIndex` it will encode to the ss58 address
|
||||
- `.toU8a()` - returns a `Uint8Array` representation of the encoded value (generally exactly as passed to the node, where values are SCALE encoded)
|
||||
|
||||
Additionally, the following getters and utilities are available -
|
||||
|
||||
- `.isEmpty` - `true` if the value is an all-empty value, i.e. `0` in for numbers, all-zero for Arrays (or anything `Uint8Array`), `false` is non-zero
|
||||
- `.hash` - a `Hash` (once again with all the methods above) that is a `blake2-256` representation of the contained value
|
||||
|
||||
## Comparing types
|
||||
|
||||
To reiterate the above API, the `.eq` method is the preferred means of comparing base types, rather than the JavaScript equality operator (`===`).
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
const { metadata } = await api.rpc.state.getMetadata();
|
||||
const modules = metadata.asV3.modules;
|
||||
|
||||
// This will not work, because `name` is an instance of `Text`, not a string
|
||||
// const system = modules.find(m => m.name === 'system');
|
||||
|
||||
// This will work, because `Text.eq()` can compare against a string
|
||||
const system = modules.find(m => m.name.eq('system'));
|
||||
```
|
||||
|
||||
## Working with numbers
|
||||
|
||||
All numbers wrap and extend an instance of [bn.js](https://github.com/indutny/bn.js/). This means that in addition to the interfaces defined above, they have some additional methods -
|
||||
|
||||
- `.toNumber()` - a JS number (limited to 2^53 - 1). This does mean that for large values, e.g. `Balance` (a `u128` extension), this can cause overflows
|
||||
- `.add(...)`, `.sub(...)`, ... - all the base methods available on the `BN` object
|
||||
|
||||
In cases where a `Compact` is returned, i.e. `Compact<Balance>`, the value is wrapped. This object should be `.unwrap()`-ed first to gain access to the underlying `Balance` object.
|
||||
|
||||
## Working with structures
|
||||
|
||||
All structures, a wrapping of an object containing a number of member variables, is an implementation of a standard JS `Map` object, so all the functions available on a `Map` such as `.entries()` are available. Additionally it is decorated with actual getters for the fields.
|
||||
|
||||
As an example, a `Header` will have getters for the `.parentHash`, `.number`, `.stateRoot`, `.extrinsicsRoot` and `.digest` fields. The same applies for all structures, as they are returned, each member will have an associated getter.
|
||||
|
||||
Be aware that in the JS version naming defaults to `camelCase` where names of fields in Substrate defaults to `snake_case`. (Each version aligning with conventions in the respective languages)
|
||||
|
||||
## Working with enums
|
||||
|
||||
Each enum has additional getters which are injected based on the fields wrapped. These take the form of `.is<Name>` and `.as<Name>` to allow you to check is the enum is a certain value or to retrieve the underlying value as a specific type.
|
||||
|
||||
As a real-world example, when an extrinsic is applied, the `Phase` enum has one of two states, `ApplyExtrinsic(u32)` or `Finalization`. In this case `.isApplyExtrinsic` would be `true` when an extrinsic is being applied, and `.asApplyExtrinsic` would return the value as a `u32` (which is the index of the extrinsic in the block, as it is being applied). When `isisApplyExtrinsic` is `false` and `asApplyExtrinsic` is called, the getter will throw.
|
||||
|
||||
## Working with Option<Type>
|
||||
|
||||
An `Option<Type>` attempts to mimic the Rust approach of having `None` and `Some` available. This means the following getters & methods are available on an `Option` -
|
||||
|
||||
- `.isNone` - is `true` if no underlying values is wrapped, effectively the same as `.isEmpty`
|
||||
- `.isSome` - this is `true` is a value is wrapped, i.e. if a `Option<u32>` has an actual underlying `u32`
|
||||
- `.unwrap()` - when `isSome`, this will return the wrapped value, i.e. for `Option<u32>`, this would return the `u32`. When the value is `isNone`, this call will throw an exception.
|
||||
- `.unwrapOr(<default value>)` - this extends `unwrap()`, returning the wrapped value when `isSome` and in the case of `isNone` it will return the `<default value>` passed.
|
||||
|
||||
## Working with Tuples
|
||||
|
||||
A tuple is defined in the form of `(u32, AccountId)`. To access the individual values, you can access t via the index, i.e.
|
||||
|
||||
```js
|
||||
// Assuming a tuple defined as `(32, AccountId)`
|
||||
const [count, accountId] = tuple;
|
||||
|
||||
console.log(`${accountId} has ${count.toNumber()} values`);
|
||||
```
|
||||
|
||||
## Extending types
|
||||
|
||||
For customized chains, the need exists to register types so the API is aware of how to decode values for those types. The next section will provide a [walk-through for the definition of custom types](types.extend.md) allowing the definition or re-definition of any type the API is aware of.
|
||||
@@ -1,142 +0,0 @@
|
||||
# Extending types
|
||||
|
||||
Circling back to metadata, by default the metadata information (at this point in time), only returns the type names as they apply to any section, be it a call, event or query. As an example, this means that transfers are defined as `balances.transfer(AccountId, Balance)` with no details as to the mapping of the `Balance` type to a `u128`. (The underlying Polkadot/Substrate default)
|
||||
|
||||
Therefore to cater for all types, a mapping in done on the [@polkadot/types library](https://github.com/polkadot-js/api/tree/master/packages/types/src/interfaces) to define each of the types and align with their underlying structures as it maps to a default Polkadot or Substrate chain.
|
||||
|
||||
Additionally, the API contains some logic for chain type detection, for instance in the case of Substrate 1.x based chains, it will define `BlockNumber` & `Index` (nonce) as a `u64`, while for current-generation chains, these will be defined as `u32`. Some of the work in maintaining the API for Polkadot/Substrate is the addition of types as they appear and gets used in the Rust codebase.
|
||||
|
||||
There is a the [recommendation](install.md#betas) to use a `@polkadot/api@beta` should you wish to track the master branches of Polkadot or Substrate, since master changes for the addition of new types do not make it into a stable release immediately.
|
||||
|
||||
## Extension
|
||||
|
||||
As a blockchain toolkit, Substrate makes it easy to add your own modules and types. In most non-trivial implementations, this would mean that developers are adding specific types for their implementation as well. The API will get to know the names of these types via the metadata, however it won't understand what they are, which means it cannot encode or decode them.
|
||||
|
||||
To close this gap, the API allows for the injection of types, i.e. you can explicitly define (or override) types for the node/chain you are connecting to. In the simplest example, assuming you have a chain where your `Balance` type is a `u64` (as opposed to the default `u128`), you need to let the API know -
|
||||
|
||||
```js
|
||||
...
|
||||
const api = await ApiPromise.create({
|
||||
provider: wsProvider,
|
||||
types: {
|
||||
Balance: 'u64'
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
The above introduces the `types` registry, effectively allowing overrides and the definition of new types. The override above would mean that immediately the API will treat all occurrences of `Balance` not as the default, but rather as the defined size.
|
||||
|
||||
## User-defined types
|
||||
|
||||
Registration also applies to any type that can be found on a specific chain, i.e. we can add any types that is available on a specific node -
|
||||
|
||||
```js
|
||||
...
|
||||
const api = await ApiPromise.create({
|
||||
...,
|
||||
types: {
|
||||
TransactionInput: {
|
||||
parentOutput: 'Hash',
|
||||
signature: 'Signature'
|
||||
},
|
||||
TransactionOutput: {
|
||||
value: 'u128',
|
||||
pubkey: 'Hash',
|
||||
sale: 'u32'
|
||||
},
|
||||
Transaction: {
|
||||
inputs: 'Vec<TransactionInput>',
|
||||
outputs: 'Vec<TransactionOutput>'
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
The example above defines non-primitive types (as found in the specific implementation) as structures. Additionally it also shows the user-defined types can depend on other user-defined types with `Transaction` referencing both `TransactionInput` and `TransactionOutput`. Here you can reference any known types, i.e. in the above we have referenced primitives such as `u32` and `Signature` (itself an alias for `H512`).
|
||||
|
||||
One form of types that appear regularly is enums, these can be defined as follow -
|
||||
|
||||
```js
|
||||
...
|
||||
const api = await ApiPromise.create({
|
||||
...,
|
||||
types: {
|
||||
CLikeEnum: {
|
||||
_enum: ['One', 'Two', 'Three']
|
||||
},
|
||||
TypedEnum: {
|
||||
_enum: {
|
||||
One: 'Compact<u32>',
|
||||
Two: 'u64',
|
||||
Three: 'Option<Balance>',
|
||||
Four: null
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
As seen in these examples, types are built up in terms of primitives and aligns with the Rust-type definition model with `Compact`, `Option` and `Vec`.
|
||||
|
||||
## Node and chain-specific types
|
||||
|
||||
There are cases where a single API object can be used to connect to different types of nodes or chains, each including their own specific types. For these cases the `typesChain` and `typesSpec` injectors are made available.
|
||||
|
||||
As a real-world example, the [polkadot-js/apps UI](https://github.com/polkadot-js/apps) can connect to a variety of chains. To support [Edgeware](https://edgewa.re/) by default, the following node-type (`specName` as per the runtime version) overrides are made -
|
||||
|
||||
```js
|
||||
import { IdentityTypes } from 'edgeware-node-types/dist/identity';
|
||||
import { SignalingTypes } from 'edgeware-node-types/dist/signaling';
|
||||
import { VotingTypes } from 'edgeware-node-types/dist/voting';
|
||||
|
||||
...
|
||||
const api = await ApiPromise.create({
|
||||
...,
|
||||
typesSpec: {
|
||||
edgeware: {
|
||||
...IdentityTypes,
|
||||
...SignalingTypes,
|
||||
...VotingTypes
|
||||
}
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
In the same way `typesChain` can be used to match on the actual chain name, i.e. for a chain such as Kusama, the following overrides can be made (as per example only - Kusama uses the Polkadot defaults, so no overrides are needed) -
|
||||
|
||||
```js
|
||||
...
|
||||
const api = await ApiPromise.create({
|
||||
...,
|
||||
typesChain: {
|
||||
'Kusama CC1': {
|
||||
BlockNumber: 'u32',
|
||||
Index: 'u32'
|
||||
}
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
The `types`, `typesChain` and `typesSpec` overrides are all optional and all are applied, as applicable to a specific connection. From the options `types` are registered first, followed by `typesSpec` for node-specific overrides and finally `typesChain` for chain-specific overrides. The would mean is you have the following (contrived) example,
|
||||
|
||||
```js
|
||||
...
|
||||
const api = await ApiPromise.create({
|
||||
...,
|
||||
types: {
|
||||
Balance: 'u32',
|
||||
}
|
||||
typesChain: {
|
||||
Balance: 'u128'
|
||||
},
|
||||
typesSpec: {
|
||||
Balance: 'u64',
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
`Balance` would be defined as an `u128` at the end. Effectively based on the flow it is first registered as a `u32`, then overridden as a `u64` and finally overridden once more as a `u128` by the chain types.
|
||||
|
||||
## Extending extrinsics
|
||||
|
||||
On customized chains, it is possible to [extend the format of the extrinsics and extrinsic payload as customized on the chain](extrinsic.extend.md), next up we will look at this advanced use-case.
|
||||
@@ -1,56 +0,0 @@
|
||||
# TypeScript interfaces
|
||||
|
||||
The API is written in TypeScript, and as such definitions for all actual exposed interfaces are available. In general terms, care has been taken to expose types via a `@polkadot/<package>/types` interface, for instance the `ApiOptions` type which is passed through on the `.create` interface is available under `@polkadot/api/types`.
|
||||
|
||||
## RPC interfaces
|
||||
|
||||
Before getting to the "hard things", i.e. methods as decorated based on metadata interfaces, let's take a look at more "static" interfaces such as RPC. (Be aware though that these can be customized on a per-chain basis as well - for now this functionality is not reflected in the API itself).
|
||||
|
||||
```js
|
||||
import { Header } from '@polkadot/types/interfaces';
|
||||
|
||||
...
|
||||
const firstHead = api.rpc.chain.getHeader();
|
||||
|
||||
api.rpc.chain.subscribeNewHeads((lastHead: Header): void => {
|
||||
console.log('current header:', JSON.stringify(lastHead));
|
||||
});
|
||||
```
|
||||
|
||||
In the above example a couple of things are introduced - most of the chain definitions (the default types for both Polkadot & Substrate) can be imported as interfaces from the `@polkadot/types/interfaces` endpoint. These are not classes (since they are [generated from definitions](https://github.com/polkadot-js/api/tree/master/packages/types/src/interfaces)) but rather a combination of TypeScript `interfaces` (where structures are involved) and `type`, i.e. `type Balance = u128`.
|
||||
|
||||
In the subscription example, we explicitly define `lastHead: Header`, although the same definition is missing for `firstHead`. However, in both these cases the definitions for the `api.rpc` sections are such that TypeScript understands that `firstHead` and `lastHead` are of type `Header`. The `: Header` here is rather for our own understanding (and could be needed based on your eslint/tslint config).
|
||||
|
||||
As indicated, most of the Polkadot/Substrate default types are available via `types/interfaces`. However, for primitives types where there is an actual implementation, these are made available via `@polkadot/types` directly. For instance, `import { u32 } from '@polkadot/types` is valid in this context.
|
||||
|
||||
## Metadata injected
|
||||
|
||||
For any interface injected by metadata, the types are not available by default (although it may be in the future for default interfaces), but rather what the API understands is that all results need to comply to the `Codec` interface. (The base of all our types)
|
||||
|
||||
However, to make this sane from a developer perspective the injected methods are generic, effectively making the following possible -
|
||||
|
||||
```js
|
||||
import { Balance, Index } from '@polkadot/types/interfaces';
|
||||
|
||||
...
|
||||
const nonce = await api.query.system.accountNonce<Index>(ADDR);
|
||||
const balance = await api.query.balances.freeBalance<Balance>(ADDR);
|
||||
```
|
||||
|
||||
In both these case we can instruct the TypeScript compiler that the type we are expecting in `Index` and `Balance` respectively, not just pure `Codec`. This means that functions like `.toNumber()` is available on both these types - as opposed to just the [general type defaults](types.basics.md#everything-is-a-type) with `.toHex()` and friends.
|
||||
|
||||
## Future work
|
||||
|
||||
As of this writing, there are still some gray areas to type detection, specifically around the following interfaces -
|
||||
|
||||
- `.at` & `.multi` on `api.query` does not (yet) have a `<TypeOverride>` interface. This means `as <TypeOverride>` casts are presently needed for these results
|
||||
- `api.queryMulti` does not (yet) allow you to provide a hint to the types returned, this ties to the previous point
|
||||
|
||||
In addition to expanding the type coverage, we wish to make the actual generation script for the types from `@polkadot/types/interfaces` available in 2 ways -
|
||||
|
||||
- allowing you to point to a folder of types and auto-generate the TypeScript typings from those. (Which is akin to what we do internally). This would allow a reduction in type classes explicitly written and injected.
|
||||
- once the metadata itself supports full type definitions, the script can be used to generate interface definitions specifically tailored for a chain
|
||||
|
||||
## And that's a wrap
|
||||
|
||||
This brings us to the end of our overview and jump through the API. While the documentation is still very much and ever evolving item, we can encourage you to try out what you have learned with some [examples](../examples). As we [indicated right at the start of this journey](README.md#help-us-help-others), if there are areas for improvement, let us know.
|
||||
@@ -1,3 +0,0 @@
|
||||
# Substrate
|
||||
|
||||
As part of a running node, some information is exposed as part of the metadata.
|
||||
@@ -1,225 +0,0 @@
|
||||
## Constants
|
||||
|
||||
The following sections contain the module constants, also known as parameter types. These can only be changed as part of a runtime upgrade. On the api, these are exposed via `api.consts.<module>.<method>`.
|
||||
|
||||
(NOTE: These were generated from a static/snapshot view of a recent Substrate master node. Some items may not be available in older nodes, or in any customized implementations.)
|
||||
- **[babe](#babe)**
|
||||
|
||||
- **[balances](#balances)**
|
||||
|
||||
- **[contracts](#contracts)**
|
||||
|
||||
- **[democracy](#democracy)**
|
||||
|
||||
- **[elections](#elections)**
|
||||
|
||||
- **[finalityTracker](#finalityTracker)**
|
||||
|
||||
- **[session](#session)**
|
||||
|
||||
- **[staking](#staking)**
|
||||
|
||||
- **[timestamp](#timestamp)**
|
||||
|
||||
- **[treasury](#treasury)**
|
||||
|
||||
|
||||
___
|
||||
|
||||
|
||||
### babe
|
||||
|
||||
▸ **epochDuration**: `u64`
|
||||
- **summary**: The number of **slots** that an epoch takes. We couple sessions to epochs, i.e. we start a new session once the new epoch begins.
|
||||
|
||||
▸ **expectedBlockTime**: `Moment`
|
||||
- **summary**: The expected average block time at which BABE should be creating blocks. Since BABE is probabilistic it is not trivial to figure out what the expected average block time should be based on the slot duration and the security parameter `c` (where `1 - c` represents the probability of a slot being empty).
|
||||
|
||||
___
|
||||
|
||||
|
||||
### balances
|
||||
|
||||
▸ **creationFee**: `Balance`
|
||||
- **summary**: The fee required to create an account.
|
||||
|
||||
▸ **existentialDeposit**: `Balance`
|
||||
- **summary**: The minimum amount required to keep an account open.
|
||||
|
||||
▸ **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.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### contracts
|
||||
|
||||
▸ **blockGasLimit**: `Gas`
|
||||
- **summary**: The maximum amount of gas that could be expended per block. A reasonable default value is 10_000_000.
|
||||
|
||||
▸ **callBaseFee**: `Gas`
|
||||
- **summary**: The base fee charged for calling into a contract. A reasonable default value is 135.
|
||||
|
||||
▸ **contractFee**: `BalanceOf`
|
||||
- **summary**: The fee required to instantiate a contract instance. A reasonable default value is 21.
|
||||
|
||||
▸ **creationFee**: `BalanceOf`
|
||||
- **summary**: The fee required to create an account.
|
||||
|
||||
▸ **instantiateBaseFee**: `Gas`
|
||||
- **summary**: The base fee charged for instantiating a contract. A reasonable default value is 175.
|
||||
|
||||
▸ **maxDepth**: `u32`
|
||||
- **summary**: The maximum nesting level of a call/instantiate stack. A reasonable default value is 100.
|
||||
|
||||
▸ **maxValueSize**: `u32`
|
||||
- **summary**: The maximum size of a storage value in bytes. A reasonable default is 16 KiB.
|
||||
|
||||
▸ **rentByteFee**: `BalanceOf`
|
||||
- **summary**: Price of a byte of storage per one block interval. Should be greater than 0.
|
||||
|
||||
▸ **rentDepositOffset**: `BalanceOf`
|
||||
- **summary**: The amount of funds a contract should deposit in order to offset the cost of one byte. Let's suppose the deposit is 1,000 BU (balance units)/byte and the rent is 1 BU/byte/day, then a contract with 1,000,000 BU that uses 1,000 bytes of storage would pay no rent. But if the balance reduced to 500,000 BU and the storage stayed the same at 1,000, then it would pay 500 BU/day.
|
||||
|
||||
▸ **signedClaimHandicap**: `BlockNumber`
|
||||
- **summary**: Number of block delay an extrinsic claim surcharge has. When claim surcharge is called by an extrinsic the rent is checked for current_block - delay
|
||||
|
||||
▸ **storageSizeOffset**: `u32`
|
||||
- **summary**: Size of a contract at the time of instantiaion. This is a simple way to ensure that empty contracts eventually gets deleted.
|
||||
|
||||
▸ **surchargeReward**: `BalanceOf`
|
||||
- **summary**: Reward that is received by the party whose touch has led to removal of a contract.
|
||||
|
||||
▸ **tombstoneDeposit**: `BalanceOf`
|
||||
- **summary**: The minimum amount required to generate a tombstone.
|
||||
|
||||
▸ **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.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### democracy
|
||||
|
||||
▸ **cooloffPeriod**: `BlockNumber`
|
||||
- **summary**: Period in blocks where an external proposal may not be re-submitted after being vetoed.
|
||||
|
||||
▸ **emergencyVotingPeriod**: `BlockNumber`
|
||||
- **summary**: Minimum voting period allowed for an emergency referendum.
|
||||
|
||||
▸ **enactmentPeriod**: `BlockNumber`
|
||||
- **summary**: The minimum period of locking and the period between a proposal being approved and enacted. It should generally be a little more than the unstake period to ensure that voting stakers have an opportunity to remove themselves from the system in the case where they are on the losing side of a vote.
|
||||
|
||||
▸ **launchPeriod**: `BlockNumber`
|
||||
- **summary**: How often (in blocks) new public referenda are launched.
|
||||
|
||||
▸ **minimumDeposit**: `BalanceOf`
|
||||
- **summary**: The minimum amount to be used as a deposit for a public referendum proposal.
|
||||
|
||||
▸ **votingPeriod**: `BlockNumber`
|
||||
- **summary**: How often (in blocks) to check for new votes.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### elections
|
||||
|
||||
▸ **approvalSetSize**: `u32`
|
||||
- **summary**: The chunk size of the approval vector.
|
||||
|
||||
▸ **candidacyBond**: `BalanceOf`
|
||||
- **summary**: How much should be locked up in order to submit one's candidacy. A reasonable default value is 9.
|
||||
|
||||
▸ **carryCount**: `u32`
|
||||
- **summary**: How many runners-up should have their approvals persist until the next vote. A reasonable default value is 2.
|
||||
|
||||
▸ **decayRatio**: `u32`
|
||||
- **summary**: Decay factor of weight when being accumulated. It should typically be set to __at least__ `membership_size -1` to keep the collective secure. When set to `N`, it indicates `(1/N)^t` of staked is decayed at weight increment step `t`. 0 will result in no weight being added at all (normal approval voting). A reasonable default value is 24.
|
||||
|
||||
▸ **inactiveGracePeriod**: `VoteIndex`
|
||||
- **summary**: How many vote indices need to go by after a target voter's last vote before they can be reaped if their approvals are moot. A reasonable default value is 1.
|
||||
|
||||
▸ **minimumVotingLock**: `BalanceOf`
|
||||
- **summary**: Minimum about that can be used as the locked value for voting.
|
||||
|
||||
▸ **presentSlashPerVoter**: `BalanceOf`
|
||||
- **summary**: The punishment, per voter, if you provide an invalid presentation. A reasonable default value is 1.
|
||||
|
||||
▸ **voterSetSize**: `u32`
|
||||
- **summary**: The chunk size of the voter vector.
|
||||
|
||||
▸ **votingBond**: `BalanceOf`
|
||||
- **summary**: How much should be locked up in order to be able to submit votes.
|
||||
|
||||
▸ **votingFee**: `BalanceOf`
|
||||
- **summary**: The amount of fee paid upon each vote submission, unless if they submit a _hole_ index and replace it.
|
||||
|
||||
▸ **votingPeriod**: `BlockNumber`
|
||||
- **summary**: How often (in blocks) to check for new votes. A reasonable default value is 1000.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### finalityTracker
|
||||
|
||||
▸ **reportLatency**: `BlockNumber`
|
||||
- **summary**: The delay after which point things become suspicious. Default is 1000.
|
||||
|
||||
▸ **windowSize**: `BlockNumber`
|
||||
- **summary**: The number of recent samples to keep from this chain. Default is 101.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### session
|
||||
|
||||
▸ **dedupKeyPrefix**: `Bytes`
|
||||
- **summary**: Used as first key for `NextKeys` and `KeyOwner` to put all the data into the same branch of the trie.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### staking
|
||||
|
||||
▸ **bondingDuration**: `EraIndex`
|
||||
- **summary**: Number of eras that staked funds must remain bonded for.
|
||||
|
||||
▸ **sessionsPerEra**: `SessionIndex`
|
||||
- **summary**: Number of sessions per era.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### timestamp
|
||||
|
||||
▸ **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.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### treasury
|
||||
|
||||
▸ **burn**: `Permill`
|
||||
- **summary**: Percentage of spare funds (if any) that are burnt per spend period.
|
||||
|
||||
▸ **proposalBond**: `Permill`
|
||||
- **summary**: Fraction of a proposal's value that should be bonded in order to place the proposal. An accepted proposal gets these back. A rejected proposal does not.
|
||||
|
||||
▸ **proposalBondMinimum**: `BalanceOf`
|
||||
- **summary**: Minimum amount of funds that should be placed in a deposit for making a proposal.
|
||||
|
||||
▸ **spendPeriod**: `BlockNumber`
|
||||
- **summary**: Period between successive spends.
|
||||
@@ -1,298 +0,0 @@
|
||||
## Events
|
||||
|
||||
Events are emitted for certain operations on the runtime. The following sections describe the events that are part of the default Substrate runtime.
|
||||
|
||||
(NOTE: These were generated from a static/snapshot view of a recent Substrate master node. Some items may not be available in older nodes, or in any customized implementations.)
|
||||
- **[balances](#balances)**
|
||||
|
||||
- **[contracts](#contracts)**
|
||||
|
||||
- **[council](#council)**
|
||||
|
||||
- **[democracy](#democracy)**
|
||||
|
||||
- **[elections](#elections)**
|
||||
|
||||
- **[grandpa](#grandpa)**
|
||||
|
||||
- **[imOnline](#imOnline)**
|
||||
|
||||
- **[indices](#indices)**
|
||||
|
||||
- **[offences](#offences)**
|
||||
|
||||
- **[session](#session)**
|
||||
|
||||
- **[staking](#staking)**
|
||||
|
||||
- **[sudo](#sudo)**
|
||||
|
||||
- **[system](#system)**
|
||||
|
||||
- **[technicalCommittee](#technicalCommittee)**
|
||||
|
||||
- **[technicalMembership](#technicalMembership)**
|
||||
|
||||
- **[treasury](#treasury)**
|
||||
|
||||
- **[utility](#utility)**
|
||||
|
||||
|
||||
___
|
||||
|
||||
|
||||
### 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).
|
||||
|
||||
___
|
||||
|
||||
|
||||
### contracts
|
||||
|
||||
▸ **CodeStored**(`Hash`)
|
||||
- **summary**: Code with the specified hash has been stored.
|
||||
|
||||
▸ **Contract**(`AccountId`, `Bytes`)
|
||||
- **summary**: An event from contract of account.
|
||||
|
||||
▸ **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 `instantiate`.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### council
|
||||
|
||||
▸ **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.
|
||||
|
||||
▸ **MemberExecuted**(`Hash`, `bool`)
|
||||
- **summary**: A single member did some action; `bool` is true if returned without error.
|
||||
|
||||
▸ **Proposed**(`AccountId`, `ProposalIndex`, `Hash`, `MemberCount`)
|
||||
- **summary**: A motion (given hash) has been proposed (by given account) with a threshold (given `MemberCount`).
|
||||
|
||||
▸ **Voted**(`AccountId`, `Hash`, `bool`, `MemberCount`, `MemberCount`)
|
||||
- **summary**: A motion (given hash) has been voted on by given account, leaving a tally (yes votes and no votes given respectively as `MemberCount`).
|
||||
|
||||
___
|
||||
|
||||
|
||||
### democracy
|
||||
|
||||
▸ **Cancelled**(`ReferendumIndex`)
|
||||
|
||||
▸ **Delegated**(`AccountId`, `AccountId`)
|
||||
|
||||
▸ **Executed**(`ReferendumIndex`, `bool`)
|
||||
|
||||
▸ **ExternalTabled**()
|
||||
|
||||
▸ **NotPassed**(`ReferendumIndex`)
|
||||
|
||||
▸ **Passed**(`ReferendumIndex`)
|
||||
|
||||
▸ **Proposed**(`PropIndex`, `Balance`)
|
||||
|
||||
▸ **Started**(`ReferendumIndex`, `VoteThreshold`)
|
||||
|
||||
▸ **Tabled**(`PropIndex`, `Balance`, `Vec<AccountId>`)
|
||||
|
||||
▸ **Undelegated**(`AccountId`)
|
||||
|
||||
▸ **Vetoed**(`AccountId`, `Hash`, `BlockNumber`)
|
||||
|
||||
___
|
||||
|
||||
|
||||
### elections
|
||||
|
||||
▸ **BadReaperSlashed**(`AccountId`)
|
||||
- **summary**: slashed reaper
|
||||
|
||||
▸ **TallyFinalized**(`Vec<AccountId>`, `Vec<AccountId>`)
|
||||
- **summary**: A tally (for approval votes of seat(s)) has ended (with one or more new members).
|
||||
|
||||
▸ **TallyStarted**(`u32`)
|
||||
- **summary**: A tally (for approval votes of seat(s)) has started.
|
||||
|
||||
▸ **VoterReaped**(`AccountId`, `AccountId`)
|
||||
- **summary**: reaped voter, reaper
|
||||
|
||||
___
|
||||
|
||||
|
||||
### grandpa
|
||||
|
||||
▸ **NewAuthorities**(`Vec<(AuthorityId,AuthorityWeight)>`)
|
||||
- **summary**: New authority set has been applied.
|
||||
|
||||
▸ **Paused**()
|
||||
- **summary**: Current authority set has been paused.
|
||||
|
||||
▸ **Resumed**()
|
||||
- **summary**: Current authority set has been resumed.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### imOnline
|
||||
|
||||
▸ **HeartbeatReceived**(`AuthorityId`)
|
||||
- **summary**: A new heartbeat was received from `AuthorityId`
|
||||
|
||||
___
|
||||
|
||||
|
||||
### 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`.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### offences
|
||||
|
||||
▸ **Offence**(`Kind`, `OpaqueTimeSlot`)
|
||||
- **summary**: There is an offence reported of the given `kind` happened at the `session_index` and (kind-specific) time slot. This event is not deposited for duplicate slashes.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### session
|
||||
|
||||
▸ **NewSession**(`SessionIndex`)
|
||||
- **summary**: New session has happened. Note that the argument is the session index, not the block number as the type might suggest.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### staking
|
||||
|
||||
▸ **OldSlashingReportDiscarded**(`SessionIndex`)
|
||||
- **summary**: An old slashing report from a prior era was discarded because it could not be processed.
|
||||
|
||||
▸ **Reward**(`Balance`)
|
||||
- **summary**: All validators have been rewarded by the given balance.
|
||||
|
||||
▸ **Slash**(`AccountId`, `Balance`)
|
||||
- **summary**: One validator (and its nominators) has been slashed by the given amount.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### sudo
|
||||
|
||||
▸ **KeyChanged**(`AccountId`)
|
||||
- **summary**: The sudoer just switched identity; the old key is supplied.
|
||||
|
||||
▸ **Sudid**(`bool`)
|
||||
- **summary**: A sudo just took place.
|
||||
|
||||
▸ **SudoAsDone**(`bool`)
|
||||
- **summary**: A sudo just took place.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### system
|
||||
|
||||
▸ **ExtrinsicFailed**(`DispatchError`)
|
||||
- **summary**: An extrinsic failed.
|
||||
|
||||
▸ **ExtrinsicSuccess**()
|
||||
- **summary**: An extrinsic completed successfully.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### technicalCommittee
|
||||
|
||||
▸ **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.
|
||||
|
||||
▸ **MemberExecuted**(`Hash`, `bool`)
|
||||
- **summary**: A single member did some action; `bool` is true if returned without error.
|
||||
|
||||
▸ **Proposed**(`AccountId`, `ProposalIndex`, `Hash`, `MemberCount`)
|
||||
- **summary**: A motion (given hash) has been proposed (by given account) with a threshold (given `MemberCount`).
|
||||
|
||||
▸ **Voted**(`AccountId`, `Hash`, `bool`, `MemberCount`, `MemberCount`)
|
||||
- **summary**: A motion (given hash) has been voted on by given account, leaving a tally (yes votes and no votes given respectively as `MemberCount`).
|
||||
|
||||
___
|
||||
|
||||
|
||||
### technicalMembership
|
||||
|
||||
▸ **Dummy**(`PhantomData`)
|
||||
- **summary**: Phantom member, never used.
|
||||
|
||||
▸ **MemberAdded**()
|
||||
- **summary**: The given member was added; see the transaction for who.
|
||||
|
||||
▸ **MemberRemoved**()
|
||||
- **summary**: The given member was removed; see the transaction for who.
|
||||
|
||||
▸ **MembersReset**()
|
||||
- **summary**: The membership was reset; see the transaction for who the new set is.
|
||||
|
||||
▸ **MembersSwapped**()
|
||||
- **summary**: Two members were swapped; see the transaction for who.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### 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.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### utility
|
||||
|
||||
▸ **BatchExecuted**(`Vec<DispatchResult>`)
|
||||
@@ -1,370 +0,0 @@
|
||||
## Extrinsics
|
||||
|
||||
The following sections contain Extrinsics methods are part of the default Substrate runtime. On the api, these are exposed via `api.tx.<module>.<method>`.
|
||||
|
||||
(NOTE: These were generated from a static/snapshot view of a recent Substrate master node. Some items may not be available in older nodes, or in any customized implementations.)
|
||||
- **[authorship](#authorship)**
|
||||
|
||||
- **[balances](#balances)**
|
||||
|
||||
- **[contracts](#contracts)**
|
||||
|
||||
- **[council](#council)**
|
||||
|
||||
- **[democracy](#democracy)**
|
||||
|
||||
- **[elections](#elections)**
|
||||
|
||||
- **[finalityTracker](#finalityTracker)**
|
||||
|
||||
- **[grandpa](#grandpa)**
|
||||
|
||||
- **[imOnline](#imOnline)**
|
||||
|
||||
- **[session](#session)**
|
||||
|
||||
- **[staking](#staking)**
|
||||
|
||||
- **[sudo](#sudo)**
|
||||
|
||||
- **[system](#system)**
|
||||
|
||||
- **[technicalCommittee](#technicalCommittee)**
|
||||
|
||||
- **[technicalMembership](#technicalMembership)**
|
||||
|
||||
- **[timestamp](#timestamp)**
|
||||
|
||||
- **[treasury](#treasury)**
|
||||
|
||||
- **[utility](#utility)**
|
||||
|
||||
|
||||
___
|
||||
|
||||
|
||||
### authorship
|
||||
|
||||
▸ **setUncles**(new_uncles: `Vec<Header>`)
|
||||
- **summary**: Provide a set of uncles.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### balances
|
||||
|
||||
▸ **forceTransfer**(source: `Address`, dest: `Address`, value: `Compact<Balance>`)
|
||||
- **summary**: Exactly as `transfer`, except the origin must be root and the source account may be specified.
|
||||
|
||||
▸ **setBalance**(who: `Address`, new_free: `Compact<Balance>`, new_reserved: `Compact<Balance>`)
|
||||
- **summary**: Set the balances of a given account. This will alter `FreeBalance` and `ReservedBalance` in storage. it will also decrease the total issuance of the system (`TotalIssuance`). If the new free or reserved balance is below the existential deposit, it will reset the account nonce (`system::AccountNonce`). The dispatch origin for this call is `root`. # <weight> - Independent of the arguments. - Contains a limited number of reads and writes. # </weight>
|
||||
|
||||
▸ **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. # <weight> - Dependent on arguments but not critical, given proper implementations for input config types. See related functions below. - It contains a limited number of reads and writes internally and no complex computation. Related functions: - `ensure_can_withdraw` is always called internally but has a bounded complexity. - Transferring balances to accounts that did not exist before will cause `T::OnNewAccount::on_new_account` to be called. - Removing enough funds from an account will trigger `T::DustRemoval::on_unbalanced` and `T::OnFreeBalanceZero::on_free_balance_zero`. # </weight>
|
||||
|
||||
___
|
||||
|
||||
|
||||
### contracts
|
||||
|
||||
▸ **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.
|
||||
|
||||
▸ **claimSurcharge**(dest: `AccountId`, aux_sender: `Option<AccountId>`)
|
||||
- **summary**: Allows block producers to claim a small reward for evicting a contract. If a block producer fails to do so, a regular users will be allowed to claim the reward. If contract is not evicted as a result of this call, no actions are taken and the sender is not eligible for the reward.
|
||||
|
||||
▸ **instantiate**(endowment: `Compact<BalanceOf>`, gas_limit: `Compact<Gas>`, code_hash: `CodeHash`, data: `Bytes`)
|
||||
- **summary**: Instantiates a new contract from the `codehash` generated by `put_code`, optionally transferring some balance. Instantiation 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 chain's 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
|
||||
|
||||
▸ **execute**(proposal: `Proposal`)
|
||||
- **summary**: Dispatch a proposal from a member using the `Member` origin. Origin must be a member of the collective.
|
||||
|
||||
▸ **propose**(threshold: `Compact<MemberCount>`, proposal: `Proposal`)
|
||||
- **summary**: # <weight> - Bounded storage reads and writes. - Argument `threshold` has bearing on weight. # </weight>
|
||||
|
||||
▸ **setMembers**(new_members: `Vec<AccountId>`)
|
||||
- **summary**: Set the collective's membership manually to `new_members`. Be nice to the chain and provide it pre-sorted. Requires root origin.
|
||||
|
||||
▸ **vote**(proposal: `Hash`, index: `Compact<ProposalIndex>`, approve: `bool`)
|
||||
- **summary**: # <weight> - Bounded storage read and writes. - Will be slightly heavier if the proposal is approved / disapproved after the vote. # </weight>
|
||||
|
||||
___
|
||||
|
||||
|
||||
### democracy
|
||||
|
||||
▸ **cancelQueued**(when: `Compact<BlockNumber>`, which: `Compact<u32>`, what: `Compact<ReferendumIndex>`)
|
||||
- **summary**: Cancel a proposal queued for enactment.
|
||||
|
||||
▸ **cancelReferendum**(ref_index: `Compact<ReferendumIndex>`)
|
||||
- **summary**: Remove a referendum.
|
||||
|
||||
▸ **delegate**(to: `AccountId`, conviction: `Conviction`)
|
||||
- **summary**: Delegate vote. # <weight> - One extra DB entry. # </weight>
|
||||
|
||||
▸ **emergencyCancel**(ref_index: `ReferendumIndex`)
|
||||
- **summary**: Schedule an emergency cancellation of a referendum. Cannot happen twice to the same referendum.
|
||||
|
||||
▸ **externalPropose**(proposal: `Proposal`)
|
||||
- **summary**: Schedule a referendum to be tabled once it is legal to schedule an external referendum.
|
||||
|
||||
▸ **externalProposeDefault**(proposal: `Proposal`)
|
||||
- **summary**: Schedule a negative-turnout-bias referendum to be tabled next once it is legal to schedule an external referendum. Unlike `external_propose`, blacklisting has no effect on this and it may replace a pre-scheduled `external_propose` call.
|
||||
|
||||
▸ **externalProposeMajority**(proposal: `Proposal`)
|
||||
- **summary**: Schedule a majority-carries referendum to be tabled next once it is legal to schedule an external referendum. Unlike `external_propose`, blacklisting has no effect on this and it may replace a pre-scheduled `external_propose` call.
|
||||
|
||||
▸ **fastTrack**(proposal_hash: `Hash`, voting_period: `BlockNumber`, delay: `BlockNumber`)
|
||||
- **summary**: Schedule the currently externally-proposed majority-carries referendum to be tabled immediately. If there is no externally-proposed referendum currently, or if there is one but it is not a majority-carries referendum then it fails. - `proposal_hash`: The hash of the current external proposal. - `voting_period`: The period that is allowed for voting on this proposal. - `delay`: The number of block after voting has ended in approval and this should be enacted. Increased to `EmergencyVotingPeriod` if too low.
|
||||
|
||||
▸ **propose**(proposal: `Proposal`, value: `Compact<BalanceOf>`)
|
||||
- **summary**: Propose a sensitive action to be taken. # <weight> - O(1). - Two DB changes, one DB entry. # </weight>
|
||||
|
||||
▸ **proxyVote**(ref_index: `Compact<ReferendumIndex>`, vote: `Vote`)
|
||||
- **summary**: Vote in a referendum on behalf of a stash. If `vote.is_aye()`, the vote is to enact the proposal; otherwise it is a vote to keep the status quo. # <weight> - O(1). - One DB change, one DB entry. # </weight>
|
||||
|
||||
▸ **removeProxy**(proxy: `AccountId`)
|
||||
- **summary**: Clear the proxy. Called by the stash. # <weight> - One DB clear. # </weight>
|
||||
|
||||
▸ **resignProxy**()
|
||||
- **summary**: Clear the proxy. Called by the proxy. # <weight> - One DB clear. # </weight>
|
||||
|
||||
▸ **second**(proposal: `Compact<PropIndex>`)
|
||||
- **summary**: Propose a sensitive action to be taken. # <weight> - O(1). - One DB entry. # </weight>
|
||||
|
||||
▸ **setProxy**(proxy: `AccountId`)
|
||||
- **summary**: Specify a proxy. Called by the stash. # <weight> - One extra DB entry. # </weight>
|
||||
|
||||
▸ **undelegate**()
|
||||
- **summary**: Undelegate vote. # <weight> - O(1). # </weight>
|
||||
|
||||
▸ **vetoExternal**(proposal_hash: `Hash`)
|
||||
- **summary**: Veto and blacklist the external proposal hash.
|
||||
|
||||
▸ **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. # <weight> - O(1). - One DB change, one DB entry. # </weight>
|
||||
|
||||
___
|
||||
|
||||
|
||||
### elections
|
||||
|
||||
▸ **presentWinner**(candidate: `Address`, total: `Compact<BalanceOf>`, index: `Compact<VoteIndex>`)
|
||||
- **summary**: Claim that `candidate` is one of the top `carry_count + desired_seats` candidates. Only works iff the presentation period is active. `candidate` should have at least collected some non-zero `total` votes and `origin` must have enough funds to pay for a potential slash. # <weight> - O(voters) compute. - One DB change. # </weight>
|
||||
|
||||
▸ **proxySetApprovals**(votes: `Vec<bool>`, index: `Compact<VoteIndex>`, hint: `SetIndex`, value: `Compact<BalanceOf>`)
|
||||
- **summary**: Set candidate approvals from a proxy. Approval slots stay valid as long as candidates in those slots are registered. # <weight> - Same as `set_approvals` with one additional storage read. # </weight>
|
||||
|
||||
▸ **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. Both indices must be provided as explained in [`voter_at`] function. May be called by anyone. Returns the voter deposit to `signed`. # <weight> - O(1). - Two fewer DB entries, one DB change. # </weight>
|
||||
|
||||
▸ **removeMember**(who: `Address`)
|
||||
- **summary**: Remove a particular member from the set. This is effective immediately. Note: A tally should happen instantly (if not already in a presentation period) to fill the seat if removal means that the desired members are not met.
|
||||
|
||||
▸ **retractVoter**(index: `Compact<u32>`)
|
||||
- **summary**: Remove a voter. All votes are cancelled and the voter deposit is returned. The index must be provided as explained in [`voter_at`] function. Also removes the lock on the balance of the voter. See [`do_set_approvals()`]. # <weight> - O(1). - Two fewer DB entries, one DB change. # </weight>
|
||||
|
||||
▸ **setApprovals**(votes: `Vec<bool>`, index: `Compact<VoteIndex>`, hint: `SetIndex`, value: `Compact<BalanceOf>`)
|
||||
- **summary**: Set candidate approvals. Approval slots stay valid as long as candidates in those slots are registered. Locks `value` from the balance of `origin` indefinitely. Only [`retract_voter`] or [`reap_inactive_voter`] can unlock the balance. `hint` argument is interpreted differently based on: - if `origin` is setting approvals for the first time: The index will be checked for being a valid _hole_ in the voter list. - if the hint is correctly pointing to a hole, no fee is deducted from `origin`. - Otherwise, the call will succeed but the index is ignored and simply a push to the last chunk with free space happens. If the new push causes a new chunk to be created, a fee indicated by [`VotingFee`] is deducted. - if `origin` is already a voter: the index __must__ be valid and point to the correct position of the `origin` in the current voters list. Note that any trailing `false` votes in `votes` is ignored; In approval voting, not voting for a candidate and voting false, are equal. # <weight> - O(1). - Two extra DB entries, one DB change. - Argument `votes` is limited in length to number of candidates. # </weight>
|
||||
|
||||
▸ **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. NOTE: if `origin` has already assigned approvals via [`set_approvals`], it will NOT have any usable funds to pass candidacy bond and must first retract. Note that setting approvals will lock the entire balance of the voter until retraction or being reported. # <weight> - Independent of input. - Three DB changes. # </weight>
|
||||
|
||||
___
|
||||
|
||||
|
||||
### 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.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### imOnline
|
||||
|
||||
▸ **heartbeat**(heartbeat: `Heartbeat`, signature: `Signature`)
|
||||
|
||||
___
|
||||
|
||||
|
||||
### session
|
||||
|
||||
▸ **setKeys**(keys: `Keys`, proof: `Bytes`)
|
||||
- **summary**: Sets the session key(s) of the function caller to `key`. Allows an account to set its session key prior to becoming a validator. This doesn't take effect until the next session. The dispatch origin of this function must be signed. # <weight> - O(log n) in number of accounts. - One extra DB entry. # </weight>
|
||||
|
||||
___
|
||||
|
||||
|
||||
### 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. `value` must be more than the `minimum_balance` specified by `T::Currency`. The dispatch origin for this call must be _Signed_ by the stash account. # <weight> - Independent of the arguments. Moderate complexity. - O(1). - Three extra DB entries. NOTE: Two of the storage writes (`Self::bonded`, `Self::payee`) are _never_ cleaned unless the `origin` falls below _existential deposit_ and gets removed as dust. # </weight>
|
||||
|
||||
▸ **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. Unlike [`bond`] or [`unbond`] this function does not impose any limitation on the amount that can be added. The dispatch origin for this call must be _Signed_ by the stash, not the controller. # <weight> - Independent of the arguments. Insignificant complexity. - O(1). - One DB entry. # </weight>
|
||||
|
||||
▸ **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. # <weight> - Independent of the arguments. Insignificant complexity. - Contains one read. - Writes are limited to the `origin` account key. # </weight>
|
||||
|
||||
▸ **forceNewEra**()
|
||||
- **summary**: Force there to be a new era at the end of the next session. After this, it will be reset to normal (non-forced) behaviour. # <weight> - No arguments. # </weight>
|
||||
|
||||
▸ **forceNoEras**()
|
||||
- **summary**: Force there to be no new eras indefinitely. # <weight> - No arguments. # </weight>
|
||||
|
||||
▸ **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. # <weight> - The transaction's complexity is proportional to the size of `targets`, which is capped at `MAX_NOMINATIONS`. - Both the reads and writes follow a similar pattern. # </weight>
|
||||
|
||||
▸ **setController**(controller: `Address`)
|
||||
- **summary**: (Re-)set the controller of a stash. 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. # <weight> - Independent of the arguments. Insignificant complexity. - Contains a limited number of reads. - Writes are limited to the `origin` account key. # </weight>
|
||||
|
||||
▸ **setInvulnerables**(validators: `Vec<AccountId>`)
|
||||
- **summary**: Set the validators who cannot be slashed (if any).
|
||||
|
||||
▸ **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. # <weight> - Independent of the arguments. Insignificant complexity. - Contains a limited number of reads. - Writes are limited to the `origin` account key. # </weight>
|
||||
|
||||
▸ **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::minimum_balance(), 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. No more than a limited number of unlocking chunks (see `MAX_UNLOCKING_CHUNKS`) can co-exists at the same time. In that case, [`Call::withdraw_unbonded`] need to be called first to remove some of the chunks (if possible). The dispatch origin for this call must be _Signed_ by the controller, not the stash. See also [`Call::withdraw_unbonded`]. # <weight> - Independent of the arguments. Limited but potentially exploitable complexity. - Contains a limited number of reads. - Each call (requires the remainder of the bonded balance to be above `minimum_balance`) will cause a new entry to be inserted into a vector (`Ledger.unlocking`) kept in storage. The only way to clean the aforementioned storage item is also user-controlled via `withdraw_unbonded`. - One DB entry. </weight>
|
||||
|
||||
▸ **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. # <weight> - Independent of the arguments. Insignificant complexity. - Contains a limited number of reads. - Writes are limited to the `origin` account key. # </weight>
|
||||
|
||||
▸ **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`]. # <weight> - Could be dependent on the `origin` argument and how much `unlocking` chunks exist. It implies `consolidate_unlocked` which loops over `Ledger.unlocking`, which is indirectly user-controlled. See [`unbond`] for more detail. - Contains a limited number of reads, yet the size of which could be large based on `ledger`. - Writes are limited to the `origin` account key. # </weight>
|
||||
|
||||
___
|
||||
|
||||
|
||||
### sudo
|
||||
|
||||
▸ **setKey**(new: `Address`)
|
||||
- **summary**: Authenticates the current sudo key and sets the given AccountId (`new`) as the new sudo key. The dispatch origin for this call must be _Signed_. # <weight> - O(1). - Limited storage reads. - One DB change. # </weight>
|
||||
|
||||
▸ **sudo**(proposal: `Proposal`)
|
||||
- **summary**: Authenticates the sudo key and dispatches a function call with `Root` origin. The dispatch origin for this call must be _Signed_. # <weight> - O(1). - Limited storage reads. - One DB write (event). - Unknown weight of derivative `proposal` execution. # </weight>
|
||||
|
||||
▸ **sudoAs**(who: `Address`, proposal: `Proposal`)
|
||||
- **summary**: Authenticates the sudo key and dispatches a function call with `Signed` origin from a given account. The dispatch origin for this call must be _Signed_. # <weight> - O(1). - Limited storage reads. - One DB write (event). - Unknown weight of derivative `proposal` execution. # </weight>
|
||||
|
||||
___
|
||||
|
||||
|
||||
### system
|
||||
|
||||
▸ **fillBlock**()
|
||||
- **summary**: A big dispatch that will disallow any other transaction to be included.
|
||||
|
||||
▸ **killPrefix**(prefix: `Key`)
|
||||
- **summary**: Kill all storage items with a key that starts with the given prefix.
|
||||
|
||||
▸ **killStorage**(keys: `Vec<Key>`)
|
||||
- **summary**: Kill some items from storage.
|
||||
|
||||
▸ **remark**(_remark: `Bytes`)
|
||||
- **summary**: Make some on-chain remark.
|
||||
|
||||
▸ **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.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### technicalCommittee
|
||||
|
||||
▸ **execute**(proposal: `Proposal`)
|
||||
- **summary**: Dispatch a proposal from a member using the `Member` origin. Origin must be a member of the collective.
|
||||
|
||||
▸ **propose**(threshold: `Compact<MemberCount>`, proposal: `Proposal`)
|
||||
- **summary**: # <weight> - Bounded storage reads and writes. - Argument `threshold` has bearing on weight. # </weight>
|
||||
|
||||
▸ **setMembers**(new_members: `Vec<AccountId>`)
|
||||
- **summary**: Set the collective's membership manually to `new_members`. Be nice to the chain and provide it pre-sorted. Requires root origin.
|
||||
|
||||
▸ **vote**(proposal: `Hash`, index: `Compact<ProposalIndex>`, approve: `bool`)
|
||||
- **summary**: # <weight> - Bounded storage read and writes. - Will be slightly heavier if the proposal is approved / disapproved after the vote. # </weight>
|
||||
|
||||
___
|
||||
|
||||
|
||||
### technicalMembership
|
||||
|
||||
▸ **addMember**(who: `AccountId`)
|
||||
- **summary**: Add a member `who` to the set. May only be called from `AddOrigin` or root.
|
||||
|
||||
▸ **removeMember**(who: `AccountId`)
|
||||
- **summary**: Remove a member `who` from the set. May only be called from `RemoveOrigin` or root.
|
||||
|
||||
▸ **resetMembers**(members: `Vec<AccountId>`)
|
||||
- **summary**: Change the membership to a new set, disregarding the existing membership. Be nice and pass `members` pre-sorted. May only be called from `ResetOrigin` or root.
|
||||
|
||||
▸ **swapMember**(remove: `AccountId`, add: `AccountId`)
|
||||
- **summary**: Swap out one member `remove` for another `add`. May only be called from `SwapOrigin` or root.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### 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 `MinimumPeriod`. 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. # <weight> - O(1). - Limited storage reads. - One DB change. # </weight>
|
||||
|
||||
▸ **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. # <weight> - O(1). - Limited storage reads. - One DB change, one extra DB entry. # </weight>
|
||||
|
||||
▸ **rejectProposal**(proposal_id: `Compact<ProposalIndex>`)
|
||||
- **summary**: Reject a proposed spend. The original deposit will be slashed. # <weight> - O(1). - Limited storage reads. - One DB clear. # </weight>
|
||||
|
||||
___
|
||||
|
||||
|
||||
### utility
|
||||
|
||||
▸ **batch**(calls: `Vec<Call>`)
|
||||
- **summary**: Send a batch of dispatch calls (only root).
|
||||
@@ -1,545 +0,0 @@
|
||||
## Storage
|
||||
|
||||
The following sections contain Storage methods are part of the default Substrate runtime. On the api, these are exposed via `api.query.<module>.<method>`.
|
||||
|
||||
(NOTE: These were generated from a static/snapshot view of a recent Substrate master node. Some items may not be available in older nodes, or in any customized implementations.)
|
||||
- **[authorship](#authorship)**
|
||||
|
||||
- **[babe](#babe)**
|
||||
|
||||
- **[balances](#balances)**
|
||||
|
||||
- **[contracts](#contracts)**
|
||||
|
||||
- **[council](#council)**
|
||||
|
||||
- **[democracy](#democracy)**
|
||||
|
||||
- **[elections](#elections)**
|
||||
|
||||
- **[grandpa](#grandpa)**
|
||||
|
||||
- **[imOnline](#imOnline)**
|
||||
|
||||
- **[indices](#indices)**
|
||||
|
||||
- **[offences](#offences)**
|
||||
|
||||
- **[session](#session)**
|
||||
|
||||
- **[staking](#staking)**
|
||||
|
||||
- **[sudo](#sudo)**
|
||||
|
||||
- **[system](#system)**
|
||||
|
||||
- **[technicalCommittee](#technicalCommittee)**
|
||||
|
||||
- **[technicalMembership](#technicalMembership)**
|
||||
|
||||
- **[timestamp](#timestamp)**
|
||||
|
||||
- **[treasury](#treasury)**
|
||||
|
||||
- **[substrate](#substrate)**
|
||||
|
||||
|
||||
___
|
||||
|
||||
|
||||
### authorship
|
||||
|
||||
▸ **author**(): `Option<AccountId>`
|
||||
- **summary**: Author of current block.
|
||||
|
||||
▸ **didSetUncles**(): `bool`
|
||||
- **summary**: Whether uncles were already set in this block.
|
||||
|
||||
▸ **uncles**(): `Vec<UncleEntryItem>`
|
||||
- **summary**: Uncles
|
||||
|
||||
___
|
||||
|
||||
|
||||
### babe
|
||||
|
||||
▸ **authorities**(): `Vec<(AuthorityId,BabeAuthorityWeight)>`
|
||||
- **summary**: Current epoch authorities.
|
||||
|
||||
▸ **currentSlot**(): `u64`
|
||||
- **summary**: Current slot number.
|
||||
|
||||
▸ **epochIndex**(): `u64`
|
||||
- **summary**: Current epoch index.
|
||||
|
||||
▸ **genesisSlot**(): `u64`
|
||||
- **summary**: The slot at which the first epoch actually started. This is 0 until the first block of the chain.
|
||||
|
||||
▸ **initialized**(): `Option<MaybeVrf>`
|
||||
- **summary**: Temporary value (cleared at block finalization) which is `Some` if per-block initialization has already been called for current block.
|
||||
|
||||
▸ **nextRandomness**(): `[u8;32]`
|
||||
- **summary**: Next epoch randomness.
|
||||
|
||||
▸ **randomness**(): `[u8;32]`
|
||||
- **summary**: The epoch randomness for the *current* epoch. # Security This MUST NOT be used for gambling, as it can be influenced by a malicious validator in the short term. It MAY be used in many cryptographic protocols, however, so long as one remembers that this (like everything else on-chain) it is public. For example, it can be used where a number is needed that cannot have been chosen by an adversary, for purposes such as public-coin zero-knowledge proofs.
|
||||
|
||||
▸ **segmentIndex**(): `u32`
|
||||
- **summary**: Randomness under construction. We make a tradeoff between storage accesses and list length. We store the under-construction randomness in segments of up to `UNDER_CONSTRUCTION_SEGMENT_LENGTH`. Once a segment reaches this length, we begin the next one. We reset all segments and return to `0` at the beginning of every epoch.
|
||||
|
||||
▸ **underConstruction**(`u32`): `Vec<[u8;32]>`
|
||||
|
||||
___
|
||||
|
||||
|
||||
### balances
|
||||
|
||||
▸ **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.
|
||||
|
||||
▸ **vesting**(`AccountId`): `Option<VestingSchedule>`
|
||||
- **summary**: Information regarding the vesting of a given account.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### contracts
|
||||
|
||||
▸ **accountCounter**(): `u64`
|
||||
- **summary**: The subtrie counter.
|
||||
|
||||
▸ **codeStorage**(`CodeHash`): `Option<PrefabWasmModule>`
|
||||
- **summary**: A mapping between an original code hash and instrumented wasm code, ready for execution.
|
||||
|
||||
▸ **contractInfoOf**(`AccountId`): `Option<ContractInfo>`
|
||||
- **summary**: The code associated with a given 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.
|
||||
|
||||
▸ **pristineCode**(`CodeHash`): `Option<Bytes>`
|
||||
- **summary**: A mapping from an original code hash to the original code, untouched by instrumentation.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### council
|
||||
|
||||
▸ **members**(): `Vec<AccountId>`
|
||||
- **summary**: The current members of the collective. This is stored sorted (just by value).
|
||||
|
||||
▸ **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<Votes>`
|
||||
- **summary**: Votes on a given proposal, if it is ongoing.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### democracy
|
||||
|
||||
▸ **blacklist**(`Hash`): `Option<(BlockNumber,Vec<AccountId>)>`
|
||||
- **summary**: A record of who vetoed what. Maps proposal hash to a possible existent block number (until when it may not be resubmitted) and who vetoed it.
|
||||
|
||||
▸ **cancellations**(`Hash`): `bool`
|
||||
- **summary**: Record of all proposals that have been subject to emergency cancellation.
|
||||
|
||||
▸ **delegations**(`AccountId`): `((AccountId,Conviction), 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.
|
||||
|
||||
▸ **lastTabledWasExternal**(): `bool`
|
||||
- **summary**: True if the last referendum tabled was submitted externally. False if it was a public proposal.
|
||||
|
||||
▸ **nextExternal**(): `Option<(Proposal,VoteThreshold)>`
|
||||
- **summary**: The referendum to be tabled whenever it would be valid to table an external proposal. This happens when a referendum needs to be tabled and one of two conditions are met: - `LastTabledWasExternal` is `false`; or - `PublicProps` is empty.
|
||||
|
||||
▸ **nextTally**(): `ReferendumIndex`
|
||||
- **summary**: The next referendum index that should be tallied.
|
||||
|
||||
▸ **proxy**(`AccountId`): `Option<AccountId>`
|
||||
- **summary**: Who is able to vote for whom. Value is the fund-holding account, key is the vote-transaction-sending account.
|
||||
|
||||
▸ **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 referenda 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.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### elections
|
||||
|
||||
▸ **approvalsOf**(`(AccountId,SetIndex)`): `Vec<ApprovalFlag>`
|
||||
|
||||
▸ **candidateCount**(): `u32`
|
||||
- **summary**: Current number of active candidates
|
||||
|
||||
▸ **candidates**(): `Vec<AccountId>`
|
||||
- **summary**: The present candidate list.
|
||||
|
||||
▸ **desiredSeats**(): `u32`
|
||||
- **summary**: Number of accounts that should constitute the collective.
|
||||
|
||||
▸ **leaderboard**(): `Option<Vec<(BalanceOf,AccountId)>>`
|
||||
- **summary**: Get the leaderboard if we're in the presentation phase. The first element is the weight of each entry; It may be the direct summed approval stakes, or a weighted version of it. Sorted from low to high.
|
||||
|
||||
▸ **members**(): `Vec<(AccountId,BlockNumber)>`
|
||||
- **summary**: The current membership. 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 member was elected and their term duration).
|
||||
|
||||
▸ **nextFinalize**(): `Option<(BlockNumber,u32,Vec<AccountId>)>`
|
||||
- **summary**: The accounts holding the seats that will become free on the next tally.
|
||||
|
||||
▸ **nextVoterSet**(): `SetIndex`
|
||||
- **summary**: the next free set to store a voter in. This will keep growing.
|
||||
|
||||
▸ **presentationDuration**(): `BlockNumber`
|
||||
- **summary**: How long to give each top candidate to present themselves after the vote ends.
|
||||
|
||||
▸ **proxy**(`AccountId`): `Option<AccountId>`
|
||||
- **summary**: Who is able to vote for whom. Value is the fund-holding account, key is the vote-transaction-sending account.
|
||||
|
||||
▸ **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.
|
||||
|
||||
▸ **termDuration**(): `BlockNumber`
|
||||
- **summary**: How long each position is active for.
|
||||
|
||||
▸ **voteCount**(): `VoteIndex`
|
||||
- **summary**: The total number of vote rounds that have happened or are in progress.
|
||||
|
||||
▸ **voterCount**(): `SetIndex`
|
||||
- **summary**: Current number of Voters.
|
||||
|
||||
▸ **voterInfoOf**(`AccountId`): `Option<VoterInfo>`
|
||||
- **summary**: Basic information about a voter.
|
||||
|
||||
▸ **voters**(`SetIndex`): `Vec<Option<AccountId>>`
|
||||
- **summary**: The present voter list (chunked and capped at [`VOTER_SET_SIZE`]).
|
||||
|
||||
___
|
||||
|
||||
|
||||
### grandpa
|
||||
|
||||
▸ **authorities**(): `Vec<(AuthorityId,AuthorityWeight)>`
|
||||
- **summary**: The current authority set.
|
||||
|
||||
▸ **currentSetId**(): `SetId`
|
||||
- **summary**: The number of changes (both in terms of keys and underlying economic responsibilities) in the "set" of Grandpa validators from genesis.
|
||||
|
||||
▸ **nextForced**(): `Option<BlockNumber>`
|
||||
- **summary**: next block number where we can force a change.
|
||||
|
||||
▸ **pendingChange**(): `Option<StoredPendingChange>`
|
||||
- **summary**: Pending change: (signaled at, scheduled change).
|
||||
|
||||
▸ **setIdSession**(`SetId`): `Option<SessionIndex>`
|
||||
- **summary**: A mapping from grandpa set ID to the index of the *most recent* session for which its members were responsible.
|
||||
|
||||
▸ **stalled**(): `Option<(BlockNumber,BlockNumber)>`
|
||||
- **summary**: `true` if we are currently stalled.
|
||||
|
||||
▸ **state**(): `StoredState`
|
||||
- **summary**: State of the current authority set.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### imOnline
|
||||
|
||||
▸ **gossipAt**(): `BlockNumber`
|
||||
- **summary**: The block number when we should gossip.
|
||||
|
||||
▸ **keys**(): `Vec<AuthorityId>`
|
||||
- **summary**: The current set of keys that may issue a heartbeat.
|
||||
|
||||
▸ **receivedHeartbeats**(`SessionIndex, AuthIndex`): `Bytes`
|
||||
- **summary**: For each session index we keep a mapping of `AuthorityId` to `offchain::OpaqueNetworkState`.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### indices
|
||||
|
||||
▸ **enumSet**(`AccountIndex`): `Vec<AccountId>`
|
||||
- **summary**: The enumeration sets.
|
||||
|
||||
▸ **nextEnumSet**(): `AccountIndex`
|
||||
- **summary**: The next free enumeration set.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### offences
|
||||
|
||||
▸ **concurrentReportsIndex**(`Kind, OpaqueTimeSlot`): `Vec<ReportIdOf>`
|
||||
- **summary**: A vector of reports of the same kind that happened at the same time slot.
|
||||
|
||||
▸ **reports**(`ReportIdOf`): `Option<OffenceDetails>`
|
||||
- **summary**: The primary structure that holds all offence records keyed by report identifiers.
|
||||
|
||||
▸ **reportsByKindIndex**(`Kind`): `Bytes`
|
||||
- **summary**: Enumerates all reports of a kind along with the time they happened. All reports are sorted by the time of offence. Note that the actual type of this mapping is `Vec<u8>`, this is because values of different types are not supported at the moment so we are doing the manual serialization.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### session
|
||||
|
||||
▸ **currentIndex**(): `SessionIndex`
|
||||
- **summary**: Current index of the session.
|
||||
|
||||
▸ **disabledValidators**(): `Vec<u32>`
|
||||
- **summary**: Indices of disabled validators. The set is cleared when `on_session_ending` returns a new set of identities.
|
||||
|
||||
▸ **keyOwner**(`Bytes, (KeyTypeId,Bytes)`): `Option<ValidatorId>`
|
||||
- **summary**: The owner of a key. The second key is the `KeyTypeId` + the encoded key. The first key is always `DEDUP_KEY_PREFIX` to have all the data in the same branch of the trie. Having all data in the same branch should prevent slowing down other queries.
|
||||
|
||||
▸ **nextKeys**(`Bytes, ValidatorId`): `Option<Keys>`
|
||||
- **summary**: The next session keys for a validator. The first key is always `DEDUP_KEY_PREFIX` to have all the data in the same branch of the trie. Having all data in the same branch should prevent slowing down other queries.
|
||||
|
||||
▸ **queuedChanged**(): `bool`
|
||||
- **summary**: True if the underlying economic identities or weighting behind the validators has changed in the queued validator set.
|
||||
|
||||
▸ **queuedKeys**(): `Vec<(ValidatorId,Keys)>`
|
||||
- **summary**: The queued keys for the next session. When the next session begins, these keys will be used to determine the validator's session keys.
|
||||
|
||||
▸ **validators**(): `Vec<ValidatorId>`
|
||||
- **summary**: The current set of validators.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### staking
|
||||
|
||||
▸ **bonded**(`AccountId`): `Option<AccountId>`
|
||||
- **summary**: Map from all locked "stash" accounts to the controller account.
|
||||
|
||||
▸ **bondedEras**(): `Vec<(EraIndex,SessionIndex)>`
|
||||
- **summary**: A mapping from still-bonded eras to the first session index of that era.
|
||||
|
||||
▸ **currentElected**(): `Vec<AccountId>`
|
||||
- **summary**: The currently elected validator set keyed by stash account ID.
|
||||
|
||||
▸ **currentEra**(): `EraIndex`
|
||||
- **summary**: The current era index.
|
||||
|
||||
▸ **currentEraPointsEarned**(): `EraPoints`
|
||||
- **summary**: Rewards for the current era. Using indices of current elected set.
|
||||
|
||||
▸ **currentEraStart**(): `MomentOf`
|
||||
- **summary**: The start of the current era.
|
||||
|
||||
▸ **currentEraStartSessionIndex**(): `SessionIndex`
|
||||
- **summary**: The session index at which the current era started.
|
||||
|
||||
▸ **eraSlashJournal**(`EraIndex`): `Vec<SlashJournalEntry>`
|
||||
- **summary**: All slashes that have occurred in a given era.
|
||||
|
||||
▸ **forceEra**(): `Forcing`
|
||||
- **summary**: True if the next session change will be a new era regardless of index.
|
||||
|
||||
▸ **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.
|
||||
|
||||
▸ **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.
|
||||
|
||||
▸ **nominators**(`AccountId`): `(Vec<AccountId>, Linkage<AccountId>)`
|
||||
- **summary**: The map from nominator stash key to the set of stash keys of all validators to nominate.
|
||||
|
||||
▸ **payee**(`AccountId`): `RewardDestination`
|
||||
- **summary**: Where the reward payment should be made. Keyed by stash.
|
||||
|
||||
▸ **slashRewardFraction**(): `Perbill`
|
||||
- **summary**: The percentage of the slash that is distributed to reporters. The rest of the slashed value is handled by the `Slash`.
|
||||
|
||||
▸ **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 Session 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`
|
||||
- **summary**: The `AccountId` of the sudo key.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### 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.
|
||||
|
||||
▸ **allExtrinsicsWeight**(): `Option<Weight>`
|
||||
- **summary**: Total weight for all extrinsics put together, for the current block.
|
||||
|
||||
▸ **blockHash**(`BlockNumber`): `Hash`
|
||||
- **summary**: Map of block numbers to block hashes.
|
||||
|
||||
▸ **digest**(): `DigestOf`
|
||||
- **summary**: Digest of the current block, also part of the block header.
|
||||
|
||||
▸ **eventCount**(): `EventIndex`
|
||||
- **summary**: The number of events in the `Events<T>` list.
|
||||
|
||||
▸ **events**(): `Vec<EventRecord>`
|
||||
- **summary**: Events deposited for the current block.
|
||||
|
||||
▸ **eventTopics**(`Null, Hash`): `Vec<(BlockNumber,EventIndex)>`
|
||||
- **summary**: Mapping between a topic (represented by T::Hash) and a vector of indexes of events in the `<Events<T>>` list. The first key serves no purpose. This field is declared as double_map just for convenience of using `remove_prefix`. All topic vectors have deterministic storage locations depending on the topic. This allows light-clients to leverage the changes trie storage tracking mechanism and in case of changes fetch the list of events of interest. The value has the type `(T::BlockNumber, EventIndex)` because if we used only just the `EventIndex` then in case if the topic has the same contents on the next block no notification will be triggered thus the event might be lost.
|
||||
|
||||
▸ **extrinsicCount**(): `Option<u32>`
|
||||
- **summary**: Total extrinsics count for the current block.
|
||||
|
||||
▸ **extrinsicData**(`u32`): `Bytes`
|
||||
- **summary**: Extrinsics data for the current block (maps an extrinsic's index to its data).
|
||||
|
||||
▸ **extrinsicsRoot**(): `Hash`
|
||||
- **summary**: Extrinsics root of the current block, also part of the block header.
|
||||
|
||||
▸ **nextWeightMultiplier**(): `WeightMultiplier`
|
||||
- **summary**: The next weight multiplier. This should be updated at the end of each block based on the saturation level (weight).
|
||||
|
||||
▸ **number**(): `BlockNumber`
|
||||
- **summary**: The current block number being processed. Set by `execute_block`.
|
||||
|
||||
▸ **parentHash**(): `Hash`
|
||||
- **summary**: Hash of the previous block.
|
||||
|
||||
▸ **randomMaterial**(): `(i8,Vec<Hash>)`
|
||||
- **summary**: Series of block headers from the last 81 blocks that acts as random seed material. This is arranged as a ring buffer with the `i8` prefix being the index into the `Vec` of the oldest hash.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### technicalCommittee
|
||||
|
||||
▸ **members**(): `Vec<AccountId>`
|
||||
- **summary**: The current members of the collective. This is stored sorted (just by value).
|
||||
|
||||
▸ **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<Votes>`
|
||||
- **summary**: Votes on a given proposal, if it is ongoing.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### technicalMembership
|
||||
|
||||
▸ **members**(): `Vec<AccountId>`
|
||||
- **summary**: The current membership, stored as an ordered Vec.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### timestamp
|
||||
|
||||
▸ **didUpdate**(): `bool`
|
||||
- **summary**: Did the timestamp get updated in this block?
|
||||
|
||||
▸ **now**(): `Moment`
|
||||
- **summary**: Current time for the current block.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### treasury
|
||||
|
||||
▸ **approvals**(): `Vec<ProposalIndex>`
|
||||
- **summary**: Proposal indices that have been approved but not yet awarded.
|
||||
|
||||
▸ **proposalCount**(): `ProposalIndex`
|
||||
- **summary**: Number of proposals that have been made.
|
||||
|
||||
▸ **proposals**(`ProposalIndex`): `Option<TreasuryProposal>`
|
||||
- **summary**: Proposals that have been made.
|
||||
|
||||
---
|
||||
|
||||
### substrate
|
||||
|
||||
_These are keys that are always available to the runtime implementation_
|
||||
|
||||
▸ **changesTrieConfig**(): `u32`
|
||||
- **summary**: Changes trie configuration is stored under this key.
|
||||
|
||||
▸ **childStorageKeyPrefix**(): `u32`
|
||||
- **summary**: Prefix of child storage keys.
|
||||
|
||||
▸ **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.
|
||||
|
||||
---
|
||||
+12
-23
@@ -1,35 +1,24 @@
|
||||
/* eslint-disable @typescript-eslint/camelcase */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const config = require('@polkadot/dev/config/jest');
|
||||
const config = require('@plugnet/dev/config/jest');
|
||||
|
||||
module.exports = Object.assign({}, config, {
|
||||
moduleNameMapper: {
|
||||
'@polkadot/api-contract(.*)$': '<rootDir>/packages/api-contract/src/$1',
|
||||
'@polkadot/api-derive(.*)$': '<rootDir>/packages/api-derive/src/$1',
|
||||
'@polkadot/api-metadata(.*)$': '<rootDir>/packages/api-metadata/src/$1',
|
||||
'@polkadot/api(.*)$': '<rootDir>/packages/api/src/$1',
|
||||
'@polkadot/rpc-(core|provider)(.*)$': '<rootDir>/packages/rpc-$1/src/$2',
|
||||
'@polkadot/jsonrpc(.*)$': '<rootDir>/packages/type-jsonrpc/src/$1',
|
||||
'@polkadot/types(.*)$': '<rootDir>/packages/types/src/$1'
|
||||
'@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/api-contract/build',
|
||||
'<rootDir>/packages/api-metadata/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'
|
||||
],
|
||||
globals: {
|
||||
ws_local: 'ws://127.0.0.1:9944/',
|
||||
ws_local_substrate_master: 'ws://127.0.0.1:9945/',
|
||||
ws_local_substrate_1: 'ws://127.0.0.1:9946/',
|
||||
ws_local_substrate_2: 'ws://127.0.0.1:9947/',
|
||||
ws_local_polkadot_master: 'ws://127.0.0.1:9948/',
|
||||
ws_local_polkadot_alex: 'ws://127.0.0.1:9949/',
|
||||
ws_substrate_1: 'wss://substrate-rpc.parity.io/',
|
||||
ws_polkadot_alex: 'wss://poc3-rpc.polkadot.io/'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
+1
-1
@@ -9,5 +9,5 @@
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "0.95.2"
|
||||
"version": "0.80.100"
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user