Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b0ef159c0 | ||
|
|
96937666d1 | ||
|
|
da6cd98e6a | ||
|
|
ad4a6e63ce | ||
|
|
c0a804332b | ||
|
|
32c4aa3bfe | ||
|
|
8293f4b585 | ||
|
|
4d2dfb43b8 | ||
|
|
a0b8619093 | ||
|
|
c1396bc23a | ||
|
|
692c208b20 | ||
|
|
498e3a1481 | ||
|
|
8de45cb09e | ||
|
|
539b26ed87 | ||
|
|
68a3b18385 | ||
|
|
1573185bf8 | ||
|
|
fff6f311e0 | ||
|
|
a7b733daa7 | ||
|
|
00d86011a7 | ||
|
|
84b9b8dc09 | ||
|
|
06d0c1fdfb | ||
|
|
bc8782a885 | ||
|
|
e7f488ed89 | ||
|
|
7b56a52fc3 | ||
|
|
67929d34bd | ||
|
|
5eef25c815 | ||
|
|
134c4b611a | ||
|
|
095f63c46e | ||
|
|
73d7a57d38 | ||
|
|
229fd72526 | ||
|
|
db9dcbdad5 | ||
|
|
9f065abb07 | ||
|
|
564964a482 | ||
|
|
ceee734ab1 | ||
|
|
3720cf86cc | ||
|
|
a4f1651f99 | ||
|
|
5b6762373c | ||
|
|
a72fbece96 | ||
|
|
587c9881f8 | ||
|
|
36991fb845 | ||
|
|
bed3f9f4c5 | ||
|
|
5576dacd9a | ||
|
|
5d2caddcaf | ||
|
|
ed7bd61230 | ||
|
|
cd272e890f | ||
|
|
0f21d522d7 |
@@ -4,5 +4,6 @@ exclude_patterns:
|
||||
- "**/*.test.js"
|
||||
- "**/*.test.ts"
|
||||
- "docs/**/*.js"
|
||||
- "packages/api/src/query.types.ts"
|
||||
- "packages/types/src/interfaces/"
|
||||
- "packages/types/src/scripts/"
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
# 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`
|
||||
|
||||
@@ -22,7 +22,7 @@ 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/METHODS_RPC.html) exposed by a Polkadot network client
|
||||
- [@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
|
||||
|
||||
Type definitions for interfaces as exposed by Polkadot & Substrate clients -
|
||||
|
||||
@@ -10,7 +10,7 @@ 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
|
||||
// We only display a couple, then unsubscribe
|
||||
let count = 0;
|
||||
|
||||
// Subscribe to the new headers on-chain. The callback is fired when new headers
|
||||
|
||||
@@ -8,8 +8,8 @@ async function main () {
|
||||
// Create a new instance of the api
|
||||
const api = await ApiPromise.create();
|
||||
|
||||
// Subscribe to chain updates and log the current block number on update.
|
||||
const unsubscribe = await api.rpc.chain.subscribeNewHead((header) => {
|
||||
// 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}`);
|
||||
});
|
||||
|
||||
|
||||
@@ -12,18 +12,18 @@ 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
|
||||
// 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
|
||||
// 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
|
||||
// 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]}`);
|
||||
|
||||
@@ -14,7 +14,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
|
||||
|
||||
@@ -15,16 +15,16 @@ 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-derived path (empty phrase, so uses dev)
|
||||
// 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
|
||||
// Get current block
|
||||
const signedBlock = await api.rpc.chain.getBlock();
|
||||
|
||||
// get current block height and hash
|
||||
// Get current block height and hash
|
||||
const currentHeight = signedBlock.block.header.number;
|
||||
const blockHash = signedBlock.block.header.hash;
|
||||
|
||||
|
||||
+1
-2
@@ -10,8 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "0.80.1",
|
||||
"@polkadot/keyring": "^0.93.1"
|
||||
"@polkadot/api": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -8,21 +8,21 @@ 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()}`);
|
||||
});
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
// Import the API & Provider and some utility functions
|
||||
const { ApiPromise } = require('@polkadot/api');
|
||||
|
||||
// import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
|
||||
// Import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
|
||||
const testKeyring = require('@polkadot/keyring/testing');
|
||||
|
||||
// utility function for random values
|
||||
// Utility function for random values
|
||||
const { randomAsU8a } = require('@polkadot/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,18 +18,18 @@ 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
|
||||
// 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());
|
||||
|
||||
@@ -16,22 +16,24 @@ async function main () {
|
||||
// Create the API and wait until ready (optional provider passed through)
|
||||
const api = await ApiPromise.create({ provider });
|
||||
|
||||
// retrieve the upgrade key from the chain state
|
||||
// Retrieve the upgrade key from the chain state
|
||||
const adminId = await api.query.sudo.key();
|
||||
|
||||
// find the actual keypair in the keyring (if this is an changed value, the key
|
||||
// Find the actual keypair in the keyring (if this is a 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
|
||||
const code = fs.readFileSync('./test.wasm').toString('hex');
|
||||
const proposal = api.tx.consensus.setCode(`0x${code}`);
|
||||
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
|
||||
|
||||
console.log(`Upgrading from ${adminId}, ${code.length / 2} bytes`);
|
||||
|
||||
// preform the actual chain upgrade via the sudo module
|
||||
// Perform the actual chain upgrade via the sudo module
|
||||
api.tx.sudo
|
||||
.sudo(proposal)
|
||||
.signAndSend(adminPair, ({ events = [], status }) => {
|
||||
|
||||
@@ -12,7 +12,7 @@ async function main () {
|
||||
new ApiRx().isReady
|
||||
.pipe(
|
||||
switchMap((api) =>
|
||||
api.rpc.chain.subscribeNewHead()
|
||||
api.rpc.chain.subscribeNewHeads()
|
||||
))
|
||||
.subscribe((header) => {
|
||||
console.log(`Chain is at block: #${header.number}`);
|
||||
|
||||
@@ -7,11 +7,11 @@ 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.subscribeNewHead()
|
||||
api.rpc.chain.subscribeNewHeads()
|
||||
))
|
||||
.subscribe((header) => {
|
||||
console.log(`Chain is at block: #${header.number}`);
|
||||
|
||||
@@ -12,13 +12,13 @@ async function main () {
|
||||
const api = await ApiRx.create().toPromise();
|
||||
|
||||
// Create an instance of the keyring
|
||||
const keyring = new Keyring({ type: 's25519' });
|
||||
const keyring = new Keyring({ type: 'sr25519' });
|
||||
|
||||
// Add Alice to our keyring (with the known seed for the account)
|
||||
const alice = keyring.addFomUri('//Alice');
|
||||
const alice = keyring.addFromUri('//Alice');
|
||||
|
||||
// Create a extrinsic, transferring 12345 units to Bob.
|
||||
api.tx.balances
|
||||
// Create a extrinsic, transferring 12345 units to Bob.
|
||||
const subscription = api.tx.balances
|
||||
// create transfer
|
||||
.transfer(BOB, 12345)
|
||||
// Sign and send the transcation
|
||||
@@ -27,10 +27,11 @@ async function main () {
|
||||
.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(`Staus of transfer: ${status.type}`);
|
||||
console.log(`Status of transfer: ${status.type}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
main().catch(console.error).finally(() => process.exit());
|
||||
main().catch(console.error);
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
// Import the API and some utility functions
|
||||
const { ApiRx } = require('@polkadot/api');
|
||||
|
||||
// import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
|
||||
// Import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
|
||||
const testKeyring = require('@polkadot/keyring/testing');
|
||||
|
||||
// utility function for random values
|
||||
// Utility function for random values
|
||||
const { randomAsU8a } = require('@polkadot/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 +18,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
|
||||
// Create a new random recipient
|
||||
const recipient = keyring.addFromSeed(randomAsU8a(32)).address;
|
||||
|
||||
console.log('Sending', AMOUNT, 'from', alicePair.address, 'to', recipient);
|
||||
|
||||
// get the nonce for the admin key
|
||||
// Create a extrinsic, transferring 12345 units to Bob.
|
||||
// Get the nonce for the admin key
|
||||
// Create a extrinsic, transferring 12345 units to Bob.
|
||||
api.tx.balances
|
||||
// Do the transfer
|
||||
.transfer(recipient, AMOUNT)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/* 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)
|
||||
// Import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
|
||||
const testKeyring = require('@polkadot/keyring/testing');
|
||||
const fs = require('fs');
|
||||
|
||||
@@ -14,27 +14,28 @@ async function main () {
|
||||
// Create the API and wait until ready (optional provider passed through)
|
||||
const api = await ApiRx.create({ provider }).toPromise();
|
||||
|
||||
// retrieve the upgrade key from the chain state
|
||||
// Retrieve the upgrade key from the chain state
|
||||
// TODO It seems like this promise doesn't resolve
|
||||
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
|
||||
// preform the actual chain upgrade via the sudo module
|
||||
// Perform 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);
|
||||
|
||||
+7
-1
@@ -4,7 +4,7 @@ The list will be updated/expanded as questions come up, dealing with some common
|
||||
|
||||
## I am getting a "Unknown types found, no types for ..." error
|
||||
|
||||
There are 2 caused 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.
|
||||
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.
|
||||
|
||||
@@ -17,3 +17,9 @@ Update your version of the API to the [latest version](install.md). Like types,
|
||||
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).
|
||||
|
||||
@@ -4,7 +4,7 @@ These sections should provide you with all the information needed to install the
|
||||
|
||||
## What this is not
|
||||
|
||||
This is not line-by-line documentation of all the extising 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...
|
||||
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
|
||||
|
||||
|
||||
@@ -5,16 +5,16 @@ Constant queries will introduce you to the concepts behind the types and the int
|
||||
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
|
||||
// Initialize the API as per previous sections
|
||||
...
|
||||
|
||||
// the length of an epoch (session) in Babe
|
||||
// The length of an epoch (session) in Babe
|
||||
console.log(api.consts.babe.epochDuration.toNumber());
|
||||
|
||||
// the amount required to create a new account
|
||||
// The amount required to create a new account
|
||||
console.log(api.consts.balances.creationFee.toNumber());
|
||||
|
||||
// the amount required per byte on an extrinsic
|
||||
// The amount required per byte on an extrinsic
|
||||
console.log(api.consts.balances.transactionByteFee.toNumber());
|
||||
```
|
||||
|
||||
|
||||
@@ -7,20 +7,20 @@ In previous sections, we initialized the API and retrieved runtime constants. Th
|
||||
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
|
||||
// Initialize the API as in previous sections
|
||||
...
|
||||
|
||||
// the actual address that we will use
|
||||
// The actual address that we will use
|
||||
const ADDR = '5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFabHE';
|
||||
|
||||
// retrieve the last timestamp
|
||||
// Retrieve the last timestamp
|
||||
const now = await api.query.timestamp.now();
|
||||
|
||||
// retrieve the account nonce via the system module
|
||||
// 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.balance.freeBalance(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}`);
|
||||
```
|
||||
@@ -29,11 +29,11 @@ There have been some additions in the code above comparing with retrieving runti
|
||||
|
||||
```js
|
||||
...
|
||||
// retrieve last block timestamp, account nonce & balance
|
||||
// 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.balance.freeBalance(ADDR)
|
||||
api.query.balances.freeBalance(ADDR)
|
||||
]);
|
||||
```
|
||||
|
||||
@@ -41,7 +41,7 @@ const [now, nonce, balance] = await Promise.all([
|
||||
|
||||
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.
|
||||
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
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@ In a number of applications, it is useful to monitor a number of like-queries at
|
||||
|
||||
## 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 -
|
||||
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)
|
||||
// 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;
|
||||
|
||||
@@ -22,10 +22,10 @@ A couple of items to note in the example above: we don't call `freeBalance` dire
|
||||
```js
|
||||
...
|
||||
|
||||
// retrieve a snapshot of the validators
|
||||
// Retrieve a snapshot of the validators
|
||||
const validators = await api.query.session.validators();
|
||||
|
||||
// subscribe to the balances for these accounts
|
||||
// Subscribe to the balances for these accounts
|
||||
const unsub = await api.query.balances.freeBalance.multi(validators, (balances) => {
|
||||
console.log(`The balances are: ${balances}`);
|
||||
});
|
||||
@@ -40,7 +40,7 @@ The previous `.multi` examples assumes that we do queries for the same types, i.
|
||||
```js
|
||||
...
|
||||
|
||||
// subscribe to the timestamp, our index and balance
|
||||
// Subscribe to the timestamp, our index and balance
|
||||
const unsub = await api.queryMulti([
|
||||
api.query.timestamp.now,
|
||||
[api.query.system.accountNonce, ADDR],
|
||||
|
||||
@@ -9,16 +9,16 @@ Quite often is is useful (taking pruning into account, more on this later) to re
|
||||
```js
|
||||
...
|
||||
|
||||
// retrieve the current block header
|
||||
// Retrieve the current block header
|
||||
const lastHdr = await api.rpc.chain.getHeader();
|
||||
|
||||
// retrieve the balance at both the current and the parent hashes
|
||||
// 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
|
||||
// Display the difference
|
||||
console.log(`The delta was ${balanceNow.sub(balancePrev)}`);
|
||||
```
|
||||
|
||||
@@ -27,13 +27,13 @@ In the above example, we introduce the `.at(<hash>[, ...params])` query. For all
|
||||
```js
|
||||
...
|
||||
|
||||
// retrieve the timestampt for the previous block
|
||||
// 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. (Generaly most public RPC nodes only run with default settings, which includes agressive state pruning)
|
||||
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. (Generaly most public RPC nodes only run with default settings, which includes aggressive state pruning)
|
||||
|
||||
## State entries
|
||||
|
||||
@@ -42,13 +42,13 @@ In addition to using `api.query` to make actual on-chain queries, it can also be
|
||||
```js
|
||||
...
|
||||
|
||||
// retrieve the hash & size of the entry as stored on-chain
|
||||
// Retrieve the hash & size of the entry as stored on-chain
|
||||
const [entryHash, entrySize] = await Promise.all([
|
||||
api.query.freeBalance.hash(ADDR),
|
||||
api.query.freeBalance.size(ADDR)
|
||||
api.query.balances.freeBalance.hash(ADDR),
|
||||
api.query.balances.freeBalance.size(ADDR)
|
||||
]);
|
||||
|
||||
// output the info
|
||||
// Output the info
|
||||
console.log(`The current size is ${entrySize} bytes with a hash of ${entryHash}`);
|
||||
```
|
||||
|
||||
@@ -59,10 +59,10 @@ As per the previous examples, the params here apply explicitly to the actual nee
|
||||
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
|
||||
// Extract the info
|
||||
const { meta, method, section } = api.query.balances.freeBalance;
|
||||
|
||||
// display some info on a specific entry
|
||||
// Display some info on a specific entry
|
||||
console.log(`${section}.${method}: ${meta.documentation.join(' ')}`);
|
||||
console.log(`query key: ${api.query.balances.freeBalance.key(ADDR)}`);
|
||||
```
|
||||
|
||||
@@ -9,7 +9,7 @@ As in the case with `api.rpc` subscriptions, query subscriptions follow exactly
|
||||
```js
|
||||
...
|
||||
|
||||
// retrieve the current timestamp via subscription
|
||||
// Retrieve the current timestamp via subscription
|
||||
const unsub = await api.query.timestamp.now((moment) => {
|
||||
console.log(`The last block has a timestamp of ${moment}`);
|
||||
});
|
||||
@@ -24,7 +24,7 @@ If we had a query with parameters, i.e. where we wish to perform a query for a s
|
||||
```js
|
||||
...
|
||||
|
||||
// subscribe to balance changes for our account
|
||||
// Subscribe to balance changes for our account
|
||||
const unsub = await api.query.balances.freeBalance(ADDR, (balance) => {
|
||||
console.log(`Your account balance is ${balance}`);
|
||||
});
|
||||
|
||||
@@ -7,13 +7,13 @@ Since you are already familiar with the `api.query` interface, the `api.rpc` int
|
||||
```js
|
||||
...
|
||||
|
||||
// retrieve the chain name
|
||||
// Retrieve the chain name
|
||||
const chain = await api.rpc.system.chain();
|
||||
|
||||
// retrieve the latest header
|
||||
// Retrieve the latest header
|
||||
const lastHeader = await api.rpc.chain.getHeader();
|
||||
|
||||
// log the information
|
||||
// Log the information
|
||||
console.log(`${chain}: last block #${lastHeader.number} has hash ${lastHeader.hash}`);
|
||||
```
|
||||
|
||||
@@ -26,13 +26,13 @@ The RPCs lend themselves to using subscriptions, for instance in the above case
|
||||
```js
|
||||
...
|
||||
|
||||
// subscribe to the new headers
|
||||
// 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.
|
||||
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 -
|
||||
|
||||
@@ -40,7 +40,7 @@ In general, whenever we create a subscription, we would like to cleanup after ou
|
||||
...
|
||||
let count = 0;
|
||||
|
||||
// subscribe to the new headers
|
||||
// Subscribe to the new headers
|
||||
const unsubHeads = await api.rpc.chain.subscribeNewHeads((lastHeader) => {
|
||||
console.log(`${chain}: last block #${lastHeader.number} has hash ${lastHeader.hash}`);
|
||||
|
||||
|
||||
@@ -9,12 +9,12 @@ To start off, let's make a balance transfer from Alice to Bob.
|
||||
```js
|
||||
...
|
||||
|
||||
// sign and send a transfer from Alice to Bob
|
||||
// Sign and send a transfer from Alice to Bob
|
||||
const txHash = await api.tx.balances
|
||||
.transfer(BOB, 12345)
|
||||
.signAndSend(alice);
|
||||
|
||||
// show the hash
|
||||
// Show the hash
|
||||
console.log(`Submitted with hash ${txHash}`);
|
||||
```
|
||||
|
||||
@@ -26,7 +26,7 @@ The result for this call (we will deal with subscriptions in a short while), is
|
||||
|
||||
## Under the hood
|
||||
|
||||
Despite the single-line format of `signAndSend`, there is a lot hapenning under the hood (and all of this can be manually provided) -
|
||||
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 blocktimes)
|
||||
|
||||
@@ -9,10 +9,10 @@ To send a transaction and then waiting until it has been included in a block, we
|
||||
```js
|
||||
...
|
||||
|
||||
// create alice (carry-over from the keyring section)
|
||||
// Create alice (carry-over from the keyring section)
|
||||
const alice = keyring.addFromUri('//Alice');
|
||||
|
||||
// make a transfer from Alice to BOB, waiting for inclusion
|
||||
// Make a transfer from Alice to BOB, waiting for inclusion
|
||||
const unsub = await api.tx.balances
|
||||
.transfer(BOB, 12345)
|
||||
.signAndSend(alice, (result) => {
|
||||
@@ -39,7 +39,7 @@ To display or act on these events, we can do the following -
|
||||
|
||||
```js
|
||||
...
|
||||
// make a transfer from Alice to BOB, waiting for inclusion
|
||||
// Make a transfer from Alice to BOB, waiting for inclusion
|
||||
const unsub = await api.tx.balances
|
||||
.transfer(BOB, 12345)
|
||||
.signAndSend(alice, ({ events = [], status }) => {
|
||||
@@ -48,7 +48,7 @@ const unsub = await api.tx.balances
|
||||
if (status.isFinalized) {
|
||||
console.log(`Transaction included at blockHash ${status.asFinalized}`);
|
||||
|
||||
// loop through Vec<EventRecord> to display all events
|
||||
// Loop through Vec<EventRecord> to display all events
|
||||
events.forEach(({ phase, event: { data, method, section } }) => {
|
||||
console.log(`\t' ${phase}: ${section}.${method}:: ${data}`);
|
||||
});
|
||||
@@ -58,7 +58,7 @@ const unsub = await api.tx.balances
|
||||
});
|
||||
```
|
||||
|
||||
Be aware that when a transaction status is `isFinalized`, it means it is included, but it may still have failed - for instance if you try to send a larger amount that you have free, the transaction is included in a block, however from a end-user perspective the transaction failed since the transfer did not occur. In these cases a `system.ExtrinsicFailed` event will be available in the events array.
|
||||
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
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@ When running a development chain (Polkadot/Substrate with a `--dev` flag), or in
|
||||
|
||||
```js
|
||||
...
|
||||
// get the current sudo key in the system
|
||||
// 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`)
|
||||
// Lookup from keyring (assuming we have added all, on --dev this would be `//Alice`)
|
||||
const sudoPair = keyring.getPair(sudoKey);
|
||||
|
||||
// send the actual sudo transaction
|
||||
// Send the actual sudo transaction
|
||||
const unsub = await api.tx.sudo
|
||||
.sudo(
|
||||
api.tx.balances.setBalance(ADDR, 12345, 678)
|
||||
@@ -41,4 +41,4 @@ In the above example, all we need to provide is a the fields for the `ValidatorP
|
||||
|
||||
## 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 reponsibility 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).
|
||||
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 reponsibility 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).
|
||||
|
||||
@@ -27,7 +27,7 @@ In addition to the `api.[consts | query | tx]` detailed above, the API, upon con
|
||||
- `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`
|
||||
- `api.libraryInfo` - The version of the API, i.e. `@polkadot/api v0.90.1`
|
||||
|
||||
## Let's do something!
|
||||
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
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
|
||||
import { ApiPromise, WsProvider } from '@polkadot/api';
|
||||
|
||||
...
|
||||
// construct
|
||||
// Construct
|
||||
const wsProvider = new WsProvider('wss://poc-3.polkadot.io');
|
||||
const api = await ApiPromise.create({ provider: wsProvider });
|
||||
|
||||
// do something
|
||||
// Do something
|
||||
console.log(api.genesisHash.toHex());
|
||||
```
|
||||
|
||||
@@ -21,12 +21,12 @@ We will have some explanation on the ES2015 syntax used next, but just a small n
|
||||
|
||||
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()`.
|
||||
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
|
||||
// Import
|
||||
const { ApiPromise, WsProvider } = require('@polkadot/api');
|
||||
...
|
||||
```
|
||||
@@ -58,13 +58,13 @@ ApiPromise
|
||||
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
|
||||
// Create the instance
|
||||
const api = new ApiPromise({ provider: wsProvider });
|
||||
|
||||
// wait until we are ready and connected
|
||||
// Wait until we are ready and connected
|
||||
await api.isReady;
|
||||
|
||||
// do something
|
||||
// Do something
|
||||
console.log(api.genesisHash.toHex());
|
||||
```
|
||||
|
||||
@@ -76,4 +76,4 @@ In these cases, create via `new`, attach listeners and then wait for the `isRead
|
||||
|
||||
## 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).
|
||||
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).
|
||||
|
||||
+33
-16
@@ -13,13 +13,13 @@ If you do opt to install it seperately, ensure that the version of `@polkadot/ut
|
||||
Once installed, you can create an instance by just creating an instance of the `Keyring` class -
|
||||
|
||||
```js
|
||||
// import the keyring as required
|
||||
// Import the keyring as required
|
||||
import { Keyring } from '@polkadot/api';
|
||||
|
||||
// initialize the API as we would normally do
|
||||
// Initialize the API as we would normally do
|
||||
...
|
||||
|
||||
// create a keyring instance
|
||||
// Create a keyring instance
|
||||
const keyring = new Keyring({ type: 'sr25519' });
|
||||
```
|
||||
|
||||
@@ -27,18 +27,18 @@ In the above example, the import is self-explanatory. Upon creation we pass thro
|
||||
|
||||
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 implictly 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.
|
||||
One "trick" that is done implictly 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
|
||||
// Crypto promise, package used by keyring internally
|
||||
import { cryptoWaitReady } from '@polkadot/util-crypto';
|
||||
|
||||
// wait for the promise to resolve, async WASM or `cryptoWaitReady().then(() => { ... })`
|
||||
// Wait for the promise to resolve, async WASM or `cryptoWaitReady().then(() => { ... })`
|
||||
await cryptoWaitReady();
|
||||
|
||||
// create a keyring instance
|
||||
// Create a keyring instance
|
||||
const keyring = new Keyring({ type: 'sr25519' });
|
||||
```
|
||||
|
||||
@@ -49,21 +49,38 @@ The recommended catch-all approach to adding accounts is via `.addFromUri(<suri>
|
||||
```js
|
||||
...
|
||||
|
||||
// some mnemonic phrase
|
||||
// Some mnemonic phrase
|
||||
const PHRASE = 'entire material egg meadow latin bargain dutch coral blood melt acoustic thought';
|
||||
|
||||
// add an account, straight menemonic
|
||||
// Add an account, straight menemonic
|
||||
const newPair = keyring.addFromUri(PHRASE);
|
||||
|
||||
// (advanced) add an account with a derivation path (hard & soft)
|
||||
// (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
|
||||
// (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 usecases 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 -
|
||||
@@ -71,27 +88,27 @@ In the previous examples we added a pair to the keyring (and we actually immedia
|
||||
```js
|
||||
...
|
||||
|
||||
// add our Alice dev account
|
||||
// Add our Alice dev account
|
||||
const alice = keyring.addFromUri('//Alice', { name: 'Alice default' });
|
||||
|
||||
// log some info
|
||||
// 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
|
||||
// Some helper functions used here
|
||||
import { stringToU8a, u8aToHex } from '@polkadot/util';
|
||||
|
||||
...
|
||||
|
||||
// convert message, sign and then verify
|
||||
// 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
|
||||
// Log info
|
||||
console.log(`The signature ${u8aToHex(signature)}, is ${isValid ? '' : 'in'}valid`);
|
||||
```
|
||||
|
||||
|
||||
@@ -19,9 +19,26 @@ Additionally, the following getters and utilities are available -
|
||||
- `.isEmpty` - `true` if the value is an all-empy 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 -
|
||||
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
|
||||
@@ -30,7 +47,7 @@ In cases where a `Compact` is returned, i.e. `Compact<Balance>`, the value is wr
|
||||
|
||||
## 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.
|
||||
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.
|
||||
|
||||
@@ -48,7 +65,7 @@ An `Option<Type>` attempts to mimic the Rust approach of having `None` and `Some
|
||||
|
||||
- `.isNone` - is `true` if no underlying values is warpped, 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.
|
||||
- `.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
|
||||
@@ -56,7 +73,7 @@ An `Option<Type>` attempts to mimic the Rust approach of having `None` and `Some
|
||||
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)`
|
||||
// Assuming a tuple defined as `(32, AccountId)`
|
||||
const [count, accountId] = tuple;
|
||||
|
||||
console.log(`${accountId} has ${count.toNumber()} values`);
|
||||
|
||||
@@ -6,7 +6,7 @@ Therefore to cater for all types, a mapping in done on the [@polkadot/types libr
|
||||
|
||||
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 codebases.
|
||||
|
||||
There is a the [recommentation](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.
|
||||
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
|
||||
|
||||
@@ -24,7 +24,7 @@ const api = await ApiPromise.create({
|
||||
});
|
||||
```
|
||||
|
||||
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 occurences of `Balance` not as the default, but rather as the defined size.
|
||||
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 occurences of `Balance` not as the default, but rather as the defined size.
|
||||
|
||||
## User-defined types
|
||||
|
||||
@@ -102,7 +102,7 @@ const api = await ApiPromise.create({
|
||||
});
|
||||
```
|
||||
|
||||
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) -
|
||||
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
|
||||
...
|
||||
@@ -139,4 +139,4 @@ const api = await ApiPromise.create({
|
||||
|
||||
## 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).
|
||||
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,6 +1,6 @@
|
||||
# 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`.
|
||||
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
|
||||
|
||||
@@ -13,19 +13,19 @@ 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(header));
|
||||
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).
|
||||
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 bas of all out types)
|
||||
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 -
|
||||
|
||||
@@ -46,11 +46,11 @@ As of this writing, there are still some gray areas to type detection, specifica
|
||||
- `.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 additiont to expanding the type covereage, we wish to make the actual generation script for the types from `@polkadot/types/interfaces` available in 2 ways -
|
||||
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 it is a wrap
|
||||
## 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.
|
||||
|
||||
+54
-51
@@ -30,10 +30,10 @@ ___
|
||||
### 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.
|
||||
- **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).
|
||||
- **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).
|
||||
|
||||
___
|
||||
|
||||
@@ -41,19 +41,19 @@ ___
|
||||
### balances
|
||||
|
||||
▸ **creationFee**: `Balance`
|
||||
- **summary**: The fee required to create an account.
|
||||
- **summary**: The fee required to create an account.
|
||||
|
||||
▸ **existentialDeposit**: `Balance`
|
||||
- **summary**: The minimum amount required to keep an account open.
|
||||
- **summary**: The minimum amount required to keep an account open.
|
||||
|
||||
▸ **transactionBaseFee**: `Balance`
|
||||
- **summary**: The fee to be paid for making a transaction; the base.
|
||||
- **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.
|
||||
- **summary**: The fee to be paid for making a transaction; the per-byte portion.
|
||||
|
||||
▸ **transferFee**: `Balance`
|
||||
- **summary**: The fee required to make a transfer.
|
||||
- **summary**: The fee required to make a transfer.
|
||||
|
||||
___
|
||||
|
||||
@@ -61,52 +61,52 @@ ___
|
||||
### contracts
|
||||
|
||||
▸ **blockGasLimit**: `Gas`
|
||||
- **summary**: The maximum amount of gas that could be expended per block. A reasonable default value is 10_000_000.
|
||||
- **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.
|
||||
- **summary**: The base fee charged for calling into a contract. A reasonable default value is 135.
|
||||
|
||||
▸ **contractFee**: `BalanceOf`
|
||||
- **summary**: The fee required to create a contract instance. A reasonable default value is 21.
|
||||
|
||||
▸ **createBaseFee**: `Gas`
|
||||
- **summary**: The base fee charged for creating a contract. A reasonable default value is 175.
|
||||
- **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.
|
||||
- **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/create stack. A reasonable default value is 100.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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
|
||||
- **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 creation. This is a simple way to ensure that empty contracts eventually gets deleted.
|
||||
- **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.
|
||||
- **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.
|
||||
- **summary**: The minimum amount required to generate a tombstone.
|
||||
|
||||
▸ **transactionBaseFee**: `BalanceOf`
|
||||
- **summary**: The fee to be paid for making a transaction; the base.
|
||||
- **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.
|
||||
- **summary**: The fee to be paid for making a transaction; the per-byte portion.
|
||||
|
||||
▸ **transferFee**: `BalanceOf`
|
||||
- **summary**: The fee required to make a transfer.
|
||||
- **summary**: The fee required to make a transfer.
|
||||
|
||||
___
|
||||
|
||||
@@ -114,22 +114,22 @@ ___
|
||||
### democracy
|
||||
|
||||
▸ **cooloffPeriod**: `BlockNumber`
|
||||
- **summary**: Period in blocks where an external proposal may not be re-submitted after being vetoed.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **summary**: How often (in blocks) to check for new votes.
|
||||
|
||||
___
|
||||
|
||||
@@ -137,34 +137,37 @@ ___
|
||||
### elections
|
||||
|
||||
▸ **approvalSetSize**: `u32`
|
||||
- **summary**: The chunk size of the approval vector.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **summary**: How often (in blocks) to check for new votes. A reasonable default value is 1000.
|
||||
|
||||
___
|
||||
|
||||
@@ -172,10 +175,10 @@ ___
|
||||
### finalityTracker
|
||||
|
||||
▸ **reportLatency**: `BlockNumber`
|
||||
- **summary**: The delay after which point things become suspicious. Default is 1000.
|
||||
- **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.
|
||||
- **summary**: The number of recent samples to keep from this chain. Default is 101.
|
||||
|
||||
___
|
||||
|
||||
@@ -183,7 +186,7 @@ ___
|
||||
### session
|
||||
|
||||
▸ **dedupKeyPrefix**: `Bytes`
|
||||
- **summary**: Used as first key for `NextKeys` and `KeyOwner` to put all the data into the same branch of the trie.
|
||||
- **summary**: Used as first key for `NextKeys` and `KeyOwner` to put all the data into the same branch of the trie.
|
||||
|
||||
___
|
||||
|
||||
@@ -191,10 +194,10 @@ ___
|
||||
### staking
|
||||
|
||||
▸ **bondingDuration**: `EraIndex`
|
||||
- **summary**: Number of eras that staked funds must remain bonded for.
|
||||
- **summary**: Number of eras that staked funds must remain bonded for.
|
||||
|
||||
▸ **sessionsPerEra**: `SessionIndex`
|
||||
- **summary**: Number of sessions per era.
|
||||
- **summary**: Number of sessions per era.
|
||||
|
||||
___
|
||||
|
||||
@@ -202,7 +205,7 @@ ___
|
||||
### 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.
|
||||
- **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.
|
||||
|
||||
___
|
||||
|
||||
@@ -210,13 +213,13 @@ ___
|
||||
### treasury
|
||||
|
||||
▸ **burn**: `Permill`
|
||||
- **summary**: Percentage of spare funds (if any) that are burnt per spend period.
|
||||
- **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.
|
||||
- **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.
|
||||
- **summary**: Minimum amount of funds that should be placed in a deposit for making a proposal.
|
||||
|
||||
▸ **spendPeriod**: `BlockNumber`
|
||||
- **summary**: Period between successive spends.
|
||||
- **summary**: Period between successive spends.
|
||||
|
||||
+52
-49
@@ -42,13 +42,13 @@ ___
|
||||
### balances
|
||||
|
||||
▸ **NewAccount**(`AccountId`, `Balance`)
|
||||
- **summary**: A new account was created.
|
||||
- **summary**: A new account was created.
|
||||
|
||||
▸ **ReapedAccount**(`AccountId`)
|
||||
- **summary**: An account was reaped.
|
||||
- **summary**: An account was reaped.
|
||||
|
||||
▸ **Transfer**(`AccountId`, `AccountId`, `Balance`, `Balance`)
|
||||
- **summary**: Transfer succeeded (from, to, value, fees).
|
||||
- **summary**: Transfer succeeded (from, to, value, fees).
|
||||
|
||||
___
|
||||
|
||||
@@ -56,22 +56,22 @@ ___
|
||||
### contracts
|
||||
|
||||
▸ **CodeStored**(`Hash`)
|
||||
- **summary**: Code with the specified hash has been stored.
|
||||
- **summary**: Code with the specified hash has been stored.
|
||||
|
||||
▸ **Contract**(`AccountId`, `Bytes`)
|
||||
- **summary**: An event from contract of account.
|
||||
- **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.
|
||||
- **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.
|
||||
- **summary**: Contract deployed by address at the specified address.
|
||||
|
||||
▸ **ScheduleUpdated**(`u32`)
|
||||
- **summary**: Triggered when the current schedule is updated.
|
||||
- **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`.
|
||||
- **summary**: Transfer happened `from` to `to` with given `value` as part of a `call` or `instantiate`.
|
||||
|
||||
___
|
||||
|
||||
@@ -79,22 +79,22 @@ ___
|
||||
### council
|
||||
|
||||
▸ **Approved**(`Hash`)
|
||||
- **summary**: A motion was approved by the required threshold.
|
||||
- **summary**: A motion was approved by the required threshold.
|
||||
|
||||
▸ **Disapproved**(`Hash`)
|
||||
- **summary**: A motion was not approved by the required threshold.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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`).
|
||||
- **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`).
|
||||
- **summary**: A motion (given hash) has been voted on by given account, leaving a tally (yes votes and no votes given respectively as `MemberCount`).
|
||||
|
||||
___
|
||||
|
||||
@@ -129,16 +129,16 @@ ___
|
||||
### elections
|
||||
|
||||
▸ **BadReaperSlashed**(`AccountId`)
|
||||
- **summary**: slashed reaper
|
||||
- **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).
|
||||
- **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.
|
||||
- **summary**: A tally (for approval votes of seat(s)) has started.
|
||||
|
||||
▸ **VoterReaped**(`AccountId`, `AccountId`)
|
||||
- **summary**: reaped voter, reaper
|
||||
- **summary**: reaped voter, reaper
|
||||
|
||||
___
|
||||
|
||||
@@ -146,13 +146,13 @@ ___
|
||||
### grandpa
|
||||
|
||||
▸ **NewAuthorities**(`Vec<(AuthorityId,AuthorityWeight)>`)
|
||||
- **summary**: New authority set has been applied.
|
||||
- **summary**: New authority set has been applied.
|
||||
|
||||
▸ **Paused**()
|
||||
- **summary**: Current authority set has been paused.
|
||||
- **summary**: Current authority set has been paused.
|
||||
|
||||
▸ **Resumed**()
|
||||
- **summary**: Current authority set has been resumed.
|
||||
- **summary**: Current authority set has been resumed.
|
||||
|
||||
___
|
||||
|
||||
@@ -160,7 +160,7 @@ ___
|
||||
### imOnline
|
||||
|
||||
▸ **HeartbeatReceived**(`AuthorityId`)
|
||||
- **summary**: A new heartbeat was received from `AuthorityId`
|
||||
- **summary**: A new heartbeat was received from `AuthorityId`
|
||||
|
||||
___
|
||||
|
||||
@@ -168,7 +168,7 @@ ___
|
||||
### 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`.
|
||||
- **summary**: A new account index was assigned. This event is not triggered when an existing index is reassigned to another `AccountId`.
|
||||
|
||||
___
|
||||
|
||||
@@ -176,7 +176,7 @@ ___
|
||||
### 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.
|
||||
- **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.
|
||||
|
||||
___
|
||||
|
||||
@@ -184,7 +184,7 @@ ___
|
||||
### 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.
|
||||
- **summary**: New session has happened. Note that the argument is the session index, not the block number as the type might suggest.
|
||||
|
||||
___
|
||||
|
||||
@@ -192,13 +192,13 @@ ___
|
||||
### staking
|
||||
|
||||
▸ **OldSlashingReportDiscarded**(`SessionIndex`)
|
||||
- **summary**: An old slashing report from a prior era was discarded because it could not be processed.
|
||||
- **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.
|
||||
- **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.
|
||||
- **summary**: One validator (and its nominators) has been slashed by the given amount.
|
||||
|
||||
___
|
||||
|
||||
@@ -206,10 +206,13 @@ ___
|
||||
### sudo
|
||||
|
||||
▸ **KeyChanged**(`AccountId`)
|
||||
- **summary**: The sudoer just switched identity; the old key is supplied.
|
||||
- **summary**: The sudoer just switched identity; the old key is supplied.
|
||||
|
||||
▸ **Sudid**(`bool`)
|
||||
- **summary**: A sudo just took place.
|
||||
- **summary**: A sudo just took place.
|
||||
|
||||
▸ **SudoAsDone**(`bool`)
|
||||
- **summary**: A sudo just took place.
|
||||
|
||||
___
|
||||
|
||||
@@ -217,10 +220,10 @@ ___
|
||||
### system
|
||||
|
||||
▸ **ExtrinsicFailed**(`DispatchError`)
|
||||
- **summary**: An extrinsic failed.
|
||||
- **summary**: An extrinsic failed.
|
||||
|
||||
▸ **ExtrinsicSuccess**()
|
||||
- **summary**: An extrinsic completed successfully.
|
||||
- **summary**: An extrinsic completed successfully.
|
||||
|
||||
___
|
||||
|
||||
@@ -228,22 +231,22 @@ ___
|
||||
### technicalCommittee
|
||||
|
||||
▸ **Approved**(`Hash`)
|
||||
- **summary**: A motion was approved by the required threshold.
|
||||
- **summary**: A motion was approved by the required threshold.
|
||||
|
||||
▸ **Disapproved**(`Hash`)
|
||||
- **summary**: A motion was not approved by the required threshold.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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`).
|
||||
- **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`).
|
||||
- **summary**: A motion (given hash) has been voted on by given account, leaving a tally (yes votes and no votes given respectively as `MemberCount`).
|
||||
|
||||
___
|
||||
|
||||
@@ -251,19 +254,19 @@ ___
|
||||
### technicalMembership
|
||||
|
||||
▸ **Dummy**(`PhantomData`)
|
||||
- **summary**: Phantom member, never used.
|
||||
- **summary**: Phantom member, never used.
|
||||
|
||||
▸ **MemberAdded**()
|
||||
- **summary**: The given member was added; see the transaction for who.
|
||||
- **summary**: The given member was added; see the transaction for who.
|
||||
|
||||
▸ **MemberRemoved**()
|
||||
- **summary**: The given member was removed; see the transaction for who.
|
||||
- **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.
|
||||
- **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.
|
||||
- **summary**: Two members were swapped; see the transaction for who.
|
||||
|
||||
___
|
||||
|
||||
@@ -271,16 +274,16 @@ ___
|
||||
### treasury
|
||||
|
||||
▸ **Awarded**(`ProposalIndex`, `Balance`, `AccountId`)
|
||||
- **summary**: Some funds have been allocated.
|
||||
- **summary**: Some funds have been allocated.
|
||||
|
||||
▸ **Burnt**(`Balance`)
|
||||
- **summary**: Some of our funds have been burnt.
|
||||
- **summary**: Some of our funds have been burnt.
|
||||
|
||||
▸ **Proposed**(`ProposalIndex`)
|
||||
- **summary**: New proposal.
|
||||
- **summary**: New proposal.
|
||||
|
||||
▸ **Rollover**(`Balance`)
|
||||
- **summary**: Spending has finished; this is the amount that rolls over until next spend.
|
||||
- **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.
|
||||
- **summary**: We have ended a spend period and will now allocate funds.
|
||||
|
||||
@@ -5,8 +5,6 @@ The following sections contain Extrinsics methods are part of the default Substr
|
||||
(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)**
|
||||
@@ -46,15 +44,7 @@ ___
|
||||
### authorship
|
||||
|
||||
▸ **setUncles**(new_uncles: `Vec<Header>`)
|
||||
- **summary**: Provide a set of uncles.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### babe
|
||||
|
||||
▸ **setPendingSecondarySlotsChange**(change: `Option<bool>`)
|
||||
- **summary**: Sets a pending change to enable / disable secondary slot assignment. The pending change will be set at the end of the current epoch and will be enacted at `current_epoch + 2`.
|
||||
- **summary**: Provide a set of uncles.
|
||||
|
||||
___
|
||||
|
||||
@@ -62,13 +52,13 @@ ___
|
||||
### 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.
|
||||
- **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>
|
||||
- **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>
|
||||
- **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>
|
||||
|
||||
___
|
||||
|
||||
@@ -76,19 +66,19 @@ ___
|
||||
### 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.
|
||||
- **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.
|
||||
- **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.
|
||||
▸ **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.
|
||||
- **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.
|
||||
- **summary**: Updates the schedule for metering contracts. The schedule must have a greater version than the stored schedule.
|
||||
|
||||
___
|
||||
|
||||
@@ -96,16 +86,16 @@ ___
|
||||
### council
|
||||
|
||||
▸ **execute**(proposal: `Proposal`)
|
||||
- **summary**: Dispatch a proposal from a member using the `Member` origin. Origin must be a member of the collective.
|
||||
- **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>
|
||||
- **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.
|
||||
- **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>
|
||||
- **summary**: # <weight> - Bounded storage read and writes. - Will be slightly heavier if the proposal is approved / disapproved after the vote. # </weight>
|
||||
|
||||
___
|
||||
|
||||
@@ -113,55 +103,55 @@ ___
|
||||
### democracy
|
||||
|
||||
▸ **cancelQueued**(when: `Compact<BlockNumber>`, which: `Compact<u32>`, what: `Compact<ReferendumIndex>`)
|
||||
- **summary**: Cancel a proposal queued for enactment.
|
||||
- **summary**: Cancel a proposal queued for enactment.
|
||||
|
||||
▸ **cancelReferendum**(ref_index: `Compact<ReferendumIndex>`)
|
||||
- **summary**: Remove a referendum.
|
||||
- **summary**: Remove a referendum.
|
||||
|
||||
▸ **delegate**(to: `AccountId`, conviction: `Conviction`)
|
||||
- **summary**: Delegate vote. # <weight> - One extra DB entry. # </weight>
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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>
|
||||
- **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>
|
||||
- **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>
|
||||
- **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>
|
||||
- **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>
|
||||
- **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>
|
||||
- **summary**: Specify a proxy. Called by the stash. # <weight> - One extra DB entry. # </weight>
|
||||
|
||||
▸ **undelegate**()
|
||||
- **summary**: Undelegate vote. # <weight> - O(1). # </weight>
|
||||
- **summary**: Undelegate vote. # <weight> - O(1). # </weight>
|
||||
|
||||
▸ **vetoExternal**(proposal_hash: `Hash`)
|
||||
- **summary**: Veto and blacklist the external proposal 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>
|
||||
- **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>
|
||||
|
||||
___
|
||||
|
||||
@@ -169,34 +159,34 @@ ___
|
||||
### elections
|
||||
|
||||
▸ **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 # <weight> - O(voters) compute. - One DB change. # </weight>
|
||||
- **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`)
|
||||
- **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>
|
||||
▸ **proxySetApprovals**(votes: `Vec<bool>`, index: `Compact<VoteIndex>`, hint: `SetIndex`, value: `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>
|
||||
- **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.
|
||||
- **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>
|
||||
- **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`)
|
||||
- **summary**: Set candidate approvals. Approval slots stay valid as long as candidates in those slots are registered. Locks the total balance of caller 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>
|
||||
▸ **setApprovals**(votes: `Vec<bool>`, index: `Compact<VoteIndex>`, hint: `SetIndex`, value: `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.
|
||||
- **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`.
|
||||
- **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`.
|
||||
- **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>
|
||||
- **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>
|
||||
|
||||
___
|
||||
|
||||
@@ -204,7 +194,7 @@ ___
|
||||
### finalityTracker
|
||||
|
||||
▸ **finalHint**(hint: `Compact<BlockNumber>`)
|
||||
- **summary**: Hint that the author of this block thinks the best finalized block is the given number.
|
||||
- **summary**: Hint that the author of this block thinks the best finalized block is the given number.
|
||||
|
||||
___
|
||||
|
||||
@@ -212,7 +202,7 @@ ___
|
||||
### grandpa
|
||||
|
||||
▸ **reportMisbehavior**(_report: `Bytes`)
|
||||
- **summary**: Report some misbehavior.
|
||||
- **summary**: Report some misbehavior.
|
||||
|
||||
___
|
||||
|
||||
@@ -227,7 +217,7 @@ ___
|
||||
### 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>
|
||||
- **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>
|
||||
|
||||
___
|
||||
|
||||
@@ -235,43 +225,43 @@ ___
|
||||
### 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>
|
||||
- **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>
|
||||
- **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>
|
||||
- **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>
|
||||
- **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>
|
||||
- **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>
|
||||
- **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>
|
||||
- **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).
|
||||
- **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>
|
||||
- **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.
|
||||
- **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>
|
||||
- **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>
|
||||
- **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>
|
||||
- **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>
|
||||
|
||||
___
|
||||
|
||||
@@ -279,10 +269,13 @@ ___
|
||||
### 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>
|
||||
- **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. - No DB writes. # </weight>
|
||||
- **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>
|
||||
|
||||
___
|
||||
|
||||
@@ -290,22 +283,22 @@ ___
|
||||
### system
|
||||
|
||||
▸ **fillBlock**()
|
||||
- **summary**: A big dispatch that will disallow any other transaction to be included.
|
||||
- **summary**: A big dispatch that will disallow any other transaction to be included.
|
||||
|
||||
▸ **killStorage**(keys: `Vec<Key>`)
|
||||
- **summary**: Kill some items from storage.
|
||||
- **summary**: Kill some items from storage.
|
||||
|
||||
▸ **remark**(_remark: `Bytes`)
|
||||
- **summary**: Make some on-chain remark.
|
||||
- **summary**: Make some on-chain remark.
|
||||
|
||||
▸ **setCode**(new: `Bytes`)
|
||||
- **summary**: Set the new code.
|
||||
- **summary**: Set the new code.
|
||||
|
||||
▸ **setHeapPages**(pages: `u64`)
|
||||
- **summary**: Set the number of pages in the WebAssembly environment's heap.
|
||||
- **summary**: Set the number of pages in the WebAssembly environment's heap.
|
||||
|
||||
▸ **setStorage**(items: `Vec<KeyValue>`)
|
||||
- **summary**: Set some items of storage.
|
||||
- **summary**: Set some items of storage.
|
||||
|
||||
___
|
||||
|
||||
@@ -313,16 +306,16 @@ ___
|
||||
### technicalCommittee
|
||||
|
||||
▸ **execute**(proposal: `Proposal`)
|
||||
- **summary**: Dispatch a proposal from a member using the `Member` origin. Origin must be a member of the collective.
|
||||
- **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>
|
||||
- **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.
|
||||
- **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>
|
||||
- **summary**: # <weight> - Bounded storage read and writes. - Will be slightly heavier if the proposal is approved / disapproved after the vote. # </weight>
|
||||
|
||||
___
|
||||
|
||||
@@ -330,16 +323,16 @@ ___
|
||||
### technicalMembership
|
||||
|
||||
▸ **addMember**(who: `AccountId`)
|
||||
- **summary**: Add a member `who` to the set. May only be called from `AddOrigin` or root.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **summary**: Swap out one member `remove` for another `add`. May only be called from `SwapOrigin` or root.
|
||||
|
||||
___
|
||||
|
||||
@@ -347,7 +340,7 @@ ___
|
||||
### 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`.
|
||||
- **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`.
|
||||
|
||||
___
|
||||
|
||||
@@ -355,10 +348,10 @@ ___
|
||||
### 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>
|
||||
- **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>
|
||||
- **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>
|
||||
- **summary**: Reject a proposed spend. The original deposit will be slashed. # <weight> - O(1). - Limited storage reads. - One DB clear. # </weight>
|
||||
|
||||
@@ -2,10 +2,16 @@
|
||||
|
||||
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)**
|
||||
|
||||
- **[author](#author)**
|
||||
|
||||
- **[chain](#chain)**
|
||||
|
||||
- **[contracts](#contracts)**
|
||||
|
||||
- **[rpc](#rpc)**
|
||||
|
||||
- **[state](#state)**
|
||||
|
||||
- **[system](#system)**
|
||||
@@ -14,6 +20,16 @@ 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_
|
||||
@@ -64,6 +80,26 @@ _Retrieval of chain data_
|
||||
___
|
||||
|
||||
|
||||
### 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
|
||||
|
||||
___
|
||||
|
||||
|
||||
### state
|
||||
|
||||
_Query of state_
|
||||
|
||||
+130
-134
@@ -50,13 +50,13 @@ ___
|
||||
### authorship
|
||||
|
||||
▸ **author**(): `Option<AccountId>`
|
||||
- **summary**: Author of current block.
|
||||
- **summary**: Author of current block.
|
||||
|
||||
▸ **didSetUncles**(): `bool`
|
||||
- **summary**: Whether uncles were already set in this block.
|
||||
- **summary**: Whether uncles were already set in this block.
|
||||
|
||||
▸ **uncles**(): `Vec<UncleEntryItem>`
|
||||
- **summary**: Uncles
|
||||
- **summary**: Uncles
|
||||
|
||||
___
|
||||
|
||||
@@ -64,34 +64,28 @@ ___
|
||||
### babe
|
||||
|
||||
▸ **authorities**(): `Vec<(AuthorityId,BabeAuthorityWeight)>`
|
||||
- **summary**: Current epoch authorities.
|
||||
- **summary**: Current epoch authorities.
|
||||
|
||||
▸ **currentSlot**(): `u64`
|
||||
- **summary**: Current slot number.
|
||||
- **summary**: Current slot number.
|
||||
|
||||
▸ **epochIndex**(): `u64`
|
||||
- **summary**: Current epoch index.
|
||||
- **summary**: Current epoch index.
|
||||
|
||||
▸ **epochStartSlot**(): `u64`
|
||||
- **summary**: Slot at which the current epoch started. It is possible that no block was authored at the given slot and the epoch change was signalled later than this.
|
||||
▸ **genesisSlot**(): `u64`
|
||||
- **summary**: The slot at which the first epoch actually started. This is 0 until the first block of the chain.
|
||||
|
||||
▸ **initialized**(): `Option<bool>`
|
||||
- **summary**: Temporary value (cleared at block finalization) which is true if per-block initialization has already been called for current block.
|
||||
▸ **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.
|
||||
|
||||
▸ **pendingSecondarySlotsChange**(): `Option<bool>`
|
||||
- **summary**: Pending change to enable/disable secondary slots which will be triggered at `current_epoch + 2`.
|
||||
- **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.
|
||||
|
||||
▸ **secondarySlots**(): `(bool,bool)`
|
||||
- **summary**: Whether secondary slots are enabled in case the VRF-based slot is empty for the current epoch and the next epoch, respectively.
|
||||
- **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.
|
||||
- **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]>`
|
||||
|
||||
@@ -101,19 +95,19 @@ ___
|
||||
### 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`.
|
||||
- **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.
|
||||
- **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`.)
|
||||
- **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.
|
||||
- **summary**: The total units issued in the system.
|
||||
|
||||
▸ **vesting**(`AccountId`): `Option<VestingSchedule>`
|
||||
- **summary**: Information regarding the vesting of a given account.
|
||||
- **summary**: Information regarding the vesting of a given account.
|
||||
|
||||
___
|
||||
|
||||
@@ -121,25 +115,25 @@ ___
|
||||
### contracts
|
||||
|
||||
▸ **accountCounter**(): `u64`
|
||||
- **summary**: The subtrie counter.
|
||||
- **summary**: The subtrie counter.
|
||||
|
||||
▸ **codeStorage**(`CodeHash`): `Option<PrefabWasmModule>`
|
||||
- **summary**: A mapping between an original code hash and instrumented wasm code, ready for execution.
|
||||
- **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.
|
||||
- **summary**: The code associated with a given account.
|
||||
|
||||
▸ **currentSchedule**(): `Schedule`
|
||||
- **summary**: Current cost schedule for contracts.
|
||||
- **summary**: Current cost schedule for contracts.
|
||||
|
||||
▸ **gasPrice**(): `BalanceOf`
|
||||
- **summary**: The price of one unit of gas.
|
||||
- **summary**: The price of one unit of gas.
|
||||
|
||||
▸ **gasSpent**(): `Gas`
|
||||
- **summary**: Gas spent so far in this block.
|
||||
- **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.
|
||||
- **summary**: A mapping from an original code hash to the original code, untouched by instrumentation.
|
||||
|
||||
___
|
||||
|
||||
@@ -147,19 +141,19 @@ ___
|
||||
### council
|
||||
|
||||
▸ **members**(): `Vec<AccountId>`
|
||||
- **summary**: The current members of the collective. This is stored sorted (just by value).
|
||||
- **summary**: The current members of the collective. This is stored sorted (just by value).
|
||||
|
||||
▸ **proposalCount**(): `u32`
|
||||
- **summary**: Proposals so far.
|
||||
- **summary**: Proposals so far.
|
||||
|
||||
▸ **proposalOf**(`Hash`): `Option<Proposal>`
|
||||
- **summary**: Actual proposal for a given hash, if it's current.
|
||||
- **summary**: Actual proposal for a given hash, if it's current.
|
||||
|
||||
▸ **proposals**(): `Vec<Hash>`
|
||||
- **summary**: The hashes of the active proposals.
|
||||
- **summary**: The hashes of the active proposals.
|
||||
|
||||
▸ **voting**(`Hash`): `Option<Votes>`
|
||||
- **summary**: Votes on a given proposal, if it is ongoing.
|
||||
- **summary**: Votes on a given proposal, if it is ongoing.
|
||||
|
||||
___
|
||||
|
||||
@@ -167,49 +161,49 @@ ___
|
||||
### 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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **summary**: Those who have locked a deposit.
|
||||
|
||||
▸ **dispatchQueue**(`BlockNumber`): `Vec<Option<(Proposal,ReferendumIndex)>>`
|
||||
- **summary**: Queue of successful referenda to be dispatched.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **summary**: The number of (public) proposals that have been made so far.
|
||||
|
||||
▸ **publicProps**(): `Vec<(PropIndex,Proposal,AccountId)>`
|
||||
- **summary**: The public proposals. Unsorted.
|
||||
- **summary**: The public proposals. Unsorted.
|
||||
|
||||
▸ **referendumCount**(): `ReferendumIndex`
|
||||
- **summary**: The next free referendum index, aka the number of referenda started so far.
|
||||
- **summary**: The next free referendum index, aka the number of referenda started so far.
|
||||
|
||||
▸ **referendumInfoOf**(`ReferendumIndex`): `Option<ReferendumInfo>`
|
||||
- **summary**: Information concerning any given referendum.
|
||||
- **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.
|
||||
- **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.
|
||||
- **summary**: Get the voters for the current proposal.
|
||||
|
||||
___
|
||||
|
||||
@@ -217,52 +211,51 @@ ___
|
||||
### elections
|
||||
|
||||
▸ **approvalsOf**(`(AccountId,SetIndex)`): `Vec<ApprovalFlag>`
|
||||
- **summary**: A list of votes for each voter. The votes are stored as numeric values and parsed in a bit-wise manner. In order to get a human-readable representation (`Vec<bool>`), use [`all_approvals_of`]. Furthermore, each vector of scalars is chunked with the cap of `APPROVAL_SET_SIZE`.
|
||||
|
||||
▸ **candidateCount**(): `u32`
|
||||
- **summary**: Current number of active candidates
|
||||
- **summary**: Current number of active candidates
|
||||
|
||||
▸ **candidates**(): `Vec<AccountId>`
|
||||
- **summary**: The present candidate list.
|
||||
- **summary**: The present candidate list.
|
||||
|
||||
▸ **desiredSeats**(): `u32`
|
||||
- **summary**: Number of accounts that should constitute the collective.
|
||||
- **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.
|
||||
- **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).
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **summary**: How long each position is active for.
|
||||
|
||||
▸ **voteCount**(): `VoteIndex`
|
||||
- **summary**: The total number of vote rounds that have happened or are in progress.
|
||||
- **summary**: The total number of vote rounds that have happened or are in progress.
|
||||
|
||||
▸ **voterCount**(): `SetIndex`
|
||||
- **summary**: Current number of Voters.
|
||||
- **summary**: Current number of Voters.
|
||||
|
||||
▸ **voterInfoOf**(`AccountId`): `Option<VoterInfo>`
|
||||
- **summary**: Basic information about a voter.
|
||||
- **summary**: Basic information about a voter.
|
||||
|
||||
▸ **voters**(`SetIndex`): `Vec<Option<AccountId>>`
|
||||
- **summary**: The present voter list (chunked and capped at [`VOTER_SET_SIZE`]).
|
||||
- **summary**: The present voter list (chunked and capped at [`VOTER_SET_SIZE`]).
|
||||
|
||||
___
|
||||
|
||||
@@ -270,25 +263,25 @@ ___
|
||||
### grandpa
|
||||
|
||||
▸ **authorities**(): `Vec<(AuthorityId,AuthorityWeight)>`
|
||||
- **summary**: The current authority set.
|
||||
- **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.
|
||||
- **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.
|
||||
- **summary**: next block number where we can force a change.
|
||||
|
||||
▸ **pendingChange**(): `Option<StoredPendingChange>`
|
||||
- **summary**: Pending change: (signaled at, scheduled change).
|
||||
- **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.
|
||||
- **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.
|
||||
- **summary**: `true` if we are currently stalled.
|
||||
|
||||
▸ **state**(): `StoredState`
|
||||
- **summary**: State of the current authority set.
|
||||
- **summary**: State of the current authority set.
|
||||
|
||||
___
|
||||
|
||||
@@ -296,13 +289,13 @@ ___
|
||||
### imOnline
|
||||
|
||||
▸ **gossipAt**(): `BlockNumber`
|
||||
- **summary**: The block number when we should gossip.
|
||||
- **summary**: The block number when we should gossip.
|
||||
|
||||
▸ **keys**(): `Vec<AuthorityId>`
|
||||
- **summary**: The current set of keys that may issue a heartbeat.
|
||||
- **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`.
|
||||
- **summary**: For each session index we keep a mapping of `AuthorityId` to `offchain::OpaqueNetworkState`.
|
||||
|
||||
___
|
||||
|
||||
@@ -310,10 +303,10 @@ ___
|
||||
### indices
|
||||
|
||||
▸ **enumSet**(`AccountIndex`): `Vec<AccountId>`
|
||||
- **summary**: The enumeration sets.
|
||||
- **summary**: The enumeration sets.
|
||||
|
||||
▸ **nextEnumSet**(): `AccountIndex`
|
||||
- **summary**: The next free enumeration set.
|
||||
- **summary**: The next free enumeration set.
|
||||
|
||||
___
|
||||
|
||||
@@ -321,13 +314,13 @@ ___
|
||||
### offences
|
||||
|
||||
▸ **concurrentReportsIndex**(`Kind, OpaqueTimeSlot`): `Vec<ReportIdOf>`
|
||||
- **summary**: A vector of reports of the same kind that happened at the same time slot.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
|
||||
___
|
||||
|
||||
@@ -335,22 +328,25 @@ ___
|
||||
### session
|
||||
|
||||
▸ **currentIndex**(): `SessionIndex`
|
||||
- **summary**: Current index of the session.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **summary**: The current set of validators.
|
||||
|
||||
___
|
||||
|
||||
@@ -358,61 +354,61 @@ ___
|
||||
### staking
|
||||
|
||||
▸ **bonded**(`AccountId`): `Option<AccountId>`
|
||||
- **summary**: Map from all locked "stash" accounts to the controller account.
|
||||
- **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.
|
||||
- **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.
|
||||
- **summary**: The currently elected validator set keyed by stash account ID.
|
||||
|
||||
▸ **currentEra**(): `EraIndex`
|
||||
- **summary**: The current era index.
|
||||
- **summary**: The current era index.
|
||||
|
||||
▸ **currentEraPointsEarned**(): `EraPoints`
|
||||
- **summary**: Rewards for the current era. Using indices of current elected set.
|
||||
- **summary**: Rewards for the current era. Using indices of current elected set.
|
||||
|
||||
▸ **currentEraStart**(): `MomentOf`
|
||||
- **summary**: The start of the current era.
|
||||
- **summary**: The start of the current era.
|
||||
|
||||
▸ **currentEraStartSessionIndex**(): `SessionIndex`
|
||||
- **summary**: The session index at which the current era started.
|
||||
- **summary**: The session index at which the current era started.
|
||||
|
||||
▸ **eraSlashJournal**(`EraIndex`): `Vec<SlashJournalEntry>`
|
||||
- **summary**: All slashes that have occurred in a given era.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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`.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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.
|
||||
- **summary**: The map from (wannabe) validator stash key to the preferences of that validator.
|
||||
|
||||
___
|
||||
|
||||
@@ -420,7 +416,7 @@ ___
|
||||
### sudo
|
||||
|
||||
▸ **key**(): `AccountId`
|
||||
- **summary**: The `AccountId` of the sudo key.
|
||||
- **summary**: The `AccountId` of the sudo key.
|
||||
|
||||
___
|
||||
|
||||
@@ -428,49 +424,49 @@ ___
|
||||
### system
|
||||
|
||||
▸ **accountNonce**(`AccountId`): `Index`
|
||||
- **summary**: Extrinsics nonce for accounts.
|
||||
- **summary**: Extrinsics nonce for accounts.
|
||||
|
||||
▸ **allExtrinsicsLen**(): `Option<u32>`
|
||||
- **summary**: Total length (in bytes) for all extrinsics put together, for the current block.
|
||||
- **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.
|
||||
- **summary**: Total weight for all extrinsics put together, for the current block.
|
||||
|
||||
▸ **blockHash**(`BlockNumber`): `Hash`
|
||||
- **summary**: Map of block numbers to block hashes.
|
||||
- **summary**: Map of block numbers to block hashes.
|
||||
|
||||
▸ **digest**(): `DigestOf`
|
||||
- **summary**: Digest of the current block, also part of the block header.
|
||||
- **summary**: Digest of the current block, also part of the block header.
|
||||
|
||||
▸ **eventCount**(): `EventIndex`
|
||||
- **summary**: The number of events in the `Events<T>` list.
|
||||
- **summary**: The number of events in the `Events<T>` list.
|
||||
|
||||
▸ **events**(): `Vec<EventRecord>`
|
||||
- **summary**: Events deposited for the current block.
|
||||
- **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.
|
||||
- **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.
|
||||
- **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).
|
||||
- **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.
|
||||
- **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).
|
||||
- **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`.
|
||||
- **summary**: The current block number being processed. Set by `execute_block`.
|
||||
|
||||
▸ **parentHash**(): `Hash`
|
||||
- **summary**: Hash of the previous block.
|
||||
- **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.
|
||||
- **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.
|
||||
|
||||
___
|
||||
|
||||
@@ -478,19 +474,19 @@ ___
|
||||
### technicalCommittee
|
||||
|
||||
▸ **members**(): `Vec<AccountId>`
|
||||
- **summary**: The current members of the collective. This is stored sorted (just by value).
|
||||
- **summary**: The current members of the collective. This is stored sorted (just by value).
|
||||
|
||||
▸ **proposalCount**(): `u32`
|
||||
- **summary**: Proposals so far.
|
||||
- **summary**: Proposals so far.
|
||||
|
||||
▸ **proposalOf**(`Hash`): `Option<Proposal>`
|
||||
- **summary**: Actual proposal for a given hash, if it's current.
|
||||
- **summary**: Actual proposal for a given hash, if it's current.
|
||||
|
||||
▸ **proposals**(): `Vec<Hash>`
|
||||
- **summary**: The hashes of the active proposals.
|
||||
- **summary**: The hashes of the active proposals.
|
||||
|
||||
▸ **voting**(`Hash`): `Option<Votes>`
|
||||
- **summary**: Votes on a given proposal, if it is ongoing.
|
||||
- **summary**: Votes on a given proposal, if it is ongoing.
|
||||
|
||||
___
|
||||
|
||||
@@ -498,7 +494,7 @@ ___
|
||||
### technicalMembership
|
||||
|
||||
▸ **members**(): `Vec<AccountId>`
|
||||
- **summary**: The current membership, stored as an ordered Vec.
|
||||
- **summary**: The current membership, stored as an ordered Vec.
|
||||
|
||||
___
|
||||
|
||||
@@ -506,10 +502,10 @@ ___
|
||||
### timestamp
|
||||
|
||||
▸ **didUpdate**(): `bool`
|
||||
- **summary**: Did the timestamp get updated in this block?
|
||||
- **summary**: Did the timestamp get updated in this block?
|
||||
|
||||
▸ **now**(): `Moment`
|
||||
- **summary**: Current time for the current block.
|
||||
- **summary**: Current time for the current block.
|
||||
|
||||
___
|
||||
|
||||
@@ -517,13 +513,13 @@ ___
|
||||
### treasury
|
||||
|
||||
▸ **approvals**(): `Vec<ProposalIndex>`
|
||||
- **summary**: Proposal indices that have been approved but not yet awarded.
|
||||
- **summary**: Proposal indices that have been approved but not yet awarded.
|
||||
|
||||
▸ **proposalCount**(): `ProposalIndex`
|
||||
- **summary**: Number of proposals that have been made.
|
||||
- **summary**: Number of proposals that have been made.
|
||||
|
||||
▸ **proposals**(`ProposalIndex`): `Option<TreasuryProposal>`
|
||||
- **summary**: Proposals that have been made.
|
||||
- **summary**: Proposals that have been made.
|
||||
|
||||
---
|
||||
|
||||
|
||||
+1
-1
@@ -9,5 +9,5 @@
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "0.92.1"
|
||||
"version": "0.93.1"
|
||||
}
|
||||
|
||||
+6
-6
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "0.92.1",
|
||||
"version": "0.93.1",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"yarn": "^1.10.1"
|
||||
@@ -30,11 +30,11 @@
|
||||
"test:watch": "jest --coverage --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.6.0",
|
||||
"@babel/register": "^7.6.0",
|
||||
"@babel/runtime": "^7.6.0",
|
||||
"@polkadot/dev": "^0.31.0-beta.8",
|
||||
"@polkadot/ts": "^0.1.72",
|
||||
"@babel/core": "^7.6.2",
|
||||
"@babel/register": "^7.6.2",
|
||||
"@babel/runtime": "^7.6.2",
|
||||
"@polkadot/dev": "^0.31.1",
|
||||
"@polkadot/ts": "^0.1.73",
|
||||
"gh-pages": "^2.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-contract",
|
||||
"version": "0.92.1",
|
||||
"version": "0.93.1",
|
||||
"description": "Interfaces for interacting with contracts and contract ABIs",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -26,7 +26,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.6.0",
|
||||
"@polkadot/types": "^0.92.1"
|
||||
"@babel/runtime": "^7.6.2",
|
||||
"@polkadot/types": "^0.93.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-derive",
|
||||
"version": "0.92.1",
|
||||
"version": "0.93.1",
|
||||
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,11 +27,11 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.6.0",
|
||||
"@polkadot/api": "^0.92.1",
|
||||
"@polkadot/types": "^0.92.1"
|
||||
"@babel/runtime": "^7.6.2",
|
||||
"@polkadot/api": "^0.93.1",
|
||||
"@polkadot/types": "^0.93.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^1.4.1"
|
||||
"@polkadot/keyring": "^1.5.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,10 @@ import { drr } from '../util/drr';
|
||||
import { bestNumber } from '../chain';
|
||||
|
||||
type Result0to94 = [BlockNumber, [SessionIndex, Option<BlockNumber>, BN, BN, SessionIndex]];
|
||||
type Result = [[u64, SessionIndex], [u64, u64, u64, SessionIndex, EraIndex]];
|
||||
type Result = [[boolean, boolean, u64, SessionIndex], [u64, u64, u64], [SessionIndex, EraIndex]];
|
||||
|
||||
const ZERO = new BN(0);
|
||||
const ONE = new BN(1);
|
||||
|
||||
// internal helper to just split the logic - take all inputs, do the calculations and combine
|
||||
function createDerived0to94 ([bestNumber, [currentIndex, _lastLengthChange, sessionLength, lastEraLengthChange, sessionsPerEra]]: Result0to94): DerivedSessionInfo {
|
||||
@@ -48,21 +49,24 @@ function createDerived0to94 ([bestNumber, [currentIndex, _lastLengthChange, sess
|
||||
} as unknown as DerivedSessionInfo;
|
||||
}
|
||||
|
||||
function createDerived ([[epochDuration, sessionsPerEra], [currentSlot, epochIndex, epochStartSlot, currentIndex, currentEra]]: Result): DerivedSessionInfo {
|
||||
function createDerived ([[hasBabe, isGenesisSlot, epochDuration, sessionsPerEra], [currentSlot, epochIndex, epochOrGenesisStartSlot], [currentIndex, currentEra]]: Result): DerivedSessionInfo {
|
||||
const epochStartSlot = isGenesisSlot
|
||||
? epochIndex
|
||||
.mul(epochDuration)
|
||||
.add(epochOrGenesisStartSlot)
|
||||
: epochOrGenesisStartSlot;
|
||||
const sessionProgress = currentSlot.sub(epochStartSlot);
|
||||
const eraProgress = epochIndex
|
||||
.mod(sessionsPerEra)
|
||||
.mul(epochDuration)
|
||||
.add(sessionProgress);
|
||||
|
||||
// FIXME This alwasy assumes Babe, as per the substrate defaults - at least for
|
||||
// aura the `isEpoch` should be false
|
||||
return {
|
||||
currentEra,
|
||||
currentIndex,
|
||||
eraLength: sessionsPerEra.mul(epochDuration),
|
||||
eraProgress,
|
||||
isEpoch: true,
|
||||
isEpoch: hasBabe,
|
||||
lastEraLengthChange: ZERO,
|
||||
lastLengthChange: epochStartSlot,
|
||||
sessionLength: epochDuration,
|
||||
@@ -75,6 +79,8 @@ function createDerived ([[epochDuration, sessionsPerEra], [currentSlot, epochInd
|
||||
* @description Retrieves all the session and era info and calculates specific values on it as the length of the session and eras
|
||||
*/
|
||||
export function info (api: ApiInterfaceRx): () => Observable<DerivedSessionInfo> {
|
||||
const hasBabe = !!api.consts.babe;
|
||||
|
||||
return (): Observable<DerivedSessionInfo> => {
|
||||
// With substrate `spec_version 94`, the era and session has been explicitly exposed as `parameter_types`.
|
||||
// pre-94 we had more info and needed to calculate (handle old/Alex first)
|
||||
@@ -101,13 +107,23 @@ export function info (api: ApiInterfaceRx): () => Observable<DerivedSessionInfo>
|
||||
// substrate spec_version >= 94 : get from parameter_types exposed as api.consts
|
||||
// https://github.com/paritytech/substrate/pull/2802/files#diff-5e5e1c3aec9ddfde0a9054d062ab3db9R156
|
||||
of([
|
||||
api.consts.babe.epochDuration,
|
||||
hasBabe,
|
||||
!!api.query.babe.genesisSlot,
|
||||
hasBabe
|
||||
? api.consts.babe.epochDuration
|
||||
: ONE,
|
||||
api.consts.staking.sessionsPerEra
|
||||
]),
|
||||
hasBabe
|
||||
? api.queryMulti([
|
||||
api.query.babe.currentSlot,
|
||||
api.query.babe.epochIndex,
|
||||
api.query.babe.genesisSlot
|
||||
? api.query.babe.genesisSlot
|
||||
: api.query.babe.epochStartSlot
|
||||
])
|
||||
: of([ONE, ONE, ONE]),
|
||||
api.queryMulti([
|
||||
api.query.babe.currentSlot,
|
||||
api.query.babe.epochIndex,
|
||||
api.query.babe.epochStartSlot,
|
||||
api.query.session.currentIndex,
|
||||
api.query.staking.currentEra
|
||||
])
|
||||
|
||||
@@ -171,10 +171,10 @@ export function info (api: ApiInterfaceRx): (_accountId: Uint8Array | string) =>
|
||||
// NOTE For 2.x-only support, only the first path is required, therefore we
|
||||
// can replace this with `.bonded<Option<AccountId>>(accountId)` - in 2.x
|
||||
// the session.validators return the stashes (as expected)
|
||||
api.queryMulti([
|
||||
api.queryMulti<[Option<AccountId>, Option<StakingLedger>]>([
|
||||
[api.query.staking.bonded, accountId], // try to map to controller
|
||||
[api.query.staking.ledger, accountId] // try to map to stash (1.x only)
|
||||
]) as Observable<[Option<AccountId>, Option<StakingLedger>]>
|
||||
])
|
||||
).pipe(
|
||||
switchMap(([controllerId, stakingLedger]): Observable<DerivedStaking> =>
|
||||
controllerId.isSome
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-metadata",
|
||||
"version": "0.92.1",
|
||||
"version": "0.93.1",
|
||||
"description": "Helpers to extract information from runtime metadata",
|
||||
"main": "index.js",
|
||||
"publishConfig": {
|
||||
@@ -26,12 +26,12 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.6.0",
|
||||
"@polkadot/types": "^0.92.1",
|
||||
"@polkadot/util": "^1.4.1",
|
||||
"@polkadot/util-crypto": "^1.4.1"
|
||||
"@babel/runtime": "^7.6.2",
|
||||
"@polkadot/types": "^0.93.1",
|
||||
"@polkadot/util": "^1.5.1",
|
||||
"@polkadot/util-crypto": "^1.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^1.4.1"
|
||||
"@polkadot/keyring": "^1.5.1"
|
||||
}
|
||||
}
|
||||
|
||||
+10
-10
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api",
|
||||
"version": "0.92.1",
|
||||
"version": "0.93.1",
|
||||
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -26,16 +26,16 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.6.0",
|
||||
"@polkadot/api-derive": "^0.92.1",
|
||||
"@polkadot/api-metadata": "^0.92.1",
|
||||
"@polkadot/keyring": "^1.4.1",
|
||||
"@polkadot/rpc-core": "^0.92.1",
|
||||
"@polkadot/rpc-provider": "^0.92.1",
|
||||
"@polkadot/types": "^0.92.1",
|
||||
"@polkadot/util-crypto": "^1.4.1"
|
||||
"@babel/runtime": "^7.6.2",
|
||||
"@polkadot/api-derive": "^0.93.1",
|
||||
"@polkadot/api-metadata": "^0.93.1",
|
||||
"@polkadot/keyring": "^1.5.1",
|
||||
"@polkadot/rpc-core": "^0.93.1",
|
||||
"@polkadot/rpc-provider": "^0.93.1",
|
||||
"@polkadot/types": "^0.93.1",
|
||||
"@polkadot/util-crypto": "^1.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^1.4.1"
|
||||
"@polkadot/keyring": "^1.5.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { RpcMethod } from '@polkadot/jsonrpc/types';
|
||||
import { RpcInterface } from '@polkadot/rpc-core/jsonrpc.types';
|
||||
import { Call, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import { AnyFunction, CallFunction, Codec, CodecArg as Arg, ModulesWithCalls } from '@polkadot/types/types';
|
||||
import { SubmittableExtrinsic } from '../submittable/types';
|
||||
import { ApiInterfaceRx, ApiOptions, ApiTypes, DecorateMethod, DecoratedRpc, DecoratedRpcSection, QueryableModuleStorage, QueryableStorage, QueryableStorageEntry, QueryableStorageMulti, QueryableStorageMultiArg, QueryableStorageMultiArgs, SubmittableExtrinsicFunction, SubmittableExtrinsics, SubmittableModuleExtrinsics } from '../types';
|
||||
import { ApiInterfaceRx, ApiOptions, ApiTypes, DecorateMethod, DecoratedRpc, DecoratedRpcSection, QueryableModuleStorage, QueryableStorage, QueryableStorageEntry, QueryableStorageMulti, QueryableStorageMultiArg, SubmittableExtrinsicFunction, SubmittableExtrinsics, SubmittableModuleExtrinsics } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
@@ -14,6 +15,7 @@ import { map, switchMap } from 'rxjs/operators';
|
||||
import decorateDerive from '@polkadot/api-derive';
|
||||
import { Constants } from '@polkadot/api-metadata/consts/types';
|
||||
import { Storage } from '@polkadot/api-metadata/storage/types';
|
||||
import jsonrpc from '@polkadot/jsonrpc';
|
||||
import RpcCore from '@polkadot/rpc-core';
|
||||
import { WsProvider } from '@polkadot/rpc-provider';
|
||||
import { Metadata, Null, u64 } from '@polkadot/types';
|
||||
@@ -62,6 +64,8 @@ export default abstract class Decorate<ApiType> extends Events {
|
||||
|
||||
protected _rpcCore: RpcCore;
|
||||
|
||||
private _rpcMap: Map<string, RpcMethod> = new Map();
|
||||
|
||||
protected _runtimeMetadata?: Metadata;
|
||||
|
||||
protected _runtimeVersion?: RuntimeVersion;
|
||||
@@ -133,14 +137,50 @@ export default abstract class Decorate<ApiType> extends Events {
|
||||
return output;
|
||||
}
|
||||
|
||||
// Filter all RPC methods based on the results of the rpc_methods call. We do this in the following
|
||||
// manner to cater for both old and new:
|
||||
// - when the number of entries are 0, only remove the ones with isOptional (account & contracts)
|
||||
// - when non-zero, remove anything that is not in the array (we don't do this)
|
||||
protected async filterRpcMethods (): Promise<void> {
|
||||
let methods: string[];
|
||||
|
||||
try {
|
||||
// we ignore the version (adjust as versions change, for now only "1")
|
||||
methods = (await this._rpcCore.rpc.methods().toPromise()).methods.map((t) => t.toString());
|
||||
} catch (error) {
|
||||
// the method is not there, we adjust accordingly
|
||||
methods = [];
|
||||
}
|
||||
|
||||
// this is true when the RPC has entries
|
||||
const hasResults = methods.length !== 0;
|
||||
|
||||
// loop through all entries we have (populated in decorate) and filter as required
|
||||
[...this._rpcMap.entries()]
|
||||
.filter(([key, { isOptional }]): boolean =>
|
||||
// only remove when we have results and method missing, or with no results if optional
|
||||
hasResults
|
||||
? !methods.includes(key) && key !== 'rpc_methods' // rpc_methods doesn't appear, v1
|
||||
: isOptional || key === 'rpc_methods' // we didn't find this one, remove
|
||||
)
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
.forEach(([_, { method, section }]): void => {
|
||||
delete (this._rpc as any)[section][method];
|
||||
delete (this._rx.rpc as any)[section][method];
|
||||
});
|
||||
}
|
||||
|
||||
protected decorateRpc<ApiType> (rpc: RpcCore, decorateMethod: Decorate<ApiType>['decorateMethod']): DecoratedRpc<ApiType, RpcInterface> {
|
||||
return ['author', 'chain', 'state', 'system'].reduce((out, _sectionName): DecoratedRpc<ApiType, RpcInterface> => {
|
||||
return Object.keys(jsonrpc).reduce((out, _sectionName): DecoratedRpc<ApiType, RpcInterface> => {
|
||||
const sectionName = _sectionName as keyof DecoratedRpc<ApiType, RpcInterface>;
|
||||
|
||||
// out and section here are horrors to get right from a typing perspective :()
|
||||
(out as any)[sectionName] = Object.entries(rpc[sectionName]).reduce((section, [methodName, method]): DecoratedRpcSection<ApiType, RpcInterface[typeof sectionName]> => {
|
||||
(section as any)[methodName] = decorateMethod(method, { methodName });
|
||||
|
||||
// add this endpoint mapping to our internal map - we use this for filters
|
||||
this._rpcMap.set(`${sectionName}_${methodName}`, jsonrpc[sectionName].methods[methodName]);
|
||||
|
||||
return section;
|
||||
}, {} as unknown as DecoratedRpcSection<ApiType, RpcInterface[typeof sectionName]>);
|
||||
|
||||
@@ -149,7 +189,7 @@ export default abstract class Decorate<ApiType> extends Events {
|
||||
}
|
||||
|
||||
protected decorateMulti<ApiType> (decorateMethod: Decorate<ApiType>['decorateMethod']): QueryableStorageMulti<ApiType> {
|
||||
return decorateMethod((calls: QueryableStorageMultiArgs<ApiType>): Observable<Codec[]> =>
|
||||
return decorateMethod((calls: QueryableStorageMultiArg<ApiType>[]): Observable<Codec[]> =>
|
||||
this._rpcCore.state.subscribeStorage(
|
||||
calls.map((arg: QueryableStorageMultiArg<ApiType>): [QueryableStorageEntry<ApiType>, ...Arg[]] =>
|
||||
// the input is a QueryableStorageEntry, convert to StorageEntry
|
||||
@@ -310,7 +350,7 @@ export default abstract class Decorate<ApiType> extends Events {
|
||||
* Put the `this.onCall` function of ApiRx here, because it is needed by
|
||||
* `api._rx`.
|
||||
*/
|
||||
protected rxDecorateMethod = <Method extends AnyFunction> (method: Method): Method => {
|
||||
protected rxDecorateMethod = <Method extends AnyFunction>(method: Method): Method => {
|
||||
return method;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Prefix } from '@polkadot/util-crypto/address/types';
|
||||
import { SignedBlock } from '@polkadot/types/interfaces';
|
||||
import { RegistryTypes } from '@polkadot/types/types';
|
||||
import { ApiInterfaceRx, ApiOptions, ApiTypes, DecorateMethod } from '../types';
|
||||
@@ -38,7 +37,15 @@ const TYPES_SUBSTRATE_1 = {
|
||||
ValidatorPrefs: 'ValidatorPrefs0to145'
|
||||
};
|
||||
|
||||
// Type overrides for specific spec types as given in runtimeVersion
|
||||
// Type overrides based on specific nodes
|
||||
const TYPES_CHAIN: Record<string, Record<string, string>> = {
|
||||
// TODO Remove this once it is not needed, i.e. upgraded
|
||||
'Kusama CC1': {
|
||||
RawBabePreDigest: 'RawBabePreDigest0to159'
|
||||
}
|
||||
};
|
||||
|
||||
// Type overrides for specific spec types as given in runtimeVersion
|
||||
const TYPES_SPEC: Record<string, Record<string, string>> = {
|
||||
kusama: TYPES_FOR_POLKADOT,
|
||||
polkadot: TYPES_FOR_POLKADOT
|
||||
@@ -100,14 +107,19 @@ export default abstract class Init<ApiType> extends Decorate<ApiType> {
|
||||
this._rpcCore.system.properties().toPromise()
|
||||
]);
|
||||
const specName = runtimeVersion.specName.toString();
|
||||
const chainName = chain.toString();
|
||||
|
||||
// based on the node spec & chain, inject specific type overrides
|
||||
this.registerTypes({
|
||||
...(TYPES_SPEC[specName] || {}),
|
||||
...(TYPES_CHAIN[chainName] || {}),
|
||||
...(typesSpec[specName] || {}),
|
||||
...(typesChain[chain.toString()] || {})
|
||||
...(typesChain[chainName] || {})
|
||||
});
|
||||
|
||||
// filter the RPC methods (this does an rpc-methods call)
|
||||
await this.filterRpcMethods();
|
||||
|
||||
// retrieve metadata, either from chain or as pass-in via options
|
||||
const metadataKey = `${genesisHash}-${runtimeVersion.specVersion}`;
|
||||
const metadata = metadataKey in optMetadata
|
||||
@@ -119,7 +131,7 @@ export default abstract class Init<ApiType> extends Decorate<ApiType> {
|
||||
this._runtimeVersion = runtimeVersion;
|
||||
|
||||
// set the global ss58Format as detected by the chain
|
||||
setSS58Format(chainProps.ss58Format.unwrapOr(DEFAULT_SS58).toNumber() as Prefix);
|
||||
setSS58Format(chainProps.ss58Format.unwrapOr(DEFAULT_SS58).toNumber());
|
||||
|
||||
// get unique types & validate
|
||||
metadata.getUniqTypes(false);
|
||||
|
||||
@@ -37,6 +37,17 @@ async function query (api: ApiPromise, keyring: TestKeyringMap): Promise<void> {
|
||||
const intentions = await api.query.staking.intentions();
|
||||
console.log('intentions:', intentions);
|
||||
|
||||
// api.query.*.* is well-typed
|
||||
const bar = await api.query.foo.bar(); // bar is Codec (unknown module)
|
||||
const bal = await api.query.balances.freeBalance(keyring.alice.address); // bal is Balance
|
||||
const bal2 = await api.query.balances.freeBalance(keyring.alice.address, 'WRONG_ARG'); // bal2 is Codec (wrong args)
|
||||
const override = await api.query.balances.freeBalance<Header>(keyring.alice.address); // override is still available
|
||||
const oldBal = await api.query.balances.freeBalance.at('abcd', keyring.alice.address);
|
||||
// It's hard to correctly type .multi. Expected: `Balance[]`, actual: Codec[].
|
||||
// In the meantime, we can case with `<Balance>`
|
||||
const multi = await api.query.balances.freeBalance.multi<Balance>([keyring.alice.address, keyring.bob.address]);
|
||||
console.log('query types:', bar, bal, bal2, override, oldBal, multi);
|
||||
|
||||
// check multi for unsub
|
||||
const multiUnsub = await api.queryMulti([
|
||||
[api.query.system.accountNonce, keyring.eve.address],
|
||||
@@ -96,7 +107,7 @@ async function tx (api: ApiPromise, keyring: TestKeyringMap): Promise<void> {
|
||||
});
|
||||
|
||||
// with options and the callback
|
||||
const nonce2 = await api.query.system.accountNonce<Index>(keyring.alice.address);
|
||||
const nonce2 = await api.query.system.accountNonce(keyring.alice.address);
|
||||
const unsub2 = await api.tx.balances
|
||||
.transfer(keyring.bob.address, 12345)
|
||||
.signAndSend(keyring.alice, { nonce: nonce2 }, ({ status }: SubmittableResult): void => {
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
// Auto-generated via `yarn build:interfaces`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { Option, U8a, Vec } from '@polkadot/types/codec';
|
||||
import { Bytes, Null, bool, i8, u32, u64 } from '@polkadot/types';
|
||||
import { AccountId, AccountIndex, Balance, BalanceOf, BlockNumber, Hash, Index, KeyTypeId, Moment, Perbill, ValidatorId, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
|
||||
import { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
|
||||
import { BabeAuthorityWeight, MaybeVrf } from '@polkadot/types/interfaces/babe';
|
||||
import { BalanceLock, VestingSchedule } from '@polkadot/types/interfaces/balances';
|
||||
import { ProposalIndex, Votes } from '@polkadot/types/interfaces/collective';
|
||||
import { AuthorityId } from '@polkadot/types/interfaces/consensus';
|
||||
import { CodeHash, ContractInfo, Gas, PrefabWasmModule, Schedule } from '@polkadot/types/interfaces/contracts';
|
||||
import { Conviction, PropIndex, Proposal, ReferendumIndex, ReferendumInfo } from '@polkadot/types/interfaces/democracy';
|
||||
import { ApprovalFlag, SetIndex, Vote, VoteIndex, VoteThreshold, VoterInfo } from '@polkadot/types/interfaces/elections';
|
||||
import { AuthorityWeight, SetId, StoredPendingChange, StoredState } from '@polkadot/types/interfaces/grandpa';
|
||||
import { AuthIndex } from '@polkadot/types/interfaces/imOnline';
|
||||
import { Kind, OffenceDetails, OpaqueTimeSlot, ReportIdOf } from '@polkadot/types/interfaces/offences';
|
||||
import { Keys, SessionIndex } from '@polkadot/types/interfaces/session';
|
||||
import { EraIndex, EraPoints, Exposure, Forcing, MomentOf, RewardDestination, SlashJournalEntry, StakingLedger, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
|
||||
import { DigestOf, EventIndex, EventRecord } from '@polkadot/types/interfaces/system';
|
||||
import { TreasuryProposal } from '@polkadot/types/interfaces/treasury';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
|
||||
declare module './types' {
|
||||
export interface QueryableStorageExact<ApiType> {
|
||||
system: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
accountNonce: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<Index>> & QueryableStorageEntry<ApiType>;
|
||||
extrinsicCount: StorageEntryExact<ApiType, () => Observable<u32>> & QueryableStorageEntry<ApiType>;
|
||||
allExtrinsicsWeight: StorageEntryExact<ApiType, () => Observable<Weight>> & QueryableStorageEntry<ApiType>;
|
||||
allExtrinsicsLen: StorageEntryExact<ApiType, () => Observable<u32>> & QueryableStorageEntry<ApiType>;
|
||||
nextWeightMultiplier: StorageEntryExact<ApiType, () => Observable<WeightMultiplier>> & QueryableStorageEntry<ApiType>;
|
||||
blockHash: StorageEntryExact<ApiType, (arg: BlockNumber | Uint8Array | number | string) => Observable<Hash>> & QueryableStorageEntry<ApiType>;
|
||||
extrinsicData: StorageEntryExact<ApiType, (arg: u32 | Uint8Array | number | string) => Observable<Bytes>> & QueryableStorageEntry<ApiType>;
|
||||
randomMaterial: StorageEntryExact<ApiType, () => Observable<ITuple<[i8, Vec<Hash>]>>> & QueryableStorageEntry<ApiType>;
|
||||
number: StorageEntryExact<ApiType, () => Observable<BlockNumber>> & QueryableStorageEntry<ApiType>;
|
||||
parentHash: StorageEntryExact<ApiType, () => Observable<Hash>> & QueryableStorageEntry<ApiType>;
|
||||
extrinsicsRoot: StorageEntryExact<ApiType, () => Observable<Hash>> & QueryableStorageEntry<ApiType>;
|
||||
digest: StorageEntryExact<ApiType, () => Observable<DigestOf>> & QueryableStorageEntry<ApiType>;
|
||||
events: StorageEntryExact<ApiType, () => Observable<Vec<EventRecord>>> & QueryableStorageEntry<ApiType>;
|
||||
eventCount: StorageEntryExact<ApiType, () => Observable<EventIndex>> & QueryableStorageEntry<ApiType>;
|
||||
eventTopics: StorageEntryExact<ApiType, (key1: Null, key2: Hash | Uint8Array | string) => Observable<Vec<ITuple<[BlockNumber, EventIndex]>>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
babe: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
epochIndex: StorageEntryExact<ApiType, () => Observable<u64>> & QueryableStorageEntry<ApiType>;
|
||||
authorities: StorageEntryExact<ApiType, () => Observable<Vec<ITuple<[AuthorityId, BabeAuthorityWeight]>>>> & QueryableStorageEntry<ApiType>;
|
||||
genesisSlot: StorageEntryExact<ApiType, () => Observable<u64>> & QueryableStorageEntry<ApiType>;
|
||||
currentSlot: StorageEntryExact<ApiType, () => Observable<u64>> & QueryableStorageEntry<ApiType>;
|
||||
randomness: StorageEntryExact<ApiType, () => Observable<U8a>> & QueryableStorageEntry<ApiType>;
|
||||
nextRandomness: StorageEntryExact<ApiType, () => Observable<U8a>> & QueryableStorageEntry<ApiType>;
|
||||
segmentIndex: StorageEntryExact<ApiType, () => Observable<u32>> & QueryableStorageEntry<ApiType>;
|
||||
underConstruction: StorageEntryExact<ApiType, (arg: u32 | Uint8Array | number | string) => Observable<Vec<U8a>>> & QueryableStorageEntry<ApiType>;
|
||||
initialized: StorageEntryExact<ApiType, () => Observable<MaybeVrf>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
timestamp: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
now: StorageEntryExact<ApiType, () => Observable<Moment>> & QueryableStorageEntry<ApiType>;
|
||||
didUpdate: StorageEntryExact<ApiType, () => Observable<bool>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
authorship: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
uncles: StorageEntryExact<ApiType, () => Observable<Vec<UncleEntryItem>>> & QueryableStorageEntry<ApiType>;
|
||||
author: StorageEntryExact<ApiType, () => Observable<AccountId>> & QueryableStorageEntry<ApiType>;
|
||||
didSetUncles: StorageEntryExact<ApiType, () => Observable<bool>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
indices: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
nextEnumSet: StorageEntryExact<ApiType, () => Observable<AccountIndex>> & QueryableStorageEntry<ApiType>;
|
||||
enumSet: StorageEntryExact<ApiType, (arg: AccountIndex | Uint8Array | number | string) => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
balances: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
totalIssuance: StorageEntryExact<ApiType, () => Observable<Balance>> & QueryableStorageEntry<ApiType>;
|
||||
vesting: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<VestingSchedule>> & QueryableStorageEntry<ApiType>;
|
||||
freeBalance: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<Balance>> & QueryableStorageEntry<ApiType>;
|
||||
reservedBalance: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<Balance>> & QueryableStorageEntry<ApiType>;
|
||||
locks: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<Vec<BalanceLock>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
staking: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
validatorCount: StorageEntryExact<ApiType, () => Observable<u32>> & QueryableStorageEntry<ApiType>;
|
||||
minimumValidatorCount: StorageEntryExact<ApiType, () => Observable<u32>> & QueryableStorageEntry<ApiType>;
|
||||
invulnerables: StorageEntryExact<ApiType, () => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
bonded: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<AccountId>> & QueryableStorageEntry<ApiType>;
|
||||
ledger: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<StakingLedger>> & QueryableStorageEntry<ApiType>;
|
||||
payee: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<RewardDestination>> & QueryableStorageEntry<ApiType>;
|
||||
validators: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<ValidatorPrefs>> & QueryableStorageEntry<ApiType>;
|
||||
nominators: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
stakers: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<Exposure>> & QueryableStorageEntry<ApiType>;
|
||||
currentElected: StorageEntryExact<ApiType, () => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
currentEra: StorageEntryExact<ApiType, () => Observable<EraIndex>> & QueryableStorageEntry<ApiType>;
|
||||
currentEraStart: StorageEntryExact<ApiType, () => Observable<MomentOf>> & QueryableStorageEntry<ApiType>;
|
||||
currentEraStartSessionIndex: StorageEntryExact<ApiType, () => Observable<SessionIndex>> & QueryableStorageEntry<ApiType>;
|
||||
currentEraPointsEarned: StorageEntryExact<ApiType, () => Observable<EraPoints>> & QueryableStorageEntry<ApiType>;
|
||||
slotStake: StorageEntryExact<ApiType, () => Observable<BalanceOf>> & QueryableStorageEntry<ApiType>;
|
||||
forceEra: StorageEntryExact<ApiType, () => Observable<Forcing>> & QueryableStorageEntry<ApiType>;
|
||||
slashRewardFraction: StorageEntryExact<ApiType, () => Observable<Perbill>> & QueryableStorageEntry<ApiType>;
|
||||
bondedEras: StorageEntryExact<ApiType, () => Observable<Vec<ITuple<[EraIndex, SessionIndex]>>>> & QueryableStorageEntry<ApiType>;
|
||||
eraSlashJournal: StorageEntryExact<ApiType, (arg: EraIndex | Uint8Array | number | string) => Observable<Vec<SlashJournalEntry>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
session: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
validators: StorageEntryExact<ApiType, () => Observable<Vec<ValidatorId>>> & QueryableStorageEntry<ApiType>;
|
||||
currentIndex: StorageEntryExact<ApiType, () => Observable<SessionIndex>> & QueryableStorageEntry<ApiType>;
|
||||
queuedChanged: StorageEntryExact<ApiType, () => Observable<bool>> & QueryableStorageEntry<ApiType>;
|
||||
queuedKeys: StorageEntryExact<ApiType, () => Observable<Vec<ITuple<[ValidatorId, Keys]>>>> & QueryableStorageEntry<ApiType>;
|
||||
disabledValidators: StorageEntryExact<ApiType, () => Observable<Vec<u32>>> & QueryableStorageEntry<ApiType>;
|
||||
nextKeys: StorageEntryExact<ApiType, (key1: Bytes | Uint8Array | string, key2: ValidatorId | Uint8Array | string) => Observable<Keys>> & QueryableStorageEntry<ApiType>;
|
||||
keyOwner: StorageEntryExact<ApiType, (key1: Bytes | Uint8Array | string, key2: ITuple<[KeyTypeId, Bytes]>) => Observable<ValidatorId>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
democracy: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
publicPropCount: StorageEntryExact<ApiType, () => Observable<PropIndex>> & QueryableStorageEntry<ApiType>;
|
||||
publicProps: StorageEntryExact<ApiType, () => Observable<Vec<ITuple<[PropIndex, Proposal, AccountId]>>>> & QueryableStorageEntry<ApiType>;
|
||||
depositOf: StorageEntryExact<ApiType, (arg: PropIndex | Uint8Array | number | string) => Observable<ITuple<[BalanceOf, Vec<AccountId>]>>> & QueryableStorageEntry<ApiType>;
|
||||
referendumCount: StorageEntryExact<ApiType, () => Observable<ReferendumIndex>> & QueryableStorageEntry<ApiType>;
|
||||
nextTally: StorageEntryExact<ApiType, () => Observable<ReferendumIndex>> & QueryableStorageEntry<ApiType>;
|
||||
referendumInfoOf: StorageEntryExact<ApiType, (arg: ReferendumIndex | Uint8Array | number | string) => Observable<ReferendumInfo>> & QueryableStorageEntry<ApiType>;
|
||||
dispatchQueue: StorageEntryExact<ApiType, (arg: BlockNumber | Uint8Array | number | string) => Observable<Vec<Option<ITuple<[Proposal, ReferendumIndex]>>>>> & QueryableStorageEntry<ApiType>;
|
||||
votersFor: StorageEntryExact<ApiType, (arg: ReferendumIndex | Uint8Array | number | string) => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
voteOf: StorageEntryExact<ApiType, (arg: ITuple<[ReferendumIndex, AccountId]>) => Observable<Vote>> & QueryableStorageEntry<ApiType>;
|
||||
proxy: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<AccountId>> & QueryableStorageEntry<ApiType>;
|
||||
delegations: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<ITuple<[AccountId, Conviction]>>> & QueryableStorageEntry<ApiType>;
|
||||
lastTabledWasExternal: StorageEntryExact<ApiType, () => Observable<bool>> & QueryableStorageEntry<ApiType>;
|
||||
nextExternal: StorageEntryExact<ApiType, () => Observable<ITuple<[Proposal, VoteThreshold]>>> & QueryableStorageEntry<ApiType>;
|
||||
blacklist: StorageEntryExact<ApiType, (arg: Hash | Uint8Array | string) => Observable<ITuple<[BlockNumber, Vec<AccountId>]>>> & QueryableStorageEntry<ApiType>;
|
||||
cancellations: StorageEntryExact<ApiType, (arg: Hash | Uint8Array | string) => Observable<bool>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
council: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
proposals: StorageEntryExact<ApiType, () => Observable<Vec<Hash>>> & QueryableStorageEntry<ApiType>;
|
||||
proposalOf: StorageEntryExact<ApiType, (arg: Hash | Uint8Array | string) => Observable<Proposal>> & QueryableStorageEntry<ApiType>;
|
||||
voting: StorageEntryExact<ApiType, (arg: Hash | Uint8Array | string) => Observable<Votes>> & QueryableStorageEntry<ApiType>;
|
||||
proposalCount: StorageEntryExact<ApiType, () => Observable<u32>> & QueryableStorageEntry<ApiType>;
|
||||
members: StorageEntryExact<ApiType, () => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
technicalCommittee: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
proposals: StorageEntryExact<ApiType, () => Observable<Vec<Hash>>> & QueryableStorageEntry<ApiType>;
|
||||
proposalOf: StorageEntryExact<ApiType, (arg: Hash | Uint8Array | string) => Observable<Proposal>> & QueryableStorageEntry<ApiType>;
|
||||
voting: StorageEntryExact<ApiType, (arg: Hash | Uint8Array | string) => Observable<Votes>> & QueryableStorageEntry<ApiType>;
|
||||
proposalCount: StorageEntryExact<ApiType, () => Observable<u32>> & QueryableStorageEntry<ApiType>;
|
||||
members: StorageEntryExact<ApiType, () => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
elections: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
presentationDuration: StorageEntryExact<ApiType, () => Observable<BlockNumber>> & QueryableStorageEntry<ApiType>;
|
||||
termDuration: StorageEntryExact<ApiType, () => Observable<BlockNumber>> & QueryableStorageEntry<ApiType>;
|
||||
desiredSeats: StorageEntryExact<ApiType, () => Observable<u32>> & QueryableStorageEntry<ApiType>;
|
||||
members: StorageEntryExact<ApiType, () => Observable<Vec<ITuple<[AccountId, BlockNumber]>>>> & QueryableStorageEntry<ApiType>;
|
||||
voteCount: StorageEntryExact<ApiType, () => Observable<VoteIndex>> & QueryableStorageEntry<ApiType>;
|
||||
approvalsOf: StorageEntryExact<ApiType, (arg: ITuple<[AccountId, SetIndex]>) => Observable<Vec<ApprovalFlag>>> & QueryableStorageEntry<ApiType>;
|
||||
registerInfoOf: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<ITuple<[VoteIndex, u32]>>> & QueryableStorageEntry<ApiType>;
|
||||
voterInfoOf: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<VoterInfo>> & QueryableStorageEntry<ApiType>;
|
||||
voters: StorageEntryExact<ApiType, (arg: SetIndex | Uint8Array | number | string) => Observable<Vec<Option<AccountId>>>> & QueryableStorageEntry<ApiType>;
|
||||
nextVoterSet: StorageEntryExact<ApiType, () => Observable<SetIndex>> & QueryableStorageEntry<ApiType>;
|
||||
voterCount: StorageEntryExact<ApiType, () => Observable<SetIndex>> & QueryableStorageEntry<ApiType>;
|
||||
candidates: StorageEntryExact<ApiType, () => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
candidateCount: StorageEntryExact<ApiType, () => Observable<u32>> & QueryableStorageEntry<ApiType>;
|
||||
nextFinalize: StorageEntryExact<ApiType, () => Observable<ITuple<[BlockNumber, u32, Vec<AccountId>]>>> & QueryableStorageEntry<ApiType>;
|
||||
leaderboard: StorageEntryExact<ApiType, () => Observable<Vec<ITuple<[BalanceOf, AccountId]>>>> & QueryableStorageEntry<ApiType>;
|
||||
proxy: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<AccountId>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
technicalMembership: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
members: StorageEntryExact<ApiType, () => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
grandpa: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
authorities: StorageEntryExact<ApiType, () => Observable<Vec<ITuple<[AuthorityId, AuthorityWeight]>>>> & QueryableStorageEntry<ApiType>;
|
||||
state: StorageEntryExact<ApiType, () => Observable<StoredState>> & QueryableStorageEntry<ApiType>;
|
||||
pendingChange: StorageEntryExact<ApiType, () => Observable<StoredPendingChange>> & QueryableStorageEntry<ApiType>;
|
||||
nextForced: StorageEntryExact<ApiType, () => Observable<BlockNumber>> & QueryableStorageEntry<ApiType>;
|
||||
stalled: StorageEntryExact<ApiType, () => Observable<ITuple<[BlockNumber, BlockNumber]>>> & QueryableStorageEntry<ApiType>;
|
||||
currentSetId: StorageEntryExact<ApiType, () => Observable<SetId>> & QueryableStorageEntry<ApiType>;
|
||||
setIdSession: StorageEntryExact<ApiType, (arg: SetId | Uint8Array | number | string) => Observable<SessionIndex>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
treasury: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
proposalCount: StorageEntryExact<ApiType, () => Observable<ProposalIndex>> & QueryableStorageEntry<ApiType>;
|
||||
proposals: StorageEntryExact<ApiType, (arg: ProposalIndex | Uint8Array | number | string) => Observable<TreasuryProposal>> & QueryableStorageEntry<ApiType>;
|
||||
approvals: StorageEntryExact<ApiType, () => Observable<Vec<ProposalIndex>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
contracts: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
gasSpent: StorageEntryExact<ApiType, () => Observable<Gas>> & QueryableStorageEntry<ApiType>;
|
||||
currentSchedule: StorageEntryExact<ApiType, () => Observable<Schedule>> & QueryableStorageEntry<ApiType>;
|
||||
pristineCode: StorageEntryExact<ApiType, (arg: CodeHash | Uint8Array | string) => Observable<Bytes>> & QueryableStorageEntry<ApiType>;
|
||||
codeStorage: StorageEntryExact<ApiType, (arg: CodeHash | Uint8Array | string) => Observable<PrefabWasmModule>> & QueryableStorageEntry<ApiType>;
|
||||
accountCounter: StorageEntryExact<ApiType, () => Observable<u64>> & QueryableStorageEntry<ApiType>;
|
||||
contractInfoOf: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<ContractInfo>> & QueryableStorageEntry<ApiType>;
|
||||
gasPrice: StorageEntryExact<ApiType, () => Observable<BalanceOf>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
sudo: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
key: StorageEntryExact<ApiType, () => Observable<AccountId>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
imOnline: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
gossipAt: StorageEntryExact<ApiType, () => Observable<BlockNumber>> & QueryableStorageEntry<ApiType>;
|
||||
keys: StorageEntryExact<ApiType, () => Observable<Vec<AuthorityId>>> & QueryableStorageEntry<ApiType>;
|
||||
receivedHeartbeats: StorageEntryExact<ApiType, (key1: SessionIndex | Uint8Array | number | string, key2: AuthIndex | Uint8Array | number | string) => Observable<Bytes>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
offences: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
reports: StorageEntryExact<ApiType, (arg: ReportIdOf | Uint8Array | string) => Observable<OffenceDetails>> & QueryableStorageEntry<ApiType>;
|
||||
concurrentReportsIndex: StorageEntryExact<ApiType, (key1: Kind | Uint8Array | string, key2: OpaqueTimeSlot | Uint8Array | string) => Observable<Vec<ReportIdOf>>> & QueryableStorageEntry<ApiType>;
|
||||
reportsByKindIndex: StorageEntryExact<ApiType, (arg: Kind | Uint8Array | string) => Observable<Bytes>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,14 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId, Address, Call, Extrinsic, ExtrinsicEra, ExtrinsicStatus, EventRecord, Hash, Header, Index } from '@polkadot/types/interfaces';
|
||||
import { AccountId, Address, Call, Extrinsic, ExtrinsicEra, ExtrinsicStatus, Hash, Header, Index } from '@polkadot/types/interfaces';
|
||||
import { Callback, Codec, Constructor, IKeyringPair, SignatureOptions } from '@polkadot/types/types';
|
||||
import { ApiInterfaceRx, ApiTypes, SignerResult } from '../types';
|
||||
import { SignerOptions, SubmittableExtrinsic, SubmittableResultImpl, SubmitableResultResult, SubmitableResultSubscription } from './types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { first, map, mergeMap, switchMap, tap } from 'rxjs/operators';
|
||||
import { createType, ClassOf, Vec } from '@polkadot/types';
|
||||
import { createType, ClassOf } from '@polkadot/types';
|
||||
import { isBn, isFunction, isNumber, isUndefined } from '@polkadot/util';
|
||||
|
||||
import { filterEvents, isKeyringPair } from '../util';
|
||||
@@ -61,13 +61,13 @@ export default class Submittable<ApiType> extends _Extrinsic implements Submitta
|
||||
}
|
||||
|
||||
// signAndSend with an immediate Hash result
|
||||
public signAndSend(account: IKeyringPair | string | AccountId | Address, options?: Partial<SignerOptions>): SubmitableResultResult<ApiType>;
|
||||
public signAndSend (account: IKeyringPair | string | AccountId | Address, options?: Partial<SignerOptions>): SubmitableResultResult<ApiType>;
|
||||
|
||||
// signAndSend with a subscription, i.e. callback provided
|
||||
public signAndSend(account: IKeyringPair | string | AccountId | Address, statusCb: Callback<SubmittableResultImpl>): SubmitableResultSubscription<ApiType>;
|
||||
public signAndSend (account: IKeyringPair | string | AccountId | Address, statusCb: Callback<SubmittableResultImpl>): SubmitableResultSubscription<ApiType>;
|
||||
|
||||
// signAndSend with options and a callback
|
||||
public signAndSend(account: IKeyringPair | string | AccountId | Address, options: Partial<SignerOptions>, statusCb?: Callback<SubmittableResultImpl>): SubmitableResultSubscription<ApiType>;
|
||||
public signAndSend (account: IKeyringPair | string | AccountId | Address, options: Partial<SignerOptions>, statusCb?: Callback<SubmittableResultImpl>): SubmitableResultSubscription<ApiType>;
|
||||
|
||||
// signAndSend implementation for all 3 cases above
|
||||
public signAndSend (account: IKeyringPair | string | AccountId | Address, optionsOrStatus?: Partial<SignerOptions> | Callback<SubmittableResultImpl>, optionalStatusCb?: Callback<SubmittableResultImpl>): SubmitableResultResult<ApiType> | SubmitableResultSubscription<ApiType> {
|
||||
@@ -193,7 +193,9 @@ export default class Submittable<ApiType> extends _Extrinsic implements Submitta
|
||||
return combineLatest([
|
||||
// if we have a nonce already, don't retrieve the latest, use what is there
|
||||
isUndefined(options.nonce)
|
||||
? this._api.query.system.accountNonce<Index>(address)
|
||||
? this._api.rpc.account.nextIndex
|
||||
? this._api.rpc.account.nextIndex(address)
|
||||
: this._api.query.system.accountNonce(address)
|
||||
: of(createType('Index', options.nonce)),
|
||||
// if we have an era provided already or eraLength is <= 0 (immortal)
|
||||
// don't get the latest block, just pass null, handle in mergeMap
|
||||
@@ -218,7 +220,7 @@ export default class Submittable<ApiType> extends _Extrinsic implements Submitta
|
||||
|
||||
return combineLatest([
|
||||
this._api.rpc.chain.getBlock(blockHash),
|
||||
this._api.query.system.events.at(blockHash) as Observable<Vec<EventRecord>>
|
||||
this._api.query.system.events.at(blockHash)
|
||||
]).pipe(
|
||||
map(([signedBlock, allEvents]): SubmittableResultImpl =>
|
||||
new SubmittableResult({
|
||||
|
||||
+38
-28
@@ -60,15 +60,22 @@ export type DecorateMethod = (method: (...args: any[]) => Observable<any>, optio
|
||||
|
||||
// These are the types that don't lose type information (used for api.derive.*)
|
||||
// Also use these for api.rpc.* https://github.com/polkadot-js/api/issues/1009
|
||||
export type RxResult<F extends AnyFunction> = (...args: Parameters<F>) => Observable<ObsInnerType<ReturnType<F>>>;
|
||||
|
||||
export interface RxResult<F extends AnyFunction> {
|
||||
(...args: Parameters<F>): Observable<ObsInnerType<ReturnType<F>>>;
|
||||
<T>(...args: Parameters<F>): Observable<T>;
|
||||
}
|
||||
export interface PromiseResult<F extends AnyFunction> {
|
||||
(...args: Parameters<F>): Promise<ObsInnerType<ReturnType<F>>>;
|
||||
(...args: Push<Parameters<F>, Callback<ObsInnerType<ReturnType<F>>>>): UnsubscribePromise;
|
||||
<T>(...args: Parameters<F>): Promise<T>;
|
||||
<T>(...args: Push<Parameters<F>, Callback<T>>): UnsubscribePromise;
|
||||
<T extends Codec | Codec[]>(...args: Parameters<F>): Promise<T>;
|
||||
<T extends Codec | Codec[]>(...args: Push<Parameters<F>, Callback<T>>): UnsubscribePromise;
|
||||
}
|
||||
|
||||
// FIXME The day TS has higher-kinded types, we can remove this hardcoded stuff
|
||||
export type PromiseOrObs<ApiType, T> = ApiType extends 'rxjs'
|
||||
? Observable<T>
|
||||
: Promise<T>
|
||||
|
||||
// FIXME The day TS has higher-kinded types, we can remove this hardcoded stuff
|
||||
export type MethodResult<ApiType, F extends AnyFunction> = ApiType extends 'rxjs'
|
||||
? RxResult<F>
|
||||
@@ -84,18 +91,22 @@ export type DecoratedRpc<ApiType, AllSections> = {
|
||||
[Section in keyof AllSections]: DecoratedRpcSection<ApiType, AllSections[Section]>
|
||||
}
|
||||
|
||||
interface StorageEntryBase<C, H, U> {
|
||||
at: (hash: Hash | Uint8Array | string, arg1?: CodecArg, arg2?: CodecArg) => C;
|
||||
creator: StorageEntry;
|
||||
hash: (arg1?: CodecArg, arg2?: CodecArg) => H;
|
||||
key: (arg1?: CodecArg, arg2?: CodecArg) => string;
|
||||
size: (arg1?: CodecArg, arg2?: CodecArg) => U;
|
||||
interface StorageEntryObservableMulti {
|
||||
<T extends Codec>(args: (CodecArg[] | CodecArg)[]): Observable<T[]>;
|
||||
}
|
||||
|
||||
export interface StorageEntryObservable extends StorageEntryBase<Observable<Codec>, Observable<Hash>, Observable<u64>> {
|
||||
(arg1?: CodecArg, arg2?: CodecArg): Observable<Codec>;
|
||||
<T extends Codec>(arg1?: CodecArg, arg2?: CodecArg): Observable<T>;
|
||||
multi: <T extends Codec>(args: (CodecArg[] | CodecArg)[]) => Observable<T[]>;
|
||||
interface StorageEntryPromiseMulti {
|
||||
<T extends Codec>(args: (CodecArg[] | CodecArg)[]): Promise<T[]>;
|
||||
<T extends Codec>(args: (CodecArg[] | CodecArg)[], callback: Callback<T[]>): UnsubscribePromise;
|
||||
}
|
||||
|
||||
export interface StorageEntryBase<ApiType, F extends AnyFunction> {
|
||||
at: (hash: Hash | Uint8Array | string, ...args: Parameters<F>) => PromiseOrObs<ApiType, ObsInnerType<ReturnType<F>>>;
|
||||
creator: StorageEntry;
|
||||
hash: (...args: Parameters<F>) => PromiseOrObs<ApiType, Hash>;
|
||||
key: (...args: Parameters<F>) => string;
|
||||
size: (...args: Parameters<F>) => PromiseOrObs<ApiType, u64>;
|
||||
multi: ApiType extends 'rxjs' ? StorageEntryObservableMulti : StorageEntryPromiseMulti;
|
||||
}
|
||||
|
||||
export interface StorageEntryPromiseOverloads {
|
||||
@@ -106,19 +117,15 @@ export interface StorageEntryPromiseOverloads {
|
||||
<T extends Codec>(arg1: CodecArg, arg2: CodecArg, callback: Callback<T>): UnsubscribePromise;
|
||||
}
|
||||
|
||||
export interface StorageEntryPromiseMulti {
|
||||
<T extends Codec>(args: (CodecArg[] | CodecArg)[]): Promise<T[]>;
|
||||
<T extends Codec>(args: (CodecArg[] | CodecArg)[], callback: Callback<T[]>): UnsubscribePromise;
|
||||
}
|
||||
export type StorageEntryExact<ApiType, F extends AnyFunction> = MethodResult<ApiType, F> & StorageEntryBase<ApiType, F>
|
||||
|
||||
export interface StorageEntryPromise extends StorageEntryBase<Promise<Codec>, Promise<Hash>, Promise<u64>>, StorageEntryPromiseOverloads {
|
||||
multi: StorageEntryPromiseMulti;
|
||||
}
|
||||
// This is the most generic typings we can have for a storage entry function
|
||||
type GenericStorageEntryFunction = (arg1?: CodecArg, arg2?: CodecArg) => Observable<Codec>
|
||||
|
||||
export type QueryableStorageEntry<ApiType> =
|
||||
ApiType extends 'rxjs'
|
||||
? StorageEntryObservable
|
||||
: StorageEntryPromise;
|
||||
? StorageEntryExact<'rxjs', GenericStorageEntryFunction>
|
||||
: StorageEntryExact<'promise', GenericStorageEntryFunction> & StorageEntryPromiseOverloads;
|
||||
|
||||
export interface QueryableModuleStorage<ApiType> {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
@@ -128,14 +135,12 @@ export type QueryableStorageMultiArg<ApiType> =
|
||||
QueryableStorageEntry<ApiType> |
|
||||
[QueryableStorageEntry<ApiType>, ...CodecArg[]];
|
||||
|
||||
export type QueryableStorageMultiArgs<ApiType> = QueryableStorageMultiArg<ApiType>[];
|
||||
|
||||
export interface QueryableStorageMultiBase<ApiType> {
|
||||
<T extends Codec>(calls: QueryableStorageMultiArgs<ApiType>): Observable<T[]>;
|
||||
<T extends Codec[]>(calls: QueryableStorageMultiArg<ApiType>[]): Observable<T>;
|
||||
}
|
||||
|
||||
export interface QueryableStorageMultiPromise<ApiType> {
|
||||
<T extends Codec>(calls: QueryableStorageMultiArgs<ApiType>, callback: Callback<T[]>): UnsubscribePromise;
|
||||
<T extends Codec[]>(calls: QueryableStorageMultiArg<ApiType>[], callback: Callback<T>): UnsubscribePromise;
|
||||
}
|
||||
|
||||
export type QueryableStorageMulti<ApiType> =
|
||||
@@ -143,7 +148,12 @@ export type QueryableStorageMulti<ApiType> =
|
||||
? QueryableStorageMultiBase<ApiType>
|
||||
: QueryableStorageMultiPromise<ApiType>;
|
||||
|
||||
export interface QueryableStorage<ApiType> {
|
||||
// QueryableStorageExact will hold the exact typed api.query.*.* generated from
|
||||
// metadata. For now it's empty, it's ready to be module augmented.
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface QueryableStorageExact<ApiType> { }
|
||||
|
||||
export interface QueryableStorage<ApiType> extends QueryableStorageExact<ApiType> {
|
||||
[index: string]: QueryableModuleStorage<ApiType>;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ describeE2E({
|
||||
|
||||
it('makes a query at a latest block (specified)', async (): Promise<void> => {
|
||||
const header = await api.rpc.chain.getHeader();
|
||||
const events = await api.query.system.events.at(header.hash) as Vec<EventRecord>;
|
||||
const events = await api.query.system.events.at(header.hash);
|
||||
|
||||
expect(events.length).not.toEqual(0);
|
||||
});
|
||||
|
||||
@@ -123,7 +123,7 @@ describeE2E({
|
||||
|
||||
describe('with map type', (): void => {
|
||||
it('queries correct value', async (): Promise<void> => {
|
||||
const balance = await api.query.balances.freeBalance(keyring.bob_stash.address) as Balance;
|
||||
const balance = await api.query.balances.freeBalance(keyring.bob_stash.address);
|
||||
|
||||
expect(balance.isZero()).toBe(false);
|
||||
});
|
||||
@@ -132,7 +132,7 @@ describeE2E({
|
||||
// assume the account Alice is only used in test(the balance of Alice does not change in this test case)
|
||||
const balance = await api.query.balances.freeBalance(keyring.alice_stash.address);
|
||||
const header = await api.rpc.chain.getHeader();
|
||||
const balanceAt = await api.query.balances.freeBalance.at(header.hash, keyring.alice_stash.address) as Balance;
|
||||
const balanceAt = await api.query.balances.freeBalance.at(header.hash, keyring.alice_stash.address);
|
||||
|
||||
expect(balanceAt.isZero()).toBe(false);
|
||||
expect(balanceAt.toString()).toEqual(balance.toString());
|
||||
|
||||
@@ -7,7 +7,7 @@ import { EventRecord, Hash, Header, SessionIndex } from '@polkadot/types/interfa
|
||||
import { HeaderExtended } from '@polkadot/api-derive';
|
||||
import WsProvider from '@polkadot/rpc-provider/ws';
|
||||
import { LinkageResult } from '@polkadot/types/codec/Linkage';
|
||||
import { Option, Vec, createType } from '@polkadot/types';
|
||||
import { Option, createType } from '@polkadot/types';
|
||||
|
||||
import ApiPromise from '../../../src/promise';
|
||||
import { describeE2E } from '../../util';
|
||||
@@ -80,7 +80,7 @@ describeE2E()('Promise e2e queries', (wsUrl: string): void => {
|
||||
|
||||
it('makes a query at a latest block (specified)', async (): Promise<void> => {
|
||||
const header = await api.rpc.chain.getHeader();
|
||||
const events = await api.query.system.events.at(header.hash) as Vec<EventRecord>;
|
||||
const events = await api.query.system.events.at(header.hash);
|
||||
|
||||
expect(events.length).not.toEqual(0);
|
||||
|
||||
@@ -100,14 +100,14 @@ describeE2E()('Promise e2e queries', (wsUrl: string): void => {
|
||||
|
||||
describe('with plain type', (): void => {
|
||||
it('queries a correct value', async (): Promise<void> => {
|
||||
const sessionIndex = await api.query.session.currentIndex() as SessionIndex;
|
||||
const sessionIndex = await api.query.session.currentIndex();
|
||||
|
||||
expect(sessionIndex.toNumber()).toBeGreaterThanOrEqual(0);
|
||||
});
|
||||
|
||||
it('queries correct value at a specified block', async (): Promise<void> => {
|
||||
const header = await api.rpc.chain.getHeader();
|
||||
const sessionIndex = await api.query.session.currentIndex.at(header.hash) as SessionIndex;
|
||||
const sessionIndex = await api.query.session.currentIndex.at(header.hash);
|
||||
|
||||
expect(sessionIndex.toNumber()).toBeGreaterThanOrEqual(0);
|
||||
});
|
||||
|
||||
@@ -5,30 +5,9 @@
|
||||
import Keyring from '@polkadot/keyring';
|
||||
import testingPairs from '@polkadot/keyring/testingPairs';
|
||||
import WsProvider from '@polkadot/rpc-provider/ws';
|
||||
import { EventRecord } from '@polkadot/types/interfaces';
|
||||
|
||||
import { SubmittableResult } from '../../../src';
|
||||
import ApiPromise from '../../../src/promise';
|
||||
import { describeE2E, calculateAccountDeposit } from '../../util';
|
||||
|
||||
// log all events for the transfers, calling done() when finalized
|
||||
const logEvents = (done: () => {}): (r: SubmittableResult) => void =>
|
||||
({ events, status }: SubmittableResult): void => {
|
||||
console.log('Transaction status:', status.type);
|
||||
|
||||
if (status.isFinalized) {
|
||||
console.log('Completed at block hash', status.value.toHex());
|
||||
console.log('Events:');
|
||||
|
||||
events.forEach(({ phase, event: { data, method, section } }: EventRecord): void => {
|
||||
console.log('\t', phase.toString(), `: ${section}.${method}`, data.toString());
|
||||
});
|
||||
|
||||
if (events.length) {
|
||||
done();
|
||||
}
|
||||
}
|
||||
};
|
||||
import { describeE2E, calculateAccountDeposit, logEvents } from '../../util';
|
||||
|
||||
describeE2E({
|
||||
except: ['remote-polkadot-alexander', 'remote-substrate-1.0']
|
||||
|
||||
@@ -4,32 +4,12 @@
|
||||
|
||||
import testingPairs from '@polkadot/keyring/testingPairs';
|
||||
import WsProvider from '@polkadot/rpc-provider/ws';
|
||||
import { EventRecord, Header, Index } from '@polkadot/types/interfaces';
|
||||
import { Header } from '@polkadot/types/interfaces';
|
||||
import { createType } from '@polkadot/types';
|
||||
|
||||
import { SubmittableResult } from '../../../src';
|
||||
import ApiPromise from '../../../src/promise';
|
||||
import { Signer } from '../../../src/types';
|
||||
import { describeE2E, SingleAccountSigner } from '../../util';
|
||||
|
||||
// log all events for the transfer, calling done() when finalized
|
||||
const logEvents = (done: () => {}): (r: SubmittableResult) => void =>
|
||||
({ events, status }: SubmittableResult): void => {
|
||||
console.log('Transaction status:', status.type);
|
||||
|
||||
if (status.isFinalized) {
|
||||
console.log('Completed at block hash', status.value.toHex());
|
||||
console.log('Events:');
|
||||
|
||||
events.forEach(({ phase, event: { data, method, section } }: EventRecord): void => {
|
||||
console.log('\t', phase.toString(), `: ${section}.${method}`, data.toString());
|
||||
});
|
||||
|
||||
if (events.length) {
|
||||
done();
|
||||
}
|
||||
}
|
||||
};
|
||||
import { describeE2E, logEvents, SingleAccountSigner } from '../../util';
|
||||
|
||||
describeE2E({
|
||||
except: [
|
||||
@@ -74,7 +54,7 @@ describeE2E({
|
||||
});
|
||||
|
||||
it('fails on a transfer with invalid time', async (done): Promise<void> => {
|
||||
const nonce = await api.query.system.accountNonce(keyring.alice.address) as Index;
|
||||
const nonce = await api.query.system.accountNonce(keyring.alice.address);
|
||||
const signedBlock = await api.rpc.chain.getBlock();
|
||||
const currentHeight = signedBlock.block.header.number;
|
||||
const exERA = createType('ExtrinsicEra', { current: currentHeight, period: 4 });
|
||||
@@ -103,7 +83,7 @@ describeE2E({
|
||||
|
||||
api.setSigner(signer);
|
||||
|
||||
const nonce = await api.query.system.accountNonce(keyring.bob_stash.address) as Index;
|
||||
const nonce = await api.query.system.accountNonce(keyring.bob_stash.address);
|
||||
const signedBlock = await api.rpc.chain.getBlock();
|
||||
const currentHeight = signedBlock.block.header.number;
|
||||
const exERA = createType('ExtrinsicEra', { current: currentHeight, period: 4 });
|
||||
|
||||
@@ -4,31 +4,10 @@
|
||||
|
||||
import testingPairs from '@polkadot/keyring/testingPairs';
|
||||
import WsProvider from '@polkadot/rpc-provider/ws';
|
||||
import { EventRecord } from '@polkadot/types/interfaces';
|
||||
|
||||
import { SubmittableResult } from '../../../src';
|
||||
import ApiPromise from '../../../src/promise';
|
||||
import { Signer } from '../../../src/types';
|
||||
import { describeE2E, SingleAccountSigner } from '../../util';
|
||||
|
||||
// log all events for the transfer, calling done() when finalized
|
||||
const logEvents = (done: () => {}): (r: SubmittableResult) => void =>
|
||||
({ events, status }: SubmittableResult): void => {
|
||||
console.log('Transaction status:', status.type);
|
||||
|
||||
if (status.isFinalized) {
|
||||
console.log('Completed at block hash', status.value.toHex());
|
||||
console.log('Events:');
|
||||
|
||||
events.forEach(({ phase, event: { data, method, section } }: EventRecord): void => {
|
||||
console.log('\t', phase.toString(), `: ${section}.${method}`, data.toString());
|
||||
});
|
||||
|
||||
if (events.length) {
|
||||
done();
|
||||
}
|
||||
}
|
||||
};
|
||||
import { describeE2E, logEvents, SingleAccountSigner } from '../../util';
|
||||
|
||||
describeE2E({
|
||||
except: ['remote-polkadot-alexander', 'remote-substrate-1.0']
|
||||
|
||||
@@ -7,31 +7,10 @@ import testingPairs from '@polkadot/keyring/testingPairs';
|
||||
import WsProvider from '@polkadot/rpc-provider/ws';
|
||||
import { randomAsHex } from '@polkadot/util-crypto';
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
import { EventRecord, Index } from '@polkadot/types/interfaces';
|
||||
|
||||
import { SubmittableResult } from '../../../src';
|
||||
import ApiPromise from '../../../src/promise';
|
||||
import randomAsHex2097152 from '../../mock-data/randomAsHex_2097152';
|
||||
import { calculateAccountDeposit, describeE2E } from '../../util';
|
||||
|
||||
// log all events for the transfers, calling done() when finalized
|
||||
const logEvents = (done: () => {}): (r: SubmittableResult) => void =>
|
||||
({ events, status }: SubmittableResult): void => {
|
||||
console.log('Transaction status:', status.type);
|
||||
|
||||
if (status.isFinalized) {
|
||||
console.log('Completed at block hash', status.value.toHex());
|
||||
console.log('Events:');
|
||||
|
||||
events.forEach(({ phase, event: { data, method, section } }: EventRecord): void => {
|
||||
console.log('\t', phase.toString(), `: ${section}.${method}`, data.toString());
|
||||
});
|
||||
|
||||
if (events.length) {
|
||||
done();
|
||||
}
|
||||
}
|
||||
};
|
||||
import { calculateAccountDeposit, describeE2E, logEvents } from '../../util';
|
||||
|
||||
describeE2E({
|
||||
except: ['remote-polkadot-alexander', 'remote-substrate-1.0']
|
||||
@@ -46,7 +25,7 @@ describeE2E({
|
||||
});
|
||||
|
||||
it('can submit an extrinsic from hex', async (done): Promise<() => void> => {
|
||||
const nonce = await api.query.system.accountNonce(keyring.bob_stash.address) as Index;
|
||||
const nonce = await api.query.system.accountNonce(keyring.bob_stash.address);
|
||||
const hex = api.tx.balances
|
||||
.transfer(keyring.eve.address, 12345)
|
||||
.sign(keyring.bob_stash, { nonce })
|
||||
@@ -56,7 +35,7 @@ describeE2E({
|
||||
});
|
||||
|
||||
it('invalid hex does throw a catchable exception', async (done): Promise<void> => {
|
||||
const nonce = await api.query.system.accountNonce(keyring.bob_stash.address) as Index;
|
||||
const nonce = await api.query.system.accountNonce(keyring.bob_stash.address);
|
||||
const hex = api.tx.balances
|
||||
.transfer(keyring.eve.address, 12345)
|
||||
.sign(keyring.bob_stash, { nonce })
|
||||
@@ -78,7 +57,7 @@ describeE2E({
|
||||
});
|
||||
|
||||
it('makes a transfer (sign, then send)', async (done): Promise<() => void> => {
|
||||
const nonce = await api.query.system.accountNonce(keyring.bob_stash.address) as Index;
|
||||
const nonce = await api.query.system.accountNonce(keyring.bob_stash.address);
|
||||
|
||||
return api.tx.balances
|
||||
.transfer(keyring.eve.address, 12345)
|
||||
@@ -87,7 +66,7 @@ describeE2E({
|
||||
});
|
||||
|
||||
it('makes a transfer (sign, then send - compat version)', async (done): Promise<() => void> => {
|
||||
const nonce = await api.query.system.accountNonce(keyring.bob_stash.address) as Index;
|
||||
const nonce = await api.query.system.accountNonce(keyring.bob_stash.address);
|
||||
|
||||
return api.tx.balances
|
||||
.transfer(keyring.eve.address, 12345)
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { Balance } from '@polkadot/types/interfaces';
|
||||
import testingPairs from '@polkadot/keyring/testingPairs';
|
||||
import WsProvider from '@polkadot/rpc-provider/ws';
|
||||
|
||||
@@ -29,7 +28,7 @@ describeE2E({
|
||||
it('queries state for a balance', (done): void => {
|
||||
api.query.balances.freeBalance(keyring.alice_stash.address).subscribe((balance): void => {
|
||||
expect(balance).toBeInstanceOf(BN);
|
||||
expect((balance as Balance).isZero()).toBe(false);
|
||||
expect(balance.isZero()).toBe(false);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,4 +4,5 @@
|
||||
|
||||
export * from './calculateAccountDeposit';
|
||||
export * from './describeE2E';
|
||||
export * from './logEvents';
|
||||
export * from './SingleAccountSigner';
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright 2017-2019 @polkadot/api authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { EventRecord } from '@polkadot/types/interfaces';
|
||||
|
||||
import { SubmittableResult } from '../../src';
|
||||
|
||||
// log all events for the transfers, calling done() when finalized
|
||||
export const logEvents = (done: () => {}): (r: SubmittableResult) => void =>
|
||||
({ events, status }: SubmittableResult): void => {
|
||||
console.log('Transaction status:', status.type);
|
||||
|
||||
if (status.isFinalized) {
|
||||
console.log('Completed at block hash', status.value.toHex());
|
||||
console.log('Events:');
|
||||
|
||||
events.forEach(({ phase, event: { data, method, section } }: EventRecord): void => {
|
||||
console.log('\t', phase.toString(), `: ${section}.${method}`, data.toString());
|
||||
});
|
||||
|
||||
if (events.length) {
|
||||
done();
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-core",
|
||||
"version": "0.92.1",
|
||||
"version": "0.93.1",
|
||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -26,11 +26,11 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.6.0",
|
||||
"@polkadot/jsonrpc": "^0.92.1",
|
||||
"@polkadot/rpc-provider": "^0.92.1",
|
||||
"@polkadot/types": "^0.92.1",
|
||||
"@polkadot/util": "^1.4.1",
|
||||
"@babel/runtime": "^7.6.2",
|
||||
"@polkadot/jsonrpc": "^0.93.1",
|
||||
"@polkadot/rpc-provider": "^0.93.1",
|
||||
"@polkadot/types": "^0.93.1",
|
||||
"@polkadot/util": "^1.5.1",
|
||||
"rxjs": "^6.5.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ describe('Api', (): void => {
|
||||
Object.keys(rpc).filter((key): boolean => !key.startsWith('_'))
|
||||
).toEqual([
|
||||
'provider',
|
||||
'author', 'chain', 'state', 'system'
|
||||
'account', 'author', 'chain', 'contracts', 'rpc', 'state', 'system'
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -56,10 +56,16 @@ export default class Rpc implements RpcInterface {
|
||||
|
||||
public readonly provider: ProviderInterface;
|
||||
|
||||
public readonly account: RpcInterface['account'];
|
||||
|
||||
public readonly author: RpcInterface['author'];
|
||||
|
||||
public readonly chain: RpcInterface['chain'];
|
||||
|
||||
public readonly contracts: RpcInterface['contracts'];
|
||||
|
||||
public readonly rpc: RpcInterface['rpc'];
|
||||
|
||||
public readonly state: RpcInterface['state'];
|
||||
|
||||
public readonly system: RpcInterface['system'];
|
||||
@@ -75,8 +81,11 @@ export default class Rpc implements RpcInterface {
|
||||
|
||||
this.provider = provider;
|
||||
|
||||
this.account = this.createInterface('account');
|
||||
this.author = this.createInterface('author');
|
||||
this.contracts = this.createInterface('contracts');
|
||||
this.chain = this.createInterface('chain');
|
||||
this.rpc = this.createInterface('rpc');
|
||||
this.state = this.createInterface('state');
|
||||
this.system = this.createInterface('system');
|
||||
}
|
||||
@@ -161,7 +170,10 @@ export default class Rpc implements RpcInterface {
|
||||
catchError((error): any => {
|
||||
const message = this.createErrorMessage(method, error);
|
||||
|
||||
l.error(message);
|
||||
// don't scare with old nodes, this is handled transparently
|
||||
if (rpcName !== 'rpc_methods') {
|
||||
l.error(message);
|
||||
}
|
||||
|
||||
return throwError(new Error(message));
|
||||
}),
|
||||
|
||||
@@ -4,11 +4,15 @@
|
||||
import { Observable } from 'rxjs';
|
||||
import { Vec } from '@polkadot/types/codec';
|
||||
import { Bytes, Metadata, StorageData, StorageKey, Text, u64 } from '@polkadot/types';
|
||||
import { BlockNumber, Extrinsic, Hash, Header, SignedBlock } from '@polkadot/types/interfaces/runtime';
|
||||
import { ChainProperties, ExtrinsicOrHash, ExtrinsicStatus, Health, NetworkState, PeerInfo, RuntimeVersion, StorageChangeSet } from '@polkadot/types/interfaces/rpc';
|
||||
import { AccountId, BlockNumber, Extrinsic, Hash, Header, Index, SignedBlock } from '@polkadot/types/interfaces/runtime';
|
||||
import { ContractCallRequest, ContractExecResult } from '@polkadot/types/interfaces/contracts';
|
||||
import { ChainProperties, ExtrinsicOrHash, ExtrinsicStatus, Health, NetworkState, PeerInfo, RpcMethods, RuntimeVersion, StorageChangeSet } from '@polkadot/types/interfaces/rpc';
|
||||
import { Codec, IExtrinsic } from '@polkadot/types/types';
|
||||
|
||||
export interface RpcInterface {
|
||||
account: {
|
||||
nextIndex(accountId: AccountId | Uint8Array | string): Observable<Index>;
|
||||
};
|
||||
author: {
|
||||
insertKey(keyType: Text | string, suri: Text | string, publicKey: Bytes | Uint8Array | string): Observable<Bytes>;
|
||||
pendingExtrinsics(): Observable<Vec<Extrinsic>>;
|
||||
@@ -25,6 +29,12 @@ export interface RpcInterface {
|
||||
subscribeFinalizedHeads(): Observable<Header>;
|
||||
subscribeNewHeads(): Observable<Header>;
|
||||
};
|
||||
contracts: {
|
||||
call(callRequest: ContractCallRequest, at?: Hash | Uint8Array | string): Observable<ContractExecResult>;
|
||||
};
|
||||
rpc: {
|
||||
methods(): Observable<RpcMethods>;
|
||||
};
|
||||
state: {
|
||||
call(method: Text | string, data: Bytes | Uint8Array | string, block?: Hash | Uint8Array | string): Observable<Bytes>;
|
||||
getChildKeys(childStorageKey: any, key: any, block?: Hash | Uint8Array | string): Observable<Vec<StorageKey>>;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-provider",
|
||||
"version": "0.92.1",
|
||||
"version": "0.93.1",
|
||||
"description": "Transport providers for the API",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -26,18 +26,18 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.6.0",
|
||||
"@polkadot/api-metadata": "^0.92.1",
|
||||
"@polkadot/util": "^1.4.1",
|
||||
"@polkadot/util-crypto": "^1.4.1",
|
||||
"@types/nock": "^10.0.3",
|
||||
"@babel/runtime": "^7.6.2",
|
||||
"@polkadot/api-metadata": "^0.93.1",
|
||||
"@polkadot/util": "^1.5.1",
|
||||
"@polkadot/util-crypto": "^1.5.1",
|
||||
"@types/nock": "^11.1.0",
|
||||
"eventemitter3": "^4.0.0",
|
||||
"isomorphic-fetch": "^2.2.1",
|
||||
"websocket": "^1.0.29"
|
||||
"websocket": "^1.0.30"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^1.4.1",
|
||||
"@polkadot/keyring": "^1.5.1",
|
||||
"mock-socket": "^9.0.0",
|
||||
"nock": "^11.3.3"
|
||||
"nock": "^11.3.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,8 +56,6 @@ export default class RpcCoder {
|
||||
? ''
|
||||
: ' (' + `${data}`.substr(0, 10) + ')';
|
||||
|
||||
console.error(`${code}: ${message}${_data}`);
|
||||
|
||||
throw new Error(`${code}: ${message}${_data}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/jsonrpc",
|
||||
"version": "0.92.1",
|
||||
"version": "0.93.1",
|
||||
"description": "Method definitions for the Polkadot RPC layer",
|
||||
"main": "index.js",
|
||||
"publishConfig": {
|
||||
@@ -26,6 +26,6 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-jsonrpc#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.6.0"
|
||||
"@babel/runtime": "^7.6.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
// Copyright 2017-2019 @polkadot/jsonrpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { RpcMethodOpt } from './types';
|
||||
|
||||
import createMethod from './create/method';
|
||||
import createParam from './create/param';
|
||||
|
||||
// NOTE order here is the same as in Rust, alphabetical below
|
||||
|
||||
const nextIndex: RpcMethodOpt = {
|
||||
description: 'Retrieves the next accountIndex as available on the node',
|
||||
isOptional: true,
|
||||
params: [
|
||||
createParam('accountId', 'AccountId')
|
||||
],
|
||||
type: 'Index'
|
||||
};
|
||||
|
||||
const section = 'account';
|
||||
|
||||
/**
|
||||
* @summary Calls to retrieve system info.
|
||||
*/
|
||||
export default {
|
||||
isDeprecated: false,
|
||||
isHidden: false,
|
||||
description: '(Optional) Methods that retrieves account-specific information',
|
||||
section,
|
||||
methods: {
|
||||
nextIndex: createMethod(section, 'nextIndex', nextIndex)
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright 2017-2019 @polkadot/jsonrpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { RpcMethodOpt } from './types';
|
||||
|
||||
import createMethod from './create/method';
|
||||
import createParam from './create/param';
|
||||
|
||||
// NOTE order here is the same as in Rust, alphabetical below
|
||||
|
||||
const call: RpcMethodOpt = {
|
||||
description: 'Executes a call to a contract',
|
||||
isOptional: true,
|
||||
params: [
|
||||
createParam('callRequest', 'ContractCallRequest'),
|
||||
createParam('at', 'Hash', { isOptional: true })
|
||||
],
|
||||
type: 'ContractExecResult'
|
||||
};
|
||||
|
||||
const section = 'contracts';
|
||||
|
||||
/**
|
||||
* @summary Calls to retrieve system info.
|
||||
*/
|
||||
export default {
|
||||
isDeprecated: false,
|
||||
isHidden: false,
|
||||
description: '(Optional) Methods that performs actions on contracts',
|
||||
section,
|
||||
methods: {
|
||||
call: createMethod(section, 'call', call)
|
||||
}
|
||||
};
|
||||
@@ -6,11 +6,12 @@ import { RpcMethodOpt, RpcMethod } from '../types';
|
||||
|
||||
import { isUndefined } from '@polkadot/util';
|
||||
|
||||
export default function createMethod (section: string, method: string, { description, isDeprecated = false, isHidden = false, isSigned = false, params, pubsub, type }: RpcMethodOpt): RpcMethod {
|
||||
export default function createMethod (section: string, method: string, { description, isDeprecated = false, isHidden = false, isOptional = false, isSigned = false, params, pubsub, type }: RpcMethodOpt): RpcMethod {
|
||||
return {
|
||||
description,
|
||||
isDeprecated,
|
||||
isHidden,
|
||||
isOptional,
|
||||
isSigned,
|
||||
isSubscription: !isUndefined(pubsub),
|
||||
method,
|
||||
|
||||
@@ -4,14 +4,20 @@
|
||||
|
||||
import { RpcSection } from './types';
|
||||
|
||||
import account from './account';
|
||||
import author from './author';
|
||||
import chain from './chain';
|
||||
import contracts from './contracts';
|
||||
import rpc from './rpc';
|
||||
import state from './state';
|
||||
import system from './system';
|
||||
|
||||
const interfaces: Record<string, RpcSection> = {
|
||||
account,
|
||||
author,
|
||||
chain,
|
||||
contracts,
|
||||
rpc,
|
||||
state,
|
||||
system
|
||||
};
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright 2017-2019 @polkadot/jsonrpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { RpcMethodOpt } from './types';
|
||||
|
||||
import createMethod from './create/method';
|
||||
|
||||
// NOTE order here is the same as in Rust, alphabetical below
|
||||
|
||||
const methods: RpcMethodOpt = {
|
||||
description: 'Retrieves the list of RPC methods that are exposed by the node',
|
||||
params: [],
|
||||
type: 'RpcMethods'
|
||||
};
|
||||
|
||||
const section = 'rpc';
|
||||
|
||||
/**
|
||||
* @summary Calls to retrieve system info.
|
||||
*/
|
||||
export default {
|
||||
isDeprecated: false,
|
||||
isHidden: false,
|
||||
description: 'Retrieves information about the RPC endpoints',
|
||||
section,
|
||||
methods: {
|
||||
methods: createMethod(section, 'methods', methods)
|
||||
}
|
||||
};
|
||||
@@ -16,6 +16,7 @@ export interface RpcMethodOpt {
|
||||
description: string;
|
||||
isDeprecated?: boolean;
|
||||
isHidden?: boolean;
|
||||
isOptional?: boolean;
|
||||
isSigned?: boolean;
|
||||
isSubscription?: boolean;
|
||||
params: RpcParam[];
|
||||
@@ -28,6 +29,7 @@ export interface RpcMethod {
|
||||
description: string;
|
||||
isDeprecated: boolean;
|
||||
isHidden: boolean;
|
||||
isOptional: boolean;
|
||||
isSigned: boolean;
|
||||
isSubscription: boolean;
|
||||
method: string;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/types",
|
||||
"version": "0.92.1",
|
||||
"version": "0.93.1",
|
||||
"description": "Implementation of the Parity codec",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -26,13 +26,13 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.6.0",
|
||||
"@polkadot/util": "^1.4.1",
|
||||
"@polkadot/util-crypto": "^1.4.1",
|
||||
"@babel/runtime": "^7.6.2",
|
||||
"@polkadot/util": "^1.5.1",
|
||||
"@polkadot/util-crypto": "^1.5.1",
|
||||
"@types/memoizee": "^0.4.3",
|
||||
"memoizee": "^0.4.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^1.4.1"
|
||||
"@polkadot/keyring": "^1.5.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,16 +327,15 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "EpochStartSlot",
|
||||
"name": "GenesisSlot",
|
||||
"modifier": 1,
|
||||
"type": {
|
||||
"Type": "u64"
|
||||
},
|
||||
"fallback": "0x0000000000000000",
|
||||
"documentation": [
|
||||
" Slot at which the current epoch started. It is possible that no",
|
||||
" block was authored at the given slot and the epoch change was",
|
||||
" signalled later than this."
|
||||
" The slot at which the first epoch actually started. This is 0",
|
||||
" until the first block of the chain."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -350,30 +349,6 @@
|
||||
" Current slot number."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SecondarySlots",
|
||||
"modifier": 1,
|
||||
"type": {
|
||||
"Type": "(bool,bool)"
|
||||
},
|
||||
"fallback": "0x0101",
|
||||
"documentation": [
|
||||
" Whether secondary slots are enabled in case the VRF-based slot is",
|
||||
" empty for the current epoch and the next epoch, respectively."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "PendingSecondarySlotsChange",
|
||||
"modifier": 0,
|
||||
"type": {
|
||||
"Type": "bool"
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" Pending change to enable/disable secondary slots which will be",
|
||||
" triggered at `current_epoch + 2`."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Randomness",
|
||||
"modifier": 1,
|
||||
@@ -442,32 +417,17 @@
|
||||
"name": "Initialized",
|
||||
"modifier": 0,
|
||||
"type": {
|
||||
"Type": "bool"
|
||||
"Type": "MaybeVrf"
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" Temporary value (cleared at block finalization) which is true",
|
||||
" Temporary value (cleared at block finalization) which is `Some`",
|
||||
" if per-block initialization has already been called for current block."
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"calls": [
|
||||
{
|
||||
"name": "set_pending_secondary_slots_change",
|
||||
"args": [
|
||||
{
|
||||
"name": "change",
|
||||
"type": "Option<bool>"
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
" Sets a pending change to enable / disable secondary slot assignment.",
|
||||
" The pending change will be set at the end of the current epoch and",
|
||||
" will be enacted at `current_epoch + 2`."
|
||||
]
|
||||
}
|
||||
],
|
||||
"calls": [],
|
||||
"events": null,
|
||||
"constants": [
|
||||
{
|
||||
@@ -1123,10 +1083,10 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CurrentEraRewards",
|
||||
"name": "CurrentEraPointsEarned",
|
||||
"modifier": 1,
|
||||
"type": {
|
||||
"Type": "EraRewards"
|
||||
"Type": "EraPoints"
|
||||
},
|
||||
"fallback": "0x0000000000",
|
||||
"documentation": [
|
||||
@@ -1646,6 +1606,19 @@
|
||||
" will be used to determine the validator's session keys."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "DisabledValidators",
|
||||
"modifier": 1,
|
||||
"type": {
|
||||
"Type": "Vec<u32>"
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" Indices of disabled validators.",
|
||||
"",
|
||||
" The set is cleared when `on_session_ending` returns a new set of identities."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "NextKeys",
|
||||
"modifier": 0,
|
||||
@@ -1984,6 +1957,13 @@
|
||||
],
|
||||
"constants": []
|
||||
},
|
||||
{
|
||||
"name": "AuthorityDiscovery",
|
||||
"storage": null,
|
||||
"calls": [],
|
||||
"events": null,
|
||||
"constants": []
|
||||
},
|
||||
{
|
||||
"name": "Democracy",
|
||||
"storage": {
|
||||
@@ -3111,10 +3091,10 @@
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" 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)."
|
||||
" 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)."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -3140,13 +3120,7 @@
|
||||
}
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" A list of votes for each voter. The votes are stored as numeric values and parsed in a bit-wise manner.",
|
||||
"",
|
||||
" In order to get a human-readable representation (`Vec<bool>`), use [`all_approvals_of`].",
|
||||
"",
|
||||
" Furthermore, each vector of scalars is chunked with the cap of `APPROVAL_SET_SIZE`."
|
||||
]
|
||||
"documentation": []
|
||||
},
|
||||
{
|
||||
"name": "RegisterInfoOf",
|
||||
@@ -3161,8 +3135,8 @@
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" The vote index and list slot that the candidate `who` was registered or `None` if they are not",
|
||||
" currently registered."
|
||||
" The vote index and list slot that the candidate `who` was registered or `None` if they",
|
||||
" are not currently registered."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -3260,8 +3234,9 @@
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" 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."
|
||||
" 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."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -3298,27 +3273,31 @@
|
||||
{
|
||||
"name": "hint",
|
||||
"type": "SetIndex"
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"type": "BalanceOf"
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
" Set candidate approvals. Approval slots stay valid as long as candidates in those slots",
|
||||
" are registered.",
|
||||
"",
|
||||
" Locks the total balance of caller indefinitely.",
|
||||
" Only [`retract_voter`] or [`reap_inactive_voter`] can unlock the balance.",
|
||||
" 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 `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.",
|
||||
" - 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.",
|
||||
" 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.",
|
||||
" 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).",
|
||||
@@ -3341,11 +3320,15 @@
|
||||
{
|
||||
"name": "hint",
|
||||
"type": "SetIndex"
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"type": "BalanceOf"
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
" Set candidate approvals from a proxy. Approval slots stay valid as long as candidates in those slots",
|
||||
" are registered.",
|
||||
" 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.",
|
||||
@@ -3374,8 +3357,8 @@
|
||||
],
|
||||
"documentation": [
|
||||
" 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.",
|
||||
" 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.",
|
||||
"",
|
||||
@@ -3449,9 +3432,10 @@
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
" 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",
|
||||
" 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.",
|
||||
@@ -3619,6 +3603,14 @@
|
||||
" is 1000."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "MinimumVotingLock",
|
||||
"type": "BalanceOf",
|
||||
"value": "0x00e40b54020000000000000000000000",
|
||||
"documentation": [
|
||||
" Minimum about that can be used as the locked value for voting."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "DecayRatio",
|
||||
"type": "u32",
|
||||
@@ -4760,7 +4752,8 @@
|
||||
" # <weight>",
|
||||
" - O(1).",
|
||||
" - Limited storage reads.",
|
||||
" - No DB writes.",
|
||||
" - One DB write (event).",
|
||||
" - Unknown weight of derivative `proposal` execution.",
|
||||
" # </weight>"
|
||||
]
|
||||
},
|
||||
@@ -4783,6 +4776,32 @@
|
||||
" - One DB change.",
|
||||
" # </weight>"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "sudo_as",
|
||||
"args": [
|
||||
{
|
||||
"name": "who",
|
||||
"type": "Address"
|
||||
},
|
||||
{
|
||||
"name": "proposal",
|
||||
"type": "Proposal"
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
" 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>"
|
||||
]
|
||||
}
|
||||
],
|
||||
"events": [
|
||||
@@ -4803,6 +4822,15 @@
|
||||
"documentation": [
|
||||
" The sudoer just switched identity; the old key is supplied."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SudoAsDone",
|
||||
"args": [
|
||||
"bool"
|
||||
],
|
||||
"documentation": [
|
||||
" A sudo just took place."
|
||||
]
|
||||
}
|
||||
],
|
||||
"constants": []
|
||||
|
||||
@@ -327,16 +327,15 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "EpochStartSlot",
|
||||
"name": "GenesisSlot",
|
||||
"modifier": 1,
|
||||
"type": {
|
||||
"Type": "u64"
|
||||
},
|
||||
"fallback": "0x0000000000000000",
|
||||
"documentation": [
|
||||
" Slot at which the current epoch started. It is possible that no",
|
||||
" block was authored at the given slot and the epoch change was",
|
||||
" signalled later than this."
|
||||
" The slot at which the first epoch actually started. This is 0",
|
||||
" until the first block of the chain."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -350,30 +349,6 @@
|
||||
" Current slot number."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SecondarySlots",
|
||||
"modifier": 1,
|
||||
"type": {
|
||||
"Type": "(bool,bool)"
|
||||
},
|
||||
"fallback": "0x0101",
|
||||
"documentation": [
|
||||
" Whether secondary slots are enabled in case the VRF-based slot is",
|
||||
" empty for the current epoch and the next epoch, respectively."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "PendingSecondarySlotsChange",
|
||||
"modifier": 0,
|
||||
"type": {
|
||||
"Type": "bool"
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" Pending change to enable/disable secondary slots which will be",
|
||||
" triggered at `current_epoch + 2`."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Randomness",
|
||||
"modifier": 1,
|
||||
@@ -442,32 +417,17 @@
|
||||
"name": "Initialized",
|
||||
"modifier": 0,
|
||||
"type": {
|
||||
"Type": "bool"
|
||||
"Type": "MaybeVrf"
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" Temporary value (cleared at block finalization) which is true",
|
||||
" Temporary value (cleared at block finalization) which is `Some`",
|
||||
" if per-block initialization has already been called for current block."
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"calls": [
|
||||
{
|
||||
"name": "set_pending_secondary_slots_change",
|
||||
"args": [
|
||||
{
|
||||
"name": "change",
|
||||
"type": "Option<bool>"
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
" Sets a pending change to enable / disable secondary slot assignment.",
|
||||
" The pending change will be set at the end of the current epoch and",
|
||||
" will be enacted at `current_epoch + 2`."
|
||||
]
|
||||
}
|
||||
],
|
||||
"calls": [],
|
||||
"events": null,
|
||||
"constants": [
|
||||
{
|
||||
@@ -1569,6 +1529,19 @@
|
||||
" will be used to determine the validator's session keys."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "DisabledValidators",
|
||||
"modifier": 1,
|
||||
"type": {
|
||||
"Type": "Vec<u32>"
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" Indices of disabled validators.",
|
||||
"",
|
||||
" The set is cleared when `on_session_ending` returns a new set of identities."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "NextKeys",
|
||||
"modifier": 0,
|
||||
@@ -2789,10 +2762,10 @@
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" 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)."
|
||||
" 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)."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -2818,13 +2791,7 @@
|
||||
}
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" A list of votes for each voter. The votes are stored as numeric values and parsed in a bit-wise manner.",
|
||||
"",
|
||||
" In order to get a human-readable representation (`Vec<bool>`), use [`all_approvals_of`].",
|
||||
"",
|
||||
" Furthermore, each vector of scalars is chunked with the cap of `APPROVAL_SET_SIZE`."
|
||||
]
|
||||
"documentation": []
|
||||
},
|
||||
{
|
||||
"name": "RegisterInfoOf",
|
||||
@@ -2839,8 +2806,8 @@
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" The vote index and list slot that the candidate `who` was registered or `None` if they are not",
|
||||
" currently registered."
|
||||
" The vote index and list slot that the candidate `who` was registered or `None` if they",
|
||||
" are not currently registered."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -2938,8 +2905,9 @@
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" 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."
|
||||
" 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."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -2976,27 +2944,31 @@
|
||||
{
|
||||
"name": "hint",
|
||||
"type": "SetIndex"
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"type": "BalanceOf"
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
" Set candidate approvals. Approval slots stay valid as long as candidates in those slots",
|
||||
" are registered.",
|
||||
"",
|
||||
" Locks the total balance of caller indefinitely.",
|
||||
" Only [`retract_voter`] or [`reap_inactive_voter`] can unlock the balance.",
|
||||
" 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 `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.",
|
||||
" - 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.",
|
||||
" 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.",
|
||||
" 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).",
|
||||
@@ -3019,11 +2991,15 @@
|
||||
{
|
||||
"name": "hint",
|
||||
"type": "SetIndex"
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"type": "BalanceOf"
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
" Set candidate approvals from a proxy. Approval slots stay valid as long as candidates in those slots",
|
||||
" are registered.",
|
||||
" 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.",
|
||||
@@ -3052,8 +3028,8 @@
|
||||
],
|
||||
"documentation": [
|
||||
" 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.",
|
||||
" 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.",
|
||||
"",
|
||||
@@ -3127,9 +3103,10 @@
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
" 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",
|
||||
" 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.",
|
||||
@@ -3297,6 +3274,14 @@
|
||||
" is 1000."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "MinimumVotingLock",
|
||||
"type": "BalanceOf",
|
||||
"value": "0x00407a10f35a00000000000000000000",
|
||||
"documentation": [
|
||||
" Minimum about that can be used as the locked value for voting."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "DecayRatio",
|
||||
"type": "u32",
|
||||
@@ -3973,7 +3958,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "create",
|
||||
"name": "instantiate",
|
||||
"args": [
|
||||
{
|
||||
"name": "endowment",
|
||||
@@ -3993,9 +3978,9 @@
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
" Creates a new contract from the `codehash` generated by `put_code`, optionally transferring some balance.",
|
||||
" Instantiates a new contract from the `codehash` generated by `put_code`, optionally transferring some balance.",
|
||||
"",
|
||||
" Creation is executed as follows:",
|
||||
" 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.",
|
||||
@@ -4035,7 +4020,7 @@
|
||||
"Balance"
|
||||
],
|
||||
"documentation": [
|
||||
" Transfer happened `from` to `to` with given `value` as part of a `call` or `create`."
|
||||
" Transfer happened `from` to `to` with given `value` as part of a `call` or `instantiate`."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -4113,8 +4098,8 @@
|
||||
"type": "u32",
|
||||
"value": "0x08000000",
|
||||
"documentation": [
|
||||
" Size of a contract at the time of creation. This is a simple way to ensure",
|
||||
" that empty contracts eventually gets deleted."
|
||||
" Size of a contract at the time of instantiaion. This is a simple way to ensure that",
|
||||
" empty contracts eventually gets deleted."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -4185,7 +4170,7 @@
|
||||
"type": "BalanceOf",
|
||||
"value": "0x0010a5d4e80000000000000000000000",
|
||||
"documentation": [
|
||||
" The fee required to create a contract instance. A reasonable default value",
|
||||
" The fee required to instantiate a contract instance. A reasonable default value",
|
||||
" is 21."
|
||||
]
|
||||
},
|
||||
@@ -4199,11 +4184,11 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CreateBaseFee",
|
||||
"name": "InstantiateBaseFee",
|
||||
"type": "Gas",
|
||||
"value": "0xe803000000000000",
|
||||
"documentation": [
|
||||
" The base fee charged for creating a contract. A reasonable default value",
|
||||
" The base fee charged for instantiating a contract. A reasonable default value",
|
||||
" is 175."
|
||||
]
|
||||
},
|
||||
@@ -4212,7 +4197,7 @@
|
||||
"type": "u32",
|
||||
"value": "0x00040000",
|
||||
"documentation": [
|
||||
" The maximum nesting level of a call/create stack. A reasonable default",
|
||||
" The maximum nesting level of a call/instantiate stack. A reasonable default",
|
||||
" value is 100."
|
||||
]
|
||||
},
|
||||
@@ -4270,7 +4255,8 @@
|
||||
" # <weight>",
|
||||
" - O(1).",
|
||||
" - Limited storage reads.",
|
||||
" - No DB writes.",
|
||||
" - One DB write (event).",
|
||||
" - Unknown weight of derivative `proposal` execution.",
|
||||
" # </weight>"
|
||||
]
|
||||
},
|
||||
@@ -4293,6 +4279,32 @@
|
||||
" - One DB change.",
|
||||
" # </weight>"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "sudo_as",
|
||||
"args": [
|
||||
{
|
||||
"name": "who",
|
||||
"type": "Address"
|
||||
},
|
||||
{
|
||||
"name": "proposal",
|
||||
"type": "Proposal"
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
" 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>"
|
||||
]
|
||||
}
|
||||
],
|
||||
"events": [
|
||||
@@ -4313,6 +4325,15 @@
|
||||
"documentation": [
|
||||
" The sudoer just switched identity; the old key is supplied."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SudoAsDone",
|
||||
"args": [
|
||||
"bool"
|
||||
],
|
||||
"documentation": [
|
||||
" A sudo just took place."
|
||||
]
|
||||
}
|
||||
],
|
||||
"constants": []
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -135,4 +135,11 @@ export default abstract class AbstractArray<T extends Codec> extends Array<T> im
|
||||
public map<U> (callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[] {
|
||||
return this.toArray().map(callbackfn, thisArg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Checks if the array includes a specific value
|
||||
*/
|
||||
public includes (check: any): boolean {
|
||||
return this.some((value: T): boolean => value.eq(check));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +61,6 @@ export default class Struct<
|
||||
* @param jsonMap
|
||||
*/
|
||||
private static decodeStruct <T> (Types: ConstructorDef, value: any, jsonMap: Map<any, string>): T {
|
||||
// l.debug(() => ['Struct.decode', { Types, value }]);
|
||||
|
||||
if (isHex(value)) {
|
||||
return Struct.decodeStruct(Types, hexToU8a(value as string), jsonMap);
|
||||
} else if (isU8a(value)) {
|
||||
|
||||
@@ -69,9 +69,8 @@ const infoMapping: Record<TypeDefInfo, (value: TypeDef) => Constructor> = {
|
||||
|
||||
[TypeDefInfo.Option]: (value: TypeDef): Constructor => Option.with(getSubType(value)),
|
||||
|
||||
[TypeDefInfo.Plain]: (value: TypeDef): Constructor => {
|
||||
throw new Error(`Unable to find plain type for ${JSON.stringify(value)}`);
|
||||
},
|
||||
[TypeDefInfo.Plain]: (value: TypeDef): Constructor =>
|
||||
getTypeRegistry().getOrThrow(value.type, `Unable to find plain type for ${JSON.stringify(value)}`),
|
||||
|
||||
[TypeDefInfo.Set]: (value: TypeDef): Constructor => {
|
||||
const result: Record<string, number> = {};
|
||||
|
||||
@@ -18,15 +18,15 @@ describe('getTypeDef', (): void => {
|
||||
it('does not allow invalid vectors, end >', (): void => {
|
||||
expect(
|
||||
(): TypeDef => getTypeDef('Vec<u64')
|
||||
).toThrow(/Expected 'Vec<' closing with '>'/);
|
||||
).toThrow(/Unable to find closing matching/);
|
||||
});
|
||||
|
||||
it('returns a type structure', (): void => {
|
||||
expect(
|
||||
getTypeDef('(u32, Compact<u32>, Vec<u64>, Option<u128>, DoubleMap<u128>, (Text, Vec<(Bool, u128)>))')
|
||||
getTypeDef('(u32, Compact<u32>, Vec<u64>, Option<u128>, DoubleMap<u128>, (Text,Vec<(Bool,u128)>))')
|
||||
).toEqual({
|
||||
info: TypeDefInfo.Tuple,
|
||||
type: '(u32, Compact<u32>, Vec<u64>, Option<u128>, DoubleMap<u128>, (Text, Vec<(Bool, u128)>))',
|
||||
type: '(u32,Compact<u32>,Vec<u64>,Option<u128>,DoubleMap<u128>,(Text,Vec<(Bool,u128)>))',
|
||||
sub: [
|
||||
{
|
||||
info: TypeDefInfo.Plain,
|
||||
@@ -66,7 +66,7 @@ describe('getTypeDef', (): void => {
|
||||
},
|
||||
{
|
||||
info: TypeDefInfo.Tuple,
|
||||
type: '(Text, Vec<(Bool, u128)>)',
|
||||
type: '(Text,Vec<(Bool,u128)>)',
|
||||
sub: [
|
||||
{
|
||||
info: TypeDefInfo.Plain,
|
||||
@@ -74,10 +74,10 @@ describe('getTypeDef', (): void => {
|
||||
},
|
||||
{
|
||||
info: TypeDefInfo.Vec,
|
||||
type: 'Vec<(Bool, u128)>',
|
||||
type: 'Vec<(Bool,u128)>',
|
||||
sub: {
|
||||
info: TypeDefInfo.Tuple,
|
||||
type: '(Bool, u128)',
|
||||
type: '(Bool,u128)',
|
||||
sub: [
|
||||
{
|
||||
info: TypeDefInfo.Plain,
|
||||
@@ -96,15 +96,42 @@ describe('getTypeDef', (): void => {
|
||||
});
|
||||
});
|
||||
|
||||
it('returns a type structure (sanitized)', (): void => {
|
||||
expect(
|
||||
getTypeDef('Vec<(Box<PropIndex>, Proposal,Lookup::Target)>')
|
||||
).toEqual({
|
||||
info: TypeDefInfo.Vec,
|
||||
type: 'Vec<(PropIndex,Proposal,AccountId)>',
|
||||
sub: {
|
||||
info: TypeDefInfo.Tuple,
|
||||
type: '(PropIndex,Proposal,AccountId)',
|
||||
sub: [
|
||||
{
|
||||
info: TypeDefInfo.Plain,
|
||||
type: 'PropIndex'
|
||||
},
|
||||
{
|
||||
info: TypeDefInfo.Plain,
|
||||
type: 'Proposal'
|
||||
},
|
||||
{
|
||||
info: TypeDefInfo.Plain,
|
||||
type: 'AccountId'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('returns a type structure (actual)', (): void => {
|
||||
expect(
|
||||
getTypeDef('Vec<(PropIndex, Proposal, AccountId)>')
|
||||
).toEqual({
|
||||
info: TypeDefInfo.Vec,
|
||||
type: 'Vec<(PropIndex, Proposal, AccountId)>',
|
||||
type: 'Vec<(PropIndex,Proposal,AccountId)>',
|
||||
sub: {
|
||||
info: TypeDefInfo.Tuple,
|
||||
type: '(PropIndex, Proposal, AccountId)',
|
||||
type: '(PropIndex,Proposal,AccountId)',
|
||||
sub: [
|
||||
{
|
||||
info: TypeDefInfo.Plain,
|
||||
@@ -128,7 +155,7 @@ describe('getTypeDef', (): void => {
|
||||
getTypeDef('{"balance":"Balance","account_id":"AccountId","log":"(u64, Signature)"}')
|
||||
).toEqual({
|
||||
info: TypeDefInfo.Struct,
|
||||
type: '{"balance":"Balance","account_id":"AccountId","log":"(u64, Signature)"}',
|
||||
type: '{"balance":"Balance","account_id":"AccountId","log":"(u64,Signature)"}',
|
||||
sub: [
|
||||
{
|
||||
info: TypeDefInfo.Plain,
|
||||
@@ -143,7 +170,7 @@ describe('getTypeDef', (): void => {
|
||||
{
|
||||
info: TypeDefInfo.Tuple,
|
||||
name: 'log',
|
||||
type: '(u64, Signature)',
|
||||
type: '(u64,Signature)',
|
||||
sub: [
|
||||
{
|
||||
info: TypeDefInfo.Plain,
|
||||
|
||||
@@ -6,6 +6,7 @@ import { TypeDef, TypeDefExtVecFixed, TypeDefInfo } from './types';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import sanitize from './sanitize';
|
||||
import { typeSplit } from './typeSplit';
|
||||
|
||||
// decode an enum of either of the following forms
|
||||
@@ -119,7 +120,8 @@ function extractSubType (type: string, [start, end]: [string, string, any]): str
|
||||
}
|
||||
|
||||
export function getTypeDef (_type: string, name?: string): TypeDef {
|
||||
const type = _type.toString().trim();
|
||||
// create the type via Type, allowing types to be sanitized
|
||||
const type = sanitize(_type);
|
||||
const value: TypeDef = { info: TypeDefInfo.Plain, name, type };
|
||||
|
||||
const nested = nestedExtraction.find((nested): boolean =>
|
||||
|
||||
@@ -6,7 +6,7 @@ import '../../injector';
|
||||
|
||||
import { Constructor } from '../../types';
|
||||
|
||||
import { TypeRegistry } from './registry';
|
||||
import { TypeRegistry, getTypeRegistry } from './registry';
|
||||
import Struct from '../Struct';
|
||||
import Text from '../../primitive/Text';
|
||||
import U32 from '../../primitive/U32';
|
||||
@@ -23,7 +23,7 @@ describe('TypeRegistry', (): void => {
|
||||
let registry: TypeRegistry;
|
||||
|
||||
beforeEach((): void => {
|
||||
registry = new TypeRegistry();
|
||||
registry = getTypeRegistry();
|
||||
});
|
||||
|
||||
it('handles non exist type', (): void => {
|
||||
@@ -50,6 +50,51 @@ describe('TypeRegistry', (): void => {
|
||||
expect(isChildClass(U32, registry.get('U32Renamed'))).toBe(true);
|
||||
});
|
||||
|
||||
it('can register recursive types', (): void => {
|
||||
registry.register({
|
||||
Recursive: {
|
||||
next: 'Option<Recursive>'
|
||||
}
|
||||
});
|
||||
|
||||
expect(registry.hasDef('Recursive')).toBe(true);
|
||||
expect(registry.hasClass('Recursive')).toBe(false);
|
||||
|
||||
const Recursive = registry.getOrThrow('Recursive');
|
||||
|
||||
expect(registry.hasClass('Recursive')).toBe(true);
|
||||
|
||||
const last = new Recursive({ next: null });
|
||||
const first = new Recursive({ next: last });
|
||||
|
||||
expect((first as any).next.isSome).toBe(true);
|
||||
expect((first as any).next.unwrap().next.isSome).toBe(false);
|
||||
});
|
||||
|
||||
it('can register cross-referencing types ()', (): void => {
|
||||
registry.register({
|
||||
A: {
|
||||
next: 'B'
|
||||
},
|
||||
B: {
|
||||
_enum: {
|
||||
End: null,
|
||||
Other: 'A'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const A = registry.getOrThrow('A');
|
||||
const B = registry.getOrThrow('B');
|
||||
|
||||
expect(registry.hasClass('Recursive')).toBe(true);
|
||||
|
||||
const last = new B({ End: null });
|
||||
const first = new B({ Other: new A({ next: last }) });
|
||||
|
||||
expect((first as any).isOther).toBe(true);
|
||||
});
|
||||
|
||||
it('can create types from string', (): void => {
|
||||
registry.register({
|
||||
U32Renamed: 'u32'
|
||||
|
||||
@@ -93,8 +93,16 @@ export class TypeRegistry {
|
||||
return type;
|
||||
}
|
||||
|
||||
public hasClass (name: string): boolean {
|
||||
return this._classes.has(name);
|
||||
}
|
||||
|
||||
public hasDef (name: string): boolean {
|
||||
return this._definitions.has(name);
|
||||
}
|
||||
|
||||
public hasType (name: string): boolean {
|
||||
return this._classes.has(name) || this._definitions.has(name);
|
||||
return this.hasClass(name) || this.hasDef(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
/* eslint-disable @typescript-eslint/no-use-before-define */
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
type Mapper = (value: string) => string;
|
||||
|
||||
const ALLOWED_BOXES = ['Compact', 'DoubleMap', 'Linkage', 'Option', 'Vec'];
|
||||
|
||||
const mappings: Mapper[] = [
|
||||
// alias <T::InherentOfflineReport as InherentOfflineReport>::Inherent -> InherentOfflineReport
|
||||
_alias('<T::InherentOfflineReport as InherentOfflineReport>::Inherent', 'InherentOfflineReport'),
|
||||
// alias TreasuryProposal from Proposal<T::AccountId, BalanceOf<T>>
|
||||
_alias('Proposal<T::AccountId, BalanceOf<T>>', 'TreasuryProposal'),
|
||||
// <T::Balance as HasCompact>
|
||||
_cleanupCompact(),
|
||||
// Remove all the trait prefixes
|
||||
_removeTraits(),
|
||||
// remove PairOf<T> -> (T, T)
|
||||
_removePairOf(),
|
||||
// remove boxing, `Box<Proposal>` -> `Proposal`
|
||||
_removeWrap('Box'),
|
||||
// remove generics, `MisbehaviorReport<Hash, BlockNumber>` -> `MisbehaviorReport`
|
||||
_removeGenerics(),
|
||||
// alias String -> Text (compat with jsonrpc methods)
|
||||
_alias('String', 'Text'),
|
||||
// alias () -> Null
|
||||
_alias('\\(\\)', 'Null'),
|
||||
// alias Vec<u8> -> Bytes
|
||||
_alias('Vec<u8>', 'Bytes'),
|
||||
// alias &[u8] -> Bytes
|
||||
_alias('&\\[u8\\]', 'Bytes'),
|
||||
// alias RawAddress -> Address
|
||||
_alias('RawAddress', 'Address'),
|
||||
// alias Lookup::Source to Address (_could_ be AccountId on certain chains)
|
||||
_alias('Lookup::Source', 'Address'),
|
||||
// alias Lookup::Target to AccountId (always the case)
|
||||
_alias('Lookup::Target', 'AccountId'),
|
||||
// alias for grandpa, as used in polkadot
|
||||
_alias('grandpa::AuthorityId', 'AuthorityId'),
|
||||
// specific for SessionIndex (could make this session::, but be conservative)
|
||||
_alias('session::SessionIndex', 'SessionIndex'),
|
||||
// HACK duplication between contracts & primitives, however contracts prefixed with exec
|
||||
_alias('exec::StorageKey', 'ContractStorageKey'),
|
||||
// Phantom
|
||||
_alias('rstd::marker::PhantomData', 'PhantomData'),
|
||||
// flattens tuples with one value, `(AccountId)` -> `AccountId`
|
||||
_flattenSingleTuple(),
|
||||
// converts ::Type to Type, <T as Trait<I>>::Proposal -> ::Proposal
|
||||
_removeColonPrefix()
|
||||
];
|
||||
|
||||
// given a starting index, find the closing >
|
||||
function _findClosing (value: string, start: number): number {
|
||||
let depth = 0;
|
||||
|
||||
for (let index = start; index < value.length; index++) {
|
||||
if (value[index] === '>') {
|
||||
if (!depth) {
|
||||
return index;
|
||||
}
|
||||
|
||||
depth--;
|
||||
} else if (value[index] === '<') {
|
||||
depth++;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`Unable to find closing matching <> on '${value}' (start ${start})`);
|
||||
}
|
||||
|
||||
function _alias (src: string, dest: string): Mapper {
|
||||
return (value: string): string => {
|
||||
return value.replace(
|
||||
new RegExp(src, 'g'), dest
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
function _cleanupCompact (): Mapper {
|
||||
return (value: string): string => {
|
||||
for (let index = 0; index < value.length; index++) {
|
||||
if (value[index] !== '<') {
|
||||
continue;
|
||||
}
|
||||
|
||||
const end = _findClosing(value, index + 1) - 14;
|
||||
|
||||
if (value.substr(end, 14) === ' as HasCompact') {
|
||||
value = `Compact<${value.substr(index + 1, end - index - 1)}>`;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
}
|
||||
|
||||
function _flattenSingleTuple (): Mapper {
|
||||
return (value: string): string => {
|
||||
return value.replace(/\(([^,]*)\)/, '$1');
|
||||
};
|
||||
}
|
||||
|
||||
function _removeColonPrefix (): Mapper {
|
||||
return (value: string): string => {
|
||||
return value.replace(/^::/, '');
|
||||
};
|
||||
}
|
||||
|
||||
function _removeGenerics (): Mapper {
|
||||
return (value: string): string => {
|
||||
for (let index = 0; index < value.length; index++) {
|
||||
if (value[index] === '<') {
|
||||
// check against the allowed wrappers, be it Vec<..>, Option<...> ...
|
||||
const box = ALLOWED_BOXES.find((box): boolean => {
|
||||
const start = index - box.length;
|
||||
|
||||
return start >= 0 && value.substr(start, box.length) === box;
|
||||
});
|
||||
|
||||
// we have not found anything, unwrap generic innards
|
||||
if (!box) {
|
||||
const end = _findClosing(value, index + 1);
|
||||
|
||||
value = `${value.substr(0, index)}${value.substr(end + 1)}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
}
|
||||
|
||||
// remove the PairOf wrappers
|
||||
function _removePairOf (): Mapper {
|
||||
return (value: string): string => {
|
||||
for (let index = 0; index < value.length; index++) {
|
||||
if (value.substr(index, 7) === 'PairOf<') {
|
||||
const start = index + 7;
|
||||
const end = _findClosing(value, start);
|
||||
const type = value.substr(start, end - start);
|
||||
|
||||
value = `${value.substr(0, index)}(${type},${type})${value.substr(end + 1)}`;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
}
|
||||
|
||||
// remove the type traits
|
||||
function _removeTraits (): Mapper {
|
||||
return (value: string): string => {
|
||||
return value
|
||||
// remove all whitespaces
|
||||
.replace(/\s/g, '')
|
||||
// anything `T::<type>` to end up as `<type>`
|
||||
.replace(/T::/g, '')
|
||||
// anything `Self::<type>` to end up as `<type>`
|
||||
.replace(/Self::/g, '')
|
||||
// `system::` with `` - basically we find `<T as system::Trait>`
|
||||
.replace(/system::/g, '')
|
||||
// replace `<T as Trait>::` (whitespaces were removed above)
|
||||
.replace(/<TasTrait>::/g, '')
|
||||
// replace `<T as something::Trait>::` (whitespaces were removed above)
|
||||
.replace(/<Tas[a-z]+::Trait>::/g, '')
|
||||
// replace `<Self as Trait>::` (whitespaces were removed above)
|
||||
.replace(/<SelfasTrait>::/g, '')
|
||||
// replace <Lookup as StaticLookup>
|
||||
.replace(/<LookupasStaticLookup>/g, 'Lookup')
|
||||
// replace `<...>::Type`
|
||||
.replace(/::Type/g, '')
|
||||
// replace `wasm::*` eg. `wasm::PrefabWasmModule`
|
||||
.replace(/wasm::/g, '')
|
||||
// `sr_std::marker::`
|
||||
.replace(/sr_std::marker::/g, '');
|
||||
};
|
||||
}
|
||||
|
||||
// remove wrapping values, i.e. Box<Proposal> -> Proposal
|
||||
function _removeWrap (_check: string): Mapper {
|
||||
const check = `${_check}<`;
|
||||
|
||||
return (value: string): string => {
|
||||
let index = 0;
|
||||
|
||||
while (index !== -1) {
|
||||
index = value.indexOf(check);
|
||||
|
||||
if (index !== -1) {
|
||||
const start = index + check.length;
|
||||
const end = _findClosing(value, start);
|
||||
|
||||
value = `${value.substr(0, index)}${value.substr(start, end - start)}${value.substr(end + 1)}`;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
}
|
||||
|
||||
export default function santize (value: string): string {
|
||||
return mappings.reduce((result, fn): string => {
|
||||
return fn(result);
|
||||
}, value).trim();
|
||||
}
|
||||
@@ -6,11 +6,11 @@ import { Bytes, Data, Fixed64, H160, H256, H512, Null, StorageData, StorageHashe
|
||||
import { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, Consensus, ConsensusEngineId, Digest, DigestItem, Ed25519Signature, Extrinsic, ExtrinsicEra, ExtrinsicPayload, ExtrinsicPayloadUnknown, ExtrinsicPayloadV1, ExtrinsicPayloadV2, ExtrinsicPayloadV3, ExtrinsicUnknown, ExtrinsicV1, ExtrinsicV2, ExtrinsicV3, Hash, Header, ImmortalEra, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, Moment, MortalEra, Origin, Perbill, Permill, Phantom, PhantomData, PreRuntime, Seal, SealV0, Signature, SignedBlock, SignerPayload, Sr25519Signature, ValidatorId, Weight, WeightMultiplier } from './interfaces/runtime';
|
||||
import { InclusionHeight, Uncle, UncleEntryItem } from './interfaces/authorship';
|
||||
import { RawAuraPreDigest } from './interfaces/aura';
|
||||
import { BabeAuthorityWeight, BabeBlockWeight, BabeWeight, RawBabePreDigest, RawBabePreDigestPrimary, RawBabePreDigestSecondary, SlotNumber } from './interfaces/babe';
|
||||
import { BabeAuthorityWeight, BabeBlockWeight, BabeWeight, MaybeVrf, RawBabePreDigest, RawBabePreDigest0to159, RawBabePreDigestCompat, RawBabePreDigestPrimary, RawBabePreDigestPrimary0to159, RawBabePreDigestSecondary, RawBabePreDigestSecondary0to159, SlotNumber, VrfData, VrfProof } from './interfaces/babe';
|
||||
import { BalanceLock, VestingSchedule, WithdrawReasons } from './interfaces/balances';
|
||||
import { MemberCount, ProposalIndex, Votes } from './interfaces/collective';
|
||||
import { AuthorityId } from './interfaces/consensus';
|
||||
import { AliveContractInfo, CodeHash, ContractInfo, ContractStorageKey, Gas, PrefabWasmModule, PrefabWasmModuleReserved, Schedule, SeedOf, TombstoneContractInfo, TrieId } from './interfaces/contracts';
|
||||
import { AliveContractInfo, CodeHash, ContractCallRequest, ContractExecResult, ContractExecResultSuccess, ContractInfo, ContractStorageKey, Gas, PrefabWasmModule, PrefabWasmModuleReserved, Schedule, SeedOf, TombstoneContractInfo, TrieId } from './interfaces/contracts';
|
||||
import { Conviction, PropIndex, Proposal, ReferendumIndex, ReferendumInfo } from './interfaces/democracy';
|
||||
import { AccountInfo, Amount, AssetOf, InherentOfflineReport, LockPeriods, NewAccountOutcome, OpaqueKey, SessionKey } from './interfaces/deprecated';
|
||||
import { ApprovalFlag, SetIndex, Vote, VoteIndex, VoteThreshold, VoterInfo } from './interfaces/elections';
|
||||
@@ -26,7 +26,7 @@ import { BlockAttestations, IncludedBlocks, MoreAttestations } from './interface
|
||||
import { EcdsaSignature, EthereumAddress } from './interfaces/claims';
|
||||
import { AttestedCandidate, AuctionIndex, BalanceUpload, Bidder, CandidateReceipt, CollatorSignature, EgressQueueRoot, HeadData, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, LeasePeriod, LeasePeriodOf, NewBidder, ParaId, ParaIdOf, ParachainDispatchOrigin, SlotRange, SubId, UpwardMessage, ValidatorIndex, ValidityAttestation, ValidityVote, WinningData, WinningDataEntry } from './interfaces/parachains';
|
||||
import { CallMetadataV0, DoubleMapTypeV3, DoubleMapTypeV4, DoubleMapTypeV5, DoubleMapTypeV6, DoubleMapTypeV7, EventMetadataV0, EventMetadataV1, EventMetadataV2, EventMetadataV3, EventMetadataV4, EventMetadataV5, EventMetadataV6, EventMetadataV7, FunctionArgumentMetadataV0, FunctionArgumentMetadataV1, FunctionArgumentMetadataV2, FunctionArgumentMetadataV3, FunctionArgumentMetadataV4, FunctionArgumentMetadataV5, FunctionArgumentMetadataV6, FunctionArgumentMetadataV7, FunctionMetadataV0, FunctionMetadataV1, FunctionMetadataV2, FunctionMetadataV3, FunctionMetadataV4, FunctionMetadataV5, FunctionMetadataV6, FunctionMetadataV7, MapTypeV0, MapTypeV2, MapTypeV3, MapTypeV4, MapTypeV5, MapTypeV6, MapTypeV7, MetadataV0, MetadataV1, ModuleConstantMetadataV6, ModuleConstantMetadataV7, ModuleMetadataV0, ModuleMetadataV1, OuterDispatchCallV0, OuterDispatchMetadataV0, OuterEventEventMetadataEventsV0, OuterEventEventMetadataV0, OuterEventMetadataV0, PlainTypeV0, PlainTypeV2, PlainTypeV3, PlainTypeV4, PlainTypeV5, PlainTypeV6, PlainTypeV7, RuntimeModuleMetadataV0, StorageEntryModifierV6, StorageEntryModifierV7, StorageFunctionMetadataV0, StorageFunctionMetadataV1, StorageFunctionModifierV0, StorageFunctionModifierV1, StorageFunctionModifierV2, StorageFunctionModifierV3, StorageFunctionModifierV4, StorageFunctionModifierV5, StorageFunctionTypeV0, StorageFunctionTypeV1, StorageMetadataV0 } from './interfaces/metadata';
|
||||
import { ApiId, ChainProperties, ExtrinsicOrHash, ExtrinsicStatus, Health, KeyValueOption, NetworkState, PeerInfo, RuntimeVersion, RuntimeVersionApi, StorageChangeSet } from './interfaces/rpc';
|
||||
import { ApiId, ChainProperties, ExtrinsicOrHash, ExtrinsicStatus, Health, KeyValueOption, NetworkState, PeerInfo, RpcMethods, RuntimeVersion, RuntimeVersionApi, StorageChangeSet } from './interfaces/rpc';
|
||||
|
||||
export interface InterfaceRegistry {
|
||||
bool: bool;
|
||||
@@ -298,6 +298,9 @@ export interface InterfaceRegistry {
|
||||
'Compact<BabeBlockWeight>': Compact<BabeBlockWeight>;
|
||||
'Option<BabeBlockWeight>': Option<BabeBlockWeight>;
|
||||
'Vec<BabeBlockWeight>': Vec<BabeBlockWeight>;
|
||||
MaybeVrf: MaybeVrf;
|
||||
'Option<MaybeVrf>': Option<MaybeVrf>;
|
||||
'Vec<MaybeVrf>': Vec<MaybeVrf>;
|
||||
BabeWeight: BabeWeight;
|
||||
'Compact<BabeWeight>': Compact<BabeWeight>;
|
||||
'Option<BabeWeight>': Option<BabeWeight>;
|
||||
@@ -311,10 +314,28 @@ export interface InterfaceRegistry {
|
||||
RawBabePreDigestSecondary: RawBabePreDigestSecondary;
|
||||
'Option<RawBabePreDigestSecondary>': Option<RawBabePreDigestSecondary>;
|
||||
'Vec<RawBabePreDigestSecondary>': Vec<RawBabePreDigestSecondary>;
|
||||
RawBabePreDigest0to159: RawBabePreDigest0to159;
|
||||
'Option<RawBabePreDigest0to159>': Option<RawBabePreDigest0to159>;
|
||||
'Vec<RawBabePreDigest0to159>': Vec<RawBabePreDigest0to159>;
|
||||
RawBabePreDigestPrimary0to159: RawBabePreDigestPrimary0to159;
|
||||
'Option<RawBabePreDigestPrimary0to159>': Option<RawBabePreDigestPrimary0to159>;
|
||||
'Vec<RawBabePreDigestPrimary0to159>': Vec<RawBabePreDigestPrimary0to159>;
|
||||
RawBabePreDigestSecondary0to159: RawBabePreDigestSecondary0to159;
|
||||
'Option<RawBabePreDigestSecondary0to159>': Option<RawBabePreDigestSecondary0to159>;
|
||||
'Vec<RawBabePreDigestSecondary0to159>': Vec<RawBabePreDigestSecondary0to159>;
|
||||
RawBabePreDigestCompat: RawBabePreDigestCompat;
|
||||
'Option<RawBabePreDigestCompat>': Option<RawBabePreDigestCompat>;
|
||||
'Vec<RawBabePreDigestCompat>': Vec<RawBabePreDigestCompat>;
|
||||
SlotNumber: SlotNumber;
|
||||
'Compact<SlotNumber>': Compact<SlotNumber>;
|
||||
'Option<SlotNumber>': Option<SlotNumber>;
|
||||
'Vec<SlotNumber>': Vec<SlotNumber>;
|
||||
VrfData: VrfData;
|
||||
'Option<VrfData>': Option<VrfData>;
|
||||
'Vec<VrfData>': Vec<VrfData>;
|
||||
VrfProof: VrfProof;
|
||||
'Option<VrfProof>': Option<VrfProof>;
|
||||
'Vec<VrfProof>': Vec<VrfProof>;
|
||||
BalanceLock: BalanceLock;
|
||||
'Option<BalanceLock>': Option<BalanceLock>;
|
||||
'Vec<BalanceLock>': Vec<BalanceLock>;
|
||||
@@ -344,6 +365,15 @@ export interface InterfaceRegistry {
|
||||
CodeHash: CodeHash;
|
||||
'Option<CodeHash>': Option<CodeHash>;
|
||||
'Vec<CodeHash>': Vec<CodeHash>;
|
||||
ContractCallRequest: ContractCallRequest;
|
||||
'Option<ContractCallRequest>': Option<ContractCallRequest>;
|
||||
'Vec<ContractCallRequest>': Vec<ContractCallRequest>;
|
||||
ContractExecResultSuccess: ContractExecResultSuccess;
|
||||
'Option<ContractExecResultSuccess>': Option<ContractExecResultSuccess>;
|
||||
'Vec<ContractExecResultSuccess>': Vec<ContractExecResultSuccess>;
|
||||
ContractExecResult: ContractExecResult;
|
||||
'Option<ContractExecResult>': Option<ContractExecResult>;
|
||||
'Vec<ContractExecResult>': Vec<ContractExecResult>;
|
||||
ContractInfo: ContractInfo;
|
||||
'Option<ContractInfo>': Option<ContractInfo>;
|
||||
'Vec<ContractInfo>': Vec<ContractInfo>;
|
||||
@@ -929,6 +959,9 @@ export interface InterfaceRegistry {
|
||||
PeerInfo: PeerInfo;
|
||||
'Option<PeerInfo>': Option<PeerInfo>;
|
||||
'Vec<PeerInfo>': Vec<PeerInfo>;
|
||||
RpcMethods: RpcMethods;
|
||||
'Option<RpcMethods>': Option<RpcMethods>;
|
||||
'Vec<RpcMethods>': Vec<RpcMethods>;
|
||||
RuntimeVersionApi: RuntimeVersionApi;
|
||||
'Option<RuntimeVersionApi>': Option<RuntimeVersionApi>;
|
||||
'Vec<RuntimeVersionApi>': Vec<RuntimeVersionApi>;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
// Auto-generated via `yarn build:interfaces`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
|
||||
import { Codec } from '../../types';
|
||||
import { ITuple } from '../../types';
|
||||
import { Enum, Option } from '../../codec';
|
||||
import { AccountId, BlockNumber, Hash } from '../runtime';
|
||||
|
||||
/** BlockNumber */
|
||||
export type InclusionHeight = BlockNumber;
|
||||
export interface InclusionHeight extends BlockNumber {}
|
||||
|
||||
/** [Hash, Option<AccountId>] & Codec */
|
||||
export type Uncle = [Hash, Option<AccountId>] & Codec;
|
||||
/** ITuple<[Hash, Option<AccountId>]> */
|
||||
export interface Uncle extends ITuple<[Hash, Option<AccountId>]> {}
|
||||
|
||||
/** Enum */
|
||||
export interface UncleEntryItem extends Enum {
|
||||
|
||||
@@ -6,10 +6,12 @@ export default {
|
||||
types: {
|
||||
BabeAuthorityWeight: 'u64',
|
||||
BabeBlockWeight: 'u32',
|
||||
MaybeVrf: 'Option<VrfData>',
|
||||
// TODO Remove as soon as merged and metadata static updated
|
||||
BabeWeight: 'u64',
|
||||
RawBabePreDigest: {
|
||||
_enum: {
|
||||
Phantom: 'Null', // index starts at 1... empty slot at 0
|
||||
Primary: 'RawBabePreDigestPrimary',
|
||||
Secondary: 'RawBabePreDigestSecondary'
|
||||
}
|
||||
@@ -17,15 +19,44 @@ export default {
|
||||
RawBabePreDigestPrimary: {
|
||||
authorityIndex: 'u32', // AuthorityIndex (also in aura)
|
||||
slotNumber: 'SlotNumber',
|
||||
weight: 'BabeBlockWeight',
|
||||
vrfOutput: 'H256', // should be '[u8; 32]' (generator support lacking here)
|
||||
vrfProof: 'H256' // should be '[u8; 32]'
|
||||
vrfOutput: 'VrfData',
|
||||
vrfProof: 'VrfProof'
|
||||
},
|
||||
RawBabePreDigestSecondary: {
|
||||
authorityIndex: 'u32', // AuthorityIndex (also in aura)
|
||||
slotNumber: 'SlotNumber'
|
||||
},
|
||||
RawBabePreDigest0to159: {
|
||||
_enum: {
|
||||
Primary: 'RawBabePreDigestPrimary0to159',
|
||||
Secondary: 'RawBabePreDigestSecondary0to159'
|
||||
}
|
||||
},
|
||||
RawBabePreDigestPrimary0to159: {
|
||||
authorityIndex: 'u32',
|
||||
slotNumber: 'SlotNumber',
|
||||
weight: 'BabeBlockWeight',
|
||||
vrfOutput: 'VrfData',
|
||||
vrfProof: 'VrfProof'
|
||||
},
|
||||
RawBabePreDigestSecondary0to159: {
|
||||
authorityIndex: 'u32',
|
||||
slotNumber: 'SlotNumber',
|
||||
weight: 'BabeBlockWeight'
|
||||
},
|
||||
SlotNumber: 'u64'
|
||||
// a cross old/new compatible version of the digest, that is _only_ useful
|
||||
// for partial parsing and extraction of the author. This assumes that all
|
||||
// entries has the authorityIndex in the first position - and that it is all
|
||||
// we are interested in
|
||||
RawBabePreDigestCompat: {
|
||||
_enum: {
|
||||
Zero: 'u32',
|
||||
One: 'u32',
|
||||
Two: 'u32'
|
||||
}
|
||||
},
|
||||
SlotNumber: 'u64',
|
||||
VrfData: '[u8; 32]',
|
||||
VrfProof: '[u8; 64]'
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,42 +1,88 @@
|
||||
// Auto-generated via `yarn build:interfaces`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
|
||||
import { Enum, Struct } from '../../codec';
|
||||
import { H256, u32, u64 } from '../../primitive';
|
||||
import { Codec } from '../../types';
|
||||
import { Enum, Option, Struct } from '../../codec';
|
||||
import { u32, u64 } from '../../primitive';
|
||||
|
||||
/** u64 */
|
||||
export type BabeAuthorityWeight = u64;
|
||||
export interface BabeAuthorityWeight extends u64 {}
|
||||
|
||||
/** u32 */
|
||||
export type BabeBlockWeight = u32;
|
||||
export interface BabeBlockWeight extends u32 {}
|
||||
|
||||
/** u64 */
|
||||
export type BabeWeight = u64;
|
||||
export interface BabeWeight extends u64 {}
|
||||
|
||||
/** Option<VrfData> */
|
||||
export interface MaybeVrf extends Option<VrfData> {}
|
||||
|
||||
/** Enum */
|
||||
export interface RawBabePreDigest extends Enum {
|
||||
/** 0:: Primary(RawBabePreDigestPrimary) */
|
||||
/** 0:: Phantom */
|
||||
readonly isPhantom: boolean;
|
||||
/** 1:: Primary(RawBabePreDigestPrimary) */
|
||||
readonly isPrimary: boolean;
|
||||
/** RawBabePreDigestPrimary */
|
||||
readonly asPrimary: RawBabePreDigestPrimary;
|
||||
/** 1:: Secondary(RawBabePreDigestSecondary) */
|
||||
/** 2:: Secondary(RawBabePreDigestSecondary) */
|
||||
readonly isSecondary: boolean;
|
||||
/** RawBabePreDigestSecondary */
|
||||
readonly asSecondary: RawBabePreDigestSecondary;
|
||||
}
|
||||
|
||||
/** Enum */
|
||||
export interface RawBabePreDigest0to159 extends Enum {
|
||||
/** 0:: Primary(RawBabePreDigestPrimary0to159) */
|
||||
readonly isPrimary: boolean;
|
||||
/** RawBabePreDigestPrimary0to159 */
|
||||
readonly asPrimary: RawBabePreDigestPrimary0to159;
|
||||
/** 1:: Secondary(RawBabePreDigestSecondary0to159) */
|
||||
readonly isSecondary: boolean;
|
||||
/** RawBabePreDigestSecondary0to159 */
|
||||
readonly asSecondary: RawBabePreDigestSecondary0to159;
|
||||
}
|
||||
|
||||
/** Enum */
|
||||
export interface RawBabePreDigestCompat extends Enum {
|
||||
/** 0:: Zero(u32) */
|
||||
readonly isZero: boolean;
|
||||
/** u32 */
|
||||
readonly asZero: u32;
|
||||
/** 1:: One(u32) */
|
||||
readonly isOne: boolean;
|
||||
/** u32 */
|
||||
readonly asOne: u32;
|
||||
/** 2:: Two(u32) */
|
||||
readonly isTwo: boolean;
|
||||
/** u32 */
|
||||
readonly asTwo: u32;
|
||||
}
|
||||
|
||||
/** Struct */
|
||||
export interface RawBabePreDigestPrimary extends Struct {
|
||||
/** u32 */
|
||||
readonly authorityIndex: u32;
|
||||
/** SlotNumber */
|
||||
readonly slotNumber: SlotNumber;
|
||||
/** VrfData */
|
||||
readonly vrfOutput: VrfData;
|
||||
/** VrfProof */
|
||||
readonly vrfProof: VrfProof;
|
||||
}
|
||||
|
||||
/** Struct */
|
||||
export interface RawBabePreDigestPrimary0to159 extends Struct {
|
||||
/** u32 */
|
||||
readonly authorityIndex: u32;
|
||||
/** SlotNumber */
|
||||
readonly slotNumber: SlotNumber;
|
||||
/** BabeBlockWeight */
|
||||
readonly weight: BabeBlockWeight;
|
||||
/** H256 */
|
||||
readonly vrfOutput: H256;
|
||||
/** H256 */
|
||||
readonly vrfProof: H256;
|
||||
/** VrfData */
|
||||
readonly vrfOutput: VrfData;
|
||||
/** VrfProof */
|
||||
readonly vrfProof: VrfProof;
|
||||
}
|
||||
|
||||
/** Struct */
|
||||
@@ -45,9 +91,23 @@ export interface RawBabePreDigestSecondary extends Struct {
|
||||
readonly authorityIndex: u32;
|
||||
/** SlotNumber */
|
||||
readonly slotNumber: SlotNumber;
|
||||
}
|
||||
|
||||
/** Struct */
|
||||
export interface RawBabePreDigestSecondary0to159 extends Struct {
|
||||
/** u32 */
|
||||
readonly authorityIndex: u32;
|
||||
/** SlotNumber */
|
||||
readonly slotNumber: SlotNumber;
|
||||
/** BabeBlockWeight */
|
||||
readonly weight: BabeBlockWeight;
|
||||
}
|
||||
|
||||
/** u64 */
|
||||
export type SlotNumber = u64;
|
||||
export interface SlotNumber extends u64 {}
|
||||
|
||||
/** Uint8Array, Codec */
|
||||
export interface VrfData extends Uint8Array, Codec {}
|
||||
|
||||
/** Uint8Array, Codec */
|
||||
export interface VrfProof extends Uint8Array, Codec {}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
import { Codec } from '../../types';
|
||||
import { H160 } from '../../primitive';
|
||||
|
||||
/** Uint8Array & Codec */
|
||||
export type EcdsaSignature = Uint8Array & Codec;
|
||||
/** Uint8Array, Codec */
|
||||
export interface EcdsaSignature extends Uint8Array, Codec {}
|
||||
|
||||
/** H160 */
|
||||
export type EthereumAddress = H160;
|
||||
export interface EthereumAddress extends H160 {}
|
||||
|
||||
@@ -6,10 +6,10 @@ import { u32 } from '../../primitive';
|
||||
import { AccountId } from '../runtime';
|
||||
|
||||
/** u32 */
|
||||
export type MemberCount = u32;
|
||||
export interface MemberCount extends u32 {}
|
||||
|
||||
/** u32 */
|
||||
export type ProposalIndex = u32;
|
||||
export interface ProposalIndex extends u32 {}
|
||||
|
||||
/** Struct */
|
||||
export interface Votes extends Struct {
|
||||
|
||||
@@ -4,4 +4,4 @@
|
||||
import { AccountId } from '../runtime';
|
||||
|
||||
/** AccountId */
|
||||
export type AuthorityId = AccountId;
|
||||
export interface AuthorityId extends AccountId {}
|
||||
|
||||
@@ -13,6 +13,23 @@ export default {
|
||||
lastWrite: 'Option<BlockNumber>'
|
||||
},
|
||||
CodeHash: 'Hash',
|
||||
ContractCallRequest: {
|
||||
origin: 'AccountId',
|
||||
dest: 'AccountId',
|
||||
value: 'Balance',
|
||||
gasLimit: 'u64',
|
||||
inputData: 'Bytes'
|
||||
},
|
||||
ContractExecResultSuccess: {
|
||||
status: 'u8',
|
||||
data: 'Bytes'
|
||||
},
|
||||
ContractExecResult: {
|
||||
_enum: {
|
||||
Success: 'ContractExecResultSuccess',
|
||||
Error: 'Null'
|
||||
}
|
||||
},
|
||||
ContractInfo: {
|
||||
_enum: {
|
||||
Alive: 'AliveContractInfo',
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
import { Codec } from '../../types';
|
||||
import { Compact, Enum, Option, Struct } from '../../codec';
|
||||
import { Bytes, Null, bool, u32, u64 } from '../../primitive';
|
||||
import { Balance, BlockNumber, Hash } from '../runtime';
|
||||
import { Bytes, Null, bool, u32, u64, u8 } from '../../primitive';
|
||||
import { AccountId, Balance, BlockNumber, Hash } from '../runtime';
|
||||
|
||||
/** Struct */
|
||||
export interface AliveContractInfo extends Struct {
|
||||
@@ -23,7 +23,39 @@ export interface AliveContractInfo extends Struct {
|
||||
}
|
||||
|
||||
/** Hash */
|
||||
export type CodeHash = Hash;
|
||||
export interface CodeHash extends Hash {}
|
||||
|
||||
/** Struct */
|
||||
export interface ContractCallRequest extends Struct {
|
||||
/** AccountId */
|
||||
readonly origin: AccountId;
|
||||
/** AccountId */
|
||||
readonly dest: AccountId;
|
||||
/** Balance */
|
||||
readonly value: Balance;
|
||||
/** u64 */
|
||||
readonly gasLimit: u64;
|
||||
/** Bytes */
|
||||
readonly inputData: Bytes;
|
||||
}
|
||||
|
||||
/** Enum */
|
||||
export interface ContractExecResult extends Enum {
|
||||
/** 0:: Success(ContractExecResultSuccess) */
|
||||
readonly isSuccess: boolean;
|
||||
/** ContractExecResultSuccess */
|
||||
readonly asSuccess: ContractExecResultSuccess;
|
||||
/** 1:: Error */
|
||||
readonly isError: boolean;
|
||||
}
|
||||
|
||||
/** Struct */
|
||||
export interface ContractExecResultSuccess extends Struct {
|
||||
/** u8 */
|
||||
readonly status: u8;
|
||||
/** Bytes */
|
||||
readonly data: Bytes;
|
||||
}
|
||||
|
||||
/** Enum */
|
||||
export interface ContractInfo extends Enum {
|
||||
@@ -37,11 +69,11 @@ export interface ContractInfo extends Enum {
|
||||
readonly asTombstone: TombstoneContractInfo;
|
||||
}
|
||||
|
||||
/** Uint8Array & Codec */
|
||||
export type ContractStorageKey = Uint8Array & Codec;
|
||||
/** Uint8Array, Codec */
|
||||
export interface ContractStorageKey extends Uint8Array, Codec {}
|
||||
|
||||
/** u64 */
|
||||
export type Gas = u64;
|
||||
export interface Gas extends u64 {}
|
||||
|
||||
/** Struct */
|
||||
export interface PrefabWasmModule extends Struct {
|
||||
@@ -58,7 +90,7 @@ export interface PrefabWasmModule extends Struct {
|
||||
}
|
||||
|
||||
/** Option<Null> */
|
||||
export type PrefabWasmModuleReserved = Option<Null>;
|
||||
export interface PrefabWasmModuleReserved extends Option<Null> {}
|
||||
|
||||
/** Struct */
|
||||
export interface Schedule extends Struct {
|
||||
@@ -95,10 +127,10 @@ export interface Schedule extends Struct {
|
||||
}
|
||||
|
||||
/** Hash */
|
||||
export type SeedOf = Hash;
|
||||
export interface SeedOf extends Hash {}
|
||||
|
||||
/** Hash */
|
||||
export type TombstoneContractInfo = Hash;
|
||||
export interface TombstoneContractInfo extends Hash {}
|
||||
|
||||
/** Bytes */
|
||||
export type TrieId = Bytes;
|
||||
export interface TrieId extends Bytes {}
|
||||
|
||||
@@ -23,13 +23,13 @@ export interface Conviction extends Enum {
|
||||
}
|
||||
|
||||
/** u32 */
|
||||
export type PropIndex = u32;
|
||||
export interface PropIndex extends u32 {}
|
||||
|
||||
/** Call */
|
||||
export type Proposal = Call;
|
||||
export interface Proposal extends Call {}
|
||||
|
||||
/** u32 */
|
||||
export type ReferendumIndex = u32;
|
||||
export interface ReferendumIndex extends u32 {}
|
||||
|
||||
/** Struct */
|
||||
export interface ReferendumInfo extends Struct {
|
||||
|
||||
@@ -14,16 +14,16 @@ export interface AccountInfo extends Struct {
|
||||
}
|
||||
|
||||
/** Balance */
|
||||
export type Amount = Balance;
|
||||
export interface Amount extends Balance {}
|
||||
|
||||
/** u32 */
|
||||
export type AssetOf = u32;
|
||||
export interface AssetOf extends u32 {}
|
||||
|
||||
/** Null */
|
||||
export type InherentOfflineReport = Null;
|
||||
export interface InherentOfflineReport extends Null {}
|
||||
|
||||
/** i8 */
|
||||
export type LockPeriods = i8;
|
||||
export interface LockPeriods extends i8 {}
|
||||
|
||||
/** Enum */
|
||||
export interface NewAccountOutcome extends Enum {
|
||||
@@ -36,7 +36,7 @@ export interface NewAccountOutcome extends Enum {
|
||||
}
|
||||
|
||||
/** Bytes */
|
||||
export type OpaqueKey = Bytes;
|
||||
export interface OpaqueKey extends Bytes {}
|
||||
|
||||
/** AccountId */
|
||||
export type SessionKey = AccountId;
|
||||
export interface SessionKey extends AccountId {}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user