Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c8dd4be3b | ||
|
|
a339491d07 | ||
|
|
ea87472354 | ||
|
|
0ed156e5d9 | ||
|
|
59590540d8 | ||
|
|
c465252e69 | ||
|
|
0822d4d8c6 | ||
|
|
2c3eee4c67 | ||
|
|
b069710008 | ||
|
|
9a7e0bf82d | ||
|
|
4f520f5de6 | ||
|
|
79ee2ede3d | ||
|
|
f6b02e1de1 | ||
|
|
c11b0dffc5 | ||
|
|
0935c39906 | ||
|
|
ee622f3d2b | ||
|
|
ae350aae6f | ||
|
|
26c59f6d6e | ||
|
|
51c6262327 | ||
|
|
07ed405610 | ||
|
|
cd5d7b10c3 | ||
|
|
8e5b43bf62 | ||
|
|
49f3e36c46 | ||
|
|
7e25145fbf | ||
|
|
b5bc2ccfaf | ||
|
|
0e7c508d7f | ||
|
|
4e1c377ceb | ||
|
|
5c4920db6f | ||
|
|
679e31668e | ||
|
|
00e567b662 | ||
|
|
503193d6c2 | ||
|
|
5e82c97c8a | ||
|
|
8c12c227b4 | ||
|
|
d72456fb26 | ||
|
|
ca6d78e7ec | ||
|
|
8210c708ac | ||
|
|
41764562e1 | ||
|
|
66c8e5b4e8 | ||
|
|
ca7fe86089 | ||
|
|
cf2fbfce26 | ||
|
|
d69113ca5a | ||
|
|
d7eb40caf5 | ||
|
|
2eda438eac | ||
|
|
beddc3e0a5 | ||
|
|
ac1ae34e37 | ||
|
|
52953f248b | ||
|
|
e027f865aa | ||
|
|
d4e3e546dc | ||
|
|
6cb5476c80 | ||
|
|
52ffa175a9 | ||
|
|
ba2cd0cff5 | ||
|
|
fefcc2e0dc | ||
|
|
c8fbed2a12 | ||
|
|
6581d779c7 | ||
|
|
cab5b8bff7 | ||
|
|
480c0abda8 | ||
|
|
866c5769bb | ||
|
|
d8141198e1 | ||
|
|
a6a1a52d61 | ||
|
|
b6534d2958 | ||
|
|
3645cde156 | ||
|
|
2ac3640900 | ||
|
|
e379e7fabd | ||
|
|
69dae84a42 | ||
|
|
fe52484547 | ||
|
|
faa12a68f7 | ||
|
|
f6490217ec | ||
|
|
601cc62d70 | ||
|
|
201480be56 | ||
|
|
519823bc0e | ||
|
|
0b134c1eb8 | ||
|
|
e6e96aa9c9 | ||
|
|
84d0d8594e | ||
|
|
6be25966d8 | ||
|
|
a5eb11e5f3 | ||
|
|
19f87aac4d | ||
|
|
b217a59310 | ||
|
|
2de7a3c130 | ||
|
|
deecf4853e | ||
|
|
8889e69341 | ||
|
|
14194a363e | ||
|
|
9c50e81ab9 | ||
|
|
6505e73355 | ||
|
|
cefeb37ae6 | ||
|
|
9e29e89baf | ||
|
|
b82c90679d | ||
|
|
eeb8d20e58 | ||
|
|
b891edbd37 | ||
|
|
2ee3afcd61 | ||
|
|
328630fb17 | ||
|
|
325080cf71 | ||
|
|
549a536328 | ||
|
|
23f41a0bab | ||
|
|
5e0c0ba91a | ||
|
|
812a077e63 | ||
|
|
6ba28c8ad2 | ||
|
|
6cd0074ce4 | ||
|
|
b3d592357f | ||
|
|
f499946f1f | ||
|
|
56e28bed7f | ||
|
|
c76fb20a83 | ||
|
|
9d4b0ea56a | ||
|
|
f9d569ddd1 | ||
|
|
7221a3637c | ||
|
|
438c830366 | ||
|
|
3d0fd5a6a8 | ||
|
|
de57876c7f | ||
|
|
b24a1ff350 | ||
|
|
5f8c623179 | ||
|
|
00026a173f | ||
|
|
8da895efd4 | ||
|
|
89d029eca3 | ||
|
|
ac2a7eea67 | ||
|
|
4f0e573adf | ||
|
|
8417eff2b3 | ||
|
|
4aa5693906 | ||
|
|
982665c337 |
+1
-1
@@ -1 +1 @@
|
||||
17
|
||||
18
|
||||
|
||||
+1
-1
@@ -4,6 +4,6 @@ exclude_patterns:
|
||||
- "**/*.test.js"
|
||||
- "**/*.test.ts"
|
||||
- "docs/**/*.js"
|
||||
- "packages/api/src/query.types.ts"
|
||||
- "packages/api/src/types/augment/"
|
||||
- "packages/types/src/interfaces/"
|
||||
- "packages/types/src/scripts/"
|
||||
|
||||
@@ -29,7 +29,7 @@ jobs:
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
yarn install --frozen-lockfile
|
||||
yarn polkadot-dev-ghact-build
|
||||
yarn polkadot-ci-ghact-build
|
||||
|
||||
build_docs:
|
||||
name: Build Docs
|
||||
@@ -52,7 +52,7 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
yarn install --frozen-lockfile
|
||||
yarn polkadot-dev-ghact-docs
|
||||
yarn polkadot-ci-ghact-docs
|
||||
|
||||
dummy:
|
||||
name: Dummy
|
||||
|
||||
@@ -3,6 +3,7 @@ build/
|
||||
build-docs/
|
||||
coverage/
|
||||
docs/.vuepress/dist/
|
||||
docs/substrate/*.md
|
||||
node_modules/
|
||||
tmp/
|
||||
.DS_Store
|
||||
|
||||
+120
-47
@@ -1,22 +1,55 @@
|
||||
# 1.0.1
|
||||
# 1.2.1 Feb 16, 2020
|
||||
|
||||
- **Important** Update RPC status codes (latest Substrate 2), with the `isInBlock` (`isFinalized` now indicates finality)
|
||||
- Storage `.entries(arg?: any)` now has the correct argument type for DoubleMap (Thanks to https://github.com/monitz87)
|
||||
- Swap Kusama and Polkadot aliasses for `Address` to `AccountId` (future update)
|
||||
- Add `LookupSource` and `LookupTarget` types instead of mapping these directly for aliassing
|
||||
- Add `BitVec` type primitive
|
||||
- Add support for `system.account` for balance & nonce queries in derives as well as Submittables (Substrate composites)
|
||||
- Add `rpc.author.hasKey` and `rpc.author.hasSessinKeys` RPCs
|
||||
- Add derives for the parachains interfaces
|
||||
- Applied the latest types for Polkadot parachains
|
||||
- `registry.findMetaError` now can take in a `DispatchErrorModule` object for error lookups (from `asModule` in `DispatchError`)
|
||||
- Metadata now correctly serializes to the original input data via `toHex()` & `toU8a()`
|
||||
- Metadata dcocumentation generation rework, including the output of errors from metadata
|
||||
- Update all examples and comments to use latest `system.account` queries (instead of `system.accountNonce` and `balances.freeBalance`/`balances.reservedBalance`)
|
||||
- Cleanup `codec/Date` tests to make it run properly on all timezones
|
||||
- Add explicit dependencies to all packages and move TypeScript `@types/*` to dev deps
|
||||
|
||||
# 1.1.1 Feb 06, 2020
|
||||
|
||||
- **Important** Chains without `balances.account` or `system.account` should supply `"BalanceLock": "BalanceLockTo212"` to their types to use the previous-generation `BalanceLock` (when querying locks)
|
||||
- Add support for `balances.account` in all applicable derives (incl. `vesting` module)
|
||||
- Inject and use SignedExtensions by name from V11 metadata (V4 extrinsics only)
|
||||
- Add typings for `api.tx.*.*` - the `polkadot-types-from-chain` now also generates these
|
||||
- Remove additional V1-only derives `(staking.recentlyOffline`, `balances.nominatorsFor`)
|
||||
- Add `.isMax()` on int values, an opposite of `isZero()` (e.g. `u128`, as well as derived, e.g. `Balances`)
|
||||
- Add `.keyPrefix()` to all `api.query.*` complementing the `.key()` call, both returning a hex string
|
||||
- Council derives now takes bootstrapping (member, no elections) into account
|
||||
- Account derives now allow for an optional indices module (not required)
|
||||
- Adjust balances fees derivation with optional transfer and creation fees (removed in Substrate)
|
||||
- Adjust enum `.toJSON()` to return type name as specified
|
||||
|
||||
# 1.0.1 Jan 30, 2020
|
||||
|
||||
- **Breaking change** Drop support for Substrate v1 chain in all derives
|
||||
- Return unsub functions from provider .on emitters (Thanks to https://github.com/jak-pan)
|
||||
- `ApiPromise.isReady` now rejects on unrecoverable errors (Thanks to https://github.com/laec)
|
||||
- Add `polkadot-types-from-chain` & `polkadot-types-from-defs` TypeScript generators to `@polkadot/types`
|
||||
- Only decorate derives where relevant parent `api.query.*` is available
|
||||
- Support `.entries(arg?: any)` lookups on DoubleMaps (in addition to previously supported maps)
|
||||
- Remove un-deployed support for v11 metadata (this was decided against on Substrate)
|
||||
- Allow v9 metadata to parse even in cases where it was wrongly deployed pre-v10
|
||||
- Allow type-aliasses on a per-module basis (e.g. `Judgement` in identity as well as society)
|
||||
- Allow type-aliases on a per-module basis (e.g. `Judgement` in identity as well as society)
|
||||
- Allow passing `{ signer }` to both `api.tx.*` and `api.sign` (in addition to `api.setSigner`)
|
||||
- Add derives for the society module
|
||||
- Don't map empy tuples, e.. `()` to `Null`, rather keep them empty
|
||||
- Add lookups to the metadata erros via `findMetaError`
|
||||
- Update metadata and types for the lastest Substrate & Polkadot versions
|
||||
- Support metadata V11 as per lastest Substrate
|
||||
- Don't map empty tuples, e.g. `()` to `Null`, rather keep them empty
|
||||
- Add lookups to the metadata errors via `findMetaError`
|
||||
- Update metadata and types for the latest Substrate & Polkadot versions
|
||||
- Support metadata V11 as per latest Substrate
|
||||
- Remove support for un-deployed metadata
|
||||
- Remove old known types for Substrate V1
|
||||
|
||||
# 0.100.1
|
||||
# 0.100.1 Jan 13, 2020
|
||||
|
||||
- **Important** This will the the last API version with Substrate 1.x support. Although you will still be able to use subsequent versions with older chans, dependent libraries such as sr25519 may not be compatible.
|
||||
- Add support for the Substrate identity module
|
||||
@@ -27,7 +60,7 @@
|
||||
- Add support for latest Polkadot/Substrate types
|
||||
- Add `paymentInfo` to submittables to calculate fees
|
||||
|
||||
# 0.99.1
|
||||
# 0.99.1 Dec 13, 2019
|
||||
|
||||
- **Breaking change** The `Data` and `U8a` type has been renamed and just replaced with the `Raw` type
|
||||
- **Breaking change** The `api.derive.staking.info` has been split into 2 - `staking.query` for non-balance related information (more effective) and `staking.account` that enhances query for all the information previously found `.info`
|
||||
@@ -36,7 +69,7 @@
|
||||
- Add additional derives for both council & treasury
|
||||
- Alignment with latest Polkadot/Substrate master branch types
|
||||
|
||||
# 0.98.1
|
||||
# 0.98.1 Dec 04, 2019
|
||||
|
||||
- Make the TypeScript generation script mor re-usable (Thanks to https://github.com/xlc)
|
||||
- Add `.entries()` for all map-types, returning storage keys and values
|
||||
@@ -45,7 +78,7 @@
|
||||
- Support for new Substrate democracy with preimages in derive
|
||||
- Alignment of types with Substrate/Polkadot master branches
|
||||
|
||||
# 0.97.1
|
||||
# 0.97.1 Nov 29, 2019
|
||||
|
||||
- **Breaking change** Add the passing on an explicit `Registry` to all calls to `createType` as well as all codec classes. If you are upgrading form an older version, use the [migration guide](UPGRADING.md) to walk through the changes required.
|
||||
- **Breaking change** The metadata classes have been moved from `@polkadot/types` into `@polkadot/metadata`. If you explicitly create `Metadata` classes, you now would need to do so with the `import Metadata from '@polkadot/metadata';` This is a decorated class, where the previous metadata is now available on `Metadata.metadata`, alongside decorated `consts.*`', `tx.*` and `query.*`.
|
||||
@@ -57,7 +90,7 @@
|
||||
- Support for Metadata V9, which adjusts the hashing methods of storage entries
|
||||
- Support for Metadata V10 (still un-released), which includes prefixed map support
|
||||
|
||||
# 0.96.1
|
||||
# 0.96.1 Nov 09, 2019
|
||||
|
||||
- Updated types for latest Kusama
|
||||
- Add `filterRecords` (in addition to `findRecord`) on submittable results
|
||||
@@ -67,11 +100,11 @@
|
||||
- Update council derives for the latest Substrate master support (with constants)
|
||||
- Derive cleanups, including sharing of instances between the API and internal to derives
|
||||
|
||||
# 0.95.2
|
||||
# 0.95.2 Oct 25, 2019
|
||||
|
||||
- Temporary removal of `account_nextIndex` use, will be re-added in a future release
|
||||
|
||||
# 0.95.1
|
||||
# 0.95.1 Oct 25, 2019
|
||||
|
||||
- Support Extrinsic V4 with additional signature indicator (Latest Polkadot/Substrate/Kusama)
|
||||
- Adjust subscription update checks to avoid duplicated data updates
|
||||
@@ -81,7 +114,7 @@
|
||||
- All latest Polkadot & Substrate types (as per master branches)
|
||||
- **Breaking change** `Call.injectMethods` is moved to `Call.injectMetadata` to align with `Events` (This _should_ not be used externally, however mentioned as breaking here)
|
||||
|
||||
# 0.94.1
|
||||
# 0.94.1 Oct 07, 2019
|
||||
|
||||
- Add handling of `Result<Ok, Error>` definitions
|
||||
- Adjust API cloning now takes RPC filters from source into account
|
||||
@@ -93,7 +126,7 @@
|
||||
- Add documentation for custom extrinsic formats (advanced chains)
|
||||
- Update to latest substrate master metadata
|
||||
|
||||
# 0.93.1
|
||||
# 0.93.1 Sep 26, 2019
|
||||
|
||||
- Support for Kusama CC2
|
||||
- In extrinsic submission, use `rpc.account.nextIndex` to retrieve the nonce when available
|
||||
@@ -103,7 +136,7 @@
|
||||
- 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
|
||||
# 0.92.1 Sep 12, 2019
|
||||
|
||||
- The API now correctly sets the ss58 prefix as retrieved from the chain properties via `ss58Format`
|
||||
- Bump to `@polkadot/util` 1.4.1, removing use of `ExtError`
|
||||
@@ -111,7 +144,7 @@
|
||||
- Support the latest Polkadot & Substrate master branches (incl. metadata updates)
|
||||
- Getting started documentation has been made available
|
||||
|
||||
# 0.91.1
|
||||
# 0.91.1 Sep 09, 2019
|
||||
|
||||
- This release was focussed on stability, with a number of cleanups and bug-fixes
|
||||
- Adjustments for Substrate 1.x chain detection (with auto-types) and Substrate 2.x support has been extended with all latest types
|
||||
@@ -125,7 +158,7 @@
|
||||
- **Breaking change** `SignerPayload` is renamed to `SignerPayloadJSON`
|
||||
- **Breaking change** `SignerPayloadJSON`, `SignerPayloadRawBase` and `SignerPayloadRaw` are all moved to `@polkadot/types`
|
||||
|
||||
# 0.90.1
|
||||
# 0.90.1 Aug 24, 2019
|
||||
|
||||
If you are upgrading form an older version, use the CHANGELOG hand-in-hand with the [migration guide](UPGRADING.md).
|
||||
|
||||
@@ -143,7 +176,7 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
|
||||
- The `types/codec/createType` has been moved to `types/codec/create` with the same exports. If you explicitly imported from here (and not doing the suggested `import { createType } from '@polkadot/types`), the reference needs to be updated
|
||||
|
||||
|
||||
# 0.82.0-beta.x
|
||||
# 0.82.0-beta.x Jul 28, 2019
|
||||
|
||||
- Support for substrate 2.x (master) has been extended,
|
||||
- Additional types have been addedd for the modules
|
||||
@@ -162,7 +195,7 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
|
||||
- The `ContractsAbi` type has been moved from `@polkadot/types` to `import { Abi } from '@polkadot/api-contract`. This paves the way for an enhanced contracts interface, instead of dealing with low-level API calls.
|
||||
|
||||
|
||||
# 0.81.1
|
||||
# 0.81.1 Jun 14, 2019
|
||||
|
||||
- The dependency on `@polkadot/keyring` has been removed - if you relied on the API to provide this, you would now need to manually add it
|
||||
- `createType` allows for the creation of `[u8; <length>]` types (opening the door for contract support)
|
||||
@@ -182,7 +215,7 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
|
||||
- Add `off` method to `Api` (Base, for both `ApiPromise` & `ApiRx`) to remove an event listener
|
||||
|
||||
|
||||
# 0.80.1
|
||||
# 0.80.1 Jun 04, 2019
|
||||
|
||||
- Support for mortal transactions
|
||||
- Better DoubleMap storage support
|
||||
@@ -192,7 +225,7 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
|
||||
- Misc. cleanups and fixes
|
||||
|
||||
|
||||
# 0.79.1
|
||||
# 0.79.1 May 22, 2019
|
||||
|
||||
- DoubleMap query support
|
||||
- Support latest EventRecord metadata (substrate master)
|
||||
@@ -204,7 +237,7 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
|
||||
- Add `toRawType` on all type classes (breakdown into primitive types)
|
||||
|
||||
|
||||
# 0.78.1
|
||||
# 0.78.1 May 08, 2019
|
||||
|
||||
- Fix linked-maps (not working since 0.77.1)
|
||||
- Convert Usize to U32 (as found in WASM environments)
|
||||
@@ -215,13 +248,13 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
|
||||
- Metadata updates for substrate (WithdrawReasons, ContractInfo)
|
||||
|
||||
|
||||
# 0.77.1
|
||||
# 0.77.1 Apr 25, 2019
|
||||
|
||||
- Support Metadata v4, which introduces the use of a custom hasher to hash storage map keys.
|
||||
- Add TreasuryProposal (not the same as democracy, type aliased)
|
||||
|
||||
|
||||
# 0.76.1
|
||||
# 0.76.1 Apr 03, 2019
|
||||
|
||||
- Caching improvements (duplicate queries, no duplicate subscriptions)
|
||||
- Experimental contract API
|
||||
@@ -229,12 +262,12 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
|
||||
- Update @polkadot/util-crypto with smaller footprint
|
||||
|
||||
|
||||
# 0.75.1
|
||||
# 0.75.1 Mar 29, 2019
|
||||
|
||||
- Start journey to 1.0
|
||||
|
||||
|
||||
# 0.53.1
|
||||
# 0.53.1 Mar 29, 2019
|
||||
|
||||
- Change spelling to US English as per substrate master (1.0-rc1). Breaking changes as a result:
|
||||
- For extrinsic status results, if you have checked the type returns, i.e. `result.type === 'Finalised'` now check on the status for `result.status.isFinalized` or `result.status.isBroadcast`, ... (the `type` property is now accessible only on `result.status.type`)
|
||||
@@ -245,7 +278,7 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
|
||||
- All examples have been updated with sr25519 addresses (with the new checksums)
|
||||
|
||||
|
||||
# 0.52.1
|
||||
# 0.52.1 Mar 28, 2019
|
||||
|
||||
- Support queries to linked mapped storage (found in new staking interfaces)
|
||||
- Add `derive.staking.controllers` to retrieve all active staking controllers
|
||||
@@ -255,42 +288,42 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
|
||||
- Check for single instances for api and types as they are loaded (assertSingletonPackage)
|
||||
|
||||
|
||||
# 0.51.1
|
||||
# 0.51.1 Mar 25, 2019
|
||||
|
||||
- Support metadata V2 as per latest substrate master
|
||||
- Update metadata with new types as per latest substrate master
|
||||
|
||||
|
||||
# 0.50.1
|
||||
# 0.50.1 Mar 23, 2019
|
||||
|
||||
- Latest util-crypto (usage of WASM with JS fallbacks if not available)
|
||||
- Update upstream @polkadot dependencies (for new crypto)
|
||||
|
||||
|
||||
# 0.49.1
|
||||
# 0.49.1 Mar 20, 2019
|
||||
|
||||
- Fix large message signing on non-known nodes (default is now hashing, there has been enough time between upgrades)
|
||||
|
||||
|
||||
# 0.48.1
|
||||
# 0.48.1 Mar 18, 2019
|
||||
|
||||
- Pull in new sr25519 capable keyring for dev nodes
|
||||
- When using dev mode, it assumes that the node is the latest with derived sr25519 keys
|
||||
|
||||
|
||||
# 0.47.1
|
||||
# 0.47.1 Mar 14, 2019
|
||||
|
||||
- Swap to publishing -beta.x on merge (non-breaking testing)
|
||||
|
||||
|
||||
# 0.46.1
|
||||
# 0.46.1 Mar 01, 2019
|
||||
|
||||
- Extended type registration to now handle internal types as well. Additionally the built-in Extrinsic type can now we overridden with a custom version.
|
||||
- Where `Extrinsic` and `Method` is used as types, consider importing `{ IMethod, IExtrinsic }` from `@polkadot/types/types`, especially in the cases where this is used from a `SubmittableExtrinsic`
|
||||
- The `typeRegistry` constant is now `getTypeRegistry()` as a function
|
||||
|
||||
|
||||
# 0.45.1
|
||||
# 0.45.1 Feb 19, 2019
|
||||
|
||||
- Storage with option values now correctly return `Option<Type>` and is indicated as such in the documentation
|
||||
|
||||
@@ -307,7 +340,7 @@ console.log('llo', llo.unwrapOr('not set') /* Option<BlockNumber> */)
|
||||
```
|
||||
|
||||
|
||||
# 0.44.1
|
||||
# 0.44.1 Feb 19, 2019
|
||||
|
||||
- Split primitives and types into separate folders. This should not affect external use since the exports remain the same, however does have an impact where classes are referenced directly. e.g.
|
||||
|
||||
@@ -325,45 +358,45 @@ import { Method, Signature } from '@polkadot/types';
|
||||
```
|
||||
|
||||
|
||||
# 0.43.1
|
||||
# 0.43.1 Feb 14, 2019
|
||||
|
||||
- Introduces support for the new keyring with sr25519 support in addition to ed25519. While this does not change the exposed API, it is considered breaking since @polkadot/keyring has interface changes. (Unless needed, don't rush the upgrade)
|
||||
|
||||
|
||||
# 0.42.1
|
||||
# 0.42.1 Jan 31, 2019
|
||||
|
||||
- Support for substrate hash signing with implVersion >= 18
|
||||
- Changed signatures for Extrinsic signing, this should not have (much) of an impact since it is generally not used directly. SubmittableExtrinsic (as exposed by the API), supports the old-style use.
|
||||
|
||||
|
||||
# 0.41.1
|
||||
# 0.41.1 Jan 26, 2019
|
||||
|
||||
- Support the V1 metadata specification from Substrate in addition to the currently testnet active V0 version
|
||||
|
||||
|
||||
# 0.40.1
|
||||
# 0.40.1 Jan 16, 2019
|
||||
|
||||
- The API interfaces now require a WS-compatible provider, e.g. subscription support is a must. Previously the HTTPProvider could be use (although it was very limited in the interactions).
|
||||
|
||||
|
||||
# 0.39.1
|
||||
# 0.39.1 Jan 11, 2019
|
||||
|
||||
- The Promise API now returns a `Promise<UnsubFunction>` instead of `UnsubFunction` when making subscriptions.
|
||||
|
||||
|
||||
# 0.38.1
|
||||
# 0.38.1 Jan 08, 2019
|
||||
|
||||
Substrate has been updated with a breaking new transaction format where the Index/Nonce is now encoded as a Compact. This change is being rolled out to both Alexander (Polkadot testnet) as well as Charred Cherry (Substrate testnet) - transactions between old and new are not compatible.
|
||||
|
||||
|
||||
# 0.37.1
|
||||
# 0.37.1 Jan 04, 2019
|
||||
|
||||
api-observable has been removed. This was only used in /apps and inconsistent with the api/rx and api/promise APIs. Future work will include derives like was included in api-observable into the base.
|
||||
|
||||
Tuples now return single types when only one type is available, i.e. `(AccountId)` would now resolve as `AccountId`. The extra type wrapper adds no benefit to users here.
|
||||
|
||||
|
||||
# 0.36.1
|
||||
# 0.36.1 Jan 03, 2019
|
||||
|
||||
Api Promise has been updated in the way we deal with subscriptions. Previously a subscription returned `Promise<number>` where the caller was to keep track of the id and use it in subsequent unsubscribes. Now any subscriptions return an unsubscribe/destroy function `(): void`, that is use for removing the subscriptions, e.g.
|
||||
|
||||
@@ -374,11 +407,51 @@ unsubscribe(); // here we destroy the subscription
|
||||
```
|
||||
|
||||
|
||||
# 0.35.1
|
||||
# 0.35.1 Dec 20, 2018
|
||||
|
||||
Swapped to new metadata structures from Substrate. If the API is not working with your node, update Substrate to latest master branch. (Or 0.9.1 for Charred Cherry). Dropped support for old metadata as found as far back as BBQ Birch.
|
||||
|
||||
|
||||
# 0.34.1
|
||||
# 0.34.1 Dec 18, 2018
|
||||
|
||||
Changed the send signature (for future expansion of eg. events) to return `result: { status: ExtrinsicStatus }` instead of `status: ExtrinsicStatus`. For most cases where only status `type` checks are used, i.e. `status.type === 'Finalised'` this should not be a breaking change. Deep inspection of the status object however will need to adapt.
|
||||
|
||||
# 0.33.1 Dec 06, 2018
|
||||
|
||||
# 0.32.1 Nov 21, 2018
|
||||
|
||||
# 0.31.1 Oct 10, 2018
|
||||
|
||||
# 0.30.1 Sep 27, 2018
|
||||
|
||||
# 0.29.1 Sep 14, 2018
|
||||
|
||||
# 0.28.1 Aug 11, 2018
|
||||
|
||||
# 0.15.1 Aug 07, 2018
|
||||
|
||||
# 0.14.1 Jun 23, 2018
|
||||
|
||||
# 0.13.1 May 29, 2018
|
||||
|
||||
# 0.12.1 May 18, 2018
|
||||
|
||||
# 0.11.1 May 16, 2018
|
||||
|
||||
# 0.10.1 May 07, 2018
|
||||
|
||||
# 0.9.1 Apr 24, 2018
|
||||
|
||||
# 0.8.1 Mar 15, 2018
|
||||
|
||||
# 0.7.1 Jan 25, 2018
|
||||
|
||||
# 0.6.1 Dec 03, 2017
|
||||
|
||||
# 0.5.1 Nov 28, 2017
|
||||
|
||||
# 0.4.1 Nov 19, 2017
|
||||
|
||||
# 0.3.1 Nov 19, 2017
|
||||
|
||||
# 0.2.1 Nov 18, 2017
|
||||
|
||||
@@ -68,6 +68,7 @@ module.exports = {
|
||||
},
|
||||
{
|
||||
title: 'Substrate defaults',
|
||||
path: '/substrate/',
|
||||
collapsable: false,
|
||||
sidebarDepth: 0,
|
||||
children: [
|
||||
@@ -75,7 +76,8 @@ module.exports = {
|
||||
['substrate/constants.md', 'Constants'],
|
||||
['substrate/storage.md', 'State storage'],
|
||||
['substrate/extrinsics.md', 'Extrinsics'],
|
||||
['substrate/events.md', 'System events']
|
||||
['substrate/events.md', 'System events'],
|
||||
['substrate/errors.md', 'Errors']
|
||||
]
|
||||
},
|
||||
['/api/', '@polkadot/api'],
|
||||
|
||||
@@ -13,21 +13,23 @@ async function main () {
|
||||
|
||||
// Retrieve the initial balance. Since the call has no callback, it is simply a promise
|
||||
// that resolves to the current on-chain value
|
||||
let previous = await api.query.balances.freeBalance(Alice);
|
||||
let [previousNonce, { free: previousFree }] = await api.query.system.account(Alice);
|
||||
|
||||
console.log(`${Alice} has a balance of ${previous}`);
|
||||
console.log(`${Alice} has a balance of ${previousFree}, nonce ${previousNonce}`);
|
||||
console.log(`You may leave this example running and start example 06 or transfer any value to ${Alice}`);
|
||||
|
||||
// Here we subscribe to any balance changes and update the on-screen value
|
||||
api.query.balances.freeBalance(Alice, (current) => {
|
||||
api.query.system.account(Alice, ([currentNonce, { free: currentFree }]) => {
|
||||
// Calculate the delta
|
||||
const change = current.sub(previous);
|
||||
const change = currentFree.sub(previousFree);
|
||||
|
||||
// Only display positive value changes (Since we are pulling `previous` above already,
|
||||
// the initial balance change will also be zero)
|
||||
if (!change.isZero()) {
|
||||
previous = current;
|
||||
console.log(`New balance change of: ${change}`);
|
||||
console.log(`New balance change of ${change}, nonce ${currentNonce}`);
|
||||
|
||||
previousFree = currentFree;
|
||||
previousNonce = currentNonce;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ async function main () {
|
||||
console.log('Tracking balances for:', [ALICE, BOB]);
|
||||
|
||||
// Subscribe and listen to several balance changes
|
||||
api.query.balances.freeBalance.multi([ALICE, BOB], (balances) => {
|
||||
console.log('Change detected, new balances: ', balances);
|
||||
api.query.system.account.multi([ALICE, BOB], (balances) => {
|
||||
console.log('Change detected, new balances: ', balances.map(([, { free }]) => free));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ async function main () {
|
||||
const api = await ApiPromise.create();
|
||||
|
||||
// Make our basic chain state/storage queries, all in one go
|
||||
const [accountNonce, now, validators] = await Promise.all([
|
||||
api.query.system.accountNonce(ALICE),
|
||||
const [[accountNonce], now, validators] = await Promise.all([
|
||||
api.query.system.account(ALICE),
|
||||
api.query.timestamp.now(),
|
||||
api.query.session.validators()
|
||||
]);
|
||||
@@ -25,14 +25,15 @@ async function main () {
|
||||
// Retrieve the balances for all validators
|
||||
const validatorBalances = await Promise.all(
|
||||
validators.map(authorityId =>
|
||||
api.query.balances.freeBalance(authorityId)
|
||||
api.query.system.account(authorityId)
|
||||
)
|
||||
);
|
||||
|
||||
// Print out the authorityIds and balances of all validators
|
||||
console.log('validators', validators.map((authorityId, index) => ({
|
||||
address: authorityId.toString(),
|
||||
balance: validatorBalances[index].toString()
|
||||
balance: validatorBalances[index][1].free.toString(),
|
||||
nonce: validatorBalances[index][0].toString()
|
||||
})));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,14 +19,14 @@ async function main () {
|
||||
|
||||
// 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);
|
||||
const balance = await api.query.system.account.at(parentHash, ALICE);
|
||||
|
||||
console.log(`Alice's balance at ${parentHash.toHex()} was ${balance}`);
|
||||
console.log(`Alice's balance at ${parentHash.toHex()} was ${balance[1].free}`);
|
||||
|
||||
// Now perform a multi query, returning multiple balances at once
|
||||
const balances = await api.query.balances.freeBalance.multi([ALICE, BOB]);
|
||||
const balances = await api.query.system.account.multi([ALICE, BOB]);
|
||||
|
||||
console.log(`Current balances for Alice and Bob are ${balances[0]} and ${balances[1]}`);
|
||||
console.log(`Current balances for Alice and Bob are ${balances[0][1].free} and ${balances[1][1].free}`);
|
||||
}
|
||||
|
||||
main().catch(console.error).finally(() => process.exit());
|
||||
|
||||
@@ -19,7 +19,7 @@ async function main () {
|
||||
const alice = keyring.addFromUri('//Alice');
|
||||
|
||||
// Get nonce for account
|
||||
const nonce = await api.query.system.accountNonce(alice.address);
|
||||
const [nonce] = await api.query.system.account(alice.address);
|
||||
|
||||
// Get current block
|
||||
const signedBlock = await api.rpc.chain.getBlock();
|
||||
|
||||
@@ -24,7 +24,7 @@ async function main () {
|
||||
const keyring = testKeyring.default();
|
||||
|
||||
// Get the nonce for the admin key
|
||||
const nonce = await api.query.system.accountNonce(ALICE);
|
||||
const [nonce] = await api.query.system.account(ALICE);
|
||||
|
||||
// Find the actual keypair in the keyring
|
||||
const alicePair = keyring.getPair(ALICE);
|
||||
|
||||
@@ -14,7 +14,7 @@ async function main () {
|
||||
|
||||
// Here we subscribe to any balance changes and update the on-screen value.
|
||||
// We're using RxJs pairwise() operator to get the previous and current values as an array.
|
||||
api.query.balances.freeBalance(Alice)
|
||||
api.query.system.account(Alice)
|
||||
.pipe(
|
||||
// since pairwise only starts emitting values on the second emission, we prepend an
|
||||
// initial value with the startWith() operator to be able to also receive the first value
|
||||
@@ -25,12 +25,13 @@ async function main () {
|
||||
if (balance[0] === 'first') {
|
||||
// Now we know that if the previous value emitted as balance[0] is `first`,
|
||||
// then balance[1] is the initial value of Alice account.
|
||||
console.log(`Alice ${Alice} has a balance of ${balance[1]}`);
|
||||
console.log(`Alice ${Alice} has a balance of ${balance[1][1].free}`);
|
||||
console.log('You may leave this example running and start the "Make a transfer" example or transfer any value to Alice address');
|
||||
return;
|
||||
}
|
||||
|
||||
const change = balance[1].sub(balance[0]);
|
||||
const change = balance[1][1].free.sub(balance[0][1].free);
|
||||
|
||||
// Only display value changes
|
||||
if (!change.isZero()) {
|
||||
console.log(`New balance change of: ${change}`);
|
||||
|
||||
@@ -22,13 +22,13 @@ function main () {
|
||||
// In the next step, we're checking if the node has active validators.
|
||||
// If it does, we're making another call to the api to get the balances for all validators
|
||||
const balances = (validators && validators.length > 0)
|
||||
? combineLatest(validators.map(authorityId => api.query.balances.freeBalance(authorityId).pipe(first())))
|
||||
? combineLatest(validators.map(authorityId => api.query.system.account(authorityId).pipe(first())))
|
||||
: of(null);
|
||||
|
||||
// We're combining the results together with the emitted value 'validators',
|
||||
// which we're turning back into an observable using of()
|
||||
return combineLatest(
|
||||
api.query.system.accountNonce(Alice).pipe(first()),
|
||||
api.query.system.account(Alice).pipe(first()),
|
||||
api.query.timestamp.blockPeriod().pipe(first()),
|
||||
of(validators),
|
||||
balances
|
||||
@@ -36,7 +36,7 @@ function main () {
|
||||
})
|
||||
)
|
||||
// Then we're subscribing to the emitted results
|
||||
.subscribe(([accountNonce, blockPeriod, validators, validatorBalances]) => {
|
||||
.subscribe(([[accountNonce], blockPeriod, validators, validatorBalances]) => {
|
||||
console.log(`accountNonce(${Alice}) ${accountNonce}`);
|
||||
console.log(`blockPeriod ${blockPeriod.toNumber()} seconds`);
|
||||
|
||||
@@ -44,7 +44,8 @@ function main () {
|
||||
// And lastly we print out the authorityIds and balances of all validators
|
||||
console.log('validators', validators.map((authorityId, index) => ({
|
||||
address: authorityId.toString(),
|
||||
balance: validatorBalances[index].toString()
|
||||
balance: validatorBalances[index][1].free.toString(),
|
||||
nonce: validatorBalances[index][0].toString()
|
||||
})));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -33,3 +33,9 @@ Tuples, as defined in the Polkadot/Substrate types appear as `(TypeA, TypeB)`. F
|
||||
Polkadot/Substrate supports both immortal and mortal transactions. For immortal, this means that the transaction has an infinite lifetime, for mortals, the transactions expire after a defined period. By default the API sends mortal transactions when no explicit extrinsic era has been specified. This means that all transaction has a limited lifetime and will expire if not included in the period set.
|
||||
|
||||
The length for this transaction validity is set to 50 blocks, which translates to 5 minutes assuming a default of 6 second blocktimes. (10 blocks per minute in this default configuration).
|
||||
|
||||
## My chain does not support system.account queries
|
||||
|
||||
The API always tracks the latest Substrate master in terms of examples. This means that nonce & balance queries are done via the `api.query.system.account(<account>)` which returns a Tuple `(Index, AccountData)` where the first is the nonce, the second a struct containing the free and reserved balances. As with all `api.query.*` endpoint, this is decorated based on what the chain you connect to support.
|
||||
|
||||
It is possible that you are connecting to an older chain that has not been upgraded yet. For these chains, this storage entry won't be available (yet). To query the nonce on older chains, you can do a query to `api.query.system.accountNonce(<account>)` and balances can be retrieved via `api.query.balances.freeBalance(<account>)`.
|
||||
|
||||
+6
-10
@@ -16,24 +16,20 @@ const ADDR = '5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFabHE';
|
||||
// Retrieve the last timestamp
|
||||
const now = await api.query.timestamp.now();
|
||||
|
||||
// Retrieve the account nonce via the system module
|
||||
const nonce = await api.query.system.accountNonce(ADDR);
|
||||
// Retrieve the account balance & nonce via the system module
|
||||
const [nonce, balance] = await api.query.system.account(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}`);
|
||||
console.log(`${now}: balance of ${balance.free} and a nonce of ${nonce}`);
|
||||
```
|
||||
|
||||
There have been some additions in the code above comparing with retrieving runtime constants. In these cases, since we are making a query to the actual chain, we use the `await` syntax to retrieve the information. Since the API is Promise-based, this means we can also rewrite the above to follow a Promise pattern,
|
||||
|
||||
```js
|
||||
...
|
||||
// Retrieve last block timestamp, account nonce & balance
|
||||
const [now, nonce, balance] = await Promise.all([
|
||||
// Retrieve last block timestamp, account nonce & balances
|
||||
const [now, [nonce, balances]] = await Promise.all([
|
||||
api.query.timestamp.now(),
|
||||
api.query.system.accountNonce(ADDR),
|
||||
api.query.balances.freeBalance(ADDR)
|
||||
api.query.system.account(ADDR)
|
||||
]);
|
||||
```
|
||||
|
||||
|
||||
@@ -10,14 +10,14 @@ Where possible, the use of multi queries are encouraged since it tracks a number
|
||||
...
|
||||
|
||||
// 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;
|
||||
const unsub = await api.query.system.account.multi([ADDR1, ADDR2], (balances) => {
|
||||
const [[, balance1], [, balance2]] = balances;
|
||||
|
||||
console.log(`The balances are ${balance1} and ${balance2}`);
|
||||
console.log(`The balances are ${balance1.free} and ${balance2.free}`);
|
||||
});
|
||||
```
|
||||
|
||||
A couple of items to note in the example above: we don't call `freeBalance` directly, but rather `freeBalance.multi`. We pass the addresses we want to query as an array, and the length thereof would depend on the number of addresses we want to query. As an extended example, we can track the balances of a list of validators,
|
||||
A couple of items to note in the example above: we don't call `account` directly, but rather `account.multi`. We pass the addresses we want to query as an array, and the length thereof would depend on the number of addresses we want to query. As an extended example, we can track the balances of a list of validators,
|
||||
|
||||
```js
|
||||
...
|
||||
@@ -26,8 +26,8 @@ A couple of items to note in the example above: we don't call `freeBalance` dire
|
||||
const validators = await api.query.session.validators();
|
||||
|
||||
// Subscribe to the balances for these accounts
|
||||
const unsub = await api.query.balances.freeBalance.multi(validators, (balances) => {
|
||||
console.log(`The balances are: ${balances}`);
|
||||
const unsub = await api.query.balances.account.multi(validators, (balances) => {
|
||||
console.log(`The nonce and free balances are: ${balances.map(([nonce, { free }]) => [nonce, free])}`);
|
||||
});
|
||||
```
|
||||
|
||||
@@ -43,17 +43,16 @@ The previous `.multi` examples assumes that we do queries for the same types, i.
|
||||
// Subscribe to the timestamp, our index and balance
|
||||
const unsub = await api.queryMulti([
|
||||
api.query.timestamp.now,
|
||||
[api.query.system.accountNonce, ADDR],
|
||||
[api.query.balances.freeBalance, ADDR]
|
||||
], ([now, nonce, balance]) => {
|
||||
console.log(`${now}: balance of ${balance} and a nonce of ${nonce}`);
|
||||
[api.query.system.account, ADDR]
|
||||
], ([now, [nonce, balance]]) => {
|
||||
console.log(`${now}: balance of ${balance.free} and a nonce of ${nonce}`);
|
||||
});
|
||||
```
|
||||
|
||||
The above example certainly does not quite look as ergonomic and clean, but the API needs to understand (a) which are all the calls we need to make and (b) the calls and their params (if required). So breaking it down -
|
||||
|
||||
- `api.query.timestamp.now` - the timestamp is passed naked without any params. Also note that we do not call it while passing, but rather only provides a reference to the function, i.e. we do not have the expected `()` at the end. (This could also be of the form `[api.query.timestamp.now]`, aligning with subsequent entries)
|
||||
- `[api.query.system.accountNonce, ADDR]` - the nonce query is passed as an array containing the function (once again naked), followed by the parameters that apply.
|
||||
- `[api.query.system.account, ADDR]` - the nonce & balance query is passed as an array containing the function (once again naked), followed by the parameters that apply.
|
||||
|
||||
## Rounding out queries
|
||||
|
||||
|
||||
@@ -13,13 +13,13 @@ Quite often is is useful (taking pruning into account, more on this later) to re
|
||||
const lastHdr = await api.rpc.chain.getHeader();
|
||||
|
||||
// Retrieve the balance at both the current and the parent hashes
|
||||
const [balanceNow, balancePrev] = await Promise.all([
|
||||
api.query.balances.freeBalance.at(lastHdr.hash, ADDR),
|
||||
api.query.balances.freeBalance.at(lastHdr.parentHash, ADDR)
|
||||
const [[, balanceNow], [, balancePrev]] = await Promise.all([
|
||||
api.query.system.account.at(lastHdr.hash, ADDR),
|
||||
api.query.system.account.at(lastHdr.parentHash, ADDR)
|
||||
]);
|
||||
|
||||
// Display the difference
|
||||
console.log(`The delta was ${balanceNow.sub(balancePrev)}`);
|
||||
console.log(`The delta was ${balanceNow.free.sub(balancePrev.free)}`);
|
||||
```
|
||||
|
||||
In the above example, we introduce the `.at(<hash>[, ...params])` query. For all `.at` queries, the first parameter is always the block hash at which we want to make the query, in our example we use both the last retrieved block and the parent thereof. The params are optional as per the type of query made, for instance to retrieve the timestamp for a previous block, it would be -
|
||||
@@ -44,8 +44,8 @@ In addition to using `api.query` to make actual on-chain queries, it can also be
|
||||
|
||||
// Retrieve the hash & size of the entry as stored on-chain
|
||||
const [entryHash, entrySize] = await Promise.all([
|
||||
api.query.balances.freeBalance.hash(ADDR),
|
||||
api.query.balances.freeBalance.size(ADDR)
|
||||
api.query.system.account.hash(ADDR),
|
||||
api.query.system.account.size(ADDR)
|
||||
]);
|
||||
|
||||
// Output the info
|
||||
@@ -60,11 +60,11 @@ It has been explained that the `api.query` interfaces are decorated from the met
|
||||
|
||||
```js
|
||||
// Extract the info
|
||||
const { meta, method, section } = api.query.balances.freeBalance;
|
||||
const { meta, method, section } = api.query.system.account;
|
||||
|
||||
// Display some info on a specific entry
|
||||
console.log(`${section}.${method}: ${meta.documentation.join(' ')}`);
|
||||
console.log(`query key: ${api.query.balances.freeBalance.key(ADDR)}`);
|
||||
console.log(`query key: ${api.query.system.account.key(ADDR)}`);
|
||||
```
|
||||
|
||||
The `section` & `method` is an indication of where it is exposed on the API. In addition the `meta` holds an array with the metadata documentation for the entry.
|
||||
|
||||
@@ -25,8 +25,8 @@ If we had a query with parameters, i.e. where we wish to perform a query for a s
|
||||
...
|
||||
|
||||
// Subscribe to balance changes for our account
|
||||
const unsub = await api.query.balances.freeBalance(ADDR, (balance) => {
|
||||
console.log(`Your account balance is ${balance}`);
|
||||
const unsub = await api.query.system.account(ADDR, ([nonce, balance]) => {
|
||||
console.log(`free balance is ${balance.freee} with ${balance.reserved} reserved and a nonce of ${nonce}`);
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ To unpack this, we will start with the Metadata and explain what it actually pro
|
||||
|
||||
When the API connects to a node, one of the first things it does is to retrieve the metadata. The metadata, effectively provides data in the form of `api.<type>.<module>.<section>` that fits into one of the following categories -
|
||||
|
||||
- [consts](../substrate/constants.md) - All runtime constants, e.g. `api.consts.balances.creationFee`. These are not functions, rather accessing the endpoint immediately yields the result as defined.
|
||||
- [query](../substrate/storage.md) - All chain state, e.g. `api.query.balances.freeBalance(<accountId>)`.
|
||||
- [consts](../substrate/constants.md) - All runtime constants, e.g. `api.consts.balances.existentialDeposit`. These are not functions, rather accessing the endpoint immediately yields the result as defined.
|
||||
- [query](../substrate/storage.md) - All chain state, e.g. `api.query.system.account(<accountId>)`.
|
||||
- [tx](../substrate/extrinsics.md) - All extrinsics, e.g. `api.tx.balances.transfer(<accountId>, <value>)`.
|
||||
|
||||
Additionally the metadata also provides information on [events](../substrate/events.md), these are query-able via the `api.query.system.events()` interface and also appear on transactions... both these cases are detailed later.
|
||||
|
||||
@@ -30,11 +30,10 @@ For any interface injected by metadata, the types are not available by default (
|
||||
However, to make this sane from a developer perspective the injected methods are generic, effectively making the following possible -
|
||||
|
||||
```js
|
||||
import { Balance, Index } from '@polkadot/types/interfaces';
|
||||
import { AccountData, Index } from '@polkadot/types/interfaces';
|
||||
|
||||
...
|
||||
const nonce = await api.query.system.accountNonce<Index>(ADDR);
|
||||
const balance = await api.query.balances.freeBalance<Balance>(ADDR);
|
||||
const [nonce, balance] = await api.query.system.account<[Index, AccountData]>(ADDR);
|
||||
```
|
||||
|
||||
In both these case we can instruct the TypeScript compiler that the type we are expecting in `Index` and `Balance` respectively, not just pure `Codec`. This means that functions like `.toNumber()` is available on both these types - as opposed to just the [general type defaults](types.basics.md#everything-is-a-type) with `.toHex()` and friends.
|
||||
|
||||
@@ -1,225 +0,0 @@
|
||||
## Constants
|
||||
|
||||
The following sections contain the module constants, also known as parameter types. These can only be changed as part of a runtime upgrade. On the api, these are exposed via `api.consts.<module>.<method>`.
|
||||
|
||||
(NOTE: These were generated from a static/snapshot view of a recent Substrate master node. Some items may not be available in older nodes, or in any customized implementations.)
|
||||
- **[babe](#babe)**
|
||||
|
||||
- **[balances](#balances)**
|
||||
|
||||
- **[contracts](#contracts)**
|
||||
|
||||
- **[democracy](#democracy)**
|
||||
|
||||
- **[elections](#elections)**
|
||||
|
||||
- **[finalityTracker](#finalityTracker)**
|
||||
|
||||
- **[session](#session)**
|
||||
|
||||
- **[staking](#staking)**
|
||||
|
||||
- **[timestamp](#timestamp)**
|
||||
|
||||
- **[treasury](#treasury)**
|
||||
|
||||
|
||||
___
|
||||
|
||||
|
||||
### babe
|
||||
|
||||
▸ **epochDuration**: `u64`
|
||||
- **summary**: The number of **slots** that an epoch takes. We couple sessions to epochs, i.e. we start a new session once the new epoch begins.
|
||||
|
||||
▸ **expectedBlockTime**: `Moment`
|
||||
- **summary**: The expected average block time at which BABE should be creating blocks. Since BABE is probabilistic it is not trivial to figure out what the expected average block time should be based on the slot duration and the security parameter `c` (where `1 - c` represents the probability of a slot being empty).
|
||||
|
||||
___
|
||||
|
||||
|
||||
### balances
|
||||
|
||||
▸ **creationFee**: `Balance`
|
||||
- **summary**: The fee required to create an account.
|
||||
|
||||
▸ **existentialDeposit**: `Balance`
|
||||
- **summary**: The minimum amount required to keep an account open.
|
||||
|
||||
▸ **transactionBaseFee**: `Balance`
|
||||
- **summary**: The fee to be paid for making a transaction; the base.
|
||||
|
||||
▸ **transactionByteFee**: `Balance`
|
||||
- **summary**: The fee to be paid for making a transaction; the per-byte portion.
|
||||
|
||||
▸ **transferFee**: `Balance`
|
||||
- **summary**: The fee required to make a transfer.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### contracts
|
||||
|
||||
▸ **blockGasLimit**: `Gas`
|
||||
- **summary**: The maximum amount of gas that could be expended per block. A reasonable default value is 10_000_000.
|
||||
|
||||
▸ **callBaseFee**: `Gas`
|
||||
- **summary**: The base fee charged for calling into a contract. A reasonable default value is 135.
|
||||
|
||||
▸ **contractFee**: `BalanceOf`
|
||||
- **summary**: The fee required to instantiate a contract instance. A reasonable default value is 21.
|
||||
|
||||
▸ **creationFee**: `BalanceOf`
|
||||
- **summary**: The fee required to create an account.
|
||||
|
||||
▸ **instantiateBaseFee**: `Gas`
|
||||
- **summary**: The base fee charged for instantiating a contract. A reasonable default value is 175.
|
||||
|
||||
▸ **maxDepth**: `u32`
|
||||
- **summary**: The maximum nesting level of a call/instantiate stack. A reasonable default value is 100.
|
||||
|
||||
▸ **maxValueSize**: `u32`
|
||||
- **summary**: The maximum size of a storage value in bytes. A reasonable default is 16 KiB.
|
||||
|
||||
▸ **rentByteFee**: `BalanceOf`
|
||||
- **summary**: Price of a byte of storage per one block interval. Should be greater than 0.
|
||||
|
||||
▸ **rentDepositOffset**: `BalanceOf`
|
||||
- **summary**: The amount of funds a contract should deposit in order to offset the cost of one byte. Let's suppose the deposit is 1,000 BU (balance units)/byte and the rent is 1 BU/byte/day, then a contract with 1,000,000 BU that uses 1,000 bytes of storage would pay no rent. But if the balance reduced to 500,000 BU and the storage stayed the same at 1,000, then it would pay 500 BU/day.
|
||||
|
||||
▸ **signedClaimHandicap**: `BlockNumber`
|
||||
- **summary**: Number of block delay an extrinsic claim surcharge has. When claim surcharge is called by an extrinsic the rent is checked for current_block - delay
|
||||
|
||||
▸ **storageSizeOffset**: `u32`
|
||||
- **summary**: Size of a contract at the time of instantiaion. This is a simple way to ensure that empty contracts eventually gets deleted.
|
||||
|
||||
▸ **surchargeReward**: `BalanceOf`
|
||||
- **summary**: Reward that is received by the party whose touch has led to removal of a contract.
|
||||
|
||||
▸ **tombstoneDeposit**: `BalanceOf`
|
||||
- **summary**: The minimum amount required to generate a tombstone.
|
||||
|
||||
▸ **transactionBaseFee**: `BalanceOf`
|
||||
- **summary**: The fee to be paid for making a transaction; the base.
|
||||
|
||||
▸ **transactionByteFee**: `BalanceOf`
|
||||
- **summary**: The fee to be paid for making a transaction; the per-byte portion.
|
||||
|
||||
▸ **transferFee**: `BalanceOf`
|
||||
- **summary**: The fee required to make a transfer.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### democracy
|
||||
|
||||
▸ **cooloffPeriod**: `BlockNumber`
|
||||
- **summary**: Period in blocks where an external proposal may not be re-submitted after being vetoed.
|
||||
|
||||
▸ **emergencyVotingPeriod**: `BlockNumber`
|
||||
- **summary**: Minimum voting period allowed for an emergency referendum.
|
||||
|
||||
▸ **enactmentPeriod**: `BlockNumber`
|
||||
- **summary**: The minimum period of locking and the period between a proposal being approved and enacted. It should generally be a little more than the unstake period to ensure that voting stakers have an opportunity to remove themselves from the system in the case where they are on the losing side of a vote.
|
||||
|
||||
▸ **launchPeriod**: `BlockNumber`
|
||||
- **summary**: How often (in blocks) new public referenda are launched.
|
||||
|
||||
▸ **minimumDeposit**: `BalanceOf`
|
||||
- **summary**: The minimum amount to be used as a deposit for a public referendum proposal.
|
||||
|
||||
▸ **votingPeriod**: `BlockNumber`
|
||||
- **summary**: How often (in blocks) to check for new votes.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### elections
|
||||
|
||||
▸ **approvalSetSize**: `u32`
|
||||
- **summary**: The chunk size of the approval vector.
|
||||
|
||||
▸ **candidacyBond**: `BalanceOf`
|
||||
- **summary**: How much should be locked up in order to submit one's candidacy. A reasonable default value is 9.
|
||||
|
||||
▸ **carryCount**: `u32`
|
||||
- **summary**: How many runners-up should have their approvals persist until the next vote. A reasonable default value is 2.
|
||||
|
||||
▸ **decayRatio**: `u32`
|
||||
- **summary**: Decay factor of weight when being accumulated. It should typically be set to __at least__ `membership_size -1` to keep the collective secure. When set to `N`, it indicates `(1/N)^t` of staked is decayed at weight increment step `t`. 0 will result in no weight being added at all (normal approval voting). A reasonable default value is 24.
|
||||
|
||||
▸ **inactiveGracePeriod**: `VoteIndex`
|
||||
- **summary**: How many vote indices need to go by after a target voter's last vote before they can be reaped if their approvals are moot. A reasonable default value is 1.
|
||||
|
||||
▸ **minimumVotingLock**: `BalanceOf`
|
||||
- **summary**: Minimum about that can be used as the locked value for voting.
|
||||
|
||||
▸ **presentSlashPerVoter**: `BalanceOf`
|
||||
- **summary**: The punishment, per voter, if you provide an invalid presentation. A reasonable default value is 1.
|
||||
|
||||
▸ **voterSetSize**: `u32`
|
||||
- **summary**: The chunk size of the voter vector.
|
||||
|
||||
▸ **votingBond**: `BalanceOf`
|
||||
- **summary**: How much should be locked up in order to be able to submit votes.
|
||||
|
||||
▸ **votingFee**: `BalanceOf`
|
||||
- **summary**: The amount of fee paid upon each vote submission, unless if they submit a _hole_ index and replace it.
|
||||
|
||||
▸ **votingPeriod**: `BlockNumber`
|
||||
- **summary**: How often (in blocks) to check for new votes. A reasonable default value is 1000.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### finalityTracker
|
||||
|
||||
▸ **reportLatency**: `BlockNumber`
|
||||
- **summary**: The delay after which point things become suspicious. Default is 1000.
|
||||
|
||||
▸ **windowSize**: `BlockNumber`
|
||||
- **summary**: The number of recent samples to keep from this chain. Default is 101.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### session
|
||||
|
||||
▸ **dedupKeyPrefix**: `Bytes`
|
||||
- **summary**: Used as first key for `NextKeys` and `KeyOwner` to put all the data into the same branch of the trie.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### staking
|
||||
|
||||
▸ **bondingDuration**: `EraIndex`
|
||||
- **summary**: Number of eras that staked funds must remain bonded for.
|
||||
|
||||
▸ **sessionsPerEra**: `SessionIndex`
|
||||
- **summary**: Number of sessions per era.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### timestamp
|
||||
|
||||
▸ **minimumPeriod**: `Moment`
|
||||
- **summary**: The minimum period between blocks. Beware that this is different to the *expected* period that the block production apparatus provides. Your chosen consensus system will generally work with this to determine a sensible block time. e.g. For Aura, it will be double this period on default settings.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### treasury
|
||||
|
||||
▸ **burn**: `Permill`
|
||||
- **summary**: Percentage of spare funds (if any) that are burnt per spend period.
|
||||
|
||||
▸ **proposalBond**: `Permill`
|
||||
- **summary**: Fraction of a proposal's value that should be bonded in order to place the proposal. An accepted proposal gets these back. A rejected proposal does not.
|
||||
|
||||
▸ **proposalBondMinimum**: `BalanceOf`
|
||||
- **summary**: Minimum amount of funds that should be placed in a deposit for making a proposal.
|
||||
|
||||
▸ **spendPeriod**: `BlockNumber`
|
||||
- **summary**: Period between successive spends.
|
||||
@@ -1,298 +0,0 @@
|
||||
## Events
|
||||
|
||||
Events are emitted for certain operations on the runtime. The following sections describe the events that are part of the default Substrate runtime.
|
||||
|
||||
(NOTE: These were generated from a static/snapshot view of a recent Substrate master node. Some items may not be available in older nodes, or in any customized implementations.)
|
||||
- **[balances](#balances)**
|
||||
|
||||
- **[contracts](#contracts)**
|
||||
|
||||
- **[council](#council)**
|
||||
|
||||
- **[democracy](#democracy)**
|
||||
|
||||
- **[elections](#elections)**
|
||||
|
||||
- **[grandpa](#grandpa)**
|
||||
|
||||
- **[imOnline](#imOnline)**
|
||||
|
||||
- **[indices](#indices)**
|
||||
|
||||
- **[offences](#offences)**
|
||||
|
||||
- **[session](#session)**
|
||||
|
||||
- **[staking](#staking)**
|
||||
|
||||
- **[sudo](#sudo)**
|
||||
|
||||
- **[system](#system)**
|
||||
|
||||
- **[technicalCommittee](#technicalCommittee)**
|
||||
|
||||
- **[technicalMembership](#technicalMembership)**
|
||||
|
||||
- **[treasury](#treasury)**
|
||||
|
||||
- **[utility](#utility)**
|
||||
|
||||
|
||||
___
|
||||
|
||||
|
||||
### balances
|
||||
|
||||
▸ **NewAccount**(`AccountId`, `Balance`)
|
||||
- **summary**: A new account was created.
|
||||
|
||||
▸ **ReapedAccount**(`AccountId`)
|
||||
- **summary**: An account was reaped.
|
||||
|
||||
▸ **Transfer**(`AccountId`, `AccountId`, `Balance`, `Balance`)
|
||||
- **summary**: Transfer succeeded (from, to, value, fees).
|
||||
|
||||
___
|
||||
|
||||
|
||||
### contracts
|
||||
|
||||
▸ **CodeStored**(`Hash`)
|
||||
- **summary**: Code with the specified hash has been stored.
|
||||
|
||||
▸ **Contract**(`AccountId`, `Bytes`)
|
||||
- **summary**: An event from contract of account.
|
||||
|
||||
▸ **Dispatched**(`AccountId`, `bool`)
|
||||
- **summary**: A call was dispatched from the given account. The bool signals whether it was successful execution or not.
|
||||
|
||||
▸ **Instantiated**(`AccountId`, `AccountId`)
|
||||
- **summary**: Contract deployed by address at the specified address.
|
||||
|
||||
▸ **ScheduleUpdated**(`u32`)
|
||||
- **summary**: Triggered when the current schedule is updated.
|
||||
|
||||
▸ **Transfer**(`AccountId`, `AccountId`, `Balance`)
|
||||
- **summary**: Transfer happened `from` to `to` with given `value` as part of a `call` or `instantiate`.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### council
|
||||
|
||||
▸ **Approved**(`Hash`)
|
||||
- **summary**: A motion was approved by the required threshold.
|
||||
|
||||
▸ **Disapproved**(`Hash`)
|
||||
- **summary**: A motion was not approved by the required threshold.
|
||||
|
||||
▸ **Executed**(`Hash`, `bool`)
|
||||
- **summary**: A motion was executed; `bool` is true if returned without error.
|
||||
|
||||
▸ **MemberExecuted**(`Hash`, `bool`)
|
||||
- **summary**: A single member did some action; `bool` is true if returned without error.
|
||||
|
||||
▸ **Proposed**(`AccountId`, `ProposalIndex`, `Hash`, `MemberCount`)
|
||||
- **summary**: A motion (given hash) has been proposed (by given account) with a threshold (given `MemberCount`).
|
||||
|
||||
▸ **Voted**(`AccountId`, `Hash`, `bool`, `MemberCount`, `MemberCount`)
|
||||
- **summary**: A motion (given hash) has been voted on by given account, leaving a tally (yes votes and no votes given respectively as `MemberCount`).
|
||||
|
||||
___
|
||||
|
||||
|
||||
### democracy
|
||||
|
||||
▸ **Cancelled**(`ReferendumIndex`)
|
||||
|
||||
▸ **Delegated**(`AccountId`, `AccountId`)
|
||||
|
||||
▸ **Executed**(`ReferendumIndex`, `bool`)
|
||||
|
||||
▸ **ExternalTabled**()
|
||||
|
||||
▸ **NotPassed**(`ReferendumIndex`)
|
||||
|
||||
▸ **Passed**(`ReferendumIndex`)
|
||||
|
||||
▸ **Proposed**(`PropIndex`, `Balance`)
|
||||
|
||||
▸ **Started**(`ReferendumIndex`, `VoteThreshold`)
|
||||
|
||||
▸ **Tabled**(`PropIndex`, `Balance`, `Vec<AccountId>`)
|
||||
|
||||
▸ **Undelegated**(`AccountId`)
|
||||
|
||||
▸ **Vetoed**(`AccountId`, `Hash`, `BlockNumber`)
|
||||
|
||||
___
|
||||
|
||||
|
||||
### elections
|
||||
|
||||
▸ **BadReaperSlashed**(`AccountId`)
|
||||
- **summary**: slashed reaper
|
||||
|
||||
▸ **TallyFinalized**(`Vec<AccountId>`, `Vec<AccountId>`)
|
||||
- **summary**: A tally (for approval votes of seat(s)) has ended (with one or more new members).
|
||||
|
||||
▸ **TallyStarted**(`u32`)
|
||||
- **summary**: A tally (for approval votes of seat(s)) has started.
|
||||
|
||||
▸ **VoterReaped**(`AccountId`, `AccountId`)
|
||||
- **summary**: reaped voter, reaper
|
||||
|
||||
___
|
||||
|
||||
|
||||
### grandpa
|
||||
|
||||
▸ **NewAuthorities**(`Vec<(AuthorityId,AuthorityWeight)>`)
|
||||
- **summary**: New authority set has been applied.
|
||||
|
||||
▸ **Paused**()
|
||||
- **summary**: Current authority set has been paused.
|
||||
|
||||
▸ **Resumed**()
|
||||
- **summary**: Current authority set has been resumed.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### imOnline
|
||||
|
||||
▸ **HeartbeatReceived**(`AuthorityId`)
|
||||
- **summary**: A new heartbeat was received from `AuthorityId`
|
||||
|
||||
___
|
||||
|
||||
|
||||
### indices
|
||||
|
||||
▸ **NewAccountIndex**(`AccountId`, `AccountIndex`)
|
||||
- **summary**: A new account index was assigned. This event is not triggered when an existing index is reassigned to another `AccountId`.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### offences
|
||||
|
||||
▸ **Offence**(`Kind`, `OpaqueTimeSlot`)
|
||||
- **summary**: There is an offence reported of the given `kind` happened at the `session_index` and (kind-specific) time slot. This event is not deposited for duplicate slashes.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### session
|
||||
|
||||
▸ **NewSession**(`SessionIndex`)
|
||||
- **summary**: New session has happened. Note that the argument is the session index, not the block number as the type might suggest.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### staking
|
||||
|
||||
▸ **OldSlashingReportDiscarded**(`SessionIndex`)
|
||||
- **summary**: An old slashing report from a prior era was discarded because it could not be processed.
|
||||
|
||||
▸ **Reward**(`Balance`)
|
||||
- **summary**: All validators have been rewarded by the given balance.
|
||||
|
||||
▸ **Slash**(`AccountId`, `Balance`)
|
||||
- **summary**: One validator (and its nominators) has been slashed by the given amount.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### sudo
|
||||
|
||||
▸ **KeyChanged**(`AccountId`)
|
||||
- **summary**: The sudoer just switched identity; the old key is supplied.
|
||||
|
||||
▸ **Sudid**(`bool`)
|
||||
- **summary**: A sudo just took place.
|
||||
|
||||
▸ **SudoAsDone**(`bool`)
|
||||
- **summary**: A sudo just took place.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### system
|
||||
|
||||
▸ **ExtrinsicFailed**(`DispatchError`)
|
||||
- **summary**: An extrinsic failed.
|
||||
|
||||
▸ **ExtrinsicSuccess**()
|
||||
- **summary**: An extrinsic completed successfully.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### technicalCommittee
|
||||
|
||||
▸ **Approved**(`Hash`)
|
||||
- **summary**: A motion was approved by the required threshold.
|
||||
|
||||
▸ **Disapproved**(`Hash`)
|
||||
- **summary**: A motion was not approved by the required threshold.
|
||||
|
||||
▸ **Executed**(`Hash`, `bool`)
|
||||
- **summary**: A motion was executed; `bool` is true if returned without error.
|
||||
|
||||
▸ **MemberExecuted**(`Hash`, `bool`)
|
||||
- **summary**: A single member did some action; `bool` is true if returned without error.
|
||||
|
||||
▸ **Proposed**(`AccountId`, `ProposalIndex`, `Hash`, `MemberCount`)
|
||||
- **summary**: A motion (given hash) has been proposed (by given account) with a threshold (given `MemberCount`).
|
||||
|
||||
▸ **Voted**(`AccountId`, `Hash`, `bool`, `MemberCount`, `MemberCount`)
|
||||
- **summary**: A motion (given hash) has been voted on by given account, leaving a tally (yes votes and no votes given respectively as `MemberCount`).
|
||||
|
||||
___
|
||||
|
||||
|
||||
### technicalMembership
|
||||
|
||||
▸ **Dummy**(`PhantomData`)
|
||||
- **summary**: Phantom member, never used.
|
||||
|
||||
▸ **MemberAdded**()
|
||||
- **summary**: The given member was added; see the transaction for who.
|
||||
|
||||
▸ **MemberRemoved**()
|
||||
- **summary**: The given member was removed; see the transaction for who.
|
||||
|
||||
▸ **MembersReset**()
|
||||
- **summary**: The membership was reset; see the transaction for who the new set is.
|
||||
|
||||
▸ **MembersSwapped**()
|
||||
- **summary**: Two members were swapped; see the transaction for who.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### treasury
|
||||
|
||||
▸ **Awarded**(`ProposalIndex`, `Balance`, `AccountId`)
|
||||
- **summary**: Some funds have been allocated.
|
||||
|
||||
▸ **Burnt**(`Balance`)
|
||||
- **summary**: Some of our funds have been burnt.
|
||||
|
||||
▸ **Proposed**(`ProposalIndex`)
|
||||
- **summary**: New proposal.
|
||||
|
||||
▸ **Rollover**(`Balance`)
|
||||
- **summary**: Spending has finished; this is the amount that rolls over until next spend.
|
||||
|
||||
▸ **Spending**(`Balance`)
|
||||
- **summary**: We have ended a spend period and will now allocate funds.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### utility
|
||||
|
||||
▸ **BatchExecuted**(`Vec<DispatchResult>`)
|
||||
@@ -1,370 +0,0 @@
|
||||
## Extrinsics
|
||||
|
||||
The following sections contain Extrinsics methods are part of the default Substrate runtime. On the api, these are exposed via `api.tx.<module>.<method>`.
|
||||
|
||||
(NOTE: These were generated from a static/snapshot view of a recent Substrate master node. Some items may not be available in older nodes, or in any customized implementations.)
|
||||
- **[authorship](#authorship)**
|
||||
|
||||
- **[balances](#balances)**
|
||||
|
||||
- **[contracts](#contracts)**
|
||||
|
||||
- **[council](#council)**
|
||||
|
||||
- **[democracy](#democracy)**
|
||||
|
||||
- **[elections](#elections)**
|
||||
|
||||
- **[finalityTracker](#finalityTracker)**
|
||||
|
||||
- **[grandpa](#grandpa)**
|
||||
|
||||
- **[imOnline](#imOnline)**
|
||||
|
||||
- **[session](#session)**
|
||||
|
||||
- **[staking](#staking)**
|
||||
|
||||
- **[sudo](#sudo)**
|
||||
|
||||
- **[system](#system)**
|
||||
|
||||
- **[technicalCommittee](#technicalCommittee)**
|
||||
|
||||
- **[technicalMembership](#technicalMembership)**
|
||||
|
||||
- **[timestamp](#timestamp)**
|
||||
|
||||
- **[treasury](#treasury)**
|
||||
|
||||
- **[utility](#utility)**
|
||||
|
||||
|
||||
___
|
||||
|
||||
|
||||
### authorship
|
||||
|
||||
▸ **setUncles**(new_uncles: `Vec<Header>`)
|
||||
- **summary**: Provide a set of uncles.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### balances
|
||||
|
||||
▸ **forceTransfer**(source: `Address`, dest: `Address`, value: `Compact<Balance>`)
|
||||
- **summary**: Exactly as `transfer`, except the origin must be root and the source account may be specified.
|
||||
|
||||
▸ **setBalance**(who: `Address`, new_free: `Compact<Balance>`, new_reserved: `Compact<Balance>`)
|
||||
- **summary**: Set the balances of a given account. This will alter `FreeBalance` and `ReservedBalance` in storage. it will also decrease the total issuance of the system (`TotalIssuance`). If the new free or reserved balance is below the existential deposit, it will reset the account nonce (`system::AccountNonce`). The dispatch origin for this call is `root`. # <weight> - Independent of the arguments. - Contains a limited number of reads and writes. # </weight>
|
||||
|
||||
▸ **transfer**(dest: `Address`, value: `Compact<Balance>`)
|
||||
- **summary**: Transfer some liquid free balance to another account. `transfer` will set the `FreeBalance` of the sender and receiver. It will decrease the total issuance of the system by the `TransferFee`. If the sender's account is below the existential deposit as a result of the transfer, the account will be reaped. The dispatch origin for this call must be `Signed` by the transactor. # <weight> - Dependent on arguments but not critical, given proper implementations for input config types. See related functions below. - It contains a limited number of reads and writes internally and no complex computation. Related functions: - `ensure_can_withdraw` is always called internally but has a bounded complexity. - Transferring balances to accounts that did not exist before will cause `T::OnNewAccount::on_new_account` to be called. - Removing enough funds from an account will trigger `T::DustRemoval::on_unbalanced` and `T::OnFreeBalanceZero::on_free_balance_zero`. # </weight>
|
||||
|
||||
___
|
||||
|
||||
|
||||
### contracts
|
||||
|
||||
▸ **call**(dest: `Address`, value: `Compact<BalanceOf>`, gas_limit: `Compact<Gas>`, data: `Bytes`)
|
||||
- **summary**: Makes a call to an account, optionally transferring some balance. * If the account is a smart-contract account, the associated code will be executed and any value will be transferred. * If the account is a regular account, any value will be transferred. * If no account exists and the call value is not less than `existential_deposit`, a regular account will be created and any value will be transferred.
|
||||
|
||||
▸ **claimSurcharge**(dest: `AccountId`, aux_sender: `Option<AccountId>`)
|
||||
- **summary**: Allows block producers to claim a small reward for evicting a contract. If a block producer fails to do so, a regular users will be allowed to claim the reward. If contract is not evicted as a result of this call, no actions are taken and the sender is not eligible for the reward.
|
||||
|
||||
▸ **instantiate**(endowment: `Compact<BalanceOf>`, gas_limit: `Compact<Gas>`, code_hash: `CodeHash`, data: `Bytes`)
|
||||
- **summary**: Instantiates a new contract from the `codehash` generated by `put_code`, optionally transferring some balance. Instantiation is executed as follows: - The destination address is computed based on the sender and hash of the code. - The smart-contract account is created at the computed address. - The `ctor_code` is executed in the context of the newly-created account. Buffer returned after the execution is saved as the `code` of the account. That code will be invoked upon any call received by this account. - The contract is initialized.
|
||||
|
||||
▸ **putCode**(gas_limit: `Compact<Gas>`, code: `Bytes`)
|
||||
- **summary**: Stores the given binary Wasm code into the chain's storage and returns its `codehash`. You can instantiate contracts only with stored code.
|
||||
|
||||
▸ **updateSchedule**(schedule: `Schedule`)
|
||||
- **summary**: Updates the schedule for metering contracts. The schedule must have a greater version than the stored schedule.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### council
|
||||
|
||||
▸ **execute**(proposal: `Proposal`)
|
||||
- **summary**: Dispatch a proposal from a member using the `Member` origin. Origin must be a member of the collective.
|
||||
|
||||
▸ **propose**(threshold: `Compact<MemberCount>`, proposal: `Proposal`)
|
||||
- **summary**: # <weight> - Bounded storage reads and writes. - Argument `threshold` has bearing on weight. # </weight>
|
||||
|
||||
▸ **setMembers**(new_members: `Vec<AccountId>`)
|
||||
- **summary**: Set the collective's membership manually to `new_members`. Be nice to the chain and provide it pre-sorted. Requires root origin.
|
||||
|
||||
▸ **vote**(proposal: `Hash`, index: `Compact<ProposalIndex>`, approve: `bool`)
|
||||
- **summary**: # <weight> - Bounded storage read and writes. - Will be slightly heavier if the proposal is approved / disapproved after the vote. # </weight>
|
||||
|
||||
___
|
||||
|
||||
|
||||
### democracy
|
||||
|
||||
▸ **cancelQueued**(when: `Compact<BlockNumber>`, which: `Compact<u32>`, what: `Compact<ReferendumIndex>`)
|
||||
- **summary**: Cancel a proposal queued for enactment.
|
||||
|
||||
▸ **cancelReferendum**(ref_index: `Compact<ReferendumIndex>`)
|
||||
- **summary**: Remove a referendum.
|
||||
|
||||
▸ **delegate**(to: `AccountId`, conviction: `Conviction`)
|
||||
- **summary**: Delegate vote. # <weight> - One extra DB entry. # </weight>
|
||||
|
||||
▸ **emergencyCancel**(ref_index: `ReferendumIndex`)
|
||||
- **summary**: Schedule an emergency cancellation of a referendum. Cannot happen twice to the same referendum.
|
||||
|
||||
▸ **externalPropose**(proposal: `Proposal`)
|
||||
- **summary**: Schedule a referendum to be tabled once it is legal to schedule an external referendum.
|
||||
|
||||
▸ **externalProposeDefault**(proposal: `Proposal`)
|
||||
- **summary**: Schedule a negative-turnout-bias referendum to be tabled next once it is legal to schedule an external referendum. Unlike `external_propose`, blacklisting has no effect on this and it may replace a pre-scheduled `external_propose` call.
|
||||
|
||||
▸ **externalProposeMajority**(proposal: `Proposal`)
|
||||
- **summary**: Schedule a majority-carries referendum to be tabled next once it is legal to schedule an external referendum. Unlike `external_propose`, blacklisting has no effect on this and it may replace a pre-scheduled `external_propose` call.
|
||||
|
||||
▸ **fastTrack**(proposal_hash: `Hash`, voting_period: `BlockNumber`, delay: `BlockNumber`)
|
||||
- **summary**: Schedule the currently externally-proposed majority-carries referendum to be tabled immediately. If there is no externally-proposed referendum currently, or if there is one but it is not a majority-carries referendum then it fails. - `proposal_hash`: The hash of the current external proposal. - `voting_period`: The period that is allowed for voting on this proposal. - `delay`: The number of block after voting has ended in approval and this should be enacted. Increased to `EmergencyVotingPeriod` if too low.
|
||||
|
||||
▸ **propose**(proposal: `Proposal`, value: `Compact<BalanceOf>`)
|
||||
- **summary**: Propose a sensitive action to be taken. # <weight> - O(1). - Two DB changes, one DB entry. # </weight>
|
||||
|
||||
▸ **proxyVote**(ref_index: `Compact<ReferendumIndex>`, vote: `Vote`)
|
||||
- **summary**: Vote in a referendum on behalf of a stash. If `vote.is_aye()`, the vote is to enact the proposal; otherwise it is a vote to keep the status quo. # <weight> - O(1). - One DB change, one DB entry. # </weight>
|
||||
|
||||
▸ **removeProxy**(proxy: `AccountId`)
|
||||
- **summary**: Clear the proxy. Called by the stash. # <weight> - One DB clear. # </weight>
|
||||
|
||||
▸ **resignProxy**()
|
||||
- **summary**: Clear the proxy. Called by the proxy. # <weight> - One DB clear. # </weight>
|
||||
|
||||
▸ **second**(proposal: `Compact<PropIndex>`)
|
||||
- **summary**: Propose a sensitive action to be taken. # <weight> - O(1). - One DB entry. # </weight>
|
||||
|
||||
▸ **setProxy**(proxy: `AccountId`)
|
||||
- **summary**: Specify a proxy. Called by the stash. # <weight> - One extra DB entry. # </weight>
|
||||
|
||||
▸ **undelegate**()
|
||||
- **summary**: Undelegate vote. # <weight> - O(1). # </weight>
|
||||
|
||||
▸ **vetoExternal**(proposal_hash: `Hash`)
|
||||
- **summary**: Veto and blacklist the external proposal hash.
|
||||
|
||||
▸ **vote**(ref_index: `Compact<ReferendumIndex>`, vote: `Vote`)
|
||||
- **summary**: Vote in a referendum. If `vote.is_aye()`, the vote is to enact the proposal; otherwise it is a vote to keep the status quo. # <weight> - O(1). - One DB change, one DB entry. # </weight>
|
||||
|
||||
___
|
||||
|
||||
|
||||
### elections
|
||||
|
||||
▸ **presentWinner**(candidate: `Address`, total: `Compact<BalanceOf>`, index: `Compact<VoteIndex>`)
|
||||
- **summary**: Claim that `candidate` is one of the top `carry_count + desired_seats` candidates. Only works iff the presentation period is active. `candidate` should have at least collected some non-zero `total` votes and `origin` must have enough funds to pay for a potential slash. # <weight> - O(voters) compute. - One DB change. # </weight>
|
||||
|
||||
▸ **proxySetApprovals**(votes: `Vec<bool>`, index: `Compact<VoteIndex>`, hint: `SetIndex`, value: `Compact<BalanceOf>`)
|
||||
- **summary**: Set candidate approvals from a proxy. Approval slots stay valid as long as candidates in those slots are registered. # <weight> - Same as `set_approvals` with one additional storage read. # </weight>
|
||||
|
||||
▸ **reapInactiveVoter**(reporter_index: `Compact<u32>`, who: `Address`, who_index: `Compact<u32>`, assumed_vote_index: `Compact<VoteIndex>`)
|
||||
- **summary**: Remove a voter. For it not to be a bond-consuming no-op, all approved candidate indices must now be either unregistered or registered to a candidate that registered the slot after the voter gave their last approval set. Both indices must be provided as explained in [`voter_at`] function. May be called by anyone. Returns the voter deposit to `signed`. # <weight> - O(1). - Two fewer DB entries, one DB change. # </weight>
|
||||
|
||||
▸ **removeMember**(who: `Address`)
|
||||
- **summary**: Remove a particular member from the set. This is effective immediately. Note: A tally should happen instantly (if not already in a presentation period) to fill the seat if removal means that the desired members are not met.
|
||||
|
||||
▸ **retractVoter**(index: `Compact<u32>`)
|
||||
- **summary**: Remove a voter. All votes are cancelled and the voter deposit is returned. The index must be provided as explained in [`voter_at`] function. Also removes the lock on the balance of the voter. See [`do_set_approvals()`]. # <weight> - O(1). - Two fewer DB entries, one DB change. # </weight>
|
||||
|
||||
▸ **setApprovals**(votes: `Vec<bool>`, index: `Compact<VoteIndex>`, hint: `SetIndex`, value: `Compact<BalanceOf>`)
|
||||
- **summary**: Set candidate approvals. Approval slots stay valid as long as candidates in those slots are registered. Locks `value` from the balance of `origin` indefinitely. Only [`retract_voter`] or [`reap_inactive_voter`] can unlock the balance. `hint` argument is interpreted differently based on: - if `origin` is setting approvals for the first time: The index will be checked for being a valid _hole_ in the voter list. - if the hint is correctly pointing to a hole, no fee is deducted from `origin`. - Otherwise, the call will succeed but the index is ignored and simply a push to the last chunk with free space happens. If the new push causes a new chunk to be created, a fee indicated by [`VotingFee`] is deducted. - if `origin` is already a voter: the index __must__ be valid and point to the correct position of the `origin` in the current voters list. Note that any trailing `false` votes in `votes` is ignored; In approval voting, not voting for a candidate and voting false, are equal. # <weight> - O(1). - Two extra DB entries, one DB change. - Argument `votes` is limited in length to number of candidates. # </weight>
|
||||
|
||||
▸ **setDesiredSeats**(count: `Compact<u32>`)
|
||||
- **summary**: Set the desired member count; if lower than the current count, then seats will not be up election when they expire. If more, then a new vote will be started if one is not already in progress.
|
||||
|
||||
▸ **setPresentationDuration**(count: `Compact<BlockNumber>`)
|
||||
- **summary**: Set the presentation duration. If there is currently a vote being presented for, will invoke `finalize_vote`.
|
||||
|
||||
▸ **setTermDuration**(count: `Compact<BlockNumber>`)
|
||||
- **summary**: Set the presentation duration. If there is current a vote being presented for, will invoke `finalize_vote`.
|
||||
|
||||
▸ **submitCandidacy**(slot: `Compact<u32>`)
|
||||
- **summary**: Submit oneself for candidacy. Account must have enough transferrable funds in it to pay the bond. NOTE: if `origin` has already assigned approvals via [`set_approvals`], it will NOT have any usable funds to pass candidacy bond and must first retract. Note that setting approvals will lock the entire balance of the voter until retraction or being reported. # <weight> - Independent of input. - Three DB changes. # </weight>
|
||||
|
||||
___
|
||||
|
||||
|
||||
### finalityTracker
|
||||
|
||||
▸ **finalHint**(hint: `Compact<BlockNumber>`)
|
||||
- **summary**: Hint that the author of this block thinks the best finalized block is the given number.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### grandpa
|
||||
|
||||
▸ **reportMisbehavior**(_report: `Bytes`)
|
||||
- **summary**: Report some misbehavior.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### imOnline
|
||||
|
||||
▸ **heartbeat**(heartbeat: `Heartbeat`, signature: `Signature`)
|
||||
|
||||
___
|
||||
|
||||
|
||||
### session
|
||||
|
||||
▸ **setKeys**(keys: `Keys`, proof: `Bytes`)
|
||||
- **summary**: Sets the session key(s) of the function caller to `key`. Allows an account to set its session key prior to becoming a validator. This doesn't take effect until the next session. The dispatch origin of this function must be signed. # <weight> - O(log n) in number of accounts. - One extra DB entry. # </weight>
|
||||
|
||||
___
|
||||
|
||||
|
||||
### staking
|
||||
|
||||
▸ **bond**(controller: `Address`, value: `Compact<BalanceOf>`, payee: `RewardDestination`)
|
||||
- **summary**: Take the origin account as a stash and lock up `value` of its balance. `controller` will be the account that controls it. `value` must be more than the `minimum_balance` specified by `T::Currency`. The dispatch origin for this call must be _Signed_ by the stash account. # <weight> - Independent of the arguments. Moderate complexity. - O(1). - Three extra DB entries. NOTE: Two of the storage writes (`Self::bonded`, `Self::payee`) are _never_ cleaned unless the `origin` falls below _existential deposit_ and gets removed as dust. # </weight>
|
||||
|
||||
▸ **bondExtra**(max_additional: `Compact<BalanceOf>`)
|
||||
- **summary**: Add some extra amount that have appeared in the stash `free_balance` into the balance up for staking. Use this if there are additional funds in your stash account that you wish to bond. Unlike [`bond`] or [`unbond`] this function does not impose any limitation on the amount that can be added. The dispatch origin for this call must be _Signed_ by the stash, not the controller. # <weight> - Independent of the arguments. Insignificant complexity. - O(1). - One DB entry. # </weight>
|
||||
|
||||
▸ **chill**()
|
||||
- **summary**: Declare no desire to either validate or nominate. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the controller, not the stash. # <weight> - Independent of the arguments. Insignificant complexity. - Contains one read. - Writes are limited to the `origin` account key. # </weight>
|
||||
|
||||
▸ **forceNewEra**()
|
||||
- **summary**: Force there to be a new era at the end of the next session. After this, it will be reset to normal (non-forced) behaviour. # <weight> - No arguments. # </weight>
|
||||
|
||||
▸ **forceNoEras**()
|
||||
- **summary**: Force there to be no new eras indefinitely. # <weight> - No arguments. # </weight>
|
||||
|
||||
▸ **nominate**(targets: `Vec<Address>`)
|
||||
- **summary**: Declare the desire to nominate `targets` for the origin controller. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the controller, not the stash. # <weight> - The transaction's complexity is proportional to the size of `targets`, which is capped at `MAX_NOMINATIONS`. - Both the reads and writes follow a similar pattern. # </weight>
|
||||
|
||||
▸ **setController**(controller: `Address`)
|
||||
- **summary**: (Re-)set the controller of a stash. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the stash, not the controller. # <weight> - Independent of the arguments. Insignificant complexity. - Contains a limited number of reads. - Writes are limited to the `origin` account key. # </weight>
|
||||
|
||||
▸ **setInvulnerables**(validators: `Vec<AccountId>`)
|
||||
- **summary**: Set the validators who cannot be slashed (if any).
|
||||
|
||||
▸ **setPayee**(payee: `RewardDestination`)
|
||||
- **summary**: (Re-)set the payment target for a controller. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the controller, not the stash. # <weight> - Independent of the arguments. Insignificant complexity. - Contains a limited number of reads. - Writes are limited to the `origin` account key. # </weight>
|
||||
|
||||
▸ **setValidatorCount**(new: `Compact<u32>`)
|
||||
- **summary**: The ideal number of validators.
|
||||
|
||||
▸ **unbond**(value: `Compact<BalanceOf>`)
|
||||
- **summary**: Schedule a portion of the stash to be unlocked ready for transfer out after the bond period ends. If this leaves an amount actively bonded less than T::Currency::minimum_balance(), then it is increased to the full amount. Once the unlock period is done, you can call `withdraw_unbonded` to actually move the funds out of management ready for transfer. No more than a limited number of unlocking chunks (see `MAX_UNLOCKING_CHUNKS`) can co-exists at the same time. In that case, [`Call::withdraw_unbonded`] need to be called first to remove some of the chunks (if possible). The dispatch origin for this call must be _Signed_ by the controller, not the stash. See also [`Call::withdraw_unbonded`]. # <weight> - Independent of the arguments. Limited but potentially exploitable complexity. - Contains a limited number of reads. - Each call (requires the remainder of the bonded balance to be above `minimum_balance`) will cause a new entry to be inserted into a vector (`Ledger.unlocking`) kept in storage. The only way to clean the aforementioned storage item is also user-controlled via `withdraw_unbonded`. - One DB entry. </weight>
|
||||
|
||||
▸ **validate**(prefs: `ValidatorPrefs`)
|
||||
- **summary**: Declare the desire to validate for the origin controller. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the controller, not the stash. # <weight> - Independent of the arguments. Insignificant complexity. - Contains a limited number of reads. - Writes are limited to the `origin` account key. # </weight>
|
||||
|
||||
▸ **withdrawUnbonded**()
|
||||
- **summary**: Remove any unlocked chunks from the `unlocking` queue from our management. This essentially frees up that balance to be used by the stash account to do whatever it wants. The dispatch origin for this call must be _Signed_ by the controller, not the stash. See also [`Call::unbond`]. # <weight> - Could be dependent on the `origin` argument and how much `unlocking` chunks exist. It implies `consolidate_unlocked` which loops over `Ledger.unlocking`, which is indirectly user-controlled. See [`unbond`] for more detail. - Contains a limited number of reads, yet the size of which could be large based on `ledger`. - Writes are limited to the `origin` account key. # </weight>
|
||||
|
||||
___
|
||||
|
||||
|
||||
### sudo
|
||||
|
||||
▸ **setKey**(new: `Address`)
|
||||
- **summary**: Authenticates the current sudo key and sets the given AccountId (`new`) as the new sudo key. The dispatch origin for this call must be _Signed_. # <weight> - O(1). - Limited storage reads. - One DB change. # </weight>
|
||||
|
||||
▸ **sudo**(proposal: `Proposal`)
|
||||
- **summary**: Authenticates the sudo key and dispatches a function call with `Root` origin. The dispatch origin for this call must be _Signed_. # <weight> - O(1). - Limited storage reads. - One DB write (event). - Unknown weight of derivative `proposal` execution. # </weight>
|
||||
|
||||
▸ **sudoAs**(who: `Address`, proposal: `Proposal`)
|
||||
- **summary**: Authenticates the sudo key and dispatches a function call with `Signed` origin from a given account. The dispatch origin for this call must be _Signed_. # <weight> - O(1). - Limited storage reads. - One DB write (event). - Unknown weight of derivative `proposal` execution. # </weight>
|
||||
|
||||
___
|
||||
|
||||
|
||||
### system
|
||||
|
||||
▸ **fillBlock**()
|
||||
- **summary**: A big dispatch that will disallow any other transaction to be included.
|
||||
|
||||
▸ **killPrefix**(prefix: `Key`)
|
||||
- **summary**: Kill all storage items with a key that starts with the given prefix.
|
||||
|
||||
▸ **killStorage**(keys: `Vec<Key>`)
|
||||
- **summary**: Kill some items from storage.
|
||||
|
||||
▸ **remark**(_remark: `Bytes`)
|
||||
- **summary**: Make some on-chain remark.
|
||||
|
||||
▸ **setCode**(new: `Bytes`)
|
||||
- **summary**: Set the new code.
|
||||
|
||||
▸ **setHeapPages**(pages: `u64`)
|
||||
- **summary**: Set the number of pages in the WebAssembly environment's heap.
|
||||
|
||||
▸ **setStorage**(items: `Vec<KeyValue>`)
|
||||
- **summary**: Set some items of storage.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### technicalCommittee
|
||||
|
||||
▸ **execute**(proposal: `Proposal`)
|
||||
- **summary**: Dispatch a proposal from a member using the `Member` origin. Origin must be a member of the collective.
|
||||
|
||||
▸ **propose**(threshold: `Compact<MemberCount>`, proposal: `Proposal`)
|
||||
- **summary**: # <weight> - Bounded storage reads and writes. - Argument `threshold` has bearing on weight. # </weight>
|
||||
|
||||
▸ **setMembers**(new_members: `Vec<AccountId>`)
|
||||
- **summary**: Set the collective's membership manually to `new_members`. Be nice to the chain and provide it pre-sorted. Requires root origin.
|
||||
|
||||
▸ **vote**(proposal: `Hash`, index: `Compact<ProposalIndex>`, approve: `bool`)
|
||||
- **summary**: # <weight> - Bounded storage read and writes. - Will be slightly heavier if the proposal is approved / disapproved after the vote. # </weight>
|
||||
|
||||
___
|
||||
|
||||
|
||||
### technicalMembership
|
||||
|
||||
▸ **addMember**(who: `AccountId`)
|
||||
- **summary**: Add a member `who` to the set. May only be called from `AddOrigin` or root.
|
||||
|
||||
▸ **removeMember**(who: `AccountId`)
|
||||
- **summary**: Remove a member `who` from the set. May only be called from `RemoveOrigin` or root.
|
||||
|
||||
▸ **resetMembers**(members: `Vec<AccountId>`)
|
||||
- **summary**: Change the membership to a new set, disregarding the existing membership. Be nice and pass `members` pre-sorted. May only be called from `ResetOrigin` or root.
|
||||
|
||||
▸ **swapMember**(remove: `AccountId`, add: `AccountId`)
|
||||
- **summary**: Swap out one member `remove` for another `add`. May only be called from `SwapOrigin` or root.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### timestamp
|
||||
|
||||
▸ **set**(now: `Compact<Moment>`)
|
||||
- **summary**: Set the current time. This call should be invoked exactly once per block. It will panic at the finalization phase, if this call hasn't been invoked by that time. The timestamp should be greater than the previous one by the amount specified by `MinimumPeriod`. The dispatch origin for this call must be `Inherent`.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### treasury
|
||||
|
||||
▸ **approveProposal**(proposal_id: `Compact<ProposalIndex>`)
|
||||
- **summary**: Approve a proposal. At a later time, the proposal will be allocated to the beneficiary and the original deposit will be returned. # <weight> - O(1). - Limited storage reads. - One DB change. # </weight>
|
||||
|
||||
▸ **proposeSpend**(value: `Compact<BalanceOf>`, beneficiary: `Address`)
|
||||
- **summary**: Put forward a suggestion for spending. A deposit proportional to the value is reserved and slashed if the proposal is rejected. It is returned once the proposal is awarded. # <weight> - O(1). - Limited storage reads. - One DB change, one extra DB entry. # </weight>
|
||||
|
||||
▸ **rejectProposal**(proposal_id: `Compact<ProposalIndex>`)
|
||||
- **summary**: Reject a proposed spend. The original deposit will be slashed. # <weight> - O(1). - Limited storage reads. - One DB clear. # </weight>
|
||||
|
||||
___
|
||||
|
||||
|
||||
### utility
|
||||
|
||||
▸ **batch**(calls: `Vec<Call>`)
|
||||
- **summary**: Send a batch of dispatch calls (only root).
|
||||
@@ -1,175 +0,0 @@
|
||||
## JSON-RPC
|
||||
|
||||
The following sections contain RPC methods that are Remote Calls available by default and allow you to interact with the actual node, query, and submit.
|
||||
|
||||
- **[account](#account)**
|
||||
|
||||
- **[author](#author)**
|
||||
|
||||
- **[chain](#chain)**
|
||||
|
||||
- **[contracts](#contracts)**
|
||||
|
||||
- **[rpc](#rpc)**
|
||||
|
||||
- **[state](#state)**
|
||||
|
||||
- **[system](#system)**
|
||||
|
||||
|
||||
___
|
||||
|
||||
|
||||
### account
|
||||
|
||||
_(Optional) Methods that retrieves account-specific information_
|
||||
|
||||
▸ **nextIndex**(accountId: `AccountId`): `Index`
|
||||
- **summary**: Retrieves the next accountIndex as available on the node
|
||||
|
||||
___
|
||||
|
||||
|
||||
### author
|
||||
|
||||
_Authoring of network items_
|
||||
|
||||
▸ **insertKey**(keyType: `Text`, suri: `Text`, publicKey: `Bytes`): `Bytes`
|
||||
- **summary**: Insert a key into the keystore.
|
||||
|
||||
▸ **pendingExtrinsics**(): `Vec<Extrinsic>`
|
||||
- **summary**: Returns all pending extrinsics, potentially grouped by sender
|
||||
|
||||
▸ **removeExtrinsic**(bytesOrHash: `Vec<ExtrinsicOrHash>`): `Vec<Hash>`
|
||||
- **summary**: Remove given extrinsic from the pool and temporarily ban it to prevent reimporting
|
||||
|
||||
▸ **rotateKeys**(): `Bytes`
|
||||
- **summary**: Generate new session keys and returns the corresponding public keys
|
||||
|
||||
▸ **submitAndWatchExtrinsic**(extrinsic: `Extrinsic`): `ExtrinsicStatus`
|
||||
- **summary**: Submit and subscribe to watch an extrinsic until unsubscribed
|
||||
|
||||
▸ **submitExtrinsic**(extrinsic: `Extrinsic`): `Hash`
|
||||
- **summary**: Submit a fully formatted extrinsic for block inclusion
|
||||
|
||||
___
|
||||
|
||||
|
||||
### chain
|
||||
|
||||
_Retrieval of chain data_
|
||||
|
||||
▸ **getBlock**(hash?: `Hash`): `SignedBlock`
|
||||
- **summary**: Get header and body of a relay chain block
|
||||
|
||||
▸ **getBlockHash**(blockNumber?: `BlockNumber`): `Hash`
|
||||
- **summary**: Get the block hash for a specific block
|
||||
|
||||
▸ **getFinalizedHead**(): `Hash`
|
||||
- **summary**: Get hash of the last finalized block in the canon chain
|
||||
|
||||
▸ **getHeader**(hash?: `Hash`): `Header`
|
||||
- **summary**: Retrieves the header for a specific block
|
||||
|
||||
▸ **subscribeFinalizedHeads**(): `Header`
|
||||
- **summary**: Retrieves the best finalized header via subscription
|
||||
|
||||
▸ **subscribeNewHeads**(): `Header`
|
||||
- **summary**: Retrieves the best header via subscription
|
||||
|
||||
___
|
||||
|
||||
|
||||
### contracts
|
||||
|
||||
_(Optional) Methods that performs actions on contracts_
|
||||
|
||||
▸ **call**(callRequest: `ContractCallRequest`, at?: `Hash`): `ContractExecResult`
|
||||
- **summary**: Executes a call to a contract
|
||||
|
||||
___
|
||||
|
||||
|
||||
### rpc
|
||||
|
||||
_Retrieves information about the RPC endpoints_
|
||||
|
||||
▸ **methods**(): `RpcMethods`
|
||||
- **summary**: Retrieves the list of RPC methods that are exposed by the node
|
||||
|
||||
___
|
||||
|
||||
|
||||
### state
|
||||
|
||||
_Query of state_
|
||||
|
||||
▸ **call**(method: `Text`, data: `Bytes`, block?: `Hash`): `Bytes`
|
||||
- **summary**: Perform a call to a builtin on the chain
|
||||
|
||||
▸ **getChildKeys**(childStorageKey: `StorageKey`, key: `StorageKey`, block?: `Hash`): `Vec<StorageKey>`
|
||||
- **summary**: Retrieves the keys with prefix of a specific child storage
|
||||
|
||||
▸ **getChildStorage**(childStorageKey: `StorageKey`, key: `StorageKey`, block?: `Hash`): `StorageData`
|
||||
- **summary**: Retrieves the child storage for a key
|
||||
|
||||
▸ **getChildStorageHash**(childStorageKey: `StorageKey`, key: `StorageKey`, block?: `Hash`): `Hash`
|
||||
- **summary**: Retrieves the child storage hash
|
||||
|
||||
▸ **getChildStorageSize**(childStorageKey: `StorageKey`, key: `StorageKey`, block?: `Hash`): `u64`
|
||||
- **summary**: Retrieves the child storage size
|
||||
|
||||
▸ **getKeys**(key: `StorageKey`, block?: `Hash`): `Vec<StorageKey>`
|
||||
- **summary**: Retrieves the keys with a certain prefix
|
||||
|
||||
▸ **getMetadata**(block?: `Hash`): `Metadata`
|
||||
- **summary**: Returns the runtime metadata
|
||||
|
||||
▸ **getRuntimeVersion**(hash?: `Hash`): `RuntimeVersion`
|
||||
- **summary**: Get the runtime version
|
||||
|
||||
▸ **getStorage**(key: `StorageKey`, block?: `Hash`): `StorageData`
|
||||
- **summary**: Retrieves the storage for a key
|
||||
|
||||
▸ **getStorageHash**(key: `StorageKey`, block?: `Hash`): `Hash`
|
||||
- **summary**: Retrieves the storage hash
|
||||
|
||||
▸ **getStorageSize**(key: `StorageKey`, block?: `Hash`): `u64`
|
||||
- **summary**: Retrieves the storage size
|
||||
|
||||
▸ **queryStorage**(keys: `Vec<StorageKey>`, startBlock: `Hash`, block?: `Hash`): `Vec<StorageChangeSet>`
|
||||
- **summary**: Query historical storage entries (by key) starting from a start block
|
||||
|
||||
▸ **subscribeRuntimeVersion**(): `RuntimeVersion`
|
||||
- **summary**: Retrieves the runtime version via subscription
|
||||
|
||||
▸ **subscribeStorage**(keys: `Vec<StorageKey>`): `StorageChangeSet`
|
||||
- **summary**: Subscribes to storage changes for the provided keys
|
||||
|
||||
___
|
||||
|
||||
|
||||
### system
|
||||
|
||||
_Calls to retrieve system info_
|
||||
|
||||
▸ **chain**(): `Text`
|
||||
- **summary**: Retrieves the chain
|
||||
|
||||
▸ **health**(): `Health`
|
||||
- **summary**: Return health status of the node
|
||||
|
||||
▸ **name**(): `Text`
|
||||
- **summary**: Retrieves the node name
|
||||
|
||||
▸ **networkState**(): `NetworkState`
|
||||
- **summary**: Returns current state of the network
|
||||
|
||||
▸ **peers**(): `Vec<PeerInfo>`
|
||||
- **summary**: Returns the currently connected peers
|
||||
|
||||
▸ **properties**(): `ChainProperties`
|
||||
- **summary**: Get a custom set of properties as a JSON object, defined in the chain spec
|
||||
|
||||
▸ **version**(): `Text`
|
||||
- **summary**: Retrieves the version of the node
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "substrate",
|
||||
"description": "These are keys that are always available to the runtime implementation",
|
||||
"items": [
|
||||
{
|
||||
"name": "changesTrieConfig(): `u32`",
|
||||
"summary": "Changes trie configuration is stored under this key."
|
||||
},
|
||||
{
|
||||
"name": "childStorageKeyPrefix(): `u32`",
|
||||
"summary": "Prefix of child storage keys."
|
||||
},
|
||||
{
|
||||
"name": "code(): `Bytes`",
|
||||
"summary": "Wasm code of the runtime."
|
||||
},
|
||||
{
|
||||
"name": "extrinsicIndex(): `u32`",
|
||||
"summary": "Current extrinsic index (u32) is stored under this key."
|
||||
},
|
||||
{
|
||||
"name": "heapPages(): `u64`",
|
||||
"summary": "Number of wasm linear memory pages required for execution of the runtime."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
|
||||
---
|
||||
|
||||
### substrate
|
||||
|
||||
_These are keys that are always available to the runtime implementation_
|
||||
|
||||
▸ **changesTrieConfig**(): `u32`
|
||||
- **summary**: Changes trie configuration is stored under this key.
|
||||
|
||||
▸ **childStorageKeyPrefix**(): `u32`
|
||||
- **summary**: Prefix of child storage keys.
|
||||
|
||||
▸ **code**(): `Bytes`
|
||||
- **summary**: Wasm code of the runtime.
|
||||
|
||||
▸ **extrinsicIndex**(): `u32`
|
||||
- **summary**: Current extrinsic index (u32) is stored under this key.
|
||||
|
||||
▸ **heapPages**(): `u64`
|
||||
- **summary**: Number of wasm linear memory pages required for execution of the runtime.
|
||||
|
||||
---
|
||||
@@ -1,545 +0,0 @@
|
||||
## Storage
|
||||
|
||||
The following sections contain Storage methods are part of the default Substrate runtime. On the api, these are exposed via `api.query.<module>.<method>`.
|
||||
|
||||
(NOTE: These were generated from a static/snapshot view of a recent Substrate master node. Some items may not be available in older nodes, or in any customized implementations.)
|
||||
- **[authorship](#authorship)**
|
||||
|
||||
- **[babe](#babe)**
|
||||
|
||||
- **[balances](#balances)**
|
||||
|
||||
- **[contracts](#contracts)**
|
||||
|
||||
- **[council](#council)**
|
||||
|
||||
- **[democracy](#democracy)**
|
||||
|
||||
- **[elections](#elections)**
|
||||
|
||||
- **[grandpa](#grandpa)**
|
||||
|
||||
- **[imOnline](#imOnline)**
|
||||
|
||||
- **[indices](#indices)**
|
||||
|
||||
- **[offences](#offences)**
|
||||
|
||||
- **[session](#session)**
|
||||
|
||||
- **[staking](#staking)**
|
||||
|
||||
- **[sudo](#sudo)**
|
||||
|
||||
- **[system](#system)**
|
||||
|
||||
- **[technicalCommittee](#technicalCommittee)**
|
||||
|
||||
- **[technicalMembership](#technicalMembership)**
|
||||
|
||||
- **[timestamp](#timestamp)**
|
||||
|
||||
- **[treasury](#treasury)**
|
||||
|
||||
- **[substrate](#substrate)**
|
||||
|
||||
|
||||
___
|
||||
|
||||
|
||||
### authorship
|
||||
|
||||
▸ **author**(): `Option<AccountId>`
|
||||
- **summary**: Author of current block.
|
||||
|
||||
▸ **didSetUncles**(): `bool`
|
||||
- **summary**: Whether uncles were already set in this block.
|
||||
|
||||
▸ **uncles**(): `Vec<UncleEntryItem>`
|
||||
- **summary**: Uncles
|
||||
|
||||
___
|
||||
|
||||
|
||||
### babe
|
||||
|
||||
▸ **authorities**(): `Vec<(AuthorityId,BabeAuthorityWeight)>`
|
||||
- **summary**: Current epoch authorities.
|
||||
|
||||
▸ **currentSlot**(): `u64`
|
||||
- **summary**: Current slot number.
|
||||
|
||||
▸ **epochIndex**(): `u64`
|
||||
- **summary**: Current epoch index.
|
||||
|
||||
▸ **genesisSlot**(): `u64`
|
||||
- **summary**: The slot at which the first epoch actually started. This is 0 until the first block of the chain.
|
||||
|
||||
▸ **initialized**(): `Option<MaybeVrf>`
|
||||
- **summary**: Temporary value (cleared at block finalization) which is `Some` if per-block initialization has already been called for current block.
|
||||
|
||||
▸ **nextRandomness**(): `[u8;32]`
|
||||
- **summary**: Next epoch randomness.
|
||||
|
||||
▸ **randomness**(): `[u8;32]`
|
||||
- **summary**: The epoch randomness for the *current* epoch. # Security This MUST NOT be used for gambling, as it can be influenced by a malicious validator in the short term. It MAY be used in many cryptographic protocols, however, so long as one remembers that this (like everything else on-chain) it is public. For example, it can be used where a number is needed that cannot have been chosen by an adversary, for purposes such as public-coin zero-knowledge proofs.
|
||||
|
||||
▸ **segmentIndex**(): `u32`
|
||||
- **summary**: Randomness under construction. We make a tradeoff between storage accesses and list length. We store the under-construction randomness in segments of up to `UNDER_CONSTRUCTION_SEGMENT_LENGTH`. Once a segment reaches this length, we begin the next one. We reset all segments and return to `0` at the beginning of every epoch.
|
||||
|
||||
▸ **underConstruction**(`u32`): `Vec<[u8;32]>`
|
||||
|
||||
___
|
||||
|
||||
|
||||
### balances
|
||||
|
||||
▸ **freeBalance**(`AccountId`): `Balance`
|
||||
- **summary**: The 'free' balance of a given account. This is the only balance that matters in terms of most operations on tokens. It alone is used to determine the balance when in the contract execution environment. When this balance falls below the value of `ExistentialDeposit`, then the 'current account' is deleted: specifically `FreeBalance`. Further, the `OnFreeBalanceZero` callback is invoked, giving a chance to external modules to clean up data associated with the deleted account. `system::AccountNonce` is also deleted if `ReservedBalance` is also zero (it also gets collapsed to zero if it ever becomes less than `ExistentialDeposit`.
|
||||
|
||||
▸ **locks**(`AccountId`): `Vec<BalanceLock>`
|
||||
- **summary**: Any liquidity locks on some account balances.
|
||||
|
||||
▸ **reservedBalance**(`AccountId`): `Balance`
|
||||
- **summary**: The amount of the balance of a given account that is externally reserved; this can still get slashed, but gets slashed last of all. This balance is a 'reserve' balance that other subsystems use in order to set aside tokens that are still 'owned' by the account holder, but which are suspendable. When this balance falls below the value of `ExistentialDeposit`, then this 'reserve account' is deleted: specifically, `ReservedBalance`. `system::AccountNonce` is also deleted if `FreeBalance` is also zero (it also gets collapsed to zero if it ever becomes less than `ExistentialDeposit`.)
|
||||
|
||||
▸ **totalIssuance**(): `Balance`
|
||||
- **summary**: The total units issued in the system.
|
||||
|
||||
▸ **vesting**(`AccountId`): `Option<VestingSchedule>`
|
||||
- **summary**: Information regarding the vesting of a given account.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### contracts
|
||||
|
||||
▸ **accountCounter**(): `u64`
|
||||
- **summary**: The subtrie counter.
|
||||
|
||||
▸ **codeStorage**(`CodeHash`): `Option<PrefabWasmModule>`
|
||||
- **summary**: A mapping between an original code hash and instrumented wasm code, ready for execution.
|
||||
|
||||
▸ **contractInfoOf**(`AccountId`): `Option<ContractInfo>`
|
||||
- **summary**: The code associated with a given account.
|
||||
|
||||
▸ **currentSchedule**(): `Schedule`
|
||||
- **summary**: Current cost schedule for contracts.
|
||||
|
||||
▸ **gasPrice**(): `BalanceOf`
|
||||
- **summary**: The price of one unit of gas.
|
||||
|
||||
▸ **gasSpent**(): `Gas`
|
||||
- **summary**: Gas spent so far in this block.
|
||||
|
||||
▸ **pristineCode**(`CodeHash`): `Option<Bytes>`
|
||||
- **summary**: A mapping from an original code hash to the original code, untouched by instrumentation.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### council
|
||||
|
||||
▸ **members**(): `Vec<AccountId>`
|
||||
- **summary**: The current members of the collective. This is stored sorted (just by value).
|
||||
|
||||
▸ **proposalCount**(): `u32`
|
||||
- **summary**: Proposals so far.
|
||||
|
||||
▸ **proposalOf**(`Hash`): `Option<Proposal>`
|
||||
- **summary**: Actual proposal for a given hash, if it's current.
|
||||
|
||||
▸ **proposals**(): `Vec<Hash>`
|
||||
- **summary**: The hashes of the active proposals.
|
||||
|
||||
▸ **voting**(`Hash`): `Option<Votes>`
|
||||
- **summary**: Votes on a given proposal, if it is ongoing.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### democracy
|
||||
|
||||
▸ **blacklist**(`Hash`): `Option<(BlockNumber,Vec<AccountId>)>`
|
||||
- **summary**: A record of who vetoed what. Maps proposal hash to a possible existent block number (until when it may not be resubmitted) and who vetoed it.
|
||||
|
||||
▸ **cancellations**(`Hash`): `bool`
|
||||
- **summary**: Record of all proposals that have been subject to emergency cancellation.
|
||||
|
||||
▸ **delegations**(`AccountId`): `((AccountId,Conviction), Linkage<AccountId>)`
|
||||
- **summary**: Get the account (and lock periods) to which another account is delegating vote.
|
||||
|
||||
▸ **depositOf**(`PropIndex`): `Option<(BalanceOf,Vec<AccountId>)>`
|
||||
- **summary**: Those who have locked a deposit.
|
||||
|
||||
▸ **dispatchQueue**(`BlockNumber`): `Vec<Option<(Proposal,ReferendumIndex)>>`
|
||||
- **summary**: Queue of successful referenda to be dispatched.
|
||||
|
||||
▸ **lastTabledWasExternal**(): `bool`
|
||||
- **summary**: True if the last referendum tabled was submitted externally. False if it was a public proposal.
|
||||
|
||||
▸ **nextExternal**(): `Option<(Proposal,VoteThreshold)>`
|
||||
- **summary**: The referendum to be tabled whenever it would be valid to table an external proposal. This happens when a referendum needs to be tabled and one of two conditions are met: - `LastTabledWasExternal` is `false`; or - `PublicProps` is empty.
|
||||
|
||||
▸ **nextTally**(): `ReferendumIndex`
|
||||
- **summary**: The next referendum index that should be tallied.
|
||||
|
||||
▸ **proxy**(`AccountId`): `Option<AccountId>`
|
||||
- **summary**: Who is able to vote for whom. Value is the fund-holding account, key is the vote-transaction-sending account.
|
||||
|
||||
▸ **publicPropCount**(): `PropIndex`
|
||||
- **summary**: The number of (public) proposals that have been made so far.
|
||||
|
||||
▸ **publicProps**(): `Vec<(PropIndex,Proposal,AccountId)>`
|
||||
- **summary**: The public proposals. Unsorted.
|
||||
|
||||
▸ **referendumCount**(): `ReferendumIndex`
|
||||
- **summary**: The next free referendum index, aka the number of referenda started so far.
|
||||
|
||||
▸ **referendumInfoOf**(`ReferendumIndex`): `Option<ReferendumInfo>`
|
||||
- **summary**: Information concerning any given referendum.
|
||||
|
||||
▸ **voteOf**(`(ReferendumIndex,AccountId)`): `Vote`
|
||||
- **summary**: Get the vote in a given referendum of a particular voter. The result is meaningful only if `voters_for` includes the voter when called with the referendum (you'll get the default `Vote` value otherwise). If you don't want to check `voters_for`, then you can also check for simple existence with `VoteOf::exists` first.
|
||||
|
||||
▸ **votersFor**(`ReferendumIndex`): `Vec<AccountId>`
|
||||
- **summary**: Get the voters for the current proposal.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### elections
|
||||
|
||||
▸ **approvalsOf**(`(AccountId,SetIndex)`): `Vec<ApprovalFlag>`
|
||||
|
||||
▸ **candidateCount**(): `u32`
|
||||
- **summary**: Current number of active candidates
|
||||
|
||||
▸ **candidates**(): `Vec<AccountId>`
|
||||
- **summary**: The present candidate list.
|
||||
|
||||
▸ **desiredSeats**(): `u32`
|
||||
- **summary**: Number of accounts that should constitute the collective.
|
||||
|
||||
▸ **leaderboard**(): `Option<Vec<(BalanceOf,AccountId)>>`
|
||||
- **summary**: Get the leaderboard if we're in the presentation phase. The first element is the weight of each entry; It may be the direct summed approval stakes, or a weighted version of it. Sorted from low to high.
|
||||
|
||||
▸ **members**(): `Vec<(AccountId,BlockNumber)>`
|
||||
- **summary**: The current membership. When there's a vote going on, this should still be used for executive matters. The block number (second element in the tuple) is the block that their position is active until (calculated by the sum of the block number when the member was elected and their term duration).
|
||||
|
||||
▸ **nextFinalize**(): `Option<(BlockNumber,u32,Vec<AccountId>)>`
|
||||
- **summary**: The accounts holding the seats that will become free on the next tally.
|
||||
|
||||
▸ **nextVoterSet**(): `SetIndex`
|
||||
- **summary**: the next free set to store a voter in. This will keep growing.
|
||||
|
||||
▸ **presentationDuration**(): `BlockNumber`
|
||||
- **summary**: How long to give each top candidate to present themselves after the vote ends.
|
||||
|
||||
▸ **proxy**(`AccountId`): `Option<AccountId>`
|
||||
- **summary**: Who is able to vote for whom. Value is the fund-holding account, key is the vote-transaction-sending account.
|
||||
|
||||
▸ **registerInfoOf**(`AccountId`): `Option<(VoteIndex,u32)>`
|
||||
- **summary**: The vote index and list slot that the candidate `who` was registered or `None` if they are not currently registered.
|
||||
|
||||
▸ **termDuration**(): `BlockNumber`
|
||||
- **summary**: How long each position is active for.
|
||||
|
||||
▸ **voteCount**(): `VoteIndex`
|
||||
- **summary**: The total number of vote rounds that have happened or are in progress.
|
||||
|
||||
▸ **voterCount**(): `SetIndex`
|
||||
- **summary**: Current number of Voters.
|
||||
|
||||
▸ **voterInfoOf**(`AccountId`): `Option<VoterInfo>`
|
||||
- **summary**: Basic information about a voter.
|
||||
|
||||
▸ **voters**(`SetIndex`): `Vec<Option<AccountId>>`
|
||||
- **summary**: The present voter list (chunked and capped at [`VOTER_SET_SIZE`]).
|
||||
|
||||
___
|
||||
|
||||
|
||||
### grandpa
|
||||
|
||||
▸ **authorities**(): `Vec<(AuthorityId,AuthorityWeight)>`
|
||||
- **summary**: The current authority set.
|
||||
|
||||
▸ **currentSetId**(): `SetId`
|
||||
- **summary**: The number of changes (both in terms of keys and underlying economic responsibilities) in the "set" of Grandpa validators from genesis.
|
||||
|
||||
▸ **nextForced**(): `Option<BlockNumber>`
|
||||
- **summary**: next block number where we can force a change.
|
||||
|
||||
▸ **pendingChange**(): `Option<StoredPendingChange>`
|
||||
- **summary**: Pending change: (signaled at, scheduled change).
|
||||
|
||||
▸ **setIdSession**(`SetId`): `Option<SessionIndex>`
|
||||
- **summary**: A mapping from grandpa set ID to the index of the *most recent* session for which its members were responsible.
|
||||
|
||||
▸ **stalled**(): `Option<(BlockNumber,BlockNumber)>`
|
||||
- **summary**: `true` if we are currently stalled.
|
||||
|
||||
▸ **state**(): `StoredState`
|
||||
- **summary**: State of the current authority set.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### imOnline
|
||||
|
||||
▸ **gossipAt**(): `BlockNumber`
|
||||
- **summary**: The block number when we should gossip.
|
||||
|
||||
▸ **keys**(): `Vec<AuthorityId>`
|
||||
- **summary**: The current set of keys that may issue a heartbeat.
|
||||
|
||||
▸ **receivedHeartbeats**(`SessionIndex, AuthIndex`): `Bytes`
|
||||
- **summary**: For each session index we keep a mapping of `AuthorityId` to `offchain::OpaqueNetworkState`.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### indices
|
||||
|
||||
▸ **enumSet**(`AccountIndex`): `Vec<AccountId>`
|
||||
- **summary**: The enumeration sets.
|
||||
|
||||
▸ **nextEnumSet**(): `AccountIndex`
|
||||
- **summary**: The next free enumeration set.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### offences
|
||||
|
||||
▸ **concurrentReportsIndex**(`Kind, OpaqueTimeSlot`): `Vec<ReportIdOf>`
|
||||
- **summary**: A vector of reports of the same kind that happened at the same time slot.
|
||||
|
||||
▸ **reports**(`ReportIdOf`): `Option<OffenceDetails>`
|
||||
- **summary**: The primary structure that holds all offence records keyed by report identifiers.
|
||||
|
||||
▸ **reportsByKindIndex**(`Kind`): `Bytes`
|
||||
- **summary**: Enumerates all reports of a kind along with the time they happened. All reports are sorted by the time of offence. Note that the actual type of this mapping is `Vec<u8>`, this is because values of different types are not supported at the moment so we are doing the manual serialization.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### session
|
||||
|
||||
▸ **currentIndex**(): `SessionIndex`
|
||||
- **summary**: Current index of the session.
|
||||
|
||||
▸ **disabledValidators**(): `Vec<u32>`
|
||||
- **summary**: Indices of disabled validators. The set is cleared when `on_session_ending` returns a new set of identities.
|
||||
|
||||
▸ **keyOwner**(`Bytes, (KeyTypeId,Bytes)`): `Option<ValidatorId>`
|
||||
- **summary**: The owner of a key. The second key is the `KeyTypeId` + the encoded key. The first key is always `DEDUP_KEY_PREFIX` to have all the data in the same branch of the trie. Having all data in the same branch should prevent slowing down other queries.
|
||||
|
||||
▸ **nextKeys**(`Bytes, ValidatorId`): `Option<Keys>`
|
||||
- **summary**: The next session keys for a validator. The first key is always `DEDUP_KEY_PREFIX` to have all the data in the same branch of the trie. Having all data in the same branch should prevent slowing down other queries.
|
||||
|
||||
▸ **queuedChanged**(): `bool`
|
||||
- **summary**: True if the underlying economic identities or weighting behind the validators has changed in the queued validator set.
|
||||
|
||||
▸ **queuedKeys**(): `Vec<(ValidatorId,Keys)>`
|
||||
- **summary**: The queued keys for the next session. When the next session begins, these keys will be used to determine the validator's session keys.
|
||||
|
||||
▸ **validators**(): `Vec<ValidatorId>`
|
||||
- **summary**: The current set of validators.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### staking
|
||||
|
||||
▸ **bonded**(`AccountId`): `Option<AccountId>`
|
||||
- **summary**: Map from all locked "stash" accounts to the controller account.
|
||||
|
||||
▸ **bondedEras**(): `Vec<(EraIndex,SessionIndex)>`
|
||||
- **summary**: A mapping from still-bonded eras to the first session index of that era.
|
||||
|
||||
▸ **currentElected**(): `Vec<AccountId>`
|
||||
- **summary**: The currently elected validator set keyed by stash account ID.
|
||||
|
||||
▸ **currentEra**(): `EraIndex`
|
||||
- **summary**: The current era index.
|
||||
|
||||
▸ **currentEraPointsEarned**(): `EraPoints`
|
||||
- **summary**: Rewards for the current era. Using indices of current elected set.
|
||||
|
||||
▸ **currentEraStart**(): `MomentOf`
|
||||
- **summary**: The start of the current era.
|
||||
|
||||
▸ **currentEraStartSessionIndex**(): `SessionIndex`
|
||||
- **summary**: The session index at which the current era started.
|
||||
|
||||
▸ **eraSlashJournal**(`EraIndex`): `Vec<SlashJournalEntry>`
|
||||
- **summary**: All slashes that have occurred in a given era.
|
||||
|
||||
▸ **forceEra**(): `Forcing`
|
||||
- **summary**: True if the next session change will be a new era regardless of index.
|
||||
|
||||
▸ **invulnerables**(): `Vec<AccountId>`
|
||||
- **summary**: Any validators that may never be slashed or forcibly kicked. It's a Vec since they're easy to initialize and the performance hit is minimal (we expect no more than four invulnerables) and restricted to testnets.
|
||||
|
||||
▸ **ledger**(`AccountId`): `Option<StakingLedger>`
|
||||
- **summary**: Map from all (unlocked) "controller" accounts to the info regarding the staking.
|
||||
|
||||
▸ **minimumValidatorCount**(): `u32`
|
||||
- **summary**: Minimum number of staking participants before emergency conditions are imposed.
|
||||
|
||||
▸ **nominators**(`AccountId`): `(Vec<AccountId>, Linkage<AccountId>)`
|
||||
- **summary**: The map from nominator stash key to the set of stash keys of all validators to nominate.
|
||||
|
||||
▸ **payee**(`AccountId`): `RewardDestination`
|
||||
- **summary**: Where the reward payment should be made. Keyed by stash.
|
||||
|
||||
▸ **slashRewardFraction**(): `Perbill`
|
||||
- **summary**: The percentage of the slash that is distributed to reporters. The rest of the slashed value is handled by the `Slash`.
|
||||
|
||||
▸ **slotStake**(): `BalanceOf`
|
||||
- **summary**: The amount of balance actively at stake for each validator slot, currently. This is used to derive rewards and punishments.
|
||||
|
||||
▸ **stakers**(`AccountId`): `Exposure`
|
||||
- **summary**: Nominators for a particular account that is in action right now. You can't iterate through validators here, but you can find them in the Session module. This is keyed by the stash account.
|
||||
|
||||
▸ **validatorCount**(): `u32`
|
||||
- **summary**: The ideal number of staking participants.
|
||||
|
||||
▸ **validators**(`AccountId`): `(ValidatorPrefs, Linkage<AccountId>)`
|
||||
- **summary**: The map from (wannabe) validator stash key to the preferences of that validator.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### sudo
|
||||
|
||||
▸ **key**(): `AccountId`
|
||||
- **summary**: The `AccountId` of the sudo key.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### system
|
||||
|
||||
▸ **accountNonce**(`AccountId`): `Index`
|
||||
- **summary**: Extrinsics nonce for accounts.
|
||||
|
||||
▸ **allExtrinsicsLen**(): `Option<u32>`
|
||||
- **summary**: Total length (in bytes) for all extrinsics put together, for the current block.
|
||||
|
||||
▸ **allExtrinsicsWeight**(): `Option<Weight>`
|
||||
- **summary**: Total weight for all extrinsics put together, for the current block.
|
||||
|
||||
▸ **blockHash**(`BlockNumber`): `Hash`
|
||||
- **summary**: Map of block numbers to block hashes.
|
||||
|
||||
▸ **digest**(): `DigestOf`
|
||||
- **summary**: Digest of the current block, also part of the block header.
|
||||
|
||||
▸ **eventCount**(): `EventIndex`
|
||||
- **summary**: The number of events in the `Events<T>` list.
|
||||
|
||||
▸ **events**(): `Vec<EventRecord>`
|
||||
- **summary**: Events deposited for the current block.
|
||||
|
||||
▸ **eventTopics**(`Null, Hash`): `Vec<(BlockNumber,EventIndex)>`
|
||||
- **summary**: Mapping between a topic (represented by T::Hash) and a vector of indexes of events in the `<Events<T>>` list. The first key serves no purpose. This field is declared as double_map just for convenience of using `remove_prefix`. All topic vectors have deterministic storage locations depending on the topic. This allows light-clients to leverage the changes trie storage tracking mechanism and in case of changes fetch the list of events of interest. The value has the type `(T::BlockNumber, EventIndex)` because if we used only just the `EventIndex` then in case if the topic has the same contents on the next block no notification will be triggered thus the event might be lost.
|
||||
|
||||
▸ **extrinsicCount**(): `Option<u32>`
|
||||
- **summary**: Total extrinsics count for the current block.
|
||||
|
||||
▸ **extrinsicData**(`u32`): `Bytes`
|
||||
- **summary**: Extrinsics data for the current block (maps an extrinsic's index to its data).
|
||||
|
||||
▸ **extrinsicsRoot**(): `Hash`
|
||||
- **summary**: Extrinsics root of the current block, also part of the block header.
|
||||
|
||||
▸ **nextWeightMultiplier**(): `WeightMultiplier`
|
||||
- **summary**: The next weight multiplier. This should be updated at the end of each block based on the saturation level (weight).
|
||||
|
||||
▸ **number**(): `BlockNumber`
|
||||
- **summary**: The current block number being processed. Set by `execute_block`.
|
||||
|
||||
▸ **parentHash**(): `Hash`
|
||||
- **summary**: Hash of the previous block.
|
||||
|
||||
▸ **randomMaterial**(): `(i8,Vec<Hash>)`
|
||||
- **summary**: Series of block headers from the last 81 blocks that acts as random seed material. This is arranged as a ring buffer with the `i8` prefix being the index into the `Vec` of the oldest hash.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### technicalCommittee
|
||||
|
||||
▸ **members**(): `Vec<AccountId>`
|
||||
- **summary**: The current members of the collective. This is stored sorted (just by value).
|
||||
|
||||
▸ **proposalCount**(): `u32`
|
||||
- **summary**: Proposals so far.
|
||||
|
||||
▸ **proposalOf**(`Hash`): `Option<Proposal>`
|
||||
- **summary**: Actual proposal for a given hash, if it's current.
|
||||
|
||||
▸ **proposals**(): `Vec<Hash>`
|
||||
- **summary**: The hashes of the active proposals.
|
||||
|
||||
▸ **voting**(`Hash`): `Option<Votes>`
|
||||
- **summary**: Votes on a given proposal, if it is ongoing.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### technicalMembership
|
||||
|
||||
▸ **members**(): `Vec<AccountId>`
|
||||
- **summary**: The current membership, stored as an ordered Vec.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### timestamp
|
||||
|
||||
▸ **didUpdate**(): `bool`
|
||||
- **summary**: Did the timestamp get updated in this block?
|
||||
|
||||
▸ **now**(): `Moment`
|
||||
- **summary**: Current time for the current block.
|
||||
|
||||
___
|
||||
|
||||
|
||||
### treasury
|
||||
|
||||
▸ **approvals**(): `Vec<ProposalIndex>`
|
||||
- **summary**: Proposal indices that have been approved but not yet awarded.
|
||||
|
||||
▸ **proposalCount**(): `ProposalIndex`
|
||||
- **summary**: Number of proposals that have been made.
|
||||
|
||||
▸ **proposals**(`ProposalIndex`): `Option<TreasuryProposal>`
|
||||
- **summary**: Proposals that have been made.
|
||||
|
||||
---
|
||||
|
||||
### substrate
|
||||
|
||||
_These are keys that are always available to the runtime implementation_
|
||||
|
||||
▸ **changesTrieConfig**(): `u32`
|
||||
- **summary**: Changes trie configuration is stored under this key.
|
||||
|
||||
▸ **childStorageKeyPrefix**(): `u32`
|
||||
- **summary**: Prefix of child storage keys.
|
||||
|
||||
▸ **code**(): `Bytes`
|
||||
- **summary**: Wasm code of the runtime.
|
||||
|
||||
▸ **extrinsicIndex**(): `u32`
|
||||
- **summary**: Current extrinsic index (u32) is stored under this key.
|
||||
|
||||
▸ **heapPages**(): `u64`
|
||||
- **summary**: Number of wasm linear memory pages required for execution of the runtime.
|
||||
|
||||
---
|
||||
+2
-1
@@ -31,5 +31,6 @@ module.exports = Object.assign({}, config, {
|
||||
ws_local_polkadot_alex: 'ws://127.0.0.1:9949/',
|
||||
ws_substrate_1: 'wss://substrate-rpc.parity.io/',
|
||||
ws_polkadot_alex: 'wss://poc3-rpc.polkadot.io/'
|
||||
}
|
||||
},
|
||||
resolver: './jest.resolver.js'
|
||||
});
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright 2017-2020 @polkadot/util authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const path = require('path');
|
||||
|
||||
module.exports = function resolver (file, config) {
|
||||
if (file.includes('package.json')) {
|
||||
return path.join(config.basedir.replace('/src', '/'), file);
|
||||
}
|
||||
|
||||
return config.defaultResolver(file, config);
|
||||
};
|
||||
+1
-1
@@ -9,5 +9,5 @@
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "1.0.1"
|
||||
"version": "1.2.1"
|
||||
}
|
||||
|
||||
+9
-11
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "1.0.1",
|
||||
"version": "1.2.1",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"yarn": "^1.10.1"
|
||||
@@ -8,7 +8,6 @@
|
||||
"packages/*"
|
||||
],
|
||||
"resolutions": {
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"typescript": "^3.7.5"
|
||||
},
|
||||
"scripts": {
|
||||
@@ -17,19 +16,18 @@
|
||||
"circular": "madge --circular --extensions ts ./",
|
||||
"docs": "node packages/types/src/scripts/MetadataMdWrapper.js && polkadot-dev-build-docs",
|
||||
"chain:info": "node packages/types/src/scripts/extractChainWrapper.js",
|
||||
"lint": "eslint --ext .js,.jsx,.ts,.tsx . && tsc --noEmit --pretty",
|
||||
"lint": "polkadot-dev-run-lint",
|
||||
"clean": "polkadot-dev-clean-build",
|
||||
"postinstall": "polkadot-dev-yarn-only",
|
||||
"test": "jest --coverage --runInBand --testPathIgnorePatterns e2e",
|
||||
"test:all": "jest",
|
||||
"test:one": "jest",
|
||||
"test:watch": "jest --coverage --watch"
|
||||
"test": "polkadot-dev-run-test --coverage --runInBand --testPathIgnorePatterns e2e",
|
||||
"test:one": "polkadot-dev-run-test",
|
||||
"test:watch": "polkadot-dev-run-test --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.8.3",
|
||||
"@babel/core": "^7.8.4",
|
||||
"@babel/register": "^7.8.3",
|
||||
"@babel/runtime": "^7.8.3",
|
||||
"@polkadot/dev": "^0.33.3",
|
||||
"@polkadot/ts": "^0.2.1"
|
||||
"@babel/runtime": "^7.8.4",
|
||||
"@polkadot/dev": "^0.40.16",
|
||||
"@polkadot/ts": "^0.2.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-contract",
|
||||
"version": "1.0.1",
|
||||
"version": "1.2.1",
|
||||
"description": "Interfaces for interacting with contracts and contract ABIs",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -26,7 +26,12 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.3",
|
||||
"@polkadot/types": "^1.0.1"
|
||||
"@babel/runtime": "^7.8.4",
|
||||
"@polkadot/api": "^1.2.1",
|
||||
"@polkadot/rpc-core": "^1.2.1",
|
||||
"@polkadot/types": "^1.2.1",
|
||||
"@polkadot/util": "^2.3.1",
|
||||
"bn.js": "^5.1.1",
|
||||
"rxjs": "^6.5.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ export default class Blueprint<ApiType extends ApiTypes> extends BaseWithTx<ApiT
|
||||
private createResult = (result: SubmittableResult): BlueprintCreateResult<ApiType> => {
|
||||
let contract: Contract<ApiType> | undefined;
|
||||
|
||||
if (result.isFinalized) {
|
||||
if (result.isInBlock) {
|
||||
const record = result.findRecord('contract', 'Instantiated');
|
||||
|
||||
if (record) {
|
||||
|
||||
@@ -58,7 +58,7 @@ export default class Code<ApiType extends ApiTypes> extends BaseWithTx<ApiType>
|
||||
private createResult = (result: SubmittableResultImpl): CodePutCodeResult<ApiType> => {
|
||||
let blueprint: Blueprint<ApiType> | undefined;
|
||||
|
||||
if (result.isFinalized) {
|
||||
if (result.isInBlock) {
|
||||
const record = result.findRecord('contract', 'CodeStored');
|
||||
|
||||
if (record) {
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiTypes, DecorateMethod, DecoratedRpc, SubmittableModuleExtrinsics } from '@polkadot/api/types';
|
||||
import { ApiObject, ContractABIMessage, ContractABIPre, ContractBase, ContractMessage } from '../types';
|
||||
import { RpcInterface } from '@polkadot/rpc-core/jsonrpc.types';
|
||||
import { RpcInterface } from '@polkadot/rpc-core/types';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
import { ApiObject, ContractABIMessage, ContractABIPre, ContractBase, ContractMessage } from '../types';
|
||||
|
||||
import { assert, isFunction, stringCamelCase } from '@polkadot/util';
|
||||
import Abi from '../Abi';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-derive",
|
||||
"version": "1.0.1",
|
||||
"version": "1.2.1",
|
||||
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,11 +27,18 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.3",
|
||||
"@polkadot/api": "^1.0.1",
|
||||
"@polkadot/types": "^1.0.1"
|
||||
"@babel/runtime": "^7.8.4",
|
||||
"@polkadot/api": "^1.2.1",
|
||||
"@polkadot/rpc-core": "^1.2.1",
|
||||
"@polkadot/rpc-provider": "^1.2.1",
|
||||
"@polkadot/types": "^1.2.1",
|
||||
"@polkadot/util": "^2.3.1",
|
||||
"@polkadot/util-crypto": "^2.3.1",
|
||||
"bn.js": "^5.1.1",
|
||||
"memoizee": "^0.4.14",
|
||||
"rxjs": "^6.5.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^2.0.1"
|
||||
"@polkadot/keyring": "^2.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,16 +2,39 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId, AccountIndex } from '@polkadot/types/interfaces';
|
||||
import { AccountId, AccountIndex, BalanceOf } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map, startWith } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { ENUMSET_SIZE } from '@polkadot/types/primitive/Generic/AccountIndex';
|
||||
import { ClassOf, Vec, createType } from '@polkadot/types';
|
||||
import { ClassOf, Option, Vec, createType } from '@polkadot/types';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
function queryEnumSet (api: ApiInterfaceRx, _accountIndex: AccountIndex | string): Observable<AccountId | undefined> {
|
||||
const accountIndex = _accountIndex instanceof ClassOf(api.registry, 'AccountIndex')
|
||||
? _accountIndex
|
||||
: createType(api.registry, 'AccountIndex', _accountIndex);
|
||||
|
||||
return api.query.indices.enumSet<Vec<AccountId>>(accountIndex.div(ENUMSET_SIZE)).pipe(
|
||||
startWith([]),
|
||||
map((accounts): AccountId | undefined =>
|
||||
(accounts || [])[accountIndex.mod(ENUMSET_SIZE).toNumber()]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// current
|
||||
function query (api: ApiInterfaceRx, accountIndex: AccountIndex | string): Observable<AccountId | undefined> {
|
||||
return api.query.indices.accounts<Option<ITuple<[AccountId, BalanceOf]>>>(accountIndex).pipe(
|
||||
map((optResult): AccountId | undefined =>
|
||||
optResult.unwrapOr([])[0]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name indexToId
|
||||
* @param {( AccountIndex | string )} accountIndex - An accounts index in different formats.
|
||||
@@ -26,18 +49,11 @@ import { memo } from '../util';
|
||||
* ```
|
||||
*/
|
||||
export function indexToId (api: ApiInterfaceRx): (accountIndex: AccountIndex | string) => Observable<AccountId | undefined> {
|
||||
const querySection = api.query.indices || api.query.balances;
|
||||
|
||||
return memo((_accountIndex: AccountIndex | string): Observable<AccountId | undefined> => {
|
||||
const accountIndex = _accountIndex instanceof ClassOf(api.registry, 'AccountIndex')
|
||||
? _accountIndex
|
||||
: createType(api.registry, 'AccountIndex', _accountIndex);
|
||||
|
||||
return querySection.enumSet<Vec<AccountId>>(accountIndex.div(ENUMSET_SIZE)).pipe(
|
||||
startWith([]),
|
||||
map((accounts): AccountId | undefined =>
|
||||
(accounts || [])[accountIndex.mod(ENUMSET_SIZE).toNumber()]
|
||||
)
|
||||
);
|
||||
});
|
||||
return memo((accountIndex: AccountIndex | string): Observable<AccountId | undefined> =>
|
||||
api.query.indices
|
||||
? api.query.indices.accounts
|
||||
? query(api, accountIndex)
|
||||
: queryEnumSet(api, accountIndex)
|
||||
: of(undefined)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { AccountId, AccountIndex } from '@polkadot/types/interfaces';
|
||||
import { AccountIndexes } from '../types';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { ENUMSET_SIZE } from '@polkadot/types/primitive/Generic/AccountIndex';
|
||||
import { Vec, createType } from '@polkadot/types';
|
||||
@@ -15,6 +15,36 @@ import { memo } from '../util';
|
||||
|
||||
const enumsetSize = ENUMSET_SIZE.toNumber();
|
||||
|
||||
function queryEnumSet (api: ApiInterfaceRx): Observable<AccountIndexes> {
|
||||
return api.query.indices.nextEnumSet<AccountIndex>().pipe(
|
||||
// use the nextEnumSet (which is a counter of the number of sets) to construct
|
||||
// a range of values to query [0, 1, 2, ...]. Retrieve the full enum set for the
|
||||
// specific index - each query can return up to ENUMSET_SIZE (64) records, each
|
||||
// containing an AccountId
|
||||
switchMap((next: AccountIndex): Observable<Vec<AccountId>[]> =>
|
||||
api.query.indices.enumSet.multi<Vec<AccountId>>([...Array(next.toNumber() + 1).keys()])
|
||||
),
|
||||
map((all: AccountId[][]): AccountIndexes =>
|
||||
all.reduce((result: AccountIndexes, list, outerIndex): AccountIndexes => {
|
||||
(list || []).forEach((accountId, innerIndex): void => {
|
||||
// re-create the index based on position 0 is [0][0] and likewise
|
||||
// 64 (0..63 in first) is [1][0] (the first index value in set 2)
|
||||
const index = (outerIndex * enumsetSize) + innerIndex;
|
||||
|
||||
result[accountId.toString()] = createType(api.registry, 'AccountIndex', index);
|
||||
});
|
||||
|
||||
return result;
|
||||
}, {})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// TODO Reverse lookup (via query keys)
|
||||
function query (): Observable<AccountIndexes> {
|
||||
return of({} as AccountIndexes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name indexes
|
||||
* @returns Returns all the indexes on the system.
|
||||
@@ -32,25 +62,10 @@ const enumsetSize = ENUMSET_SIZE.toNumber();
|
||||
*/
|
||||
export function indexes (api: ApiInterfaceRx): () => Observable<AccountIndexes> {
|
||||
return memo((): Observable<AccountIndexes> =>
|
||||
api.query.indices.nextEnumSet<AccountIndex>().pipe(
|
||||
// use the nextEnumSet (which is a counter of the number of sets) to construct
|
||||
// a range of values to query [0, 1, 2, ...]. Retrieve the full enum set for the
|
||||
// specific index - each query can return up to ENUMSET_SIZE (64) records, each
|
||||
// containing an AccountId
|
||||
switchMap((next: AccountIndex): Observable<Vec<AccountId>[]> =>
|
||||
api.query.indices.enumSet.multi<Vec<AccountId>>([...Array(next.toNumber() + 1).keys()])
|
||||
),
|
||||
map((all: AccountId[][]): AccountIndexes =>
|
||||
all.reduce((result: AccountIndexes, list, outerIndex): AccountIndexes => {
|
||||
(list || []).forEach((accountId, innerIndex): void => {
|
||||
// re-create the index based on position 0 is [0][0] and likewise
|
||||
// 64 (0..63 in first) is [1][0] (the first index value in set 2)
|
||||
const index = (outerIndex * enumsetSize) + innerIndex;
|
||||
|
||||
result[accountId.toString()] = createType(api.registry, 'AccountIndex', index);
|
||||
});
|
||||
|
||||
return result;
|
||||
}, {}))
|
||||
));
|
||||
api.query.indices
|
||||
? api.query.indices.accounts
|
||||
? query()
|
||||
: queryEnumSet(api)
|
||||
: of({} as AccountIndexes)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId, AccountData, AccountIndex, Address, Balance, Index } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { DerivedBalancesAccount } from '../types';
|
||||
|
||||
import { combineLatest, of, Observable } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { createType } from '@polkadot/types';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type Result = [Balance, Balance, Balance, Balance, Index];
|
||||
|
||||
function calcBalances (api: ApiInterfaceRx, [accountId, [freeBalance, reservedBalance, frozenFee, frozenMisc, accountNonce]]: [AccountId, Result]): DerivedBalancesAccount {
|
||||
return {
|
||||
accountId,
|
||||
accountNonce,
|
||||
freeBalance,
|
||||
frozenFee,
|
||||
frozenMisc,
|
||||
reservedBalance,
|
||||
votingBalance: createType(api.registry, 'Balance', freeBalance.add(reservedBalance))
|
||||
};
|
||||
}
|
||||
|
||||
// old
|
||||
function queryBalancesFree (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
||||
return api.queryMulti<[Balance, Balance, Index]>([
|
||||
[api.query.balances.freeBalance, accountId],
|
||||
[api.query.balances.reservedBalance, accountId],
|
||||
[api.query.system.accountNonce, accountId]
|
||||
]).pipe(
|
||||
map(([freeBalance, reservedBalance, accountNonce]): Result =>
|
||||
[freeBalance, reservedBalance, createType(api.registry, 'Balance'), createType(api.registry, 'Balance'), accountNonce]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
||||
return api.queryMulti<[AccountData, Index]>([
|
||||
[api.query.balances.account, accountId],
|
||||
[api.query.system.accountNonce, accountId]
|
||||
]).pipe(
|
||||
map(([{ free, reserved, miscFrozen, feeFrozen }, accountNonce]): Result =>
|
||||
[free, reserved, feeFrozen, miscFrozen, accountNonce]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
||||
return api.query.system.account<ITuple<[Index, AccountData]>>(accountId).pipe(
|
||||
map(([accountNonce, { free, reserved, miscFrozen, feeFrozen }]): Result =>
|
||||
[free, reserved, feeFrozen, miscFrozen, accountNonce]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name account
|
||||
* @param {( AccountIndex | AccountId | Address | string )} address - An accounts Id in different formats.
|
||||
* @returns An object containing the results of various balance queries
|
||||
* @example
|
||||
* <BR>
|
||||
*
|
||||
* ```javascript
|
||||
* const ALICE = 'F7Hs';
|
||||
*
|
||||
* api.derive.balances.all(ALICE, ({ accountId, lockedBalance }) => {
|
||||
* console.log(`The account ${accountId} has a locked balance ${lockedBalance} units.`);
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function account (api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DerivedBalancesAccount> {
|
||||
return memo((address: AccountIndex | AccountId | Address | string): Observable<DerivedBalancesAccount> =>
|
||||
api.derive.accounts.info(address).pipe(
|
||||
switchMap(({ accountId }): Observable<[AccountId, Result]> =>
|
||||
(accountId
|
||||
? combineLatest([
|
||||
of(accountId),
|
||||
api.query.system.account
|
||||
? queryCurrent(api, accountId)
|
||||
: api.query.balances.account
|
||||
? queryBalancesAccount(api, accountId)
|
||||
: queryBalancesFree(api, accountId)
|
||||
])
|
||||
: of([createType(api.registry, 'AccountId'), [createType(api.registry, 'Balance'), createType(api.registry, 'Balance'), createType(api.registry, 'Balance'), createType(api.registry, 'Balance'), createType(api.registry, 'Index')]])
|
||||
)
|
||||
),
|
||||
map((result): DerivedBalancesAccount => calcBalances(api, result))
|
||||
));
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId, AccountIndex, Address, Balance, BalanceLock, BlockNumber, Index, VestingSchedule } from '@polkadot/types/interfaces';
|
||||
import { DerivedBalances } from '../types';
|
||||
import { AccountId, AccountIndex, Address, Balance, BalanceLock, BalanceLockTo212, BlockNumber, VestingInfo, VestingSchedule } from '@polkadot/types/interfaces';
|
||||
import { DerivedBalancesAccount, DerivedBalancesAll } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { combineLatest, of, Observable } from 'rxjs';
|
||||
@@ -14,29 +14,32 @@ import { bnMax } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type ResultBalance = [Balance, Balance, BalanceLock[], Option<VestingSchedule>, Index];
|
||||
type Result = [AccountId, BlockNumber, ResultBalance];
|
||||
type ResultBalance = [VestingInfo | null, (BalanceLock | BalanceLockTo212)[]];
|
||||
type Result = [DerivedBalancesAccount, BlockNumber, ResultBalance];
|
||||
|
||||
function calcBalances (api: ApiInterfaceRx, [accountId, bestNumber, [freeBalance, reservedBalance, locks, vesting, accountNonce]]: Result): DerivedBalances {
|
||||
function calcBalances (api: ApiInterfaceRx, [{ accountId, accountNonce, freeBalance, frozenFee, frozenMisc, reservedBalance, votingBalance }, bestNumber, [vesting, locks]]: Result): DerivedBalancesAll {
|
||||
let lockedBalance = createType(api.registry, 'Balance');
|
||||
let lockedBreakdown: BalanceLock[] = [];
|
||||
let lockedBreakdown: (BalanceLock | BalanceLockTo212)[] = [];
|
||||
|
||||
if (Array.isArray(locks)) {
|
||||
// only get the locks that are valid until passed the current block
|
||||
lockedBreakdown = locks.filter(({ until }): boolean => bestNumber && until.gt(bestNumber));
|
||||
lockedBreakdown = (locks as BalanceLockTo212[]).filter(({ until }): boolean => !until || (bestNumber && until.gt(bestNumber)));
|
||||
|
||||
const notAll = lockedBreakdown.filter(({ amount }): boolean => !amount.isMax());
|
||||
|
||||
// get the maximum of the locks according to https://github.com/paritytech/substrate/blob/master/srml/balances/src/lib.rs#L699
|
||||
if (lockedBreakdown.length) {
|
||||
lockedBalance = createType(api.registry, 'Balance', bnMax(...lockedBreakdown.map(({ amount }): Balance => amount)));
|
||||
if (notAll.length) {
|
||||
lockedBalance = createType(api.registry, 'Balance', bnMax(...notAll.map(({ amount }): Balance => amount)));
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate the vesting balances,
|
||||
// - offset = balance locked at genesis,
|
||||
// - offset = balance locked at startingBlock
|
||||
// - perBlock is the unlock amount
|
||||
const { offset: vestingTotal, perBlock } = vesting.unwrapOr(createType(api.registry, 'VestingSchedule'));
|
||||
const vestedBalance = createType(api.registry, 'Balance', perBlock.mul(bestNumber));
|
||||
const isVesting = vestedBalance.lt(vestingTotal);
|
||||
const { locked: vestingTotal, perBlock, startingBlock } = vesting || createType(api.registry, 'VestingInfo');
|
||||
const isStarted = bestNumber.gt(startingBlock);
|
||||
const vestedBalance = createType(api.registry, 'Balance', isStarted ? perBlock.mul(bestNumber.sub(startingBlock)) : 0);
|
||||
const isVesting = isStarted && vestedBalance.lt(vestingTotal);
|
||||
|
||||
// The available balance & vested has an interplay here
|
||||
// "
|
||||
@@ -54,16 +57,58 @@ function calcBalances (api: ApiInterfaceRx, [accountId, bestNumber, [freeBalance
|
||||
accountNonce,
|
||||
availableBalance,
|
||||
freeBalance,
|
||||
frozenFee,
|
||||
frozenMisc,
|
||||
isVesting,
|
||||
lockedBalance,
|
||||
lockedBreakdown,
|
||||
reservedBalance,
|
||||
vestedBalance,
|
||||
vestingTotal,
|
||||
votingBalance: createType(api.registry, 'Balance', freeBalance.add(reservedBalance))
|
||||
votingBalance
|
||||
};
|
||||
}
|
||||
|
||||
// old
|
||||
function queryOld (api: ApiInterfaceRx, accountId: AccountId): Observable<ResultBalance> {
|
||||
return api.queryMulti<[Vec<BalanceLock>, Option<VestingSchedule>]>([
|
||||
[api.query.balances.locks, accountId],
|
||||
[api.query.balances.vesting, accountId]
|
||||
]).pipe(
|
||||
map(([locks, optVesting]): ResultBalance => {
|
||||
let vestingNew = null;
|
||||
|
||||
if (optVesting.isSome) {
|
||||
const { offset: locked, perBlock, startingBlock } = optVesting.unwrap();
|
||||
|
||||
vestingNew = createType(api.registry, 'VestingInfo', { locked, perBlock, startingBlock });
|
||||
}
|
||||
|
||||
return [vestingNew, locks];
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// current (balances vesting)
|
||||
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<ResultBalance> {
|
||||
return (
|
||||
api.query.vesting.vesting
|
||||
? api.queryMulti<[Vec<BalanceLock>, Option<VestingInfo>]>([
|
||||
[api.query.balances.locks, accountId],
|
||||
[api.query.vesting.vesting, accountId]
|
||||
])
|
||||
: api.query.balances.locks(accountId).pipe(
|
||||
map((locks): [Vec<BalanceLock>, Option<VestingInfo>] =>
|
||||
[locks, createType(api.registry, 'Option<VestingInfo>')]
|
||||
)
|
||||
)
|
||||
).pipe(
|
||||
map(([locks, optVesting]): ResultBalance =>
|
||||
[optVesting.unwrapOr(null), locks]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name all
|
||||
* @param {( AccountIndex | AccountId | Address | string )} address - An accounts Id in different formats.
|
||||
@@ -79,25 +124,21 @@ function calcBalances (api: ApiInterfaceRx, [accountId, bestNumber, [freeBalance
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function all (api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DerivedBalances> {
|
||||
return memo((address: AccountIndex | AccountId | Address | string): Observable<DerivedBalances> =>
|
||||
api.derive.accounts.info(address).pipe(
|
||||
switchMap(({ accountId }): Observable<Result> =>
|
||||
(accountId
|
||||
export function all (api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DerivedBalancesAll> {
|
||||
return memo((address: AccountIndex | AccountId | Address | string): Observable<DerivedBalancesAll> =>
|
||||
api.derive.balances.account(address).pipe(
|
||||
switchMap((account): Observable<Result> =>
|
||||
(!account.accountId.isEmpty
|
||||
? combineLatest([
|
||||
of(accountId),
|
||||
of(account),
|
||||
api.derive.chain.bestNumber(),
|
||||
api.queryMulti<[Balance, Balance, Vec<BalanceLock>, Option<VestingSchedule>, Index]>([
|
||||
[api.query.balances.freeBalance, accountId],
|
||||
[api.query.balances.reservedBalance, accountId],
|
||||
[api.query.balances.locks, accountId],
|
||||
[api.query.balances.vesting, accountId],
|
||||
[api.query.system.accountNonce, accountId]
|
||||
])
|
||||
api.query.balances.account
|
||||
? queryCurrent(api, account.accountId)
|
||||
: queryOld(api, account.accountId)
|
||||
])
|
||||
: of([createType(api.registry, 'AccountId'), createType(api.registry, 'BlockNumber'), [createType(api.registry, 'Balance'), createType(api.registry, 'Balance'), createType(api.registry, 'Vec<BalanceLock>'), createType(api.registry, 'Option<VestingSchedule>', null), createType(api.registry, 'Index')]])
|
||||
: of([account, createType(api.registry, 'BlockNumber'), [null, createType(api.registry, 'Vec<BalanceLock>')]])
|
||||
)
|
||||
),
|
||||
map((result): DerivedBalances => calcBalances(api, result))
|
||||
map((result): DerivedBalancesAll => calcBalances(api, result))
|
||||
));
|
||||
}
|
||||
|
||||
@@ -8,22 +8,22 @@ import { DerivedFees } from '../types';
|
||||
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { createType } from '@polkadot/types';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type Result = [Balance, Balance, Balance, Balance, Balance];
|
||||
|
||||
function query (api: ApiInterfaceRx): Observable<Result> {
|
||||
const paymentBase = api.consts.transactionPayment || api.consts.balances;
|
||||
|
||||
return of([
|
||||
// get values from api.const for substrate versions post spec_version: 101
|
||||
// https://github.com/paritytech/substrate/pull/2883/files#diff-5e5e1c3aec9ddfde0a9054d062ab3db9R131
|
||||
api.consts.balances.creationFee,
|
||||
// deprecated - remove
|
||||
(api.consts.balances.creationFee as Balance) || createType(api.registry, 'Balance'),
|
||||
(api.consts.balances.transferFee as Balance) || createType(api.registry, 'Balance'),
|
||||
|
||||
// current
|
||||
api.consts.balances.existentialDeposit,
|
||||
api.consts.balances.transferFee,
|
||||
paymentBase.transactionBaseFee as Balance,
|
||||
paymentBase.transactionByteFee as Balance
|
||||
api.consts.transactionPayment.transactionBaseFee,
|
||||
api.consts.transactionPayment.transactionByteFee
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ function query (api: ApiInterfaceRx): Observable<Result> {
|
||||
export function fees (api: ApiInterfaceRx): () => Observable<DerivedFees> {
|
||||
return memo((): Observable<DerivedFees> =>
|
||||
query(api).pipe(
|
||||
map(([creationFee, existentialDeposit, transferFee, transactionBaseFee, transactionByteFee]): DerivedFees => ({
|
||||
map(([creationFee, transferFee, existentialDeposit, transactionBaseFee, transactionByteFee]): DerivedFees => ({
|
||||
creationFee,
|
||||
existentialDeposit,
|
||||
transactionBaseFee,
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
import { all } from './all';
|
||||
|
||||
export * from './account';
|
||||
export * from './fees';
|
||||
export * from './votingBalances';
|
||||
export * from './votingBalancesNominatorsFor';
|
||||
|
||||
const votingBalance = all;
|
||||
|
||||
|
||||
@@ -3,20 +3,20 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
|
||||
import { DerivedBalances } from '../types';
|
||||
import { DerivedBalancesAccount } from '../types';
|
||||
|
||||
import { combineLatest, Observable, of } from 'rxjs';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
export function votingBalances (api: ApiInterfaceRx): (addresses?: (AccountId | AccountIndex | Address | string)[]) => Observable<DerivedBalances[]> {
|
||||
return memo((addresses?: (AccountId | AccountIndex | Address | string)[]): Observable<DerivedBalances[]> =>
|
||||
export function votingBalances (api: ApiInterfaceRx): (addresses?: (AccountId | AccountIndex | Address | string)[]) => Observable<DerivedBalancesAccount[]> {
|
||||
return memo((addresses?: (AccountId | AccountIndex | Address | string)[]): Observable<DerivedBalancesAccount[]> =>
|
||||
!addresses || !addresses.length
|
||||
? of([] as DerivedBalances[])
|
||||
? of([] as DerivedBalancesAccount[])
|
||||
: combineLatest(
|
||||
addresses.map((accountId): Observable<DerivedBalances> =>
|
||||
api.derive.balances.all(accountId))
|
||||
addresses.map((accountId): Observable<DerivedBalancesAccount> =>
|
||||
api.derive.balances.account(accountId))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
|
||||
import { DerivedBalances } from '../types';
|
||||
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Vec } from '@polkadot/types';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
export function votingBalancesNominatorsFor (api: ApiInterfaceRx): (address: AccountId | AccountIndex | Address | string) => Observable<DerivedBalances[]> {
|
||||
return memo((address: AccountId | AccountIndex | Address | string): Observable<DerivedBalances[]> =>
|
||||
api.derive.accounts.info(address).pipe(
|
||||
switchMap(({ accountId }): Observable<AccountId[]> =>
|
||||
accountId
|
||||
? api.query.staking.nominatorsFor<Vec<AccountId>>(accountId)
|
||||
: of([] as AccountId[])
|
||||
),
|
||||
switchMap((accounts): Observable<DerivedBalances[]> =>
|
||||
api.derive.balances.votingBalances(accounts)
|
||||
)
|
||||
));
|
||||
}
|
||||
@@ -8,42 +8,27 @@ import { DerivedContractFees } from '../types';
|
||||
import BN from 'bn.js';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { createType } from '@polkadot/types';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type ResultV2 = [BN, BN, BN, BN, BN, BN, BN, BN, BN, BN];
|
||||
|
||||
const ZERO = new BN(0);
|
||||
|
||||
// parse the result
|
||||
function parseResult ([callBaseFee, contractFee, createBaseFee, creationFee, rentByteFee, rentDepositOffset, tombstoneDeposit, transactionBaseFee, transactionByteFee, transferFee]: ResultV2): DerivedContractFees {
|
||||
return {
|
||||
callBaseFee,
|
||||
contractFee,
|
||||
createBaseFee,
|
||||
creationFee,
|
||||
rentByteFee,
|
||||
rentDepositOffset,
|
||||
tombstoneDeposit,
|
||||
transactionBaseFee,
|
||||
transactionByteFee,
|
||||
transferFee
|
||||
};
|
||||
}
|
||||
type ResultV2 = [BN, BN, BN, BN, BN, BN, BN, BN, BN];
|
||||
|
||||
// query via constants (current applicable path)
|
||||
function queryConstants (api: ApiInterfaceRx): Observable<ResultV2> {
|
||||
return of([
|
||||
// deprecated
|
||||
api.consts.contracts.creationFee || createType(api.registry, 'Balance'),
|
||||
api.consts.contracts.transferFee || createType(api.registry, 'Balance'),
|
||||
|
||||
// current
|
||||
api.consts.contracts.callBaseFee,
|
||||
api.consts.contracts.contractFee,
|
||||
api.consts.contracts.createBaseFee,
|
||||
api.consts.contracts.creationFee,
|
||||
api.consts.contracts.rentByteFee,
|
||||
api.consts.contracts.rentDepositOffset,
|
||||
api.consts.contracts.tombstoneDeposit,
|
||||
api.consts.contracts.transactionBaseFee,
|
||||
api.consts.contracts.transactionByteFee,
|
||||
api.consts.contracts.transferFee
|
||||
api.consts.contracts.transactionByteFee
|
||||
]) as unknown as Observable<ResultV2>;
|
||||
}
|
||||
|
||||
@@ -62,17 +47,18 @@ function queryConstants (api: ApiInterfaceRx): Observable<ResultV2> {
|
||||
*/
|
||||
export function fees (api: ApiInterfaceRx): () => Observable<DerivedContractFees> {
|
||||
return memo((): Observable<DerivedContractFees> => {
|
||||
return (
|
||||
api.consts.contracts
|
||||
? queryConstants(api)
|
||||
: of([ZERO, ZERO, ZERO, ZERO, ZERO, ZERO, ZERO, ZERO, ZERO, ZERO])
|
||||
).pipe(
|
||||
map(([callBaseFee, contractFee, createBaseFee, creationFee, rentByteFee, rentDepositOffset, tombstoneDeposit, transactionBaseFee, transactionByteFee, transferFee]): DerivedContractFees =>
|
||||
// We've done this on purpose, i.e. so we can just copy the name/order from the parse above and see gaps
|
||||
parseResult([
|
||||
callBaseFee, contractFee, createBaseFee, creationFee, rentByteFee, rentDepositOffset, tombstoneDeposit, transactionBaseFee, transactionByteFee, transferFee
|
||||
])
|
||||
)
|
||||
return queryConstants(api).pipe(
|
||||
map(([creationFee, transferFee, callBaseFee, contractFee, rentByteFee, rentDepositOffset, tombstoneDeposit, transactionBaseFee, transactionByteFee]): DerivedContractFees => ({
|
||||
callBaseFee,
|
||||
contractFee,
|
||||
creationFee,
|
||||
rentByteFee,
|
||||
rentDepositOffset,
|
||||
tombstoneDeposit,
|
||||
transactionBaseFee,
|
||||
transactionByteFee,
|
||||
transferFee
|
||||
}))
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@ import { map, switchMap } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Vec, createType } from '@polkadot/types';
|
||||
|
||||
import { DerivedBalances, DerivedReferendumVote } from '../types';
|
||||
import { DerivedBalancesAccount, DerivedReferendumVote } from '../types';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function referendumVotesFor (api: ApiInterfaceRx): (referendumId: BN | number) => Observable<DerivedReferendumVote[]> {
|
||||
return memo((referendumId: BN | number): Observable<DerivedReferendumVote[]> =>
|
||||
api.query.democracy.votersFor<Vec<AccountId>>(referendumId).pipe(
|
||||
switchMap((votersFor): Observable<[Vec<AccountId>, Vote[], DerivedBalances[]]> =>
|
||||
switchMap((votersFor): Observable<[Vec<AccountId>, Vote[], DerivedBalancesAccount[]]> =>
|
||||
combineLatest([
|
||||
of(votersFor),
|
||||
api.derive.democracy.votes(referendumId, votersFor),
|
||||
|
||||
@@ -13,21 +13,28 @@ import { createType, Vec, u32 } from '@polkadot/types';
|
||||
import { DerivedElectionsInfo } from '../types';
|
||||
import { memo } from '../util';
|
||||
|
||||
function sortAccounts ([, balanceA]: ITuple<[AccountId, Balance]>, [, balanceB]: ITuple<[AccountId, Balance]>): number {
|
||||
return balanceB.cmp(balanceA);
|
||||
}
|
||||
|
||||
function queryElections (api: ApiInterfaceRx): Observable<DerivedElectionsInfo> {
|
||||
const section = api.query.electionsPhragmen ? 'electionsPhragmen' : 'elections';
|
||||
|
||||
return api.queryMulti<[Vec<AccountId>, Vec<ITuple<[AccountId, Balance]>>, Vec<ITuple<[AccountId, Balance]>>]>([
|
||||
return api.queryMulti<[Vec<AccountId>, Vec<AccountId>, Vec<ITuple<[AccountId, Balance]>>, Vec<ITuple<[AccountId, Balance]>>]>([
|
||||
api.query.council.members,
|
||||
api.query[section].candidates,
|
||||
api.query[section].members,
|
||||
api.query[section].runnersUp
|
||||
]).pipe(
|
||||
map(([candidates, members, runnersUp]): DerivedElectionsInfo => ({
|
||||
map(([councilMembers, candidates, members, runnersUp]): DerivedElectionsInfo => ({
|
||||
candidates,
|
||||
candidateCount: createType(api.registry, 'u32', candidates.length),
|
||||
candidacyBond: api.consts[section].candidacyBond as Balance,
|
||||
desiredSeats: api.consts[section].desiredMembers as u32,
|
||||
members: members.sort((a, b): number => b[1].cmp(a[1])),
|
||||
runnersUp: runnersUp.sort((a, b): number => b[1].cmp(a[1])),
|
||||
members: members.length
|
||||
? members.sort(sortAccounts)
|
||||
: councilMembers.map((accountId): [AccountId, Balance] => [accountId, createType(api.registry, 'Balance')]),
|
||||
runnersUp: runnersUp.sort(sortAccounts),
|
||||
termDuration: api.consts[section].termDuration as BlockNumber,
|
||||
votingBond: api.consts[section].votingBond as Balance
|
||||
}))
|
||||
|
||||
@@ -45,7 +45,6 @@ describe('derive', (): void => {
|
||||
testFunction(api)('balances', 'fees', []);
|
||||
testFunction(api)('balances', 'votingBalance', []);
|
||||
testFunction(api)('balances', 'votingBalances', []);
|
||||
testFunction(api)('balances', 'votingBalancesNominatorsFor', []);
|
||||
|
||||
testFunction(api)('chain', 'bestNumber', []);
|
||||
testFunction(api)('chain', 'bestNumberFinalized', []);
|
||||
@@ -62,7 +61,6 @@ describe('derive', (): void => {
|
||||
testFunction(api)('session', 'sessionProgress', []);
|
||||
|
||||
testFunction(api)('staking', 'account', []);
|
||||
testFunction(api)('staking', 'recentlyOffline', []);
|
||||
testFunction(api)('staking', 'controllers', []);
|
||||
});
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import * as council from './council';
|
||||
import * as democracy from './democracy';
|
||||
import * as elections from './elections';
|
||||
import * as imOnline from './imOnline';
|
||||
import * as parachains from './parachains';
|
||||
import * as session from './session';
|
||||
import * as society from './society';
|
||||
import * as staking from './staking';
|
||||
@@ -23,7 +24,7 @@ import * as treasury from './treasury';
|
||||
|
||||
export * from './type';
|
||||
|
||||
export const derive = { accounts, balances, chain, contracts, council, democracy, elections, imOnline, session, society, staking, technicalCommittee, treasury };
|
||||
export const derive = { accounts, balances, chain, contracts, council, democracy, elections, imOnline, parachains, session, society, staking, technicalCommittee, treasury };
|
||||
|
||||
type DeriveSection<Section> = {
|
||||
[Method in keyof Section]: Section[Method] extends AnyFunction
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { BlockNumber, CollatorId, ParaId, ParaInfo, Retriable, UpwardMessage } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { DeriveParachain, DeriveParachainActive } from '../types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Bytes, Option, Vec } from '@polkadot/types';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type ParaIds = ParaId[];
|
||||
type ParaInfoResult = Option<ParaInfo>;
|
||||
type PendingSwap = Option<ParaId>;
|
||||
type Active = ITuple<[ParaId, Option<ITuple<[CollatorId, Retriable]>>]>[];
|
||||
type RetryQueue = ITuple<[ParaId, CollatorId]>[][]
|
||||
type SelectedThreads = ITuple<[ParaId, CollatorId]>[][];
|
||||
type Heads = Bytes;
|
||||
type RelayDispatchQueue = Vec<UpwardMessage>
|
||||
type Watermarks = Option<BlockNumber>;
|
||||
type DidUpdate = Option<Vec<ParaId>>;
|
||||
|
||||
type Result = [
|
||||
ParaId[],
|
||||
[
|
||||
Active,
|
||||
RetryQueue,
|
||||
SelectedThreads,
|
||||
DidUpdate
|
||||
],
|
||||
ParaInfoResult[],
|
||||
PendingSwap[],
|
||||
Heads[],
|
||||
RelayDispatchQueue[],
|
||||
Watermarks[],
|
||||
];
|
||||
|
||||
function parseActive (id: ParaId, active: Active): DeriveParachainActive | null {
|
||||
const found = active.find(([paraId]): boolean => paraId === id);
|
||||
|
||||
if (found && found[1].isSome) {
|
||||
const [collatorId, retriable] = found[1].unwrap();
|
||||
|
||||
return {
|
||||
collatorId,
|
||||
...(
|
||||
retriable.isWithRetries
|
||||
? {
|
||||
isRetriable: true,
|
||||
retries: retriable.asWithRetries.toNumber()
|
||||
}
|
||||
: {
|
||||
isRetriable: false,
|
||||
retries: 0
|
||||
}
|
||||
)
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function parseCollators (id: ParaId, collatorQueue: SelectedThreads | RetryQueue): (CollatorId | null)[] {
|
||||
return collatorQueue
|
||||
.map((queue): CollatorId | null => {
|
||||
const found = queue.find(([paraId]): boolean => paraId === id);
|
||||
|
||||
return found ? found[1] : null;
|
||||
});
|
||||
}
|
||||
|
||||
function parse ([ids, [active, retryQueue, selectedThreads, didUpdate], infos, pendingSwaps, heads, relayDispatchQueues, watermarks]: Result): DeriveParachain[] {
|
||||
return ids.map((id, index): DeriveParachain => {
|
||||
return {
|
||||
active: parseActive(id, active),
|
||||
didUpdate: didUpdate.isSome
|
||||
? didUpdate.unwrap().some((paraId): boolean => paraId === id)
|
||||
: false,
|
||||
heads: heads[index],
|
||||
id,
|
||||
info: infos[index].unwrapOr(null),
|
||||
pendingSwapId: pendingSwaps[index].unwrapOr(null),
|
||||
relayDispatchQueue: relayDispatchQueues[index],
|
||||
retryCollators: parseCollators(id, retryQueue),
|
||||
selectedCollators: parseCollators(id, selectedThreads),
|
||||
watermark: watermarks[index].unwrapOr(null)
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function all (api: ApiInterfaceRx): () => Observable<DeriveParachain[]> {
|
||||
return memo((): Observable<DeriveParachain[]> =>
|
||||
api.query.registrar?.parachains && api.query.parachains
|
||||
? api.query.registrar.parachains<ParaIds>().pipe(
|
||||
switchMap((paraIds) =>
|
||||
combineLatest([
|
||||
of(paraIds),
|
||||
api.queryMulti([
|
||||
api.query.registrar.active,
|
||||
api.query.registrar.retryQueue,
|
||||
api.query.registrar.selectedThreads,
|
||||
api.query.parachains.didUpdate
|
||||
]),
|
||||
api.query.registrar.paras.multi<ParaInfo>(paraIds),
|
||||
api.query.registrar.pendingSwap.multi<PendingSwap>(paraIds),
|
||||
api.query.parachains.heads.multi<Heads>(paraIds),
|
||||
api.query.parachains.relayDispatchQueue.multi<RelayDispatchQueue>(paraIds),
|
||||
api.query.parachains.watermarks.multi<Watermarks>(paraIds)
|
||||
]) as Observable<Result>
|
||||
),
|
||||
map((result: Result): DeriveParachain[] =>
|
||||
parse(result)
|
||||
)
|
||||
)
|
||||
: of([] as DeriveParachain[])
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export * from './all';
|
||||
@@ -7,5 +7,4 @@ export * from './controllers';
|
||||
export * from './electedInfo';
|
||||
export * from './overview';
|
||||
export * from './query';
|
||||
export * from './recentlyOffline';
|
||||
export * from './validators';
|
||||
|
||||
@@ -3,24 +3,23 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { AccountId, Exposure, Keys, RewardDestination, ValidatorPrefs } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { AccountId, Exposure, Keys, Nominations, RewardDestination, ValidatorPrefs } from '@polkadot/types/interfaces';
|
||||
import { DerivedStakingStash } from '../types';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Option, Vec } from '@polkadot/types';
|
||||
import { Option } from '@polkadot/types';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type Result = [Option<AccountId>, [Vec<AccountId>], RewardDestination, Exposure, ValidatorPrefs, Option<Keys>?];
|
||||
type ResultV2 = [Option<AccountId>, ITuple<[Vec<AccountId>]>, RewardDestination, Exposure, ValidatorPrefs, Option<Keys>];
|
||||
type Result = [Option<AccountId>, Nominations, RewardDestination, Exposure, ValidatorPrefs, Option<Keys>];
|
||||
|
||||
function parse (stashId: AccountId, [_controllerId, [nominators], rewardDestination, stakers, validatorPrefs, _nextKeys]: Result): DerivedStakingStash {
|
||||
function parse (stashId: AccountId, [_controllerId, nominators, rewardDestination, stakers, validatorPrefs, _nextKeys]: Result): DerivedStakingStash {
|
||||
return {
|
||||
controllerId: _controllerId.unwrapOr(undefined),
|
||||
nextKeys: _nextKeys?.unwrapOr(undefined),
|
||||
nominators,
|
||||
nextKeys: _nextKeys.unwrapOr(undefined),
|
||||
nominators: nominators.targets,
|
||||
nominateAt: nominators.submittedIn,
|
||||
rewardDestination,
|
||||
stakers,
|
||||
stashId,
|
||||
@@ -29,7 +28,7 @@ function parse (stashId: AccountId, [_controllerId, [nominators], rewardDestinat
|
||||
}
|
||||
|
||||
function query (api: ApiInterfaceRx, stashId: AccountId): Observable<Result> {
|
||||
return api.queryMulti<ResultV2>([
|
||||
return api.queryMulti<Result>([
|
||||
[api.query.staking.bonded, stashId],
|
||||
[api.query.staking.nominators, stashId],
|
||||
[api.query.staking.payee, stashId],
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { AccountId, BlockNumber } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { DerivedRecentlyOffline } from '../types';
|
||||
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Vec, u32 } from '@polkadot/types';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type OfflineResult = Vec<ITuple<[AccountId, BlockNumber, u32]>>;
|
||||
|
||||
function expandDerived (recentlyOffline: OfflineResult): DerivedRecentlyOffline {
|
||||
return recentlyOffline.reduce((result: DerivedRecentlyOffline, [accountId, blockNumber, count]): DerivedRecentlyOffline => {
|
||||
const key = accountId.toString();
|
||||
|
||||
if (!result[key]) {
|
||||
result[key] = [];
|
||||
}
|
||||
|
||||
result[key].push({
|
||||
blockNumber,
|
||||
count
|
||||
});
|
||||
|
||||
return result;
|
||||
}, {});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Retrieve a keyed record of accounts recently reported to be offline
|
||||
*/
|
||||
export function recentlyOffline (api: ApiInterfaceRx): () => Observable<DerivedRecentlyOffline> {
|
||||
return memo((): Observable<DerivedRecentlyOffline> =>
|
||||
(
|
||||
// TODO recentlyOffline has been dropped for 2.x and replaced, figure out the
|
||||
// replacement as actually use and implement it
|
||||
api.query.staking.recentlyOffline
|
||||
? api.query.staking.recentlyOffline<OfflineResult>()
|
||||
: of([] as unknown as OfflineResult)
|
||||
).pipe(
|
||||
map(expandDerived)
|
||||
));
|
||||
}
|
||||
@@ -2,10 +2,10 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId, AccountIndex, Balance, BalanceLock, BalanceOf, Bid, BidKind, BlockNumber, EraIndex, EraPoints, Exposure, Hash, Index, Keys, Proposal, PropIndex, ProposalIndex, ReferendumInfo, RegistrationJudgement, RewardDestination, SessionIndex, SetIndex, SocietyVote, StakingLedger, StrikeCount, TreasuryProposal, ValidatorPrefs, Vote, Votes, VoteIndex, VouchingStatus } from '@polkadot/types/interfaces';
|
||||
import { AccountId, AccountIndex, Balance, BalanceLock, BalanceLockTo212, BalanceOf, Bid, BidKind, BlockNumber, CollatorId, EraIndex, EraPoints, Exposure, Hash, Index, Keys, ParaId, ParaInfo, Proposal, PropIndex, ProposalIndex, ReferendumInfo, RegistrationJudgement, RewardDestination, SessionIndex, SetIndex, SocietyVote, StakingLedger, StrikeCount, TreasuryProposal, UpwardMessage, ValidatorPrefs, Vote, Votes, VoteIndex, VouchingStatus } from '@polkadot/types/interfaces';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { u32, Vec } from '@polkadot/types';
|
||||
import { Bytes, u32, Vec } from '@polkadot/types';
|
||||
|
||||
export type AccountIndexes = Record<string, AccountIndex>;
|
||||
|
||||
@@ -30,26 +30,31 @@ export interface DeriveAccountInfo {
|
||||
nickname?: string;
|
||||
}
|
||||
|
||||
export interface DerivedBalances {
|
||||
export interface DerivedBalancesAccount {
|
||||
accountId: AccountId;
|
||||
accountNonce: Index;
|
||||
freeBalance: Balance;
|
||||
frozenFee: Balance;
|
||||
frozenMisc: Balance;
|
||||
reservedBalance: Balance;
|
||||
votingBalance: Balance;
|
||||
}
|
||||
|
||||
export interface DerivedBalancesAll extends DerivedBalancesAccount {
|
||||
isVesting: boolean;
|
||||
lockedBalance: Balance;
|
||||
lockedBreakdown: BalanceLock[];
|
||||
lockedBreakdown: (BalanceLock | BalanceLockTo212)[];
|
||||
availableBalance: Balance;
|
||||
reservedBalance: Balance;
|
||||
votingBalance: Balance;
|
||||
vestedBalance: Balance;
|
||||
vestingTotal: Balance;
|
||||
}
|
||||
|
||||
export type DerivedBalancesMap = Record<string, DerivedBalances>;
|
||||
export type DerivedBalancesMap = Record<string, DerivedBalancesAll>;
|
||||
|
||||
export interface DerivedContractFees {
|
||||
callBaseFee: BN;
|
||||
contractFee: BN;
|
||||
createBaseFee: BN;
|
||||
creationFee: BN;
|
||||
rentByteFee: BN;
|
||||
rentDepositOffset: BN;
|
||||
@@ -102,6 +107,25 @@ export interface RecentlyOffline {
|
||||
count: BN;
|
||||
}
|
||||
|
||||
export interface DeriveParachainActive {
|
||||
collatorId: CollatorId;
|
||||
isRetriable: boolean;
|
||||
retries: number;
|
||||
}
|
||||
|
||||
export interface DeriveParachain {
|
||||
active: DeriveParachainActive | null;
|
||||
didUpdate: boolean;
|
||||
pendingSwapId: ParaId | null;
|
||||
heads: Bytes | null;
|
||||
id: ParaId;
|
||||
info: ParaInfo | null;
|
||||
relayDispatchQueue: UpwardMessage[];
|
||||
retryCollators: (CollatorId | null)[];
|
||||
selectedCollators: (CollatorId | null)[];
|
||||
watermark: BlockNumber | null;
|
||||
}
|
||||
|
||||
export interface DeriveProposalPreImage {
|
||||
at: BlockNumber;
|
||||
balance: Balance;
|
||||
@@ -188,6 +212,7 @@ export interface DeriveStakingValidators {
|
||||
export interface DerivedStakingStash {
|
||||
controllerId?: AccountId;
|
||||
nominators?: AccountId[];
|
||||
nominateAt?: EraIndex;
|
||||
rewardDestination?: RewardDestination;
|
||||
nextKeys?: Keys;
|
||||
stakers?: Exposure;
|
||||
|
||||
+14
-13
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api",
|
||||
"version": "1.0.1",
|
||||
"version": "1.2.1",
|
||||
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -25,20 +25,21 @@
|
||||
"url": "https://github.com/polkadot-js/api/issues"
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
|
||||
"browser": {
|
||||
"../package.json": "./package.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.3",
|
||||
"@polkadot/api-derive": "^1.0.1",
|
||||
"@polkadot/keyring": "^2.0.1",
|
||||
"@polkadot/metadata": "^1.0.1",
|
||||
"@polkadot/rpc-core": "^1.0.1",
|
||||
"@polkadot/rpc-provider": "^1.0.1",
|
||||
"@polkadot/types": "^1.0.1",
|
||||
"@polkadot/util-crypto": "^2.0.1"
|
||||
"@babel/runtime": "^7.8.4",
|
||||
"@polkadot/api-derive": "^1.2.1",
|
||||
"@polkadot/keyring": "^2.3.1",
|
||||
"@polkadot/metadata": "^1.2.1",
|
||||
"@polkadot/rpc-core": "^1.2.1",
|
||||
"@polkadot/rpc-provider": "^1.2.1",
|
||||
"@polkadot/types": "^1.2.1",
|
||||
"@polkadot/util": "^2.3.1",
|
||||
"@polkadot/util-crypto": "^2.3.1",
|
||||
"bn.js": "^5.1.1",
|
||||
"eventemitter3": "^4.0.0",
|
||||
"rxjs": "^6.5.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^2.0.1"
|
||||
"@polkadot/keyring": "^2.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Constants, Storage } from '@polkadot/metadata/Decorated/types';
|
||||
import { RpcInterface } from '@polkadot/rpc-core/jsonrpc.types';
|
||||
import { RpcInterface } from '@polkadot/rpc-core/types';
|
||||
import { InterfaceRegistry } from '@polkadot/types/interfaceRegistry';
|
||||
import { Call, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import { AnyFunction, CallFunction, Codec, CodecArg as Arg, ITuple, InterfaceTypes, ModulesWithCalls, Registry, RegistryTypes } from '@polkadot/types/types';
|
||||
@@ -285,6 +285,9 @@ export default abstract class Decorate<ApiType extends ApiTypes> extends Events
|
||||
decorated.key = (arg1?: Arg, arg2?: Arg): string =>
|
||||
u8aToHex(compactStripLength(creator(creator.meta.type.isDoubleMap ? [arg1, arg2] : arg1))[1]);
|
||||
|
||||
decorated.keyPrefix = (): string =>
|
||||
u8aToHex(creator.keyPrefix);
|
||||
|
||||
if (this.hasSubscriptions) {
|
||||
// When using double map storage function, user need to pass double map key as an array
|
||||
decorated.multi = decorateMethod((args: (Arg | Arg[])[]): Observable<Codec[]> =>
|
||||
|
||||
@@ -128,9 +128,12 @@ export default abstract class Init<ApiType extends ApiTypes> extends Decorate<Ap
|
||||
this.registerTypes(getMetadataTypes(metadata.version));
|
||||
|
||||
const decoratedMeta = new DecoratedMeta(this.registry, metadata);
|
||||
const metaExtrinsic = metadata.asLatest.extrinsic;
|
||||
|
||||
// only inject if we are not a clone (global init)
|
||||
if (!this._options.source) {
|
||||
if (metaExtrinsic.version.gtn(0)) {
|
||||
this._extrinsicType = metaExtrinsic.version.toNumber();
|
||||
} else if (!this._options.source) {
|
||||
// detect the extrinsic version in-use based on the last block
|
||||
const { block: { extrinsics: [firstTx] } }: SignedBlock = await this._rpcCore.chain.getBlock().toPromise();
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Constants } from '@polkadot/metadata/Decorated/types';
|
||||
import { RpcInterface } from '@polkadot/rpc-core/jsonrpc.types';
|
||||
import { RpcInterface } from '@polkadot/rpc-core/types';
|
||||
import { Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import { InterfaceRegistry } from '@polkadot/types/interfaceRegistry';
|
||||
import { CallFunction, InterfaceTypes, RegistryError, RegistryTypes, SignerPayloadRawBase } from '@polkadot/types/types';
|
||||
@@ -123,14 +123,14 @@ export default abstract class ApiBase<ApiType extends ApiTypes> extends Init<Api
|
||||
/**
|
||||
* @description Contains all the chain state modules and their subsequent methods in the API. These are attached dynamically from the runtime metadata.
|
||||
*
|
||||
* All calls inside the namespace, is denoted by `section`.`method` and may take an optional query parameter. As an example, `api.query.timestamp.now()` (current block timestamp) does not take parameters, while `api.query.system.accountNonce(<accountId>)` (retrieving the associated nonce for an account), takes the `AccountId` as a parameter.
|
||||
* All calls inside the namespace, is denoted by `section`.`method` and may take an optional query parameter. As an example, `api.query.timestamp.now()` (current block timestamp) does not take parameters, while `api.query.system.account(<accountId>)` (retrieving the associated nonce & balances for an account), takes the `AccountId` as a parameter.
|
||||
*
|
||||
* @example
|
||||
* <BR>
|
||||
*
|
||||
* ```javascript
|
||||
* api.query.balances.freeBalance(<accountId>, (balance) => {
|
||||
* console.log('new balance', balance);
|
||||
* api.query.system.account(<accountId>, ([nonce, balance]) => {
|
||||
* console.log('new free balance', balance.free, 'new nonce', nonce);
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
@@ -150,10 +150,10 @@ export default abstract class ApiBase<ApiType extends ApiTypes> extends Init<Api
|
||||
* // you can include the storage without any parameters
|
||||
* api.query.balances.totalIssuance,
|
||||
* // or you can pass parameters to the storage query
|
||||
* [api.query.balances.freeBalance, '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY']
|
||||
* [api.query.system.account, '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY']
|
||||
* ],
|
||||
* ([existential, balance]) => {
|
||||
* console.log(`You have ${balance.sub(existential)} more than the existential deposit`);
|
||||
* ([existential, [, { free }]]) => {
|
||||
* console.log(`You have ${free.sub(existential)} more than the existential deposit`);
|
||||
*
|
||||
* unsub();
|
||||
* }
|
||||
|
||||
@@ -20,8 +20,8 @@ function consts (api: ApiPromise): void {
|
||||
// constants has actual value & metadata
|
||||
console.log(
|
||||
api.consts.foo.bar,
|
||||
api.consts.balances.creationFee.toNumber(),
|
||||
api.consts.balances.creationFee.meta.documentation.map((s): string => s.toString()).join('')
|
||||
api.consts.balances.existentialDeposit.toNumber(),
|
||||
api.consts.balances.existentialDeposit.meta.documentation.map((s): string => s.toString()).join('')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -35,29 +35,34 @@ async function derive (api: ApiPromise): Promise<void> {
|
||||
}
|
||||
|
||||
async function query (api: ApiPromise, keyring: TestKeyringMap): Promise<void> {
|
||||
const intentions = await api.query.staking.intentions();
|
||||
const intentions = await api.query.staking.bonded();
|
||||
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);
|
||||
const bal = await api.query.balances.totalIssuance(); // bal is Balance
|
||||
const bal2 = await api.query.balances.totalIssuance('WRONG_ARG'); // bal2 is Codec (wrong args)
|
||||
const override = await api.query.balances.totalIssuance<Header>(); // override is still available
|
||||
const oldBal = await api.query.balances.totalIssuance.at('abcd');
|
||||
// It's hard to correctly type .multi. Expected: `Balance[]`, actual: Codec[].
|
||||
// In the meantime, we can case with `<Balance>`
|
||||
// In the meantime, we can case with `<Balance>` (this is not available on recent chains)
|
||||
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],
|
||||
[api.query.system.account, keyring.eve.address],
|
||||
// older chains only
|
||||
[api.query.system.accountNonce, keyring.bob.address]
|
||||
], (balances): void => {
|
||||
console.log('balances', balances);
|
||||
], (values): void => {
|
||||
console.log('values', values);
|
||||
|
||||
multiUnsub();
|
||||
});
|
||||
|
||||
// check entries()
|
||||
await api.query.system.account.entries(); // should not take a param
|
||||
await api.query.staking.nominatorSlashInEra.entries(123); // should take a param
|
||||
}
|
||||
|
||||
async function rpc (api: ApiPromise): Promise<void> {
|
||||
@@ -116,6 +121,13 @@ async function tx (api: ApiPromise, keyring: TestKeyringMap): Promise<void> {
|
||||
|
||||
unsub2();
|
||||
});
|
||||
|
||||
// it allows for query & then using the submittable
|
||||
const second = api.tx.democracy.second(123);
|
||||
|
||||
second.signAndSend('123', (result): void => {
|
||||
console.log(result);
|
||||
});
|
||||
}
|
||||
|
||||
async function main (): Promise<void> {
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
|
||||
import { Bytes, u32, u64 } from '@polkadot/types';
|
||||
import { Balance, BalanceOf, BlockNumber, Moment, Percent, Permill } from '@polkadot/types/interfaces/runtime';
|
||||
import { Gas } from '@polkadot/types/interfaces/contracts';
|
||||
import { SessionIndex } from '@polkadot/types/interfaces/session';
|
||||
import { EraIndex } from '@polkadot/types/interfaces/staking';
|
||||
import { Codec } from '@polkadot/types/types';
|
||||
|
||||
declare module '@polkadot/metadata/Decorated/types' {
|
||||
export interface Constants {
|
||||
babe: {
|
||||
[index: string]: Codec;
|
||||
epochDuration: u64 & ConstantCodec;
|
||||
expectedBlockTime: Moment & ConstantCodec;
|
||||
};
|
||||
timestamp: {
|
||||
[index: string]: Codec;
|
||||
minimumPeriod: Moment & ConstantCodec;
|
||||
};
|
||||
balances: {
|
||||
[index: string]: Codec;
|
||||
existentialDeposit: Balance & ConstantCodec;
|
||||
transferFee: Balance & ConstantCodec;
|
||||
creationFee: Balance & ConstantCodec;
|
||||
};
|
||||
transactionPayment: {
|
||||
[index: string]: Codec;
|
||||
transactionBaseFee: BalanceOf & ConstantCodec;
|
||||
transactionByteFee: BalanceOf & ConstantCodec;
|
||||
};
|
||||
staking: {
|
||||
[index: string]: Codec;
|
||||
sessionsPerEra: SessionIndex & ConstantCodec;
|
||||
bondingDuration: EraIndex & ConstantCodec;
|
||||
};
|
||||
session: {
|
||||
[index: string]: Codec;
|
||||
dedupKeyPrefix: Bytes & ConstantCodec;
|
||||
};
|
||||
democracy: {
|
||||
[index: string]: Codec;
|
||||
enactmentPeriod: BlockNumber & ConstantCodec;
|
||||
launchPeriod: BlockNumber & ConstantCodec;
|
||||
votingPeriod: BlockNumber & ConstantCodec;
|
||||
minimumDeposit: BalanceOf & ConstantCodec;
|
||||
emergencyVotingPeriod: BlockNumber & ConstantCodec;
|
||||
cooloffPeriod: BlockNumber & ConstantCodec;
|
||||
preimageByteDeposit: BalanceOf & ConstantCodec;
|
||||
};
|
||||
elections: {
|
||||
[index: string]: Codec;
|
||||
candidacyBond: BalanceOf & ConstantCodec;
|
||||
votingBond: BalanceOf & ConstantCodec;
|
||||
desiredMembers: u32 & ConstantCodec;
|
||||
desiredRunnersUp: u32 & ConstantCodec;
|
||||
termDuration: BlockNumber & ConstantCodec;
|
||||
};
|
||||
finalityTracker: {
|
||||
[index: string]: Codec;
|
||||
windowSize: BlockNumber & ConstantCodec;
|
||||
reportLatency: BlockNumber & ConstantCodec;
|
||||
};
|
||||
treasury: {
|
||||
[index: string]: Codec;
|
||||
proposalBond: Permill & ConstantCodec;
|
||||
proposalBondMinimum: BalanceOf & ConstantCodec;
|
||||
spendPeriod: BlockNumber & ConstantCodec;
|
||||
burn: Permill & ConstantCodec;
|
||||
tipCountdown: BlockNumber & ConstantCodec;
|
||||
tipFindersFee: Percent & ConstantCodec;
|
||||
tipReportDepositBase: BalanceOf & ConstantCodec;
|
||||
tipReportDepositPerByte: BalanceOf & ConstantCodec;
|
||||
};
|
||||
contracts: {
|
||||
[index: string]: Codec;
|
||||
signedClaimHandicap: BlockNumber & ConstantCodec;
|
||||
tombstoneDeposit: BalanceOf & ConstantCodec;
|
||||
storageSizeOffset: u32 & ConstantCodec;
|
||||
rentByteFee: BalanceOf & ConstantCodec;
|
||||
rentDepositOffset: BalanceOf & ConstantCodec;
|
||||
surchargeReward: BalanceOf & ConstantCodec;
|
||||
transferFee: BalanceOf & ConstantCodec;
|
||||
creationFee: BalanceOf & ConstantCodec;
|
||||
transactionBaseFee: BalanceOf & ConstantCodec;
|
||||
transactionByteFee: BalanceOf & ConstantCodec;
|
||||
contractFee: BalanceOf & ConstantCodec;
|
||||
callBaseFee: Gas & ConstantCodec;
|
||||
instantiateBaseFee: Gas & ConstantCodec;
|
||||
maxDepth: u32 & ConstantCodec;
|
||||
maxValueSize: u32 & ConstantCodec;
|
||||
blockGasLimit: Gas & ConstantCodec;
|
||||
};
|
||||
society: {
|
||||
[index: string]: Codec;
|
||||
candidateDeposit: BalanceOf & ConstantCodec;
|
||||
wrongSideDeduction: BalanceOf & ConstantCodec;
|
||||
maxStrikes: u32 & ConstantCodec;
|
||||
periodSpend: BalanceOf & ConstantCodec;
|
||||
rotationPeriod: BlockNumber & ConstantCodec;
|
||||
challengePeriod: BlockNumber & ConstantCodec;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -4,16 +4,14 @@
|
||||
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
let pkgJson;
|
||||
|
||||
// eslint-disable-next-line no-useless-catch
|
||||
try {
|
||||
pkgJson = require('./package.json');
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
detectPackage(require('./package.json'), __dirname);
|
||||
} catch (error) {
|
||||
pkgJson = require('../package.json');
|
||||
throw error;
|
||||
}
|
||||
|
||||
detectPackage(pkgJson);
|
||||
|
||||
export { Keyring } from '@polkadot/keyring';
|
||||
export { WsProvider } from '@polkadot/rpc-provider';
|
||||
|
||||
|
||||
@@ -122,10 +122,13 @@ describe('ApiPromise', (): void => {
|
||||
const api = await ApiPromise.create({ provider, registry, signer });
|
||||
const transfer = api.tx.balances.transfer(keyring.getPair('0xe659a7a1628cdd93febc04a4e0646ea20e9f5f0ce097d9a05290d4a9e054df4e').address, 12345);
|
||||
|
||||
await transfer.signAsync(aliceEd, {});
|
||||
await transfer.signAsync(aliceEd.address, {});
|
||||
|
||||
expect(transfer.signature.toHex()).toEqual(
|
||||
'0x6b9ccc95afbd4e916d30c65c720f4f7b70a77db545735b48a763844aa5210e695aa346686bad1224af77d00bcfbf6fc8d2c216a60731027835d5a414186a2607'
|
||||
// v1 extrinsic
|
||||
// '0x6b9ccc95afbd4e916d30c65c720f4f7b70a77db545735b48a763844aa5210e695aa346686bad1224af77d00bcfbf6fc8d2c216a60731027835d5a414186a2607'
|
||||
// v4 extrinsic
|
||||
'0x0716cbdc3b649dad8741238bcc8e4336f859c518cf2b17a3427b2f5d0b8a79cf518da71b9ac71d92c517342e0978f297f5e05362babf5987d3f1c5ba3314af08'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -154,7 +154,7 @@ export function decorateMethod<Method extends AnyFunction> (method: Method, opti
|
||||
* import ApiPromise from '@polkadot/api/promise';
|
||||
*
|
||||
* ApiPromise.create().then((api) => {
|
||||
* const nonce = await api.query.system.accountNonce(keyring.alice.address);
|
||||
* const [nonce] = await api.query.system.account(keyring.alice.address);
|
||||
*
|
||||
* api.tx.balances
|
||||
* // create transfer
|
||||
@@ -256,10 +256,9 @@ export default class ApiPromise extends ApiBase<'promise'> {
|
||||
* // combines values from balance & nonce as it updates
|
||||
* api.combineLatest([
|
||||
* api.rpc.chain.subscribeNewHeads,
|
||||
* [api.query.balances.freeBalance, address],
|
||||
* (cb) => api.query.system.accountNonce(address, cb)
|
||||
* ], ([head, balance, nonce]) => {
|
||||
* console.log(`#${head.number}: You have ${balance} units, with ${nonce} transactions sent`);
|
||||
* (cb) => api.query.system.account(address, cb)
|
||||
* ], ([head, [balance, nonce]]) => {
|
||||
* console.log(`#${head.number}: You have ${balance.free} units, with ${nonce} transactions sent`);
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
|
||||
@@ -1,261 +0,0 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { Option, Raw, Vec } from '@polkadot/types/codec';
|
||||
import { Bytes, Data, bool, u32, u64 } from '@polkadot/types';
|
||||
import { AccountId, AccountIndex, Balance, BalanceOf, BlockNumber, Hash, Index, KeyTypeId, Moment, Perbill, ValidatorId, Weight } 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 { Vote, VoteThreshold } from '@polkadot/types/interfaces/elections';
|
||||
import { AuthorityList, SetId, StoredPendingChange, StoredState } from '@polkadot/types/interfaces/grandpa';
|
||||
import { RegistrarInfo, Registration } from '@polkadot/types/interfaces/identity';
|
||||
import { AuthIndex } from '@polkadot/types/interfaces/imOnline';
|
||||
import { Kind, OffenceDetails, OpaqueTimeSlot, ReportIdOf } from '@polkadot/types/interfaces/offences';
|
||||
import { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
|
||||
import { Keys, SessionIndex } from '@polkadot/types/interfaces/session';
|
||||
import { Bid, BidKind, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
|
||||
import { EraIndex, EraPoints, Exposure, Forcing, MomentOf, Nominations, RewardDestination, SlashingSpans, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
|
||||
import { DigestOf, EventIndex, EventRecord } from '@polkadot/types/interfaces/system';
|
||||
import { OpenTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
|
||||
import { Multiplier } from '@polkadot/types/interfaces/txpayment';
|
||||
import { Multisig } from '@polkadot/types/interfaces/utility';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
|
||||
declare module '@polkadot/api/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<Option<u32>>> & QueryableStorageEntry<ApiType>;
|
||||
allExtrinsicsWeight: StorageEntryExact<ApiType, () => Observable<Option<Weight>>> & QueryableStorageEntry<ApiType>;
|
||||
allExtrinsicsLen: StorageEntryExact<ApiType, () => Observable<Option<u32>>> & 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>;
|
||||
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, (arg: Hash | Uint8Array | string) => Observable<Vec<ITuple<[BlockNumber, EventIndex]>>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
utility: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
multisigs: StorageEntryExact<ApiType, (key1: AccountId | Uint8Array | string, key2: Raw | Uint8Array | string) => Observable<Option<Multisig>>> & 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<Raw>> & QueryableStorageEntry<ApiType>;
|
||||
nextRandomness: StorageEntryExact<ApiType, () => Observable<Raw>> & QueryableStorageEntry<ApiType>;
|
||||
segmentIndex: StorageEntryExact<ApiType, () => Observable<u32>> & QueryableStorageEntry<ApiType>;
|
||||
underConstruction: StorageEntryExact<ApiType, (arg: u32 | Uint8Array | number | string) => Observable<Vec<Raw>>> & QueryableStorageEntry<ApiType>;
|
||||
initialized: StorageEntryExact<ApiType, () => Observable<Option<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<Option<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<Option<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>;
|
||||
};
|
||||
transactionPayment: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
nextFeeMultiplier: StorageEntryExact<ApiType, () => Observable<Multiplier>> & 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<Option<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
ledger: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<Option<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<Option<Nominations>>> & 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>;
|
||||
canceledSlashPayout: StorageEntryExact<ApiType, () => Observable<BalanceOf>> & QueryableStorageEntry<ApiType>;
|
||||
unappliedSlashes: StorageEntryExact<ApiType, (arg: EraIndex | Uint8Array | number | string) => Observable<Vec<UnappliedSlash>>> & QueryableStorageEntry<ApiType>;
|
||||
bondedEras: StorageEntryExact<ApiType, () => Observable<Vec<ITuple<[EraIndex, SessionIndex]>>>> & QueryableStorageEntry<ApiType>;
|
||||
validatorSlashInEra: StorageEntryExact<ApiType, (key1: EraIndex | Uint8Array | number | string, key2: AccountId | Uint8Array | string) => Observable<Option<ITuple<[Perbill, BalanceOf]>>>> & QueryableStorageEntry<ApiType>;
|
||||
nominatorSlashInEra: StorageEntryExact<ApiType, (key1: EraIndex | Uint8Array | number | string, key2: AccountId | Uint8Array | string) => Observable<Option<BalanceOf>>> & QueryableStorageEntry<ApiType>;
|
||||
slashingSpans: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<Option<SlashingSpans>>> & QueryableStorageEntry<ApiType>;
|
||||
spanSlash: StorageEntryExact<ApiType, (arg: ITuple<[AccountId, SpanIndex]>) => Observable<SpanRecord>> & QueryableStorageEntry<ApiType>;
|
||||
earliestUnappliedSlash: StorageEntryExact<ApiType, () => Observable<Option<EraIndex>>> & QueryableStorageEntry<ApiType>;
|
||||
storageVersion: StorageEntryExact<ApiType, () => Observable<u32>> & 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<Option<Keys>>> & QueryableStorageEntry<ApiType>;
|
||||
keyOwner: StorageEntryExact<ApiType, (key1: Bytes | Uint8Array | string, key2: ITuple<[KeyTypeId, Bytes]>) => Observable<Option<ValidatorId>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
democracy: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
publicPropCount: StorageEntryExact<ApiType, () => Observable<PropIndex>> & QueryableStorageEntry<ApiType>;
|
||||
publicProps: StorageEntryExact<ApiType, () => Observable<Vec<ITuple<[PropIndex, Hash, AccountId]>>>> & QueryableStorageEntry<ApiType>;
|
||||
preimages: StorageEntryExact<ApiType, (arg: Hash | Uint8Array | string) => Observable<Option<ITuple<[Bytes, AccountId, BalanceOf, BlockNumber]>>>> & QueryableStorageEntry<ApiType>;
|
||||
depositOf: StorageEntryExact<ApiType, (arg: PropIndex | Uint8Array | number | string) => Observable<Option<ITuple<[BalanceOf, Vec<AccountId>]>>>> & QueryableStorageEntry<ApiType>;
|
||||
referendumCount: StorageEntryExact<ApiType, () => Observable<ReferendumIndex>> & QueryableStorageEntry<ApiType>;
|
||||
lowestUnbaked: StorageEntryExact<ApiType, () => Observable<ReferendumIndex>> & QueryableStorageEntry<ApiType>;
|
||||
referendumInfoOf: StorageEntryExact<ApiType, (arg: ReferendumIndex | Uint8Array | number | string) => Observable<Option<ReferendumInfo>>> & QueryableStorageEntry<ApiType>;
|
||||
dispatchQueue: StorageEntryExact<ApiType, () => Observable<Vec<ITuple<[BlockNumber, Hash, 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<Option<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<Option<ITuple<[Hash, VoteThreshold]>>>> & QueryableStorageEntry<ApiType>;
|
||||
blacklist: StorageEntryExact<ApiType, (arg: Hash | Uint8Array | string) => Observable<Option<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<Option<Proposal>>> & QueryableStorageEntry<ApiType>;
|
||||
voting: StorageEntryExact<ApiType, (arg: Hash | Uint8Array | string) => Observable<Option<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<Option<Proposal>>> & QueryableStorageEntry<ApiType>;
|
||||
voting: StorageEntryExact<ApiType, (arg: Hash | Uint8Array | string) => Observable<Option<Votes>>> & QueryableStorageEntry<ApiType>;
|
||||
proposalCount: StorageEntryExact<ApiType, () => Observable<u32>> & QueryableStorageEntry<ApiType>;
|
||||
members: StorageEntryExact<ApiType, () => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
elections: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
members: StorageEntryExact<ApiType, () => Observable<Vec<ITuple<[AccountId, BalanceOf]>>>> & QueryableStorageEntry<ApiType>;
|
||||
runnersUp: StorageEntryExact<ApiType, () => Observable<Vec<ITuple<[AccountId, BalanceOf]>>>> & QueryableStorageEntry<ApiType>;
|
||||
electionRounds: StorageEntryExact<ApiType, () => Observable<u32>> & QueryableStorageEntry<ApiType>;
|
||||
votesOf: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
stakeOf: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<BalanceOf>> & QueryableStorageEntry<ApiType>;
|
||||
candidates: StorageEntryExact<ApiType, () => Observable<Vec<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<AuthorityList>> & QueryableStorageEntry<ApiType>;
|
||||
state: StorageEntryExact<ApiType, () => Observable<StoredState>> & QueryableStorageEntry<ApiType>;
|
||||
pendingChange: StorageEntryExact<ApiType, () => Observable<Option<StoredPendingChange>>> & QueryableStorageEntry<ApiType>;
|
||||
nextForced: StorageEntryExact<ApiType, () => Observable<Option<BlockNumber>>> & QueryableStorageEntry<ApiType>;
|
||||
stalled: StorageEntryExact<ApiType, () => Observable<Option<ITuple<[BlockNumber, BlockNumber]>>>> & QueryableStorageEntry<ApiType>;
|
||||
currentSetId: StorageEntryExact<ApiType, () => Observable<SetId>> & QueryableStorageEntry<ApiType>;
|
||||
setIdSession: StorageEntryExact<ApiType, (arg: SetId | Uint8Array | number | string) => Observable<Option<SessionIndex>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
treasury: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
proposalCount: StorageEntryExact<ApiType, () => Observable<ProposalIndex>> & QueryableStorageEntry<ApiType>;
|
||||
proposals: StorageEntryExact<ApiType, (arg: ProposalIndex | Uint8Array | number | string) => Observable<Option<TreasuryProposal>>> & QueryableStorageEntry<ApiType>;
|
||||
approvals: StorageEntryExact<ApiType, () => Observable<Vec<ProposalIndex>>> & QueryableStorageEntry<ApiType>;
|
||||
tips: StorageEntryExact<ApiType, (arg: Hash | Uint8Array | string) => Observable<Option<OpenTip>>> & QueryableStorageEntry<ApiType>;
|
||||
reasons: StorageEntryExact<ApiType, (arg: Hash | Uint8Array | string) => Observable<Option<Bytes>>> & 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<Option<Bytes>>> & QueryableStorageEntry<ApiType>;
|
||||
codeStorage: StorageEntryExact<ApiType, (arg: CodeHash | Uint8Array | string) => Observable<Option<PrefabWasmModule>>> & QueryableStorageEntry<ApiType>;
|
||||
accountCounter: StorageEntryExact<ApiType, () => Observable<u64>> & QueryableStorageEntry<ApiType>;
|
||||
contractInfoOf: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<Option<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<Option<Bytes>>> & QueryableStorageEntry<ApiType>;
|
||||
authoredBlocks: StorageEntryExact<ApiType, (key1: SessionIndex | Uint8Array | number | string, key2: ValidatorId | Uint8Array | string) => Observable<u32>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
offences: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
reports: StorageEntryExact<ApiType, (arg: ReportIdOf | Uint8Array | string) => Observable<Option<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>;
|
||||
};
|
||||
randomnessCollectiveFlip: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
randomMaterial: StorageEntryExact<ApiType, () => Observable<Vec<Hash>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
identity: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
identityOf: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<Option<Registration>>> & QueryableStorageEntry<ApiType>;
|
||||
superOf: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<Option<ITuple<[AccountId, Data]>>>> & QueryableStorageEntry<ApiType>;
|
||||
subsOf: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<ITuple<[BalanceOf, Vec<AccountId>]>>> & QueryableStorageEntry<ApiType>;
|
||||
registrars: StorageEntryExact<ApiType, () => Observable<Vec<Option<RegistrarInfo>>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
society: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
founder: StorageEntryExact<ApiType, () => Observable<Option<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
rules: StorageEntryExact<ApiType, () => Observable<Option<Hash>>> & QueryableStorageEntry<ApiType>;
|
||||
candidates: StorageEntryExact<ApiType, () => Observable<Vec<Bid>>> & QueryableStorageEntry<ApiType>;
|
||||
suspendedCandidates: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<Option<ITuple<[BalanceOf, BidKind]>>>> & QueryableStorageEntry<ApiType>;
|
||||
pot: StorageEntryExact<ApiType, () => Observable<BalanceOf>> & QueryableStorageEntry<ApiType>;
|
||||
head: StorageEntryExact<ApiType, () => Observable<Option<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
members: StorageEntryExact<ApiType, () => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
suspendedMembers: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<bool>> & QueryableStorageEntry<ApiType>;
|
||||
bids: StorageEntryExact<ApiType, () => Observable<Vec<Bid>>> & QueryableStorageEntry<ApiType>;
|
||||
vouching: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<Option<VouchingStatus>>> & QueryableStorageEntry<ApiType>;
|
||||
payouts: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<Vec<ITuple<[BlockNumber, BalanceOf]>>>> & QueryableStorageEntry<ApiType>;
|
||||
strikes: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<StrikeCount>> & QueryableStorageEntry<ApiType>;
|
||||
votes: StorageEntryExact<ApiType, (key1: AccountId | Uint8Array | string, key2: AccountId | Uint8Array | string) => Observable<Option<SocietyVote>>> & QueryableStorageEntry<ApiType>;
|
||||
defender: StorageEntryExact<ApiType, () => Observable<Option<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
defenderVotes: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<Option<SocietyVote>>> & QueryableStorageEntry<ApiType>;
|
||||
maxMembers: StorageEntryExact<ApiType, () => Observable<u32>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
recovery: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
recoverable: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<Option<RecoveryConfig>>> & QueryableStorageEntry<ApiType>;
|
||||
activeRecoveries: StorageEntryExact<ApiType, (key1: AccountId | Uint8Array | string, key2: AccountId | Uint8Array | string) => Observable<Option<ActiveRecovery>>> & QueryableStorageEntry<ApiType>;
|
||||
recovered: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<Option<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -91,11 +91,11 @@ export function decorateMethod <Method extends AnyFunction> (method: Method): Me
|
||||
*
|
||||
* // retrieve nonce for the account
|
||||
* api.query.system
|
||||
* .accountNonce(keyring.alice.address)
|
||||
* .account(keyring.alice.address)
|
||||
* .pipe(
|
||||
* first(),
|
||||
* // pipe nonce into transfer
|
||||
* switchMap((nonce) =>
|
||||
* switchMap(([nonce]) =>
|
||||
* api.tx.balances
|
||||
* // create transfer
|
||||
* .transfer(keyring.bob.address, 12345)
|
||||
@@ -107,7 +107,7 @@ export function decorateMethod <Method extends AnyFunction> (method: Method): Me
|
||||
* )
|
||||
* // subscribe to overall result
|
||||
* .subscribe(({ status }) => {
|
||||
* if (status.isFinalized) {
|
||||
* if (status.isInBlock) {
|
||||
* console.log('Completed at block hash', status.asFinalized.toHex());
|
||||
* }
|
||||
* });
|
||||
|
||||
@@ -16,17 +16,21 @@ export default class SubmittableResult implements SubmittableResultImpl {
|
||||
}
|
||||
|
||||
public get isCompleted (): boolean {
|
||||
return this.isError || this.isFinalized;
|
||||
return this.isError || this.status.isInBlock || this.status.isFinalized;
|
||||
}
|
||||
|
||||
public get isError (): boolean {
|
||||
return this.status.isDropped || this.status.isInvalid || this.status.isUsurped;
|
||||
return this.status.isDropped || this.status.isFinalityTimeout || this.status.isInvalid || this.status.isRetracted || this.status.isUsurped;
|
||||
}
|
||||
|
||||
public get isFinalized (): boolean {
|
||||
return this.status.isFinalized;
|
||||
}
|
||||
|
||||
public get isInBlock (): boolean {
|
||||
return this.status.isInBlock;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Filters EventRecords for the specified method & section (there could be multiple)
|
||||
*/
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Address, Call, ExtrinsicEra, ExtrinsicStatus, Hash, Header, Index, RuntimeDispatchInfo } from '@polkadot/types/interfaces';
|
||||
import { Callback, Codec, Constructor, IKeyringPair, Registry, SignatureOptions } from '@polkadot/types/types';
|
||||
import { AccountData, Address, Call, ExtrinsicEra, ExtrinsicStatus, Hash, Header, Index, RuntimeDispatchInfo } from '@polkadot/types/interfaces';
|
||||
import { Callback, Codec, Constructor, IKeyringPair, ITuple, Registry, SignatureOptions } from '@polkadot/types/types';
|
||||
import { ApiInterfaceRx, ApiTypes, SignerResult } from '../types';
|
||||
import { AddressOrPair, SignerOptions, SubmittableExtrinsic, SubmittablePaymentResult, SubmittableResultImpl, SubmittableResultResult, SubmittableResultSubscription, SubmittableThis } from './types';
|
||||
|
||||
@@ -235,7 +235,11 @@ export default function createClass <ApiType extends ApiTypes> ({ api, apiType,
|
||||
// ? this._api.rpc.account.nextIndex
|
||||
// ? this._api.rpc.account.nextIndex(address)
|
||||
// : this._api.query.system.accountNonce(address)
|
||||
? this._api.query.system.accountNonce(address)
|
||||
? this._api.query.system.account
|
||||
? this._api.query.system.account<ITuple<[Index, AccountData]>>(address).pipe(
|
||||
map(([nonce]): Index => nonce)
|
||||
)
|
||||
: this._api.query.system.accountNonce<Index>(address)
|
||||
: of(createType(this.registry, '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
|
||||
@@ -252,11 +256,13 @@ export default function createClass <ApiType extends ApiTypes> ({ api, apiType,
|
||||
}
|
||||
|
||||
private _statusObservable (status: ExtrinsicStatus): Observable<SubmittableResultImpl> {
|
||||
if (!status.isFinalized) {
|
||||
if (!status.isFinalized && !status.isInBlock) {
|
||||
return of(new SubmittableResult({ status }));
|
||||
}
|
||||
|
||||
const blockHash = status.asFinalized;
|
||||
const blockHash = status.isInBlock
|
||||
? status.asInBlock
|
||||
: status.asFinalized;
|
||||
|
||||
return combineLatest([
|
||||
this._api.rpc.chain.getBlock(blockHash),
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId, Address, ExtrinsicStatus, EventRecord, Hash, RuntimeDispatchInfo } from '@polkadot/types/interfaces';
|
||||
import { AnyNumber, AnyU8a, Callback, IExtrinsic, IExtrinsicEra, IKeyringPair, SignatureOptions } from '@polkadot/types/types';
|
||||
import { AnyNumber, AnyU8a, Callback, Codec, IExtrinsic, IExtrinsicEra, IKeyringPair, SignatureOptions } from '@polkadot/types/types';
|
||||
import { ApiTypes, Signer } from '../types';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
@@ -14,6 +14,7 @@ export interface SubmittableResultImpl {
|
||||
readonly isCompleted: boolean;
|
||||
readonly isError: boolean;
|
||||
readonly isFinalized: boolean;
|
||||
readonly isInBlock: boolean;
|
||||
|
||||
filterRecords (section: string, method: string): EventRecord[];
|
||||
findRecord (section: string, method: string): EventRecord | undefined;
|
||||
@@ -47,7 +48,7 @@ export type SubmittableThis<ApiType extends ApiTypes, THIS> =
|
||||
export interface SignerOptions {
|
||||
blockHash: AnyU8a;
|
||||
era?: IExtrinsicEra | number;
|
||||
nonce: AnyNumber;
|
||||
nonce: AnyNumber | Codec;
|
||||
signer?: Signer;
|
||||
tip?: AnyNumber;
|
||||
}
|
||||
|
||||
@@ -1,283 +0,0 @@
|
||||
// Copyright 2017-2020 @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.
|
||||
|
||||
// These two files add module augmentation so that `api.{query,consts}.*.*`
|
||||
// get typed. Import them to make these types effective.
|
||||
import './consts.types';
|
||||
import './query.types';
|
||||
|
||||
import { Constants } from '@polkadot/metadata/Decorated/types';
|
||||
import { UserRpc } from '@polkadot/rpc-core/types';
|
||||
import { Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import { AnyFunction, Callback, CallFunction, Codec, CodecArg, RegistryTypes, SignatureOptions, SignerPayloadJSON, SignerPayloadRaw, Registry } from '@polkadot/types/types';
|
||||
import { SubmittableResultImpl, SubmittableExtrinsic } from './submittable/types';
|
||||
import { DeriveAllSections } from './util/decorate';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Observable } from 'rxjs';
|
||||
import { DeriveCustom, ExactDerive } from '@polkadot/api-derive';
|
||||
import { RpcInterface } from '@polkadot/rpc-core/jsonrpc.types';
|
||||
import { ProviderInterface, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types';
|
||||
import { Metadata, u64 } from '@polkadot/types';
|
||||
import StorageKey, { StorageEntry } from '@polkadot/types/primitive/StorageKey';
|
||||
|
||||
import ApiBase from './base';
|
||||
|
||||
export * from './submittable/types';
|
||||
|
||||
// Prepend an element V onto the beginning of a tuple T.
|
||||
// Cons<1, [2,3,4]> is [1,2,3,4]
|
||||
type Cons<V, T extends any[]> = ((v: V, ...t: T) => void) extends ((...r: infer R) => void)
|
||||
? R
|
||||
: never;
|
||||
|
||||
// Append an element V onto the end of a tuple T
|
||||
// Push<[1,2,3],4> is [1,2,3,4]
|
||||
// note that this DOES NOT PRESERVE optionality/readonly in tuples.
|
||||
// So unfortunately Push<[1, 2?, 3?], 4> is [1,2|undefined,3|undefined,4]
|
||||
type Push<T extends any[], V> = (
|
||||
(
|
||||
Cons<any, Required<T>> extends infer R
|
||||
? { [K in keyof R]: K extends keyof T ? T[K] : V }
|
||||
: never
|
||||
) extends infer P
|
||||
? P extends any[] ? P : never
|
||||
: never
|
||||
);
|
||||
|
||||
// Returns the inner type of an Observable
|
||||
export type ObsInnerType<O extends Observable<any>> = O extends Observable<infer U> ? U : never;
|
||||
|
||||
export type UnsubscribePromise = Promise<() => void>;
|
||||
|
||||
// In the abstract `decorateMethod` in Base.ts, we can also pass in some meta-
|
||||
// information. This describes it.
|
||||
export interface DecorateMethodOptions {
|
||||
methodName?: string;
|
||||
}
|
||||
|
||||
export type DecorateMethod<ApiType extends ApiTypes> = <Method extends (...args: any[]) => Observable<any>>(method: Method, options?: DecorateMethodOptions) => any;
|
||||
|
||||
// Here are the return types of these parts of the api:
|
||||
// - api.query.*.*: no exact typings
|
||||
// - api.tx.*.*: SubmittableExtrinsic<ApiType extends ApiTypes>
|
||||
// - api.derive.*.*: MethodResult<ApiType, F>
|
||||
// - api.rpc.*.*: no exact typings (for now, FIXME: should be MethodResult<ApiType, F>, like in derive)
|
||||
|
||||
// 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 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 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 extends ApiTypes, 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 extends ApiTypes, F extends AnyFunction> = ApiType extends 'rxjs'
|
||||
? RxResult<F>
|
||||
: PromiseResult<F>;
|
||||
|
||||
export type DecoratedRpcSection<ApiType extends ApiTypes, Section> = {
|
||||
[Method in keyof Section]: Section[Method] extends AnyFunction
|
||||
? MethodResult<ApiType, Section[Method]>
|
||||
: never
|
||||
}
|
||||
|
||||
export type DecoratedRpc<ApiType extends ApiTypes, AllSections> = {
|
||||
[Section in keyof AllSections]: DecoratedRpcSection<ApiType, AllSections[Section]>
|
||||
}
|
||||
|
||||
interface StorageEntryObservableMulti {
|
||||
<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 extends ApiTypes, F extends AnyFunction> {
|
||||
at: (hash: Hash | Uint8Array | string, ...args: Parameters<F>) => PromiseOrObs<ApiType, ObsInnerType<ReturnType<F>>>;
|
||||
creator: StorageEntry;
|
||||
entries: () => PromiseOrObs<ApiType, [StorageKey, ObsInnerType<ReturnType<F>>][]>;
|
||||
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 {
|
||||
(arg1?: CodecArg, arg2?: CodecArg): Promise<Codec>;
|
||||
<T extends Codec>(arg1?: CodecArg, arg2?: CodecArg): Promise<T>;
|
||||
<T extends Codec>(callback: Callback<T>): UnsubscribePromise;
|
||||
<T extends Codec>(arg: CodecArg, callback: Callback<T>): UnsubscribePromise;
|
||||
<T extends Codec>(arg1: CodecArg, arg2: CodecArg, callback: Callback<T>): UnsubscribePromise;
|
||||
}
|
||||
|
||||
export type StorageEntryExact<ApiType extends ApiTypes, F extends AnyFunction> = MethodResult<ApiType, F> & StorageEntryBase<ApiType, F>
|
||||
|
||||
// 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 extends ApiTypes> =
|
||||
ApiType extends 'rxjs'
|
||||
? StorageEntryExact<'rxjs', GenericStorageEntryFunction>
|
||||
: StorageEntryExact<'promise', GenericStorageEntryFunction> & StorageEntryPromiseOverloads;
|
||||
|
||||
export interface QueryableModuleStorage<ApiType extends ApiTypes> {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
}
|
||||
|
||||
export type QueryableStorageMultiArg<ApiType extends ApiTypes> =
|
||||
QueryableStorageEntry<ApiType> |
|
||||
[QueryableStorageEntry<ApiType>, ...CodecArg[]];
|
||||
|
||||
export interface QueryableStorageMultiBase<ApiType extends ApiTypes> {
|
||||
<T extends Codec[]>(calls: QueryableStorageMultiArg<ApiType>[]): Observable<T>;
|
||||
}
|
||||
|
||||
export interface QueryableStorageMultiPromise<ApiType extends ApiTypes> {
|
||||
<T extends Codec[]>(calls: QueryableStorageMultiArg<ApiType>[], callback: Callback<T>): UnsubscribePromise;
|
||||
}
|
||||
|
||||
export type QueryableStorageMulti<ApiType extends ApiTypes> =
|
||||
ApiType extends 'rxjs'
|
||||
? QueryableStorageMultiBase<ApiType>
|
||||
: QueryableStorageMultiPromise<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 extends ApiTypes> { }
|
||||
|
||||
export interface QueryableStorage<ApiType extends ApiTypes> extends QueryableStorageExact<ApiType> {
|
||||
[index: string]: QueryableModuleStorage<ApiType>;
|
||||
}
|
||||
|
||||
export interface SubmittableExtrinsicFunction<ApiType extends ApiTypes> extends CallFunction {
|
||||
(...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
|
||||
}
|
||||
|
||||
export interface SubmittableModuleExtrinsics<ApiType extends ApiTypes> {
|
||||
[index: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
}
|
||||
|
||||
export interface SubmittableExtrinsics<ApiType extends ApiTypes> {
|
||||
(extrinsic: Uint8Array | string): SubmittableExtrinsic<ApiType>;
|
||||
[index: string]: SubmittableModuleExtrinsics<ApiType>;
|
||||
}
|
||||
|
||||
export interface ApiOptions {
|
||||
/**
|
||||
* @description Add custom derives to be injected
|
||||
*/
|
||||
derives?: DeriveCustom;
|
||||
/**
|
||||
* @description prebundles is a map of 'genesis hash and runtime spec version' as key to metadata's hex string
|
||||
* if genesis hash and runtime spec version matches, then use metadata, else fetch it from chain
|
||||
*/
|
||||
metadata?: Record<string, string>;
|
||||
/**
|
||||
* @description Transport Provider from rpc-provider. If not specified, it will default to
|
||||
* connecting to a WsProvider connecting localhost with the default port, i.e. `ws://127.0.0.1:9944`
|
||||
*/
|
||||
provider?: ProviderInterface;
|
||||
/**
|
||||
* @description A type registry to use along with this instance
|
||||
*/
|
||||
registry?: Registry;
|
||||
/**
|
||||
* @description User-defined RPC methods
|
||||
*/
|
||||
rpc?: UserRpc;
|
||||
/**
|
||||
* @description An external signer which will be used to sign extrinsic when account passed in is not KeyringPair
|
||||
*/
|
||||
signer?: Signer;
|
||||
/**
|
||||
* @description The source object to use for runtime information (only used when cloning)
|
||||
*/
|
||||
source?: ApiBase<any>;
|
||||
/**
|
||||
* @description Additional types used by runtime modules. This is nessusary if the runtime modules
|
||||
* uses types not available in the base Substrate runtime.
|
||||
*/
|
||||
types?: RegistryTypes;
|
||||
/**
|
||||
* @description Additional types that are injected based on the chain we are connecting to. There are keyed by the chain, i.e. `{ 'Kusama CC1': { ... } }`
|
||||
*/
|
||||
typesChain?: Record<string, RegistryTypes>;
|
||||
/**
|
||||
* @description Additional types that are injected based on the type of node we are connecting to, as set via specName in the runtime version. There are keyed by the node, i.e. `{ 'edgeware': { ... } }`
|
||||
*/
|
||||
typesSpec?: Record<string, RegistryTypes>;
|
||||
}
|
||||
|
||||
// A smaller interface of ApiRx, used in derive and in SubmittableExtrinsic
|
||||
export interface ApiInterfaceRx {
|
||||
consts: Constants;
|
||||
// TODO This needs to be typed correctly
|
||||
derive: DeriveAllSections<'rxjs', ExactDerive>;
|
||||
extrinsicType: number;
|
||||
genesisHash: Hash;
|
||||
hasSubscriptions: boolean;
|
||||
registry: Registry;
|
||||
runtimeMetadata: Metadata;
|
||||
runtimeVersion: RuntimeVersion;
|
||||
query: QueryableStorage<'rxjs'>;
|
||||
queryMulti: QueryableStorageMulti<'rxjs'>;
|
||||
rpc: DecoratedRpc<'rxjs', RpcInterface>;
|
||||
tx: SubmittableExtrinsics<'rxjs'>;
|
||||
signer?: Signer;
|
||||
}
|
||||
|
||||
export type ApiInterfaceEvents = ProviderInterfaceEmitted | 'ready';
|
||||
|
||||
export type ApiTypes = 'promise' | 'rxjs';
|
||||
|
||||
export interface SignerOptions extends SignatureOptions {
|
||||
blockNumber: BN;
|
||||
genesisHash: Hash;
|
||||
}
|
||||
|
||||
export interface SignerResult {
|
||||
/**
|
||||
* @description The id for this request
|
||||
*/
|
||||
id: number;
|
||||
|
||||
/**
|
||||
* @description The resulting signature in hex
|
||||
*/
|
||||
signature: string;
|
||||
}
|
||||
|
||||
export interface Signer {
|
||||
/**
|
||||
* @description signs an extrinsic payload from a serialized form
|
||||
*/
|
||||
signPayload?: (payload: SignerPayloadJSON) => Promise<SignerResult>;
|
||||
|
||||
/**
|
||||
* @description signs a raw payload, only the bytes data as supplied
|
||||
*/
|
||||
signRaw?: (raw: SignerPayloadRaw) => Promise<SignerResult>;
|
||||
|
||||
/**
|
||||
* @description Receives an update for the extrinsic signed by a `signer.sign`
|
||||
*/
|
||||
update?: (id: number, status: Hash | SubmittableResultImpl) => void;
|
||||
}
|
||||
|
||||
export { ApiBase };
|
||||
@@ -0,0 +1,268 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
|
||||
import { Codec } from '@polkadot/types/types';
|
||||
import { Bytes, u32, u64 } from '@polkadot/types/primitive';
|
||||
import { Balance, BalanceOf, BlockNumber, Moment, Percent, Permill } from '@polkadot/types/interfaces/runtime';
|
||||
import { Gas } from '@polkadot/types/interfaces/contracts';
|
||||
import { SessionIndex } from '@polkadot/types/interfaces/session';
|
||||
import { EraIndex } from '@polkadot/types/interfaces/staking';
|
||||
|
||||
declare module '@polkadot/metadata/Decorated/consts/types' {
|
||||
export interface Constants {
|
||||
babe: {
|
||||
[index: string]: Codec;
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
epochDuration: AugmentedConst<u64>;
|
||||
/**
|
||||
* 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).
|
||||
**/
|
||||
expectedBlockTime: AugmentedConst<Moment>;
|
||||
};
|
||||
timestamp: {
|
||||
[index: string]: Codec;
|
||||
/**
|
||||
* The minimum period between blocks. Beware that this is different to the *expected* period
|
||||
* that the block production apparatus provides. Your chosen consensus system will generally
|
||||
* work with this to determine a sensible block time. e.g. For Aura, it will be double this
|
||||
* period on default settings.
|
||||
**/
|
||||
minimumPeriod: AugmentedConst<Moment>;
|
||||
};
|
||||
balances: {
|
||||
[index: string]: Codec;
|
||||
/**
|
||||
* The minimum amount required to keep an account open.
|
||||
**/
|
||||
existentialDeposit: AugmentedConst<Balance>;
|
||||
};
|
||||
transactionPayment: {
|
||||
[index: string]: Codec;
|
||||
/**
|
||||
* The fee to be paid for making a transaction; the base.
|
||||
**/
|
||||
transactionBaseFee: AugmentedConst<BalanceOf>;
|
||||
/**
|
||||
* The fee to be paid for making a transaction; the per-byte portion.
|
||||
**/
|
||||
transactionByteFee: AugmentedConst<BalanceOf>;
|
||||
};
|
||||
staking: {
|
||||
[index: string]: Codec;
|
||||
/**
|
||||
* Number of sessions per era.
|
||||
**/
|
||||
sessionsPerEra: AugmentedConst<SessionIndex>;
|
||||
/**
|
||||
* Number of eras that staked funds must remain bonded for.
|
||||
**/
|
||||
bondingDuration: AugmentedConst<EraIndex>;
|
||||
};
|
||||
session: {
|
||||
[index: string]: Codec;
|
||||
/**
|
||||
* Used as first key for `NextKeys` and `KeyOwner` to put all the data into the same branch
|
||||
* of the trie.
|
||||
**/
|
||||
dedupKeyPrefix: AugmentedConst<Bytes>;
|
||||
};
|
||||
democracy: {
|
||||
[index: string]: Codec;
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
enactmentPeriod: AugmentedConst<BlockNumber>;
|
||||
/**
|
||||
* How often (in blocks) new public referenda are launched.
|
||||
**/
|
||||
launchPeriod: AugmentedConst<BlockNumber>;
|
||||
/**
|
||||
* How often (in blocks) to check for new votes.
|
||||
**/
|
||||
votingPeriod: AugmentedConst<BlockNumber>;
|
||||
/**
|
||||
* The minimum amount to be used as a deposit for a public referendum proposal.
|
||||
**/
|
||||
minimumDeposit: AugmentedConst<BalanceOf>;
|
||||
/**
|
||||
* Minimum voting period allowed for an emergency referendum.
|
||||
**/
|
||||
emergencyVotingPeriod: AugmentedConst<BlockNumber>;
|
||||
/**
|
||||
* Period in blocks where an external proposal may not be re-submitted after being vetoed.
|
||||
**/
|
||||
cooloffPeriod: AugmentedConst<BlockNumber>;
|
||||
/**
|
||||
* The amount of balance that must be deposited per byte of preimage stored.
|
||||
**/
|
||||
preimageByteDeposit: AugmentedConst<BalanceOf>;
|
||||
};
|
||||
elections: {
|
||||
[index: string]: Codec;
|
||||
candidacyBond: AugmentedConst<BalanceOf>;
|
||||
votingBond: AugmentedConst<BalanceOf>;
|
||||
desiredMembers: AugmentedConst<u32>;
|
||||
desiredRunnersUp: AugmentedConst<u32>;
|
||||
termDuration: AugmentedConst<BlockNumber>;
|
||||
};
|
||||
finalityTracker: {
|
||||
[index: string]: Codec;
|
||||
/**
|
||||
* The number of recent samples to keep from this chain. Default is 101.
|
||||
**/
|
||||
windowSize: AugmentedConst<BlockNumber>;
|
||||
/**
|
||||
* The delay after which point things become suspicious. Default is 1000.
|
||||
**/
|
||||
reportLatency: AugmentedConst<BlockNumber>;
|
||||
};
|
||||
treasury: {
|
||||
[index: string]: Codec;
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
proposalBond: AugmentedConst<Permill>;
|
||||
/**
|
||||
* Minimum amount of funds that should be placed in a deposit for making a proposal.
|
||||
**/
|
||||
proposalBondMinimum: AugmentedConst<BalanceOf>;
|
||||
/**
|
||||
* Period between successive spends.
|
||||
**/
|
||||
spendPeriod: AugmentedConst<BlockNumber>;
|
||||
/**
|
||||
* Percentage of spare funds (if any) that are burnt per spend period.
|
||||
**/
|
||||
burn: AugmentedConst<Permill>;
|
||||
/**
|
||||
* The period for which a tip remains open after is has achieved threshold tippers.
|
||||
**/
|
||||
tipCountdown: AugmentedConst<BlockNumber>;
|
||||
/**
|
||||
* The amount of the final tip which goes to the original reporter of the tip.
|
||||
**/
|
||||
tipFindersFee: AugmentedConst<Percent>;
|
||||
/**
|
||||
* The amount held on deposit for placing a tip report.
|
||||
**/
|
||||
tipReportDepositBase: AugmentedConst<BalanceOf>;
|
||||
/**
|
||||
* The amount held on deposit per byte within the tip report reason.
|
||||
**/
|
||||
tipReportDepositPerByte: AugmentedConst<BalanceOf>;
|
||||
};
|
||||
contracts: {
|
||||
[index: string]: Codec;
|
||||
/**
|
||||
* Number of block delay an extrinsic claim surcharge has.
|
||||
* When claim surcharge is called by an extrinsic the rent is checked
|
||||
* for current_block - delay
|
||||
**/
|
||||
signedClaimHandicap: AugmentedConst<BlockNumber>;
|
||||
/**
|
||||
* The minimum amount required to generate a tombstone.
|
||||
**/
|
||||
tombstoneDeposit: AugmentedConst<BalanceOf>;
|
||||
/**
|
||||
* Size of a contract at the time of instantiaion. This is a simple way to ensure that
|
||||
* empty contracts eventually gets deleted.
|
||||
**/
|
||||
storageSizeOffset: AugmentedConst<u32>;
|
||||
/**
|
||||
* Price of a byte of storage per one block interval. Should be greater than 0.
|
||||
**/
|
||||
rentByteFee: AugmentedConst<BalanceOf>;
|
||||
/**
|
||||
* The amount of funds a contract should deposit in order to offset
|
||||
* the cost of one byte.
|
||||
* Let's suppose the deposit is 1,000 BU (balance units)/byte and the rent is 1 BU/byte/day,
|
||||
* then a contract with 1,000,000 BU that uses 1,000 bytes of storage would pay no rent.
|
||||
* But if the balance reduced to 500,000 BU and the storage stayed the same at 1,000,
|
||||
* then it would pay 500 BU/day.
|
||||
**/
|
||||
rentDepositOffset: AugmentedConst<BalanceOf>;
|
||||
/**
|
||||
* Reward that is received by the party whose touch has led
|
||||
* to removal of a contract.
|
||||
**/
|
||||
surchargeReward: AugmentedConst<BalanceOf>;
|
||||
/**
|
||||
* The fee to be paid for making a transaction; the base.
|
||||
**/
|
||||
transactionBaseFee: AugmentedConst<BalanceOf>;
|
||||
/**
|
||||
* The fee to be paid for making a transaction; the per-byte portion.
|
||||
**/
|
||||
transactionByteFee: AugmentedConst<BalanceOf>;
|
||||
/**
|
||||
* The fee required to instantiate a contract instance. A reasonable default value
|
||||
* is 21.
|
||||
**/
|
||||
contractFee: AugmentedConst<BalanceOf>;
|
||||
/**
|
||||
* The base fee charged for calling into a contract. A reasonable default
|
||||
* value is 135.
|
||||
**/
|
||||
callBaseFee: AugmentedConst<Gas>;
|
||||
/**
|
||||
* The base fee charged for instantiating a contract. A reasonable default value
|
||||
* is 175.
|
||||
**/
|
||||
instantiateBaseFee: AugmentedConst<Gas>;
|
||||
/**
|
||||
* The maximum nesting level of a call/instantiate stack. A reasonable default
|
||||
* value is 100.
|
||||
**/
|
||||
maxDepth: AugmentedConst<u32>;
|
||||
/**
|
||||
* The maximum size of a storage value in bytes. A reasonable default is 16 KiB.
|
||||
**/
|
||||
maxValueSize: AugmentedConst<u32>;
|
||||
/**
|
||||
* The maximum amount of gas that could be expended per block. A reasonable
|
||||
* default value is 10_000_000.
|
||||
**/
|
||||
blockGasLimit: AugmentedConst<Gas>;
|
||||
};
|
||||
society: {
|
||||
[index: string]: Codec;
|
||||
/**
|
||||
* The minimum amount of a deposit required for a bid to be made.
|
||||
**/
|
||||
candidateDeposit: AugmentedConst<BalanceOf>;
|
||||
/**
|
||||
* The amount of the unpaid reward that gets deducted in the case that either a skeptic
|
||||
* doesn't vote or someone votes in the wrong way.
|
||||
**/
|
||||
wrongSideDeduction: AugmentedConst<BalanceOf>;
|
||||
/**
|
||||
* The number of times a member may vote the wrong way (or not at all, when they are a skeptic)
|
||||
* before they become suspended.
|
||||
**/
|
||||
maxStrikes: AugmentedConst<u32>;
|
||||
/**
|
||||
* The amount of incentive paid within each period. Doesn't include VoterTip.
|
||||
**/
|
||||
periodSpend: AugmentedConst<BalanceOf>;
|
||||
/**
|
||||
* The number of blocks between candidate/membership rotation periods.
|
||||
**/
|
||||
rotationPeriod: AugmentedConst<BlockNumber>;
|
||||
/**
|
||||
* The number of blocks between membership challenges.
|
||||
**/
|
||||
challengePeriod: AugmentedConst<BlockNumber>;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright 2017-2020 @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 './consts';
|
||||
import './query';
|
||||
import './rpc';
|
||||
import './tx';
|
||||
@@ -0,0 +1,797 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
|
||||
import { AnyNumber, ITuple } from '@polkadot/types/types';
|
||||
import { Option, Raw, Vec } from '@polkadot/types/codec';
|
||||
import { Bytes, Data, bool, u32, u64 } from '@polkadot/types/primitive';
|
||||
import { AccountId, AccountIndex, Balance, BalanceOf, BlockNumber, Hash, Index, KeyTypeId, Moment, Perbill, ValidatorId, Weight } from '@polkadot/types/interfaces/runtime';
|
||||
import { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
|
||||
import { BabeAuthorityWeight, MaybeVrf } from '@polkadot/types/interfaces/babe';
|
||||
import { AccountData, BalanceLock } 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 { Vote, VoteThreshold } from '@polkadot/types/interfaces/elections';
|
||||
import { AuthorityList, SetId, StoredPendingChange, StoredState } from '@polkadot/types/interfaces/grandpa';
|
||||
import { RegistrarInfo, Registration } from '@polkadot/types/interfaces/identity';
|
||||
import { AuthIndex } from '@polkadot/types/interfaces/imOnline';
|
||||
import { Kind, OffenceDetails, OpaqueTimeSlot, ReportIdOf } from '@polkadot/types/interfaces/offences';
|
||||
import { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
|
||||
import { Keys, SessionIndex } from '@polkadot/types/interfaces/session';
|
||||
import { Bid, BidKind, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
|
||||
import { EraIndex, EraPoints, Exposure, Forcing, MomentOf, Nominations, RewardDestination, SlashingSpans, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
|
||||
import { DigestOf, EventIndex, EventRecord } from '@polkadot/types/interfaces/system';
|
||||
import { OpenTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
|
||||
import { Multiplier } from '@polkadot/types/interfaces/txpayment';
|
||||
import { Multisig } from '@polkadot/types/interfaces/utility';
|
||||
import { VestingInfo } from '@polkadot/types/interfaces/vesting';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
declare module '@polkadot/api/types/storage' {
|
||||
export interface AugmentedQueries<ApiType> {
|
||||
system: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The full account information for a particular account ID.
|
||||
**/
|
||||
account: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ITuple<[Index, AccountData]>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Total extrinsics count for the current block.
|
||||
**/
|
||||
extrinsicCount: AugmentedQuery<ApiType, () => Observable<Option<u32>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Total weight for all extrinsics put together, for the current block.
|
||||
**/
|
||||
allExtrinsicsWeight: AugmentedQuery<ApiType, () => Observable<Option<Weight>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Total length (in bytes) for all extrinsics put together, for the current block.
|
||||
**/
|
||||
allExtrinsicsLen: AugmentedQuery<ApiType, () => Observable<Option<u32>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Map of block numbers to block hashes.
|
||||
**/
|
||||
blockHash: AugmentedQuery<ApiType, (arg: BlockNumber | AnyNumber | Uint8Array) => Observable<Hash>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Extrinsics data for the current block (maps an extrinsic's index to its data).
|
||||
**/
|
||||
extrinsicData: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Bytes>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The current block number being processed. Set by `execute_block`.
|
||||
**/
|
||||
number: AugmentedQuery<ApiType, () => Observable<BlockNumber>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Hash of the previous block.
|
||||
**/
|
||||
parentHash: AugmentedQuery<ApiType, () => Observable<Hash>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Extrinsics root of the current block, also part of the block header.
|
||||
**/
|
||||
extrinsicsRoot: AugmentedQuery<ApiType, () => Observable<Hash>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Digest of the current block, also part of the block header.
|
||||
**/
|
||||
digest: AugmentedQuery<ApiType, () => Observable<DigestOf>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Events deposited for the current block.
|
||||
**/
|
||||
events: AugmentedQuery<ApiType, () => Observable<Vec<EventRecord>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The number of events in the `Events<T>` list.
|
||||
**/
|
||||
eventCount: AugmentedQuery<ApiType, () => Observable<EventIndex>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Mapping between a topic (represented by T::Hash) and a vector of indexes
|
||||
* of events in the `<Events<T>>` list.
|
||||
* 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.
|
||||
**/
|
||||
eventTopics: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Vec<ITuple<[BlockNumber, EventIndex]>>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
utility: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The set of open multisig operations.
|
||||
**/
|
||||
multisigs: AugmentedQueryDoubleMap<ApiType, (key1: AccountId | string | Uint8Array, key2: Raw | string | Uint8Array) => Observable<Option<Multisig>>, AccountId | string | Uint8Array> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
babe: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Current epoch index.
|
||||
**/
|
||||
epochIndex: AugmentedQuery<ApiType, () => Observable<u64>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Current epoch authorities.
|
||||
**/
|
||||
authorities: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[AuthorityId, BabeAuthorityWeight]>>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The slot at which the first epoch actually started. This is 0
|
||||
* until the first block of the chain.
|
||||
**/
|
||||
genesisSlot: AugmentedQuery<ApiType, () => Observable<u64>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Current slot number.
|
||||
**/
|
||||
currentSlot: AugmentedQuery<ApiType, () => Observable<u64>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
randomness: AugmentedQuery<ApiType, () => Observable<Raw>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Next epoch randomness.
|
||||
**/
|
||||
nextRandomness: AugmentedQuery<ApiType, () => Observable<Raw>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
segmentIndex: AugmentedQuery<ApiType, () => Observable<u32>> & QueryableStorageEntry<ApiType>;
|
||||
underConstruction: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Vec<Raw>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Temporary value (cleared at block finalization) which is `Some`
|
||||
* if per-block initialization has already been called for current block.
|
||||
**/
|
||||
initialized: AugmentedQuery<ApiType, () => Observable<Option<MaybeVrf>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
timestamp: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Current time for the current block.
|
||||
**/
|
||||
now: AugmentedQuery<ApiType, () => Observable<Moment>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Did the timestamp get updated in this block?
|
||||
**/
|
||||
didUpdate: AugmentedQuery<ApiType, () => Observable<bool>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
authorship: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Uncles
|
||||
**/
|
||||
uncles: AugmentedQuery<ApiType, () => Observable<Vec<UncleEntryItem>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Author of current block.
|
||||
**/
|
||||
author: AugmentedQuery<ApiType, () => Observable<Option<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Whether uncles were already set in this block.
|
||||
**/
|
||||
didSetUncles: AugmentedQuery<ApiType, () => Observable<bool>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
indices: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The lookup from index to account.
|
||||
**/
|
||||
accounts: AugmentedQuery<ApiType, (arg: AccountIndex | AnyNumber | Uint8Array) => Observable<Option<ITuple<[AccountId, BalanceOf]>>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
balances: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The total units issued in the system.
|
||||
**/
|
||||
totalIssuance: AugmentedQuery<ApiType, () => Observable<Balance>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The balance of an account.
|
||||
* NOTE: THIS MAY NEVER BE IN EXISTENCE AND YET HAVE A `total().is_zero()`. If the total
|
||||
* is ever zero, then the entry *MUST* be removed.
|
||||
* NOTE: This is only used in the case that this module is used to store balances.
|
||||
**/
|
||||
account: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<AccountData>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Any liquidity locks on some account balances.
|
||||
* NOTE: Should only be accessed when setting, changing and freeing a lock.
|
||||
**/
|
||||
locks: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Vec<BalanceLock>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* True if network has been upgraded to this version.
|
||||
* True for new networks.
|
||||
**/
|
||||
isUpgraded: AugmentedQuery<ApiType, () => Observable<bool>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
transactionPayment: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
nextFeeMultiplier: AugmentedQuery<ApiType, () => Observable<Multiplier>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
staking: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The ideal number of staking participants.
|
||||
**/
|
||||
validatorCount: AugmentedQuery<ApiType, () => Observable<u32>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Minimum number of staking participants before emergency conditions are imposed.
|
||||
**/
|
||||
minimumValidatorCount: AugmentedQuery<ApiType, () => Observable<u32>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
invulnerables: AugmentedQuery<ApiType, () => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Map from all locked "stash" accounts to the controller account.
|
||||
**/
|
||||
bonded: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Map from all (unlocked) "controller" accounts to the info regarding the staking.
|
||||
**/
|
||||
ledger: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<StakingLedger>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Where the reward payment should be made. Keyed by stash.
|
||||
**/
|
||||
payee: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<RewardDestination>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The map from (wannabe) validator stash key to the preferences of that validator.
|
||||
**/
|
||||
validators: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ValidatorPrefs>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The map from nominator stash key to the set of stash keys of all validators to nominate.
|
||||
* NOTE: is private so that we can ensure upgraded before all typical accesses.
|
||||
* Direct storage APIs can still bypass this protection.
|
||||
**/
|
||||
nominators: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<Nominations>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
stakers: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Exposure>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The currently elected validator set keyed by stash account ID.
|
||||
**/
|
||||
currentElected: AugmentedQuery<ApiType, () => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The current era index.
|
||||
**/
|
||||
currentEra: AugmentedQuery<ApiType, () => Observable<EraIndex>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The start of the current era.
|
||||
**/
|
||||
currentEraStart: AugmentedQuery<ApiType, () => Observable<MomentOf>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The session index at which the current era started.
|
||||
**/
|
||||
currentEraStartSessionIndex: AugmentedQuery<ApiType, () => Observable<SessionIndex>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Rewards for the current era. Using indices of current elected set.
|
||||
**/
|
||||
currentEraPointsEarned: AugmentedQuery<ApiType, () => Observable<EraPoints>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The amount of balance actively at stake for each validator slot, currently.
|
||||
* This is used to derive rewards and punishments.
|
||||
**/
|
||||
slotStake: AugmentedQuery<ApiType, () => Observable<BalanceOf>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* True if the next session change will be a new era regardless of index.
|
||||
**/
|
||||
forceEra: AugmentedQuery<ApiType, () => Observable<Forcing>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The percentage of the slash that is distributed to reporters.
|
||||
* The rest of the slashed value is handled by the `Slash`.
|
||||
**/
|
||||
slashRewardFraction: AugmentedQuery<ApiType, () => Observable<Perbill>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The amount of currency given to reporters of a slash event which was
|
||||
* canceled by extraordinary circumstances (e.g. governance).
|
||||
**/
|
||||
canceledSlashPayout: AugmentedQuery<ApiType, () => Observable<BalanceOf>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* All unapplied slashes that are queued for later.
|
||||
**/
|
||||
unappliedSlashes: AugmentedQuery<ApiType, (arg: EraIndex | AnyNumber | Uint8Array) => Observable<Vec<UnappliedSlash>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* A mapping from still-bonded eras to the first session index of that era.
|
||||
**/
|
||||
bondedEras: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[EraIndex, SessionIndex]>>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* All slashing events on validators, mapped by era to the highest slash proportion
|
||||
* and slash value of the era.
|
||||
**/
|
||||
validatorSlashInEra: AugmentedQueryDoubleMap<ApiType, (key1: EraIndex | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<Option<ITuple<[Perbill, BalanceOf]>>>, EraIndex | AnyNumber | Uint8Array> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* All slashing events on nominators, mapped by era to the highest slash value of the era.
|
||||
**/
|
||||
nominatorSlashInEra: AugmentedQueryDoubleMap<ApiType, (key1: EraIndex | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<Option<BalanceOf>>, EraIndex | AnyNumber | Uint8Array> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Slashing spans for stash accounts.
|
||||
**/
|
||||
slashingSpans: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<SlashingSpans>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Records information about the maximum slash of a stash within a slashing span,
|
||||
* as well as how much reward has been paid out.
|
||||
**/
|
||||
spanSlash: AugmentedQuery<ApiType, (arg: ITuple<[AccountId, SpanIndex]>) => Observable<SpanRecord>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The earliest era for which we have a pending, unapplied slash.
|
||||
**/
|
||||
earliestUnappliedSlash: AugmentedQuery<ApiType, () => Observable<Option<EraIndex>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
session: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The current set of validators.
|
||||
**/
|
||||
validators: AugmentedQuery<ApiType, () => Observable<Vec<ValidatorId>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Current index of the session.
|
||||
**/
|
||||
currentIndex: AugmentedQuery<ApiType, () => Observable<SessionIndex>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* True if the underlying economic identities or weighting behind the validators
|
||||
* has changed in the queued validator set.
|
||||
**/
|
||||
queuedChanged: AugmentedQuery<ApiType, () => Observable<bool>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The queued keys for the next session. When the next session begins, these keys
|
||||
* will be used to determine the validator's session keys.
|
||||
**/
|
||||
queuedKeys: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[ValidatorId, Keys]>>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Indices of disabled validators.
|
||||
* The set is cleared when `on_session_ending` returns a new set of identities.
|
||||
**/
|
||||
disabledValidators: AugmentedQuery<ApiType, () => Observable<Vec<u32>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
nextKeys: AugmentedQueryDoubleMap<ApiType, (key1: Bytes | string | Uint8Array, key2: ValidatorId | string | Uint8Array) => Observable<Option<Keys>>, Bytes | string | Uint8Array> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
keyOwner: AugmentedQueryDoubleMap<ApiType, (key1: Bytes | string | Uint8Array, key2: ITuple<[KeyTypeId, Bytes]>) => Observable<Option<ValidatorId>>, Bytes | string | Uint8Array> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
democracy: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The number of (public) proposals that have been made so far.
|
||||
**/
|
||||
publicPropCount: AugmentedQuery<ApiType, () => Observable<PropIndex>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The public proposals. Unsorted. The second item is the proposal's hash.
|
||||
**/
|
||||
publicProps: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[PropIndex, Hash, AccountId]>>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Map of hashes to the proposal preimage, along with who registered it and their deposit.
|
||||
* The block number is the block at which it was deposited.
|
||||
**/
|
||||
preimages: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Option<ITuple<[Bytes, AccountId, BalanceOf, BlockNumber]>>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Those who have locked a deposit.
|
||||
**/
|
||||
depositOf: AugmentedQuery<ApiType, (arg: PropIndex | AnyNumber | Uint8Array) => Observable<Option<ITuple<[BalanceOf, Vec<AccountId>]>>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The next free referendum index, aka the number of referenda started so far.
|
||||
**/
|
||||
referendumCount: AugmentedQuery<ApiType, () => Observable<ReferendumIndex>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The lowest referendum index representing an unbaked referendum. Equal to
|
||||
* `ReferendumCount` if there isn't a unbaked referendum.
|
||||
**/
|
||||
lowestUnbaked: AugmentedQuery<ApiType, () => Observable<ReferendumIndex>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Information concerning any given referendum.
|
||||
**/
|
||||
referendumInfoOf: AugmentedQuery<ApiType, (arg: ReferendumIndex | AnyNumber | Uint8Array) => Observable<Option<ReferendumInfo>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Queue of successful referenda to be dispatched. Stored ordered by block number.
|
||||
**/
|
||||
dispatchQueue: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[BlockNumber, Hash, ReferendumIndex]>>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Get the voters for the current proposal.
|
||||
**/
|
||||
votersFor: AugmentedQuery<ApiType, (arg: ReferendumIndex | AnyNumber | Uint8Array) => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* 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::contains_key` first.
|
||||
**/
|
||||
voteOf: AugmentedQuery<ApiType, (arg: ITuple<[ReferendumIndex, AccountId]>) => Observable<Vote>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Who is able to vote for whom. Value is the fund-holding account, key is the
|
||||
* vote-transaction-sending account.
|
||||
**/
|
||||
proxy: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Get the account (and lock periods) to which another account is delegating vote.
|
||||
**/
|
||||
delegations: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ITuple<[AccountId, Conviction]>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Accounts for which there are locks in action which may be removed at some point in the
|
||||
* future. The value is the block number at which the lock expires and may be removed.
|
||||
**/
|
||||
locks: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<BlockNumber>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* True if the last referendum tabled was submitted externally. False if it was a public
|
||||
* proposal.
|
||||
**/
|
||||
lastTabledWasExternal: AugmentedQuery<ApiType, () => Observable<bool>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
nextExternal: AugmentedQuery<ApiType, () => Observable<Option<ITuple<[Hash, VoteThreshold]>>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
blacklist: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Option<ITuple<[BlockNumber, Vec<AccountId>]>>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Record of all proposals that have been subject to emergency cancellation.
|
||||
**/
|
||||
cancellations: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<bool>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
council: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The hashes of the active proposals.
|
||||
**/
|
||||
proposals: AugmentedQuery<ApiType, () => Observable<Vec<Hash>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Actual proposal for a given hash, if it's current.
|
||||
**/
|
||||
proposalOf: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Option<Proposal>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Votes on a given proposal, if it is ongoing.
|
||||
**/
|
||||
voting: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Option<Votes>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Proposals so far.
|
||||
**/
|
||||
proposalCount: AugmentedQuery<ApiType, () => Observable<u32>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The current members of the collective. This is stored sorted (just by value).
|
||||
**/
|
||||
members: AugmentedQuery<ApiType, () => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
technicalCommittee: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The hashes of the active proposals.
|
||||
**/
|
||||
proposals: AugmentedQuery<ApiType, () => Observable<Vec<Hash>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Actual proposal for a given hash, if it's current.
|
||||
**/
|
||||
proposalOf: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Option<Proposal>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Votes on a given proposal, if it is ongoing.
|
||||
**/
|
||||
voting: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Option<Votes>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Proposals so far.
|
||||
**/
|
||||
proposalCount: AugmentedQuery<ApiType, () => Observable<u32>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The current members of the collective. This is stored sorted (just by value).
|
||||
**/
|
||||
members: AugmentedQuery<ApiType, () => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
elections: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The current elected membership. Sorted based on account id.
|
||||
**/
|
||||
members: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[AccountId, BalanceOf]>>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The current runners_up. Sorted based on low to high merit (worse to best runner).
|
||||
**/
|
||||
runnersUp: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[AccountId, BalanceOf]>>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The total number of vote rounds that have happened, excluding the upcoming one.
|
||||
**/
|
||||
electionRounds: AugmentedQuery<ApiType, () => Observable<u32>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Votes of a particular voter, with the round index of the votes.
|
||||
**/
|
||||
votesOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Locked stake of a voter.
|
||||
**/
|
||||
stakeOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<BalanceOf>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The present candidate list. Sorted based on account-id. A current member or a runner can
|
||||
* never enter this vector and is always implicitly assumed to be a candidate.
|
||||
**/
|
||||
candidates: AugmentedQuery<ApiType, () => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
technicalMembership: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The current membership, stored as an ordered Vec.
|
||||
**/
|
||||
members: AugmentedQuery<ApiType, () => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
grandpa: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* DEPRECATED
|
||||
* This used to store the current authority set, which has been migrated to the well-known
|
||||
* GRANDPA_AUTHORITES_KEY unhashed key.
|
||||
**/
|
||||
authorities: AugmentedQuery<ApiType, () => Observable<AuthorityList>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* State of the current authority set.
|
||||
**/
|
||||
state: AugmentedQuery<ApiType, () => Observable<StoredState>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Pending change: (signaled at, scheduled change).
|
||||
**/
|
||||
pendingChange: AugmentedQuery<ApiType, () => Observable<Option<StoredPendingChange>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* next block number where we can force a change.
|
||||
**/
|
||||
nextForced: AugmentedQuery<ApiType, () => Observable<Option<BlockNumber>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* `true` if we are currently stalled.
|
||||
**/
|
||||
stalled: AugmentedQuery<ApiType, () => Observable<Option<ITuple<[BlockNumber, BlockNumber]>>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The number of changes (both in terms of keys and underlying economic responsibilities)
|
||||
* in the "set" of Grandpa validators from genesis.
|
||||
**/
|
||||
currentSetId: AugmentedQuery<ApiType, () => Observable<SetId>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* A mapping from grandpa set ID to the index of the *most recent* session for which its members were responsible.
|
||||
**/
|
||||
setIdSession: AugmentedQuery<ApiType, (arg: SetId | AnyNumber | Uint8Array) => Observable<Option<SessionIndex>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
treasury: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Number of proposals that have been made.
|
||||
**/
|
||||
proposalCount: AugmentedQuery<ApiType, () => Observable<ProposalIndex>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Proposals that have been made.
|
||||
**/
|
||||
proposals: AugmentedQuery<ApiType, (arg: ProposalIndex | AnyNumber | Uint8Array) => Observable<Option<TreasuryProposal>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Proposal indices that have been approved but not yet awarded.
|
||||
**/
|
||||
approvals: AugmentedQuery<ApiType, () => Observable<Vec<ProposalIndex>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Tips that are not yet completed. Keyed by the hash of `(reason, who)` from the value.
|
||||
* This has the insecure enumerable hash function since the key itself is already
|
||||
* guaranteed to be a secure hash.
|
||||
**/
|
||||
tips: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Option<OpenTip>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Simple preimage lookup from the reason's hash to the original data. Again, has an
|
||||
* insecure enumerable hash since the key is guaranteed to be the result of a secure hash.
|
||||
**/
|
||||
reasons: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Option<Bytes>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
contracts: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Gas spent so far in this block.
|
||||
**/
|
||||
gasSpent: AugmentedQuery<ApiType, () => Observable<Gas>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Current cost schedule for contracts.
|
||||
**/
|
||||
currentSchedule: AugmentedQuery<ApiType, () => Observable<Schedule>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* A mapping from an original code hash to the original code, untouched by instrumentation.
|
||||
**/
|
||||
pristineCode: AugmentedQuery<ApiType, (arg: CodeHash | string | Uint8Array) => Observable<Option<Bytes>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* A mapping between an original code hash and instrumented wasm code, ready for execution.
|
||||
**/
|
||||
codeStorage: AugmentedQuery<ApiType, (arg: CodeHash | string | Uint8Array) => Observable<Option<PrefabWasmModule>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The subtrie counter.
|
||||
**/
|
||||
accountCounter: AugmentedQuery<ApiType, () => Observable<u64>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The code associated with a given account.
|
||||
**/
|
||||
contractInfoOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<ContractInfo>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The price of one unit of gas.
|
||||
**/
|
||||
gasPrice: AugmentedQuery<ApiType, () => Observable<BalanceOf>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
sudo: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The `AccountId` of the sudo key.
|
||||
**/
|
||||
key: AugmentedQuery<ApiType, () => Observable<AccountId>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
imOnline: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The block number after which it's ok to send heartbeats in current session.
|
||||
* At the beginning of each session we set this to a value that should
|
||||
* fall roughly in the middle of the session duration.
|
||||
* The idea is to first wait for the validators to produce a block
|
||||
* in the current session, so that the heartbeat later on will not be necessary.
|
||||
**/
|
||||
heartbeatAfter: AugmentedQuery<ApiType, () => Observable<BlockNumber>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The current set of keys that may issue a heartbeat.
|
||||
**/
|
||||
keys: AugmentedQuery<ApiType, () => Observable<Vec<AuthorityId>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* For each session index, we keep a mapping of `AuthIndex`
|
||||
* to `offchain::OpaqueNetworkState`.
|
||||
**/
|
||||
receivedHeartbeats: AugmentedQueryDoubleMap<ApiType, (key1: SessionIndex | AnyNumber | Uint8Array, key2: AuthIndex | AnyNumber | Uint8Array) => Observable<Option<Bytes>>, SessionIndex | AnyNumber | Uint8Array> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* For each session index, we keep a mapping of `T::ValidatorId` to the
|
||||
* number of blocks authored by the given authority.
|
||||
**/
|
||||
authoredBlocks: AugmentedQueryDoubleMap<ApiType, (key1: SessionIndex | AnyNumber | Uint8Array, key2: ValidatorId | string | Uint8Array) => Observable<u32>, SessionIndex | AnyNumber | Uint8Array> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
offences: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The primary structure that holds all offence records keyed by report identifiers.
|
||||
**/
|
||||
reports: AugmentedQuery<ApiType, (arg: ReportIdOf | string | Uint8Array) => Observable<Option<OffenceDetails>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* A vector of reports of the same kind that happened at the same time slot.
|
||||
**/
|
||||
concurrentReportsIndex: AugmentedQueryDoubleMap<ApiType, (key1: Kind | string | Uint8Array, key2: OpaqueTimeSlot | string | Uint8Array) => Observable<Vec<ReportIdOf>>, Kind | string | Uint8Array> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
reportsByKindIndex: AugmentedQuery<ApiType, (arg: Kind | string | Uint8Array) => Observable<Bytes>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
randomnessCollectiveFlip: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Series of block headers from the last 81 blocks that acts as random seed material. This
|
||||
* is arranged as a ring buffer with `block_number % 81` being the index into the `Vec` of
|
||||
* the oldest hash.
|
||||
**/
|
||||
randomMaterial: AugmentedQuery<ApiType, () => Observable<Vec<Hash>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
identity: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Information that is pertinent to identify the entity behind an account.
|
||||
**/
|
||||
identityOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<Registration>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The super-identity of an alternative "sub" identity together with its name, within that
|
||||
* context. If the account is not some other account's sub-identity, then just `None`.
|
||||
**/
|
||||
superOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<ITuple<[AccountId, Data]>>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Alternative "sub" identities of this account.
|
||||
* The first item is the deposit, the second is a vector of the accounts.
|
||||
**/
|
||||
subsOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ITuple<[BalanceOf, Vec<AccountId>]>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The set of registrars. Not expected to get very big as can only be added through a
|
||||
* special origin (likely a council motion).
|
||||
* The index into this can be cast to `RegistrarIndex` to get a valid value.
|
||||
**/
|
||||
registrars: AugmentedQuery<ApiType, () => Observable<Vec<Option<RegistrarInfo>>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
society: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The first member.
|
||||
**/
|
||||
founder: AugmentedQuery<ApiType, () => Observable<Option<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* A hash of the rules of this society concerning membership. Can only be set once and
|
||||
* only by the founder.
|
||||
**/
|
||||
rules: AugmentedQuery<ApiType, () => Observable<Option<Hash>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The current set of candidates; bidders that are attempting to become members.
|
||||
**/
|
||||
candidates: AugmentedQuery<ApiType, () => Observable<Vec<Bid>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The set of suspended candidates.
|
||||
**/
|
||||
suspendedCandidates: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<ITuple<[BalanceOf, BidKind]>>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Amount of our account balance that is specifically for the next round's bid(s).
|
||||
**/
|
||||
pot: AugmentedQuery<ApiType, () => Observable<BalanceOf>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The most primary from the most recently approved members.
|
||||
**/
|
||||
head: AugmentedQuery<ApiType, () => Observable<Option<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The current set of members, ordered.
|
||||
**/
|
||||
members: AugmentedQuery<ApiType, () => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The set of suspended members.
|
||||
**/
|
||||
suspendedMembers: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<bool>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The current bids, stored ordered by the value of the bid.
|
||||
**/
|
||||
bids: AugmentedQuery<ApiType, () => Observable<Vec<Bid>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Members currently vouching or banned from vouching again
|
||||
**/
|
||||
vouching: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<VouchingStatus>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Pending payouts; ordered by block number, with the amount that should be paid out.
|
||||
**/
|
||||
payouts: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Vec<ITuple<[BlockNumber, BalanceOf]>>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The ongoing number of losing votes cast by the member.
|
||||
**/
|
||||
strikes: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<StrikeCount>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Double map from Candidate -> Voter -> (Maybe) Vote.
|
||||
**/
|
||||
votes: AugmentedQueryDoubleMap<ApiType, (key1: AccountId | string | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<Option<SocietyVote>>, AccountId | string | Uint8Array> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The defending member currently being challenged.
|
||||
**/
|
||||
defender: AugmentedQuery<ApiType, () => Observable<Option<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Votes for the defender.
|
||||
**/
|
||||
defenderVotes: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<SocietyVote>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The max number of members for the society at one time.
|
||||
**/
|
||||
maxMembers: AugmentedQuery<ApiType, () => Observable<u32>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
recovery: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The set of recoverable accounts and their recovery configuration.
|
||||
**/
|
||||
recoverable: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<RecoveryConfig>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Active recovery attempts.
|
||||
* First account is the account to be recovered, and the second account
|
||||
* is the user trying to recover the account.
|
||||
**/
|
||||
activeRecoveries: AugmentedQueryDoubleMap<ApiType, (key1: AccountId | string | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<Option<ActiveRecovery>>, AccountId | string | Uint8Array> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The final list of recovered accounts.
|
||||
* Map from the recovered account to the user who can access it.
|
||||
**/
|
||||
recovered: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<AccountId>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
vesting: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Information regarding the vesting of a given account.
|
||||
**/
|
||||
vesting: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<VestingInfo>>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
|
||||
import { AnyNumber, Codec, IExtrinsic } from '@polkadot/types/types';
|
||||
import { Option, Vec } from '@polkadot/types/codec';
|
||||
import { Bytes, H256, StorageData, StorageKey, Text, bool, u32, u64 } from '@polkadot/types/primitive';
|
||||
import { Metadata } from '@polkadot/types';
|
||||
import { AccountId, BlockNumber, Extrinsic, Hash, Header, Index, SignedBlock } from '@polkadot/types/interfaces/runtime';
|
||||
import { ContractCallRequest, ContractExecResult } from '@polkadot/types/interfaces/contracts';
|
||||
import { BlockHash, ChainProperties, ExtrinsicOrHash, ExtrinsicStatus, Health, NetworkState, PeerInfo, RpcMethods, RuntimeDispatchInfo, RuntimeVersion, StorageChangeSet } from '@polkadot/types/interfaces/rpc';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
export interface RpcInterface {
|
||||
account: {
|
||||
/**
|
||||
* Retrieves the next accountIndex as available on the node
|
||||
**/
|
||||
nextIndex(accountId: AccountId | string | Uint8Array): Observable<Index>;
|
||||
};
|
||||
author: {
|
||||
/**
|
||||
* Returns true if the keystore has private keys for the given public key and key type.
|
||||
**/
|
||||
hasKey(publicKey: Bytes | string | Uint8Array, keyType: Text | string): Observable<bool>;
|
||||
/**
|
||||
* Returns true if the keystore has private keys for the given session public keys.
|
||||
**/
|
||||
hasSessionKeys(sessionKeys: Bytes | string | Uint8Array): Observable<bool>;
|
||||
/**
|
||||
* Insert a key into the keystore.
|
||||
**/
|
||||
insertKey(keyType: Text | string, suri: Text | string, publicKey: Bytes | string | Uint8Array): Observable<Bytes>;
|
||||
/**
|
||||
* Returns all pending extrinsics, potentially grouped by sender
|
||||
**/
|
||||
pendingExtrinsics(): Observable<Vec<Extrinsic>>;
|
||||
/**
|
||||
* Remove given extrinsic from the pool and temporarily ban it to prevent reimporting
|
||||
**/
|
||||
removeExtrinsic(bytesOrHash: Vec<ExtrinsicOrHash> | (ExtrinsicOrHash | { hash: any } | { extrinsic: any } | string | Uint8Array)[]): Observable<Vec<Hash>>;
|
||||
/**
|
||||
* Generate new session keys and returns the corresponding public keys
|
||||
**/
|
||||
rotateKeys(): Observable<Bytes>;
|
||||
/**
|
||||
* Submit and subscribe to watch an extrinsic until unsubscribed
|
||||
**/
|
||||
submitAndWatchExtrinsic(extrinsic: IExtrinsic): Observable<ExtrinsicStatus>;
|
||||
/**
|
||||
* Submit a fully formatted extrinsic for block inclusion
|
||||
**/
|
||||
submitExtrinsic(extrinsic: IExtrinsic): Observable<Hash>;
|
||||
};
|
||||
chain: {
|
||||
/**
|
||||
* Get header and body of a relay chain block
|
||||
**/
|
||||
getBlock(hash?: BlockHash | string | Uint8Array): Observable<SignedBlock>;
|
||||
/**
|
||||
* Get the block hash for a specific block
|
||||
**/
|
||||
getBlockHash(blockNumber?: BlockNumber | AnyNumber | Uint8Array): Observable<BlockHash>;
|
||||
/**
|
||||
* Get hash of the last finalized block in the canon chain
|
||||
**/
|
||||
getFinalizedHead(): Observable<BlockHash>;
|
||||
/**
|
||||
* Retrieves the header for a specific block
|
||||
**/
|
||||
getHeader(hash?: BlockHash | string | Uint8Array): Observable<Header>;
|
||||
/**
|
||||
* Retrieves the best finalized header via subscription
|
||||
**/
|
||||
subscribeFinalizedHeads(): Observable<Header>;
|
||||
/**
|
||||
* Retrieves the best header via subscription
|
||||
**/
|
||||
subscribeNewHeads(): Observable<Header>;
|
||||
};
|
||||
contracts: {
|
||||
/**
|
||||
* Executes a call to a contract
|
||||
**/
|
||||
call(callRequest: ContractCallRequest | { origin?: any; dest?: any; value?: any; gasLimit?: any; inputData?: any } | string | Uint8Array, at?: BlockHash | string | Uint8Array): Observable<ContractExecResult>;
|
||||
/**
|
||||
* Returns the value under a specified storage key in a contract
|
||||
**/
|
||||
getStorage(address: AccountId | string | Uint8Array, key: H256 | string | Uint8Array, at?: BlockHash | string | Uint8Array): Observable<Option<Bytes>>;
|
||||
};
|
||||
payment: {
|
||||
/**
|
||||
* Retrieves the fee information for an encoded extrinsic
|
||||
**/
|
||||
queryInfo(extrinsic: Bytes | string | Uint8Array, at?: BlockHash | string | Uint8Array): Observable<RuntimeDispatchInfo>;
|
||||
};
|
||||
rpc: {
|
||||
/**
|
||||
* Retrieves the list of RPC methods that are exposed by the node
|
||||
**/
|
||||
methods(): Observable<RpcMethods>;
|
||||
};
|
||||
state: {
|
||||
/**
|
||||
* Perform a call to a builtin on the chain
|
||||
**/
|
||||
call(method: Text | string, data: Bytes | string | Uint8Array, at?: BlockHash | string | Uint8Array): Observable<Bytes>;
|
||||
/**
|
||||
* Retrieves the keys with prefix of a specific child storage
|
||||
**/
|
||||
getChildKeys(childStorageKey: StorageKey | string | Uint8Array | any, childDefinition: StorageKey | string | Uint8Array | any, childType: u32 | AnyNumber | Uint8Array, key: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array): Observable<Vec<StorageKey>>;
|
||||
/**
|
||||
* Retrieves the child storage for a key
|
||||
**/
|
||||
getChildStorage(childStorageKey: StorageKey | string | Uint8Array | any, childDefinition: StorageKey | string | Uint8Array | any, childType: u32 | AnyNumber | Uint8Array, key: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array): Observable<StorageData>;
|
||||
/**
|
||||
* Retrieves the child storage hash
|
||||
**/
|
||||
getChildStorageHash(childStorageKey: StorageKey | string | Uint8Array | any, childDefinition: StorageKey | string | Uint8Array | any, childType: u32 | AnyNumber | Uint8Array, key: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array): Observable<Hash>;
|
||||
/**
|
||||
* Retrieves the child storage size
|
||||
**/
|
||||
getChildStorageSize(childStorageKey: StorageKey | string | Uint8Array | any, childDefinition: StorageKey | string | Uint8Array | any, childType: u32 | AnyNumber | Uint8Array, key: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array): Observable<u64>;
|
||||
/**
|
||||
* Retrieves the keys with a certain prefix
|
||||
**/
|
||||
getKeys(key: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array): Observable<Vec<StorageKey>>;
|
||||
/**
|
||||
* Returns the runtime metadata
|
||||
**/
|
||||
getMetadata(at?: BlockHash | string | Uint8Array): Observable<Metadata>;
|
||||
/**
|
||||
* Get the runtime version
|
||||
**/
|
||||
getRuntimeVersion(at?: BlockHash | string | Uint8Array): Observable<RuntimeVersion>;
|
||||
getStorage<T = Codec>(key: any, block?: Hash | Uint8Array | string): Observable<T>;
|
||||
/**
|
||||
* Retrieves the storage hash
|
||||
**/
|
||||
getStorageHash(key: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array): Observable<Hash>;
|
||||
/**
|
||||
* Retrieves the storage size
|
||||
**/
|
||||
getStorageSize(key: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array): Observable<u64>;
|
||||
/**
|
||||
* Query historical storage entries (by key) starting from a start block
|
||||
**/
|
||||
queryStorage(keys: Vec<StorageKey> | (StorageKey | string | Uint8Array | any)[], startBlock: Hash | string | Uint8Array, at?: BlockHash | string | Uint8Array): Observable<Vec<StorageChangeSet>>;
|
||||
/**
|
||||
* Retrieves the runtime version via subscription
|
||||
**/
|
||||
subscribeRuntimeVersion(): Observable<RuntimeVersion>;
|
||||
subscribeStorage<T = Codec[]>(keys: any[]): Observable<T>;
|
||||
};
|
||||
system: {
|
||||
/**
|
||||
* Retrieves the chain
|
||||
**/
|
||||
chain(): Observable<Text>;
|
||||
/**
|
||||
* Return health status of the node
|
||||
**/
|
||||
health(): Observable<Health>;
|
||||
/**
|
||||
* Retrieves the node name
|
||||
**/
|
||||
name(): Observable<Text>;
|
||||
/**
|
||||
* Returns current state of the network
|
||||
**/
|
||||
networkState(): Observable<NetworkState>;
|
||||
/**
|
||||
* Returns the currently connected peers
|
||||
**/
|
||||
peers(): Observable<Vec<PeerInfo>>;
|
||||
/**
|
||||
* Get a custom set of properties as a JSON object, defined in the chain spec
|
||||
**/
|
||||
properties(): Observable<ChainProperties>;
|
||||
/**
|
||||
* Retrieves the version of the node
|
||||
**/
|
||||
version(): Observable<Text>;
|
||||
};
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,70 @@
|
||||
// Copyright 2017-2020 @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 { Observable } from 'rxjs';
|
||||
import { AnyFunction, Callback, Codec } from '@polkadot/types/types';
|
||||
|
||||
// Prepend an element V onto the beginning of a tuple T.
|
||||
// Cons<1, [2,3,4]> is [1,2,3,4]
|
||||
type Cons<V, T extends any[]> = ((v: V, ...t: T) => void) extends ((...r: infer R) => void)
|
||||
? R
|
||||
: never;
|
||||
|
||||
// Append an element V onto the end of a tuple T
|
||||
// Push<[1,2,3],4> is [1,2,3,4]
|
||||
// note that this DOES NOT PRESERVE optionality/readonly in tuples.
|
||||
// So unfortunately Push<[1, 2?, 3?], 4> is [1,2|undefined,3|undefined,4]
|
||||
type Push<T extends any[], V> = (
|
||||
(
|
||||
Cons<any, Required<T>> extends infer R
|
||||
? { [K in keyof R]: K extends keyof T ? T[K] : V }
|
||||
: never
|
||||
) extends infer P
|
||||
? P extends any[] ? P : never
|
||||
: never
|
||||
);
|
||||
|
||||
export type ApiTypes = 'promise' | 'rxjs';
|
||||
|
||||
// Returns the inner type of an Observable
|
||||
export type ObsInnerType<O extends Observable<any>> = O extends Observable<infer U> ? U : never;
|
||||
|
||||
export type UnsubscribePromise = Promise<() => void>;
|
||||
|
||||
// FIXME The day TS has higher-kinded types, we can remove this hardcoded stuff
|
||||
export type PromiseOrObs<ApiType extends ApiTypes, T> = ApiType extends 'rxjs'
|
||||
? Observable<T>
|
||||
: Promise<T>;
|
||||
|
||||
// Here are the return types of these parts of the api:
|
||||
// - api.query.*.*: no exact typings
|
||||
// - api.tx.*.*: SubmittableExtrinsic<ApiType extends ApiTypes>
|
||||
// - api.derive.*.*: MethodResult<ApiType, F>
|
||||
// - api.rpc.*.*: no exact typings (for now, FIXME: should be MethodResult<ApiType, F>, like in derive)
|
||||
|
||||
// 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 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 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 MethodResult<ApiType extends ApiTypes, F extends AnyFunction> = ApiType extends 'rxjs'
|
||||
? RxResult<F>
|
||||
: PromiseResult<F>;
|
||||
|
||||
// In the abstract `decorateMethod` in Base.ts, we can also pass in some meta-
|
||||
// information. This describes it.
|
||||
export interface DecorateMethodOptions {
|
||||
methodName?: string;
|
||||
}
|
||||
|
||||
export type DecorateMethod<ApiType extends ApiTypes> = <Method extends (...args: any[]) => Observable<any>>(method: Method, options?: DecorateMethodOptions) => any;
|
||||
@@ -0,0 +1,130 @@
|
||||
// Copyright 2017-2020 @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.
|
||||
|
||||
// Module augmentation so that `api.{consts,query,rpc,tx}.*.*` work
|
||||
import './augment';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { DeriveCustom, ExactDerive } from '@polkadot/api-derive';
|
||||
import { Constants } from '@polkadot/metadata/Decorated/types';
|
||||
import { RpcInterface, UserRpc } from '@polkadot/rpc-core/types';
|
||||
import { Metadata } from '@polkadot/types';
|
||||
import { Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import { RegistryTypes, SignatureOptions, SignerPayloadJSON, SignerPayloadRaw, Registry } from '@polkadot/types/types';
|
||||
|
||||
import ApiBase from '../base';
|
||||
import { SubmittableResultImpl } from '../submittable/types';
|
||||
import { DeriveAllSections } from '../util/decorate';
|
||||
import { DecoratedRpc } from './rpc';
|
||||
import { QueryableStorage, QueryableStorageMulti } from './storage';
|
||||
import { SubmittableExtrinsics } from './submittable';
|
||||
import { ProviderInterface, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types';
|
||||
|
||||
export * from '../submittable/types';
|
||||
export * from './base';
|
||||
export * from './rpc';
|
||||
export * from './storage';
|
||||
export * from './submittable';
|
||||
|
||||
export interface ApiOptions {
|
||||
/**
|
||||
* @description Add custom derives to be injected
|
||||
*/
|
||||
derives?: DeriveCustom;
|
||||
/**
|
||||
* @description prebundles is a map of 'genesis hash and runtime spec version' as key to metadata's hex string
|
||||
* if genesis hash and runtime spec version matches, then use metadata, else fetch it from chain
|
||||
*/
|
||||
metadata?: Record<string, string>;
|
||||
/**
|
||||
* @description Transport Provider from rpc-provider. If not specified, it will default to
|
||||
* connecting to a WsProvider connecting localhost with the default port, i.e. `ws://127.0.0.1:9944`
|
||||
*/
|
||||
provider?: ProviderInterface;
|
||||
/**
|
||||
* @description A type registry to use along with this instance
|
||||
*/
|
||||
registry?: Registry;
|
||||
/**
|
||||
* @description User-defined RPC methods
|
||||
*/
|
||||
rpc?: UserRpc;
|
||||
/**
|
||||
* @description An external signer which will be used to sign extrinsic when account passed in is not KeyringPair
|
||||
*/
|
||||
signer?: Signer;
|
||||
/**
|
||||
* @description The source object to use for runtime information (only used when cloning)
|
||||
*/
|
||||
source?: ApiBase<any>;
|
||||
/**
|
||||
* @description Additional types used by runtime modules. This is nessusary if the runtime modules
|
||||
* uses types not available in the base Substrate runtime.
|
||||
*/
|
||||
types?: RegistryTypes;
|
||||
/**
|
||||
* @description Additional types that are injected based on the chain we are connecting to. There are keyed by the chain, i.e. `{ 'Kusama CC1': { ... } }`
|
||||
*/
|
||||
typesChain?: Record<string, RegistryTypes>;
|
||||
/**
|
||||
* @description Additional types that are injected based on the type of node we are connecting to, as set via specName in the runtime version. There are keyed by the node, i.e. `{ 'edgeware': { ... } }`
|
||||
*/
|
||||
typesSpec?: Record<string, RegistryTypes>;
|
||||
}
|
||||
|
||||
// A smaller interface of ApiRx, used in derive and in SubmittableExtrinsic
|
||||
export interface ApiInterfaceRx {
|
||||
consts: Constants;
|
||||
// TODO This needs to be typed correctly
|
||||
derive: DeriveAllSections<'rxjs', ExactDerive>;
|
||||
extrinsicType: number;
|
||||
genesisHash: Hash;
|
||||
hasSubscriptions: boolean;
|
||||
registry: Registry;
|
||||
runtimeMetadata: Metadata;
|
||||
runtimeVersion: RuntimeVersion;
|
||||
query: QueryableStorage<'rxjs'>;
|
||||
queryMulti: QueryableStorageMulti<'rxjs'>;
|
||||
rpc: DecoratedRpc<'rxjs', RpcInterface>;
|
||||
tx: SubmittableExtrinsics<'rxjs'>;
|
||||
signer?: Signer;
|
||||
}
|
||||
|
||||
export type ApiInterfaceEvents = ProviderInterfaceEmitted | 'ready';
|
||||
|
||||
export interface SignerOptions extends SignatureOptions {
|
||||
blockNumber: BN;
|
||||
genesisHash: Hash;
|
||||
}
|
||||
|
||||
export interface SignerResult {
|
||||
/**
|
||||
* @description The id for this request
|
||||
*/
|
||||
id: number;
|
||||
|
||||
/**
|
||||
* @description The resulting signature in hex
|
||||
*/
|
||||
signature: string;
|
||||
}
|
||||
|
||||
export interface Signer {
|
||||
/**
|
||||
* @description signs an extrinsic payload from a serialized form
|
||||
*/
|
||||
signPayload?: (payload: SignerPayloadJSON) => Promise<SignerResult>;
|
||||
|
||||
/**
|
||||
* @description signs a raw payload, only the bytes data as supplied
|
||||
*/
|
||||
signRaw?: (raw: SignerPayloadRaw) => Promise<SignerResult>;
|
||||
|
||||
/**
|
||||
* @description Receives an update for the extrinsic signed by a `signer.sign`
|
||||
*/
|
||||
update?: (id: number, status: Hash | SubmittableResultImpl) => void;
|
||||
}
|
||||
|
||||
export { ApiBase };
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright 2017-2020 @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 { AnyFunction } from '@polkadot/types/types';
|
||||
|
||||
import { ApiTypes, MethodResult } from './base';
|
||||
|
||||
export type DecoratedRpcSection<ApiType extends ApiTypes, Section> = {
|
||||
[Method in keyof Section]: Section[Method] extends AnyFunction
|
||||
? MethodResult<ApiType, Section[Method]>
|
||||
: never
|
||||
}
|
||||
|
||||
export type DecoratedRpc<ApiType extends ApiTypes, AllSections> = {
|
||||
[Section in keyof AllSections]: DecoratedRpcSection<ApiType, AllSections[Section]>
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
// Copyright 2017-2020 @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 { Observable } from 'rxjs';
|
||||
import { u64 } from '@polkadot/types';
|
||||
import { Hash } from '@polkadot/types/interfaces';
|
||||
import { AnyFunction, Callback, Codec, CodecArg } from '@polkadot/types/types';
|
||||
import StorageKey, { StorageEntry } from '@polkadot/types/primitive/StorageKey';
|
||||
|
||||
import { ApiTypes, MethodResult, ObsInnerType, PromiseOrObs, UnsubscribePromise } from './base';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface AugmentedQueries<ApiType extends ApiTypes> { }
|
||||
|
||||
export type AugmentedQuery<ApiType extends ApiTypes, F extends AnyFunction> = MethodResult<ApiType, F> & StorageEntryBase<ApiType, F>
|
||||
|
||||
export type AugmentedQueryDoubleMap<ApiType extends ApiTypes, F extends AnyFunction, FirstKeyType = any> = MethodResult<ApiType, F> & StorageEntryDoubleMap<ApiType, F, FirstKeyType>
|
||||
|
||||
// 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 extends ApiTypes> =
|
||||
ApiType extends 'rxjs'
|
||||
? AugmentedQuery<'rxjs', GenericStorageEntryFunction>
|
||||
: AugmentedQuery<'promise', GenericStorageEntryFunction> & StorageEntryPromiseOverloads;
|
||||
|
||||
export interface StorageEntryBase<ApiType extends ApiTypes, F extends AnyFunction> {
|
||||
at: (hash: Hash | Uint8Array | string, ...args: Parameters<F>) => PromiseOrObs<ApiType, ObsInnerType<ReturnType<F>>>;
|
||||
creator: StorageEntry;
|
||||
entries: (arg?: any) => PromiseOrObs<ApiType, [StorageKey, ObsInnerType<ReturnType<F>>][]>;
|
||||
hash: (...args: Parameters<F>) => PromiseOrObs<ApiType, Hash>;
|
||||
key: (...args: Parameters<F>) => string;
|
||||
keyPrefix: () => string;
|
||||
size: (...args: Parameters<F>) => PromiseOrObs<ApiType, u64>;
|
||||
multi: ApiType extends 'rxjs' ? StorageEntryObservableMulti : StorageEntryPromiseMulti;
|
||||
}
|
||||
|
||||
export interface StorageEntryDoubleMap<ApiType extends ApiTypes, F extends AnyFunction, FirstKeyType> extends StorageEntryBase<ApiType, F> {
|
||||
entries: (arg?: FirstKeyType) => PromiseOrObs<ApiType, [StorageKey, ObsInnerType<ReturnType<F>>][]>;
|
||||
}
|
||||
|
||||
interface StorageEntryObservableMulti {
|
||||
<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 StorageEntryPromiseOverloads {
|
||||
(arg1?: CodecArg, arg2?: CodecArg): Promise<Codec>;
|
||||
<T extends Codec>(arg1?: CodecArg, arg2?: CodecArg): Promise<T>;
|
||||
<T extends Codec>(callback: Callback<T>): UnsubscribePromise;
|
||||
<T extends Codec>(arg: CodecArg, callback: Callback<T>): UnsubscribePromise;
|
||||
<T extends Codec>(arg1: CodecArg, arg2: CodecArg, callback: Callback<T>): UnsubscribePromise;
|
||||
}
|
||||
|
||||
export interface QueryableModuleStorage<ApiType extends ApiTypes> {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
}
|
||||
|
||||
export type QueryableStorageMultiArg<ApiType extends ApiTypes> =
|
||||
QueryableStorageEntry<ApiType> |
|
||||
[QueryableStorageEntry<ApiType>, ...CodecArg[]];
|
||||
|
||||
export interface QueryableStorageMultiBase<ApiType extends ApiTypes> {
|
||||
<T extends Codec[]>(calls: QueryableStorageMultiArg<ApiType>[]): Observable<T>;
|
||||
}
|
||||
|
||||
export interface QueryableStorageMultiPromise<ApiType extends ApiTypes> {
|
||||
<T extends Codec[]>(calls: QueryableStorageMultiArg<ApiType>[], callback: Callback<T>): UnsubscribePromise;
|
||||
}
|
||||
|
||||
export type QueryableStorageMulti<ApiType extends ApiTypes> =
|
||||
ApiType extends 'rxjs'
|
||||
? QueryableStorageMultiBase<ApiType>
|
||||
: QueryableStorageMultiPromise<ApiType>;
|
||||
|
||||
export interface QueryableStorage<ApiType extends ApiTypes> extends AugmentedQueries<ApiType> {
|
||||
[index: string]: QueryableModuleStorage<ApiType>;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright 2017-2020 @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 { AnyFunction, CallBase } from '@polkadot/types/types';
|
||||
|
||||
import { SubmittableExtrinsic } from '../submittable/types';
|
||||
import { ApiTypes } from './base';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface AugmentedSubmittables<ApiType extends ApiTypes> { }
|
||||
|
||||
export type AugmentedSubmittable<T extends AnyFunction> = T & CallBase;
|
||||
|
||||
export interface SubmittableExtrinsicFunction<ApiType extends ApiTypes> extends CallBase {
|
||||
(...params: any[]): SubmittableExtrinsic<ApiType>;
|
||||
}
|
||||
|
||||
export interface SubmittableModuleExtrinsics<ApiType extends ApiTypes> {
|
||||
[index: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
}
|
||||
|
||||
export interface SubmittableExtrinsics<ApiType extends ApiTypes> extends AugmentedSubmittables<ApiType> {
|
||||
(extrinsic: Uint8Array | string): SubmittableExtrinsic<ApiType>;
|
||||
[index: string]: SubmittableModuleExtrinsics<ApiType>;
|
||||
}
|
||||
@@ -11,7 +11,7 @@ export const logEvents = (done: () => {}): (r: SubmittableResult) => void =>
|
||||
({ events, status }: SubmittableResult): void => {
|
||||
console.log('Transaction status:', status.type);
|
||||
|
||||
if (status.isFinalized) {
|
||||
if (status.isInBlock) {
|
||||
console.log('Completed at block hash', status.value.toHex());
|
||||
console.log('Events:');
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/metadata",
|
||||
"version": "1.0.1",
|
||||
"version": "1.2.1",
|
||||
"description": "Helpers to extract information from runtime metadata",
|
||||
"main": "index.js",
|
||||
"publishConfig": {
|
||||
@@ -26,12 +26,13 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.8.3",
|
||||
"@polkadot/types": "^1.0.1",
|
||||
"@polkadot/util": "^2.0.1",
|
||||
"@polkadot/util-crypto": "^2.0.1"
|
||||
"@babel/runtime": "^7.8.4",
|
||||
"@polkadot/types": "^1.2.1",
|
||||
"@polkadot/util": "^2.3.1",
|
||||
"@polkadot/util-crypto": "^2.3.1",
|
||||
"bn.js": "^5.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^2.0.1"
|
||||
"@polkadot/keyring": "^2.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ClassOf, createType, TypeRegistry } from '@polkadot/types/codec/create';
|
||||
import { hexToU8a } from '@polkadot/util';
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
import Decorated from './Decorated';
|
||||
import json from '../Metadata/static';
|
||||
@@ -12,15 +12,13 @@ const registry = new TypeRegistry();
|
||||
const decorated = new Decorated(registry, json);
|
||||
|
||||
describe('Decorated', () => {
|
||||
it('should correctly get Alice\'s freeBalance storage key (u8a)', (): void => {
|
||||
it('should correctly get Alice\'s nonce storage key (u8a)', (): void => {
|
||||
expect(
|
||||
decorated.query
|
||||
.balances
|
||||
.freeBalance('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY')
|
||||
).toEqual(
|
||||
hexToU8a(
|
||||
'0x0101c2261276cc9d1f8598ea4b6a74b15c2f6482b9ade7bc6657aaca787ba1add3b42e3fb4c297a84c5cebc0e78257d213d0927ccc7596044c6ba013dd05522aacba'
|
||||
u8aToHex(
|
||||
decorated.query.system.account('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY')
|
||||
)
|
||||
).toEqual(
|
||||
'0x010126aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da92e3fb4c297a84c5cebc0e78257d213d0927ccc7596044c6ba013dd05522aacba'
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
|
||||
// Copyright 2017-2020 @polkadot/metadata 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 { Codec } from '@polkadot/types/types';
|
||||
import { ModuleConstantMetadataLatest } from '@polkadot/types/interfaces';
|
||||
|
||||
export type AugmentedConst<T extends Codec> = T & ConstantCodec;
|
||||
|
||||
export type ModuleConstants = Record<string, Codec>;
|
||||
|
||||
export interface Constants {
|
||||
[index: string]: ModuleConstants;
|
||||
}
|
||||
|
||||
export interface ConstantCodec extends Codec {
|
||||
meta: ModuleConstantMetadataLatest;
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import { Codec, Registry } from '@polkadot/types/types';
|
||||
import BN from 'bn.js';
|
||||
import { Compact, Raw, createType, createTypeUnsafe } from '@polkadot/types/codec';
|
||||
import StorageKey, { StorageEntry } from '@polkadot/types/primitive/StorageKey';
|
||||
import { assert, isNull, isUndefined, stringLowerFirst, stringToU8a, u8aConcat } from '@polkadot/util';
|
||||
import { assert, compactStripLength, isNull, isUndefined, stringLowerFirst, stringToU8a, u8aConcat } from '@polkadot/util';
|
||||
import { xxhashAsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import getHasher, { HasherFunction } from './getHasher';
|
||||
@@ -196,7 +196,7 @@ export default function createFunction (registry: Registry, itemFn: CreateItemFn
|
||||
const [hasher, key2Hasher] = getHashers(itemFn);
|
||||
|
||||
// Can only have zero or one argument:
|
||||
// - storage.balances.freeBalance(address)
|
||||
// - storage.system.account(address)
|
||||
// - storage.timestamp.blockPeriod()
|
||||
// For doublemap queries the params is passed in as an tuple, [key1, key2]
|
||||
const _storageFn = (arg?: CreateArgType | [CreateArgType?, CreateArgType?]): Uint8Array =>
|
||||
@@ -218,5 +218,7 @@ export default function createFunction (registry: Registry, itemFn: CreateItemFn
|
||||
extendDoubleMap(registry, itemFn, storageFn);
|
||||
}
|
||||
|
||||
storageFn.keyPrefix = storageFn.iterKey || compactStripLength(storageFn())[1];
|
||||
|
||||
return storageFn;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ describe('fromMetadata', (): void => {
|
||||
const decorated = new Decorated(registry, rpcMetadata);
|
||||
|
||||
it('should throw if the storage function expects an argument', (): void => {
|
||||
expect((): any => decorated.query.balances.freeBalance()).toThrowError(/requires one argument/);
|
||||
expect((): any => decorated.query.balances.account()).toThrowError(/requires one argument/);
|
||||
});
|
||||
|
||||
it('should return a value if the storage function does not expect an argument', (): void => {
|
||||
@@ -28,11 +28,11 @@ describe('fromMetadata', (): void => {
|
||||
it('should return the correct length-prefixed storage key', (): void => {
|
||||
expect(
|
||||
u8aToHex(
|
||||
decorated.query.balances.freeBalance(keyring.alice.address)
|
||||
decorated.query.system.account(keyring.alice.address)
|
||||
)
|
||||
).toEqual(
|
||||
// new storage key format
|
||||
'0x0101c2261276cc9d1f8598ea4b6a74b15c2f6482b9ade7bc6657aaca787ba1add3b42e3fb4c297a84c5cebc0e78257d213d0927ccc7596044c6ba013dd05522aacba'
|
||||
'0x010126aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da92e3fb4c297a84c5cebc0e78257d213d0927ccc7596044c6ba013dd05522aacba'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -23,7 +23,7 @@ export default function fromMetadata (registry: Registry, metadata: Metadata): S
|
||||
const unwrapped = moduleMetadata.storage.unwrap();
|
||||
const prefix = unwrapped.prefix.toString();
|
||||
|
||||
// For access, we change the index names, i.e. Balances.FreeBalance -> balances.freeBalance
|
||||
// For access, we change the index names, i.e. System.Account -> system.account
|
||||
result[section] = unwrapped.items.reduce((newModule, meta): ModuleStorage => {
|
||||
const method = meta.name.toString();
|
||||
|
||||
|
||||
@@ -3,18 +3,8 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { StorageEntry } from '@polkadot/types/primitive/StorageKey';
|
||||
import { Codec } from '@polkadot/types/types';
|
||||
import { ModuleConstantMetadataLatest } from '@polkadot/types/interfaces';
|
||||
|
||||
export interface ConstantCodec extends Codec {
|
||||
meta: ModuleConstantMetadataLatest;
|
||||
}
|
||||
|
||||
export type ModuleConstants = Record<string, Codec>;
|
||||
|
||||
export interface Constants {
|
||||
[index: string]: ModuleConstants;
|
||||
}
|
||||
export * from './consts/types';
|
||||
|
||||
export interface ModuleStorage {
|
||||
[key: string]: StorageEntry;
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata 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 { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import substrateData from './static';
|
||||
import Metadata from './Metadata';
|
||||
|
||||
describe('Metadata', (): void => {
|
||||
it('allows creation from hex with JSON equivalence', (): void => {
|
||||
const test = new Metadata(new TypeRegistry(), substrateData);
|
||||
|
||||
expect(
|
||||
new Metadata(new TypeRegistry(), test.toHex()).toJSON()
|
||||
).toEqual(test.toJSON());
|
||||
});
|
||||
});
|
||||
@@ -9,6 +9,32 @@ import { bnToU8a, isHex, hexToU8a, u8aConcat } from '@polkadot/util';
|
||||
import { MAGIC_NUMBER } from './MagicNumber';
|
||||
import MetadataVersioned from './MetadataVersioned';
|
||||
|
||||
// first we try and parse using the versioned structure, if this does fail,
|
||||
// we adjust with the magic number and a manual version and re-try. As soon as
|
||||
// we remove support for V0, we will just do a new here
|
||||
function decodeMetadata (registry: Registry, _value: Uint8Array | string = new Uint8Array()): MetadataVersioned {
|
||||
const value = isHex(_value)
|
||||
? hexToU8a(_value)
|
||||
: _value;
|
||||
|
||||
try {
|
||||
return new MetadataVersioned(registry, value);
|
||||
} catch (error) {
|
||||
if (error.message.indexOf('MagicNumber mismatch') === -1) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return new MetadataVersioned(
|
||||
registry,
|
||||
u8aConcat(
|
||||
bnToU8a(MAGIC_NUMBER), // manually add the magic number
|
||||
Uint8Array.from([0]), // add the version for the original
|
||||
value // the actual data as retrieved
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Metadata
|
||||
* @description
|
||||
@@ -16,32 +42,6 @@ import MetadataVersioned from './MetadataVersioned';
|
||||
*/
|
||||
export default class Metadata extends MetadataVersioned {
|
||||
constructor (registry: Registry, value?: Uint8Array | string) {
|
||||
super(registry, Metadata.decodeMetadata(registry, value));
|
||||
}
|
||||
|
||||
// first we try and parse using the versioned structure, if this does fail,
|
||||
// we adjust with the magic number and a manual version and re-try. As soon as
|
||||
// we remove support for V0, we will just do a new here
|
||||
private static decodeMetadata (registry: Registry, _value: Uint8Array | string = new Uint8Array()): MetadataVersioned {
|
||||
const value = isHex(_value)
|
||||
? hexToU8a(_value)
|
||||
: _value;
|
||||
|
||||
try {
|
||||
return new MetadataVersioned(registry, value);
|
||||
} catch (error) {
|
||||
if (error.message.indexOf('MagicNumber mismatch') === -1) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return new MetadataVersioned(
|
||||
registry,
|
||||
u8aConcat(
|
||||
bnToU8a(MAGIC_NUMBER), // manually add the magic number
|
||||
Uint8Array.from([0]), // add the version for the original
|
||||
value // the actual data as retrieved
|
||||
)
|
||||
);
|
||||
super(registry, decodeMetadata(registry, value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { MetadataLatest } from '@polkadot/types/interfaces/metadata';
|
||||
import { AnyJsonObject, Registry } from '@polkadot/types/types';
|
||||
|
||||
import { createType } from '@polkadot/types';
|
||||
import { createType } from '@polkadot/types/codec';
|
||||
|
||||
/** @internal */
|
||||
export default function toCallsOnly (registry: Registry, { extrinsic, modules }: MetadataLatest): AnyJsonObject | string {
|
||||
|
||||
@@ -438,7 +438,7 @@
|
||||
"functions": [
|
||||
{
|
||||
"name": "AccountNonce",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "AccountId",
|
||||
@@ -450,7 +450,7 @@
|
||||
},
|
||||
{
|
||||
"name": "ExtrinsicCount",
|
||||
"modifier": "optional",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Plain": "u32"
|
||||
},
|
||||
@@ -459,7 +459,7 @@
|
||||
},
|
||||
{
|
||||
"name": "BlockHash",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "BlockNumber",
|
||||
@@ -471,7 +471,7 @@
|
||||
},
|
||||
{
|
||||
"name": "ExtrinsicData",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "u32",
|
||||
@@ -483,7 +483,7 @@
|
||||
},
|
||||
{
|
||||
"name": "RandomSeed",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Hash"
|
||||
},
|
||||
@@ -492,7 +492,7 @@
|
||||
},
|
||||
{
|
||||
"name": "Number",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "BlockNumber"
|
||||
},
|
||||
@@ -503,7 +503,7 @@
|
||||
},
|
||||
{
|
||||
"name": "ParentHash",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Hash"
|
||||
},
|
||||
@@ -512,7 +512,7 @@
|
||||
},
|
||||
{
|
||||
"name": "ExtrinsicsRoot",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Hash"
|
||||
},
|
||||
@@ -521,7 +521,7 @@
|
||||
},
|
||||
{
|
||||
"name": "Digest",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Digest"
|
||||
},
|
||||
@@ -530,7 +530,7 @@
|
||||
},
|
||||
{
|
||||
"name": "Events",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Vec<EventRecord>"
|
||||
},
|
||||
@@ -586,7 +586,7 @@
|
||||
"functions": [
|
||||
{
|
||||
"name": "Now",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Moment"
|
||||
},
|
||||
@@ -597,7 +597,7 @@
|
||||
},
|
||||
{
|
||||
"name": "BlockPeriod",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Moment"
|
||||
},
|
||||
@@ -608,7 +608,7 @@
|
||||
},
|
||||
{
|
||||
"name": "DidUpdate",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "bool"
|
||||
},
|
||||
@@ -713,7 +713,7 @@
|
||||
"functions": [
|
||||
{
|
||||
"name": "OriginalAuthorities",
|
||||
"modifier": "optional",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Plain": "Vec<SessionKey>"
|
||||
},
|
||||
@@ -737,7 +737,7 @@
|
||||
"functions": [
|
||||
{
|
||||
"name": "NextEnumSet",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "AccountIndex"
|
||||
},
|
||||
@@ -748,7 +748,7 @@
|
||||
},
|
||||
{
|
||||
"name": "EnumSet",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "AccountIndex",
|
||||
@@ -776,7 +776,7 @@
|
||||
"args": [
|
||||
{
|
||||
"name": "dest",
|
||||
"type": "Address"
|
||||
"type": "LookupSource"
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
@@ -793,7 +793,7 @@
|
||||
"args": [
|
||||
{
|
||||
"name": "who",
|
||||
"type": "Address"
|
||||
"type": "LookupSource"
|
||||
},
|
||||
{
|
||||
"name": "free",
|
||||
@@ -816,7 +816,7 @@
|
||||
"functions": [
|
||||
{
|
||||
"name": "TotalIssuance",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Balance"
|
||||
},
|
||||
@@ -827,7 +827,7 @@
|
||||
},
|
||||
{
|
||||
"name": "ExistentialDeposit",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Balance"
|
||||
},
|
||||
@@ -838,7 +838,7 @@
|
||||
},
|
||||
{
|
||||
"name": "TransferFee",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Balance"
|
||||
},
|
||||
@@ -849,7 +849,7 @@
|
||||
},
|
||||
{
|
||||
"name": "CreationFee",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Balance"
|
||||
},
|
||||
@@ -860,7 +860,7 @@
|
||||
},
|
||||
{
|
||||
"name": "FreeBalance",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "AccountId",
|
||||
@@ -884,7 +884,7 @@
|
||||
},
|
||||
{
|
||||
"name": "ReservedBalance",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "AccountId",
|
||||
@@ -909,7 +909,7 @@
|
||||
},
|
||||
{
|
||||
"name": "TransactionBaseFee",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Balance"
|
||||
},
|
||||
@@ -920,7 +920,7 @@
|
||||
},
|
||||
{
|
||||
"name": "TransactionByteFee",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Balance"
|
||||
},
|
||||
@@ -987,7 +987,7 @@
|
||||
"functions": [
|
||||
{
|
||||
"name": "Validators",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Vec<AccountId>"
|
||||
},
|
||||
@@ -998,7 +998,7 @@
|
||||
},
|
||||
{
|
||||
"name": "SessionLength",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "BlockNumber"
|
||||
},
|
||||
@@ -1009,7 +1009,7 @@
|
||||
},
|
||||
{
|
||||
"name": "CurrentIndex",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "BlockNumber"
|
||||
},
|
||||
@@ -1020,7 +1020,7 @@
|
||||
},
|
||||
{
|
||||
"name": "CurrentStart",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Moment"
|
||||
},
|
||||
@@ -1031,7 +1031,7 @@
|
||||
},
|
||||
{
|
||||
"name": "ForcingNewSession",
|
||||
"modifier": "optional",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Plain": "bool"
|
||||
},
|
||||
@@ -1043,7 +1043,7 @@
|
||||
},
|
||||
{
|
||||
"name": "LastLengthChange",
|
||||
"modifier": "optional",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Plain": "BlockNumber"
|
||||
},
|
||||
@@ -1054,7 +1054,7 @@
|
||||
},
|
||||
{
|
||||
"name": "NextKeyFor",
|
||||
"modifier": "optional",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "AccountId",
|
||||
@@ -1068,7 +1068,7 @@
|
||||
},
|
||||
{
|
||||
"name": "NextSessionLength",
|
||||
"modifier": "optional",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Plain": "BlockNumber"
|
||||
},
|
||||
@@ -1118,7 +1118,7 @@
|
||||
"args": [
|
||||
{
|
||||
"name": "target",
|
||||
"type": "Address"
|
||||
"type": "LookupSource"
|
||||
}
|
||||
],
|
||||
"documentation": []
|
||||
@@ -1243,7 +1243,7 @@
|
||||
"functions": [
|
||||
{
|
||||
"name": "ValidatorCount",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "u32"
|
||||
},
|
||||
@@ -1254,7 +1254,7 @@
|
||||
},
|
||||
{
|
||||
"name": "MinimumValidatorCount",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "u32"
|
||||
},
|
||||
@@ -1265,7 +1265,7 @@
|
||||
},
|
||||
{
|
||||
"name": "SessionsPerEra",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "BlockNumber"
|
||||
},
|
||||
@@ -1276,7 +1276,7 @@
|
||||
},
|
||||
{
|
||||
"name": "SessionReward",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Perbill"
|
||||
},
|
||||
@@ -1287,7 +1287,7 @@
|
||||
},
|
||||
{
|
||||
"name": "OfflineSlash",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Perbill"
|
||||
},
|
||||
@@ -1298,7 +1298,7 @@
|
||||
},
|
||||
{
|
||||
"name": "OfflineSlashGrace",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "u32"
|
||||
},
|
||||
@@ -1309,7 +1309,7 @@
|
||||
},
|
||||
{
|
||||
"name": "BondingDuration",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "BlockNumber"
|
||||
},
|
||||
@@ -1320,7 +1320,7 @@
|
||||
},
|
||||
{
|
||||
"name": "Invulerables",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Vec<AccountId>"
|
||||
},
|
||||
@@ -1332,7 +1332,7 @@
|
||||
},
|
||||
{
|
||||
"name": "CurrentEra",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "BlockNumber"
|
||||
},
|
||||
@@ -1343,7 +1343,7 @@
|
||||
},
|
||||
{
|
||||
"name": "ValidatorPreferences",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "AccountId",
|
||||
@@ -1357,7 +1357,7 @@
|
||||
},
|
||||
{
|
||||
"name": "Intentions",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Vec<AccountId>"
|
||||
},
|
||||
@@ -1368,7 +1368,7 @@
|
||||
},
|
||||
{
|
||||
"name": "Nominating",
|
||||
"modifier": "optional",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "AccountId",
|
||||
@@ -1382,7 +1382,7 @@
|
||||
},
|
||||
{
|
||||
"name": "NominatorsFor",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "AccountId",
|
||||
@@ -1396,7 +1396,7 @@
|
||||
},
|
||||
{
|
||||
"name": "CurrentNominatorsFor",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "AccountId",
|
||||
@@ -1410,7 +1410,7 @@
|
||||
},
|
||||
{
|
||||
"name": "CurrentSessionReward",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Balance"
|
||||
},
|
||||
@@ -1421,7 +1421,7 @@
|
||||
},
|
||||
{
|
||||
"name": "CurrentOfflineSlash",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Balance"
|
||||
},
|
||||
@@ -1432,7 +1432,7 @@
|
||||
},
|
||||
{
|
||||
"name": "NextSessionsPerEra",
|
||||
"modifier": "optional",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Plain": "BlockNumber"
|
||||
},
|
||||
@@ -1443,7 +1443,7 @@
|
||||
},
|
||||
{
|
||||
"name": "LastEraLengthChange",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "BlockNumber"
|
||||
},
|
||||
@@ -1454,7 +1454,7 @@
|
||||
},
|
||||
{
|
||||
"name": "StakeRange",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "(Balance,Balance)"
|
||||
},
|
||||
@@ -1465,7 +1465,7 @@
|
||||
},
|
||||
{
|
||||
"name": "Bondage",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "AccountId",
|
||||
@@ -1479,7 +1479,7 @@
|
||||
},
|
||||
{
|
||||
"name": "SlashCount",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "AccountId",
|
||||
@@ -1493,7 +1493,7 @@
|
||||
},
|
||||
{
|
||||
"name": "ForcingNewEra",
|
||||
"modifier": "optional",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Plain": "()"
|
||||
},
|
||||
@@ -1619,7 +1619,7 @@
|
||||
"functions": [
|
||||
{
|
||||
"name": "PublicPropCount",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "PropIndex"
|
||||
},
|
||||
@@ -1630,7 +1630,7 @@
|
||||
},
|
||||
{
|
||||
"name": "PublicProps",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Vec<(PropIndex,Proposal,AccountId)>"
|
||||
},
|
||||
@@ -1641,7 +1641,7 @@
|
||||
},
|
||||
{
|
||||
"name": "DepositOf",
|
||||
"modifier": "optional",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "PropIndex",
|
||||
@@ -1655,7 +1655,7 @@
|
||||
},
|
||||
{
|
||||
"name": "LaunchPeriod",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "BlockNumber"
|
||||
},
|
||||
@@ -1666,7 +1666,7 @@
|
||||
},
|
||||
{
|
||||
"name": "MinimumDeposit",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Balance"
|
||||
},
|
||||
@@ -1677,7 +1677,7 @@
|
||||
},
|
||||
{
|
||||
"name": "PublicDelay",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "BlockNumber"
|
||||
},
|
||||
@@ -1688,7 +1688,7 @@
|
||||
},
|
||||
{
|
||||
"name": "MaxLockPeriods",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "LockPeriods"
|
||||
},
|
||||
@@ -1699,7 +1699,7 @@
|
||||
},
|
||||
{
|
||||
"name": "VotingPeriod",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "BlockNumber"
|
||||
},
|
||||
@@ -1710,7 +1710,7 @@
|
||||
},
|
||||
{
|
||||
"name": "ReferendumCount",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "ReferendumIndex"
|
||||
},
|
||||
@@ -1721,7 +1721,7 @@
|
||||
},
|
||||
{
|
||||
"name": "NextTally",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "ReferendumIndex"
|
||||
},
|
||||
@@ -1732,7 +1732,7 @@
|
||||
},
|
||||
{
|
||||
"name": "ReferendumInfoOf",
|
||||
"modifier": "optional",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "ReferendumIndex",
|
||||
@@ -1746,7 +1746,7 @@
|
||||
},
|
||||
{
|
||||
"name": "DispatchQueue",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "BlockNumber",
|
||||
@@ -1760,7 +1760,7 @@
|
||||
},
|
||||
{
|
||||
"name": "Bondage",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "AccountId",
|
||||
@@ -1774,7 +1774,7 @@
|
||||
},
|
||||
{
|
||||
"name": "VotersFor",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "ReferendumIndex",
|
||||
@@ -1788,7 +1788,7 @@
|
||||
},
|
||||
{
|
||||
"name": "VoteOf",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "(ReferendumIndex,AccountId)",
|
||||
@@ -1840,7 +1840,7 @@
|
||||
},
|
||||
{
|
||||
"name": "who",
|
||||
"type": "Address"
|
||||
"type": "LookupSource"
|
||||
},
|
||||
{
|
||||
"name": "who_index",
|
||||
@@ -1893,7 +1893,7 @@
|
||||
"args": [
|
||||
{
|
||||
"name": "candidate",
|
||||
"type": "Address"
|
||||
"type": "LookupSource"
|
||||
},
|
||||
{
|
||||
"name": "total",
|
||||
@@ -1931,7 +1931,7 @@
|
||||
"args": [
|
||||
{
|
||||
"name": "who",
|
||||
"type": "Address"
|
||||
"type": "LookupSource"
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
@@ -1976,7 +1976,7 @@
|
||||
"functions": [
|
||||
{
|
||||
"name": "CandidacyBond",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Balance"
|
||||
},
|
||||
@@ -1987,7 +1987,7 @@
|
||||
},
|
||||
{
|
||||
"name": "VotingBond",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Balance"
|
||||
},
|
||||
@@ -1998,7 +1998,7 @@
|
||||
},
|
||||
{
|
||||
"name": "PresentSlashPerVoter",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Balance"
|
||||
},
|
||||
@@ -2009,7 +2009,7 @@
|
||||
},
|
||||
{
|
||||
"name": "CarryCount",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "u32"
|
||||
},
|
||||
@@ -2020,7 +2020,7 @@
|
||||
},
|
||||
{
|
||||
"name": "PresentationDuration",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "BlockNumber"
|
||||
},
|
||||
@@ -2031,7 +2031,7 @@
|
||||
},
|
||||
{
|
||||
"name": "InactiveGracePeriod",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "VoteIndex"
|
||||
},
|
||||
@@ -2043,7 +2043,7 @@
|
||||
},
|
||||
{
|
||||
"name": "VotingPeriod",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "BlockNumber"
|
||||
},
|
||||
@@ -2054,7 +2054,7 @@
|
||||
},
|
||||
{
|
||||
"name": "TermDuration",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "BlockNumber"
|
||||
},
|
||||
@@ -2065,7 +2065,7 @@
|
||||
},
|
||||
{
|
||||
"name": "DesiredSeats",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "u32"
|
||||
},
|
||||
@@ -2076,7 +2076,7 @@
|
||||
},
|
||||
{
|
||||
"name": "ActiveCouncil",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Vec<(AccountId,BlockNumber)>"
|
||||
},
|
||||
@@ -2090,7 +2090,7 @@
|
||||
},
|
||||
{
|
||||
"name": "VoteCount",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "VoteIndex"
|
||||
},
|
||||
@@ -2101,7 +2101,7 @@
|
||||
},
|
||||
{
|
||||
"name": "ApprovalsOf",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "AccountId",
|
||||
@@ -2116,7 +2116,7 @@
|
||||
},
|
||||
{
|
||||
"name": "RegisterInfoOf",
|
||||
"modifier": "optional",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "AccountId",
|
||||
@@ -2131,7 +2131,7 @@
|
||||
},
|
||||
{
|
||||
"name": "LastActiveOf",
|
||||
"modifier": "optional",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "AccountId",
|
||||
@@ -2145,7 +2145,7 @@
|
||||
},
|
||||
{
|
||||
"name": "Voters",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Vec<AccountId>"
|
||||
},
|
||||
@@ -2156,7 +2156,7 @@
|
||||
},
|
||||
{
|
||||
"name": "Candidates",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Vec<AccountId>"
|
||||
},
|
||||
@@ -2167,7 +2167,7 @@
|
||||
},
|
||||
{
|
||||
"name": "CandidateCount",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "u32"
|
||||
},
|
||||
@@ -2176,7 +2176,7 @@
|
||||
},
|
||||
{
|
||||
"name": "NextFinalise",
|
||||
"modifier": "optional",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Plain": "(BlockNumber,u32,Vec<AccountId>)"
|
||||
},
|
||||
@@ -2187,7 +2187,7 @@
|
||||
},
|
||||
{
|
||||
"name": "SnapshotedStakes",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Vec<Balance>"
|
||||
},
|
||||
@@ -2198,7 +2198,7 @@
|
||||
},
|
||||
{
|
||||
"name": "Leaderboard",
|
||||
"modifier": "optional",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Plain": "Vec<(Balance,AccountId)>"
|
||||
},
|
||||
@@ -2284,7 +2284,7 @@
|
||||
"functions": [
|
||||
{
|
||||
"name": "CooloffPeriod",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "BlockNumber"
|
||||
},
|
||||
@@ -2293,7 +2293,7 @@
|
||||
},
|
||||
{
|
||||
"name": "VotingPeriod",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "BlockNumber"
|
||||
},
|
||||
@@ -2302,7 +2302,7 @@
|
||||
},
|
||||
{
|
||||
"name": "EnactDelayPeriod",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "BlockNumber"
|
||||
},
|
||||
@@ -2313,7 +2313,7 @@
|
||||
},
|
||||
{
|
||||
"name": "Proposals",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Vec<(BlockNumber,Hash)>"
|
||||
},
|
||||
@@ -2322,7 +2322,7 @@
|
||||
},
|
||||
{
|
||||
"name": "ProposalOf",
|
||||
"modifier": "optional",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "Hash",
|
||||
@@ -2334,7 +2334,7 @@
|
||||
},
|
||||
{
|
||||
"name": "ProposalVoters",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "Hash",
|
||||
@@ -2346,7 +2346,7 @@
|
||||
},
|
||||
{
|
||||
"name": "CouncilVoteOf",
|
||||
"modifier": "optional",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "(Hash,AccountId)",
|
||||
@@ -2358,7 +2358,7 @@
|
||||
},
|
||||
{
|
||||
"name": "VetoedProposal",
|
||||
"modifier": "optional",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "Hash",
|
||||
@@ -2420,7 +2420,7 @@
|
||||
"functions": [
|
||||
{
|
||||
"name": "Proposals",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Vec<Hash>"
|
||||
},
|
||||
@@ -2431,7 +2431,7 @@
|
||||
},
|
||||
{
|
||||
"name": "ProposalOf",
|
||||
"modifier": "optional",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "Hash",
|
||||
@@ -2445,7 +2445,7 @@
|
||||
},
|
||||
{
|
||||
"name": "Voting",
|
||||
"modifier": "optional",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "Hash",
|
||||
@@ -2459,7 +2459,7 @@
|
||||
},
|
||||
{
|
||||
"name": "ProposalCount",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "u32"
|
||||
},
|
||||
@@ -2499,7 +2499,7 @@
|
||||
"functions": [
|
||||
{
|
||||
"name": "PendingChange",
|
||||
"modifier": "optional",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Plain": "StoredPendingChange"
|
||||
},
|
||||
@@ -2526,7 +2526,7 @@
|
||||
},
|
||||
{
|
||||
"name": "beneficiary",
|
||||
"type": "Address"
|
||||
"type": "LookupSource"
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
@@ -2608,7 +2608,7 @@
|
||||
"functions": [
|
||||
{
|
||||
"name": "ProposalBond",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Permill"
|
||||
},
|
||||
@@ -2620,7 +2620,7 @@
|
||||
},
|
||||
{
|
||||
"name": "ProposalBondMinimum",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Balance"
|
||||
},
|
||||
@@ -2631,7 +2631,7 @@
|
||||
},
|
||||
{
|
||||
"name": "SpendPeriod",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "BlockNumber"
|
||||
},
|
||||
@@ -2642,7 +2642,7 @@
|
||||
},
|
||||
{
|
||||
"name": "Burn",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Permill"
|
||||
},
|
||||
@@ -2653,7 +2653,7 @@
|
||||
},
|
||||
{
|
||||
"name": "Pot",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Balance"
|
||||
},
|
||||
@@ -2664,7 +2664,7 @@
|
||||
},
|
||||
{
|
||||
"name": "ProposalCount",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "ProposalIndex"
|
||||
},
|
||||
@@ -2675,7 +2675,7 @@
|
||||
},
|
||||
{
|
||||
"name": "Proposals",
|
||||
"modifier": "optional",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"Map": {
|
||||
"key": "ProposalIndex",
|
||||
@@ -2689,7 +2689,7 @@
|
||||
},
|
||||
{
|
||||
"name": "Approvals",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "Vec<ProposalIndex>"
|
||||
},
|
||||
@@ -2714,7 +2714,7 @@
|
||||
"args": [
|
||||
{
|
||||
"name": "dest",
|
||||
"type": "Address"
|
||||
"type": "LookupSource"
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
@@ -2796,7 +2796,7 @@
|
||||
"args": [
|
||||
{
|
||||
"name": "new",
|
||||
"type": "Address"
|
||||
"type": "LookupSource"
|
||||
}
|
||||
],
|
||||
"documentation": []
|
||||
@@ -2809,7 +2809,7 @@
|
||||
"functions": [
|
||||
{
|
||||
"name": "Key",
|
||||
"modifier": "default",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"Plain": "AccountId"
|
||||
},
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@
|
||||
import { MetadataV1, MetadataV2 } from '@polkadot/types/interfaces/metadata';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { createType } from '@polkadot/types';
|
||||
import { createType } from '@polkadot/types/codec';
|
||||
|
||||
/** @internal */
|
||||
export default function toV2 (registry: Registry, metadataV1: MetadataV1): MetadataV2 {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@
|
||||
import { MetadataV10, MetadataV11 } from '@polkadot/types/interfaces/metadata';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { createType } from '@polkadot/types';
|
||||
import { createType } from '@polkadot/types/codec';
|
||||
|
||||
/** @internal */
|
||||
export default function toV11 (registry: Registry, { modules }: MetadataV10): MetadataV11 {
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import polkadotJson from './static-polkadot.json';
|
||||
import polkadotData from './static.polkadot';
|
||||
import substrateJson from './static-substrate.json';
|
||||
import substrateData from './static';
|
||||
import { decodeLatestSubstrate, defaultValues, toLatest } from '../util/testUtil';
|
||||
|
||||
describe('MetadataV10 (substrate)', (): void => {
|
||||
describe('MetadataV11 (substrate)', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
decodeLatestSubstrate(registry, 11, substrateData, substrateJson);
|
||||
@@ -17,3 +19,13 @@ describe('MetadataV10 (substrate)', (): void => {
|
||||
|
||||
defaultValues(registry, substrateData);
|
||||
});
|
||||
|
||||
describe('MetadataV11 (polkadot)', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
decodeLatestSubstrate(registry, 11, polkadotData, polkadotJson);
|
||||
|
||||
toLatest(registry, 11, polkadotData);
|
||||
|
||||
defaultValues(registry, polkadotData);
|
||||
});
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user