Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
05e3db01ba | ||
|
|
6158c07e0a | ||
|
|
ce505aaf62 | ||
|
|
09f9a48037 | ||
|
|
700c1cfcd4 | ||
|
|
7d2463e53f | ||
|
|
a2ecd9bd3b | ||
|
|
b0de692147 | ||
|
|
dcd53c76d7 | ||
|
|
6ed90c6111 | ||
|
|
babef6d7bc | ||
|
|
e2205a65e9 | ||
|
|
32d55dfb18 | ||
|
|
60e0d0eae4 | ||
|
|
9cef1febe1 | ||
|
|
4c9032fedc | ||
|
|
5b6f222e5e | ||
|
|
47235d01bf | ||
|
|
32efe83136 | ||
|
|
c4c099e693 | ||
|
|
f26ca0e624 | ||
|
|
5f496f1809 | ||
|
|
f1cbf8cc70 | ||
|
|
8b7fccb744 | ||
|
|
66d3486674 | ||
|
|
2dbd217f6d | ||
|
|
fea9ae8f97 | ||
|
|
4e81bbc43c | ||
|
|
83650b8f28 | ||
|
|
50a3501dd2 | ||
|
|
526a3fd139 | ||
|
|
3b996b3444 | ||
|
|
c72c9e4a5e | ||
|
|
60a71a5ac9 | ||
|
|
26c3ccccc3 | ||
|
|
963e25934d | ||
|
|
55d9f8a062 | ||
|
|
700c8ba21f | ||
|
|
cbc255b4e7 | ||
|
|
2fe1e5031e | ||
|
|
f2cdac7875 | ||
|
|
165405bdc3 | ||
|
|
f86d71524d | ||
|
|
4d6d59f1c5 | ||
|
|
7a709898e5 | ||
|
|
121bfc7913 | ||
|
|
a04ccec445 | ||
|
|
2611fc5e1a | ||
|
|
cd5c306b22 | ||
|
|
ca6a7819f6 | ||
|
|
29c0ea9856 | ||
|
|
c82ed58d68 | ||
|
|
59a3867c50 | ||
|
|
0fca4e6866 | ||
|
|
3f9e65a179 | ||
|
|
92bde9de6f | ||
|
|
9b3158599c | ||
|
|
206fb49df5 | ||
|
|
cc0ad9b04b | ||
|
|
39902dd8ac | ||
|
|
324e4ab89b | ||
|
|
68bf0a487f | ||
|
|
3acf7e0fd7 | ||
|
|
edaf13abe1 | ||
|
|
b3649a70ce | ||
|
|
80ab628643 | ||
|
|
76363c0142 | ||
|
|
80c18c2201 | ||
|
|
fcf9b86b87 | ||
|
|
1113a3d2f8 | ||
|
|
c899dbf893 | ||
|
|
be137b2a03 | ||
|
|
122d780fe8 | ||
|
|
12be027b18 | ||
|
|
dfeef40037 | ||
|
|
a7b4fe4dd0 | ||
|
|
f4ec64d6f5 | ||
|
|
9a0d39199e | ||
|
|
77d82d9511 | ||
|
|
5464b91cc6 | ||
|
|
64ff87952a | ||
|
|
0de39e4c52 | ||
|
|
60bc384d22 | ||
|
|
ca7ea0e143 | ||
|
|
23d50248de | ||
|
|
ad4e54a2f6 | ||
|
|
e659df27ae | ||
|
|
6dc3c06fe8 | ||
|
|
776956f166 | ||
|
|
4c5203acba | ||
|
|
d80070a041 | ||
|
|
1c00cb4c4e | ||
|
|
736505603e | ||
|
|
c243da79e1 | ||
|
|
2677f38090 | ||
|
|
41d05d2402 | ||
|
|
0f38584566 | ||
|
|
2b7fb8667e | ||
|
|
ca18846bfb | ||
|
|
4ba372d29b | ||
|
|
bdc2d24366 | ||
|
|
3de06c1d4c | ||
|
|
b51149d895 | ||
|
|
e0fef55366 | ||
|
|
e2aac5f94a | ||
|
|
8f44f84c7f | ||
|
|
d53a61ec86 | ||
|
|
cf18f79c14 | ||
|
|
beb8011b4c | ||
|
|
38a601b665 | ||
|
|
11a3483ce5 | ||
|
|
1db133b741 | ||
|
|
716dce0093 | ||
|
|
3b53442172 | ||
|
|
253d94a47d | ||
|
|
fb1129a49b | ||
|
|
1cc56d6e44 | ||
|
|
9e2983a735 | ||
|
|
a6fcba95de | ||
|
|
c8c535834e | ||
|
|
b8d7c2e3e3 | ||
|
|
0283d4727b | ||
|
|
a4ab732478 | ||
|
|
0dc121a796 | ||
|
|
a827131457 | ||
|
|
2174537f76 | ||
|
|
53fca2406a | ||
|
|
0eaba284ae | ||
|
|
378f359a76 | ||
|
|
5460d96b5d | ||
|
|
b1353edc84 | ||
|
|
9129fed6e5 | ||
|
|
7c4abacaca | ||
|
|
3664c7d81b | ||
|
|
f75b87c5a5 | ||
|
|
1c228216cd | ||
|
|
cec3c12795 | ||
|
|
0d0d12e85b | ||
|
|
3a16e69be5 | ||
|
|
4ae8e3909f | ||
|
|
6e18bb3b1d | ||
|
|
be153e13a6 | ||
|
|
4c01dfd0ab | ||
|
|
b57c7a1343 | ||
|
|
da62acdf50 | ||
|
|
cc95e4fc0a | ||
|
|
7f5647c6e1 | ||
|
|
c636d63bc0 | ||
|
|
30c98ef857 | ||
|
|
debecde50f | ||
|
|
cd2cdd1184 | ||
|
|
f5c25d75ff | ||
|
|
780cc62942 | ||
|
|
165568c905 | ||
|
|
976a48d8f9 | ||
|
|
35cbbbe0ed | ||
|
|
772769c981 | ||
|
|
1ba2bd1766 | ||
|
|
4afa345a7d | ||
|
|
5c03359f32 | ||
|
|
04120505f0 | ||
|
|
7bd9dd65f8 | ||
|
|
5f57ecb2e1 | ||
|
|
9123f1d805 | ||
|
|
7050c4a554 | ||
|
|
62afb0b534 | ||
|
|
5157ca5608 | ||
|
|
315617c027 | ||
|
|
7d33b4dec6 | ||
|
|
2345f69c71 | ||
|
|
3cef2fb4d5 | ||
|
|
2bbf5513b2 | ||
|
|
c146f06178 | ||
|
|
5903704b61 | ||
|
|
90d8db651b | ||
|
|
557283a3d1 | ||
|
|
88b84dcf75 | ||
|
|
45d190eaca | ||
|
|
6d32328509 | ||
|
|
ba470e7417 | ||
|
|
4a16e46f88 | ||
|
|
ada0d99a84 | ||
|
|
e486fc4316 | ||
|
|
6e5c6f4e0b | ||
|
|
21ddcaf173 | ||
|
|
6085b994f6 | ||
|
|
7c3bf05868 | ||
|
|
8bce5b4a09 | ||
|
|
7a6077301f | ||
|
|
3f2767462f | ||
|
|
ecc37d11df | ||
|
|
0589d151da | ||
|
|
47cd6c6410 | ||
|
|
65688f9e0e | ||
|
|
5eb2a95ef2 | ||
|
|
282b39d27a | ||
|
|
f21e3d317a | ||
|
|
c2af7cf8f2 | ||
|
|
0958a4c693 | ||
|
|
c687181130 | ||
|
|
685f1ec0b6 | ||
|
|
e0069b6f7d | ||
|
|
cf48762ff2 | ||
|
|
31a7545a19 | ||
|
|
5cd8e8fb97 | ||
|
|
96e4090174 | ||
|
|
0bbebab90b | ||
|
|
57dac0ef47 | ||
|
|
6c3d24551b | ||
|
|
e7dc6d7a5a | ||
|
|
a63b7f611e | ||
|
|
82e15dc36d | ||
|
|
6f96037cb5 | ||
|
|
b6da84b8b2 | ||
|
|
41209f074c | ||
|
|
c47964c942 | ||
|
|
5f13a634e5 | ||
|
|
40af520fe7 | ||
|
|
1e506e0f8c | ||
|
|
96ea5803d4 | ||
|
|
7d99459f50 | ||
|
|
8fa090f435 | ||
|
|
d3c60d197c | ||
|
|
ad8550f7f5 | ||
|
|
a899aa439d | ||
|
|
e0e075b350 | ||
|
|
34ff14547e | ||
|
|
681a80d456 | ||
|
|
ed5f2673ce | ||
|
|
43e87603e2 | ||
|
|
d056416b47 | ||
|
|
1bcf94131d | ||
|
|
17b607b6c3 | ||
|
|
5a16d1dd8b | ||
|
|
144b74306a | ||
|
|
16b9fa956d | ||
|
|
b6af4b9877 | ||
|
|
3f368e721d | ||
|
|
22b4257636 | ||
|
|
ca7a631032 | ||
|
|
da5bbd17af | ||
|
|
b58f3f5c3e | ||
|
|
8c30194f59 | ||
|
|
dc9ec37490 | ||
|
|
5175e77eec | ||
|
|
9553c5467c | ||
|
|
a1f07e3274 | ||
|
|
58deb2eb14 | ||
|
|
83caad7f1b | ||
|
|
26c3cc9126 | ||
|
|
1a231dfb0d | ||
|
|
712d0425d0 | ||
|
|
eaa5db517f | ||
|
|
88c3850d1b | ||
|
|
943df72ae9 | ||
|
|
67ab11a036 | ||
|
|
c87ef7526b | ||
|
|
bccf2d52ad | ||
|
|
be6dbdd3e4 | ||
|
|
3c34ee9897 | ||
|
|
9ad97813e3 | ||
|
|
028f04e47f | ||
|
|
4974c9247f | ||
|
|
1ffe6a11bf | ||
|
|
19699ea445 | ||
|
|
d98ccfb12a | ||
|
|
41cb056b0f | ||
|
|
48bda0bdea | ||
|
|
1b393c7b67 | ||
|
|
f52e518b7b | ||
|
|
08970cff88 | ||
|
|
6d38ca6453 | ||
|
|
60db4bc66b | ||
|
|
0661237b28 | ||
|
|
6ccac712a8 | ||
|
|
3d4877940c | ||
|
|
70fc95ef27 |
+7
-3
@@ -1,4 +1,4 @@
|
||||
26
|
||||
29
|
||||
1.4.2
|
||||
1.6.2
|
||||
1.11.2
|
||||
@@ -17,6 +17,10 @@
|
||||
3.9.2
|
||||
3.9.3
|
||||
3.10.2
|
||||
|
||||
4.0.2
|
||||
4.0.3
|
||||
4.0.3
|
||||
|
||||
4.6.2
|
||||
4.7.2
|
||||
4.9.2
|
||||
4.11.2
|
||||
+220
@@ -1,5 +1,225 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 4.11.2 May 24, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended where users are having TS mismatches with type definitions created on older versions.
|
||||
|
||||
Changes:
|
||||
|
||||
- Add backwards-compatible TS-only `AugmentedQueryDoubleMap` type (unused now in type generation)
|
||||
|
||||
|
||||
## 4.11.1 May 23, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for users using staking entries on Polkadot and users of Substrate master.
|
||||
|
||||
Changes:
|
||||
|
||||
- Fix metadata v13 storage decoding on `NMap`
|
||||
- Add augmentation & keys/entries for NMap types
|
||||
- Return additional error information from internal u8a decoding failures
|
||||
- Adjust Westend types for 16 nominators-only
|
||||
- Add support for `DisallowSigned` (as per shell runtime) extension
|
||||
- Display small hex-slice with u8a decoding failures
|
||||
- Add `state_getChildReadProof` RPC
|
||||
- Cleanup Rococo known types (only as used)
|
||||
- Under Node.js allow for WS receiving up to 16MB messages
|
||||
- Update entries/keys for max of 256 items per call
|
||||
|
||||
|
||||
## 4.10.1 May 17, 2021
|
||||
|
||||
Upgrade priority: Medium. Recommended for uses of Polkadot/Kusama 9010 runtimes.
|
||||
|
||||
- **Breaking change** Support for the contracts V2 compatibility has been dropped in `@polkadot/api-contract`
|
||||
|
||||
Contributed:
|
||||
|
||||
- Expose RPC definitions via `.meta` (Thanks to https://github.com/jiqiang90)
|
||||
- Adjust staking derives for chain-specific optional fields (https://github.com/WoeOm)
|
||||
- Update base Centrifuge types (Thanks to https://github.com/branan)
|
||||
|
||||
Changes:
|
||||
|
||||
- Allow for `Bounded*` type usage (as per latest Substrate)
|
||||
- Adjust internal TS definitions for providers
|
||||
- Fix `ContractRx` query result definitions (no extra Observable)
|
||||
- Handle contract call RPC result directly as `Raw` (returned as hex)
|
||||
- Use `BN_*` constants as non-specified defaults in contract interfaces
|
||||
- Remove all type overrides for node/node-template (API tracks latest)
|
||||
- Contracts ABI now supports metadata version where indexes are 0-based
|
||||
- Remove support for the old-style V2 contracts from `@polkadot/api-contract`
|
||||
- Adjust historic decoration, return as-at registry via `getHeader`, `getMetadata` & `getRuntimeVersion`
|
||||
- Adjust `VecFixed` to allow for the handling of hex inputs
|
||||
- Adjust `Compact<*>` to allow for wrapped `toBigInt()` conversions
|
||||
- Fix `isPedantic` decoding to correctly handle `Text`
|
||||
- Cater for new `phragmenElection` module naming
|
||||
- Add Kusama & Westend 9010 upgrade blocks
|
||||
- Adjust `CompactSolution` for 24 nominators
|
||||
- Bump static metadata to latest Substrate
|
||||
|
||||
|
||||
## 4.9.1 May 6, 2021
|
||||
|
||||
Upgrade priority: Medium. Required for the next v0.9.0 Polkadot/Kusama chain upgrades where parachains are used.
|
||||
|
||||
- **Breaking change** The previously deprecated contracts interfaces, has been removed. Update to `<myContract>.query.*`, `<myContract>.tx.*` and `<myCode>.tx.*` interfaces as per the previous code usage hints.
|
||||
- **Important** By default the `isPedantic` mode is now switched on for storage queries. This means that the API will fail on any types where the input/output decoding doesn't match 100%
|
||||
|
||||
Changes:
|
||||
|
||||
- Re-add isPedantic check on storage decoding
|
||||
- `ConsensusEngineId` now implements `[u8;4]` (mapping closer to Rust source)
|
||||
- Additional Xcm types
|
||||
- Adjust parachain types
|
||||
- Remove error logging on createType (details passed in error)
|
||||
- Adjust `ContractInfo` type as per latest Substrate
|
||||
- Adjust `DigestItem` type as per latest Substrate
|
||||
- Adjust re-encoding of `BitVec` based on decoded length
|
||||
- Added `contracts_instantiate`, `state_traceBlock` & `system_reservedPeers` RPCs
|
||||
- Prepare for auto-capability detection with historic `.at` queries
|
||||
- Add known upgrade block for Westend 900 & 9000
|
||||
- Remove all deprecated interfaces inside `@polkadot/api-contracts`
|
||||
- Initial support for NMap storage keys
|
||||
- Support metadata v13 from Substrate (upcoming upgrade)
|
||||
- Optimize historic metadata retrieval from rpc core
|
||||
|
||||
|
||||
## 4.8.1 May 2, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended when using or developing for parachains.
|
||||
|
||||
Changes:
|
||||
|
||||
- De-alias xcm `Outcome` (used in multiple pallettes)
|
||||
- Adjust xcm types as per latest, e.g. `XcmError`
|
||||
- Fix generate of well-known storage keys (e.g. `:code`)
|
||||
- Optimize metadata unknown type validation
|
||||
- Allow metadata creation for `Map` or `Record`
|
||||
- Expose additional camelCase `method` on `AbiMessage` (maps to decorated name)
|
||||
- Added explicit double-byte ss58 `AccountId` encoding test
|
||||
- Add known upgrade block for Polkadot v30
|
||||
- Cleanup WebSocket handlers when close event has been received
|
||||
- Update to latest Substrate metadata
|
||||
|
||||
|
||||
## 4.7.2 Apr 26, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for users of 4.7.1 using nvm
|
||||
|
||||
Changes:
|
||||
|
||||
- Update `EthBlock`/`EthHeader` types (as per Rust origin)
|
||||
- Updated Xcm `OriginKind` enum
|
||||
- Add derives for `membership`
|
||||
- Cleanups on encodedLength calculations
|
||||
- Update `.nvmrc` to reflect engines changes
|
||||
|
||||
|
||||
## 4.7.1 Apr 25, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for users following Substrate master.
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust Struct decoding with better error messages on invalid input objects
|
||||
- Add support for new `BoundedVec` type
|
||||
- Expand `Data` type (as used in identity), with all is/as getters
|
||||
- Updated `Xcm` types (with Plularity)
|
||||
- Adjust `DispatchError` type as per current Substrate master
|
||||
- Adjusted Statemint `Proxy` type
|
||||
- Remove metadata generation dependency on well-known.json (dedupe)
|
||||
- Adjust WebSocket reconnection delay from 1s to 2.5s
|
||||
- Revert Beefy keys addition for Westend
|
||||
- Add explicit `engines` config to `package.json`
|
||||
- Support for `None` in `RewardDestination`
|
||||
- Align with latest substrate metadata
|
||||
|
||||
|
||||
## 4.6.2 Apr 19, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for users of Kusama/Polkadot.
|
||||
|
||||
Changes:
|
||||
|
||||
- Correct Kusama/Polkadot runtime 30 session key definitions
|
||||
|
||||
|
||||
## 4.6.1 Apr 19, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended if used in a Node.js 15.x environment.
|
||||
|
||||
Changes:
|
||||
|
||||
- Assert keypair validity in signing operations
|
||||
- Expose `internalError` on submittable results (e.g. event decoding errors)
|
||||
- Simplify session derives for old/new
|
||||
- Add Statemint to known types
|
||||
- Add support for `rpc.beefy.subscribeJustifications`
|
||||
- Update Xcm types
|
||||
- Explicitly handle `isReadyOrError` with `Api.create`
|
||||
- Add Kusama upgrade block for 2030
|
||||
|
||||
|
||||
## 4.5.1 Apr 12, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended with usage with the Rococo testnet.
|
||||
|
||||
Changes:
|
||||
|
||||
- Update parachain types as per latest Polkadot
|
||||
- Cater for `Keys` with `BEEFY` session keys
|
||||
- Update `Keys` injection to allow for on-chain type detection
|
||||
- Add `Westend` known upgrade block for runtime 50
|
||||
- Align types with latest Substrate master
|
||||
- Adjust keepalive `system_health` timer
|
||||
|
||||
|
||||
## 4.4.1 Apr 5, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended with usage with the Rococo testnet.
|
||||
|
||||
Changes:
|
||||
|
||||
- Add `ServiceQuality` type for Cumulus
|
||||
- Adjust XCM MultiLocation type (X5 to X8 junctions)
|
||||
- Add Polkadot 29 upgrade block
|
||||
|
||||
|
||||
## 4.3.1 Mar 29, 2021
|
||||
|
||||
Upgrade priority: Low.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Fix documentation on ABI parameters (Thanks to https://github.com/vminkov)
|
||||
|
||||
Changes:
|
||||
|
||||
- Warn on usage of deprecated contract interfaces
|
||||
- Update `ParaInfo` type
|
||||
- Council should be optional in treasury derives
|
||||
- Allow extraction of session derives indexes with no staking
|
||||
|
||||
|
||||
## 4.2.1 Mar 22, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended when tracking the latest updates from Substrate.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Fix contract even decoding on Substrate 3 (Thanks to https://github.com/vminkov)
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust `Extender{Header, SignedBlock}` types to ensure at-block `Header` types are used
|
||||
- Explicit definition for new Rococo triple refcount `AccountData` types
|
||||
- Convert metadata private class fields to ES-private
|
||||
- Adjust `SignedBlock` type for new `justifications` field
|
||||
- Optimize society derive for multi accounts
|
||||
- Bump metadata to latest substrate version
|
||||
|
||||
|
||||
## 4.1.1 Mar 15, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended when tracking the latest updates from Substrate.
|
||||
|
||||
@@ -21,7 +21,7 @@ The API is split up into a number of internal packages -
|
||||
|
||||
- [@polkadot/api](packages/api/) The API library, providing both Promise and RxJS Observable-based interfaces. This is the main user-facing entry point.
|
||||
- [@polkadot/api-derive](packages/api-derive/) Derived results that are injected into the API, allowing for combinations of various query results (only used internally and exposed on the Api instances via `api.derive.*`)
|
||||
- [@polkadot/api-metadata](packages/api-metadata/) Base extrinsic, storage and constant injectors for injection
|
||||
- [@polkadot/metadata](packages/metadata/) Base extrinsic, storage and constant injectors for injection
|
||||
- [@polkadot/rpc-core](packages/rpc-core/) Wrapper around all [JSON-RPC methods](https://polkadot.js.org/docs/substrate/rpc) exposed by a Polkadot network client
|
||||
- [@polkadot/rpc-provider](packages/rpc-provider/) Providers for connecting to nodes, including WebSockets and Http
|
||||
|
||||
|
||||
+8
-8
@@ -8,7 +8,7 @@
|
||||
"packages/*"
|
||||
],
|
||||
"resolutions": {
|
||||
"typescript": "^4.2.3"
|
||||
"typescript": "^4.2.4"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn build:interfaces && polkadot-dev-build-ts",
|
||||
@@ -25,14 +25,14 @@
|
||||
"test:watch": "polkadot-dev-run-test --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.13.8",
|
||||
"@babel/register": "^7.13.8",
|
||||
"@babel/runtime": "^7.13.9",
|
||||
"@polkadot/dev": "^0.62.5",
|
||||
"@polkadot/ts": "^0.3.62",
|
||||
"@babel/core": "^7.14.3",
|
||||
"@babel/register": "^7.13.16",
|
||||
"@babel/runtime": "^7.14.0",
|
||||
"@polkadot/dev": "^0.62.16",
|
||||
"@polkadot/ts": "^0.3.66",
|
||||
"@polkadot/typegen": "workspace:packages/typegen",
|
||||
"@types/jest": "^26.0.20",
|
||||
"@types/jest": "^26.0.23",
|
||||
"copyfiles": "^2.4.1"
|
||||
},
|
||||
"version": "4.1.1"
|
||||
"version": "4.11.2"
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Abi } from '@polkadot/api-contract';
|
||||
|
||||
const wsProvider = new WsProvider(<...Node Url...>);
|
||||
const api = await ApiPromise.create({ provider: wsProvider });
|
||||
const abi = new Abi(api.registry, <...JSON ABI...>);
|
||||
const abi = new Abi(<...JSON ABI...>, api.registry.getChainProperties());
|
||||
|
||||
api.tx.contracts
|
||||
.call(<contract addr>, <value>, <max gas>, abi.messages.<method name>(<...params...>))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-contract",
|
||||
"version": "4.1.1",
|
||||
"version": "4.11.2",
|
||||
"type": "module",
|
||||
"description": "Interfaces for interacting with contracts and contract ABIs",
|
||||
"main": "index.js",
|
||||
@@ -8,6 +8,9 @@
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
@@ -16,11 +19,11 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.13.9",
|
||||
"@polkadot/api": "4.1.1",
|
||||
"@polkadot/types": "4.1.1",
|
||||
"@polkadot/util": "^6.0.5",
|
||||
"@polkadot/x-rxjs": "^6.0.5",
|
||||
"@babel/runtime": "^7.14.0",
|
||||
"@polkadot/api": "4.11.2",
|
||||
"@polkadot/types": "4.11.2",
|
||||
"@polkadot/util": "^6.5.1",
|
||||
"@polkadot/x-rxjs": "^6.5.1",
|
||||
"bn.js": "^4.11.9"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,10 @@ import type { ChainProperties, ContractConstructorSpec, ContractEventSpec, Contr
|
||||
import type { AnyJson, Codec, CodecArg } from '@polkadot/types/types';
|
||||
import type { AbiConstructor, AbiEvent, AbiMessage, AbiParam, DecodedEvent, DecodedMessage } from './types';
|
||||
|
||||
import { assert, assertReturn, compactAddLength, compactStripLength, isNumber, isObject, isString, logger, stringCamelCase, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
import { assert, assertReturn, compactAddLength, compactStripLength, isNumber, isObject, isString, logger, stringCamelCase, stringify, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { MetaRegistry } from './MetaRegistry';
|
||||
|
||||
const EMPTY_U8A = new Uint8Array();
|
||||
|
||||
const l = logger('Abi');
|
||||
|
||||
function findMessage <T extends AbiMessage> (list: T[], messageOrId: T | string | number): T {
|
||||
@@ -21,7 +19,7 @@ function findMessage <T extends AbiMessage> (list: T[], messageOrId: T | string
|
||||
? list.find(({ identifier }) => [identifier, stringCamelCase(identifier)].includes(messageOrId.toString()))
|
||||
: messageOrId;
|
||||
|
||||
return assertReturn(message, `Attempted to call an invalid contract interface, ${JSON.stringify(messageOrId)}`);
|
||||
return assertReturn(message, `Attempted to call an invalid contract interface, ${stringify(messageOrId)}`);
|
||||
}
|
||||
|
||||
export class Abi {
|
||||
@@ -45,13 +43,13 @@ export class Abi {
|
||||
assert(isObject(json) && !Array.isArray(json) && json.metadataVersion && isObject(json.spec) && !Array.isArray(json.spec) && Array.isArray(json.spec.constructors) && Array.isArray(json.spec.messages), 'Invalid JSON ABI structure supplied, expected a recent metadata version');
|
||||
|
||||
this.json = json;
|
||||
this.registry = new MetaRegistry(chainProperties);
|
||||
this.registry = new MetaRegistry(json.metadataVersion as string, chainProperties);
|
||||
this.project = this.registry.createType('ContractProject', json);
|
||||
|
||||
this.registry.setMetaTypes(this.project.types);
|
||||
|
||||
this.project.types.forEach((_, index) =>
|
||||
this.registry.getMetaTypeDef({ type: this.registry.createType('SiLookupTypeId', index + 1) })
|
||||
this.registry.getMetaTypeDef({ type: this.registry.createType('SiLookupTypeId', index + this.registry.typeOffset) })
|
||||
);
|
||||
this.constructors = this.project.spec.constructors.map((spec: ContractConstructorSpec, index) =>
|
||||
this.#createMessage(spec, index, {
|
||||
@@ -81,7 +79,7 @@ export class Abi {
|
||||
const index = data[0];
|
||||
const event = this.#events[index];
|
||||
|
||||
assert(event, `Unable to find event with index ${index}`);
|
||||
assert(event, () => `Unable to find event with index ${index}`);
|
||||
|
||||
return event.fromU8a(data.subarray(1));
|
||||
}
|
||||
@@ -118,7 +116,7 @@ export class Abi {
|
||||
type: this.registry.getMetaTypeDef(arg.type)
|
||||
};
|
||||
} catch (error) {
|
||||
l.error(`Error expanding argument ${index} in ${JSON.stringify(spec)}`);
|
||||
l.error(`Error expanding argument ${index} in ${stringify(spec)}`);
|
||||
|
||||
throw error;
|
||||
}
|
||||
@@ -143,6 +141,7 @@ export class Abi {
|
||||
|
||||
#createMessage = (spec: ContractMessageSpec | ContractConstructorSpec, index: number, add: Partial<AbiMessage> = {}): AbiMessage => {
|
||||
const args = this.#createArgs(spec.args, spec);
|
||||
const identifier = spec.name.toString();
|
||||
const message = {
|
||||
...add,
|
||||
args,
|
||||
@@ -151,11 +150,12 @@ export class Abi {
|
||||
args: this.#decodeArgs(args, data),
|
||||
message
|
||||
}),
|
||||
identifier: spec.name.toString(),
|
||||
identifier,
|
||||
index,
|
||||
method: stringCamelCase(identifier),
|
||||
selector: spec.selector,
|
||||
toU8a: (params: CodecArg[], additional?: Uint8Array) =>
|
||||
this.#encodeArgs(spec, args, params, additional)
|
||||
toU8a: (params: CodecArg[]) =>
|
||||
this.#encodeArgs(spec, args, params)
|
||||
};
|
||||
|
||||
return message;
|
||||
@@ -185,14 +185,13 @@ export class Abi {
|
||||
return message.fromU8a(trimmed.subarray(4));
|
||||
}
|
||||
|
||||
#encodeArgs = ({ name, selector }: ContractMessageSpec | ContractConstructorSpec, args: AbiParam[], data: CodecArg[], additional = EMPTY_U8A): Uint8Array => {
|
||||
assert(data.length === args.length, `Expected ${args.length} arguments to contract message '${name.toString()}', found ${data.length}`);
|
||||
#encodeArgs = ({ name, selector }: ContractMessageSpec | ContractConstructorSpec, args: AbiParam[], data: CodecArg[]): Uint8Array => {
|
||||
assert(data.length === args.length, () => `Expected ${args.length} arguments to contract message '${name.toString()}', found ${data.length}`);
|
||||
|
||||
return compactAddLength(
|
||||
u8aConcat(
|
||||
this.registry.createType('ContractSelector', selector).toU8a(),
|
||||
...args.map(({ type }, index) => this.registry.createType(type.type as 'Text', data[index]).toU8a()),
|
||||
additional
|
||||
...args.map(({ type }, index) => this.registry.createType(type.type as 'Text', data[index]).toU8a())
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ interface PartialTypeSpec {
|
||||
}
|
||||
|
||||
// convert the offset into project-specific, index-1
|
||||
export function getRegistryOffset (id: SiLookupTypeId): number {
|
||||
return id.toNumber() - 1;
|
||||
export function getRegistryOffset (id: SiLookupTypeId, typeOffset: number): number {
|
||||
return id.toNumber() - typeOffset;
|
||||
}
|
||||
|
||||
const PRIMITIVE_ALIAS: Record<string, keyof InterfaceTypes> = {
|
||||
@@ -28,11 +28,16 @@ const PRIMITIVE_ALWAYS = ['AccountId', 'AccountIndex', 'Address', 'Balance'];
|
||||
export class MetaRegistry extends TypeRegistry {
|
||||
public readonly metaTypeDefs: TypeDef[] = [];
|
||||
|
||||
public readonly typeOffset;
|
||||
|
||||
#siTypes: SiType[] = [];
|
||||
|
||||
constructor (chainProperties?: ChainProperties) {
|
||||
constructor (metadataVersion: string, chainProperties?: ChainProperties) {
|
||||
super();
|
||||
|
||||
// type indexes are 1-based pre-1.0 and 0-based post-1.0
|
||||
this.typeOffset = metadataVersion.split('.')[0] === '0' ? 1 : 0;
|
||||
|
||||
if (chainProperties) {
|
||||
this.setChainProperties(chainProperties);
|
||||
}
|
||||
@@ -43,7 +48,7 @@ export class MetaRegistry extends TypeRegistry {
|
||||
}
|
||||
|
||||
public getMetaTypeDef (typeSpec: PartialTypeSpec): TypeDef {
|
||||
const offset = getRegistryOffset(typeSpec.type);
|
||||
const offset = getRegistryOffset(typeSpec.type, this.typeOffset);
|
||||
let typeDef = this.metaTypeDefs[offset];
|
||||
|
||||
if (!typeDef) {
|
||||
@@ -78,19 +83,22 @@ export class MetaRegistry extends TypeRegistry {
|
||||
}
|
||||
|
||||
#getMetaType = (id: SiLookupTypeId): SiType => {
|
||||
const type = this.#siTypes[getRegistryOffset(id)];
|
||||
const type = this.#siTypes[getRegistryOffset(id, this.typeOffset)];
|
||||
|
||||
assert(!isUndefined(type), `getMetaType:: Unable to find ${id.toNumber()} in type values`);
|
||||
assert(!isUndefined(type), () => `getMetaType:: Unable to find ${id.toNumber()} in type values`);
|
||||
|
||||
return this.createType('SiType', type);
|
||||
}
|
||||
|
||||
#extract = (type: SiType, id: SiLookupTypeId): TypeDef => {
|
||||
const path = [...type.path];
|
||||
const pathFinal = path.length ? path[path.length - 1].toString() : '';
|
||||
const isPrimitivePath = !!path.length && (
|
||||
(path.length > 2 && path[0].eq('ink_env') && path[1].eq('types')) ||
|
||||
PRIMITIVE_ALWAYS.includes(path[path.length - 1].toString())
|
||||
);
|
||||
let typeDef: Omit<TypeDef, 'type'>;
|
||||
|
||||
if (type.path.join('::').startsWith('ink_env::types::') || PRIMITIVE_ALWAYS.includes(pathFinal)) {
|
||||
if (isPrimitivePath) {
|
||||
typeDef = this.#extractPrimitivePath(type);
|
||||
} else if (type.def.isPrimitive) {
|
||||
typeDef = this.#extractPrimitive(type);
|
||||
@@ -128,7 +136,7 @@ export class MetaRegistry extends TypeRegistry {
|
||||
}
|
||||
|
||||
#extractArray = ({ len: length, type }: SiTypeDefArray): Omit<TypeDef, 'type'> => {
|
||||
assert(!length || length.toNumber() <= 256, 'MetaRegistry: Only support for [Type; <length>], where length > 256');
|
||||
assert(!length || length.toNumber() <= 256, 'MetaRegistry: Only support for [Type; <length>], where length <= 256');
|
||||
|
||||
return {
|
||||
info: TypeDefInfo.VecFixed,
|
||||
@@ -144,27 +152,27 @@ export class MetaRegistry extends TypeRegistry {
|
||||
]),
|
||||
[true, true]);
|
||||
|
||||
let info;
|
||||
|
||||
// check for tuple first (no fields may be available)
|
||||
if (isTuple) {
|
||||
info = TypeDefInfo.Tuple;
|
||||
} else if (isStruct) {
|
||||
info = TypeDefInfo.Struct;
|
||||
} else {
|
||||
throw new Error('Invalid fields type detected, expected either Tuple or Struct');
|
||||
}
|
||||
assert(isTuple || isStruct, 'Invalid fields type detected, expected either Tuple or Struct');
|
||||
|
||||
const sub = fields.map(({ name, type }) => {
|
||||
return {
|
||||
...this.getMetaTypeDef({ type }),
|
||||
...(name.isSome ? { name: name.unwrap().toString() } : {})
|
||||
...(name.isSome
|
||||
? { name: name.unwrap().toString() }
|
||||
: {}
|
||||
)
|
||||
};
|
||||
});
|
||||
|
||||
return isTuple && sub.length === 1
|
||||
? sub[0]
|
||||
: { info, sub };
|
||||
: {
|
||||
// check for tuple first (no fields may be available)
|
||||
info: isTuple
|
||||
? TypeDefInfo.Tuple
|
||||
: TypeDefInfo.Struct,
|
||||
sub
|
||||
};
|
||||
}
|
||||
|
||||
#extractPrimitive = (type: SiType): TypeDef => {
|
||||
@@ -184,7 +192,7 @@ export class MetaRegistry extends TypeRegistry {
|
||||
}
|
||||
|
||||
#extractSequence = ({ type }: SiTypeDefSequence, id: SiLookupTypeId): Omit<TypeDef, 'type'> => {
|
||||
assert(!!type, `ContractRegistry: Invalid sequence type found at id ${id.toString()}`);
|
||||
assert(!!type, () => `ContractRegistry: Invalid sequence type found at id ${id.toString()}`);
|
||||
|
||||
return {
|
||||
info: TypeDefInfo.Vec,
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import type { AnyJson, Registry } from '@polkadot/types/types';
|
||||
|
||||
import { ApiBase } from '@polkadot/api/base';
|
||||
import { assert } from '@polkadot/util';
|
||||
import { assert, isFunction } from '@polkadot/util';
|
||||
|
||||
import { Abi } from '../Abi';
|
||||
|
||||
@@ -26,6 +26,6 @@ export abstract class Base<ApiType extends ApiTypes> {
|
||||
this.registry = this.abi.registry;
|
||||
this._decorateMethod = decorateMethod;
|
||||
|
||||
assert(api.rx.tx.contracts?.instantiate, 'You need to connect to a node with the contracts module, the metadata does not enable api.tx.contracts on this instance');
|
||||
assert(isFunction(api.rx.tx.contracts?.instantiateWithCode), 'You need to connect to a node with a V3 contracts module. Your node does not expose api.tx.contracts.instantiateWithCode on this instance');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,17 +6,17 @@ import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import type { AccountId, EventRecord, Hash } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
|
||||
import type { AbiConstructor, BlueprintOptions } from '../types';
|
||||
import type { ContractGeneric, MapConstructorExec } from './types';
|
||||
import type { MapConstructorExec } from './types';
|
||||
|
||||
import { SubmittableResult } from '@polkadot/api';
|
||||
import { ApiBase } from '@polkadot/api/base';
|
||||
import { isUndefined, stringCamelCase } from '@polkadot/util';
|
||||
import { BN_ZERO, isUndefined } from '@polkadot/util';
|
||||
|
||||
import { Abi } from '../Abi';
|
||||
import { applyOnEvent } from '../util';
|
||||
import { Base } from './Base';
|
||||
import { Contract } from './Contract';
|
||||
import { createBluePrintTx, createBluePrintWithId, EMPTY_SALT, encodeSalt } from './util';
|
||||
import { createBluePrintTx, encodeSalt } from './util';
|
||||
|
||||
export class BlueprintSubmittableResult<ApiType extends ApiTypes> extends SubmittableResult {
|
||||
public readonly contract?: Contract<ApiType>;
|
||||
@@ -34,25 +34,16 @@ export class Blueprint<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
*/
|
||||
public readonly codeHash: Hash;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @description Deprecated. Use `.tx.<constructorName>`. Creates a contract in a non-deterministic way.
|
||||
*/
|
||||
public readonly createContract: ContractGeneric<BlueprintOptions, SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>>>;
|
||||
|
||||
readonly #tx: MapConstructorExec<ApiType> = {};
|
||||
|
||||
constructor (api: ApiBase<ApiType>, abi: AnyJson | Abi, codeHash: string | Hash | Uint8Array, decorateMethod: DecorateMethod<ApiType>) {
|
||||
super(api, abi, decorateMethod);
|
||||
|
||||
this.codeHash = this.registry.createType('Hash', codeHash);
|
||||
this.createContract = createBluePrintWithId(this.#deploy);
|
||||
|
||||
this.abi.constructors.forEach((c): void => {
|
||||
const messageName = stringCamelCase(c.identifier);
|
||||
|
||||
if (isUndefined(this.#tx[messageName])) {
|
||||
this.#tx[messageName] = createBluePrintTx((o, p) => this.#deploy(c, o, p));
|
||||
if (isUndefined(this.#tx[c.method])) {
|
||||
this.#tx[c.method] = createBluePrintTx((o, p) => this.#deploy(c, o, p));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -61,20 +52,19 @@ export class Blueprint<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
return this.#tx;
|
||||
}
|
||||
|
||||
#deploy = (constructorOrId: AbiConstructor | string | number, { gasLimit = 0, salt, value = 0 }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> => {
|
||||
const encodedSalt = encodeSalt(salt);
|
||||
const withSalt = this.api.tx.contracts.instantiate.meta.args.length === 5;
|
||||
const encoded = this.abi.findConstructor(constructorOrId).toU8a(params, withSalt ? EMPTY_SALT : encodedSalt);
|
||||
const tx = withSalt
|
||||
? this.api.tx.contracts.instantiate(value, gasLimit, this.codeHash, encoded, encodedSalt)
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore old style with salt included
|
||||
: this.api.tx.contracts.instantiate(value, gasLimit, this.codeHash, encoded);
|
||||
|
||||
return tx.withResultTransform((result: ISubmittableResult) =>
|
||||
new BlueprintSubmittableResult(result, applyOnEvent(result, ['Instantiated'], ([record]: EventRecord[]) =>
|
||||
new Contract<ApiType>(this.api, this.abi, record.event.data[1] as AccountId, this._decorateMethod)
|
||||
))
|
||||
);
|
||||
#deploy = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, value = BN_ZERO }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> => {
|
||||
return this.api.tx.contracts
|
||||
.instantiate(
|
||||
value,
|
||||
gasLimit,
|
||||
this.codeHash,
|
||||
this.abi.findConstructor(constructorOrId).toU8a(params),
|
||||
encodeSalt(salt)
|
||||
)
|
||||
.withResultTransform((result: ISubmittableResult) =>
|
||||
new BlueprintSubmittableResult(result, applyOnEvent(result, ['Instantiated'], ([record]: EventRecord[]) =>
|
||||
new Contract<ApiType>(this.api, this.abi, record.event.data[1] as AccountId, this._decorateMethod)
|
||||
))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,15 +10,14 @@ import type { MapConstructorExec } from './types';
|
||||
|
||||
import { SubmittableResult } from '@polkadot/api';
|
||||
import { ApiBase } from '@polkadot/api/base';
|
||||
import { assert, compactAddLength, isFunction, isUndefined, isWasm, stringCamelCase, u8aToU8a } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
import { assert, BN_ZERO, compactAddLength, isUndefined, isWasm, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { Abi } from '../Abi';
|
||||
import { applyOnEvent } from '../util';
|
||||
import { Base } from './Base';
|
||||
import { Blueprint } from './Blueprint';
|
||||
import { Contract } from './Contract';
|
||||
import { createBluePrintTx, EMPTY_SALT, encodeSalt } from './util';
|
||||
import { createBluePrintTx, encodeSalt } from './util';
|
||||
|
||||
export class CodeSubmittableResult<ApiType extends ApiTypes> extends SubmittableResult {
|
||||
public readonly blueprint?: Blueprint<ApiType>;
|
||||
@@ -47,10 +46,8 @@ export class Code<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
assert(isWasm(this.code), 'No WASM code provided');
|
||||
|
||||
this.abi.constructors.forEach((c): void => {
|
||||
const messageName = stringCamelCase(c.identifier);
|
||||
|
||||
if (isUndefined(this.#tx[messageName])) {
|
||||
this.#tx[messageName] = createBluePrintTx((o, p) => this.#instantiate(c, o, p));
|
||||
if (isUndefined(this.#tx[c.method])) {
|
||||
this.#tx[c.method] = createBluePrintTx((o, p) => this.#instantiate(c, o, p));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -59,51 +56,25 @@ export class Code<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
return this.#tx;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Deploy the code bundle and the contract, creating a Blueprint.
|
||||
* @deprecated Use the `code.tx.<constructor>(...) format to put code and deploy
|
||||
*/
|
||||
public createContract (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> {
|
||||
return this.#instantiate(constructorOrId, options, params);
|
||||
}
|
||||
|
||||
#instantiate = (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
|
||||
return isFunction(this.api.tx.contracts.instantiateWithCode)
|
||||
? this.#instantiateSingle(constructorOrId, options, params)
|
||||
: this.#instantiateBatch(constructorOrId, options, params);
|
||||
}
|
||||
|
||||
#instantiateSingle = (constructorOrId: AbiConstructor | string | number, { gasLimit = 0, salt, value = 0 }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
|
||||
#instantiate = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, value = BN_ZERO }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
|
||||
return this.api.tx.contracts
|
||||
.instantiateWithCode(value, gasLimit, compactAddLength(this.code), this.abi.findConstructor(constructorOrId).toU8a(params), encodeSalt(salt))
|
||||
.withResultTransform(this.#transformEvents);
|
||||
}
|
||||
|
||||
#instantiateBatch = (constructorOrId: AbiConstructor | string | number, { gasLimit = 0, salt, value = 0 }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
|
||||
const encodedSalt = encodeSalt(salt);
|
||||
const withSalt = this.api.tx.contracts.instantiate.meta.args.length === 5;
|
||||
const encoded = this.abi.findConstructor(constructorOrId).toU8a(params, withSalt ? EMPTY_SALT : encodedSalt);
|
||||
const codeHash = blake2AsU8a(this.code);
|
||||
|
||||
return this.api.tx.utility.batch([
|
||||
this.api.tx.contracts.putCode(compactAddLength(this.code)),
|
||||
withSalt
|
||||
? this.api.tx.contracts.instantiate(value, gasLimit, codeHash, encoded, encodedSalt)
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore old style with salt included in the params itself
|
||||
: this.api.tx.contracts.instantiate(value, gasLimit, codeHash, encoded)
|
||||
]).withResultTransform(this.#transformEvents);
|
||||
}
|
||||
|
||||
#transformEvents = (result: ISubmittableResult): CodeSubmittableResult<ApiType> => {
|
||||
return new CodeSubmittableResult(result, ...(applyOnEvent(result, ['CodeStored', 'Instantiated'], (records: EventRecord[]) =>
|
||||
records.reduce(([blueprint, contract], { event }): [Blueprint<ApiType>?, Contract<ApiType>?] =>
|
||||
this.api.events.contracts.Instantiated.is(event)
|
||||
? [blueprint, new Contract<ApiType>(this.api, this.abi, event.data[1], this._decorateMethod)]
|
||||
: this.api.events.contracts.CodeStored.is(event)
|
||||
? [new Blueprint<ApiType>(this.api, this.abi, event.data[0], this._decorateMethod), contract]
|
||||
: [blueprint, contract],
|
||||
[] as [Blueprint<ApiType>?, Contract<ApiType>?])
|
||||
) || []));
|
||||
.instantiateWithCode(
|
||||
value,
|
||||
gasLimit,
|
||||
compactAddLength(this.code),
|
||||
this.abi.findConstructor(constructorOrId).toU8a(params),
|
||||
encodeSalt(salt)
|
||||
)
|
||||
.withResultTransform((result: ISubmittableResult) =>
|
||||
new CodeSubmittableResult(result, ...(applyOnEvent(result, ['CodeStored', 'Instantiated'], (records: EventRecord[]) =>
|
||||
records.reduce<[Blueprint<ApiType>?, Contract<ApiType>?]>(([blueprint, contract], { event }) =>
|
||||
this.api.events.contracts.Instantiated.is(event)
|
||||
? [blueprint, new Contract<ApiType>(this.api, this.abi, event.data[1], this._decorateMethod)]
|
||||
: this.api.events.contracts.CodeStored.is(event)
|
||||
? [new Blueprint<ApiType>(this.api, this.abi, event.data[0], this._decorateMethod), contract]
|
||||
: [blueprint, contract],
|
||||
[])
|
||||
) || []))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,25 +4,27 @@
|
||||
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import type { Bytes } from '@polkadot/types';
|
||||
import type { AccountId, ContractExecResult, EventRecord, Weight } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson, CodecArg, ISubmittableResult, Registry } from '@polkadot/types/types';
|
||||
import type { AccountId, EventRecord, Weight } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
|
||||
import type { AbiMessage, ContractCallOutcome, ContractOptions, DecodedEvent } from '../types';
|
||||
import type { ContractCallResult, ContractCallSend, ContractGeneric, ContractQuery, ContractTx, MapMessageQuery, MapMessageTx } from './types';
|
||||
import type { ContractCallResult, ContractCallSend, ContractQuery, ContractTx, MapMessageQuery, MapMessageTx } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { SubmittableResult } from '@polkadot/api';
|
||||
import { ApiBase } from '@polkadot/api/base';
|
||||
import { assert, bnToBn, isFunction, isUndefined, logger, stringCamelCase } from '@polkadot/util';
|
||||
import { createTypeUnsafe } from '@polkadot/types';
|
||||
import { assert, BN_HUNDRED, BN_ONE, BN_ZERO, bnToBn, isFunction, isUndefined, logger } from '@polkadot/util';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { Abi } from '../Abi';
|
||||
import { applyOnEvent, extractOptions, formatData, isOptions } from '../util';
|
||||
import { applyOnEvent, extractOptions, isOptions } from '../util';
|
||||
import { Base } from './Base';
|
||||
|
||||
// As per Rust, 5 * GAS_PER_SEC
|
||||
const MAX_CALL_GAS = new BN(5_000_000_000_000).subn(1);
|
||||
const MAX_CALL_GAS = new BN(5_000_000_000_000).isub(BN_ONE);
|
||||
const ERROR_NO_CALL = 'Your node does not expose the contracts.call RPC. This is most probably due to a runtime configuration.';
|
||||
|
||||
const l = logger('Contract');
|
||||
|
||||
function createQuery <ApiType extends ApiTypes> (fn: (origin: string | AccountId | Uint8Array, options: ContractOptions, params: CodecArg[]) => ContractCallResult<ApiType, ContractCallOutcome>): ContractQuery<ApiType> {
|
||||
@@ -39,13 +41,6 @@ function createTx <ApiType extends ApiTypes> (fn: (options: ContractOptions, par
|
||||
: fn(...extractOptions(options, params));
|
||||
}
|
||||
|
||||
function createWithId <T> (fn: (messageOrId: AbiMessage | string | number, options: ContractOptions, params: CodecArg[]) => T): ContractGeneric<ContractOptions, T> {
|
||||
return (messageOrId: AbiMessage | string | number, options: BigInt | string | number | BN | ContractOptions, ...params: CodecArg[]): T =>
|
||||
isOptions(options)
|
||||
? fn(messageOrId, options, params)
|
||||
: fn(messageOrId, ...extractOptions(options, params));
|
||||
}
|
||||
|
||||
export class ContractSubmittableResult extends SubmittableResult {
|
||||
public readonly contractEvents?: DecodedEvent[];
|
||||
|
||||
@@ -56,51 +51,12 @@ export class ContractSubmittableResult extends SubmittableResult {
|
||||
}
|
||||
}
|
||||
|
||||
// map from a JSON result to current-style ContractExecResult
|
||||
function mapExecResult (registry: Registry, json: Record<string, AnyJson>): ContractExecResult {
|
||||
if (!Object.keys(json).some((key) => ['error', 'success'].includes(key))) {
|
||||
return registry.createType('ContractExecResult', json);
|
||||
}
|
||||
|
||||
const from = registry.createType('ContractExecResultTo260', json);
|
||||
|
||||
if (from.isSuccess) {
|
||||
const s = from.asSuccess;
|
||||
|
||||
return registry.createType('ContractExecResult', {
|
||||
gasConsumed: s.gasConsumed,
|
||||
result: {
|
||||
ok: {
|
||||
data: s.data,
|
||||
flags: s.flags
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// in the old format error has no additional information,
|
||||
// map it as-is with an "unknown" error
|
||||
return registry.createType('ContractExecResult', { result: { err: { other: 'unknown' } } });
|
||||
}
|
||||
|
||||
export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
/**
|
||||
* @description The on-chain address for this contract
|
||||
*/
|
||||
public readonly address: AccountId;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @description Deprecated. Use `.tx.<messageName>` to send a transaction.
|
||||
*/
|
||||
public readonly exec: ContractGeneric<ContractOptions, SubmittableExtrinsic<ApiType>>;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @description Deprecated. Use `.tx.<messageName>` to send a transaction.
|
||||
*/
|
||||
public readonly read: ContractGeneric<ContractOptions, ContractCallSend<ApiType>>;
|
||||
|
||||
readonly #query: MapMessageQuery<ApiType> = {};
|
||||
|
||||
readonly #tx: MapMessageTx<ApiType> = {};
|
||||
@@ -109,18 +65,14 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
super(api, abi, decorateMethod);
|
||||
|
||||
this.address = this.registry.createType('AccountId', address);
|
||||
this.exec = createWithId(this.#exec);
|
||||
this.read = createWithId(this.#read);
|
||||
|
||||
this.abi.messages.forEach((m): void => {
|
||||
const messageName = stringCamelCase(m.identifier);
|
||||
|
||||
if (isUndefined(this.#tx[messageName])) {
|
||||
this.#tx[messageName] = createTx((o, p) => this.#exec(m, o, p));
|
||||
if (isUndefined(this.#tx[m.method])) {
|
||||
this.#tx[m.method] = createTx((o, p) => this.#exec(m, o, p));
|
||||
}
|
||||
|
||||
if (isUndefined(this.#query[messageName])) {
|
||||
this.#query[messageName] = createQuery((f, o, p) => this.#read(m, o, p).send(f));
|
||||
if (isUndefined(this.#query[m.method])) {
|
||||
this.#query[m.method] = createQuery((f, o, p) => this.#read(m, o, p).send(f));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -142,21 +94,27 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
#getGas = (_gasLimit: BigInt | BN | string | number, isCall = false): BN => {
|
||||
const gasLimit = bnToBn(_gasLimit);
|
||||
|
||||
return gasLimit.lten(0)
|
||||
return gasLimit.lte(BN_ZERO)
|
||||
? isCall
|
||||
? MAX_CALL_GAS
|
||||
: (this.api.consts.system.blockWeights
|
||||
? this.api.consts.system.blockWeights.maxBlock
|
||||
: this.api.consts.system.maximumBlockWeight as Weight
|
||||
).muln(64).divn(100)
|
||||
).muln(64).div(BN_HUNDRED)
|
||||
: gasLimit;
|
||||
}
|
||||
|
||||
#exec = (messageOrId: AbiMessage | string | number, { gasLimit = 0, value = 0 }: ContractOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType> => {
|
||||
#exec = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, value = BN_ZERO }: ContractOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType> => {
|
||||
return this.api.tx.contracts
|
||||
.call(this.address, value, this.#getGas(gasLimit), this.abi.findMessage(messageOrId).toU8a(params))
|
||||
.call(
|
||||
this.address,
|
||||
value,
|
||||
this.#getGas(gasLimit),
|
||||
this.abi.findMessage(messageOrId).toU8a(params)
|
||||
)
|
||||
.withResultTransform((result: ISubmittableResult) =>
|
||||
new ContractSubmittableResult(result, applyOnEvent(result, ['ContractExecution'], (records: EventRecord[]) =>
|
||||
// ContractEmitted is the current generation, ContractExecution is the previous generation
|
||||
new ContractSubmittableResult(result, applyOnEvent(result, ['ContractEmitted', 'ContractExecution'], (records: EventRecord[]) =>
|
||||
records
|
||||
.map(({ event: { data: [, data] } }): DecodedEvent | null => {
|
||||
try {
|
||||
@@ -172,7 +130,7 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
);
|
||||
}
|
||||
|
||||
#read = (messageOrId: AbiMessage | string | number, { gasLimit = 0, value = 0 }: ContractOptions, params: CodecArg[]): ContractCallSend<ApiType> => {
|
||||
#read = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, value = BN_ZERO }: ContractOptions, params: CodecArg[]): ContractCallSend<ApiType> => {
|
||||
assert(this.hasRpcContractsCall, ERROR_NO_CALL);
|
||||
|
||||
const message = this.abi.findMessage(messageOrId);
|
||||
@@ -180,24 +138,24 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
return {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
send: this._decorateMethod((origin: string | AccountId | Uint8Array) =>
|
||||
this.api.rx.rpc.contracts.call.json({
|
||||
dest: this.address,
|
||||
gasLimit: this.#getGas(gasLimit, true),
|
||||
inputData: message.toU8a(params),
|
||||
origin,
|
||||
value
|
||||
}).pipe(map((json): ContractCallOutcome => {
|
||||
const { debugMessage, gasConsumed, result } = mapExecResult(this.registry, json.toJSON());
|
||||
|
||||
return {
|
||||
debugMessage,
|
||||
gasConsumed,
|
||||
output: result.isOk && message.returnType
|
||||
? formatData(this.registry, result.asOk.data, message.returnType)
|
||||
: null,
|
||||
result
|
||||
};
|
||||
}))
|
||||
this.api.rx.rpc.contracts
|
||||
.call({
|
||||
dest: this.address,
|
||||
gasLimit: this.#getGas(gasLimit, true),
|
||||
inputData: message.toU8a(params),
|
||||
origin,
|
||||
value
|
||||
})
|
||||
.pipe(
|
||||
map(({ debugMessage, gasConsumed, result }): ContractCallOutcome => ({
|
||||
debugMessage,
|
||||
gasConsumed,
|
||||
output: result.isOk && message.returnType
|
||||
? createTypeUnsafe(this.registry, message.returnType.type, [result.asOk.data.toU8a(true)], { isPedantic: true })
|
||||
: null,
|
||||
result
|
||||
}))
|
||||
)
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,10 +11,7 @@ export const mockApi = {
|
||||
rx: {
|
||||
tx: {
|
||||
contracts: {
|
||||
instantiate: (): never => {
|
||||
throw new Error('mock');
|
||||
},
|
||||
putCode: (): never => {
|
||||
instantiateWithCode: (): never => {
|
||||
throw new Error('mock');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ export interface ContractGeneric<O, T> {
|
||||
}
|
||||
|
||||
export type ContractCallResult<ApiType extends ApiTypes, T> = ApiType extends 'rxjs'
|
||||
? Observable<Observable<T>>
|
||||
? Observable<T>
|
||||
: Promise<ObsInnerType<Observable<T>>>;
|
||||
|
||||
export interface ContractCallSend<ApiType extends ApiTypes> {
|
||||
|
||||
@@ -30,10 +30,6 @@ async function checkContract (api: ApiPromise, pairs: TestKeyringMap): Promise<v
|
||||
// execute
|
||||
await contract.tx.inc({ gasLimit: 1234 }, 123).signAndSend(pairs.eve);
|
||||
await contract.tx.inc(123, 456, 69).signAndSend(pairs.eve);
|
||||
|
||||
// deprecated
|
||||
await contract.read('get', {}).send(pairs.eve.address);
|
||||
await contract.exec('inc', {}, 123).signAndSend(pairs.dave);
|
||||
}
|
||||
|
||||
async function main (): Promise<void> {
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api-contract', version: '4.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/api-contract', version: '4.11.2' };
|
||||
|
||||
@@ -39,9 +39,10 @@ export interface AbiMessage {
|
||||
isConstructor?: boolean;
|
||||
isMutating?: boolean;
|
||||
isPayable?: boolean;
|
||||
method: string;
|
||||
returnType?: TypeDef | null;
|
||||
selector: ContractSelector;
|
||||
toU8a: (params: CodecArg[], additional?: Uint8Array) => Uint8Array;
|
||||
toU8a: (params: CodecArg[]) => Uint8Array;
|
||||
}
|
||||
|
||||
export type AbiConstructor = AbiMessage;
|
||||
|
||||
@@ -2,24 +2,18 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { SubmittableResult } from '@polkadot/api';
|
||||
import type { Raw } from '@polkadot/types';
|
||||
import type { EventRecord } from '@polkadot/types/interfaces';
|
||||
import type { Codec, CodecArg, Registry, TypeDef } from '@polkadot/types/types';
|
||||
import type { CodecArg } from '@polkadot/types/types';
|
||||
import type { BlueprintOptions, ContractOptions } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { createTypeUnsafe } from '@polkadot/types/create';
|
||||
import { isBigInt, isBn, isNumber, isString } from '@polkadot/util';
|
||||
|
||||
type ContractEvents = 'CodeStored' | 'ContractExecution' | 'Instantiated';
|
||||
type ContractEvents = 'CodeStored' | 'ContractEmitted' | 'ContractExecution' | 'Instantiated';
|
||||
|
||||
type TOptions = BlueprintOptions | ContractOptions;
|
||||
|
||||
export function formatData (registry: Registry, data: Raw, { type }: TypeDef): Codec {
|
||||
return createTypeUnsafe(registry, type, [data], { isPedantic: true });
|
||||
}
|
||||
|
||||
export function applyOnEvent <T> (result: SubmittableResult, types: ContractEvents[], fn: (records: EventRecord[]) => T): T | undefined {
|
||||
if (result.isInBlock || result.isFinalized) {
|
||||
const records = result.filterRecords('contracts', types);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-derive",
|
||||
"version": "4.1.1",
|
||||
"version": "4.11.2",
|
||||
"type": "module",
|
||||
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
|
||||
"main": "index.js",
|
||||
@@ -8,6 +8,9 @@
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
@@ -16,17 +19,17 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.13.9",
|
||||
"@polkadot/api": "4.1.1",
|
||||
"@polkadot/rpc-core": "4.1.1",
|
||||
"@polkadot/types": "4.1.1",
|
||||
"@polkadot/util": "^6.0.5",
|
||||
"@polkadot/util-crypto": "^6.0.5",
|
||||
"@polkadot/x-rxjs": "^6.0.5",
|
||||
"@babel/runtime": "^7.14.0",
|
||||
"@polkadot/api": "4.11.2",
|
||||
"@polkadot/rpc-core": "4.11.2",
|
||||
"@polkadot/types": "4.11.2",
|
||||
"@polkadot/util": "^6.5.1",
|
||||
"@polkadot/util-crypto": "^6.5.1",
|
||||
"@polkadot/x-rxjs": "^6.5.1",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^6.0.5",
|
||||
"@polkadot/rpc-provider": "4.1.1"
|
||||
"@polkadot/keyring": "^6.5.1",
|
||||
"@polkadot/rpc-provider": "4.11.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,11 @@ function parseFlags (address: AccountId | Address | string | null | undefined, [
|
||||
*/
|
||||
export function flags (instanceId: string, api: ApiInterfaceRx): (address?: AccountId | Address | string | null) => Observable<DeriveAccountFlags> {
|
||||
return memo(instanceId, (address?: AccountId | Address | string | null): Observable<DeriveAccountFlags> => {
|
||||
const councilSection = api.query.electionsPhragmen ? 'electionsPhragmen' : 'elections';
|
||||
const councilSection = api.query.phragmenElection
|
||||
? 'phragmenElection'
|
||||
: api.query.electionsPhragmen
|
||||
? 'electionsPhragmen'
|
||||
: 'elections';
|
||||
|
||||
return combineLatest<FlagsIntermediate>([
|
||||
address && api.query[councilSection]?.members
|
||||
|
||||
@@ -44,11 +44,11 @@ function calcLocked (api: ApiInterfaceRx, bestNumber: BlockNumber, locks: (Balan
|
||||
if (Array.isArray(locks)) {
|
||||
// only get the locks that are valid until passed the current block
|
||||
lockedBreakdown = (locks as BalanceLockTo212[]).filter(({ until }): boolean => !until || (bestNumber && until.gt(bestNumber)));
|
||||
allLocked = lockedBreakdown.some(({ amount }) => amount.isMax());
|
||||
allLocked = lockedBreakdown.some(({ amount }) => amount && amount.isMax());
|
||||
vestingLocked = api.registry.createType('Balance', lockedBreakdown.filter(({ id }) => id.eq(VESTING_ID)).reduce((result: BN, { amount }) => result.iadd(amount), new BN(0)));
|
||||
|
||||
// get the maximum of the locks according to https://github.com/paritytech/substrate/blob/master/srml/balances/src/lib.rs#L699
|
||||
const notAll = lockedBreakdown.filter(({ amount }) => !amount.isMax());
|
||||
const notAll = lockedBreakdown.filter(({ amount }) => amount && !amount.isMax());
|
||||
|
||||
if (notAll.length) {
|
||||
lockedBalance = api.registry.createType('Balance', bnMax(...notAll.map(({ amount }): Balance => amount)));
|
||||
|
||||
@@ -37,12 +37,16 @@ export function bounties (instanceId: string, api: ApiInterfaceRx): () => Observ
|
||||
return memo(instanceId, (): Observable<DeriveBounties> =>
|
||||
combineLatest([
|
||||
bountyBase.bountyCount<BountyIndex>(),
|
||||
api.query.council ? api.query.council.proposalCount<ProposalIndex>() : of(0)
|
||||
api.query.council
|
||||
? api.query.council.proposalCount<ProposalIndex>()
|
||||
: of(0)
|
||||
]).pipe(
|
||||
switchMap(() =>
|
||||
combineLatest([
|
||||
bountyBase.bounties.keys<[BountyIndex]>(),
|
||||
api.derive.council ? api.derive.council.proposals() : of([])
|
||||
api.derive.council
|
||||
? api.derive.council.proposals()
|
||||
: of([])
|
||||
])
|
||||
),
|
||||
switchMap(([keys, proposals]): Observable<Result> => {
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { SignedBlockExtended } from '../type/types';
|
||||
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { catchError, map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { SignedBlockExtended } from '../type';
|
||||
import { createSignedBlockExtended } from '../type';
|
||||
import { memo } from '../util';
|
||||
|
||||
/**
|
||||
@@ -33,7 +34,7 @@ export function getBlock (instanceId: string, api: ApiInterfaceRx): (hash: Uint8
|
||||
: of([])
|
||||
]).pipe(
|
||||
map(([signedBlock, events, validators]): SignedBlockExtended =>
|
||||
new SignedBlockExtended(signedBlock.registry, signedBlock, events, validators)
|
||||
createSignedBlockExtended(api.registry, signedBlock, events, validators)
|
||||
),
|
||||
catchError((): Observable<undefined> =>
|
||||
// where rpc.chain.getHeader throws, we will land here - it can happen that
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { HeaderExtended } from '../type/types';
|
||||
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { catchError, map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { HeaderExtended } from '../type';
|
||||
import { createHeaderExtended } from '../type';
|
||||
import { memo } from '../util';
|
||||
|
||||
/**
|
||||
@@ -33,7 +34,7 @@ export function getHeader (instanceId: string, api: ApiInterfaceRx): (hash: Uint
|
||||
: of([])
|
||||
]).pipe(
|
||||
map(([header, validators]): HeaderExtended =>
|
||||
new HeaderExtended(header.registry, header, validators)
|
||||
createHeaderExtended(header.registry, header, validators)
|
||||
),
|
||||
catchError((): Observable<undefined> =>
|
||||
// where rpc.chain.getHeader throws, we will land here - it can happen that
|
||||
|
||||
@@ -5,12 +5,12 @@ import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Vec } from '@polkadot/types';
|
||||
import type { EventRecord, SignedBlock } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { HeaderExtended } from '../type';
|
||||
import type { HeaderExtended, SignedBlockExtended } from '../type/types';
|
||||
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { SignedBlockExtended } from '../type';
|
||||
import { createSignedBlockExtended } from '../type';
|
||||
import { memo } from '../util';
|
||||
|
||||
/**
|
||||
@@ -30,7 +30,7 @@ export function subscribeNewBlocks (instanceId: string, api: ApiInterfaceRx): ()
|
||||
);
|
||||
}),
|
||||
map(([block, events, header]) =>
|
||||
new SignedBlockExtended(block.registry, block, events, header.validators)
|
||||
createSignedBlockExtended(block.registry, block, events, header.validators)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { HeaderExtended } from '../type/types';
|
||||
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { HeaderExtended } from '../type';
|
||||
import { createHeaderExtended } from '../type';
|
||||
import { memo } from '../util';
|
||||
|
||||
/**
|
||||
@@ -34,7 +35,7 @@ export function subscribeNewHeads (instanceId: string, api: ApiInterfaceRx): ()
|
||||
map(([header, validators]): HeaderExtended => {
|
||||
header.createdAtHash = header.hash;
|
||||
|
||||
return new HeaderExtended(header.registry, header, validators);
|
||||
return createHeaderExtended(header.registry, header, validators);
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
@@ -13,6 +13,8 @@ import { catchError, map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type Collective = 'council' | 'membership' | 'technicalCommittee';
|
||||
|
||||
type Result = [(Hash | Uint8Array | string)[], (Option<Proposal> | null)[], Option<Votes>[]];
|
||||
|
||||
function parse (api: ApiInterfaceRx, [hashes, proposals, votes]: Result): DeriveCollectiveProposal[] {
|
||||
@@ -29,7 +31,7 @@ function parse (api: ApiInterfaceRx, [hashes, proposals, votes]: Result): Derive
|
||||
.filter((proposal): proposal is DeriveCollectiveProposal => !!proposal);
|
||||
}
|
||||
|
||||
function _proposalsFrom (instanceId: string, api: ApiInterfaceRx, section: 'council' | 'technicalCommittee' = 'council'): (hashes: (Hash | Uint8Array | string)[]) => Observable<DeriveCollectiveProposal[]> {
|
||||
function _proposalsFrom (instanceId: string, api: ApiInterfaceRx, section: Collective): (hashes: (Hash | Uint8Array | string)[]) => Observable<DeriveCollectiveProposal[]> {
|
||||
return memo(instanceId, (hashes: (Hash | Uint8Array | string)[]): Observable<DeriveCollectiveProposal[]> =>
|
||||
(isFunction(api.query[section]?.proposals) && hashes.length
|
||||
? combineLatest<Result>([
|
||||
@@ -49,19 +51,19 @@ function _proposalsFrom (instanceId: string, api: ApiInterfaceRx, section: 'coun
|
||||
);
|
||||
}
|
||||
|
||||
export function proposals (instanceId: string, api: ApiInterfaceRx, section: 'council' | 'technicalCommittee' = 'council'): () => Observable<DeriveCollectiveProposal[]> {
|
||||
export function proposals (instanceId: string, api: ApiInterfaceRx, section: Collective): () => Observable<DeriveCollectiveProposal[]> {
|
||||
const proposalsFrom = _proposalsFrom(instanceId, api, section);
|
||||
|
||||
return memo(instanceId, (): Observable<DeriveCollectiveProposal[]> =>
|
||||
isFunction(api.query[section]?.proposals)
|
||||
? api.query[section].proposals().pipe(
|
||||
? api.query[section as 'council'].proposals().pipe(
|
||||
switchMap(proposalsFrom)
|
||||
)
|
||||
: of([] as DeriveCollectiveProposal[])
|
||||
);
|
||||
}
|
||||
|
||||
export function proposal (instanceId: string, api: ApiInterfaceRx, section: 'council' | 'technicalCommittee' = 'council'): (hash: Hash | Uint8Array | string) => Observable<DeriveCollectiveProposal | null> {
|
||||
export function proposal (instanceId: string, api: ApiInterfaceRx, section: Collective): (hash: Hash | Uint8Array | string) => Observable<DeriveCollectiveProposal | null> {
|
||||
const proposalsFrom = _proposalsFrom(instanceId, api, section);
|
||||
|
||||
return memo(instanceId, (hash: Hash | Uint8Array | string): Observable<DeriveCollectiveProposal | null> =>
|
||||
|
||||
@@ -10,9 +10,9 @@ import { proposal as collectiveProposal, proposals as collectiveProposals } from
|
||||
import { memo } from '../util';
|
||||
|
||||
export function proposal (instanceId: string, api: ApiInterfaceRx): (hash: Hash | Uint8Array | string) => Observable<DeriveCollectiveProposal | null> {
|
||||
return memo(instanceId, collectiveProposal(instanceId, api));
|
||||
return memo(instanceId, collectiveProposal(instanceId, api, 'council'));
|
||||
}
|
||||
|
||||
export function proposals (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveCollectiveProposal[]> {
|
||||
return memo(instanceId, collectiveProposals(instanceId, api));
|
||||
return memo(instanceId, collectiveProposals(instanceId, api, 'council'));
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ function isVoter (value: VoteEntry): value is Voter {
|
||||
}
|
||||
|
||||
function retrieveStakeOf (api: ApiInterfaceRx): Observable<[AccountId, Balance][]> {
|
||||
return (api.query.electionsPhragmen || api.query.elections).stakeOf.entries<Balance, [AccountId]>().pipe(
|
||||
return (api.query.phragmenElection || api.query.electionsPhragmen || api.query.elections).stakeOf.entries<Balance, [AccountId]>().pipe(
|
||||
map((entries) =>
|
||||
entries.map(([{ args: [accountId] }, stake]) => [accountId, stake])
|
||||
)
|
||||
@@ -29,7 +29,7 @@ function retrieveStakeOf (api: ApiInterfaceRx): Observable<[AccountId, Balance][
|
||||
}
|
||||
|
||||
function retrieveVoteOf (api: ApiInterfaceRx): Observable<[AccountId, AccountId[]][]> {
|
||||
return (api.query.electionsPhragmen || api.query.elections).votesOf.entries<Vec<AccountId>, [AccountId]>().pipe(
|
||||
return (api.query.phragmenElection || api.query.electionsPhragmen || api.query.elections).votesOf.entries<Vec<AccountId>, [AccountId]>().pipe(
|
||||
map((entries) =>
|
||||
entries.map(([{ args: [accountId] }, votes]) => [accountId, votes])
|
||||
)
|
||||
@@ -61,7 +61,7 @@ function retrievePrev (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
|
||||
}
|
||||
|
||||
function retrieveCurrent (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
|
||||
const elections = (api.query.electionsPhragmen || api.query.elections);
|
||||
const elections = (api.query.phragmenElection || api.query.electionsPhragmen || api.query.elections);
|
||||
|
||||
return elections.voting.entries<VoteEntry, [AccountId]>().pipe(
|
||||
map((entries): DeriveCouncilVotes =>
|
||||
@@ -77,7 +77,7 @@ function retrieveCurrent (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
|
||||
|
||||
export function votes (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveCouncilVotes> {
|
||||
return memo(instanceId, (): Observable<DeriveCouncilVotes> =>
|
||||
(api.query.electionsPhragmen || api.query.elections).stakeOf
|
||||
(api.query.phragmenElection || api.query.electionsPhragmen || api.query.elections).stakeOf
|
||||
? retrievePrev(api)
|
||||
: retrieveCurrent(api)
|
||||
);
|
||||
|
||||
@@ -42,7 +42,11 @@ function sortAccounts ([, balanceA]: [AccountId, Balance], [, balanceB]: [Accoun
|
||||
}
|
||||
|
||||
function queryElections (api: ApiInterfaceRx): Observable<DeriveElectionsInfo> {
|
||||
const section = api.query.electionsPhragmen ? 'electionsPhragmen' : 'elections';
|
||||
const section = api.query.phragmenElection
|
||||
? 'phragmenElection'
|
||||
: api.query.electionsPhragmen
|
||||
? 'electionsPhragmen'
|
||||
: 'elections';
|
||||
|
||||
return api.queryMulti<[Vec<AccountId>, Vec<Candidate>, Vec<Member>, Vec<Member>]>([
|
||||
api.query.council.members,
|
||||
|
||||
@@ -16,6 +16,7 @@ import * as council from './council';
|
||||
import * as democracy from './democracy';
|
||||
import * as elections from './elections';
|
||||
import * as imOnline from './imOnline';
|
||||
import * as membership from './membership';
|
||||
import * as parachains from './parachains';
|
||||
import * as session from './session';
|
||||
import * as society from './society';
|
||||
@@ -27,7 +28,7 @@ import * as tx from './tx';
|
||||
export { packageInfo } from './packageInfo';
|
||||
export * from './type';
|
||||
|
||||
export const derive = { accounts, balances, bounties, chain, contracts, council, democracy, elections, imOnline, parachains, session, society, staking, technicalCommittee, treasury, tx };
|
||||
export const derive = { accounts, balances, bounties, chain, contracts, council, democracy, elections, imOnline, membership, parachains, session, society, staking, technicalCommittee, treasury, tx };
|
||||
|
||||
type DeriveSection<Section> = {
|
||||
[Method in keyof Section]: Section[Method] extends AnyFunction
|
||||
@@ -47,8 +48,9 @@ const deriveAvail: Record<string, string[]> = {
|
||||
contracts: ['contracts'],
|
||||
council: ['council'],
|
||||
democracy: ['democracy'],
|
||||
elections: ['electionsPhragmen', 'elections'],
|
||||
elections: ['phragmenElection', 'electionsPhragmen', 'elections'],
|
||||
imOnline: ['imOnline'],
|
||||
membership: ['membership'],
|
||||
parachains: ['parachains', 'registrar'],
|
||||
session: ['session'],
|
||||
society: ['society'],
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './proposals';
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveCollectiveProposal } from '../types';
|
||||
|
||||
import { proposals as collectiveProposals } from '../collective';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function proposals (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveCollectiveProposal[]> {
|
||||
return memo(instanceId, collectiveProposals(instanceId, api, 'membership'));
|
||||
}
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api-derive', version: '4.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/api-derive', version: '4.11.2' };
|
||||
|
||||
@@ -13,7 +13,7 @@ import { map } from '@polkadot/x-rxjs/operators';
|
||||
import { memo } from '../util';
|
||||
|
||||
// parse into Indexes
|
||||
function parse ([activeEra, activeEraStart, currentEra, currentIndex, validatorCount]: [EraIndex, Option<Moment>, EraIndex, SessionIndex, u32]): DeriveSessionIndexes {
|
||||
function parse ([currentIndex, activeEra, activeEraStart, currentEra, validatorCount]: [SessionIndex, EraIndex, Option<Moment>, EraIndex, u32]): DeriveSessionIndexes {
|
||||
return {
|
||||
activeEra,
|
||||
activeEraStart,
|
||||
@@ -24,42 +24,57 @@ function parse ([activeEra, activeEraStart, currentEra, currentIndex, validatorC
|
||||
}
|
||||
|
||||
// query based on latest
|
||||
function query (api: ApiInterfaceRx): Observable<DeriveSessionIndexes> {
|
||||
return api.queryMulti<[Option<ActiveEraInfo>, Option<EraIndex>, SessionIndex, u32]>([
|
||||
function queryStaking (api: ApiInterfaceRx): Observable<DeriveSessionIndexes> {
|
||||
return api.queryMulti<[SessionIndex, Option<ActiveEraInfo>, Option<EraIndex>, u32]>([
|
||||
api.query.session.currentIndex,
|
||||
api.query.staking.activeEra,
|
||||
api.query.staking.currentEra,
|
||||
api.query.session.currentIndex,
|
||||
api.query.staking.validatorCount
|
||||
]).pipe(
|
||||
map(([activeOpt, currentEra, currentIndex, validatorCount]): DeriveSessionIndexes => {
|
||||
map(([currentIndex, activeOpt, currentEra, validatorCount]): DeriveSessionIndexes => {
|
||||
const { index, start } = activeOpt.unwrapOrDefault();
|
||||
|
||||
return parse([
|
||||
currentIndex,
|
||||
index,
|
||||
start,
|
||||
currentEra.unwrapOrDefault(),
|
||||
currentIndex,
|
||||
validatorCount
|
||||
]);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// query based on latest
|
||||
function querySession (api: ApiInterfaceRx): Observable<DeriveSessionIndexes> {
|
||||
return api.query.session.currentIndex().pipe(
|
||||
map((currentIndex): DeriveSessionIndexes => parse([
|
||||
currentIndex,
|
||||
api.registry.createType('EraIndex'),
|
||||
api.registry.createType('Option<Moment>'),
|
||||
api.registry.createType('EraIndex'),
|
||||
api.registry.createType('u32')
|
||||
]))
|
||||
);
|
||||
}
|
||||
|
||||
// empty set when none is available
|
||||
function empty (api: ApiInterfaceRx): Observable<DeriveSessionIndexes> {
|
||||
return of(parse([
|
||||
api.registry.createType('SessionIndex', 1),
|
||||
api.registry.createType('EraIndex'),
|
||||
api.registry.createType('Option<Moment>'),
|
||||
api.registry.createType('EraIndex'),
|
||||
api.registry.createType('SessionIndex', 1),
|
||||
api.registry.createType('u32')
|
||||
]));
|
||||
}
|
||||
|
||||
export function indexes (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveSessionIndexes> {
|
||||
return memo(instanceId, (): Observable<DeriveSessionIndexes> =>
|
||||
api.query.session && api.query.staking
|
||||
? query(api)
|
||||
api.query.session
|
||||
? api.query.staking
|
||||
? queryStaking(api)
|
||||
: querySession(api)
|
||||
: empty(api)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,71 +2,31 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { u64 } from '@polkadot/types';
|
||||
import type { SessionIndex } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveSessionIndexes, DeriveSessionInfo } from '../types';
|
||||
import type { DeriveSessionInfo } from '../types';
|
||||
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type ResultType = [boolean, u64, SessionIndex];
|
||||
type Result = [ResultType, DeriveSessionIndexes];
|
||||
|
||||
function createDerive (api: ApiInterfaceRx, [[hasBabe, epochDuration, sessionsPerEra], { activeEra, activeEraStart, currentEra, currentIndex, validatorCount }]: Result): DeriveSessionInfo {
|
||||
return {
|
||||
activeEra,
|
||||
activeEraStart,
|
||||
currentEra,
|
||||
currentIndex,
|
||||
eraLength: api.registry.createType('BlockNumber', sessionsPerEra.mul(epochDuration)),
|
||||
isEpoch: hasBabe,
|
||||
sessionLength: epochDuration,
|
||||
sessionsPerEra,
|
||||
validatorCount
|
||||
};
|
||||
}
|
||||
|
||||
function queryAura (api: ApiInterfaceRx): Observable<DeriveSessionInfo> {
|
||||
return api.derive.session.indexes().pipe(
|
||||
map((indexes): DeriveSessionInfo =>
|
||||
createDerive(api, [
|
||||
[
|
||||
false,
|
||||
api.registry.createType('u64', 1),
|
||||
// we may have aura without staking (permissioned)
|
||||
api.consts.staking?.sessionsPerEra || api.registry.createType('SessionIndex', 1)
|
||||
],
|
||||
indexes
|
||||
])
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function queryBabe (api: ApiInterfaceRx): Observable<DeriveSessionInfo> {
|
||||
return api.derive.session.indexes().pipe(
|
||||
map((indexes) =>
|
||||
createDerive(api, [
|
||||
[
|
||||
true,
|
||||
api.consts.babe.epochDuration,
|
||||
// we may have babe without staking (permissioned)
|
||||
api.consts.staking?.sessionsPerEra || api.registry.createType('SessionIndex', 1)
|
||||
],
|
||||
indexes
|
||||
])
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Retrieves all the session and era query and calculates specific values on it as the length of the session and eras
|
||||
*/
|
||||
export function info (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveSessionInfo> {
|
||||
return memo(instanceId, (): Observable<DeriveSessionInfo> =>
|
||||
api.consts.babe
|
||||
? queryBabe(api)
|
||||
: queryAura(api)
|
||||
api.derive.session.indexes().pipe(
|
||||
map((indexes) => {
|
||||
const sessionLength = api.consts?.babe?.epochDuration || api.registry.createType('u64', 1);
|
||||
const sessionsPerEra = api.consts?.staking?.sessionsPerEra || api.registry.createType('SessionIndex', 1);
|
||||
|
||||
return {
|
||||
...indexes,
|
||||
eraLength: api.registry.createType('BlockNumber', sessionsPerEra.mul(sessionLength)),
|
||||
isEpoch: !!api.query.babe,
|
||||
sessionLength,
|
||||
sessionsPerEra
|
||||
};
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ function queryBabe (api: ApiInterfaceRx): Observable<[DeriveSessionInfo, ResultS
|
||||
combineLatest([
|
||||
of(info),
|
||||
// we may have no staking, but have babe (permissioned)
|
||||
api.query.staking
|
||||
api.query.staking?.erasStartSessionIndex
|
||||
? api.queryMulti<ResultSlots>([
|
||||
api.query.babe.currentSlot,
|
||||
api.query.babe.epochIndex,
|
||||
@@ -69,7 +69,7 @@ function queryBabe (api: ApiInterfaceRx): Observable<[DeriveSessionInfo, ResultS
|
||||
*/
|
||||
export function progress (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveSessionProgress> {
|
||||
return memo(instanceId, (): Observable<DeriveSessionProgress> =>
|
||||
api.consts.babe
|
||||
api.query.babe
|
||||
? queryBabe(api).pipe(
|
||||
map(([info, slots]: [DeriveSessionInfo, ResultSlotsFlat]): DeriveSessionProgress =>
|
||||
createDerive(api, info, slots)
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { bool, Option, Vec } from '@polkadot/types';
|
||||
import type { AccountId, Balance, BlockNumber, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { AccountId } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveSocietyMember } from '../types';
|
||||
|
||||
@@ -12,28 +10,13 @@ import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type Result = [Vec<ITuple<[BlockNumber, Balance]>>, StrikeCount, Option<SocietyVote>, bool, Option<VouchingStatus>];
|
||||
|
||||
/**
|
||||
* @description Get the member info for a society
|
||||
*/
|
||||
export function member (instanceId: string, api: ApiInterfaceRx): (accountId: AccountId) => Observable<DeriveSocietyMember> {
|
||||
return memo(instanceId, (accountId: AccountId): Observable<DeriveSocietyMember> =>
|
||||
api.queryMulti<Result>([
|
||||
[api.query.society.payouts, accountId],
|
||||
[api.query.society.strikes, accountId],
|
||||
[api.query.society.defenderVotes, accountId],
|
||||
[api.query.society.suspendedMembers, accountId],
|
||||
[api.query.society.vouching, accountId]
|
||||
]).pipe(
|
||||
map(([payouts, strikes, defenderVotes, suspended, vouching]: Result): DeriveSocietyMember => ({
|
||||
accountId,
|
||||
isSuspended: suspended.isTrue,
|
||||
payouts,
|
||||
strikes,
|
||||
vote: defenderVotes.unwrapOr(undefined),
|
||||
vouching: vouching.unwrapOr(undefined)
|
||||
}))
|
||||
api.derive.society._members([accountId]).pipe(
|
||||
map(([result]) => result)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,28 +2,51 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AccountId } from '@polkadot/types/interfaces';
|
||||
import type { bool, Option, Vec } from '@polkadot/types';
|
||||
import type { AccountId, Balance, BlockNumber, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveSocietyMember } from '../types';
|
||||
|
||||
import { combineLatest } from '@polkadot/x-rxjs';
|
||||
import { switchMap } from '@polkadot/x-rxjs/operators';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type Result = [AccountId[], Vec<ITuple<[BlockNumber, Balance]>>[], StrikeCount[], Option<SocietyVote>[], bool[], Option<VouchingStatus>[]];
|
||||
|
||||
export function _members (instanceId: string, api: ApiInterfaceRx): (accountIds: AccountId[]) => Observable<DeriveSocietyMember[]> {
|
||||
return memo(instanceId, (accountIds: AccountId[]): Observable<DeriveSocietyMember[]> =>
|
||||
combineLatest<Result>([
|
||||
of(accountIds),
|
||||
api.query.society.payouts.multi(accountIds),
|
||||
api.query.society.strikes.multi(accountIds),
|
||||
api.query.society.defenderVotes.multi(accountIds),
|
||||
api.query.society.suspendedMembers.multi(accountIds),
|
||||
api.query.society.vouching.multi(accountIds)
|
||||
]).pipe(
|
||||
map(([accountIds, payouts, strikes, defenderVotes, suspended, vouching]) =>
|
||||
accountIds.map((accountId, index) => ({
|
||||
accountId,
|
||||
isDefenderVoter: defenderVotes[index].isSome,
|
||||
isSuspended: suspended[index].isTrue,
|
||||
payouts: payouts[index],
|
||||
strikes: strikes[index],
|
||||
vote: defenderVotes[index].unwrapOr(undefined),
|
||||
vouching: vouching[index].unwrapOr(undefined)
|
||||
}))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Get the member info for a society
|
||||
*/
|
||||
export function members (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveSocietyMember[]> {
|
||||
return memo(instanceId, (): Observable<DeriveSocietyMember[]> =>
|
||||
api.query.society.members<AccountId[]>().pipe(
|
||||
switchMap((members): Observable<DeriveSocietyMember[]> =>
|
||||
combineLatest(
|
||||
members.map((accountId): Observable<DeriveSocietyMember> =>
|
||||
api.derive.society.member(accountId)
|
||||
)
|
||||
)
|
||||
)
|
||||
switchMap((members) => api.derive.society._members(members))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ function parseRewards (api: ApiInterfaceRx, stashId: AccountId, [erasPoints, era
|
||||
Object.entries(eraValidators).forEach(([validatorId, exposure]): void => {
|
||||
const valPoints = allValPoints[validatorId] || BN_ZERO;
|
||||
const valComm = allValPrefs[validatorId]?.commission.unwrap() || BN_ZERO;
|
||||
const expTotal = exposure.total.unwrap();
|
||||
const expTotal = exposure.total?.unwrap() || BN_ZERO;
|
||||
let avail = BN_ZERO;
|
||||
let value: BN | undefined;
|
||||
|
||||
|
||||
@@ -61,7 +61,9 @@ function retrieveProposals (api: ApiInterfaceRx, proposalCount: ProposalIndex, a
|
||||
|
||||
return combineLatest([
|
||||
api.query.treasury.proposals.multi<Option<TreasuryProposal>>(allIds),
|
||||
api.derive.council.proposals()
|
||||
api.derive.council
|
||||
? api.derive.council.proposals()
|
||||
: of([] as DeriveCollectiveProposal[])
|
||||
]).pipe(
|
||||
map(([allProposals, councilProposals]: [Option<TreasuryProposal>[], DeriveCollectiveProposal[]]): DeriveTreasuryProposals =>
|
||||
parseResult(api, { allIds, allProposals, approvalIds, councilProposals, proposalCount })
|
||||
|
||||
@@ -2,44 +2,41 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { AccountId, Header } from '@polkadot/types/interfaces';
|
||||
import type { Constructor, Registry } from '@polkadot/types/types';
|
||||
|
||||
import { Struct } from '@polkadot/types';
|
||||
import runtimeTypes from '@polkadot/types/interfaces/runtime/definitions';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { HeaderExtended } from './types';
|
||||
|
||||
import { extractAuthor } from './util';
|
||||
|
||||
// We can ignore the properties, added via Struct.with
|
||||
const _Header = Struct.with(runtimeTypes.types.Header as any) as Constructor<Header>;
|
||||
export function createHeaderExtended (registry: Registry, header?: Header, validators?: AccountId[]): HeaderExtended {
|
||||
// an instance of the base extrinsic for us to extend
|
||||
const HeaderBase = registry.createClass('Header');
|
||||
|
||||
/**
|
||||
* @name HeaderExtended
|
||||
* @description
|
||||
* A [[Block]] header with an additional `author` field that indicates the block author
|
||||
*/
|
||||
export class HeaderExtended extends _Header {
|
||||
readonly #author?: AccountId;
|
||||
readonly #validators?: AccountId[];
|
||||
class Implementation extends HeaderBase implements HeaderExtended {
|
||||
readonly #author?: AccountId;
|
||||
readonly #validators?: AccountId[];
|
||||
|
||||
constructor (registry: Registry, header?: Header, validators?: AccountId[]) {
|
||||
super(registry, header);
|
||||
constructor (registry: Registry, header?: Header, validators?: AccountId[]) {
|
||||
super(registry, header);
|
||||
|
||||
this.#author = extractAuthor(this.digest, validators);
|
||||
this.#validators = validators;
|
||||
this.createdAtHash = header?.createdAtHash;
|
||||
this.#author = extractAuthor(this.digest, validators);
|
||||
this.#validators = validators;
|
||||
this.createdAtHash = header?.createdAtHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Convenience method, returns the author for the block
|
||||
*/
|
||||
public get author (): AccountId | undefined {
|
||||
return this.#author;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Convenience method, returns the validators for the block
|
||||
*/
|
||||
public get validators (): AccountId[] | undefined {
|
||||
return this.#validators;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Convenience method, returns the author for the block
|
||||
*/
|
||||
public get author (): AccountId | undefined {
|
||||
return this.#author;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Convenience method, returns the validators for the block
|
||||
*/
|
||||
public get validators (): AccountId[] | undefined {
|
||||
return this.#validators;
|
||||
}
|
||||
return new Implementation(registry, header, validators);
|
||||
}
|
||||
|
||||
@@ -1,24 +1,12 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { AccountId, DispatchError, DispatchInfo, Event, EventRecord, Extrinsic, SignedBlock } from '@polkadot/types/interfaces';
|
||||
import type { Constructor, Registry } from '@polkadot/types/types';
|
||||
|
||||
import { Struct } from '@polkadot/types';
|
||||
import runtimeTypes from '@polkadot/types/interfaces/runtime/definitions';
|
||||
import type { AccountId, DispatchError, DispatchInfo, EventRecord, Extrinsic, SignedBlock } from '@polkadot/types/interfaces';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { SignedBlockExtended, TxWithEvent } from './types';
|
||||
|
||||
import { extractAuthor } from './util';
|
||||
|
||||
// We can ignore the properties, added via Struct.with
|
||||
const _SignedBlock = Struct.with(runtimeTypes.types.SignedBlock as any) as Constructor<SignedBlock>;
|
||||
|
||||
interface TxWithEvent {
|
||||
dispatchError?: DispatchError;
|
||||
dispatchInfo?: DispatchInfo;
|
||||
events: Event[];
|
||||
extrinsic: Extrinsic;
|
||||
}
|
||||
|
||||
function mapExtrinsics (extrinsics: Extrinsic[], records: EventRecord[]): TxWithEvent[] {
|
||||
return extrinsics.map((extrinsic, index): TxWithEvent => {
|
||||
let dispatchError: DispatchError | undefined;
|
||||
@@ -43,43 +31,45 @@ function mapExtrinsics (extrinsics: Extrinsic[], records: EventRecord[]): TxWith
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @name SignedBlockExtended
|
||||
* @description
|
||||
* A [[Block]] header with an additional `author` field that indicates the block author
|
||||
*/
|
||||
export class SignedBlockExtended extends _SignedBlock {
|
||||
readonly #author?: AccountId;
|
||||
readonly #events: EventRecord[];
|
||||
readonly #extrinsics: TxWithEvent[];
|
||||
export function createSignedBlockExtended (registry: Registry, block?: SignedBlock, events?: EventRecord[], validators?: AccountId[]): SignedBlockExtended {
|
||||
// an instance of the base extrinsic for us to extend
|
||||
const SignedBlockBase = registry.createClass('SignedBlock');
|
||||
|
||||
constructor (registry: Registry, block?: SignedBlock, events?: EventRecord[], validators?: AccountId[]) {
|
||||
super(registry, block);
|
||||
class Implementation extends SignedBlockBase implements SignedBlockExtended {
|
||||
readonly #author?: AccountId;
|
||||
readonly #events: EventRecord[];
|
||||
readonly #extrinsics: TxWithEvent[];
|
||||
|
||||
this.#author = extractAuthor(this.block.header.digest, validators);
|
||||
this.#events = events || ([] as EventRecord[]);
|
||||
this.#extrinsics = mapExtrinsics(this.block.extrinsics, this.#events);
|
||||
this.createdAtHash = block?.createdAtHash;
|
||||
constructor (registry: Registry, block?: SignedBlock, events?: EventRecord[], validators?: AccountId[]) {
|
||||
super(registry, block);
|
||||
|
||||
this.#author = extractAuthor(this.block.header.digest, validators);
|
||||
this.#events = events || ([] as EventRecord[]);
|
||||
this.#extrinsics = mapExtrinsics(this.block.extrinsics, this.#events);
|
||||
this.createdAtHash = block?.createdAtHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Convenience method, returns the author for the block
|
||||
*/
|
||||
public get author (): AccountId | undefined {
|
||||
return this.#author;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Convenience method, returns the events associated with the block
|
||||
*/
|
||||
public get events (): EventRecord[] {
|
||||
return this.#events;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the extrinsics and their events, mapped
|
||||
*/
|
||||
public get extrinsics (): TxWithEvent[] {
|
||||
return this.#extrinsics;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Convenience method, returns the author for the block
|
||||
*/
|
||||
public get author (): AccountId | undefined {
|
||||
return this.#author;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Convenience method, returns the events associated with the block
|
||||
*/
|
||||
public get events (): EventRecord[] {
|
||||
return this.#events;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the extrinsics and their events, mapped
|
||||
*/
|
||||
public get extrinsics (): TxWithEvent[] {
|
||||
return this.#extrinsics;
|
||||
}
|
||||
return new Implementation(registry, block, events, validators);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { HeaderExtended } from './HeaderExtended';
|
||||
export { SignedBlockExtended } from './SignedBlockExtended';
|
||||
export { createHeaderExtended } from './HeaderExtended';
|
||||
export { createSignedBlockExtended } from './SignedBlockExtended';
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { AccountId, DispatchError, DispatchInfo, Event, EventRecord, Extrinsic, Header, SignedBlock } from '@polkadot/types/interfaces';
|
||||
|
||||
export interface HeaderExtended extends Header {
|
||||
readonly author: AccountId | undefined;
|
||||
readonly validators: AccountId[] | undefined;
|
||||
}
|
||||
|
||||
export interface SignedBlockExtended extends SignedBlock {
|
||||
readonly author: AccountId | undefined;
|
||||
readonly events: EventRecord[];
|
||||
readonly extrinsics: TxWithEvent[];
|
||||
}
|
||||
|
||||
export interface TxWithEvent {
|
||||
dispatchError?: DispatchError;
|
||||
dispatchInfo?: DispatchInfo;
|
||||
events: Event[];
|
||||
extrinsic: Extrinsic;
|
||||
}
|
||||
@@ -12,6 +12,7 @@ export * from './elections/types';
|
||||
export * from './parachains/types';
|
||||
export * from './session/types';
|
||||
export * from './staking/types';
|
||||
export * from './type/types';
|
||||
|
||||
export interface DeriveBalancesAccountData {
|
||||
freeBalance: Balance;
|
||||
@@ -107,6 +108,7 @@ export interface DeriveSocietyCandidate {
|
||||
|
||||
export interface DeriveSocietyMember {
|
||||
accountId: AccountId;
|
||||
isDefenderVoter: boolean;
|
||||
isSuspended: boolean;
|
||||
payouts: [BlockNumber, Balance][];
|
||||
strikes: StrikeCount;
|
||||
|
||||
+15
-12
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api",
|
||||
"version": "4.1.1",
|
||||
"version": "4.11.2",
|
||||
"type": "module",
|
||||
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
|
||||
"main": "index.js",
|
||||
@@ -8,6 +8,9 @@
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
@@ -16,17 +19,17 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.13.9",
|
||||
"@polkadot/api-derive": "4.1.1",
|
||||
"@polkadot/keyring": "^6.0.5",
|
||||
"@polkadot/metadata": "4.1.1",
|
||||
"@polkadot/rpc-core": "4.1.1",
|
||||
"@polkadot/rpc-provider": "4.1.1",
|
||||
"@polkadot/types": "4.1.1",
|
||||
"@polkadot/types-known": "4.1.1",
|
||||
"@polkadot/util": "^6.0.5",
|
||||
"@polkadot/util-crypto": "^6.0.5",
|
||||
"@polkadot/x-rxjs": "^6.0.5",
|
||||
"@babel/runtime": "^7.14.0",
|
||||
"@polkadot/api-derive": "4.11.2",
|
||||
"@polkadot/keyring": "^6.5.1",
|
||||
"@polkadot/metadata": "4.11.2",
|
||||
"@polkadot/rpc-core": "4.11.2",
|
||||
"@polkadot/rpc-provider": "4.11.2",
|
||||
"@polkadot/types": "4.11.2",
|
||||
"@polkadot/types-known": "4.11.2",
|
||||
"@polkadot/util": "^6.5.1",
|
||||
"@polkadot/util-crypto": "^6.5.1",
|
||||
"@polkadot/x-rxjs": "^6.5.1",
|
||||
"bn.js": "^4.11.9",
|
||||
"eventemitter3": "^4.0.7"
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
|
||||
import type { Vec, u16, u32, u64, u8 } from '@polkadot/types';
|
||||
import type { Codec } from '@polkadot/types/types';
|
||||
import type { Balance, BalanceOf, BlockNumber, LockIdentifier, ModuleId, Moment, Perbill, Percent, Permill, RuntimeDbWeight, Weight } from '@polkadot/types/interfaces/runtime';
|
||||
import type { Schedule } from '@polkadot/types/interfaces/contracts';
|
||||
import type { Balance, BalanceOf, BlockNumber, LockIdentifier, Moment, PalletId, Perbill, Percent, Permill, RuntimeDbWeight, Weight } from '@polkadot/types/interfaces/runtime';
|
||||
import type { SessionIndex } from '@polkadot/types/interfaces/session';
|
||||
import type { EraIndex } from '@polkadot/types/interfaces/staking';
|
||||
import type { RuntimeVersion } from '@polkadot/types/interfaces/state';
|
||||
@@ -14,13 +15,10 @@ import type { ApiTypes } from '@polkadot/api/types';
|
||||
declare module '@polkadot/api/types/consts' {
|
||||
export interface AugmentedConsts<ApiType> {
|
||||
babe: {
|
||||
[key: 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.
|
||||
* NOTE: Currently it is not possible to change the epoch duration
|
||||
* after the chain has started. Attempting to do so will brick block
|
||||
* production.
|
||||
* The amount of time, in slots, that each epoch should last.
|
||||
* NOTE: Currently it is not possible to change the epoch duration after
|
||||
* the chain has started. Attempting to do so will brick block production.
|
||||
**/
|
||||
epochDuration: u64 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
@@ -31,16 +29,22 @@ declare module '@polkadot/api/types/consts' {
|
||||
* the probability of a slot being empty).
|
||||
**/
|
||||
expectedBlockTime: Moment & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
balances: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* The minimum amount required to keep an account open.
|
||||
**/
|
||||
existentialDeposit: Balance & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
bounties: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* Percentage of the curator fee that will be reserved upfront as deposit for bounty curator.
|
||||
**/
|
||||
@@ -69,9 +73,12 @@ declare module '@polkadot/api/types/consts' {
|
||||
* Maximum acceptable reason length.
|
||||
**/
|
||||
maximumReasonLength: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
contracts: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* The maximum number of tries that can be queued for deletion.
|
||||
**/
|
||||
@@ -106,20 +113,6 @@ declare module '@polkadot/api/types/consts' {
|
||||
* It works the same as [`Self::DepositPerStorageByte`] but for storage items.
|
||||
**/
|
||||
depositPerStorageItem: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum length of a contract code in bytes. This limit applies to the instrumented
|
||||
* version of the code. Therefore `instantiate_with_code` can fail even when supplying
|
||||
* a wasm binary below this maximum size.
|
||||
**/
|
||||
maxCodeSize: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum nesting level of a call/instantiate stack.
|
||||
**/
|
||||
maxDepth: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum size of a storage value and event payload in bytes.
|
||||
**/
|
||||
maxValueSize: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The fraction of the deposit that should be used as rent per block.
|
||||
*
|
||||
@@ -128,6 +121,10 @@ declare module '@polkadot/api/types/consts' {
|
||||
* This determines how high this rent payment is per block as a fraction of the deposit.
|
||||
**/
|
||||
rentFraction: Perbill & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Cost schedule and limits.
|
||||
**/
|
||||
schedule: Schedule & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Number of block delay an extrinsic claim surcharge has.
|
||||
*
|
||||
@@ -144,9 +141,12 @@ declare module '@polkadot/api/types/consts' {
|
||||
* The minimum amount required to generate a tombstone.
|
||||
**/
|
||||
tombstoneDeposit: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
democracy: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* Period in blocks where an external proposal may not be re-submitted after being vetoed.
|
||||
**/
|
||||
@@ -183,9 +183,19 @@ declare module '@polkadot/api/types/consts' {
|
||||
* How often (in blocks) to check for new votes.
|
||||
**/
|
||||
votingPeriod: BlockNumber & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
electionProviderMultiPhase: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* The repeat threshold of the offchain worker.
|
||||
*
|
||||
* For example, if it is 5, that means that at least 5 blocks will elapse between attempts
|
||||
* to submit the worker's solution.
|
||||
**/
|
||||
offchainRepeat: BlockNumber & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Duration of the signed phase.
|
||||
**/
|
||||
@@ -199,19 +209,51 @@ declare module '@polkadot/api/types/consts' {
|
||||
* Duration of the unsigned phase.
|
||||
**/
|
||||
unsignedPhase: BlockNumber & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
elections: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* How much should be locked up in order to submit one's candidacy.
|
||||
**/
|
||||
candidacyBond: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Number of members to elect.
|
||||
**/
|
||||
desiredMembers: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Number of runners_up to keep.
|
||||
**/
|
||||
desiredRunnersUp: u32 & AugmentedConst<ApiType>;
|
||||
moduleId: LockIdentifier & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Identifier for the elections-phragmen pallet's lock
|
||||
**/
|
||||
palletId: LockIdentifier & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* How long each seat is kept. This defines the next block number at which an election
|
||||
* round will happen. If set to zero, no elections are ever triggered and the module will
|
||||
* be in passive mode.
|
||||
**/
|
||||
termDuration: BlockNumber & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Base deposit associated with voting.
|
||||
*
|
||||
* This should be sensibly high to economically ensure the pallet cannot be attacked by
|
||||
* creating a gigantic number of votes.
|
||||
**/
|
||||
votingBondBase: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The amount of bond that need to be locked for each vote (32 bytes).
|
||||
**/
|
||||
votingBondFactor: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
gilt: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* Portion of the queue which is free from ordering and just a FIFO.
|
||||
*
|
||||
@@ -255,11 +297,14 @@ declare module '@polkadot/api/types/consts' {
|
||||
* this value multiplied by `Period`.
|
||||
**/
|
||||
queueCount: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
identity: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* The amount held on deposit for a registered identity.
|
||||
* The amount held on deposit for a registered identity
|
||||
**/
|
||||
basicDeposit: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
@@ -286,21 +331,36 @@ declare module '@polkadot/api/types/consts' {
|
||||
* another trie item whose value is the size of an account ID plus 32 bytes.
|
||||
**/
|
||||
subAccountDeposit: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
indices: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* The deposit needed for reserving an index.
|
||||
**/
|
||||
deposit: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
lottery: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* The max number of calls available in a single lottery.
|
||||
**/
|
||||
maxCalls: u32 & AugmentedConst<ApiType>;
|
||||
moduleId: ModuleId & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The Lottery's pallet id
|
||||
**/
|
||||
palletId: PalletId & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
multisig: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* The base amount of currency needed to reserve for creating a multisig execution or to store
|
||||
* a dispatch call for later.
|
||||
@@ -314,19 +374,27 @@ declare module '@polkadot/api/types/consts' {
|
||||
* The maximum amount of signatories allowed for a given multisig.
|
||||
**/
|
||||
maxSignatories: u16 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
proxy: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* `AnnouncementDepositBase` metadata shadow.
|
||||
* The base amount of currency needed to reserve for creating an announcement.
|
||||
*
|
||||
* This is held when a new storage item holding a `Balance` is created (typically 16 bytes).
|
||||
**/
|
||||
announcementDepositBase: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* `AnnouncementDepositFactor` metadata shadow.
|
||||
* The amount of currency needed per announcement made.
|
||||
*
|
||||
* This is held for adding an `AccountId`, `Hash` and `BlockNumber` (typically 68 bytes)
|
||||
* into a pre-existing storage value.
|
||||
**/
|
||||
announcementDepositFactor: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* `MaxPending` metadata shadow.
|
||||
* The maximum amount of time-delayed announcements that are allowed to be pending.
|
||||
**/
|
||||
maxPending: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
@@ -335,21 +403,36 @@ declare module '@polkadot/api/types/consts' {
|
||||
maxProxies: u16 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The base amount of currency needed to reserve for creating a proxy.
|
||||
*
|
||||
* This is held for an additional storage item whose value size is
|
||||
* `sizeof(Balance)` bytes and whose key size is `sizeof(AccountId)` bytes.
|
||||
**/
|
||||
proxyDepositBase: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The amount of currency needed per proxy added.
|
||||
*
|
||||
* This is held for adding 32 bytes plus an instance of `ProxyType` more into a pre-existing
|
||||
* storage value. Thus, when configuring `ProxyDepositFactor` one should take into account
|
||||
* `32 + proxy_type.encode().len()` bytes of data.
|
||||
**/
|
||||
proxyDepositFactor: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
recovery: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* The base amount of currency needed to reserve for creating a recovery configuration.
|
||||
*
|
||||
* This is held for an additional storage item whose value size is
|
||||
* `2 + sizeof(BlockNumber, Balance)` bytes.
|
||||
**/
|
||||
configDepositBase: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The amount of currency needed per additional user when creating a recovery configuration.
|
||||
*
|
||||
* This is held for adding `sizeof(AccountId)` bytes more into a pre-existing storage value.
|
||||
**/
|
||||
friendDepositFactor: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
@@ -358,11 +441,20 @@ declare module '@polkadot/api/types/consts' {
|
||||
maxFriends: u16 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The base amount of currency needed to reserve for starting a recovery.
|
||||
*
|
||||
* This is primarily held for deterring malicious recovery attempts, and should
|
||||
* have a value large enough that a bad actor would choose not to place this
|
||||
* deposit. It also acts to fund additional storage item whose value size is
|
||||
* `sizeof(BlockNumber, Balance + T * AccountId)` bytes. Where T is a configurable
|
||||
* threshold.
|
||||
**/
|
||||
recoveryDeposit: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
society: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* The minimum amount of a deposit required for a bid to be made.
|
||||
**/
|
||||
@@ -371,6 +463,10 @@ declare module '@polkadot/api/types/consts' {
|
||||
* The number of blocks between membership challenges.
|
||||
**/
|
||||
challengePeriod: BlockNumber & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Maximum candidate intake per round.
|
||||
**/
|
||||
maxCandidateIntake: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The number of times a member may vote the wrong way (or not at all, when they are a skeptic)
|
||||
* before they become suspended.
|
||||
@@ -379,7 +475,7 @@ declare module '@polkadot/api/types/consts' {
|
||||
/**
|
||||
* The societies's module id
|
||||
**/
|
||||
moduleId: ModuleId & AugmentedConst<ApiType>;
|
||||
palletId: PalletId & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The amount of incentive paid within each period. Doesn't include VoterTip.
|
||||
**/
|
||||
@@ -393,29 +489,20 @@ declare module '@polkadot/api/types/consts' {
|
||||
* doesn't vote or someone votes in the wrong way.
|
||||
**/
|
||||
wrongSideDeduction: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
staking: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* Number of eras that staked funds must remain bonded for.
|
||||
**/
|
||||
bondingDuration: EraIndex & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The number of blocks before the end of the era from which election submissions are allowed.
|
||||
*
|
||||
* Setting this to zero will disable the offchain compute and only on-chain seq-phragmen will
|
||||
* be used.
|
||||
*
|
||||
* This is bounded by being within the last session. Hence, setting it to a value more than the
|
||||
* length of a session will be pointless.
|
||||
* Maximum number of nominations per nominator.
|
||||
**/
|
||||
electionLookahead: BlockNumber & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Maximum number of balancing iterations to run in the offchain submission.
|
||||
*
|
||||
* If set to 0, balance_solution will not be executed at all.
|
||||
**/
|
||||
maxIterations: u32 & AugmentedConst<ApiType>;
|
||||
maxNominations: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum number of nominators rewarded for each validator.
|
||||
*
|
||||
@@ -423,10 +510,6 @@ declare module '@polkadot/api/types/consts' {
|
||||
* their reward. This used to limit the i/o cost for the nominator payout.
|
||||
**/
|
||||
maxNominatorRewardedPerValidator: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The threshold of improvement that should be provided for a new solution to be accepted.
|
||||
**/
|
||||
minSolutionScoreBump: Perbill & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Number of sessions per era.
|
||||
**/
|
||||
@@ -439,9 +522,12 @@ declare module '@polkadot/api/types/consts' {
|
||||
* intervention.
|
||||
**/
|
||||
slashDeferDuration: EraIndex & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
system: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* Maximum number of block number to block hash mappings to keep (oldest pruned first).
|
||||
**/
|
||||
@@ -470,9 +556,12 @@ declare module '@polkadot/api/types/consts' {
|
||||
* Get the chain's current version.
|
||||
**/
|
||||
version: RuntimeVersion & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
timestamp: {
|
||||
[key: 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
|
||||
@@ -480,9 +569,12 @@ declare module '@polkadot/api/types/consts' {
|
||||
* period on default settings.
|
||||
**/
|
||||
minimumPeriod: Moment & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
tips: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* The amount held on deposit per byte within the tip report reason.
|
||||
**/
|
||||
@@ -503,9 +595,12 @@ declare module '@polkadot/api/types/consts' {
|
||||
* The amount held on deposit for placing a tip report.
|
||||
**/
|
||||
tipReportDepositBase: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
transactionPayment: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* The fee to be paid for making a transaction; the per-byte portion.
|
||||
**/
|
||||
@@ -514,9 +609,12 @@ declare module '@polkadot/api/types/consts' {
|
||||
* The polynomial that is applied in order to derive fee from weight.
|
||||
**/
|
||||
weightToFee: Vec<WeightToFeeCoefficient> & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
treasury: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* Percentage of spare funds (if any) that are burnt per spend period.
|
||||
**/
|
||||
@@ -524,7 +622,7 @@ declare module '@polkadot/api/types/consts' {
|
||||
/**
|
||||
* The treasury's module id, used for deriving its sovereign account ID.
|
||||
**/
|
||||
moduleId: ModuleId & AugmentedConst<ApiType>;
|
||||
palletId: PalletId & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* 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.
|
||||
@@ -538,13 +636,20 @@ declare module '@polkadot/api/types/consts' {
|
||||
* Period between successive spends.
|
||||
**/
|
||||
spendPeriod: BlockNumber & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
vesting: {
|
||||
[key: string]: Codec;
|
||||
/**
|
||||
* The minimum amount to be transferred to create a new vesting schedule.
|
||||
* The minimum amount transferred to call `vested_transfer`.
|
||||
**/
|
||||
minVestedTransfer: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+214
-105
@@ -6,7 +6,6 @@ import type { ApiTypes } from '@polkadot/api/types';
|
||||
declare module '@polkadot/api/types/errors' {
|
||||
export interface AugmentedErrors<ApiType> {
|
||||
assets: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Invalid metadata given.
|
||||
**/
|
||||
@@ -43,10 +42,6 @@ declare module '@polkadot/api/types/errors' {
|
||||
* No provider reference exists to allow a non-zero balance of a non-self-sufficient asset.
|
||||
**/
|
||||
NoProvider: AugmentedError<ApiType>;
|
||||
/**
|
||||
* A mint operation lead to an overflow.
|
||||
**/
|
||||
Overflow: AugmentedError<ApiType>;
|
||||
/**
|
||||
* No approval exists that would allow the transfer.
|
||||
**/
|
||||
@@ -59,9 +54,12 @@ declare module '@polkadot/api/types/errors' {
|
||||
* The source account would not survive the transfer and it needs to stay alive.
|
||||
**/
|
||||
WouldDie: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
authorship: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The uncle is genesis.
|
||||
**/
|
||||
@@ -90,9 +88,30 @@ declare module '@polkadot/api/types/errors' {
|
||||
* Uncles already set in the block.
|
||||
**/
|
||||
UnclesAlreadySet: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
babe: {
|
||||
/**
|
||||
* A given equivocation report is valid but already previously reported.
|
||||
**/
|
||||
DuplicateOffenceReport: AugmentedError<ApiType>;
|
||||
/**
|
||||
* An equivocation proof provided as part of an equivocation report is invalid.
|
||||
**/
|
||||
InvalidEquivocationProof: AugmentedError<ApiType>;
|
||||
/**
|
||||
* A key ownership proof provided as part of an equivocation report is invalid.
|
||||
**/
|
||||
InvalidKeyOwnershipProof: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
balances: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Beneficiary account must pre-exist
|
||||
**/
|
||||
@@ -117,17 +136,16 @@ declare module '@polkadot/api/types/errors' {
|
||||
* Account liquidity restrictions prevent withdrawal
|
||||
**/
|
||||
LiquidityRestrictions: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Got an overflow after adding
|
||||
**/
|
||||
Overflow: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Vesting balance too high to send value
|
||||
**/
|
||||
VestingBalance: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
bounties: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Proposer's balance is too low.
|
||||
**/
|
||||
@@ -165,9 +183,12 @@ declare module '@polkadot/api/types/errors' {
|
||||
* The bounty status is unexpected.
|
||||
**/
|
||||
UnexpectedStatus: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
contracts: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Performing the requested transfer would have brought the contract below
|
||||
* the subsistence threshold. No transfer is allowed to do this in order to allow
|
||||
@@ -195,6 +216,10 @@ declare module '@polkadot/api/types/errors' {
|
||||
* Contract trapped during execution.
|
||||
**/
|
||||
ContractTrapped: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The debug message specified to `seal_debug_message` does contain invalid UTF-8.
|
||||
**/
|
||||
DebugMessageInvalidUTF8: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Input passed to a contract API function failed to decode as expected type.
|
||||
**/
|
||||
@@ -293,6 +318,12 @@ declare module '@polkadot/api/types/errors' {
|
||||
* when number of storage items is too large.
|
||||
**/
|
||||
StorageExhausted: AugmentedError<ApiType>;
|
||||
/**
|
||||
* A contract self destructed in its constructor.
|
||||
*
|
||||
* This can be triggered by a call to `seal_terminate` or `seal_restore_to`.
|
||||
**/
|
||||
TerminatedInConstructor: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The amount of topics passed to `seal_deposit_events` exceeds the limit.
|
||||
**/
|
||||
@@ -307,9 +338,12 @@ declare module '@polkadot/api/types/errors' {
|
||||
* The size defined in `T::MaxValueSize` was exceeded.
|
||||
**/
|
||||
ValueTooLarge: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
council: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Members are already initialized!
|
||||
**/
|
||||
@@ -350,9 +384,12 @@ declare module '@polkadot/api/types/errors' {
|
||||
* The given weight bound for the proposal was too low.
|
||||
**/
|
||||
WrongProposalWeight: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
democracy: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Cannot cancel the same proposal twice
|
||||
**/
|
||||
@@ -445,10 +482,6 @@ declare module '@polkadot/api/types/errors' {
|
||||
* The given account did not vote on the referendum.
|
||||
**/
|
||||
NotVoter: AugmentedError<ApiType>;
|
||||
/**
|
||||
* An unexpected integer overflow occurred.
|
||||
**/
|
||||
Overflow: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Invalid preimage
|
||||
**/
|
||||
@@ -477,10 +510,6 @@ declare module '@polkadot/api/types/errors' {
|
||||
* Maximum number of proposals reached.
|
||||
**/
|
||||
TooManyProposals: AugmentedError<ApiType>;
|
||||
/**
|
||||
* An unexpected integer underflow occurred.
|
||||
**/
|
||||
Underflow: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Value too low
|
||||
**/
|
||||
@@ -494,9 +523,16 @@ declare module '@polkadot/api/types/errors' {
|
||||
* Invalid upper bound.
|
||||
**/
|
||||
WrongUpperBound: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
electionProviderMultiPhase: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* OCW submitted solution for wrong round
|
||||
**/
|
||||
OcwCallWrongEra: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Submission was too early.
|
||||
**/
|
||||
@@ -509,9 +545,12 @@ declare module '@polkadot/api/types/errors' {
|
||||
* Wrong number of winners presented.
|
||||
**/
|
||||
PreDispatchWrongWinnerCount: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
elections: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Duplicated candidate submission.
|
||||
**/
|
||||
@@ -580,9 +619,12 @@ declare module '@polkadot/api/types/errors' {
|
||||
* Cannot vote when no candidates or members exist.
|
||||
**/
|
||||
UnableToVote: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
gilt: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The amount of the bid is less than the minimum allowed.
|
||||
**/
|
||||
@@ -616,9 +658,12 @@ declare module '@polkadot/api/types/errors' {
|
||||
* Gilt index is unknown.
|
||||
**/
|
||||
Unknown: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
grandpa: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Attempt to signal GRANDPA change with one already pending.
|
||||
**/
|
||||
@@ -649,9 +694,12 @@ declare module '@polkadot/api/types/errors' {
|
||||
* Cannot signal forced change so soon after last.
|
||||
**/
|
||||
TooSoon: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
identity: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Account ID is already named.
|
||||
**/
|
||||
@@ -716,9 +764,12 @@ declare module '@polkadot/api/types/errors' {
|
||||
* Too many subs-accounts.
|
||||
**/
|
||||
TooManySubAccounts: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
imOnline: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Duplicated heartbeat.
|
||||
**/
|
||||
@@ -727,9 +778,72 @@ declare module '@polkadot/api/types/errors' {
|
||||
* Non existent public key.
|
||||
**/
|
||||
InvalidKey: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
indices: {
|
||||
/**
|
||||
* The index was not available.
|
||||
**/
|
||||
InUse: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The index was not already assigned.
|
||||
**/
|
||||
NotAssigned: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The index is assigned to another account.
|
||||
**/
|
||||
NotOwner: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The source and destination accounts are identical.
|
||||
**/
|
||||
NotTransfer: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The index is permanent and may not be freed/changed.
|
||||
**/
|
||||
Permanent: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
lottery: {
|
||||
/**
|
||||
* A lottery has already ended.
|
||||
**/
|
||||
AlreadyEnded: AugmentedError<ApiType>;
|
||||
/**
|
||||
* You are already participating in the lottery with this call.
|
||||
**/
|
||||
AlreadyParticipating: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Failed to encode calls
|
||||
**/
|
||||
EncodingFailed: AugmentedError<ApiType>;
|
||||
/**
|
||||
* A lottery is already in progress.
|
||||
**/
|
||||
InProgress: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The call is not valid for an open lottery.
|
||||
**/
|
||||
InvalidCall: AugmentedError<ApiType>;
|
||||
/**
|
||||
* A lottery has not been configured.
|
||||
**/
|
||||
NotConfigured: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Too many calls for a single lottery.
|
||||
**/
|
||||
TooManyCalls: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
multisig: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Call is already approved by this signatory.
|
||||
**/
|
||||
@@ -786,9 +900,12 @@ declare module '@polkadot/api/types/errors' {
|
||||
* A different timepoint was given to the multisig operation that is underway.
|
||||
**/
|
||||
WrongTimepoint: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
proxy: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Account is already a proxy.
|
||||
**/
|
||||
@@ -821,9 +938,12 @@ declare module '@polkadot/api/types/errors' {
|
||||
* A call which is incompatible with the proxy type's filter was attempted.
|
||||
**/
|
||||
Unproxyable: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
recovery: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* This account is already set up for recovery
|
||||
**/
|
||||
@@ -876,10 +996,6 @@ declare module '@polkadot/api/types/errors' {
|
||||
* A recovery process has not started for this rescuer
|
||||
**/
|
||||
NotStarted: AugmentedError<ApiType>;
|
||||
/**
|
||||
* There was an overflow in a calculation
|
||||
**/
|
||||
Overflow: AugmentedError<ApiType>;
|
||||
/**
|
||||
* There are still active recovery attempts that need to be closed
|
||||
**/
|
||||
@@ -892,9 +1008,12 @@ declare module '@polkadot/api/types/errors' {
|
||||
* Threshold must be greater than zero
|
||||
**/
|
||||
ZeroThreshold: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
scheduler: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Failed to schedule a call
|
||||
**/
|
||||
@@ -911,9 +1030,12 @@ declare module '@polkadot/api/types/errors' {
|
||||
* Given target block number is in the past.
|
||||
**/
|
||||
TargetBlockNumberInPast: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
session: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Registered duplicate key.
|
||||
**/
|
||||
@@ -934,9 +1056,12 @@ declare module '@polkadot/api/types/errors' {
|
||||
* No keys are associated with this account.
|
||||
**/
|
||||
NoKeys: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
society: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* User has already made a bid.
|
||||
**/
|
||||
@@ -1009,9 +1134,12 @@ declare module '@polkadot/api/types/errors' {
|
||||
* User is suspended.
|
||||
**/
|
||||
Suspended: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
staking: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Stash is already bonded.
|
||||
**/
|
||||
@@ -1032,10 +1160,6 @@ declare module '@polkadot/api/types/errors' {
|
||||
* A nomination target was supplied that was blocked or otherwise not a validator.
|
||||
**/
|
||||
BadTarget: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The call is not allowed at the given time due to restrictions of election period.
|
||||
**/
|
||||
CallNotAllowed: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Duplicate index.
|
||||
**/
|
||||
@@ -1092,75 +1216,26 @@ declare module '@polkadot/api/types/errors' {
|
||||
* Can not rebond without unlocking chunks.
|
||||
**/
|
||||
NoUnlockChunk: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Error while building the assignment type from the compact. This can happen if an index
|
||||
* is invalid, or if the weights _overflow_.
|
||||
**/
|
||||
OffchainElectionBogusCompact: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The submitted result has unknown edges that are not among the presented winners.
|
||||
**/
|
||||
OffchainElectionBogusEdge: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The election size is invalid.
|
||||
**/
|
||||
OffchainElectionBogusElectionSize: AugmentedError<ApiType>;
|
||||
/**
|
||||
* One of the submitted nominators has an edge to which they have not voted on chain.
|
||||
**/
|
||||
OffchainElectionBogusNomination: AugmentedError<ApiType>;
|
||||
/**
|
||||
* One of the submitted nominators is not an active nominator on chain.
|
||||
**/
|
||||
OffchainElectionBogusNominator: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The claimed score does not match with the one computed from the data.
|
||||
**/
|
||||
OffchainElectionBogusScore: AugmentedError<ApiType>;
|
||||
/**
|
||||
* A self vote must only be originated from a validator to ONLY themselves.
|
||||
**/
|
||||
OffchainElectionBogusSelfVote: AugmentedError<ApiType>;
|
||||
/**
|
||||
* One of the submitted winners is not an active candidate on chain (index is out of range
|
||||
* in snapshot).
|
||||
**/
|
||||
OffchainElectionBogusWinner: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Incorrect number of winners were presented.
|
||||
**/
|
||||
OffchainElectionBogusWinnerCount: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The submitted result is received out of the open window.
|
||||
**/
|
||||
OffchainElectionEarlySubmission: AugmentedError<ApiType>;
|
||||
/**
|
||||
* One of the submitted nominators has an edge which is submitted before the last non-zero
|
||||
* slash of the target.
|
||||
**/
|
||||
OffchainElectionSlashedNomination: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The submitted result is not as good as the one stored on chain.
|
||||
**/
|
||||
OffchainElectionWeakSubmission: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The snapshot data of the current window is missing.
|
||||
**/
|
||||
SnapshotUnavailable: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Too many nomination targets supplied.
|
||||
**/
|
||||
TooManyTargets: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
sudo: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Sender must be the Sudo account
|
||||
**/
|
||||
RequireSudo: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
system: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Failed to extract the runtime version from the new runtime.
|
||||
*
|
||||
@@ -1185,9 +1260,12 @@ declare module '@polkadot/api/types/errors' {
|
||||
* and the new runtime.
|
||||
**/
|
||||
SpecVersionNeedsToIncrease: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
technicalCommittee: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Members are already initialized!
|
||||
**/
|
||||
@@ -1228,9 +1306,26 @@ declare module '@polkadot/api/types/errors' {
|
||||
* The given weight bound for the proposal was too low.
|
||||
**/
|
||||
WrongProposalWeight: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
technicalMembership: {
|
||||
/**
|
||||
* Already a member.
|
||||
**/
|
||||
AlreadyMember: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Not a member.
|
||||
**/
|
||||
NotMember: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
tips: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The tip was already found/started.
|
||||
**/
|
||||
@@ -1255,9 +1350,12 @@ declare module '@polkadot/api/types/errors' {
|
||||
* The tip hash is unknown.
|
||||
**/
|
||||
UnknownTip: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
treasury: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Proposer's balance is too low.
|
||||
**/
|
||||
@@ -1266,9 +1364,16 @@ declare module '@polkadot/api/types/errors' {
|
||||
* No proposal or bounty at that index.
|
||||
**/
|
||||
InvalidIndex: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Too many approvals in the queue.
|
||||
**/
|
||||
TooManyApprovals: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
vesting: {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Amount being transferred is too low to create a vesting schedule.
|
||||
**/
|
||||
@@ -1281,6 +1386,10 @@ declare module '@polkadot/api/types/errors' {
|
||||
* The account given is not vesting.
|
||||
**/
|
||||
NotVesting: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import type { ApiTypes } from '@polkadot/api/types';
|
||||
declare module '@polkadot/api/types/events' {
|
||||
export interface AugmentedEvents<ApiType> {
|
||||
assets: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* An approval for account `delegate` was cancelled by `owner`.
|
||||
* \[id, owner, delegate\]
|
||||
@@ -105,9 +104,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* \[id, owner, delegate, destination\]
|
||||
**/
|
||||
TransferredApproved: AugmentedEvent<ApiType, [AssetId, AccountId, AccountId, AccountId, TAssetBalance]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
balances: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A balance was set by root. \[who, free, reserved\]
|
||||
**/
|
||||
@@ -143,9 +145,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* Some balance was unreserved (moved from reserved to free). \[who, value\]
|
||||
**/
|
||||
Unreserved: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
bounties: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A bounty is awarded to a beneficiary. \[index, beneficiary\]
|
||||
**/
|
||||
@@ -174,9 +179,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* A bounty proposal was rejected; funds were slashed. \[index, bond\]
|
||||
**/
|
||||
BountyRejected: AugmentedEvent<ApiType, [BountyIndex, Balance]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
contracts: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A code with the specified hash was removed.
|
||||
* \[code_hash\]
|
||||
@@ -243,9 +251,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* this event is by calling `seal_terminate`.
|
||||
**/
|
||||
Terminated: AugmentedEvent<ApiType, [AccountId, AccountId]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
council: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A motion was approved by the required threshold.
|
||||
* \[proposal_hash\]
|
||||
@@ -283,9 +294,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* \[account, proposal_hash, voted, yes, no\]
|
||||
**/
|
||||
Voted: AugmentedEvent<ApiType, [AccountId, Hash, bool, MemberCount, MemberCount]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
democracy: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A proposal \[hash\] has been blacklisted permanently.
|
||||
**/
|
||||
@@ -362,9 +376,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* An external proposal has been vetoed. \[who, proposal_hash, until\]
|
||||
**/
|
||||
Vetoed: AugmentedEvent<ApiType, [AccountId, Hash, BlockNumber]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
electionProviderMultiPhase: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* The election has been finalized, with `Some` of the given computation, or else if the
|
||||
* election failed, `None`.
|
||||
@@ -393,9 +410,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* The unsigned phase of the given round has started.
|
||||
**/
|
||||
UnsignedPhaseStarted: AugmentedEvent<ApiType, [u32]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
elections: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A \[candidate\] was slashed by \[amount\] due to failing to obtain a seat as member or
|
||||
* runner-up.
|
||||
@@ -418,10 +438,11 @@ declare module '@polkadot/api/types/events' {
|
||||
**/
|
||||
MemberKicked: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* A new term with \[new_members\]. This indicates that enough candidates existed to run the
|
||||
* election, not that enough have has been elected. The inner value must be examined for
|
||||
* this purpose. A `NewTerm(\[\])` indicates that some candidates got their bond slashed and
|
||||
* none were elected, whilst `EmptyTerm` means that no candidates existed to begin with.
|
||||
* A new term with \[new_members\]. This indicates that enough candidates existed to run
|
||||
* the election, not that enough have has been elected. The inner value must be examined
|
||||
* for this purpose. A `NewTerm(\[\])` indicates that some candidates got their bond
|
||||
* slashed and none were elected, whilst `EmptyTerm` means that no candidates existed to
|
||||
* begin with.
|
||||
**/
|
||||
NewTerm: AugmentedEvent<ApiType, [Vec<ITuple<[AccountId, Balance]>>]>;
|
||||
/**
|
||||
@@ -432,9 +453,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* A \[seat holder\] was slashed by \[amount\] by being forcefully removed from the set.
|
||||
**/
|
||||
SeatHolderSlashed: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
gilt: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A bid was successfully placed.
|
||||
* \[ who, amount, duration \]
|
||||
@@ -455,9 +479,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* \[ index, who, original_amount, additional_amount \]
|
||||
**/
|
||||
GiltThawed: AugmentedEvent<ApiType, [ActiveIndex, AccountId, BalanceOf, BalanceOf]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
grandpa: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* New authority set has been applied. \[authority_set\]
|
||||
**/
|
||||
@@ -470,9 +497,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* Current authority set has been resumed.
|
||||
**/
|
||||
Resumed: AugmentedEvent<ApiType, []>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
identity: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A name was cleared, and the given balance returned. \[who, deposit\]
|
||||
**/
|
||||
@@ -515,9 +545,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* main identity account to the sub-identity account. \[sub, main, deposit\]
|
||||
**/
|
||||
SubIdentityRevoked: AugmentedEvent<ApiType, [AccountId, AccountId, Balance]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
imOnline: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* At the end of the session, no offence was committed.
|
||||
**/
|
||||
@@ -530,9 +563,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* At the end of the session, at least one validator was found to be \[offline\].
|
||||
**/
|
||||
SomeOffline: AugmentedEvent<ApiType, [Vec<IdentificationTuple>]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
indices: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A account index was assigned. \[index, who\]
|
||||
**/
|
||||
@@ -545,9 +581,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* A account index has been frozen to its current account ID. \[index, who\]
|
||||
**/
|
||||
IndexFrozen: AugmentedEvent<ApiType, [AccountIndex, AccountId]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
lottery: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A new set of calls have been set!
|
||||
**/
|
||||
@@ -564,9 +603,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* A winner has been chosen!
|
||||
**/
|
||||
Winner: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
multisig: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A multisig operation has been approved by someone.
|
||||
* \[approving, timepoint, multisig, call_hash\]
|
||||
@@ -584,19 +626,24 @@ declare module '@polkadot/api/types/events' {
|
||||
* A new multisig operation has begun. \[approving, multisig, call_hash\]
|
||||
**/
|
||||
NewMultisig: AugmentedEvent<ApiType, [AccountId, AccountId, CallHash]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
offences: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* 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. last
|
||||
* element indicates of the offence was applied (true) or queued (false)
|
||||
* \[kind, timeslot, applied\].
|
||||
* (kind-specific) time slot. This event is not deposited for duplicate slashes.
|
||||
* \[kind, timeslot\].
|
||||
**/
|
||||
Offence: AugmentedEvent<ApiType, [Kind, OpaqueTimeSlot, bool]>;
|
||||
Offence: AugmentedEvent<ApiType, [Kind, OpaqueTimeSlot]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
proxy: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* An announcement was placed to make a call in the future. \[real, proxy, call_hash\]
|
||||
**/
|
||||
@@ -610,9 +657,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* A proxy was executed correctly, with the given \[result\].
|
||||
**/
|
||||
ProxyExecuted: AugmentedEvent<ApiType, [DispatchResult]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
recovery: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* Lost account has been successfully recovered by rescuer account.
|
||||
* \[lost, rescuer\]
|
||||
@@ -641,9 +691,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* \[lost, rescuer, sender\]
|
||||
**/
|
||||
RecoveryVouched: AugmentedEvent<ApiType, [AccountId, AccountId, AccountId]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
scheduler: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* Canceled some task. \[when, index\]
|
||||
**/
|
||||
@@ -656,17 +709,23 @@ declare module '@polkadot/api/types/events' {
|
||||
* Scheduled some task. \[when, index\]
|
||||
**/
|
||||
Scheduled: AugmentedEvent<ApiType, [BlockNumber, u32]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
session: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* New session has happened. Note that the argument is the \[session_index\], not the block
|
||||
* number as the type might suggest.
|
||||
**/
|
||||
NewSession: AugmentedEvent<ApiType, [SessionIndex]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
society: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A \[candidate\] was dropped (due to an excess of bids in the system).
|
||||
**/
|
||||
@@ -734,9 +793,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* their offer is the second. The vouching party is the third. \[candidate_id, offer, vouching\]
|
||||
**/
|
||||
Vouch: AugmentedEvent<ApiType, [AccountId, Balance, AccountId]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
staking: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* An account has bonded this amount. \[stash, amount\]
|
||||
*
|
||||
@@ -769,13 +831,9 @@ declare module '@polkadot/api/types/events' {
|
||||
**/
|
||||
Slash: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
/**
|
||||
* A new solution for the upcoming election has been stored. \[compute\]
|
||||
* A new set of stakers was elected.
|
||||
**/
|
||||
SolutionStored: AugmentedEvent<ApiType, [ElectionCompute]>;
|
||||
/**
|
||||
* A new set of stakers was elected with the given \[compute\].
|
||||
**/
|
||||
StakingElection: AugmentedEvent<ApiType, [ElectionCompute]>;
|
||||
StakingElection: AugmentedEvent<ApiType, []>;
|
||||
/**
|
||||
* An account has unbonded this amount. \[stash, amount\]
|
||||
**/
|
||||
@@ -785,9 +843,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* from the unlocking queue. \[stash, amount\]
|
||||
**/
|
||||
Withdrawn: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
sudo: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* The \[sudoer\] just switched identity; the old key is supplied.
|
||||
**/
|
||||
@@ -800,9 +861,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* A sudo just took place. \[result\]
|
||||
**/
|
||||
SudoAsDone: AugmentedEvent<ApiType, [DispatchResult]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
system: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* `:code` was updated.
|
||||
**/
|
||||
@@ -827,9 +891,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* On on-chain remark happened. \[origin, remark_hash\]
|
||||
**/
|
||||
Remarked: AugmentedEvent<ApiType, [AccountId, Hash]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
technicalCommittee: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A motion was approved by the required threshold.
|
||||
* \[proposal_hash\]
|
||||
@@ -867,9 +934,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* \[account, proposal_hash, voted, yes, no\]
|
||||
**/
|
||||
Voted: AugmentedEvent<ApiType, [AccountId, Hash, bool, MemberCount, MemberCount]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
technicalMembership: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* Phantom member, never used.
|
||||
**/
|
||||
@@ -894,9 +964,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* Two members were swapped; see the transaction for who.
|
||||
**/
|
||||
MembersSwapped: AugmentedEvent<ApiType, []>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
tips: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A new tip suggestion has been opened. \[tip_hash\]
|
||||
**/
|
||||
@@ -917,9 +990,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* A tip suggestion has been slashed. \[tip_hash, finder, deposit\]
|
||||
**/
|
||||
TipSlashed: AugmentedEvent<ApiType, [Hash, AccountId, Balance]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
treasury: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* Some funds have been allocated. \[proposal_index, award, beneficiary\]
|
||||
**/
|
||||
@@ -949,9 +1025,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* We have ended a spend period and will now allocate funds. \[budget_remaining\]
|
||||
**/
|
||||
Spending: AugmentedEvent<ApiType, [Balance]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
utility: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* Batch of dispatches completed fully with no error.
|
||||
**/
|
||||
@@ -961,9 +1040,12 @@ declare module '@polkadot/api/types/events' {
|
||||
* well as the error. \[index, error\]
|
||||
**/
|
||||
BatchInterrupted: AugmentedEvent<ApiType, [u32, DispatchError]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
vesting: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* An \[account\] has become fully vested. No further vesting can happen.
|
||||
**/
|
||||
@@ -974,6 +1056,10 @@ declare module '@polkadot/api/types/events' {
|
||||
* \[account, unvested\]
|
||||
**/
|
||||
VestingUpdated: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+159
-104
@@ -3,13 +3,13 @@
|
||||
|
||||
import type { Bytes, Data, Option, U8aFixed, Vec, bool, u32, u64 } from '@polkadot/types';
|
||||
import type { AnyNumber, ITuple, Observable } from '@polkadot/types/types';
|
||||
import type { AssetApproval, AssetApprovalKey, AssetBalance, AssetDetails, AssetMetadata } from '@polkadot/types/interfaces/assets';
|
||||
import type { AssetApproval, AssetBalance, AssetDetails, AssetMetadata } from '@polkadot/types/interfaces/assets';
|
||||
import type { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
|
||||
import type { BabeAuthorityWeight, BabeEpochConfiguration, MaybeRandomness, NextConfigDescriptor, Randomness } from '@polkadot/types/interfaces/babe';
|
||||
import type { AccountData, BalanceLock } from '@polkadot/types/interfaces/balances';
|
||||
import type { ProposalIndex, Votes } from '@polkadot/types/interfaces/collective';
|
||||
import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
|
||||
import type { CodeHash, ContractInfo, DeletedContract, PrefabWasmModule, Schedule } from '@polkadot/types/interfaces/contracts';
|
||||
import type { CodeHash, ContractInfo, DeletedContract, PrefabWasmModule } from '@polkadot/types/interfaces/contracts';
|
||||
import type { PreimageStatus, PropIndex, Proposal, ReferendumIndex, ReferendumInfo, Voting } from '@polkadot/types/interfaces/democracy';
|
||||
import type { VoteThreshold } from '@polkadot/types/interfaces/elections';
|
||||
import type { ActiveGilt, ActiveGiltsTotal, ActiveIndex, GiltBid } from '@polkadot/types/interfaces/gilt';
|
||||
@@ -17,14 +17,14 @@ import type { SetId, StoredPendingChange, StoredState } from '@polkadot/types/in
|
||||
import type { RegistrarInfo, Registration } from '@polkadot/types/interfaces/identity';
|
||||
import type { AuthIndex } from '@polkadot/types/interfaces/imOnline';
|
||||
import type { CallIndex, LotteryConfig } from '@polkadot/types/interfaces/lottery';
|
||||
import type { DeferredOffenceOf, Kind, OffenceDetails, OpaqueTimeSlot, ReportIdOf } from '@polkadot/types/interfaces/offences';
|
||||
import type { Kind, OffenceDetails, OpaqueTimeSlot, ReportIdOf } from '@polkadot/types/interfaces/offences';
|
||||
import type { ProxyAnnouncement, ProxyDefinition } from '@polkadot/types/interfaces/proxy';
|
||||
import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
|
||||
import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber, Hash, KeyTypeId, Moment, OpaqueCall, Perbill, Releases, Slot, ValidatorId } from '@polkadot/types/interfaces/runtime';
|
||||
import type { Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler';
|
||||
import type { Keys, SessionIndex } from '@polkadot/types/interfaces/session';
|
||||
import type { Bid, BidKind, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
|
||||
import type { ActiveEraInfo, ElectionPhase, ElectionResult, ElectionScore, ElectionStatus, EraIndex, EraRewardPoints, Exposure, Forcing, Nominations, ReadySolution, RewardDestination, RoundSnapshot, SeatHolder, SlashingSpans, SolutionOrSnapshotSize, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs, Voter } from '@polkadot/types/interfaces/staking';
|
||||
import type { ActiveEraInfo, ElectionPhase, EraIndex, EraRewardPoints, Exposure, Forcing, Nominations, ReadySolution, RewardDestination, RoundSnapshot, SeatHolder, SlashingSpans, SolutionOrSnapshotSize, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs, Voter } from '@polkadot/types/interfaces/staking';
|
||||
import type { AccountInfo, ConsumedWeight, DigestOf, EventIndex, EventRecord, LastRuntimeUpgradeInfo, Phase } from '@polkadot/types/interfaces/system';
|
||||
import type { Bounty, BountyIndex, OpenTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
|
||||
import type { Multiplier } from '@polkadot/types/interfaces/txpayment';
|
||||
@@ -35,16 +35,16 @@ import type { ApiTypes } from '@polkadot/api/types';
|
||||
declare module '@polkadot/api/types/storage' {
|
||||
export interface AugmentedQueries<ApiType> {
|
||||
assets: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The number of units of assets held by any given account.
|
||||
**/
|
||||
account: AugmentedQueryDoubleMap<ApiType, (key1: AssetId | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<AssetBalance>, [AssetId, AccountId]> & QueryableStorageEntry<ApiType, [AssetId, AccountId]>;
|
||||
account: AugmentedQuery<ApiType, (arg1: AssetId | AnyNumber | Uint8Array, arg2: AccountId | string | Uint8Array) => Observable<AssetBalance>, [AssetId, AccountId]> & QueryableStorageEntry<ApiType, [AssetId, AccountId]>;
|
||||
/**
|
||||
* Approved balance transfers. First balance is the amount approved for transfer. Second
|
||||
* is the amount of `T::Currency` reserved for storing this.
|
||||
* First key is the asset ID, second key is the owner and third key is the delegate.
|
||||
**/
|
||||
approvals: AugmentedQueryDoubleMap<ApiType, (key1: AssetId | AnyNumber | Uint8Array, key2: AssetApprovalKey | { owner?: any; delegate?: any } | string | Uint8Array) => Observable<Option<AssetApproval>>, [AssetId, AssetApprovalKey]> & QueryableStorageEntry<ApiType, [AssetId, AssetApprovalKey]>;
|
||||
approvals: AugmentedQuery<ApiType, (arg1: AssetId | AnyNumber | Uint8Array, arg2: AccountId | string | Uint8Array, arg3: AccountId | string | Uint8Array) => Observable<Option<AssetApproval>>, [AssetId, AccountId, AccountId]> & QueryableStorageEntry<ApiType, [AssetId, AccountId, AccountId]>;
|
||||
/**
|
||||
* Details of an asset.
|
||||
**/
|
||||
@@ -53,9 +53,12 @@ declare module '@polkadot/api/types/storage' {
|
||||
* Metadata of an asset.
|
||||
**/
|
||||
metadata: AugmentedQuery<ApiType, (arg: AssetId | AnyNumber | Uint8Array) => Observable<AssetMetadata>, [AssetId]> & QueryableStorageEntry<ApiType, [AssetId]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
authorship: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Author of current block.
|
||||
**/
|
||||
@@ -68,9 +71,12 @@ declare module '@polkadot/api/types/storage' {
|
||||
* Uncles
|
||||
**/
|
||||
uncles: AugmentedQuery<ApiType, () => Observable<Vec<UncleEntryItem>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
babe: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Current epoch authorities.
|
||||
**/
|
||||
@@ -165,9 +171,12 @@ declare module '@polkadot/api/types/storage' {
|
||||
* TWOX-NOTE: `SegmentIndex` is an increasing integer, so this is okay.
|
||||
**/
|
||||
underConstruction: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Vec<Randomness>>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
balances: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The balance of an account.
|
||||
*
|
||||
@@ -189,9 +198,12 @@ declare module '@polkadot/api/types/storage' {
|
||||
* The total units issued in the system.
|
||||
**/
|
||||
totalIssuance: AugmentedQuery<ApiType, () => Observable<Balance>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
bounties: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Bounties that have been made.
|
||||
**/
|
||||
@@ -208,9 +220,12 @@ declare module '@polkadot/api/types/storage' {
|
||||
* The description of each bounty.
|
||||
**/
|
||||
bountyDescriptions: AugmentedQuery<ApiType, (arg: BountyIndex | AnyNumber | Uint8Array) => Observable<Option<Bytes>>, [BountyIndex]> & QueryableStorageEntry<ApiType, [BountyIndex]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
contracts: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The subtrie counter.
|
||||
**/
|
||||
@@ -225,10 +240,6 @@ declare module '@polkadot/api/types/storage' {
|
||||
* TWOX-NOTE: SAFE since `AccountId` is a secure hash.
|
||||
**/
|
||||
contractInfoOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<ContractInfo>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
||||
/**
|
||||
* Current cost schedule for contracts.
|
||||
**/
|
||||
currentSchedule: AugmentedQuery<ApiType, () => Observable<Schedule>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Evicted contracts that await child trie deletion.
|
||||
*
|
||||
@@ -240,9 +251,12 @@ declare module '@polkadot/api/types/storage' {
|
||||
* A mapping from an original code hash to the original code, untouched by instrumentation.
|
||||
**/
|
||||
pristineCode: AugmentedQuery<ApiType, (arg: CodeHash | string | Uint8Array) => Observable<Option<Bytes>>, [CodeHash]> & QueryableStorageEntry<ApiType, [CodeHash]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
council: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The current members of the collective. This is stored sorted (just by value).
|
||||
**/
|
||||
@@ -267,9 +281,12 @@ declare module '@polkadot/api/types/storage' {
|
||||
* Votes on a given proposal, if it is ongoing.
|
||||
**/
|
||||
voting: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Option<Votes>>, [Hash]> & QueryableStorageEntry<ApiType, [Hash]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
democracy: {
|
||||
[key: string]: 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.
|
||||
@@ -345,9 +362,12 @@ declare module '@polkadot/api/types/storage' {
|
||||
* TWOX-NOTE: SAFE as `AccountId`s are crypto hashes anyway.
|
||||
**/
|
||||
votingOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Voting>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
electionProviderMultiPhase: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Current phase.
|
||||
**/
|
||||
@@ -383,9 +403,12 @@ declare module '@polkadot/api/types/storage' {
|
||||
* Only exists when [`Snapshot`] is present.
|
||||
**/
|
||||
snapshotMetadata: AugmentedQuery<ApiType, () => Observable<Option<SolutionOrSnapshotSize>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
elections: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The present candidate list. A current member or runner-up can never enter this vector
|
||||
* and is always implicitly assumed to be a candidate.
|
||||
@@ -418,9 +441,12 @@ declare module '@polkadot/api/types/storage' {
|
||||
* TWOX-NOTE: SAFE as `AccountId` is a crypto hash.
|
||||
**/
|
||||
voting: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Voter>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
gilt: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The currently active gilts, indexed according to the order of creation.
|
||||
**/
|
||||
@@ -441,9 +467,12 @@ declare module '@polkadot/api/types/storage' {
|
||||
* whose duration is one `Period` would be storage `0`.
|
||||
**/
|
||||
queueTotals: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[u32, BalanceOf]>>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
grandpa: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The number of changes (both in terms of keys and underlying economic responsibilities)
|
||||
* in the "set" of Grandpa validators from genesis.
|
||||
@@ -472,9 +501,12 @@ declare module '@polkadot/api/types/storage' {
|
||||
* State of the current authority set.
|
||||
**/
|
||||
state: AugmentedQuery<ApiType, () => Observable<StoredState>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
identity: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Information that is pertinent to identify the entity behind an account.
|
||||
*
|
||||
@@ -501,14 +533,17 @@ declare module '@polkadot/api/types/storage' {
|
||||
* 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]>>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
imOnline: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* For each session index, we keep a mapping of `ValidatorId<T>` to the
|
||||
* number of blocks authored by the given authority.
|
||||
**/
|
||||
authoredBlocks: AugmentedQueryDoubleMap<ApiType, (key1: SessionIndex | AnyNumber | Uint8Array, key2: ValidatorId | string | Uint8Array) => Observable<u32>, [SessionIndex, ValidatorId]> & QueryableStorageEntry<ApiType, [SessionIndex, ValidatorId]>;
|
||||
authoredBlocks: AugmentedQuery<ApiType, (arg1: SessionIndex | AnyNumber | Uint8Array, arg2: ValidatorId | string | Uint8Array) => Observable<u32>, [SessionIndex, ValidatorId]> & QueryableStorageEntry<ApiType, [SessionIndex, ValidatorId]>;
|
||||
/**
|
||||
* The block number after which it's ok to send heartbeats in the current
|
||||
* session.
|
||||
@@ -531,17 +566,23 @@ declare module '@polkadot/api/types/storage' {
|
||||
* 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, AuthIndex]> & QueryableStorageEntry<ApiType, [SessionIndex, AuthIndex]>;
|
||||
receivedHeartbeats: AugmentedQuery<ApiType, (arg1: SessionIndex | AnyNumber | Uint8Array, arg2: AuthIndex | AnyNumber | Uint8Array) => Observable<Option<Bytes>>, [SessionIndex, AuthIndex]> & QueryableStorageEntry<ApiType, [SessionIndex, AuthIndex]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
indices: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The lookup from index to account.
|
||||
**/
|
||||
accounts: AugmentedQuery<ApiType, (arg: AccountIndex | AnyNumber | Uint8Array) => Observable<Option<ITuple<[AccountId, BalanceOf, bool]>>>, [AccountIndex]> & QueryableStorageEntry<ApiType, [AccountIndex]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
lottery: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The calls stored in this pallet to be used in an active lottery if configured
|
||||
* by `Config::ValidateCall`.
|
||||
@@ -567,9 +608,12 @@ declare module '@polkadot/api/types/storage' {
|
||||
* Total number of tickets sold.
|
||||
**/
|
||||
ticketsCount: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
mmr: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Hashes of the nodes in the MMR.
|
||||
*
|
||||
@@ -585,26 +629,27 @@ declare module '@polkadot/api/types/storage' {
|
||||
* Latest MMR Root hash.
|
||||
**/
|
||||
rootHash: AugmentedQuery<ApiType, () => Observable<Hash>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
multisig: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
calls: AugmentedQuery<ApiType, (arg: U8aFixed | string | Uint8Array) => Observable<Option<ITuple<[OpaqueCall, AccountId, BalanceOf]>>>, [U8aFixed]> & QueryableStorageEntry<ApiType, [U8aFixed]>;
|
||||
/**
|
||||
* The set of open multisig operations.
|
||||
**/
|
||||
multisigs: AugmentedQueryDoubleMap<ApiType, (key1: AccountId | string | Uint8Array, key2: U8aFixed | string | Uint8Array) => Observable<Option<Multisig>>, [AccountId, U8aFixed]> & QueryableStorageEntry<ApiType, [AccountId, U8aFixed]>;
|
||||
multisigs: AugmentedQuery<ApiType, (arg1: AccountId | string | Uint8Array, arg2: U8aFixed | string | Uint8Array) => Observable<Option<Multisig>>, [AccountId, U8aFixed]> & QueryableStorageEntry<ApiType, [AccountId, U8aFixed]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
offences: {
|
||||
[key: string]: 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, OpaqueTimeSlot]> & QueryableStorageEntry<ApiType, [Kind, OpaqueTimeSlot]>;
|
||||
/**
|
||||
* Deferred reports that have been rejected by the offence handler and need to be submitted
|
||||
* at a later time.
|
||||
**/
|
||||
deferredOffences: AugmentedQuery<ApiType, () => Observable<Vec<DeferredOffenceOf>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
concurrentReportsIndex: AugmentedQuery<ApiType, (arg1: Kind | string | Uint8Array, arg2: OpaqueTimeSlot | string | Uint8Array) => Observable<Vec<ReportIdOf>>, [Kind, OpaqueTimeSlot]> & QueryableStorageEntry<ApiType, [Kind, OpaqueTimeSlot]>;
|
||||
/**
|
||||
* The primary structure that holds all offence records keyed by report identifiers.
|
||||
**/
|
||||
@@ -618,9 +663,12 @@ declare module '@polkadot/api/types/storage' {
|
||||
* different types are not supported at the moment so we are doing the manual serialization.
|
||||
**/
|
||||
reportsByKindIndex: AugmentedQuery<ApiType, (arg: Kind | string | Uint8Array) => Observable<Bytes>, [Kind]> & QueryableStorageEntry<ApiType, [Kind]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
proxy: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The announcements made by the proxy (key).
|
||||
**/
|
||||
@@ -630,25 +678,31 @@ declare module '@polkadot/api/types/storage' {
|
||||
* which are being delegated to, together with the amount held on deposit.
|
||||
**/
|
||||
proxies: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ITuple<[Vec<ProxyDefinition>, BalanceOf]>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
randomnessCollectiveFlip: {
|
||||
[key: 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, []>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
recovery: {
|
||||
[key: string]: 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, AccountId]> & QueryableStorageEntry<ApiType, [AccountId, AccountId]>;
|
||||
activeRecoveries: AugmentedQuery<ApiType, (arg1: AccountId | string | Uint8Array, arg2: AccountId | string | Uint8Array) => Observable<Option<ActiveRecovery>>, [AccountId, AccountId]> & QueryableStorageEntry<ApiType, [AccountId, AccountId]>;
|
||||
/**
|
||||
* The list of allowed proxy accounts.
|
||||
*
|
||||
@@ -659,9 +713,12 @@ declare module '@polkadot/api/types/storage' {
|
||||
* The set of recoverable accounts and their recovery configuration.
|
||||
**/
|
||||
recoverable: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<RecoveryConfig>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
scheduler: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Items to be executed, indexed by the block number that they should be executed on.
|
||||
**/
|
||||
@@ -676,9 +733,12 @@ declare module '@polkadot/api/types/storage' {
|
||||
* New networks start with last version.
|
||||
**/
|
||||
storageVersion: AugmentedQuery<ApiType, () => Observable<Releases>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
session: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Current index of the session.
|
||||
**/
|
||||
@@ -711,9 +771,12 @@ declare module '@polkadot/api/types/storage' {
|
||||
* The current set of validators.
|
||||
**/
|
||||
validators: AugmentedQuery<ApiType, () => Observable<Vec<ValidatorId>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
society: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The current bids, stored ordered by the value of the bid.
|
||||
**/
|
||||
@@ -774,14 +837,17 @@ declare module '@polkadot/api/types/storage' {
|
||||
/**
|
||||
* Double map from Candidate -> Voter -> (Maybe) Vote.
|
||||
**/
|
||||
votes: AugmentedQueryDoubleMap<ApiType, (key1: AccountId | string | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<Option<SocietyVote>>, [AccountId, AccountId]> & QueryableStorageEntry<ApiType, [AccountId, AccountId]>;
|
||||
votes: AugmentedQuery<ApiType, (arg1: AccountId | string | Uint8Array, arg2: AccountId | string | Uint8Array) => Observable<Option<SocietyVote>>, [AccountId, AccountId]> & QueryableStorageEntry<ApiType, [AccountId, AccountId]>;
|
||||
/**
|
||||
* Members currently vouching or banned from vouching again
|
||||
**/
|
||||
vouching: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<VouchingStatus>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
staking: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The active era information, it holds index and start.
|
||||
*
|
||||
@@ -822,13 +888,6 @@ declare module '@polkadot/api/types/storage' {
|
||||
* The earliest era for which we have a pending, unapplied slash.
|
||||
**/
|
||||
earliestUnappliedSlash: AugmentedQuery<ApiType, () => Observable<Option<EraIndex>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Flag to control the execution of the offchain election. When `Open(_)`, we accept
|
||||
* solutions to be submitted.
|
||||
*
|
||||
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
|
||||
**/
|
||||
eraElectionStatus: AugmentedQuery<ApiType, () => Observable<ElectionStatus>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Rewards for the last `HISTORY_DEPTH` eras.
|
||||
* If reward hasn't been set or has been removed then 0 reward is returned.
|
||||
@@ -842,7 +901,7 @@ declare module '@polkadot/api/types/storage' {
|
||||
* Is it removed after `HISTORY_DEPTH` eras.
|
||||
* If stakers hasn't been set or has been removed then empty exposure is returned.
|
||||
**/
|
||||
erasStakers: AugmentedQueryDoubleMap<ApiType, (key1: EraIndex | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<Exposure>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
|
||||
erasStakers: AugmentedQuery<ApiType, (arg1: EraIndex | AnyNumber | Uint8Array, arg2: AccountId | string | Uint8Array) => Observable<Exposure>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
|
||||
/**
|
||||
* Clipped Exposure of validator at era.
|
||||
*
|
||||
@@ -856,7 +915,7 @@ declare module '@polkadot/api/types/storage' {
|
||||
* Is it removed after `HISTORY_DEPTH` eras.
|
||||
* If stakers hasn't been set or has been removed then empty exposure is returned.
|
||||
**/
|
||||
erasStakersClipped: AugmentedQueryDoubleMap<ApiType, (key1: EraIndex | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<Exposure>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
|
||||
erasStakersClipped: AugmentedQuery<ApiType, (arg1: EraIndex | AnyNumber | Uint8Array, arg2: AccountId | string | Uint8Array) => Observable<Exposure>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
|
||||
/**
|
||||
* The session index at which the era start for the last `HISTORY_DEPTH` eras.
|
||||
*
|
||||
@@ -876,7 +935,7 @@ declare module '@polkadot/api/types/storage' {
|
||||
*
|
||||
* Is it removed after `HISTORY_DEPTH` eras.
|
||||
**/
|
||||
erasValidatorPrefs: AugmentedQueryDoubleMap<ApiType, (key1: EraIndex | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<ValidatorPrefs>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
|
||||
erasValidatorPrefs: AugmentedQuery<ApiType, (arg1: EraIndex | AnyNumber | Uint8Array, arg2: AccountId | string | Uint8Array) => Observable<ValidatorPrefs>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
|
||||
/**
|
||||
* The total validator era payout for the last `HISTORY_DEPTH` eras.
|
||||
*
|
||||
@@ -903,13 +962,6 @@ declare module '@polkadot/api/types/storage' {
|
||||
* invulnerables) and restricted to testnets.
|
||||
**/
|
||||
invulnerables: AugmentedQuery<ApiType, () => Observable<Vec<AccountId>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* True if the current **planned** session is final. Note that this does not take era
|
||||
* forcing into account.
|
||||
*
|
||||
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
|
||||
**/
|
||||
isCurrentSessionFinal: AugmentedQuery<ApiType, () => Observable<bool>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Map from all (unlocked) "controller" accounts to the info regarding the staking.
|
||||
**/
|
||||
@@ -925,25 +977,11 @@ declare module '@polkadot/api/types/storage' {
|
||||
/**
|
||||
* 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, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
|
||||
nominatorSlashInEra: AugmentedQuery<ApiType, (arg1: EraIndex | AnyNumber | Uint8Array, arg2: AccountId | string | Uint8Array) => Observable<Option<BalanceOf>>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
|
||||
/**
|
||||
* Where the reward payment should be made. Keyed by stash.
|
||||
**/
|
||||
payee: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<RewardDestination>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
||||
/**
|
||||
* The next validator set. At the end of an era, if this is available (potentially from the
|
||||
* result of an offchain worker), it is immediately used. Otherwise, the on-chain election
|
||||
* is executed.
|
||||
*
|
||||
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
|
||||
**/
|
||||
queuedElected: AugmentedQuery<ApiType, () => Observable<Option<ElectionResult>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The score of the current [`QueuedElected`].
|
||||
*
|
||||
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
|
||||
**/
|
||||
queuedScore: AugmentedQuery<ApiType, () => Observable<Option<ElectionScore>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Slashing spans for stash accounts.
|
||||
**/
|
||||
@@ -954,20 +992,6 @@ declare module '@polkadot/api/types/storage' {
|
||||
* The rest of the slashed value is handled by the `Slash`.
|
||||
**/
|
||||
slashRewardFraction: AugmentedQuery<ApiType, () => Observable<Perbill>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Snapshot of nominators at the beginning of the current election window. This should only
|
||||
* have a value when [`EraElectionStatus`] == `ElectionStatus::Open(_)`.
|
||||
*
|
||||
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
|
||||
**/
|
||||
snapshotNominators: AugmentedQuery<ApiType, () => Observable<Option<Vec<AccountId>>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Snapshot of validators at the beginning of the current election window. This should only
|
||||
* have a value when [`EraElectionStatus`] == `ElectionStatus::Open(_)`.
|
||||
*
|
||||
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
|
||||
**/
|
||||
snapshotValidators: AugmentedQuery<ApiType, () => Observable<Option<Vec<AccountId>>>, []> & 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.
|
||||
@@ -977,7 +1001,7 @@ declare module '@polkadot/api/types/storage' {
|
||||
* True if network has been upgraded to this version.
|
||||
* Storage version of the pallet.
|
||||
*
|
||||
* This is set to v5.0.0 for new networks.
|
||||
* This is set to v6.0.0 for new networks.
|
||||
**/
|
||||
storageVersion: AugmentedQuery<ApiType, () => Observable<Releases>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
@@ -996,17 +1020,23 @@ declare module '@polkadot/api/types/storage' {
|
||||
* 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, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
|
||||
validatorSlashInEra: AugmentedQuery<ApiType, (arg1: EraIndex | AnyNumber | Uint8Array, arg2: AccountId | string | Uint8Array) => Observable<Option<ITuple<[Perbill, BalanceOf]>>>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
sudo: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The `AccountId` of the sudo key.
|
||||
**/
|
||||
key: AugmentedQuery<ApiType, () => Observable<AccountId>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
system: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The full account information for a particular account ID.
|
||||
**/
|
||||
@@ -1081,9 +1111,12 @@ declare module '@polkadot/api/types/storage' {
|
||||
* True if we have upgraded so that `type RefCount` is `u32`. False (default) if not.
|
||||
**/
|
||||
upgradedToU32RefCount: AugmentedQuery<ApiType, () => Observable<bool>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
technicalCommittee: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The current members of the collective. This is stored sorted (just by value).
|
||||
**/
|
||||
@@ -1108,9 +1141,12 @@ declare module '@polkadot/api/types/storage' {
|
||||
* Votes on a given proposal, if it is ongoing.
|
||||
**/
|
||||
voting: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Option<Votes>>, [Hash]> & QueryableStorageEntry<ApiType, [Hash]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
technicalMembership: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The current membership, stored as an ordered Vec.
|
||||
**/
|
||||
@@ -1119,9 +1155,12 @@ declare module '@polkadot/api/types/storage' {
|
||||
* The current prime member, if one exists.
|
||||
**/
|
||||
prime: AugmentedQuery<ApiType, () => Observable<Option<AccountId>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
timestamp: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Did the timestamp get updated in this block?
|
||||
**/
|
||||
@@ -1130,9 +1169,12 @@ declare module '@polkadot/api/types/storage' {
|
||||
* Current time for the current block.
|
||||
**/
|
||||
now: AugmentedQuery<ApiType, () => Observable<Moment>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
tips: {
|
||||
[key: string]: 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.
|
||||
@@ -1144,14 +1186,20 @@ declare module '@polkadot/api/types/storage' {
|
||||
* guaranteed to be a secure hash.
|
||||
**/
|
||||
tips: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Option<OpenTip>>, [Hash]> & QueryableStorageEntry<ApiType, [Hash]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
transactionPayment: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
nextFeeMultiplier: AugmentedQuery<ApiType, () => Observable<Multiplier>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
storageVersion: AugmentedQuery<ApiType, () => Observable<Releases>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
treasury: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Proposal indices that have been approved but not yet awarded.
|
||||
**/
|
||||
@@ -1164,13 +1212,20 @@ declare module '@polkadot/api/types/storage' {
|
||||
* Proposals that have been made.
|
||||
**/
|
||||
proposals: AugmentedQuery<ApiType, (arg: ProposalIndex | AnyNumber | Uint8Array) => Observable<Option<TreasuryProposal>>, [ProposalIndex]> & QueryableStorageEntry<ApiType, [ProposalIndex]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
vesting: {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Information regarding the vesting of a given account.
|
||||
**/
|
||||
vesting: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<VestingInfo>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,10 +6,11 @@ import type { Bytes, HashMap, Json, Null, Option, StorageKey, Text, U256, U64, V
|
||||
import type { AnyNumber, Codec, IExtrinsic, Observable } from '@polkadot/types/types';
|
||||
import type { ExtrinsicOrHash, ExtrinsicStatus } from '@polkadot/types/interfaces/author';
|
||||
import type { EpochAuthorship } from '@polkadot/types/interfaces/babe';
|
||||
import type { BeefySignedCommitment } from '@polkadot/types/interfaces/beefy';
|
||||
import type { BlockHash } from '@polkadot/types/interfaces/chain';
|
||||
import type { PrefixedStorageKey } from '@polkadot/types/interfaces/childstate';
|
||||
import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
|
||||
import type { ContractCallRequest, ContractExecResult } from '@polkadot/types/interfaces/contracts';
|
||||
import type { ContractCallRequest, ContractExecResult, ContractInstantiateResult, InstantiateRequest } from '@polkadot/types/interfaces/contracts';
|
||||
import type { CreatedBlock } from '@polkadot/types/interfaces/engine';
|
||||
import type { EthAccount, EthCallRequest, EthFilter, EthFilterChanges, EthLog, EthReceipt, EthRichBlock, EthSubKind, EthSubParams, EthSyncStatus, EthTransaction, EthTransactionRequest, EthWork } from '@polkadot/types/interfaces/eth';
|
||||
import type { Extrinsic } from '@polkadot/types/interfaces/extrinsics';
|
||||
@@ -19,7 +20,7 @@ import type { StorageKind } from '@polkadot/types/interfaces/offchain';
|
||||
import type { FeeDetails, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
|
||||
import type { RpcMethods } from '@polkadot/types/interfaces/rpc';
|
||||
import type { AccountId, BlockNumber, H160, H256, H64, Hash, Header, Index, Justification, KeyValue, SignedBlock, StorageData } from '@polkadot/types/interfaces/runtime';
|
||||
import type { ReadProof, RuntimeVersion } from '@polkadot/types/interfaces/state';
|
||||
import type { ReadProof, RuntimeVersion, TraceBlockResponse } from '@polkadot/types/interfaces/state';
|
||||
import type { ApplyExtrinsicResult, ChainProperties, ChainType, Health, NetworkState, NodeRole, PeerInfo, SyncState } from '@polkadot/types/interfaces/system';
|
||||
|
||||
declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
@@ -64,6 +65,12 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
**/
|
||||
epochAuthorship: AugmentedRpc<() => Observable<HashMap<AuthorityId, EpochAuthorship>>>;
|
||||
};
|
||||
beefy: {
|
||||
/**
|
||||
* Returns the block most recently finalized by BEEFY, alongside side its justification.
|
||||
**/
|
||||
subscribeJustifications: AugmentedRpc<() => Observable<BeefySignedCommitment>>;
|
||||
};
|
||||
chain: {
|
||||
/**
|
||||
* Get header and body of a relay chain block
|
||||
@@ -121,6 +128,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
* Returns the value under a specified storage key in a contract
|
||||
**/
|
||||
getStorage: AugmentedRpc<(address: AccountId | string | Uint8Array, key: H256 | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<Option<Bytes>>>;
|
||||
/**
|
||||
* Instantiate a new contract
|
||||
**/
|
||||
instantiate: AugmentedRpc<(request: InstantiateRequest | { origin?: any; endowment?: any; gasLimit?: any; code?: any; data?: any; salt?: any } | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<ContractInstantiateResult>>;
|
||||
/**
|
||||
* Returns the projected time a given contract will be able to sustain paying its rent
|
||||
**/
|
||||
@@ -134,7 +145,7 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
/**
|
||||
* Instructs the manual-seal authorship task to finalize a block
|
||||
**/
|
||||
finalizeBlock: AugmentedRpc<(hash: BlockHash | string | Uint8Array, justification?: Justification | string | Uint8Array) => Observable<bool>>;
|
||||
finalizeBlock: AugmentedRpc<(hash: BlockHash | string | Uint8Array, justification?: Justification) => Observable<bool>>;
|
||||
};
|
||||
eth: {
|
||||
/**
|
||||
@@ -371,6 +382,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
* Retrieves the keys with prefix of a specific child storage
|
||||
**/
|
||||
getChildKeys: AugmentedRpc<(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>>>;
|
||||
/**
|
||||
* Returns proof of storage for child key entries at a specific block state.
|
||||
**/
|
||||
getChildReadProof: AugmentedRpc<(childStorageKey: PrefixedStorageKey | string | Uint8Array, keys: Vec<StorageKey> | (StorageKey | string | Uint8Array | any)[], at?: BlockHash | string | Uint8Array) => Observable<ReadProof>>;
|
||||
/**
|
||||
* Retrieves the child storage for a key
|
||||
**/
|
||||
@@ -435,6 +450,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
* Subscribes to storage changes for the provided keys
|
||||
**/
|
||||
subscribeStorage: AugmentedRpc<<T = Codec[]>(keys?: Vec<StorageKey> | (StorageKey | string | Uint8Array | any)[]) => Observable<T>>;
|
||||
/**
|
||||
* Provides a way to trace the re-execution of a single block
|
||||
**/
|
||||
traceBlock: AugmentedRpc<(block: Hash | string | Uint8Array, targets: Option<Text> | null | object | string | Uint8Array, storageKeys: Option<Text> | null | object | string | Uint8Array) => Observable<TraceBlockResponse>>;
|
||||
};
|
||||
syncstate: {
|
||||
/**
|
||||
@@ -503,6 +522,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
* Remove a reserved peer
|
||||
**/
|
||||
removeReservedPeer: AugmentedRpc<(peerId: Text | string) => Observable<Text>>;
|
||||
/**
|
||||
* Returns the list of reserved peers
|
||||
**/
|
||||
reservedPeers: AugmentedRpc<() => Observable<Vec<Text>>>;
|
||||
/**
|
||||
* Resets the log filter to Substrate defaults
|
||||
**/
|
||||
|
||||
+137
-115
@@ -6,7 +6,7 @@ import type { AnyNumber, ITuple } from '@polkadot/types/types';
|
||||
import type { AssetDestroyWitness, TAssetBalance } from '@polkadot/types/interfaces/assets';
|
||||
import type { BabeEquivocationProof, NextConfigDescriptor } from '@polkadot/types/interfaces/babe';
|
||||
import type { MemberCount, ProposalIndex } from '@polkadot/types/interfaces/collective';
|
||||
import type { CodeHash, Schedule } from '@polkadot/types/interfaces/contracts';
|
||||
import type { CodeHash } from '@polkadot/types/interfaces/contracts';
|
||||
import type { AccountVote, Conviction, PropIndex, Proposal, ReferendumIndex } from '@polkadot/types/interfaces/democracy';
|
||||
import type { Renouncing } from '@polkadot/types/interfaces/elections';
|
||||
import type { Extrinsic, Signature } from '@polkadot/types/interfaces/extrinsics';
|
||||
@@ -19,7 +19,7 @@ import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber,
|
||||
import type { Period, Priority } from '@polkadot/types/interfaces/scheduler';
|
||||
import type { Keys } from '@polkadot/types/interfaces/session';
|
||||
import type { SocietyJudgement } from '@polkadot/types/interfaces/society';
|
||||
import type { CompactAssignments, ElectionScore, ElectionSize, EraIndex, RawSolution, RewardDestination, SolutionOrSnapshotSize, ValidatorIndex, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
|
||||
import type { EraIndex, RawSolution, RewardDestination, SolutionOrSnapshotSize, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
|
||||
import type { Key } from '@polkadot/types/interfaces/system';
|
||||
import type { BountyIndex } from '@polkadot/types/interfaces/treasury';
|
||||
import type { Timepoint } from '@polkadot/types/interfaces/utility';
|
||||
@@ -29,7 +29,6 @@ import type { ApiTypes, SubmittableExtrinsic } from '@polkadot/api/types';
|
||||
declare module '@polkadot/api/types/submittable' {
|
||||
export interface AugmentedSubmittables<ApiType> {
|
||||
assets: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Approve an amount of asset for transfer by a delegated third-party account.
|
||||
*
|
||||
@@ -108,8 +107,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* The origin must be Signed and the sender must have sufficient funds free.
|
||||
*
|
||||
* Funds of sender are reserved according to the formula:
|
||||
* `AssetDepositBase + AssetDepositPerZombie * max_zombies`.
|
||||
* Funds of sender are reserved by `AssetDeposit`.
|
||||
*
|
||||
* Parameters:
|
||||
* - `id`: The identifier of the new asset. This must not be currently in use to identify
|
||||
@@ -434,16 +432,22 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
transferOwnership: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, owner: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
authorship: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Provide a set of uncles.
|
||||
**/
|
||||
setUncles: AugmentedSubmittable<(newUncles: Vec<Header> | (Header | { parentHash?: any; number?: any; stateRoot?: any; extrinsicsRoot?: any; digest?: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [Vec<Header>]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
babe: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Plan an epoch config change. The epoch config change is recorded and will be enacted on
|
||||
* the next call to `enact_epoch_change`. The config will be activated one epoch after.
|
||||
@@ -469,9 +473,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* reporter.
|
||||
**/
|
||||
reportEquivocationUnsigned: AugmentedSubmittable<(equivocationProof: BabeEquivocationProof | { offender?: any; slotNumber?: any; firstHeader?: any; secondHeader?: any } | string | Uint8Array, keyOwnerProof: KeyOwnerProof | { session?: any; trieNodes?: any; validatorCount?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [BabeEquivocationProof, KeyOwnerProof]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
balances: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Exactly as `transfer`, except the origin must be root and the source account may be
|
||||
* specified.
|
||||
@@ -546,9 +553,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* #</weight>
|
||||
**/
|
||||
transferKeepAlive: AugmentedSubmittable<(dest: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<Balance>]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
bounties: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Accept the curator role for a bounty.
|
||||
* A deposit will be reserved from curator and refund upon successful payout.
|
||||
@@ -668,9 +678,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
unassignCurator: AugmentedSubmittable<(bountyId: Compact<BountyIndex> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BountyIndex>]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
contracts: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Makes a call to an account, optionally transferring some balance.
|
||||
*
|
||||
@@ -713,7 +726,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* * `gas_limit`: The gas limit enforced when executing the constructor.
|
||||
* * `code`: The contract code to deploy in raw bytes.
|
||||
* * `data`: The input data to pass to the contract constructor.
|
||||
* * `salt`: Used for the address derivation. See [`Self::contract_address`].
|
||||
* * `salt`: Used for the address derivation. See [`Pallet::contract_address`].
|
||||
*
|
||||
* Instantiation is executed as follows:
|
||||
*
|
||||
@@ -726,17 +739,11 @@ declare module '@polkadot/api/types/submittable' {
|
||||
**/
|
||||
instantiateWithCode: AugmentedSubmittable<(endowment: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Weight> | AnyNumber | Uint8Array, code: Bytes | string | Uint8Array, data: Bytes | string | Uint8Array, salt: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BalanceOf>, Compact<Weight>, Bytes, Bytes, Bytes]>;
|
||||
/**
|
||||
* Updates the schedule for metering contracts.
|
||||
*
|
||||
* The schedule's version cannot be less than the version of the stored schedule.
|
||||
* If a schedule does not change the instruction weights the version does not
|
||||
* need to be increased. Therefore we allow storing a schedule that has the same
|
||||
* version as the stored one.
|
||||
* Generic tx
|
||||
**/
|
||||
updateSchedule: AugmentedSubmittable<(schedule: Schedule | { version?: any; enablePrintln?: any; limits?: any; instructionWeights?: any; hostFnWeights?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Schedule]>;
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
council: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Close a vote that is either approved, disapproved or whose voting period has ended.
|
||||
*
|
||||
@@ -873,9 +880,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
vote: AugmentedSubmittable<(proposal: Hash | string | Uint8Array, index: Compact<ProposalIndex> | AnyNumber | Uint8Array, approve: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [Hash, Compact<ProposalIndex>, bool]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
democracy: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Permanently place a proposal into the blacklist. This prevents it from ever being
|
||||
* proposed again.
|
||||
@@ -1206,9 +1216,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* Weight: `O(R)` where R is the number of referendums the voter has voted on.
|
||||
**/
|
||||
vote: AugmentedSubmittable<(refIndex: Compact<ReferendumIndex> | AnyNumber | Uint8Array, vote: AccountVote | { Standard: any } | { Split: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ReferendumIndex>, AccountVote]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
electionProviderMultiPhase: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Submit a solution for the unsigned phase.
|
||||
*
|
||||
@@ -1226,9 +1239,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* No deposit or reward is associated with this submission.
|
||||
**/
|
||||
submitUnsigned: AugmentedSubmittable<(solution: RawSolution | { compact?: any; score?: any; round?: any } | string | Uint8Array, witness: SolutionOrSnapshotSize | { voters?: any; targets?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [RawSolution, SolutionOrSnapshotSize]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
elections: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Clean all voters who are defunct (i.e. they do not serve any purpose at all). The
|
||||
* deposit of the removed voters are returned.
|
||||
@@ -1277,8 +1293,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* origin is removed as a runner-up.
|
||||
* - `origin` is a current member. In this case, the deposit is unreserved and origin is
|
||||
* removed as a member, consequently not being a candidate for the next round anymore.
|
||||
* Similar to [`remove_members`], if replacement runners exists, they are immediately used.
|
||||
* If the prime is renouncing, then no prime will exist until the next round.
|
||||
* Similar to [`remove_members`], if replacement runners exists, they are immediately
|
||||
* used. If the prime is renouncing, then no prime will exist until the next round.
|
||||
*
|
||||
* The dispatch origin of this call must be signed, and have one of the above roles.
|
||||
*
|
||||
@@ -1331,9 +1347,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
vote: AugmentedSubmittable<(votes: Vec<AccountId> | (AccountId | string | Uint8Array)[], value: Compact<BalanceOf> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Vec<AccountId>, Compact<BalanceOf>]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
gilt: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Place a bid for a gilt to be issued.
|
||||
*
|
||||
@@ -1379,9 +1398,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - `index`: The index of the gilt to be thawed.
|
||||
**/
|
||||
thaw: AugmentedSubmittable<(index: Compact<ActiveIndex> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ActiveIndex>]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
grandpa: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Note that the current authority set of the GRANDPA finality gadget has
|
||||
* stalled. This will trigger a forced authority set change at the beginning
|
||||
@@ -1411,9 +1433,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* reporter.
|
||||
**/
|
||||
reportEquivocationUnsigned: AugmentedSubmittable<(equivocationProof: GrandpaEquivocationProof | { setId?: any; equivocation?: any } | string | Uint8Array, keyOwnerProof: KeyOwnerProof | { session?: any; trieNodes?: any; validatorCount?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [GrandpaEquivocationProof, KeyOwnerProof]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
identity: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Add a registrar to the system.
|
||||
*
|
||||
@@ -1675,9 +1700,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
setSubs: AugmentedSubmittable<(subs: Vec<ITuple<[AccountId, Data]>> | ([AccountId | string | Uint8Array, Data | { None: any } | { Raw: any } | { BlakeTwo256: any } | { Sha256: any } | { Keccak256: any } | { ShaThree256: any } | string | Uint8Array])[]) => SubmittableExtrinsic<ApiType>, [Vec<ITuple<[AccountId, Data]>>]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
imOnline: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* # <weight>
|
||||
* - Complexity: `O(K + E)` where K is length of `Keys` (heartbeat.validators_len)
|
||||
@@ -1690,9 +1718,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
heartbeat: AugmentedSubmittable<(heartbeat: Heartbeat | { blockNumber?: any; networkState?: any; sessionIndex?: any; authorityIndex?: any; validatorsLen?: any } | string | Uint8Array, signature: Signature | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Heartbeat, Signature]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
indices: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Assign an previously unassigned index.
|
||||
*
|
||||
@@ -1802,9 +1833,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
transfer: AugmentedSubmittable<(updated: AccountId | string | Uint8Array, index: AccountIndex | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId, AccountIndex]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
lottery: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Buy a ticket to enter the lottery.
|
||||
*
|
||||
@@ -1848,9 +1882,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* This extrinsic must be called by the `ManagerOrigin`.
|
||||
**/
|
||||
stopRepeat: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
multisig: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Register approval for a dispatch to be made from a deterministic composite account if
|
||||
* approved by a total of `threshold - 1` of `other_signatories`.
|
||||
@@ -1987,9 +2024,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
cancelAsMulti: AugmentedSubmittable<(threshold: u16 | AnyNumber | Uint8Array, otherSignatories: Vec<AccountId> | (AccountId | string | Uint8Array)[], timepoint: Timepoint | { height?: any; index?: any } | string | Uint8Array, callHash: U8aFixed | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u16, Vec<AccountId>, Timepoint, U8aFixed]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
proxy: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Register a proxy account for the sender that is able to make calls on its behalf.
|
||||
*
|
||||
@@ -2098,7 +2138,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
**/
|
||||
proxy: AugmentedSubmittable<(real: AccountId | string | Uint8Array, forceProxyType: Option<ProxyType> | null | object | string | Uint8Array, call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId, Option<ProxyType>, Call]>;
|
||||
/**
|
||||
* Dispatch the given `call` from an account that the sender is authorised for through
|
||||
* Dispatch the given `call` from an account that the sender is authorized for through
|
||||
* `add_proxy`.
|
||||
*
|
||||
* Removes any corresponding announcement(s).
|
||||
@@ -2182,9 +2222,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
removeProxy: AugmentedSubmittable<(delegate: AccountId | string | Uint8Array, proxyType: ProxyType | 'Any' | 'NonTransfer' | 'Governance' | 'Staking' | number | Uint8Array, delay: BlockNumber | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId, ProxyType, BlockNumber]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
recovery: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Send a call through a recovered account.
|
||||
*
|
||||
@@ -2384,9 +2427,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
vouchRecovery: AugmentedSubmittable<(lost: AccountId | string | Uint8Array, rescuer: AccountId | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId, AccountId]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
scheduler: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Cancel an anonymously scheduled task.
|
||||
*
|
||||
@@ -2455,9 +2501,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
scheduleNamedAfter: AugmentedSubmittable<(id: Bytes | string | Uint8Array, after: BlockNumber | AnyNumber | Uint8Array, maybePeriodic: Option<Period> | null | object | string | Uint8Array, priority: Priority | AnyNumber | Uint8Array, call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Bytes, BlockNumber, Option<Period>, Priority, Call]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
session: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Removes any session key(s) of the function caller.
|
||||
* This doesn't take effect until the next session.
|
||||
@@ -2490,9 +2539,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
setKeys: AugmentedSubmittable<(keys: Keys, proof: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Keys, Bytes]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
society: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* A user outside of the society can make a bid for entry.
|
||||
*
|
||||
@@ -2810,9 +2862,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
vouch: AugmentedSubmittable<(who: AccountId | string | Uint8Array, value: BalanceOf | AnyNumber | Uint8Array, tip: BalanceOf | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId, BalanceOf, BalanceOf]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
staking: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Take the origin account as a stash and lock up `value` of its balance. `controller` will
|
||||
* be the account that controls it.
|
||||
@@ -2837,7 +2892,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Write: Bonded, Payee, [Origin Account], Locks, Ledger
|
||||
* # </weight>
|
||||
**/
|
||||
bond: AugmentedSubmittable<(controller: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, value: Compact<BalanceOf> | AnyNumber | Uint8Array, payee: RewardDestination | { Staked: any } | { Stash: any } | { Controller: any } | { Account: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<BalanceOf>, RewardDestination]>;
|
||||
bond: AugmentedSubmittable<(controller: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, value: Compact<BalanceOf> | AnyNumber | Uint8Array, payee: RewardDestination | { Staked: any } | { Stash: any } | { Controller: any } | { Account: any } | { None: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<BalanceOf>, RewardDestination]>;
|
||||
/**
|
||||
* Add some extra amount that have appeared in the stash `free_balance` into the balance up
|
||||
* for staking.
|
||||
@@ -3143,7 +3198,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Write: Payee
|
||||
* # </weight>
|
||||
**/
|
||||
setPayee: AugmentedSubmittable<(payee: RewardDestination | { Staked: any } | { Stash: any } | { Controller: any } | { Account: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [RewardDestination]>;
|
||||
setPayee: AugmentedSubmittable<(payee: RewardDestination | { Staked: any } | { Stash: any } | { Controller: any } | { Account: any } | { None: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [RewardDestination]>;
|
||||
/**
|
||||
* Sets the ideal number of validators.
|
||||
*
|
||||
@@ -3155,70 +3210,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
setValidatorCount: AugmentedSubmittable<(updated: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<u32>]>;
|
||||
/**
|
||||
* Submit an election result to the chain. If the solution:
|
||||
*
|
||||
* 1. is valid.
|
||||
* 2. has a better score than a potentially existing solution on chain.
|
||||
*
|
||||
* then, it will be _put_ on chain.
|
||||
*
|
||||
* A solution consists of two pieces of data:
|
||||
*
|
||||
* 1. `winners`: a flat vector of all the winners of the round.
|
||||
* 2. `assignments`: the compact version of an assignment vector that encodes the edge
|
||||
* weights.
|
||||
*
|
||||
* Both of which may be computed using _phragmen_, or any other algorithm.
|
||||
*
|
||||
* Additionally, the submitter must provide:
|
||||
*
|
||||
* - The `score` that they claim their solution has.
|
||||
*
|
||||
* Both validators and nominators will be represented by indices in the solution. The
|
||||
* indices should respect the corresponding types ([`ValidatorIndex`] and
|
||||
* [`NominatorIndex`]). Moreover, they should be valid when used to index into
|
||||
* [`SnapshotValidators`] and [`SnapshotNominators`]. Any invalid index will cause the
|
||||
* solution to be rejected. These two storage items are set during the election window and
|
||||
* may be used to determine the indices.
|
||||
*
|
||||
* A solution is valid if:
|
||||
*
|
||||
* 0. It is submitted when [`EraElectionStatus`] is `Open`.
|
||||
* 1. Its claimed score is equal to the score computed on-chain.
|
||||
* 2. Presents the correct number of winners.
|
||||
* 3. All indexes must be value according to the snapshot vectors. All edge values must
|
||||
* also be correct and should not overflow the granularity of the ratio type (i.e. 256
|
||||
* or billion).
|
||||
* 4. For each edge, all targets are actually nominated by the voter.
|
||||
* 5. Has correct self-votes.
|
||||
*
|
||||
* A solutions score is consisted of 3 parameters:
|
||||
*
|
||||
* 1. `min { support.total }` for each support of a winner. This value should be maximized.
|
||||
* 2. `sum { support.total }` for each support of a winner. This value should be minimized.
|
||||
* 3. `sum { support.total^2 }` for each support of a winner. This value should be
|
||||
* minimized (to ensure less variance)
|
||||
*
|
||||
* # <weight>
|
||||
* The transaction is assumed to be the longest path, a better solution.
|
||||
* - Initial solution is almost the same.
|
||||
* - Worse solution is retraced in pre-dispatch-checks which sets its own weight.
|
||||
* # </weight>
|
||||
**/
|
||||
submitElectionSolution: AugmentedSubmittable<(winners: Vec<ValidatorIndex> | (ValidatorIndex | AnyNumber | Uint8Array)[], compact: CompactAssignments | { votes1?: any; votes2?: any; votes3?: any; votes4?: any; votes5?: any; votes6?: any; votes7?: any; votes8?: any; votes9?: any; votes10?: any; votes11?: any; votes12?: any; votes13?: any; votes14?: any; votes15?: any; votes16?: any } | string | Uint8Array, score: ElectionScore, era: EraIndex | AnyNumber | Uint8Array, size: ElectionSize | { validators?: any; nominators?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Vec<ValidatorIndex>, CompactAssignments, ElectionScore, EraIndex, ElectionSize]>;
|
||||
/**
|
||||
* Unsigned version of `submit_election_solution`.
|
||||
*
|
||||
* Note that this must pass the [`ValidateUnsigned`] check which only allows transactions
|
||||
* from the local node to be included. In other words, only the block author can include a
|
||||
* transaction in the block.
|
||||
*
|
||||
* # <weight>
|
||||
* See [`submit_election_solution`].
|
||||
* # </weight>
|
||||
**/
|
||||
submitElectionSolutionUnsigned: AugmentedSubmittable<(winners: Vec<ValidatorIndex> | (ValidatorIndex | AnyNumber | Uint8Array)[], compact: CompactAssignments | { votes1?: any; votes2?: any; votes3?: any; votes4?: any; votes5?: any; votes6?: any; votes7?: any; votes8?: any; votes9?: any; votes10?: any; votes11?: any; votes12?: any; votes13?: any; votes14?: any; votes15?: any; votes16?: any } | string | Uint8Array, score: ElectionScore, era: EraIndex | AnyNumber | Uint8Array, size: ElectionSize | { validators?: any; nominators?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Vec<ValidatorIndex>, CompactAssignments, ElectionScore, EraIndex, ElectionSize]>;
|
||||
/**
|
||||
* 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
|
||||
@@ -3308,9 +3299,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
withdrawUnbonded: AugmentedSubmittable<(numSlashingSpans: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
sudo: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Authenticates the current sudo key and sets the given AccountId (`new`) as the new sudo key.
|
||||
*
|
||||
@@ -3363,9 +3357,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
sudoUncheckedWeight: AugmentedSubmittable<(call: Call | { callIndex?: any; args?: any } | string | Uint8Array, weight: Weight | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Call, Weight]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
system: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* A dispatch that will fill the block weight up to the given ratio.
|
||||
**/
|
||||
@@ -3471,9 +3468,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
setStorage: AugmentedSubmittable<(items: Vec<KeyValue> | (KeyValue)[]) => SubmittableExtrinsic<ApiType>, [Vec<KeyValue>]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
technicalCommittee: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Close a vote that is either approved, disapproved or whose voting period has ended.
|
||||
*
|
||||
@@ -3610,9 +3610,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
vote: AugmentedSubmittable<(proposal: Hash | string | Uint8Array, index: Compact<ProposalIndex> | AnyNumber | Uint8Array, approve: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [Hash, Compact<ProposalIndex>, bool]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
technicalMembership: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Add a member `who` to the set.
|
||||
*
|
||||
@@ -3660,9 +3663,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* Prime membership is *not* passed from `remove` to `add`, if extant.
|
||||
**/
|
||||
swapMember: AugmentedSubmittable<(remove: AccountId | string | Uint8Array, add: AccountId | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId, AccountId]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
timestamp: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Set the current time.
|
||||
*
|
||||
@@ -3681,9 +3687,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
set: AugmentedSubmittable<(now: Compact<Moment> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<Moment>]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
tips: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Close and payout a tip.
|
||||
*
|
||||
@@ -3816,9 +3825,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
tipNew: AugmentedSubmittable<(reason: Bytes | string | Uint8Array, who: AccountId | string | Uint8Array, tipValue: Compact<BalanceOf> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Bytes, AccountId, Compact<BalanceOf>]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
treasury: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Approve a proposal. At a later time, the proposal will be allocated to the beneficiary
|
||||
* and the original deposit will be returned.
|
||||
@@ -3856,9 +3868,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
rejectProposal: AugmentedSubmittable<(proposalId: Compact<ProposalIndex> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ProposalIndex>]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
utility: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Send a call through an indexed pseudonym of the sender.
|
||||
*
|
||||
@@ -3912,9 +3927,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
batchAll: AugmentedSubmittable<(calls: Vec<Call> | (Call | { callIndex?: any; args?: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [Vec<Call>]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
vesting: {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Force a vested transfer.
|
||||
*
|
||||
@@ -3939,7 +3957,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* Unlock any vested funds of the sender account.
|
||||
*
|
||||
* The dispatch origin for this call must be _Signed_ and the sender must have funds still
|
||||
* locked under this module.
|
||||
* locked under this pallet.
|
||||
*
|
||||
* Emits either `VestingCompleted` or `VestingUpdated`.
|
||||
*
|
||||
@@ -3957,7 +3975,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* The dispatch origin for this call must be _Signed_.
|
||||
*
|
||||
* - `target`: The account whose vested funds should be unlocked. Must have funds still
|
||||
* locked under this module.
|
||||
* locked under this pallet.
|
||||
*
|
||||
* Emits either `VestingCompleted` or `VestingUpdated`.
|
||||
*
|
||||
@@ -3988,6 +4006,10 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
vestedTransfer: AugmentedSubmittable<(target: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, schedule: VestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, VestingInfo]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ interface MetaDecoration {
|
||||
}
|
||||
|
||||
// the max amount of keys/values that we will retrieve at once
|
||||
const PAGE_SIZE = 384;
|
||||
const PAGE_SIZE = 256;
|
||||
|
||||
const l = logger('api/init');
|
||||
|
||||
@@ -262,7 +262,8 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
|
||||
return allKeys;
|
||||
}, []);
|
||||
const unknown = exposed.filter((key) => !allKeys.includes(key));
|
||||
const unknown = exposed.filter((k) => !allKeys.includes(k));
|
||||
const deletion = allKnown.filter(([k]) => hasResults && !exposed.includes(k) && k !== 'rpc_methods');
|
||||
|
||||
if (unknown.length) {
|
||||
l.warn(`RPC methods not decorated: ${unknown.join(', ')}`);
|
||||
@@ -270,17 +271,10 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
|
||||
// loop through all entries we have (populated in decorate) and filter as required
|
||||
// only remove when we have results and method missing, or with no results if optional
|
||||
allKnown
|
||||
.filter(([key]): boolean => hasResults
|
||||
? !exposed.includes(key) && key !== 'rpc_methods' // rpc_methods doesn't appear, v1
|
||||
: key === 'rpc_methods' // we didn't find this one, remove
|
||||
)
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
.forEach(([_, { method, section }]): void => {
|
||||
delete (this._rpc as Record<string, Record<string, unknown>>)[section][method];
|
||||
delete (this._rpcCore as unknown as Record<string, Record<string, unknown>>)[section][method];
|
||||
delete (this._rx.rpc as Record<string, Record<string, unknown>>)[section][method];
|
||||
});
|
||||
deletion.forEach(([, { method, section }]): void => {
|
||||
delete (this._rpc as Record<string, Record<string, unknown>>)[section][method];
|
||||
delete (this._rx.rpc as Record<string, Record<string, unknown>>)[section][method];
|
||||
});
|
||||
}
|
||||
|
||||
protected _decorateRpc<ApiType extends ApiTypes> (rpc: RpcCore & RpcInterface, decorateMethod: DecorateMethod<ApiType>, input: Partial<DecoratedRpc<ApiType, RpcInterface>> = {}): DecoratedRpc<ApiType, RpcInterface> {
|
||||
@@ -297,6 +291,8 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
(section as Record<string, { json: unknown }>)[methodName].json = decorateMethod(method.json, { methodName }) as unknown;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
(section as Record<string, { raw: unknown }>)[methodName].raw = decorateMethod(method.raw, { methodName }) as unknown;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
(section as Record<string, { meta: unknown }>)[methodName].meta = method.meta;
|
||||
}
|
||||
|
||||
return section;
|
||||
@@ -360,7 +356,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
|
||||
private _decorateStorageEntry<ApiType extends ApiTypes> (creator: StorageEntry, decorateMethod: DecorateMethod<ApiType>): QueryableStorageEntry<ApiType> {
|
||||
// get the storage arguments, with DoubleMap as an array entry, otherwise spread
|
||||
const getArgs = (...args: unknown[]): unknown[] => extractStorageArgs(creator, args);
|
||||
const getArgs = (args: unknown[]): unknown[] => extractStorageArgs(creator, args);
|
||||
|
||||
// Disable this where it occurs for each field we are decorating
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
|
||||
@@ -369,51 +365,60 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
|
||||
decorated.creator = creator;
|
||||
|
||||
decorated.at = decorateMethod((hash: Hash, arg1?: Arg, arg2?: Arg): Observable<Codec> =>
|
||||
this._rpcCore.state.getStorage(getArgs(arg1, arg2), hash));
|
||||
decorated.at = decorateMethod((hash: Hash, ...args: Arg[]): Observable<Codec> =>
|
||||
this._rpcCore.state.getStorage(getArgs(args), hash));
|
||||
|
||||
decorated.hash = decorateMethod((arg1?: Arg, arg2?: Arg): Observable<Hash> =>
|
||||
this._rpcCore.state.getStorageHash(getArgs(arg1, arg2)));
|
||||
decorated.hash = decorateMethod((...args: Arg[]): Observable<Hash> =>
|
||||
this._rpcCore.state.getStorageHash(getArgs(args)));
|
||||
|
||||
decorated.is = <A extends AnyTuple> (key: IStorageKey<AnyTuple>): key is IStorageKey<A> =>
|
||||
key.section === creator.section && key.method === creator.method;
|
||||
|
||||
decorated.key = (arg1?: Arg, arg2?: Arg): string =>
|
||||
u8aToHex(compactStripLength(creator(creator.meta.type.isDoubleMap ? [arg1, arg2] : arg1))[1]);
|
||||
decorated.key = (...args: Arg[]): string =>
|
||||
u8aToHex(compactStripLength(creator(
|
||||
creator.meta.type.isPlain
|
||||
? undefined
|
||||
: creator.meta.type.isMap
|
||||
? args[0]
|
||||
: creator.meta.type.isDoubleMap
|
||||
? [args[0], args[1]]
|
||||
: args
|
||||
))[1]);
|
||||
|
||||
decorated.keyPrefix = (key1?: Arg): string =>
|
||||
u8aToHex(creator.keyPrefix(key1));
|
||||
decorated.keyPrefix = (...keys: Arg[]): string =>
|
||||
u8aToHex(creator.keyPrefix(...keys));
|
||||
|
||||
decorated.range = decorateMethod((range: [Hash, Hash?], arg1?: Arg, arg2?: Arg): Observable<[Hash, Codec][]> =>
|
||||
this._decorateStorageRange(decorated, [arg1, arg2], range));
|
||||
decorated.range = decorateMethod((range: [Hash, Hash?], ...args: Arg[]): Observable<[Hash, Codec][]> =>
|
||||
this._decorateStorageRange(decorated, args, range));
|
||||
|
||||
decorated.size = decorateMethod((arg1?: Arg, arg2?: Arg): Observable<u64> =>
|
||||
this._rpcCore.state.getStorageSize(getArgs(arg1, arg2)));
|
||||
decorated.size = decorateMethod((...args: Arg[]): Observable<u64> =>
|
||||
this._rpcCore.state.getStorageSize(getArgs(args)));
|
||||
|
||||
decorated.sizeAt = decorateMethod((hash: Hash | Uint8Array | string, arg1?: Arg, arg2?: Arg): Observable<u64> =>
|
||||
this._rpcCore.state.getStorageSize(getArgs(arg1, arg2), hash));
|
||||
decorated.sizeAt = decorateMethod((hash: Hash | Uint8Array | string, ...args: Arg[]): Observable<u64> =>
|
||||
this._rpcCore.state.getStorageSize(getArgs(args), hash));
|
||||
|
||||
// FIXME NMap support
|
||||
// .keys() & .entries() only available on map types
|
||||
if (creator.iterKey && (creator.meta.type.isMap || creator.meta.type.isDoubleMap)) {
|
||||
decorated.entries = decorateMethod(
|
||||
memo(this.#instanceId, (doubleMapArg?: Arg): Observable<[StorageKey, Codec][]> =>
|
||||
this._retrieveMapEntries(creator, null, doubleMapArg)));
|
||||
memo(this.#instanceId, (...args: Arg[]): Observable<[StorageKey, Codec][]> =>
|
||||
this._retrieveMapEntries(creator, null, args)));
|
||||
|
||||
decorated.entriesAt = decorateMethod(
|
||||
memo(this.#instanceId, (hash: Hash | Uint8Array | string, doubleMapArg?: Arg): Observable<[StorageKey, Codec][]> =>
|
||||
this._retrieveMapEntries(creator, hash, doubleMapArg)));
|
||||
memo(this.#instanceId, (hash: Hash | Uint8Array | string, ...args: Arg[]): Observable<[StorageKey, Codec][]> =>
|
||||
this._retrieveMapEntries(creator, hash, args)));
|
||||
|
||||
decorated.entriesPaged = decorateMethod(
|
||||
memo(this.#instanceId, (opts: PaginationOptions): Observable<[StorageKey, Codec][]> =>
|
||||
this._retrieveMapEntriesPaged(creator, opts)));
|
||||
|
||||
decorated.keys = decorateMethod(
|
||||
memo(this.#instanceId, (doubleMapArg?: Arg): Observable<StorageKey[]> =>
|
||||
this._retrieveMapKeys(creator, null, doubleMapArg)));
|
||||
memo(this.#instanceId, (...args: Arg[]): Observable<StorageKey[]> =>
|
||||
this._retrieveMapKeys(creator, null, args)));
|
||||
|
||||
decorated.keysAt = decorateMethod(
|
||||
memo(this.#instanceId, (hash: Hash | Uint8Array | string, doubleMapArg?: Arg): Observable<StorageKey[]> =>
|
||||
this._retrieveMapKeys(creator, hash, doubleMapArg)));
|
||||
memo(this.#instanceId, (hash: Hash | Uint8Array | string, ...args: Arg[]): Observable<StorageKey[]> =>
|
||||
this._retrieveMapKeys(creator, hash, args)));
|
||||
|
||||
decorated.keysPaged = decorateMethod(
|
||||
memo(this.#instanceId, (opts: PaginationOptions): Observable<StorageKey[]> =>
|
||||
@@ -447,7 +452,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
});
|
||||
}
|
||||
|
||||
private _decorateStorageRange<ApiType extends ApiTypes> (decorated: QueryableStorageEntry<ApiType>, args: [Arg?, Arg?], range: [Hash, Hash?]): Observable<[Hash, Codec][]> {
|
||||
private _decorateStorageRange<ApiType extends ApiTypes> (decorated: QueryableStorageEntry<ApiType>, args: Arg[], range: [Hash, Hash?]): Observable<[Hash, Codec][]> {
|
||||
const outputType = unwrapStorageType(decorated.creator.meta.type, decorated.creator.meta.modifier.isOptional);
|
||||
|
||||
return this._rpcCore.state
|
||||
@@ -478,10 +483,10 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
);
|
||||
}
|
||||
|
||||
private _retrieveMapKeys ({ iterKey, meta, method, section }: StorageEntry, at: Hash | Uint8Array | string | null, arg?: Arg): Observable<StorageKey[]> {
|
||||
assert(iterKey && (meta.type.isMap || meta.type.isDoubleMap), 'keys can only be retrieved on maps, linked maps and double maps');
|
||||
private _retrieveMapKeys ({ iterKey, meta, method, section }: StorageEntry, at: Hash | Uint8Array | string | null, args: Arg[]): Observable<StorageKey[]> {
|
||||
assert(iterKey && (meta.type.isMap || meta.type.isDoubleMap || meta.type.isNMap), 'keys can only be retrieved on maps, linked maps and double maps');
|
||||
|
||||
const headKey = iterKey(arg).toHex();
|
||||
const headKey = iterKey(...args).toHex();
|
||||
const startSubject = new BehaviorSubject<string>(headKey);
|
||||
const query = at
|
||||
? (startKey: string) => this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE, startKey, at)
|
||||
@@ -506,21 +511,21 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
}
|
||||
|
||||
private _retrieveMapKeysPaged ({ iterKey, meta, method, section }: StorageEntry, opts: PaginationOptions): Observable<StorageKey[]> {
|
||||
assert(iterKey && (meta.type.isMap || meta.type.isDoubleMap), 'keys can only be retrieved on maps, linked maps and double maps');
|
||||
assert(iterKey && (meta.type.isMap || meta.type.isDoubleMap || meta.type.isNMap), 'keys can only be retrieved on maps, linked maps and double maps');
|
||||
|
||||
const headKey = iterKey(opts.arg).toHex();
|
||||
const headKey = iterKey(...opts.args).toHex();
|
||||
|
||||
return this._rpcCore.state.getKeysPaged(headKey, opts.pageSize, opts.startKey || headKey).pipe(
|
||||
map((keys) => keys.map((key) => key.setMeta(meta, section, method)))
|
||||
);
|
||||
}
|
||||
|
||||
private _retrieveMapEntries (entry: StorageEntry, at: Hash | Uint8Array | string | null, arg?: Arg): Observable<[StorageKey, Codec][]> {
|
||||
private _retrieveMapEntries (entry: StorageEntry, at: Hash | Uint8Array | string | null, args: Arg[]): Observable<[StorageKey, Codec][]> {
|
||||
const query = at
|
||||
? (keyset: StorageKey[]) => this._rpcCore.state.queryStorageAt(keyset, at)
|
||||
: (keyset: StorageKey[]) => this._rpcCore.state.queryStorageAt(keyset);
|
||||
|
||||
return this._retrieveMapKeys(entry, at, arg).pipe(
|
||||
return this._retrieveMapKeys(entry, at, args).pipe(
|
||||
switchMap((keys) =>
|
||||
keys.length
|
||||
? combineLatest(arrayChunk(keys, PAGE_SIZE).map(query)).pipe(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { RpcInterfaceMethod } from '@polkadot/rpc-core/types';
|
||||
import type { Text } from '@polkadot/types';
|
||||
import type { ChainProperties, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
@@ -13,16 +14,15 @@ import BN from 'bn.js';
|
||||
import { Metadata } from '@polkadot/metadata';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
import { getSpecAlias, getSpecExtensions, getSpecHasher, getSpecRpc, getSpecTypes, getUpgradeVersion } from '@polkadot/types-known';
|
||||
import { assert, BN_ZERO, logger, u8aEq, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
import { assert, BN_ZERO, logger, stringify, u8aEq, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
import { cryptoWaitReady } from '@polkadot/util-crypto';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { detectedCapabilities } from './capabilities';
|
||||
import { Decorate } from './Decorate';
|
||||
import { detectedCapabilities } from './util';
|
||||
|
||||
const KEEPALIVE_INTERVAL = 15000;
|
||||
const DEFAULT_BLOCKNUMBER = { unwrap: () => BN_ZERO };
|
||||
const KEEPALIVE_INTERVAL = 10000;
|
||||
|
||||
const l = logger('api/init');
|
||||
|
||||
@@ -31,7 +31,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
|
||||
#registries: VersionedRegistry[] = [];
|
||||
|
||||
#updateSub?: Subscription;
|
||||
#updateSub?: Subscription | null = null;
|
||||
|
||||
constructor (options: ApiOptions, type: ApiTypes, decorateMethod: DecorateMethod<ApiType>) {
|
||||
super(options, type, decorateMethod);
|
||||
@@ -58,7 +58,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
|
||||
this._rx.signer = options.signer;
|
||||
|
||||
this._rpcCore.setRegistrySwap((hash: string | Uint8Array) => this.getBlockRegistry(hash));
|
||||
this._rpcCore.setRegistrySwap((blockHash: Uint8Array) => this.getBlockRegistry(blockHash));
|
||||
|
||||
if (this.hasSubscriptions) {
|
||||
this._rpcCore.provider.on('disconnected', this.#onProviderDisconnect);
|
||||
@@ -102,10 +102,10 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
/**
|
||||
* @description Sets up a registry based on the block hash defined
|
||||
*/
|
||||
public async getBlockRegistry (blockHash: string | Uint8Array): Promise<VersionedRegistry> {
|
||||
// shortcut in the case where we have an immediate-same request
|
||||
const lastBlockHash = u8aToU8a(blockHash);
|
||||
const existingViaHash = this.#registries.find((r) => r.lastBlockHash && u8aEq(lastBlockHash, r.lastBlockHash));
|
||||
public async getBlockRegistry (blockHash: Uint8Array): Promise<VersionedRegistry> {
|
||||
const existingViaHash = this.#registries.find(({ lastBlockHash }) =>
|
||||
lastBlockHash && u8aEq(lastBlockHash, blockHash)
|
||||
);
|
||||
|
||||
if (existingViaHash) {
|
||||
return existingViaHash;
|
||||
@@ -116,39 +116,45 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
|
||||
// We have to assume that on the RPC layer the calls used here does not call back into
|
||||
// the registry swap, so getHeader & getRuntimeVersion should not be historic
|
||||
const header = this._genesisHash.eq(blockHash)
|
||||
? { number: DEFAULT_BLOCKNUMBER, parentHash: this._genesisHash }
|
||||
: await this._rpcCore.chain.getHeader(blockHash).toPromise();
|
||||
const header = this.registry.createType('HeaderPartial',
|
||||
this._genesisHash.eq(blockHash)
|
||||
? { number: BN_ZERO, parentHash: this._genesisHash }
|
||||
: await (this._rpcCore.chain.getHeader as RpcInterfaceMethod).json(blockHash).toPromise()
|
||||
);
|
||||
|
||||
assert(header?.parentHash && !header.parentHash.isEmpty, 'Unable to retrieve header and parent from supplied hash');
|
||||
assert(!header.parentHash.isEmpty, 'Unable to retrieve header and parent from supplied hash');
|
||||
|
||||
// get the runtime version, either on-chain or via an known upgrade history
|
||||
const [firstVersion, lastVersion] = getUpgradeVersion(this._genesisHash, header.number.unwrap());
|
||||
const version = (firstVersion && (lastVersion || firstVersion.specVersion.eq(this._runtimeVersion.specVersion)))
|
||||
? { specName: this._runtimeVersion.specName, specVersion: firstVersion.specVersion }
|
||||
: await this._rpcCore.state.getRuntimeVersion(header.parentHash).toPromise();
|
||||
const [firstVersion, lastVersion] = getUpgradeVersion(this._genesisHash, header.number);
|
||||
const version = this.registry.createType('RuntimeVersionPartial',
|
||||
(firstVersion && (lastVersion || firstVersion.specVersion.eq(this._runtimeVersion.specVersion)))
|
||||
? { specName: this._runtimeVersion.specName, specVersion: firstVersion.specVersion }
|
||||
: await (this._rpcCore.state.getRuntimeVersion as RpcInterfaceMethod).json(header.parentHash).toPromise()
|
||||
);
|
||||
|
||||
// check for pre-existing registries
|
||||
const existingViaVersion = this.#registries.find((r) => r.specVersion.eq(version.specVersion));
|
||||
const existingViaVersion = this.#registries.find(({ specVersion }) => specVersion.eq(version.specVersion));
|
||||
|
||||
if (existingViaVersion) {
|
||||
existingViaVersion.lastBlockHash = lastBlockHash;
|
||||
existingViaVersion.lastBlockHash = blockHash;
|
||||
|
||||
return existingViaVersion;
|
||||
}
|
||||
|
||||
// nothing has been found, construct new
|
||||
const metadata = await this._rpcCore.state.getMetadata(header.parentHash).toPromise();
|
||||
const metadata = new Metadata(this.registry,
|
||||
await (this._rpcCore.state.getMetadata as RpcInterfaceMethod).raw(header.parentHash).toPromise()
|
||||
);
|
||||
const registry = this._initRegistry(new TypeRegistry(blockHash), this._runtimeChain as Text, version, metadata);
|
||||
|
||||
// For now, since this is new we ignore the capability lookups (this could be useful once proven)
|
||||
// this._detectCapabilities(registry, blockHash);
|
||||
|
||||
// add our new registry
|
||||
const result = { isDefault: false, lastBlockHash, metadata, metadataConsts: null, registry, specVersion: version.specVersion };
|
||||
const result = { isDefault: false, lastBlockHash: blockHash, metadata, metadataConsts: null, registry, specVersion: version.specVersion };
|
||||
|
||||
this.#registries.push(result);
|
||||
|
||||
// TODO This could be useful for historic, disabled due to cross-looping, i.e. .at queries
|
||||
// this._detectCapabilities(registry, blockHash);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -156,10 +162,10 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
// on re-connection to the same chain, we don't want to re-do everything from chain again
|
||||
if (this._isReady) {
|
||||
return true;
|
||||
} else if (this.#updateSub) {
|
||||
this.#updateSub.unsubscribe();
|
||||
}
|
||||
|
||||
this._unsubscribeUpdates();
|
||||
|
||||
// only load from on-chain if we are not a clone (default path), alternatively
|
||||
// just use the values from the source instance provided
|
||||
[this._genesisHash, this._runtimeMetadata] = this._options.source?._isReady
|
||||
@@ -190,17 +196,19 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
return [source.genesisHash, source.runtimeMetadata];
|
||||
}
|
||||
|
||||
private _detectCapabilities (registry?: Registry, blockHash?: string | Uint8Array): void {
|
||||
private _detectCapabilities (registry: Registry, blockHash?: string | Uint8Array): boolean {
|
||||
detectedCapabilities(this._rx, blockHash)
|
||||
.toPromise()
|
||||
.then((types): void => {
|
||||
if (Object.keys(types).length) {
|
||||
(registry || this.registry).register(types as Record<string, string>);
|
||||
registry.register(types as Record<string, string>);
|
||||
|
||||
l.debug(`Capabilities detected${blockHash ? ` (${u8aToHex(u8aToU8a(blockHash))})` : ''}: ${JSON.stringify(types)}`);
|
||||
l.debug(() => `Capabilities detected${blockHash ? ` (${u8aToHex(u8aToU8a(blockHash))})` : ''}: ${stringify(types)}`);
|
||||
}
|
||||
})
|
||||
.catch(l.error);
|
||||
.catch(undefined);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// subscribe to metadata updates, inject the types on changes
|
||||
@@ -235,9 +243,8 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
// clear the registry types to ensure that we override correctly
|
||||
this._initRegistry(thisRegistry.registry.init(), this._runtimeChain as Text, version, metadata);
|
||||
this.injectMetadata(metadata, false, thisRegistry.registry);
|
||||
this._detectCapabilities(thisRegistry.registry);
|
||||
|
||||
return true;
|
||||
return this._detectCapabilities(thisRegistry.registry);
|
||||
})
|
||||
)
|
||||
)
|
||||
@@ -293,15 +300,36 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
|
||||
// inject metadata and adjust the types as detected
|
||||
this.injectMetadata(metadata, true);
|
||||
this._detectCapabilities();
|
||||
|
||||
// derive is last, since it uses the decorated rx
|
||||
this._rx.derive = this._decorateDeriveRx(this._rxDecorateMethod);
|
||||
this._derive = this._decorateDerive(this._decorateMethod);
|
||||
|
||||
// detect the on-chain capabilities
|
||||
this._detectCapabilities(this.registry);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private _unsubscribeHealth (): void {
|
||||
if (this.#healthTimer) {
|
||||
clearInterval(this.#healthTimer);
|
||||
this.#healthTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
private _unsubscribeUpdates (): void {
|
||||
if (this.#updateSub) {
|
||||
this.#updateSub.unsubscribe();
|
||||
this.#updateSub = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected _unsubscribe (): void {
|
||||
this._unsubscribeHealth();
|
||||
this._unsubscribeUpdates();
|
||||
}
|
||||
|
||||
#onProviderConnect = async (): Promise<void> => {
|
||||
this.emit('connected');
|
||||
this._isConnected.next(true);
|
||||
@@ -321,7 +349,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
}
|
||||
|
||||
this.#healthTimer = setInterval((): void => {
|
||||
this._rpcCore.system.health().toPromise().catch(() => null);
|
||||
this._rpcCore.system.health().toPromise().catch((error) => l.warn(`Health keepalive check failed: ${(error as Error).message}`));
|
||||
}, KEEPALIVE_INTERVAL);
|
||||
} catch (_error) {
|
||||
const error = new Error(`FATAL: Unable to initialize the API: ${(_error as Error).message}`);
|
||||
@@ -337,10 +365,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
this.emit('disconnected');
|
||||
this._isConnected.next(false);
|
||||
|
||||
if (this.#healthTimer) {
|
||||
clearInterval(this.#healthTimer);
|
||||
this.#healthTimer = null;
|
||||
}
|
||||
this._unsubscribeHealth();
|
||||
};
|
||||
|
||||
#onProviderError = (error: Error): void => {
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Raw, u32 } from '@polkadot/types';
|
||||
import type { Releases } from '@polkadot/types/interfaces';
|
||||
import type { InterfaceTypes } from '@polkadot/types/types';
|
||||
|
||||
import { assert, compactFromU8a } from '@polkadot/util';
|
||||
import { combineLatest, Observable, of } from '@polkadot/x-rxjs';
|
||||
import { catchError, map, take } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
// the order and types needs to map with the all array setup below
|
||||
type ExtractedQ = [Releases | null];
|
||||
|
||||
type ExtractedR = [Raw | null, Raw | null];
|
||||
|
||||
type ExtractedC = [u32 | null, u32 | null];
|
||||
|
||||
type DetectedKeys = keyof Pick<InterfaceTypes, 'AccountInfo' | 'ValidatorPrefs'>;
|
||||
|
||||
type DetectedValues = keyof InterfaceTypes;
|
||||
|
||||
interface DetectedTypes extends Record<DetectedKeys, DetectedValues> {
|
||||
AccountInfo: 'AccountInfoWithRefCount' | 'AccountInfoWithDualRefCount' | 'AccountInfoWithTripleRefCount',
|
||||
Keys: 'SessionKeys1' | 'SessionKeys2' | 'SessionKeys3' | 'SessionKeys4' | 'SessionKeys5' | 'SessionKeys6' | 'SessionKeys7' | 'SessionKeys8' | 'SessionKeys9' | 'SessionKeys10';
|
||||
RefCount: 'u8' | 'u32',
|
||||
SlotRange: Record<string, unknown>;
|
||||
ValidatorPrefs: 'ValidatorPrefsWithBlocked' | 'ValidatorPrefsWithCommission';
|
||||
WinningData: string;
|
||||
}
|
||||
|
||||
interface AvailableMap<T> {
|
||||
filtered: T[];
|
||||
included: boolean[];
|
||||
original: T[];
|
||||
}
|
||||
|
||||
interface Constants {
|
||||
accountIdLength: number;
|
||||
refcount1Length: number;
|
||||
refcount2Length: number;
|
||||
refcount3Length: number;
|
||||
}
|
||||
|
||||
const NumberMap = ['Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten'];
|
||||
|
||||
function mapCapabilities ({ accountIdLength, refcount1Length, refcount2Length, refcount3Length }: Constants, [leasePeriodsPerSlot, slotRangeCount]: ExtractedC, [stakingVersion]: ExtractedQ, [keys, accountInfo]: ExtractedR): Partial<DetectedTypes> {
|
||||
const types: Partial<DetectedTypes> = {};
|
||||
|
||||
// AccountInfo
|
||||
if (accountInfo) {
|
||||
const length = accountInfo.length;
|
||||
|
||||
if (length === refcount1Length) {
|
||||
types.AccountInfo = 'AccountInfoWithRefCount';
|
||||
} else if (length === refcount2Length) {
|
||||
types.AccountInfo = 'AccountInfoWithDualRefCount';
|
||||
} else if (length === refcount3Length) {
|
||||
types.AccountInfo = 'AccountInfoWithTripleRefCount';
|
||||
}
|
||||
}
|
||||
|
||||
// ValidatorPrefs
|
||||
if (stakingVersion) {
|
||||
if (stakingVersion.index >= 4) { // v1 = index 0, V5 = index 4
|
||||
types.ValidatorPrefs = 'ValidatorPrefsWithBlocked';
|
||||
} else {
|
||||
types.ValidatorPrefs = 'ValidatorPrefsWithCommission';
|
||||
}
|
||||
}
|
||||
|
||||
// Keys
|
||||
if (keys) {
|
||||
try {
|
||||
const [offset, numItems] = compactFromU8a(keys);
|
||||
const tupleLength = (keys.length - offset) / numItems.toNumber();
|
||||
const numIds = tupleLength / accountIdLength;
|
||||
const numIdsRound = Math.floor(numIds);
|
||||
|
||||
assert(numIds >= 2 && numIds <= 11, () => `Detected ${numIds} in Keys, should be >= 2 and <= 11`);
|
||||
|
||||
if (numIdsRound !== numIds) {
|
||||
// Beefy?
|
||||
if ((((numIdsRound - 1) * accountIdLength) + 33) === tupleLength) {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
types.Keys = `SessionKeys${numIdsRound - 1}B`;
|
||||
} else {
|
||||
assert(false, () => `Expected integer number of keys, found ${numIds.toFixed(2)}`);
|
||||
}
|
||||
} else {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
types.Keys = `SessionKeys${numIds - 1}`;
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
// auctions
|
||||
if (leasePeriodsPerSlot && slotRangeCount) {
|
||||
const _enum: string[] = [];
|
||||
|
||||
for (let i = 0; leasePeriodsPerSlot.gtn(i); i++) {
|
||||
for (let j = i; leasePeriodsPerSlot.gtn(j); j++) {
|
||||
_enum.push(`${NumberMap[i]}${NumberMap[j]}`);
|
||||
}
|
||||
}
|
||||
|
||||
types.SlotRange = { _enum };
|
||||
types.WinningData = `[WinningDataEntry; ${slotRangeCount.toNumber()}]`;
|
||||
}
|
||||
|
||||
return types;
|
||||
}
|
||||
|
||||
function filterEntries <T> (original: T[]): AvailableMap<T> {
|
||||
const included = original.map((c) => !!c);
|
||||
|
||||
return {
|
||||
filtered: original.filter((_, index) => included[index]),
|
||||
included,
|
||||
original
|
||||
};
|
||||
}
|
||||
|
||||
function extractResults <R, T = unknown> (results: unknown[], map: AvailableMap<T>): R {
|
||||
let offset = -1;
|
||||
|
||||
return map.included.map((isIncluded) =>
|
||||
isIncluded
|
||||
? results[++offset]
|
||||
: null
|
||||
) as unknown as R;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Query the chain for the specific capabilities
|
||||
*/
|
||||
export function detectedCapabilities (api: ApiInterfaceRx, blockHash?: Uint8Array | string | undefined): Observable<Partial<DetectedTypes>> {
|
||||
const emptyAccountId = api.registry.createType('AccountId');
|
||||
const consts = filterEntries([
|
||||
api.consts.auctions?.leasePeriodsPerSlot,
|
||||
api.consts.auctions?.slotRangeCount
|
||||
]);
|
||||
const queries = filterEntries([
|
||||
api.query.staking?.storageVersion
|
||||
]);
|
||||
const raws = filterEntries([
|
||||
api.query.session?.queuedKeys.key(),
|
||||
api.query.system?.account?.key(emptyAccountId)
|
||||
]);
|
||||
|
||||
return combineLatest([
|
||||
consts.filtered.length
|
||||
? blockHash
|
||||
// FIXME consts don't have .at as of yet...
|
||||
? of([])
|
||||
: of(consts.filtered)
|
||||
: of([]),
|
||||
queries.filtered.length
|
||||
? blockHash
|
||||
? combineLatest(queries.filtered.map((c) => c.at(blockHash)))
|
||||
: api.queryMulti(queries.filtered)
|
||||
: of([]),
|
||||
raws.filtered.length
|
||||
? blockHash
|
||||
? combineLatest(raws.filtered.map((k) => api.rpc.state.getStorage.raw(k, blockHash)))
|
||||
: combineLatest(raws.filtered.map((k) => api.rpc.state.getStorage.raw(k)))
|
||||
: of([])
|
||||
]).pipe(
|
||||
map(([cResults, qResults, rResults]): Partial<DetectedTypes> =>
|
||||
mapCapabilities(
|
||||
{
|
||||
accountIdLength: emptyAccountId.encodedLength,
|
||||
refcount1Length: api.registry.createType('AccountInfoWithRefCount').encodedLength,
|
||||
refcount2Length: api.registry.createType('AccountInfoWithDualRefCount').encodedLength,
|
||||
refcount3Length: api.registry.createType('AccountInfoWithTripleRefCount').encodedLength
|
||||
},
|
||||
extractResults<ExtractedC>(cResults, consts),
|
||||
extractResults<ExtractedQ>(qResults, queries),
|
||||
extractResults<ExtractedR>(rResults, raws)
|
||||
)
|
||||
),
|
||||
take(1),
|
||||
catchError(() => of({}))
|
||||
);
|
||||
}
|
||||
@@ -50,6 +50,8 @@ export abstract class ApiBase<ApiType extends ApiTypes> extends Getters<ApiType>
|
||||
* @description Disconnect from the underlying provider, halting all network traffic
|
||||
*/
|
||||
public disconnect (): Promise<void> {
|
||||
this._unsubscribe();
|
||||
|
||||
return this._rpcCore.disconnect();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { bool } from '@polkadot/types';
|
||||
import type { Releases } from '@polkadot/types/interfaces';
|
||||
import type { InterfaceTypes } from '@polkadot/types/types';
|
||||
|
||||
import { combineLatest, Observable, of } from '@polkadot/x-rxjs';
|
||||
import { map, take } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
// the order and types needs to map with the all array setup below
|
||||
type Extracted = [bool | null, bool | null, bool | null, Releases | null];
|
||||
|
||||
type DetectedKeys = keyof Pick<InterfaceTypes, 'AccountInfo' | 'ValidatorPrefs'>;
|
||||
|
||||
type DetectedValues = keyof InterfaceTypes;
|
||||
|
||||
interface DetectedTypes extends Record<DetectedKeys, DetectedValues> {
|
||||
AccountInfo: 'AccountInfoWithRefCount' | 'AccountInfoWithDualRefCount' | 'AccountInfoWithTripleRefCount',
|
||||
RefCount: 'u8' | 'u32',
|
||||
ValidatorPrefs: 'ValidatorPrefsWithBlocked' | 'ValidatorPrefsWithCommission';
|
||||
}
|
||||
|
||||
function mapCapabilities ([systemRefcount32, systemRefcountDual, systemRefcountTriple, stakingVersion]: Extracted): Partial<DetectedTypes> {
|
||||
const types: Partial<DetectedTypes> = {};
|
||||
|
||||
// AccountInfo
|
||||
if (systemRefcountTriple && systemRefcountTriple.isTrue) {
|
||||
types.AccountInfo = 'AccountInfoWithTripleRefCount';
|
||||
} else if (systemRefcountDual && systemRefcountDual.isTrue) {
|
||||
types.AccountInfo = 'AccountInfoWithDualRefCount';
|
||||
} else {
|
||||
types.AccountInfo = 'AccountInfoWithRefCount';
|
||||
|
||||
if (!systemRefcount32 || systemRefcount32.isFalse) {
|
||||
types.RefCount = 'u8';
|
||||
}
|
||||
}
|
||||
|
||||
// ValidatorPrefs
|
||||
if (stakingVersion) {
|
||||
if (stakingVersion.index >= 4) { // v1 = index 0, V5 = index 4
|
||||
types.ValidatorPrefs = 'ValidatorPrefsWithBlocked';
|
||||
} else {
|
||||
types.ValidatorPrefs = 'ValidatorPrefsWithCommission';
|
||||
}
|
||||
}
|
||||
|
||||
return types;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Query the chain for the specific capabilities
|
||||
*/
|
||||
export function detectedCapabilities (api: ApiInterfaceRx, blockHash?: Uint8Array | string | undefined): Observable<Partial<DetectedTypes>> {
|
||||
const all = [
|
||||
api.query.system?.upgradedToU32RefCount,
|
||||
api.query.system?.upgradedToDualRefCount,
|
||||
api.query.system?.upgradedToTripleRefCount,
|
||||
api.query.staking?.storageVersion
|
||||
];
|
||||
const included = all.map((c) => !!c);
|
||||
const filtered = all.filter((_, index) => included[index]);
|
||||
|
||||
return (
|
||||
filtered.length
|
||||
? blockHash
|
||||
? combineLatest(filtered.map((c) => c.at(blockHash)))
|
||||
: api.queryMulti(filtered)
|
||||
: of([])
|
||||
).pipe(
|
||||
map((results): Partial<DetectedTypes> => {
|
||||
let offset = -1;
|
||||
|
||||
return mapCapabilities(
|
||||
included.map((isIncluded) => isIncluded ? results[++offset] : null) as Extracted
|
||||
);
|
||||
}),
|
||||
take(1)
|
||||
);
|
||||
}
|
||||
@@ -3,12 +3,12 @@
|
||||
|
||||
// Simple non-runnable checks to test type definitions in the editor itself
|
||||
|
||||
import type { HeaderExtended } from '@polkadot/api-derive/types';
|
||||
import type { StorageKey } from '@polkadot/types';
|
||||
import type { AccountId, Balance, DispatchErrorModule, Event, Header, Index } from '@polkadot/types/interfaces';
|
||||
import type { AnyTuple, IExtrinsic, IMethod } from '@polkadot/types/types';
|
||||
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import { HeaderExtended } from '@polkadot/api-derive';
|
||||
import { createTestPairs, TestKeyringMap } from '@polkadot/keyring/testingPairs';
|
||||
import { createTypeUnsafe, TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
@@ -129,6 +129,12 @@ async function queryExtra (api: ApiPromise, pairs: TestKeyringMap): Promise<void
|
||||
await api.query.system.account.entries(); // should not take a param
|
||||
await api.query.staking.nominatorSlashInEra.entries(123); // should take a param
|
||||
|
||||
// nmap with keys
|
||||
await api.query.assets.approvals.keys(123, 'blah');
|
||||
await api.query.assets.account.keys(123);
|
||||
await api.query.assets.account.entries(123);
|
||||
await api.query.assets.blah.keys();
|
||||
|
||||
// check range
|
||||
await api.query.balances.freeBalance.range<Balance>(['0x1234'], pairs.bob.address);
|
||||
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api', version: '4.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/api', version: '4.11.2' };
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiOptions, SubmittableExtrinsic } from '../types';
|
||||
import type { SubmittableExtrinsic } from '../types';
|
||||
|
||||
import { createPair } from '@polkadot/keyring/pair';
|
||||
import { createTestKeyring } from '@polkadot/keyring/testing';
|
||||
@@ -44,23 +44,16 @@ describe('ApiPromise', (): void => {
|
||||
}
|
||||
|
||||
beforeEach((): void => {
|
||||
jest.setTimeout(3000000);
|
||||
jest.setTimeout(10000);
|
||||
provider = new MockProvider(registry);
|
||||
});
|
||||
|
||||
describe('initialization', (): void => {
|
||||
it('Create API instance with metadata map and makes the runtime, rpc, state & extrinsics available', async (): Promise<void> => {
|
||||
const rpcData = await provider.send('state_getMetadata', []);
|
||||
const rpcData = await provider.send<string>('state_getMetadata', []);
|
||||
const genesisHash = registry.createType('Hash', await provider.send('chain_getBlockHash', [])).toHex();
|
||||
const specVersion = 0;
|
||||
const metadata: any = {};
|
||||
const key = `${genesisHash}-${specVersion}`;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
metadata[key] = rpcData;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const api = await ApiPromise.create({ metadata, provider, registry } as ApiOptions);
|
||||
const api = await ApiPromise.create({ metadata: { [`${genesisHash}-${specVersion}`]: rpcData }, provider, registry });
|
||||
|
||||
expect(api.genesisHash).toBeDefined();
|
||||
expect(api.runtimeMetadata).toBeDefined();
|
||||
|
||||
@@ -211,7 +211,19 @@ export class ApiPromise extends ApiBase<'promise'> {
|
||||
* ```
|
||||
*/
|
||||
public static create (options?: ApiOptions): Promise<ApiPromise> {
|
||||
return new ApiPromise(options).isReady;
|
||||
const instance = new ApiPromise(options);
|
||||
|
||||
if (options && options.throwOnConnect) {
|
||||
return instance.isReadyOrError;
|
||||
}
|
||||
|
||||
// Swallow any rejections on isReadyOrError
|
||||
// (in Node 15.x this creates issues, when not being looked at)
|
||||
instance.isReadyOrError.catch(() => {
|
||||
// ignore
|
||||
});
|
||||
|
||||
return instance.isReady;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -235,18 +247,14 @@ export class ApiPromise extends ApiBase<'promise'> {
|
||||
super(options, 'promise', decorateMethod);
|
||||
|
||||
this.#isReadyPromise = new Promise((resolve): void => {
|
||||
super.once('ready', (): void => {
|
||||
resolve(this);
|
||||
});
|
||||
super.once('ready', () => resolve(this));
|
||||
});
|
||||
|
||||
this.#isReadyOrErrorPromise = new Promise((resolve, reject): void => {
|
||||
super.once('ready', (): void => {
|
||||
resolve(this);
|
||||
});
|
||||
super.once('error', (e): void => {
|
||||
reject(e);
|
||||
});
|
||||
const tracker = promiseTracker(resolve, reject);
|
||||
|
||||
super.once('ready', () => tracker.resolve(this));
|
||||
super.once('error', (e) => tracker.reject(e));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -165,9 +165,7 @@ export class ApiRx extends ApiBase<'rxjs'> {
|
||||
this.#isReadyRx = from<Promise<ApiRx>>(
|
||||
// You can create an observable from an event, however my mind groks this form better
|
||||
new Promise((resolve): void => {
|
||||
super.on('ready', (): void => {
|
||||
resolve(this);
|
||||
});
|
||||
super.on('ready', () => resolve(this));
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -32,14 +32,17 @@ export class SubmittableResult implements ISubmittableResult {
|
||||
|
||||
public readonly dispatchInfo?: DispatchInfo;
|
||||
|
||||
public readonly internalError?: Error;
|
||||
|
||||
public readonly events: EventRecord[];
|
||||
|
||||
public readonly status: ExtrinsicStatus;
|
||||
|
||||
constructor ({ dispatchError, dispatchInfo, events, status }: SubmittableResultValue) {
|
||||
constructor ({ dispatchError, dispatchInfo, events, internalError, status }: SubmittableResultValue) {
|
||||
this.dispatchError = dispatchError || extractError(events);
|
||||
this.dispatchInfo = dispatchInfo || extractInfo(events);
|
||||
this.events = events || [];
|
||||
this.internalError = internalError;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@@ -85,6 +88,7 @@ export class SubmittableResult implements ISubmittableResult {
|
||||
dispatchError: this.dispatchError?.toHuman(),
|
||||
dispatchInfo: this.dispatchInfo?.toHuman(),
|
||||
events: this.events.map((event) => event.toHuman(isExtended)),
|
||||
internalError: this.internalError?.message.toString(),
|
||||
status: this.status.toHuman(isExtended)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import type { AddressOrPair, SignerOptions, SubmittableDryRunResult, Submittable
|
||||
|
||||
import { assert, isBn, isFunction, isNumber, isString, isU8a } from '@polkadot/util';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { first, map, mapTo, mergeMap, switchMap, tap } from '@polkadot/x-rxjs/operators';
|
||||
import { catchError, first, map, mapTo, mergeMap, switchMap, tap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { ApiBase } from '../base';
|
||||
import { filterEvents, isKeyringPair } from '../util';
|
||||
@@ -242,6 +242,9 @@ export function createClass <ApiType extends ApiTypes> ({ api, apiType, decorate
|
||||
events: filterEvents(hash, block, events, status),
|
||||
status
|
||||
}))
|
||||
),
|
||||
catchError((internalError: Error) =>
|
||||
of(this.#transformResult(new SubmittableResult({ internalError, status })))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ export interface SubmittableResultValue {
|
||||
dispatchError?: DispatchError;
|
||||
dispatchInfo?: DispatchInfo;
|
||||
events?: EventRecord[];
|
||||
internalError?: Error;
|
||||
status: ExtrinsicStatus;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,30 +1,12 @@
|
||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
import type { AnyFunction, Callback, Codec, CodecArg } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
// Prepend an element V onto the beginning of a tuple T.
|
||||
// Cons<1, [2,3,4]> is [1,2,3,4]
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export type Cons<V, T extends any[]> = ((v: V, ...t: T) => void) extends ((...r: infer R) => void)
|
||||
? R
|
||||
: never;
|
||||
export type Push<T extends readonly unknown[], V> = [...T, V]
|
||||
|
||||
// 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]
|
||||
export 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 DropLast<T extends readonly unknown[]> = T extends readonly [...infer U, any?] ? U : [...T];
|
||||
|
||||
export type ApiTypes = 'promise' | 'rxjs';
|
||||
|
||||
@@ -75,8 +57,9 @@ export interface DecorateMethodOptions {
|
||||
|
||||
export type DecorateFn <T extends Codec> = (...args: any[]) => Observable<T>;
|
||||
|
||||
// FIXME We need a solution for NMap
|
||||
export interface PaginationOptions<ArgType = CodecArg> {
|
||||
arg?: ArgType;
|
||||
args: ArgType[];
|
||||
pageSize: number;
|
||||
startKey?: string;
|
||||
}
|
||||
|
||||
@@ -69,6 +69,10 @@ export interface ApiOptions extends RegisteredTypes {
|
||||
* @description The source object to use for runtime information (only used when cloning)
|
||||
*/
|
||||
source?: ApiBase<any>;
|
||||
/**
|
||||
* @description Throws an error when the initial connection fails (same as isReadyOrError)
|
||||
*/
|
||||
throwOnConnect?: boolean;
|
||||
}
|
||||
|
||||
// A smaller interface of ApiRx, used in derive and in SubmittableExtrinsic
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Json, Raw } from '@polkadot/types/codec';
|
||||
import type { AnyFunction, Callback } from '@polkadot/types/types';
|
||||
import type { AnyFunction, Callback, DefinitionRpc } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
@@ -11,6 +11,7 @@ import { ApiTypes, PromiseResult, Push, RxResult, UnsubscribePromise } from './b
|
||||
export interface RpcRxResult<F extends AnyFunction> extends RxResult<F> {
|
||||
json (...args: Parameters<F>): Observable<Json>;
|
||||
raw (...args: Parameters<F>): Observable<Raw>;
|
||||
meta: DefinitionRpc;
|
||||
}
|
||||
|
||||
export interface RpcPromiseResult<F extends AnyFunction> extends PromiseResult<F> {
|
||||
@@ -18,6 +19,7 @@ export interface RpcPromiseResult<F extends AnyFunction> extends PromiseResult<F
|
||||
json (...args: Push<Parameters<F>, Callback<Json>>): UnsubscribePromise;
|
||||
raw (...args: Parameters<F>): Promise<Raw>;
|
||||
raw (...args: Push<Parameters<F>, Callback<Raw>>): UnsubscribePromise;
|
||||
meta: DefinitionRpc;
|
||||
}
|
||||
|
||||
export type RpcMethodResult<ApiType extends ApiTypes, F extends AnyFunction> = ApiType extends 'rxjs'
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { Hash } from '@polkadot/types/interfaces';
|
||||
import type { StorageEntry } from '@polkadot/types/primitive/types';
|
||||
import type { AnyFunction, AnyTuple, Callback, Codec, CodecArg, IStorageKey } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { ApiTypes, MethodResult, ObsInnerType, PaginationOptions, PromiseOrObs, UnsubscribePromise } from './base';
|
||||
import type { ApiTypes, DropLast, MethodResult, ObsInnerType, PaginationOptions, PromiseOrObs, UnsubscribePromise } from './base';
|
||||
|
||||
interface StorageEntryObservableMulti {
|
||||
<T extends Codec>(args: (CodecArg[] | CodecArg)[]): Observable<T[]>;
|
||||
@@ -18,15 +18,16 @@ interface StorageEntryPromiseMulti {
|
||||
}
|
||||
|
||||
export interface StorageEntryPromiseOverloads {
|
||||
(arg1?: CodecArg, arg2?: CodecArg): Promise<Codec>;
|
||||
<T extends Codec>(arg1?: CodecArg, arg2?: CodecArg): Promise<T>;
|
||||
(arg1?: CodecArg, arg2?: CodecArg, arg3?: CodecArg): Promise<Codec>;
|
||||
<T extends Codec>(arg1?: CodecArg, arg2?: CodecArg, arg3?: 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;
|
||||
<T extends Codec>(arg1: CodecArg, arg2: CodecArg, arg3: CodecArg, callback: Callback<T>): UnsubscribePromise;
|
||||
}
|
||||
|
||||
// This is the most generic typings we can have for a storage entry function
|
||||
type GenericStorageEntryFunction = (arg1?: CodecArg, arg2?: CodecArg) => Observable<Codec>
|
||||
type GenericStorageEntryFunction = (...args: CodecArg[]) => Observable<Codec>
|
||||
|
||||
export type QueryableStorageEntry<ApiType extends ApiTypes, A extends AnyTuple = AnyTuple> =
|
||||
ApiType extends 'rxjs'
|
||||
@@ -38,15 +39,15 @@ export type QueryableStorageEntry<ApiType extends ApiTypes, A extends AnyTuple =
|
||||
export interface StorageEntryBase<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> {
|
||||
at: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(hash: Hash | Uint8Array | string, ...args: Parameters<F>) => PromiseOrObs<ApiType, T>;
|
||||
creator: StorageEntry;
|
||||
entries: <T extends Codec | any = ObsInnerType<ReturnType<F>>, K extends AnyTuple = A>(arg?: Parameters<F>[0]) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
|
||||
entriesAt: <T extends Codec | any = ObsInnerType<ReturnType<F>>, K extends AnyTuple = A>(hash: Hash | Uint8Array | string, arg?: Parameters<F>[0]) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
|
||||
entries: <T extends Codec | any = ObsInnerType<ReturnType<F>>, K extends AnyTuple = A>(...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
|
||||
entriesAt: <T extends Codec | any = ObsInnerType<ReturnType<F>>, K extends AnyTuple = A>(hash: Hash | Uint8Array | string, ...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
|
||||
entriesPaged: <T extends Codec | any = ObsInnerType<ReturnType<F>>, K extends AnyTuple = A>(opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
|
||||
hash: (...args: Parameters<F>) => PromiseOrObs<ApiType, Hash>;
|
||||
is: (key: IStorageKey<AnyTuple>) => key is IStorageKey<A>;
|
||||
key: (...args: Parameters<F>) => string;
|
||||
keyPrefix: () => string;
|
||||
keys: <K extends AnyTuple = A> (arg?: any) => PromiseOrObs<ApiType, StorageKey<K>[]>;
|
||||
keysAt: <K extends AnyTuple = A> (hash: Hash | Uint8Array | string, arg?: any) => PromiseOrObs<ApiType, StorageKey<K>[]>;
|
||||
keyPrefix: (...args: DropLast<Parameters<F>>) => string;
|
||||
keys: <K extends AnyTuple = A> (...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, StorageKey<K>[]>;
|
||||
keysAt: <K extends AnyTuple = A> (hash: Hash | Uint8Array | string, ...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, StorageKey<K>[]>;
|
||||
keysPaged: <K extends AnyTuple = A> (opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, StorageKey<K>[]>;
|
||||
// @deprecated The underlying RPC this been marked unsafe and is generally not exposed
|
||||
range: <T extends Codec | any = ObsInnerType<ReturnType<F>>>([from, to]: [Hash | Uint8Array | string, Hash | Uint8Array | string | undefined] | [Hash | Uint8Array | string], ...args: Parameters<F>) => PromiseOrObs<ApiType, [Hash, T][]>;
|
||||
@@ -80,10 +81,7 @@ export type QueryableStorageMulti<ApiType extends ApiTypes> =
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface,@typescript-eslint/no-unused-vars
|
||||
export interface AugmentedQueries<ApiType extends ApiTypes> { }
|
||||
|
||||
export interface StorageEntryDoubleMap<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple> extends StorageEntryBase<ApiType, F, A> {
|
||||
keyPrefix: (key1?: Parameters<F>[0]) => string;
|
||||
}
|
||||
|
||||
export type AugmentedQuery<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> = MethodResult<ApiType, F> & StorageEntryBase<ApiType, F, A>;
|
||||
|
||||
export type AugmentedQueryDoubleMap<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> = MethodResult<ApiType, F> & StorageEntryDoubleMap<ApiType, F, A>;
|
||||
// backwards compatibility-only
|
||||
export type AugmentedQueryDoubleMap<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> = AugmentedQuery<ApiType, F, A>;
|
||||
|
||||
@@ -66,14 +66,14 @@ describe('extractStorageArgs', (): void => {
|
||||
expect(
|
||||
(): any =>
|
||||
extractStorageArgs(storage.staking.erasStakers, [])
|
||||
).toThrow('staking.erasStakers(EraIndex, AccountId) is a doublemap, requiring 2 arguments, 0 found');
|
||||
).toThrow('staking.erasStakers(EraIndex, AccountId) is a double map, requiring 2 arguments, 0 found');
|
||||
});
|
||||
|
||||
it('validates doublemap, 2 args (failing with 1 arg)', (): void => {
|
||||
expect(
|
||||
(): any =>
|
||||
extractStorageArgs(storage.staking.erasStakers, [123])
|
||||
).toThrow('staking.erasStakers(EraIndex, AccountId) is a doublemap, requiring 2 arguments, 1 found');
|
||||
).toThrow('staking.erasStakers(EraIndex, AccountId) is a double map, requiring 2 arguments, 1 found');
|
||||
});
|
||||
|
||||
// Linked maps have been removed
|
||||
|
||||
@@ -6,14 +6,14 @@ import type { StorageEntry } from '@polkadot/types/primitive/types';
|
||||
|
||||
import { assert, isUndefined } from '@polkadot/util';
|
||||
|
||||
function sig ({ method, section }: StorageEntry, ...args: Type[]): string {
|
||||
function sig ({ method, section }: StorageEntry, args: Type[]): string {
|
||||
return `${section}.${method}(${args.join(', ')})`;
|
||||
}
|
||||
|
||||
function doDoubleMap (creator: StorageEntry, args: unknown[]): [StorageEntry, [any, any]] {
|
||||
const { key1, key2 } = creator.meta.type.asDoubleMap;
|
||||
|
||||
assert(args.length === 2, `${sig(creator, key1, key2)} is a doublemap, requiring 2 arguments, ${args.length} found`);
|
||||
assert(args.length === 2, () => `${sig(creator, [key1, key2])} is a double map, requiring 2 arguments, ${args.length} found`);
|
||||
|
||||
// pass as tuple
|
||||
return [creator, args as [any, any]];
|
||||
@@ -22,7 +22,7 @@ function doDoubleMap (creator: StorageEntry, args: unknown[]): [StorageEntry, [a
|
||||
function doMap (creator: StorageEntry, args: unknown[]): [StorageEntry] | [StorageEntry, any] {
|
||||
const { key } = creator.meta.type.asMap;
|
||||
|
||||
assert(args.length === 1, `${sig(creator, key)} is a map, requiring 1 argument, ${args.length} found`);
|
||||
assert(args.length === 1, () => `${sig(creator, [key])} is a map, requiring 1 argument, ${args.length} found`);
|
||||
|
||||
// expand
|
||||
return args.length
|
||||
@@ -30,18 +30,29 @@ function doMap (creator: StorageEntry, args: unknown[]): [StorageEntry] | [Stora
|
||||
: [creator];
|
||||
}
|
||||
|
||||
function doNMap (creator: StorageEntry, args: unknown[]): [StorageEntry, any[]] {
|
||||
const { keyVec } = creator.meta.type.asNMap;
|
||||
|
||||
assert(args.length === keyVec.length, () => `${sig(creator, keyVec)} is a multi map, requiring ${keyVec.length} arguments, ${args.length} found`);
|
||||
|
||||
// pass as tuple
|
||||
return [creator, args];
|
||||
}
|
||||
|
||||
// sets up the arguments in the form of [creator, args] ready to be used in a storage
|
||||
// call. Additionally, it verifies that the correct number of arguments have been passed
|
||||
export function extractStorageArgs (creator: StorageEntry, _args: unknown[]): [StorageEntry, [any, any]] | [StorageEntry] | [StorageEntry, any] {
|
||||
export function extractStorageArgs (creator: StorageEntry, _args: unknown[]): [StorageEntry, any[]] | [StorageEntry] | [StorageEntry, any] {
|
||||
const args = _args.filter((arg) => !isUndefined(arg));
|
||||
|
||||
if (creator.meta.type.isDoubleMap) {
|
||||
return doDoubleMap(creator, args);
|
||||
} else if (creator.meta.type.isMap) {
|
||||
return doMap(creator, args);
|
||||
} else if (creator.meta.type.isNMap) {
|
||||
return doNMap(creator, args);
|
||||
}
|
||||
|
||||
assert(args.length === 0, `${sig(creator)} does not take any arguments, ${args.length} found`);
|
||||
assert(args.length === 0, () => `${sig(creator, [])} does not take any arguments, ${args.length} found`);
|
||||
|
||||
// no args
|
||||
return [creator];
|
||||
|
||||
@@ -14,7 +14,7 @@ function createApi (): Promise<ApiPromise> {
|
||||
return new ApiPromise({ provider }).isReady;
|
||||
}
|
||||
|
||||
describe.skip('misc quick tests', (): void => {
|
||||
describe('misc quick tests', (): void => {
|
||||
it.skip('retrieves balances correctly', async (): Promise<void> => {
|
||||
const api = await createApi();
|
||||
|
||||
@@ -76,4 +76,12 @@ describe.skip('misc quick tests', (): void => {
|
||||
.map(([block, value]) => [block, value.toRawType(), value.toHuman()])
|
||||
));
|
||||
});
|
||||
|
||||
it('expose rpc and rx definition', async (): Promise<void> => {
|
||||
const api = await createApi();
|
||||
|
||||
console.error(api.rpc.payment.queryFeeDetails.meta);
|
||||
|
||||
console.error(api.rx.rpc.chain.getBlock.meta);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/metadata",
|
||||
"version": "4.1.1",
|
||||
"version": "4.11.2",
|
||||
"type": "module",
|
||||
"description": "Helpers to extract information from runtime metadata",
|
||||
"main": "index.js",
|
||||
@@ -8,6 +8,9 @@
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"repository": "github:polkadot-js/api",
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
@@ -16,14 +19,14 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.13.9",
|
||||
"@polkadot/types": "4.1.1",
|
||||
"@polkadot/types-known": "4.1.1",
|
||||
"@polkadot/util": "^6.0.5",
|
||||
"@polkadot/util-crypto": "^6.0.5",
|
||||
"@babel/runtime": "^7.14.0",
|
||||
"@polkadot/types": "4.11.2",
|
||||
"@polkadot/types-known": "4.11.2",
|
||||
"@polkadot/util": "^6.5.1",
|
||||
"@polkadot/util-crypto": "^6.5.1",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^6.0.5"
|
||||
"@polkadot/keyring": "^6.5.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,20 @@ describe('MagicNumber', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
it('succeeds when the magic number matches', (): void => {
|
||||
expect((): MagicNumber => new MagicNumber(registry, MAGIC_NUMBER)).not.toThrow();
|
||||
expect(
|
||||
() => new MagicNumber(registry, MAGIC_NUMBER)
|
||||
).not.toThrow();
|
||||
});
|
||||
|
||||
it('succeeds when the magic number is empty', (): void => {
|
||||
expect(
|
||||
() => new MagicNumber(registry)
|
||||
).not.toThrow();
|
||||
});
|
||||
|
||||
it('fails when the magic number mismatches', (): void => {
|
||||
expect((): MagicNumber => new MagicNumber(registry, 0x12345)).toThrow(/MagicNumber/);
|
||||
expect(
|
||||
() => new MagicNumber(registry, 0x12345678)
|
||||
).toThrow(/MagicNumber mismatch/);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,9 +13,7 @@ export class MagicNumber extends U32 {
|
||||
super(registry, value);
|
||||
|
||||
if (!this.isEmpty) {
|
||||
const magic = registry.createType('u32', MAGIC_NUMBER);
|
||||
|
||||
assert(this.eq(magic), `MagicNumber mismatch: expected ${magic.toHex()}, found ${this.toHex()}`);
|
||||
assert(this.eq(MAGIC_NUMBER), () => `MagicNumber mismatch: expected ${registry.createType('u32', MAGIC_NUMBER).toHex()}, found ${this.toHex()}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { isString, u8aConcat, u8aToU8a } from '@polkadot/util';
|
||||
import { isHex, isU8a, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { MetadataVersioned } from './MetadataVersioned';
|
||||
|
||||
@@ -11,37 +11,39 @@ import { MetadataVersioned } from './MetadataVersioned';
|
||||
const VERSION_IDX = 4;
|
||||
|
||||
// magic + lowest supported version
|
||||
const EMPTY_METADATA = u8aConcat(new Uint8Array([0x6d, 0x65, 0x74, 0x61, 9]));
|
||||
const EMPTY_METADATA = new Uint8Array([0x6d, 0x65, 0x74, 0x61, 9]);
|
||||
const EMPTY_U8A = new Uint8Array();
|
||||
|
||||
function sanitizeInput (_value: Uint8Array | string = EMPTY_U8A): Uint8Array {
|
||||
if (isString(_value)) {
|
||||
return sanitizeInput(u8aToU8a(_value));
|
||||
}
|
||||
|
||||
return _value.length === 0
|
||||
? EMPTY_METADATA
|
||||
: _value;
|
||||
function toU8a (value: Uint8Array | string = EMPTY_U8A): Uint8Array {
|
||||
return isHex(value)
|
||||
? toU8a(u8aToU8a(value))
|
||||
: isU8a(value) && value.length === 0
|
||||
? EMPTY_METADATA
|
||||
: value;
|
||||
}
|
||||
|
||||
function decodeMetadata (registry: Registry, _value?: Uint8Array | string): MetadataVersioned {
|
||||
const value = sanitizeInput(_value);
|
||||
const version = value[VERSION_IDX];
|
||||
function decodeMetadata (registry: Registry, _value?: Uint8Array | string | Map<string, unknown> | Record<string, unknown>): MetadataVersioned {
|
||||
if (!_value || isU8a(_value) || isHex(_value)) {
|
||||
const value = toU8a(_value);
|
||||
const version = value[VERSION_IDX];
|
||||
|
||||
try {
|
||||
return new MetadataVersioned(registry, value);
|
||||
} catch (error) {
|
||||
// This is an f-ing hack as a follow-up to another ugly hack
|
||||
// https://github.com/polkadot-js/api/commit/a9211690be6b68ad6c6dad7852f1665cadcfa5b2
|
||||
// when we fail on V9, try to re-parse it as v10... yes... HACK
|
||||
if (version === 9) {
|
||||
value[VERSION_IDX] = 10;
|
||||
try {
|
||||
return new MetadataVersioned(registry, value);
|
||||
} catch (error) {
|
||||
// This is an f-ing hack as a follow-up to another ugly hack
|
||||
// https://github.com/polkadot-js/api/commit/a9211690be6b68ad6c6dad7852f1665cadcfa5b2
|
||||
// when we fail on V9, try to re-parse it as v10... yes... HACK
|
||||
if (version === 9) {
|
||||
value[VERSION_IDX] = 10;
|
||||
|
||||
return decodeMetadata(registry, value);
|
||||
return decodeMetadata(registry, value);
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
return new MetadataVersioned(registry, _value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,7 +52,7 @@ function decodeMetadata (registry: Registry, _value?: Uint8Array | string): Meta
|
||||
* The versioned runtime metadata as a decoded structure
|
||||
*/
|
||||
export class Metadata extends MetadataVersioned {
|
||||
constructor (registry: Registry, value?: Uint8Array | string) {
|
||||
constructor (registry: Registry, value?: Uint8Array | string | Map<string, unknown> | Record<string, unknown>) {
|
||||
super(registry, decodeMetadata(registry, value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { MetadataAll, MetadataLatest, MetadataV9, MetadataV10, MetadataV11, MetadataV12 } from '@polkadot/types/interfaces/metadata';
|
||||
import type { MetadataAll, MetadataLatest, MetadataV9, MetadataV10, MetadataV11, MetadataV12, MetadataV13 } from '@polkadot/types/interfaces/metadata';
|
||||
import type { AnyJson, Registry } from '@polkadot/types/types';
|
||||
|
||||
import { Struct } from '@polkadot/types/codec';
|
||||
@@ -10,13 +10,16 @@ import { assert } from '@polkadot/util';
|
||||
import { toV10 } from './v9/toV10';
|
||||
import { toV11 } from './v10/toV11';
|
||||
import { toV12 } from './v11/toV12';
|
||||
import { toLatest } from './v12/toLatest';
|
||||
import { toV13 } from './v12/toV13';
|
||||
import { toLatest } from './v13/toLatest';
|
||||
import { MagicNumber } from './MagicNumber';
|
||||
import { getUniqTypes, toCallsOnly } from './util';
|
||||
|
||||
type MetaMapped = MetadataV9 | MetadataV10 | MetadataV11 | MetadataV12;
|
||||
type MetaVersions = 9 | 10 | 11 | 12 | 13;
|
||||
type MetaAsX = 'asV9' | 'asV10' | 'asV11' | 'asV12';
|
||||
type MetaMapped = MetadataV9 | MetadataV10 | MetadataV11 | MetadataV12 | MetadataV13;
|
||||
type MetaAsX = 'asV9' | 'asV10' | 'asV11' | 'asV12' | 'asV13';
|
||||
type MetaVersions = 'latest' | 9 | 10 | 11 | 12 | 13;
|
||||
|
||||
const LATEST_VERSION = 13;
|
||||
|
||||
/**
|
||||
* @name MetadataVersioned
|
||||
@@ -24,7 +27,7 @@ type MetaAsX = 'asV9' | 'asV10' | 'asV11' | 'asV12';
|
||||
* The versioned runtime metadata as a decoded structure
|
||||
*/
|
||||
export class MetadataVersioned extends Struct {
|
||||
readonly #converted = new Map<number, MetaMapped>();
|
||||
readonly #converted = new Map<MetaVersions, MetaMapped>();
|
||||
|
||||
constructor (registry: Registry, value?: unknown) {
|
||||
super(registry, {
|
||||
@@ -33,18 +36,20 @@ export class MetadataVersioned extends Struct {
|
||||
}, value as Map<unknown, unknown>);
|
||||
}
|
||||
|
||||
private _assertVersion (version: number): boolean {
|
||||
assert(this.version <= version, `Cannot convert metadata from v${this.version} to v${version}`);
|
||||
#assertVersion = (version: number): boolean => {
|
||||
assert(this.version <= version, () => `Cannot convert metadata from version ${this.version} to ${version}`);
|
||||
|
||||
return this.version === version;
|
||||
}
|
||||
};
|
||||
|
||||
private _getVersion<T extends MetaMapped, F extends MetaMapped> (version: MetaVersions, fromPrev: (registry: Registry, input: F, metaVersion: number) => T): T {
|
||||
#getVersion = <T extends MetaMapped, F extends MetaMapped>(version: MetaVersions, fromPrev: (registry: Registry, input: F, metaVersion: number) => T): T => {
|
||||
const asCurr = `asV${version}` as MetaAsX;
|
||||
const asPrev = `asV${version - 1}` as MetaAsX;
|
||||
const asPrev = version === 'latest'
|
||||
? `asV${LATEST_VERSION}` as MetaAsX
|
||||
: `asV${version - 1}` as MetaAsX;
|
||||
|
||||
if (this._assertVersion(version)) {
|
||||
return this._metadata[asCurr] as T;
|
||||
if (version !== 'latest' && this.#assertVersion(version)) {
|
||||
return this.#metadata()[asCurr] as T;
|
||||
}
|
||||
|
||||
if (!this.#converted.has(version)) {
|
||||
@@ -52,6 +57,13 @@ export class MetadataVersioned extends Struct {
|
||||
}
|
||||
|
||||
return this.#converted.get(version) as T;
|
||||
};
|
||||
|
||||
/**
|
||||
* @description the metadata wrapped
|
||||
*/
|
||||
#metadata = (): MetadataAll => {
|
||||
return this.get('metadata') as MetadataAll;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,30 +80,37 @@ export class MetadataVersioned extends Struct {
|
||||
* @description Returns the wrapped metadata as a V9 object
|
||||
*/
|
||||
public get asV9 (): MetadataV9 {
|
||||
this._assertVersion(9);
|
||||
this.#assertVersion(9);
|
||||
|
||||
return this._metadata.asV9;
|
||||
return this.#metadata().asV9;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the wrapped values as a V10 object
|
||||
*/
|
||||
public get asV10 (): MetadataV10 {
|
||||
return this._getVersion(10, toV10);
|
||||
return this.#getVersion(10, toV10);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the wrapped values as a V11 object
|
||||
*/
|
||||
public get asV11 (): MetadataV11 {
|
||||
return this._getVersion(11, toV11);
|
||||
return this.#getVersion(11, toV11);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the wrapped values as a V12 object
|
||||
*/
|
||||
public get asV12 (): MetadataV12 {
|
||||
return this._getVersion(12, toV12);
|
||||
return this.#getVersion(12, toV12);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the wrapped values as a V13 object
|
||||
*/
|
||||
public get asV13 (): MetadataV13 {
|
||||
return this.#getVersion(13, toV13);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,28 +118,21 @@ export class MetadataVersioned extends Struct {
|
||||
*/
|
||||
public get asLatest (): MetadataLatest {
|
||||
// This is non-existent & latest - applied here to do the module-specific type conversions
|
||||
return this._getVersion(13, toLatest);
|
||||
return this.#getVersion('latest', toLatest);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description
|
||||
* @description The magicNumber for the Metadata (known constant)
|
||||
*/
|
||||
public get magicNumber (): MagicNumber {
|
||||
return this.get('magicNumber') as MagicNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the metadata wrapped
|
||||
*/
|
||||
private get _metadata (): MetadataAll {
|
||||
return this.get('metadata') as MetadataAll;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the metadata version this structure represents
|
||||
*/
|
||||
public get version (): number {
|
||||
return this._metadata.index;
|
||||
return this.#metadata().index;
|
||||
}
|
||||
|
||||
public getUniqTypes (throwError: boolean): string[] {
|
||||
@@ -131,8 +143,8 @@ export class MetadataVersioned extends Struct {
|
||||
* @description Converts the Object to JSON, typically used for RPC transfers
|
||||
*/
|
||||
public toJSON (): Record<string, AnyJson> {
|
||||
// HACK(y): ensure that we apply the aliasses if we have not done so already, this is
|
||||
// needed to ensure we have the overrides as intended (only applied in toLatest)
|
||||
// HACK(y): ensure that we apply the aliases if we have not done so already, this is
|
||||
// needed to ensure we have the correct overrides (which is only applied in toLatest)
|
||||
// eslint-disable-next-line no-unused-expressions
|
||||
this.asLatest;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ function init (meta: string): [Constants, TypeRegistry] {
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
return [decorateConstants(registry, metadata.asLatest), registry];
|
||||
return [decorateConstants(registry, metadata.asLatest, 12), registry];
|
||||
}
|
||||
|
||||
describe('decorateConstants', (): void => {
|
||||
|
||||
@@ -8,7 +8,8 @@ import type { ConstantCodec, Constants, ModuleConstants } from '../types';
|
||||
import { hexToU8a, stringCamelCase } from '@polkadot/util';
|
||||
|
||||
/** @internal */
|
||||
export function decorateConstants (registry: Registry, { modules }: MetadataLatest): Constants {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export function decorateConstants (registry: Registry, { modules }: MetadataLatest, _metaVersion: number): Constants {
|
||||
return modules.reduce((result: Constants, { constants, name }): Constants => {
|
||||
if (constants.isEmpty) {
|
||||
return result;
|
||||
|
||||
@@ -16,7 +16,7 @@ export function createUnchecked (registry: Registry, section: string, callIndex:
|
||||
const funcName = stringCamelCase(callMetadata.name);
|
||||
|
||||
const extrinsicFn = (...args: any[]): Call => {
|
||||
assert(expectedArgs.length === args.length, `Extrinsic ${section}.${funcName} expects ${expectedArgs.length.valueOf()} arguments, got ${args.length}.`);
|
||||
assert(expectedArgs.length === args.length, () => `Extrinsic ${section}.${funcName} expects ${expectedArgs.length.valueOf()} arguments, got ${args.length}.`);
|
||||
|
||||
return registry.createType('Call', {
|
||||
args,
|
||||
|
||||
@@ -46,7 +46,7 @@ describe('Decorated', () => {
|
||||
});
|
||||
|
||||
it('should return constants with the correct type and value', (): void => {
|
||||
const consts = decorateConstants(registry, metadata.asLatest);
|
||||
const consts = decorateConstants(registry, metadata.asLatest, metadata.version);
|
||||
|
||||
expect(consts.democracy.cooloffPeriod).toBeInstanceOf(registry.createClass('BlockNumber'));
|
||||
expect(consts.democracy.cooloffPeriod.toHex()).toEqual('0x000c4e00');
|
||||
|
||||
@@ -20,13 +20,14 @@ export function expandMetadata (registry: Registry, metadata: Metadata): Decorat
|
||||
assert(metadata instanceof Metadata, 'You need to pass a valid Metadata instance to Decorated');
|
||||
|
||||
const latest = metadata.asLatest;
|
||||
const version = metadata.version;
|
||||
|
||||
return {
|
||||
consts: decorateConstants(registry, latest),
|
||||
errors: decorateErrors(registry, latest, metadata.version),
|
||||
events: decorateEvents(registry, latest, metadata.version),
|
||||
query: decorateStorage(registry, latest, metadata.version),
|
||||
tx: decorateExtrinsics(registry, latest, metadata.version)
|
||||
consts: decorateConstants(registry, latest, version),
|
||||
errors: decorateErrors(registry, latest, version),
|
||||
events: decorateEvents(registry, latest, version),
|
||||
query: decorateStorage(registry, latest, version),
|
||||
tx: decorateExtrinsics(registry, latest, version)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ describe('createFunction', (): void => {
|
||||
method: 'NextKeys',
|
||||
prefix: 'Session',
|
||||
section: 'session'
|
||||
}, { metaVersion: 9 });
|
||||
}, {});
|
||||
|
||||
expect(
|
||||
u8aToHex(
|
||||
@@ -49,4 +49,52 @@ describe('createFunction', (): void => {
|
||||
'5eb36b60f0fc4b9177116eba3e5cd57fea6289a57f5f5b9ffeb0475c66e7a521' // blake2
|
||||
);
|
||||
});
|
||||
|
||||
it('allows creating of NMap keys (with Bytes)', (): void => {
|
||||
const storageFn = createFunction(registry, {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
meta: {
|
||||
type: {
|
||||
asNMap: {
|
||||
hashers: [
|
||||
registry.createType('StorageHasher', 'Twox64Concat'),
|
||||
registry.createType('StorageHasher', 'Blake2_256'),
|
||||
registry.createType('StorageHasher', 'Blake2_256')
|
||||
],
|
||||
keyVec: [
|
||||
new Text(registry, 'Bytes'),
|
||||
new Text(registry, 'AccountId'),
|
||||
new Text(registry, 'AccountId')
|
||||
],
|
||||
value: new Text(registry, 'SessionKeys5')
|
||||
},
|
||||
isNMap: true
|
||||
}
|
||||
} as any,
|
||||
method: 'NextKeys',
|
||||
prefix: 'Session',
|
||||
section: 'session'
|
||||
}, {});
|
||||
|
||||
expect(
|
||||
u8aToHex(
|
||||
storageFn([
|
||||
// hex, without length prefix
|
||||
'0x3a73657373696f6e3a6b657973',
|
||||
// addresses
|
||||
'DB2mp5nNhbFN86J9hxoAog8JALMhDXgwvWMxrRMLNUFMEY4',
|
||||
'DB2mp5nNhbFN86J9hxoAog8JALMhDXgwvWMxrRMLNUFMEY4'
|
||||
])
|
||||
)
|
||||
).toEqual(
|
||||
'0x' +
|
||||
'd901' + // length
|
||||
'cec5070d609dd3497f72bde07fc96ba0' + // twox 128
|
||||
'4c014e6bf8b8c2c011e7290b85696bb3' + // twox 128
|
||||
'9fe6329cc0b39e09' + // twox 64
|
||||
'343a73657373696f6e3a6b657973' + // twox 64 (concat, with length)
|
||||
'5eb36b60f0fc4b9177116eba3e5cd57fea6289a57f5f5b9ffeb0475c66e7a521' + // blake2
|
||||
'5eb36b60f0fc4b9177116eba3e5cd57fea6289a57f5f5b9ffeb0475c66e7a521' // blake2
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,16 +8,15 @@ import type { Codec, Registry } from '@polkadot/types/types';
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { Raw } from '@polkadot/types/codec';
|
||||
import { StorageKey } from '@polkadot/types/primitive';
|
||||
import { assert, compactAddLength, compactStripLength, isNull, isUndefined, stringLowerFirst, u8aConcat } from '@polkadot/util';
|
||||
import { StorageKey, Type } from '@polkadot/types/primitive';
|
||||
import { assert, compactAddLength, compactStripLength, isNull, isUndefined, stringCamelCase, stringify, stringLowerFirst, u8aConcat, u8aToU8a } from '@polkadot/util';
|
||||
import { xxhashAsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import { getHasher, HasherFunction } from './getHasher';
|
||||
import { getHasher } from './getHasher';
|
||||
|
||||
export interface CreateItemOptions {
|
||||
key?: string;
|
||||
metaVersion: number;
|
||||
skipHashing?: boolean; // We don't hash the keys defined in ./substrate.ts
|
||||
skipHashing?: boolean;
|
||||
}
|
||||
|
||||
export interface CreateItemFn {
|
||||
@@ -34,81 +33,41 @@ interface IterFn {
|
||||
|
||||
type CreateArgType = boolean | string | number | null | BN | BigInt | Uint8Array | Codec;
|
||||
|
||||
const EMPTY_U8A = new Uint8Array([]);
|
||||
const NULL_HASHER = (value: Uint8Array): Uint8Array => value;
|
||||
type U8aHasher = (input: Uint8Array) => Uint8Array;
|
||||
|
||||
// get the hashers, the base (and in the case of DoubleMap), the second key
|
||||
/** @internal */
|
||||
function getHashers ({ meta: { type } }: CreateItemFn): [HasherFunction, HasherFunction?] {
|
||||
if (type.isDoubleMap) {
|
||||
return [
|
||||
getHasher(type.asDoubleMap.hasher),
|
||||
getHasher(type.asDoubleMap.key2Hasher)
|
||||
];
|
||||
} else if (type.isMap) {
|
||||
return [getHasher(type.asMap.hasher)];
|
||||
}
|
||||
|
||||
// the default
|
||||
return [getHasher()];
|
||||
}
|
||||
|
||||
// create a base prefixed key
|
||||
/** @internal */
|
||||
function createPrefixedKey ({ method, prefix }: CreateItemFn): Uint8Array {
|
||||
return u8aConcat(xxhashAsU8a(prefix, 128), xxhashAsU8a(method, 128));
|
||||
}
|
||||
|
||||
// create a key for a DoubleMap type
|
||||
/** @internal */
|
||||
function createKeyDoubleMap (registry: Registry, itemFn: CreateItemFn, args: [CreateArgType, CreateArgType], [hasher1, hasher2]: [HasherFunction, HasherFunction?]): Uint8Array {
|
||||
const { meta: { name, type } } = itemFn;
|
||||
function createKeyRaw (registry: Registry, itemFn: CreateItemFn, keys: Type[], hashers: U8aHasher[], args: CreateArgType[]): Uint8Array {
|
||||
const { method, section } = itemFn;
|
||||
|
||||
// since we are passing an almost-unknown through, trust, but verify
|
||||
assert(Array.isArray(args) && !isUndefined(args[0]) && !isNull(args[0]) && !isUndefined(args[1]) && !isNull(args[1]), `${(name || 'unknown').toString()} is a DoubleMap and requires two arguments`);
|
||||
|
||||
// if this fails, we have bigger issues
|
||||
assert(!isUndefined(hasher2), '2 hashing functions should be defined for DoubleMaps');
|
||||
|
||||
const [key1, key2] = args;
|
||||
const map = type.asDoubleMap;
|
||||
const val1 = registry.createType(map.key1.toString() as 'Raw', key1).toU8a();
|
||||
const val2 = registry.createType(map.key2.toString() as 'Raw', key2).toU8a();
|
||||
|
||||
// as per createKey, always add the length prefix (underlying it is Bytes)
|
||||
return compactAddLength(u8aConcat(
|
||||
return u8aConcat(
|
||||
createPrefixedKey(itemFn),
|
||||
hasher1(val1),
|
||||
hasher2(val2)
|
||||
));
|
||||
...keys.map((type, index): Uint8Array => {
|
||||
const arg = args[index];
|
||||
|
||||
assert(!isUndefined(arg) && !isNull(arg), () => `Call to ${stringCamelCase(section || 'unknown')}.${stringCamelCase(method || 'unknown')} has a null or undefined argument at position ${index}`);
|
||||
|
||||
return hashers[index](registry.createType(type.toString() as 'Raw', arg).toU8a());
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// create a key for either a map or a plain value
|
||||
/** @internal */
|
||||
function createKey (registry: Registry, itemFn: CreateItemFn, arg: CreateArgType, hasher: (value: Uint8Array) => Uint8Array): Uint8Array {
|
||||
const { meta: { name, type } } = itemFn;
|
||||
let param: Uint8Array = EMPTY_U8A;
|
||||
function createKey (registry: Registry, itemFn: CreateItemFn, keys: Type[], hashers: U8aHasher[], args: CreateArgType[]): Uint8Array {
|
||||
const { method, section } = itemFn;
|
||||
|
||||
if (type.isMap) {
|
||||
const map = type.asMap;
|
||||
assert(Array.isArray(args) && args.length === keys.length, () => `Call to ${stringCamelCase(section || 'unknown')}.${stringCamelCase(method || 'unknown')} needs ${keys.length} arguments, found ${stringify(args)}`);
|
||||
|
||||
assert(!isUndefined(arg) && !isNull(arg), `${name.toString()} is a Map and requires one argument`);
|
||||
|
||||
param = registry.createType(map.key.toString() as 'Raw', arg).toU8a();
|
||||
}
|
||||
|
||||
// StorageKey is a Bytes, so is length-prefixed
|
||||
return compactAddLength(u8aConcat(
|
||||
createPrefixedKey(itemFn),
|
||||
param.length
|
||||
? hasher(param)
|
||||
: EMPTY_U8A
|
||||
));
|
||||
// as per createKey, always add the length prefix (underlying it is Bytes)
|
||||
return compactAddLength(
|
||||
createKeyRaw(registry, itemFn, keys, hashers, args)
|
||||
);
|
||||
}
|
||||
|
||||
// attach the metadata to expand to a StorageFunction
|
||||
/** @internal */
|
||||
function expandWithMeta ({ meta, method, prefix, section }: CreateItemFn, _storageFn: (arg?: CreateArgType | [CreateArgType?, CreateArgType?]) => Uint8Array): StorageEntry {
|
||||
function expandWithMeta ({ meta, method, prefix, section }: CreateItemFn, _storageFn: (arg?: CreateArgType | CreateArgType[]) => Uint8Array): StorageEntry {
|
||||
const storageFn = _storageFn as StorageEntry;
|
||||
|
||||
storageFn.meta = meta;
|
||||
@@ -127,48 +86,58 @@ function expandWithMeta ({ meta, method, prefix, section }: CreateItemFn, _stora
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function extendHeadMeta (registry: Registry, { meta: { documentation, name, type }, section }: CreateItemFn, { method }: StorageEntry, iterFn: (arg?: any) => Raw): (arg?: any) => StorageKey {
|
||||
function extendHeadMeta (registry: Registry, { meta: { documentation, name, type }, section }: CreateItemFn, { method }: StorageEntry, iterFn: (...args: unknown[]) => Raw): (...args: unknown[]) => StorageKey {
|
||||
const outputType = type.isMap
|
||||
? type.asMap.key.toString()
|
||||
: type.asDoubleMap.key1.toString();
|
||||
? type.asMap.key
|
||||
: type.isDoubleMap
|
||||
? type.asDoubleMap.key1
|
||||
: type.asNMap.keyVec[0];
|
||||
|
||||
// metadata with a fallback value using the type of the key, the normal
|
||||
// meta fallback only applies to actual entry values, create one for head
|
||||
(iterFn as IterFn).meta = registry.createType('StorageEntryMetadataLatest', {
|
||||
documentation,
|
||||
fallback: registry.createType('Bytes', registry.createType(outputType as 'Raw').toHex()),
|
||||
fallback: registry.createType('Bytes', registry.createType(outputType.toString() as 'Raw').toHex()),
|
||||
modifier: registry.createType('StorageEntryModifierLatest', 1), // required
|
||||
name,
|
||||
type: registry.createType('StorageEntryTypeLatest', registry.createType('Type', type.isMap ? type.asMap.key : type.asDoubleMap.key1), 0)
|
||||
type: registry.createType('StorageEntryTypeLatest', registry.createType('Type', outputType), 0)
|
||||
});
|
||||
|
||||
const prefixKey = registry.createType('StorageKey', iterFn, { method, section });
|
||||
|
||||
return (arg?: any) =>
|
||||
!isUndefined(arg) && !isNull(arg)
|
||||
? registry.createType('StorageKey', iterFn(arg), { method, section })
|
||||
: prefixKey;
|
||||
return (...args: unknown[]) =>
|
||||
registry.createType('StorageKey', iterFn(...args), { method, section });
|
||||
}
|
||||
|
||||
// attach the full list hashing for prefixed maps
|
||||
/** @internal */
|
||||
function extendPrefixedMap (registry: Registry, itemFn: CreateItemFn, storageFn: StorageEntry): StorageEntry {
|
||||
const { meta: { type } } = itemFn;
|
||||
const { meta: { type }, method, section } = itemFn;
|
||||
|
||||
storageFn.iterKey = extendHeadMeta(registry, itemFn, storageFn, (arg?: any): Raw => {
|
||||
assert(type.isDoubleMap || isUndefined(arg), 'Filtering arguments for keys/entries are only valid on double maps');
|
||||
|
||||
return new Raw(
|
||||
registry,
|
||||
type.isDoubleMap && !isUndefined(arg) && !isNull(arg)
|
||||
? u8aConcat(
|
||||
createPrefixedKey(itemFn),
|
||||
getHasher(type.asDoubleMap.hasher)(
|
||||
registry.createType(type.asDoubleMap.key1.toString() as 'Raw', arg).toU8a()
|
||||
)
|
||||
)
|
||||
: createPrefixedKey(itemFn)
|
||||
storageFn.iterKey = extendHeadMeta(registry, itemFn, storageFn, (...args: unknown[]): Raw => {
|
||||
assert(
|
||||
(
|
||||
(args.length === 0) ||
|
||||
(type.isDoubleMap && args.length === 1) ||
|
||||
(type.isNMap && args.length === (type.asNMap.hashers.length - 1))
|
||||
),
|
||||
() => `Iteration ${stringCamelCase(section || 'unknown')}.${stringCamelCase(method || 'unknown')} needs arguments to be one less than the full arguments, found [${args.join(', ')}]`
|
||||
);
|
||||
|
||||
if (args.length) {
|
||||
if (type.isDoubleMap) {
|
||||
return new Raw(registry, createKeyRaw(registry, itemFn, [type.asDoubleMap.key1], [getHasher(type.asDoubleMap.hasher)], args as CreateArgType[]));
|
||||
} else if (type.isNMap) {
|
||||
const keys = [...type.asNMap.keyVec];
|
||||
const hashers = type.asNMap.hashers.map((h) => getHasher(h));
|
||||
|
||||
// remove the last entry
|
||||
keys.pop();
|
||||
hashers.pop();
|
||||
|
||||
return new Raw(registry, createKeyRaw(registry, itemFn, keys, hashers, args as CreateArgType[]));
|
||||
}
|
||||
}
|
||||
|
||||
return new Raw(registry, createKeyRaw(registry, itemFn, [], [], []));
|
||||
});
|
||||
|
||||
return storageFn;
|
||||
@@ -177,24 +146,30 @@ function extendPrefixedMap (registry: Registry, itemFn: CreateItemFn, storageFn:
|
||||
/** @internal */
|
||||
export function createFunction (registry: Registry, itemFn: CreateItemFn, options: CreateItemOptions): StorageEntry {
|
||||
const { meta: { type } } = itemFn;
|
||||
const [hasher, key2Hasher] = getHashers(itemFn);
|
||||
|
||||
// Can only have zero or one argument:
|
||||
// - storage.system.account(address)
|
||||
// - storage.timestamp.blockPeriod()
|
||||
// For doublemap queries the params is passed in as an tuple, [key1, key2]
|
||||
const storageFn = expandWithMeta(itemFn, (arg?: CreateArgType | [CreateArgType?, CreateArgType?]): Uint8Array =>
|
||||
type.isDoubleMap
|
||||
? createKeyDoubleMap(registry, itemFn, arg as [CreateArgType, CreateArgType], [hasher, key2Hasher])
|
||||
: createKey(registry, itemFn, arg as CreateArgType, options.skipHashing ? NULL_HASHER : hasher)
|
||||
// For higher-map queries the params are passed in as an tuple, [key1, key2]
|
||||
const storageFn = expandWithMeta(itemFn, (arg?: CreateArgType | CreateArgType[]) =>
|
||||
type.isPlain
|
||||
? options.skipHashing
|
||||
? compactAddLength(u8aToU8a(options.key))
|
||||
: createKey(registry, itemFn, [], [], [])
|
||||
: type.isMap
|
||||
? createKey(registry, itemFn, [type.asMap.key], [getHasher(type.asMap.hasher)], [arg as CreateArgType])
|
||||
: type.isDoubleMap
|
||||
? createKey(registry, itemFn, [type.asDoubleMap.key1, type.asDoubleMap.key2], [getHasher(type.asDoubleMap.hasher), getHasher(type.asDoubleMap.key2Hasher)], arg as CreateArgType[])
|
||||
: createKey(registry, itemFn, type.asNMap.keyVec, type.asNMap.hashers.map((h) => getHasher(h)), arg as CreateArgType[])
|
||||
);
|
||||
|
||||
if (type.isMap || type.isDoubleMap) {
|
||||
if (type.isMap || type.isDoubleMap || type.isNMap) {
|
||||
extendPrefixedMap(registry, itemFn, storageFn);
|
||||
}
|
||||
|
||||
storageFn.keyPrefix = (arg?: any): Uint8Array =>
|
||||
(storageFn.iterKey && storageFn.iterKey(arg)) || compactStripLength(storageFn())[1];
|
||||
storageFn.keyPrefix = (...args: unknown[]): Uint8Array =>
|
||||
(storageFn.iterKey && storageFn.iterKey(...args)) ||
|
||||
compactStripLength(storageFn())[1];
|
||||
|
||||
return storageFn;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,6 @@ const HASHERS: Record<keyof typeof AllHashers, HasherFunction> = {
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
export function getHasher (hasher?: StorageHasher): HasherFunction {
|
||||
return HASHERS[hasher?.type as 'Identity'] || DEFAULT_FN;
|
||||
export function getHasher (hasher: StorageHasher): HasherFunction {
|
||||
return HASHERS[hasher.type as 'Identity'] || DEFAULT_FN;
|
||||
}
|
||||
|
||||
@@ -2,19 +2,21 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
import { compactAddLength, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { getStorage } from './getStorage';
|
||||
|
||||
describe('getSorage', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
const storage = getStorage(registry, 8);
|
||||
const storage = getStorage(registry);
|
||||
|
||||
it('should return well known keys', (): void => {
|
||||
expect(typeof storage.substrate).toBe('object');
|
||||
|
||||
expect(storage.substrate.code()).toEqual(compactAddLength(u8aToU8a(':code')));
|
||||
|
||||
expect(storage.substrate.changesTrieConfig).toBeTruthy();
|
||||
expect(storage.substrate.childStorageKeyPrefix).toBeTruthy();
|
||||
expect(storage.substrate.code).toBeTruthy();
|
||||
expect(storage.substrate.extrinsicIndex).toBeTruthy();
|
||||
expect(storage.substrate.heapPages).toBeTruthy();
|
||||
});
|
||||
|
||||
@@ -5,15 +5,15 @@ import type { StorageEntry } from '@polkadot/types/primitive/types';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { Storage } from '../types';
|
||||
|
||||
import * as substrate from './substrate';
|
||||
import { substrate } from './substrate';
|
||||
|
||||
/** @internal */
|
||||
export function getStorage (registry: Registry, metaVersion: number): Storage {
|
||||
export function getStorage (registry: Registry): Storage {
|
||||
return {
|
||||
substrate: Object
|
||||
.entries(substrate)
|
||||
.reduce((storage: Record<string, StorageEntry>, [key, fn]): Record<string, StorageEntry> => {
|
||||
(storage as Record<string, unknown>)[key] = fn(registry, metaVersion);
|
||||
(storage as Record<string, unknown>)[key] = fn(registry);
|
||||
|
||||
return storage;
|
||||
}, {})
|
||||
|
||||
@@ -21,7 +21,11 @@ describe('decorateStorage', (): void => {
|
||||
const query = decorateStorage(registry, metadata.asLatest, metadata.version);
|
||||
|
||||
it('should throw if the storage function expects an argument', (): void => {
|
||||
expect(() => query.balances.account()).toThrowError(/requires one argument/);
|
||||
expect(() => query.balances.account()).toThrowError('Call to balances.account has a null or undefined argument at position 0');
|
||||
});
|
||||
|
||||
it('should throw if the storage function expects multiple arguments', (): void => {
|
||||
expect(() => query.staking.erasStakers([1])).toThrowError('Call to staking.erasStakers needs 2 arguments, found [1]');
|
||||
});
|
||||
|
||||
it('should return a value if the storage function does not expect an argument', (): void => {
|
||||
|
||||
@@ -11,7 +11,8 @@ import { createFunction } from './createFunction';
|
||||
import { getStorage } from './getStorage';
|
||||
|
||||
/** @internal */
|
||||
export function decorateStorage (registry: Registry, { modules }: MetadataLatest, metaVersion: number): Storage {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export function decorateStorage (registry: Registry, { modules }: MetadataLatest, _metaVersion: number): Storage {
|
||||
return modules.reduce((result: Storage, moduleMetadata): Storage => {
|
||||
if (moduleMetadata.storage.isNone) {
|
||||
return result;
|
||||
@@ -31,11 +32,11 @@ export function decorateStorage (registry: Registry, { modules }: MetadataLatest
|
||||
method,
|
||||
prefix,
|
||||
section
|
||||
}, { metaVersion });
|
||||
}, {});
|
||||
|
||||
return newModule;
|
||||
}, {} as ModuleStorage);
|
||||
|
||||
return result;
|
||||
}, { ...getStorage(registry, metaVersion) });
|
||||
}, { ...getStorage(registry) });
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright 2017-2021 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
import { compactAddLength, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { substrate } from './substrate';
|
||||
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
describe('substrate', (): void => {
|
||||
it('creates a well-known :code key', (): void => {
|
||||
expect(
|
||||
substrate.code(registry)()
|
||||
).toEqual(
|
||||
compactAddLength(u8aToU8a(':code'))
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -12,44 +12,45 @@ interface SubstrateMetadata {
|
||||
type: string;
|
||||
}
|
||||
|
||||
type Creator = (registry: Registry) => StorageEntry;
|
||||
|
||||
// Small helper function to factorize code on this page.
|
||||
/** @internal */
|
||||
function createRuntimeFunction (method: string, key: string, { documentation, type }: SubstrateMetadata): (registry: Registry, metaVersion: number) => StorageEntry {
|
||||
return (registry: Registry, metaVersion: number): StorageEntry =>
|
||||
function createRuntimeFunction (method: string, key: string, { documentation, type }: SubstrateMetadata): (registry: Registry) => StorageEntry {
|
||||
return (registry: Registry): StorageEntry =>
|
||||
createFunction(registry, {
|
||||
meta: {
|
||||
documentation: registry.createType('Vec<Text>', [documentation]),
|
||||
modifier: registry.createType('StorageEntryModifierLatest', 1), // required
|
||||
name: registry.createType('Text', method),
|
||||
toJSON: (): any => key,
|
||||
type: registry.createType('StorageEntryTypeLatest', type, 0)
|
||||
} as StorageEntryMetadataLatest,
|
||||
method,
|
||||
prefix: 'Substrate',
|
||||
section: 'substrate'
|
||||
}, { key, metaVersion, skipHashing: true });
|
||||
}, { key, skipHashing: true });
|
||||
}
|
||||
|
||||
export const code = createRuntimeFunction('code', ':code', {
|
||||
documentation: 'Wasm code of the runtime.',
|
||||
type: 'Bytes'
|
||||
});
|
||||
|
||||
export const heapPages = createRuntimeFunction('heapPages', ':heappages', {
|
||||
documentation: 'Number of wasm linear memory pages required for execution of the runtime.',
|
||||
type: 'u64'
|
||||
});
|
||||
|
||||
export const extrinsicIndex = createRuntimeFunction('extrinsicIndex', ':extrinsic_index', {
|
||||
documentation: 'Current extrinsic index (u32) is stored under this key.',
|
||||
type: 'u32'
|
||||
});
|
||||
|
||||
export const changesTrieConfig = createRuntimeFunction('changesTrieConfig', ':changes_trie', {
|
||||
documentation: 'Changes trie configuration is stored under this key.',
|
||||
type: 'u32'
|
||||
});
|
||||
|
||||
export const childStorageKeyPrefix = createRuntimeFunction('childStorageKeyPrefix', ':child_storage:', {
|
||||
documentation: 'Prefix of child storage keys.',
|
||||
type: 'u32'
|
||||
});
|
||||
export const substrate: Record<string, Creator> = {
|
||||
changesTrieConfig: createRuntimeFunction('changesTrieConfig', ':changes_trie', {
|
||||
documentation: ' Changes trie configuration is stored under this key.',
|
||||
type: 'u32'
|
||||
}),
|
||||
childStorageKeyPrefix: createRuntimeFunction('childStorageKeyPrefix', ':child_storage:', {
|
||||
documentation: ' Prefix of child storage keys.',
|
||||
type: 'u32'
|
||||
}),
|
||||
code: createRuntimeFunction('code', ':code', {
|
||||
documentation: ' Wasm code of the runtime.',
|
||||
type: 'Bytes'
|
||||
}),
|
||||
extrinsicIndex: createRuntimeFunction('extrinsicIndex', ':extrinsic_index', {
|
||||
documentation: ' Current extrinsic index (u32) is stored under this key.',
|
||||
type: 'u32'
|
||||
}),
|
||||
heapPages: createRuntimeFunction('heapPages', ':heappages', {
|
||||
documentation: ' Number of wasm linear memory pages required for execution of the runtime.',
|
||||
type: 'u64'
|
||||
})
|
||||
};
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/metadata', version: '4.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/metadata', version: '4.11.2' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import metadata from './v12/static';
|
||||
import metadata from './v13/static';
|
||||
|
||||
export default metadata;
|
||||
|
||||
@@ -4,16 +4,16 @@
|
||||
type Types = string | Types[];
|
||||
|
||||
/** @internal */
|
||||
export function flattenUniq (list: Types[]): string[] {
|
||||
const flat = list.reduce((result: string[], entry): string[] => {
|
||||
return result.concat(
|
||||
Array.isArray(entry)
|
||||
? flattenUniq(entry)
|
||||
: entry
|
||||
);
|
||||
}, []);
|
||||
export function flattenUniq (list: Types[], start: string[] = []): string[] {
|
||||
return [...new Set(
|
||||
list.reduce((result: string[], entry): string[] => {
|
||||
if (Array.isArray(entry)) {
|
||||
return flattenUniq(entry, result);
|
||||
}
|
||||
|
||||
return [...new Set(flat)]
|
||||
.filter((value: string) => value)
|
||||
.sort();
|
||||
result.push(entry);
|
||||
|
||||
return result;
|
||||
}, start)
|
||||
)];
|
||||
}
|
||||
|
||||
@@ -12,10 +12,11 @@ type Arg = { type: Type } & Codec;
|
||||
|
||||
type Item = {
|
||||
type: {
|
||||
isDoubleMap?: boolean;
|
||||
isDoubleMap: boolean;
|
||||
isMap: boolean;
|
||||
isNMap: boolean;
|
||||
isPlain: boolean;
|
||||
asDoubleMap?: {
|
||||
asDoubleMap: {
|
||||
key1: Text;
|
||||
key2: Text;
|
||||
value: Text;
|
||||
@@ -24,16 +25,15 @@ type Item = {
|
||||
key: Text;
|
||||
value: Text;
|
||||
};
|
||||
asNMap: {
|
||||
keyVec: Text[];
|
||||
value: Text;
|
||||
},
|
||||
asPlain: Text;
|
||||
};
|
||||
} & Codec;
|
||||
|
||||
type Storage = Option<Vec<Item> | {
|
||||
// v0
|
||||
functions?: Vec<Item>;
|
||||
// V7+
|
||||
items?: Vec<Item>;
|
||||
} & Codec>;
|
||||
type Storage = Option<{ items: Vec<Item> } & Codec>;
|
||||
|
||||
type Call = { args: Vec<Arg> } & Codec;
|
||||
|
||||
@@ -44,12 +44,6 @@ type Event = { args: Vec<Type> } & Codec;
|
||||
type Events = Option<Vec<Event>>;
|
||||
|
||||
type Module = {
|
||||
// V0
|
||||
module?: {
|
||||
call: {
|
||||
functions: Vec<Call>;
|
||||
};
|
||||
};
|
||||
// V1+
|
||||
calls?: Calls;
|
||||
// V6+
|
||||
@@ -60,30 +54,25 @@ type Module = {
|
||||
|
||||
interface ExtractionMetadata {
|
||||
modules: Vec<Module>;
|
||||
|
||||
// V0
|
||||
outerEvent?: {
|
||||
events: Vec<[Text, Vec<Event>] & Codec>;
|
||||
};
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function unwrapCalls (mod: Module): Call[] {
|
||||
return mod.calls
|
||||
? mod.calls.unwrapOr([])
|
||||
// V0
|
||||
: mod.module
|
||||
? mod.module.call.functions
|
||||
: [];
|
||||
: [];
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function typeToString ({ type }: Arg): string {
|
||||
return type.toString();
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function getCallNames ({ modules }: ExtractionMetadata): string[][][] {
|
||||
return modules.map((mod): string[][] =>
|
||||
unwrapCalls(mod).map(({ args }): string[] =>
|
||||
args.map((arg): string =>
|
||||
arg.type.toString()
|
||||
)
|
||||
args.map(typeToString)
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -91,90 +80,66 @@ function getCallNames ({ modules }: ExtractionMetadata): string[][][] {
|
||||
/** @internal */
|
||||
function getConstantNames ({ modules }: ExtractionMetadata): string[][] {
|
||||
return modules.map(({ constants }): string[] =>
|
||||
constants
|
||||
? constants.map((constant): string =>
|
||||
constant.type.toString()
|
||||
)
|
||||
: []
|
||||
(constants || []).map(typeToString)
|
||||
);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function unwrapEvents (events?: Events): Event[] {
|
||||
if (!events) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return events.unwrapOr([]);
|
||||
return events
|
||||
? events.unwrapOr([])
|
||||
: [];
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function getEventNames ({ modules, outerEvent }: ExtractionMetadata): string[][][] {
|
||||
const mapArg = ({ args }: Event): string[] =>
|
||||
args.map((arg): string =>
|
||||
arg.toString()
|
||||
);
|
||||
|
||||
// V0
|
||||
if (outerEvent) {
|
||||
return outerEvent.events.map(([, events]): string[][] =>
|
||||
events.map(mapArg)
|
||||
);
|
||||
}
|
||||
|
||||
// V1+
|
||||
function getEventNames ({ modules }: ExtractionMetadata): string[][][] {
|
||||
return modules.map(({ events }): string[][] =>
|
||||
unwrapEvents(events).map(mapArg)
|
||||
unwrapEvents(events).map(({ args }: Event): string[] =>
|
||||
args.map((a) => a.toString())
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function unwrapStorage (storage?: Storage): Item[] {
|
||||
if (!storage) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const data = storage.unwrapOr([]);
|
||||
|
||||
return Array.isArray(data)
|
||||
? data
|
||||
: (data.items || data.functions) as Item[];
|
||||
return storage
|
||||
? storage.unwrapOr({ items: [] }).items
|
||||
: [];
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function getStorageNames ({ modules }: ExtractionMetadata): string[][][] {
|
||||
return modules.map(({ storage }): string[][] =>
|
||||
unwrapStorage(storage).map(({ type }): string[] => {
|
||||
if (type.isDoubleMap && type.asDoubleMap) {
|
||||
return [
|
||||
type.asDoubleMap.key1.toString(),
|
||||
type.asDoubleMap.key2.toString(),
|
||||
type.asDoubleMap.value.toString()
|
||||
];
|
||||
} else if (type.isMap) {
|
||||
return [
|
||||
type.asMap.key.toString(),
|
||||
type.asMap.value.toString()
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
unwrapStorage(storage).map(({ type }) =>
|
||||
type.isPlain
|
||||
? [
|
||||
type.asPlain.toString()
|
||||
];
|
||||
}
|
||||
})
|
||||
]
|
||||
: type.isMap
|
||||
? [
|
||||
type.asMap.value.toString(),
|
||||
type.asMap.key.toString()
|
||||
]
|
||||
: type.isDoubleMap
|
||||
? [
|
||||
type.asDoubleMap.value.toString(),
|
||||
type.asDoubleMap.key1.toString(),
|
||||
type.asDoubleMap.key2.toString()
|
||||
]
|
||||
: [
|
||||
type.asNMap.value.toString(),
|
||||
...type.asNMap.keyVec.map((k) => k.toString())
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getUniqTypes (registry: Registry, meta: ExtractionMetadata, throwError: boolean): string[] {
|
||||
const types = flattenUniq([
|
||||
return validateTypes(registry, throwError, flattenUniq([
|
||||
getCallNames(meta),
|
||||
getConstantNames(meta),
|
||||
getEventNames(meta),
|
||||
getStorageNames(meta)
|
||||
]);
|
||||
|
||||
validateTypes(registry, types, throwError);
|
||||
|
||||
return types;
|
||||
]));
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { Codec, Registry } from '@polkadot/types/types';
|
||||
import type { MetadataInterface } from '../types';
|
||||
|
||||
import { unwrapStorageType } from '@polkadot/types/primitive/StorageKey';
|
||||
import { assert, hexToU8a, u8aToHex } from '@polkadot/util';
|
||||
import { assert, hexToU8a, stringify, u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { Metadata } from '../Metadata';
|
||||
import { getUniqTypes } from './getUniqTypes';
|
||||
@@ -22,7 +22,7 @@ export function decodeLatestSubstrate<Modules extends Codec> (registry: Registry
|
||||
expect((metadata[`asV${version}` as keyof Metadata] as unknown as MetadataInterface<Modules>).modules.length).not.toBe(0);
|
||||
expect(metadata.toJSON()).toEqual(staticSubstrate);
|
||||
} catch (error) {
|
||||
console.error(JSON.stringify(metadata.toJSON()));
|
||||
console.error(stringify(metadata.toJSON()));
|
||||
|
||||
throw error;
|
||||
}
|
||||
@@ -65,7 +65,7 @@ export function defaultValues (registry: Registry, rpcData: string, withThrow =
|
||||
if (withFallbackCheck) {
|
||||
const [hexType, hexOrig] = [u8aToHex(type.toU8a()), u8aToHex(fallback.toU8a(true))];
|
||||
|
||||
assert(hexType === hexOrig, `Fallback does not match (${((hexOrig.length - 2) / 2) - ((hexType.length - 2) / 2)} bytes missing): ${hexType} !== ${hexOrig}`);
|
||||
assert(hexType === hexOrig, () => `Fallback does not match (${((hexOrig.length - 2) / 2) - ((hexType.length - 2) / 2)} bytes missing): ${hexType} !== ${hexOrig}`);
|
||||
}
|
||||
} catch (error) {
|
||||
const message = `${location}:: ${(error as Error).message}`;
|
||||
|
||||
@@ -11,8 +11,10 @@ import { flattenUniq } from './flattenUniq';
|
||||
const l = logger('metadata');
|
||||
|
||||
/** @internal */
|
||||
export function validateTypes (registry: Registry, types: string[], throwError: boolean): void {
|
||||
const missing = flattenUniq(extractTypes(types)).filter((type) => !registry.hasType(type));
|
||||
export function validateTypes (registry: Registry, throwError: boolean, types: string[]): string[] {
|
||||
const missing = flattenUniq(extractTypes(types))
|
||||
.filter((type) => !registry.hasType(type))
|
||||
.sort();
|
||||
|
||||
if (missing.length !== 0) {
|
||||
const message = `Unknown types found, no types for ${missing.join(', ')}`;
|
||||
@@ -23,4 +25,6 @@ export function validateTypes (registry: Registry, types: string[], throwError:
|
||||
l.warn(message);
|
||||
}
|
||||
}
|
||||
|
||||
return types;
|
||||
}
|
||||
|
||||
@@ -499,7 +499,7 @@
|
||||
{
|
||||
"name": "Version",
|
||||
"type": "RuntimeVersion",
|
||||
"value": "0x106e6f6465387375627374726174652d6e6f64650a000000090100000000000034df6acb689907609b0300000037e397fc7c91f5e40100000040fe3ad401f8959a04000000d2bc9897eed08f1502000000f78b278be53f454c02000000ed99c5acb25eedf502000000cbca25e39f14238702000000687ad44ad37f03c201000000bc9d89904f5b923f0100000068b66ba122c93fa70100000037c8bb1350a9a2a80100000091d5df18b0d2cf5801000000ab3c0572291feb8b0100000002000000",
|
||||
"value": "0x106e6f6465387375627374726174652d6e6f64650a000000090100000100000034df6acb689907609b0300000037e397fc7c91f5e40100000040fe3ad401f8959a04000000d2bc9897eed08f1502000000f78b278be53f454c02000000ed99c5acb25eedf502000000cbca25e39f14238702000000687ad44ad37f03c201000000bc9d89904f5b923f0100000068b66ba122c93fa70100000037c8bb1350a9a2a80100000091d5df18b0d2cf5801000000ab3c0572291feb8b0100000002000000",
|
||||
"documentation": [
|
||||
" Get the chain's current version."
|
||||
]
|
||||
@@ -947,13 +947,11 @@
|
||||
{
|
||||
"name": "EpochDuration",
|
||||
"type": "u64",
|
||||
"value": "0x1400000000000000",
|
||||
"value": "0xc800000000000000",
|
||||
"documentation": [
|
||||
" 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.",
|
||||
" NOTE: Currently it is not possible to change the epoch duration",
|
||||
" after the chain has started. Attempting to do so will brick block",
|
||||
" production."
|
||||
" The amount of time, in slots, that each epoch should last.",
|
||||
" NOTE: Currently it is not possible to change the epoch duration after",
|
||||
" the chain has started. Attempting to do so will brick block production."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -969,7 +967,26 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"errors": [],
|
||||
"errors": [
|
||||
{
|
||||
"name": "InvalidEquivocationProof",
|
||||
"documentation": [
|
||||
" An equivocation proof provided as part of an equivocation report is invalid."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "InvalidKeyOwnershipProof",
|
||||
"documentation": [
|
||||
" A key ownership proof provided as part of an equivocation report is invalid."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "DuplicateOffenceReport",
|
||||
"documentation": [
|
||||
" A given equivocation report is valid but already previously reported."
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 2
|
||||
},
|
||||
{
|
||||
@@ -1375,7 +1392,38 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"errors": [],
|
||||
"errors": [
|
||||
{
|
||||
"name": "NotAssigned",
|
||||
"documentation": [
|
||||
" The index was not already assigned."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "NotOwner",
|
||||
"documentation": [
|
||||
" The index is assigned to another account."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "InUse",
|
||||
"documentation": [
|
||||
" The index was not available."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "NotTransfer",
|
||||
"documentation": [
|
||||
" The source and destination accounts are identical."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Permanent",
|
||||
"documentation": [
|
||||
" The index is permanent and may not be freed/changed."
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 5
|
||||
},
|
||||
{
|
||||
@@ -1954,7 +2002,7 @@
|
||||
{
|
||||
"name": "UnsignedPhase",
|
||||
"type": "BlockNumber",
|
||||
"value": "0x05000000",
|
||||
"value": "0x32000000",
|
||||
"documentation": [
|
||||
" Duration of the unsigned phase."
|
||||
]
|
||||
@@ -1962,7 +2010,7 @@
|
||||
{
|
||||
"name": "SignedPhase",
|
||||
"type": "BlockNumber",
|
||||
"value": "0x05000000",
|
||||
"value": "0x32000000",
|
||||
"documentation": [
|
||||
" Duration of the signed phase."
|
||||
]
|
||||
@@ -1970,7 +2018,7 @@
|
||||
{
|
||||
"name": "SolutionImprovementThreshold",
|
||||
"type": "Perbill",
|
||||
"value": "0x20a10700",
|
||||
"value": "0xa0860100",
|
||||
"documentation": [
|
||||
" The minimum amount of improvement to the solution score that defines a solution as",
|
||||
" \"better\" (in any phase)."
|
||||
@@ -2463,102 +2511,18 @@
|
||||
" This is basically in sync with the call to [`SessionManager::new_session`]."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SnapshotValidators",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"plain": "Vec<AccountId>"
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" Snapshot of validators at the beginning of the current election window. This should only",
|
||||
" have a value when [`EraElectionStatus`] == `ElectionStatus::Open(_)`.",
|
||||
"",
|
||||
" TWO_PHASE_NOTE: should be removed once we switch to multi-phase."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SnapshotNominators",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"plain": "Vec<AccountId>"
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" Snapshot of nominators at the beginning of the current election window. This should only",
|
||||
" have a value when [`EraElectionStatus`] == `ElectionStatus::Open(_)`.",
|
||||
"",
|
||||
" TWO_PHASE_NOTE: should be removed once we switch to multi-phase."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "QueuedElected",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"plain": "ElectionResult"
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" The next validator set. At the end of an era, if this is available (potentially from the",
|
||||
" result of an offchain worker), it is immediately used. Otherwise, the on-chain election",
|
||||
" is executed.",
|
||||
"",
|
||||
" TWO_PHASE_NOTE: should be removed once we switch to multi-phase."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "QueuedScore",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"plain": "ElectionScore"
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" The score of the current [`QueuedElected`].",
|
||||
"",
|
||||
" TWO_PHASE_NOTE: should be removed once we switch to multi-phase."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "EraElectionStatus",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"plain": "ElectionStatus"
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" Flag to control the execution of the offchain election. When `Open(_)`, we accept",
|
||||
" solutions to be submitted.",
|
||||
"",
|
||||
" TWO_PHASE_NOTE: should be removed once we switch to multi-phase."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "IsCurrentSessionFinal",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"plain": "bool"
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" True if the current **planned** session is final. Note that this does not take era",
|
||||
" forcing into account.",
|
||||
"",
|
||||
" TWO_PHASE_NOTE: should be removed once we switch to multi-phase."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "StorageVersion",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"plain": "Releases"
|
||||
},
|
||||
"fallback": "0x04",
|
||||
"fallback": "0x05",
|
||||
"documentation": [
|
||||
" True if network has been upgraded to this version.",
|
||||
" Storage version of the pallet.",
|
||||
"",
|
||||
" This is set to v5.0.0 for new networks."
|
||||
" This is set to v6.0.0 for new networks."
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -3163,118 +3127,6 @@
|
||||
" # </weight>"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "submit_election_solution",
|
||||
"args": [
|
||||
{
|
||||
"name": "winners",
|
||||
"type": "Vec<ValidatorIndex>"
|
||||
},
|
||||
{
|
||||
"name": "compact",
|
||||
"type": "CompactAssignments"
|
||||
},
|
||||
{
|
||||
"name": "score",
|
||||
"type": "ElectionScore"
|
||||
},
|
||||
{
|
||||
"name": "era",
|
||||
"type": "EraIndex"
|
||||
},
|
||||
{
|
||||
"name": "size",
|
||||
"type": "ElectionSize"
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
" Submit an election result to the chain. If the solution:",
|
||||
"",
|
||||
" 1. is valid.",
|
||||
" 2. has a better score than a potentially existing solution on chain.",
|
||||
"",
|
||||
" then, it will be _put_ on chain.",
|
||||
"",
|
||||
" A solution consists of two pieces of data:",
|
||||
"",
|
||||
" 1. `winners`: a flat vector of all the winners of the round.",
|
||||
" 2. `assignments`: the compact version of an assignment vector that encodes the edge",
|
||||
" weights.",
|
||||
"",
|
||||
" Both of which may be computed using _phragmen_, or any other algorithm.",
|
||||
"",
|
||||
" Additionally, the submitter must provide:",
|
||||
"",
|
||||
" - The `score` that they claim their solution has.",
|
||||
"",
|
||||
" Both validators and nominators will be represented by indices in the solution. The",
|
||||
" indices should respect the corresponding types ([`ValidatorIndex`] and",
|
||||
" [`NominatorIndex`]). Moreover, they should be valid when used to index into",
|
||||
" [`SnapshotValidators`] and [`SnapshotNominators`]. Any invalid index will cause the",
|
||||
" solution to be rejected. These two storage items are set during the election window and",
|
||||
" may be used to determine the indices.",
|
||||
"",
|
||||
" A solution is valid if:",
|
||||
"",
|
||||
" 0. It is submitted when [`EraElectionStatus`] is `Open`.",
|
||||
" 1. Its claimed score is equal to the score computed on-chain.",
|
||||
" 2. Presents the correct number of winners.",
|
||||
" 3. All indexes must be value according to the snapshot vectors. All edge values must",
|
||||
" also be correct and should not overflow the granularity of the ratio type (i.e. 256",
|
||||
" or billion).",
|
||||
" 4. For each edge, all targets are actually nominated by the voter.",
|
||||
" 5. Has correct self-votes.",
|
||||
"",
|
||||
" A solutions score is consisted of 3 parameters:",
|
||||
"",
|
||||
" 1. `min { support.total }` for each support of a winner. This value should be maximized.",
|
||||
" 2. `sum { support.total }` for each support of a winner. This value should be minimized.",
|
||||
" 3. `sum { support.total^2 }` for each support of a winner. This value should be",
|
||||
" minimized (to ensure less variance)",
|
||||
"",
|
||||
" # <weight>",
|
||||
" The transaction is assumed to be the longest path, a better solution.",
|
||||
" - Initial solution is almost the same.",
|
||||
" - Worse solution is retraced in pre-dispatch-checks which sets its own weight.",
|
||||
" # </weight>"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "submit_election_solution_unsigned",
|
||||
"args": [
|
||||
{
|
||||
"name": "winners",
|
||||
"type": "Vec<ValidatorIndex>"
|
||||
},
|
||||
{
|
||||
"name": "compact",
|
||||
"type": "CompactAssignments"
|
||||
},
|
||||
{
|
||||
"name": "score",
|
||||
"type": "ElectionScore"
|
||||
},
|
||||
{
|
||||
"name": "era",
|
||||
"type": "EraIndex"
|
||||
},
|
||||
{
|
||||
"name": "size",
|
||||
"type": "ElectionSize"
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
" Unsigned version of `submit_election_solution`.",
|
||||
"",
|
||||
" Note that this must pass the [`ValidateUnsigned`] check which only allows transactions",
|
||||
" from the local node to be included. In other words, only the block author can include a",
|
||||
" transaction in the block.",
|
||||
"",
|
||||
" # <weight>",
|
||||
" See [`submit_election_solution`].",
|
||||
" # </weight>"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "kick",
|
||||
"args": [
|
||||
@@ -3347,20 +3199,9 @@
|
||||
},
|
||||
{
|
||||
"name": "StakingElection",
|
||||
"args": [
|
||||
"ElectionCompute"
|
||||
],
|
||||
"args": [],
|
||||
"documentation": [
|
||||
" A new set of stakers was elected with the given \\[compute\\]."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SolutionStored",
|
||||
"args": [
|
||||
"ElectionCompute"
|
||||
],
|
||||
"documentation": [
|
||||
" A new solution for the upcoming election has been stored. \\[compute\\]"
|
||||
" A new set of stakers was elected."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -3437,38 +3278,6 @@
|
||||
" intervention."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ElectionLookahead",
|
||||
"type": "BlockNumber",
|
||||
"value": "0x05000000",
|
||||
"documentation": [
|
||||
" The number of blocks before the end of the era from which election submissions are allowed.",
|
||||
"",
|
||||
" Setting this to zero will disable the offchain compute and only on-chain seq-phragmen will",
|
||||
" be used.",
|
||||
"",
|
||||
" This is bounded by being within the last session. Hence, setting it to a value more than the",
|
||||
" length of a session will be pointless."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "MaxIterations",
|
||||
"type": "u32",
|
||||
"value": "0x0a000000",
|
||||
"documentation": [
|
||||
" Maximum number of balancing iterations to run in the offchain submission.",
|
||||
"",
|
||||
" If set to 0, balance_solution will not be executed at all."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "MinSolutionScoreBump",
|
||||
"type": "Perbill",
|
||||
"value": "0x20a10700",
|
||||
"documentation": [
|
||||
" The threshold of improvement that should be provided for a new solution to be accepted."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "MaxNominatorRewardedPerValidator",
|
||||
"type": "u32",
|
||||
@@ -3479,6 +3288,14 @@
|
||||
" For each validator only the `$MaxNominatorRewardedPerValidator` biggest stakers can claim",
|
||||
" their reward. This used to limit the i/o cost for the nominator payout."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "MaxNominations",
|
||||
"type": "u32",
|
||||
"value": "0x10000000",
|
||||
"documentation": [
|
||||
" Maximum number of nominations per nominator."
|
||||
]
|
||||
}
|
||||
],
|
||||
"errors": [
|
||||
@@ -3572,93 +3389,6 @@
|
||||
" Rewards for this era have already been claimed for this validator."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "OffchainElectionEarlySubmission",
|
||||
"documentation": [
|
||||
" The submitted result is received out of the open window."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "OffchainElectionWeakSubmission",
|
||||
"documentation": [
|
||||
" The submitted result is not as good as the one stored on chain."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SnapshotUnavailable",
|
||||
"documentation": [
|
||||
" The snapshot data of the current window is missing."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "OffchainElectionBogusWinnerCount",
|
||||
"documentation": [
|
||||
" Incorrect number of winners were presented."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "OffchainElectionBogusWinner",
|
||||
"documentation": [
|
||||
" One of the submitted winners is not an active candidate on chain (index is out of range",
|
||||
" in snapshot)."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "OffchainElectionBogusCompact",
|
||||
"documentation": [
|
||||
" Error while building the assignment type from the compact. This can happen if an index",
|
||||
" is invalid, or if the weights _overflow_."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "OffchainElectionBogusNominator",
|
||||
"documentation": [
|
||||
" One of the submitted nominators is not an active nominator on chain."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "OffchainElectionBogusNomination",
|
||||
"documentation": [
|
||||
" One of the submitted nominators has an edge to which they have not voted on chain."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "OffchainElectionSlashedNomination",
|
||||
"documentation": [
|
||||
" One of the submitted nominators has an edge which is submitted before the last non-zero",
|
||||
" slash of the target."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "OffchainElectionBogusSelfVote",
|
||||
"documentation": [
|
||||
" A self vote must only be originated from a validator to ONLY themselves."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "OffchainElectionBogusEdge",
|
||||
"documentation": [
|
||||
" The submitted result has unknown edges that are not among the presented winners."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "OffchainElectionBogusScore",
|
||||
"documentation": [
|
||||
" The claimed score does not match with the one computed from the data."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "OffchainElectionBogusElectionSize",
|
||||
"documentation": [
|
||||
" The election size is invalid."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CallNotAllowed",
|
||||
"documentation": [
|
||||
" The call is not allowed at the given time due to restrictions of election period."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "IncorrectHistoryDepth",
|
||||
"documentation": [
|
||||
@@ -6056,7 +5786,7 @@
|
||||
{
|
||||
"name": "Elections",
|
||||
"storage": {
|
||||
"prefix": "PhragmenElection",
|
||||
"prefix": "Elections",
|
||||
"items": [
|
||||
{
|
||||
"name": "Members",
|
||||
@@ -6226,8 +5956,8 @@
|
||||
" origin is removed as a runner-up.",
|
||||
" - `origin` is a current member. In this case, the deposit is unreserved and origin is",
|
||||
" removed as a member, consequently not being a candidate for the next round anymore.",
|
||||
" Similar to [`remove_members`], if replacement runners exists, they are immediately used.",
|
||||
" If the prime is renouncing, then no prime will exist until the next round.",
|
||||
" Similar to [`remove_members`], if replacement runners exists, they are immediately",
|
||||
" used. If the prime is renouncing, then no prime will exist until the next round.",
|
||||
"",
|
||||
" The dispatch origin of this call must be signed, and have one of the above roles.",
|
||||
"",
|
||||
@@ -6298,10 +6028,11 @@
|
||||
"Vec<(AccountId,Balance)>"
|
||||
],
|
||||
"documentation": [
|
||||
" A new term with \\[new_members\\]. This indicates that enough candidates existed to run the",
|
||||
" election, not that enough have has been elected. The inner value must be examined for",
|
||||
" this purpose. A `NewTerm(\\[\\])` indicates that some candidates got their bond slashed and",
|
||||
" none were elected, whilst `EmptyTerm` means that no candidates existed to begin with."
|
||||
" A new term with \\[new_members\\]. This indicates that enough candidates existed to run",
|
||||
" the election, not that enough have has been elected. The inner value must be examined",
|
||||
" for this purpose. A `NewTerm(\\[\\])` indicates that some candidates got their bond",
|
||||
" slashed and none were elected, whilst `EmptyTerm` means that no candidates existed to",
|
||||
" begin with."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -6363,47 +6094,66 @@
|
||||
}
|
||||
],
|
||||
"constants": [
|
||||
{
|
||||
"name": "PalletId",
|
||||
"type": "LockIdentifier",
|
||||
"value": "0x706872656c656374",
|
||||
"documentation": [
|
||||
" Identifier for the elections-phragmen pallet's lock"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CandidacyBond",
|
||||
"type": "BalanceOf",
|
||||
"value": "0x0080c6a47e8d03000000000000000000",
|
||||
"documentation": []
|
||||
"documentation": [
|
||||
" How much should be locked up in order to submit one's candidacy."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "VotingBondBase",
|
||||
"type": "BalanceOf",
|
||||
"value": "0x00f0436de36a01000000000000000000",
|
||||
"documentation": []
|
||||
"documentation": [
|
||||
" Base deposit associated with voting.",
|
||||
"",
|
||||
" This should be sensibly high to economically ensure the pallet cannot be attacked by",
|
||||
" creating a gigantic number of votes."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "VotingBondFactor",
|
||||
"type": "BalanceOf",
|
||||
"value": "0x0000cc7b9fae00000000000000000000",
|
||||
"documentation": []
|
||||
"documentation": [
|
||||
" The amount of bond that need to be locked for each vote (32 bytes)."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "DesiredMembers",
|
||||
"type": "u32",
|
||||
"value": "0x0d000000",
|
||||
"documentation": []
|
||||
"documentation": [
|
||||
" Number of members to elect."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "DesiredRunnersUp",
|
||||
"type": "u32",
|
||||
"value": "0x07000000",
|
||||
"documentation": []
|
||||
"documentation": [
|
||||
" Number of runners_up to keep."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TermDuration",
|
||||
"type": "BlockNumber",
|
||||
"value": "0x80130300",
|
||||
"documentation": []
|
||||
},
|
||||
{
|
||||
"name": "ModuleId",
|
||||
"type": "LockIdentifier",
|
||||
"value": "0x706872656c656374",
|
||||
"documentation": []
|
||||
"documentation": [
|
||||
" How long each seat is kept. This defines the next block number at which an election",
|
||||
" round will happen. If set to zero, no elections are ever triggered and the module will",
|
||||
" be in passive mode."
|
||||
]
|
||||
}
|
||||
],
|
||||
"errors": [
|
||||
@@ -6692,7 +6442,20 @@
|
||||
}
|
||||
],
|
||||
"constants": [],
|
||||
"errors": [],
|
||||
"errors": [
|
||||
{
|
||||
"name": "AlreadyMember",
|
||||
"documentation": [
|
||||
" Already a member."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "NotMember",
|
||||
"documentation": [
|
||||
" Not a member."
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 15
|
||||
},
|
||||
{
|
||||
@@ -7134,8 +6897,8 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ModuleId",
|
||||
"type": "ModuleId",
|
||||
"name": "PalletId",
|
||||
"type": "PalletId",
|
||||
"value": "0x70792f7472737279",
|
||||
"documentation": [
|
||||
" The treasury's module id, used for deriving its sovereign account ID."
|
||||
@@ -7154,6 +6917,12 @@
|
||||
"documentation": [
|
||||
" No proposal or bounty at that index."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TooManyApprovals",
|
||||
"documentation": [
|
||||
" Too many approvals in the queue."
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 17
|
||||
@@ -7335,7 +7104,7 @@
|
||||
" * `gas_limit`: The gas limit enforced when executing the constructor.",
|
||||
" * `code`: The contract code to deploy in raw bytes.",
|
||||
" * `data`: The input data to pass to the contract constructor.",
|
||||
" * `salt`: Used for the address derivation. See [`Self::contract_address`].",
|
||||
" * `salt`: Used for the address derivation. See [`Pallet::contract_address`].",
|
||||
"",
|
||||
" Instantiation is executed as follows:",
|
||||
"",
|
||||
@@ -9878,12 +9647,20 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ModuleId",
|
||||
"type": "ModuleId",
|
||||
"name": "PalletId",
|
||||
"type": "PalletId",
|
||||
"value": "0x70792f736f636965",
|
||||
"documentation": [
|
||||
" The societies's module id"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "MaxCandidateIntake",
|
||||
"type": "u32",
|
||||
"value": "0x0a000000",
|
||||
"documentation": [
|
||||
" Maximum candidate intake per round."
|
||||
]
|
||||
}
|
||||
],
|
||||
"errors": [
|
||||
@@ -10583,7 +10360,7 @@
|
||||
" Unlock any vested funds of the sender account.",
|
||||
"",
|
||||
" The dispatch origin for this call must be _Signed_ and the sender must have funds still",
|
||||
" locked under this module.",
|
||||
" locked under this pallet.",
|
||||
"",
|
||||
" Emits either `VestingCompleted` or `VestingUpdated`.",
|
||||
"",
|
||||
@@ -10609,7 +10386,7 @@
|
||||
" The dispatch origin for this call must be _Signed_.",
|
||||
"",
|
||||
" - `target`: The account whose vested funds should be unlocked. Must have funds still",
|
||||
" locked under this module.",
|
||||
" locked under this pallet.",
|
||||
"",
|
||||
" Emits either `VestingCompleted` or `VestingUpdated`.",
|
||||
"",
|
||||
@@ -10718,7 +10495,7 @@
|
||||
"type": "BalanceOf",
|
||||
"value": "0x0000c16ff28623000000000000000000",
|
||||
"documentation": [
|
||||
" The minimum amount to be transferred to create a new vesting schedule."
|
||||
" The minimum amount transferred to call `vested_transfer`."
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -11397,7 +11174,7 @@
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
" Dispatch the given `call` from an account that the sender is authorised for through",
|
||||
" Dispatch the given `call` from an account that the sender is authorized for through",
|
||||
" `add_proxy`.",
|
||||
"",
|
||||
" Removes any corresponding announcement(s).",
|
||||
@@ -11458,7 +11235,10 @@
|
||||
"type": "BalanceOf",
|
||||
"value": "0x00f09e544c3900000000000000000000",
|
||||
"documentation": [
|
||||
" The base amount of currency needed to reserve for creating a proxy."
|
||||
" The base amount of currency needed to reserve for creating a proxy.",
|
||||
"",
|
||||
" This is held for an additional storage item whose value size is",
|
||||
" `sizeof(Balance)` bytes and whose key size is `sizeof(AccountId)` bytes."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -11466,7 +11246,11 @@
|
||||
"type": "BalanceOf",
|
||||
"value": "0x0060aa7714b400000000000000000000",
|
||||
"documentation": [
|
||||
" The amount of currency needed per proxy added."
|
||||
" The amount of currency needed per proxy added.",
|
||||
"",
|
||||
" This is held for adding 32 bytes plus an instance of `ProxyType` more into a pre-existing",
|
||||
" storage value. Thus, when configuring `ProxyDepositFactor` one should take into account",
|
||||
" `32 + proxy_type.encode().len()` bytes of data."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -11482,7 +11266,7 @@
|
||||
"type": "u32",
|
||||
"value": "0x20000000",
|
||||
"documentation": [
|
||||
" `MaxPending` metadata shadow."
|
||||
" The maximum amount of time-delayed announcements that are allowed to be pending."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -11490,7 +11274,9 @@
|
||||
"type": "BalanceOf",
|
||||
"value": "0x00f09e544c3900000000000000000000",
|
||||
"documentation": [
|
||||
" `AnnouncementDepositBase` metadata shadow."
|
||||
" The base amount of currency needed to reserve for creating an announcement.",
|
||||
"",
|
||||
" This is held when a new storage item holding a `Balance` is created (typically 16 bytes)."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -11498,7 +11284,10 @@
|
||||
"type": "BalanceOf",
|
||||
"value": "0x00c054ef286801000000000000000000",
|
||||
"documentation": [
|
||||
" `AnnouncementDepositFactor` metadata shadow."
|
||||
" The amount of currency needed per announcement made.",
|
||||
"",
|
||||
" This is held for adding an `AccountId`, `Hash` and `BlockNumber` (typically 68 bytes)",
|
||||
" into a pre-existing storage value."
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -12911,8 +12700,7 @@
|
||||
"",
|
||||
" The origin must be Signed and the sender must have sufficient funds free.",
|
||||
"",
|
||||
" Funds of sender are reserved according to the formula:",
|
||||
" `AssetDepositBase + AssetDepositPerZombie * max_zombies`.",
|
||||
" Funds of sender are reserved by `AssetDeposit`.",
|
||||
"",
|
||||
" Parameters:",
|
||||
" - `id`: The identifier of the new asset. This must not be currently in use to identify",
|
||||
@@ -14199,8 +13987,8 @@
|
||||
],
|
||||
"constants": [
|
||||
{
|
||||
"name": "ModuleId",
|
||||
"type": "ModuleId",
|
||||
"name": "PalletId",
|
||||
"type": "PalletId",
|
||||
"value": "0x70792f6c6f74746f",
|
||||
"documentation": []
|
||||
},
|
||||
@@ -14211,7 +13999,56 @@
|
||||
"documentation": []
|
||||
}
|
||||
],
|
||||
"errors": [],
|
||||
"errors": [
|
||||
{
|
||||
"name": "Overflow",
|
||||
"documentation": [
|
||||
" An overflow has occurred."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "NotConfigured",
|
||||
"documentation": [
|
||||
" A lottery has not been configured."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "InProgress",
|
||||
"documentation": [
|
||||
" A lottery is already in progress."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "AlreadyEnded",
|
||||
"documentation": [
|
||||
" A lottery has already ended."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "InvalidCall",
|
||||
"documentation": [
|
||||
" The call is not valid for an open lottery."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "AlreadyParticipating",
|
||||
"documentation": [
|
||||
" You are already participating in the lottery with this call."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TooManyCalls",
|
||||
"documentation": [
|
||||
" Too many calls for a single lottery."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "EncodingFailed",
|
||||
"documentation": [
|
||||
" Failed to encode calls"
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 36
|
||||
},
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user