Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1a1be49c5 | ||
|
|
4b6ad647a2 | ||
|
|
04f656cafa | ||
|
|
09bbd5f6c9 | ||
|
|
dbc3df6d09 | ||
|
|
26865f92e3 | ||
|
|
73045de73d | ||
|
|
6d3491b9f1 | ||
|
|
886f3a3c08 | ||
|
|
c72f976895 | ||
|
|
ab8b381d8b | ||
|
|
443e29a3be | ||
|
|
117bb5717a | ||
|
|
5fb76baa16 | ||
|
|
274b3498d4 | ||
|
|
fa9e1c53e1 | ||
|
|
3ebf7eb424 | ||
|
|
7d11e6f9a5 | ||
|
|
a0d6384b01 | ||
|
|
47afe2cfc6 | ||
|
|
c37a2fc756 | ||
|
|
e2545276bb | ||
|
|
4219409ef8 | ||
|
|
c9e64d2a32 | ||
|
|
41db3b2e35 | ||
|
|
ebe15dada6 | ||
|
|
c2cb5dc574 | ||
|
|
ba451348c0 | ||
|
|
ec76b11666 | ||
|
|
7603f9e6c1 | ||
|
|
b50eab11c0 | ||
|
|
66d05c1771 | ||
|
|
fd7c3d7e10 | ||
|
|
28d4c7d808 | ||
|
|
43d36fbcf6 | ||
|
|
e54eef2369 | ||
|
|
296842858f | ||
|
|
ba8849a3e9 | ||
|
|
e333c3d8d9 | ||
|
|
0fe6a21624 | ||
|
|
0abedb81c6 | ||
|
|
08eda72d4b | ||
|
|
70d4126c84 | ||
|
|
dcccab705c | ||
|
|
e45ff6d026 | ||
|
|
b49c2314e7 | ||
|
|
0ac085756a | ||
|
|
542a690c89 | ||
|
|
ff23ead797 | ||
|
|
ae55e4fbf7 | ||
|
|
b17412163d | ||
|
|
46dcbf9a42 | ||
|
|
193dfcc32f | ||
|
|
a81011cf94 | ||
|
|
d43a8b2e11 | ||
|
|
dff859ba68 | ||
|
|
5169b6ee69 | ||
|
|
f4405667fe | ||
|
|
49ff636305 | ||
|
|
d77d686c76 | ||
|
|
502c6a3451 | ||
|
|
b58c77683d | ||
|
|
b9f82fc549 | ||
|
|
25b8dba607 | ||
|
|
1bc4f2c334 | ||
|
|
aee8ac6b0a | ||
|
|
aa7e30070f | ||
|
|
64b5855f65 | ||
|
|
d7ff9e706e | ||
|
|
15ba6f6261 | ||
|
|
8c88a880c6 | ||
|
|
74566cce7b | ||
|
|
16f6deed5e | ||
|
|
40edc131fe | ||
|
|
3e014b38e6 | ||
|
|
b4cfdbffab | ||
|
|
cbfb6f8f59 | ||
|
|
b5bc15ab8b | ||
|
|
0b343fc0f8 | ||
|
|
e7f9693873 | ||
|
|
a0a5c3185d | ||
|
|
151d4693a9 | ||
|
|
cdb27d8ec2 | ||
|
|
055e4d1261 | ||
|
|
bf753255ab | ||
|
|
e2230ef454 | ||
|
|
0f5b01b856 | ||
|
|
82787c96c6 | ||
|
|
f89028d5fe | ||
|
|
ba24a2e917 | ||
|
|
b549bbf46b | ||
|
|
1e87f58f36 | ||
|
|
f643426067 | ||
|
|
94d26c76ec | ||
|
|
8fe262a712 | ||
|
|
122ee968cb | ||
|
|
d2ff350db9 | ||
|
|
9100aabbac | ||
|
|
1e73f69253 | ||
|
|
7153cb4158 | ||
|
|
999dc6f8a5 | ||
|
|
724574afe7 | ||
|
|
0352a30b6b | ||
|
|
41b4cd5c55 | ||
|
|
89f16f3123 | ||
|
|
261a4eede3 | ||
|
|
f623b382f7 | ||
|
|
51537c619a | ||
|
|
3df943572f | ||
|
|
aa10804f6f | ||
|
|
981407f00f | ||
|
|
74f7098e0a | ||
|
|
c2e46bf16d | ||
|
|
78b26d2d40 | ||
|
|
e4d5be85f6 | ||
|
|
23b5601eeb | ||
|
|
859679ce09 | ||
|
|
71543c2351 | ||
|
|
edae5057c8 | ||
|
|
8dd450ded4 | ||
|
|
bc2061723e | ||
|
|
5753e37307 | ||
|
|
e74da70a9d | ||
|
|
737bbc225a | ||
|
|
9313551559 | ||
|
|
5b8f53f050 | ||
|
|
7358e4715b | ||
|
|
a9005d86d6 | ||
|
|
788c05d86e | ||
|
|
de6ba69631 | ||
|
|
4153fed250 | ||
|
|
c68b89831e | ||
|
|
01c9c5ed53 | ||
|
|
573fb135a7 | ||
|
|
0ee7256e37 | ||
|
|
9829ee558c | ||
|
|
34b563dd48 | ||
|
|
f6bb200146 | ||
|
|
af36e3a52c | ||
|
|
c50c7ae6ef | ||
|
|
61739d5ba1 | ||
|
|
34c4a6055e | ||
|
|
27dabdaf52 | ||
|
|
2ee3242f41 | ||
|
|
67ae9627af | ||
|
|
29f7e12df6 | ||
|
|
a4bb2c8268 | ||
|
|
6521c5f533 | ||
|
|
6925c18821 | ||
|
|
9269d94677 | ||
|
|
d438814ad6 | ||
|
|
bc205a350b | ||
|
|
6bf6fddd28 | ||
|
|
23f8eb9713 | ||
|
|
8ab3097328 | ||
|
|
644d0e6c2e | ||
|
|
6a69fdfbbf | ||
|
|
16e9a64941 | ||
|
|
f3cbc070ea | ||
|
|
df22526229 | ||
|
|
3739bdaa89 | ||
|
|
1f55f38bd2 | ||
|
|
c9deb0d88f | ||
|
|
eecfb39463 | ||
|
|
51bb27da42 | ||
|
|
9c0d296e87 | ||
|
|
0793e0bf8c | ||
|
|
e9ad88d50e | ||
|
|
fbe24c04b8 | ||
|
|
8a7d4d3be3 | ||
|
|
61c9a3bb93 | ||
|
|
3721a11f34 | ||
|
|
21039dec1f | ||
|
|
1393f565d8 | ||
|
|
1530e55f9d | ||
|
|
c982505f73 | ||
|
|
ec8c0d3e8b | ||
|
|
8cb0269676 | ||
|
|
27f460cfe3 | ||
|
|
e98e8d6a0d | ||
|
|
2f94662837 | ||
|
|
d46d6a9acd | ||
|
|
093d2cfa7c | ||
|
|
35b31a21dc | ||
|
|
8b9741a722 | ||
|
|
d5cfa9b0e9 | ||
|
|
129d1214fe | ||
|
|
abb3375c3a | ||
|
|
4cfa06b43f | ||
|
|
8fa80ac0f6 | ||
|
|
2d011c68df | ||
|
|
640ef4bdab | ||
|
|
cdd20c0b99 | ||
|
|
3a12123bf9 | ||
|
|
5657d5395b | ||
|
|
66b1108c5c | ||
|
|
7bf7e207c2 | ||
|
|
01098395ec | ||
|
|
3e21dfdc03 | ||
|
|
a400fb2362 | ||
|
|
44172aa359 | ||
|
|
82cab2827a | ||
|
|
a198eb1515 | ||
|
|
6e67cd6c97 | ||
|
|
e51e89df56 | ||
|
|
e46fd07d39 | ||
|
|
b2cf9aed83 | ||
|
|
c632030437 | ||
|
|
9dc683d289 | ||
|
|
6cef6190b1 | ||
|
|
75dd443d79 | ||
|
|
13dacb591d | ||
|
|
429bf5456e | ||
|
|
527c0f5015 | ||
|
|
527ab27bee | ||
|
|
7991403022 | ||
|
|
61d2e6c5e5 | ||
|
|
e005a3fc0c | ||
|
|
2dfb0fb59a | ||
|
|
70c011e7e2 | ||
|
|
8134322626 | ||
|
|
60152749bb | ||
|
|
b257e120d4 | ||
|
|
6dc75acd21 | ||
|
|
a04400170c |
+9
-2
@@ -1,4 +1,4 @@
|
|||||||
25
|
26
|
||||||
1.4.2
|
1.4.2
|
||||||
1.6.2
|
1.6.2
|
||||||
1.11.2
|
1.11.2
|
||||||
@@ -8,5 +8,12 @@
|
|||||||
2.8.2
|
2.8.2
|
||||||
3.2.2
|
3.2.2
|
||||||
3.2.3
|
3.2.3
|
||||||
|
|
||||||
3.3.2
|
3.3.2
|
||||||
|
3.6.2
|
||||||
|
3.6.3
|
||||||
|
3.6.4
|
||||||
|
3.7.2
|
||||||
|
3.7.3
|
||||||
|
3.9.2
|
||||||
|
3.9.3
|
||||||
|
3.10.2
|
||||||
|
|||||||
@@ -24,8 +24,6 @@ module.exports = {
|
|||||||
...base.rules,
|
...base.rules,
|
||||||
// add override for any (a metric ton of them, initial conversion)
|
// add override for any (a metric ton of them, initial conversion)
|
||||||
'@typescript-eslint/no-explicit-any': 'off',
|
'@typescript-eslint/no-explicit-any': 'off',
|
||||||
// these should be removed, there are 8 of them as errors
|
|
||||||
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
||||||
// this seems very broken atm, false positives
|
// this seems very broken atm, false positives
|
||||||
'@typescript-eslint/unbound-method': 'off'
|
'@typescript-eslint/unbound-method': 'off'
|
||||||
}
|
}
|
||||||
|
|||||||
+186
@@ -1,5 +1,191 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
|
## 3.11.1 Feb 28, 2021
|
||||||
|
|
||||||
|
Upgrade priority: Low. Recommended for users wanting to keep updated with chain changes.
|
||||||
|
|
||||||
|
Contributed:
|
||||||
|
|
||||||
|
- Clean Websocket states on disconnects (Thanks to https://github.com/ianhe8x)
|
||||||
|
- Support for C-like indexed enums (Thanks to https://github.com/xlc)
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Adjust council derives to cater for current-generation candidate mapping
|
||||||
|
- Allow for override of codec hasher (& output type)
|
||||||
|
- Adjust submittables to submit hex-encoded addresses to queries
|
||||||
|
- Adjust initialization to always retrieve tx version from Metadata only
|
||||||
|
- Update election types as per latest Substrate
|
||||||
|
- Add types for the new gilt module
|
||||||
|
- Upgrade to the latest Substrate metadata
|
||||||
|
- Adjust package detection to check for local monorepo dependencies
|
||||||
|
- Ensure that metadata `.toJSON()` does apply type aliasses
|
||||||
|
|
||||||
|
|
||||||
|
## 3.10.2 Feb 23, 2021
|
||||||
|
|
||||||
|
Upgrade priority: Medium. Recommended for users of chains where `MultiAddress` is in-use and blocks are decoded.
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Fix decoding for `MultiAddress` enum where non-`AccountId` variable-lengths are provided as part of a stream
|
||||||
|
- Added known Polkadot 28 upgrade block
|
||||||
|
- Update for latest Substrate contracts `Schedule` types
|
||||||
|
|
||||||
|
|
||||||
|
## 3.10.1 Feb 22, 2021
|
||||||
|
|
||||||
|
Upgrade priority: Low.
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Adjust ConsumedWeight types to align with Rust module code
|
||||||
|
- Check for connection status in subscription unsubscribe
|
||||||
|
- Adjust staking reward derives ordering for better performance
|
||||||
|
- Adapt detection imports to remove `.json` dependencies (Better behavior using Node.js with ESM)
|
||||||
|
|
||||||
|
|
||||||
|
## 3.9.3 Feb 16, 2021
|
||||||
|
|
||||||
|
Upgrade priority: Low. Recommended for parachain builders since it contains the updated parachain types.
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Adjusted parachain `PersistedValidationData` structure
|
||||||
|
|
||||||
|
|
||||||
|
## 3.9.2 Feb 15, 2021
|
||||||
|
|
||||||
|
Upgrade priority: Low. Recommended for parachain builders since it contains the latest parachain types.
|
||||||
|
|
||||||
|
Contributed:
|
||||||
|
|
||||||
|
- Update README links (Thanks to https://github.com/wirednkod)
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Added missing Culmulus `ParachainInherentData` & `MessageQueueChain` types
|
||||||
|
- Add alias for `system_unstable_networkState` RPC
|
||||||
|
|
||||||
|
|
||||||
|
## 3.9.1 Feb 14, 2021
|
||||||
|
|
||||||
|
Upgrade priority: Low.
|
||||||
|
|
||||||
|
- **Important** The `Result<T, E>` has been updated in the generation and the base types to follow the Rust version 100%. This means `{as, is}Error` is now available as `{as, is}Err` on the `Result` type. The older versions can still be used, but the `*Error` interfaces are now marked as deprecated.
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Adjust `Result<T, E>` interface to be 100% compatible with the Rust version
|
||||||
|
- Add the `2028` upgrade to the known upgrades (optimizing certain `.at` queries)
|
||||||
|
- Adjust council derives to cater for latest Substrate & Polkadot
|
||||||
|
- Adjust Rococo know type definitions to cater for the latest update
|
||||||
|
- Update types for latest Polkadot/Substrate
|
||||||
|
- Add generic arguments for TypeScript users to `.entries/.keys` to deal with the key typings
|
||||||
|
|
||||||
|
|
||||||
|
## 3.8.1 Feb 7, 2021
|
||||||
|
|
||||||
|
Upgrade priority: Low. Recommended for users of the latest Substrate master, especially using contracts.
|
||||||
|
|
||||||
|
- **Important** The `api-contract` `Code` now supports deploying the code and a contract in on operation. This aligns with the latest Substrate where code cannot be uploaded with a contract. The `createBlueprint` is therefore deprecated, use `code.tx.<constructor>(...)` to deploy code. (Compatible with both old and new versions of Substrate)
|
||||||
|
|
||||||
|
Contributed:
|
||||||
|
|
||||||
|
- Add support for latest Frontier RPCs (Thanks to https://github.com/jnaviask)
|
||||||
|
- Fix user-supplied signed extensions type signature (Thanks to https://github.com/ntduan)
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Expand `api-contract` to allow for `Code` to deploy contract alongside code. `createBlueprint` is now deprecated, replaced by `createContract` or the preferred `code.tx.<constructor>`, which uploads and deploys the code in one operation. This aligns with the current Substrate master contracts implementation.
|
||||||
|
- Allow for signed extensions to be supplied inside type bundles
|
||||||
|
- Ensure that the auto-connect state is checked on auto-connections (respecting disconnect)
|
||||||
|
- Added `CancelProxy` to `ProxyTypes on Polkadot, Kusama & Westend
|
||||||
|
- Updated to latest Substrate metadata
|
||||||
|
|
||||||
|
|
||||||
|
## 3.7.3 Feb 2, 2021
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Added Polkadot upgrade block for runtime 27 (known checkpoint optimization)
|
||||||
|
|
||||||
|
|
||||||
|
## 3.7.2 Feb 2, 2021
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Adjusted the `Keys` type for the 28 runtime on Kusama, Polkadot & Westend
|
||||||
|
|
||||||
|
|
||||||
|
## 3.7.1 Feb 1, 2021
|
||||||
|
|
||||||
|
Upgrade priority: Low. However recommended for current Substrate master, Polkadot and Rococo users and those wishing to support the upcoming Polkadot 28 runtime with the new `MultiAddress`.
|
||||||
|
|
||||||
|
- **Breaking change** As indicated in the 3.5.1 release notes, the `Address`/`LookupSource` defaults have now been adjusted for `MultiAddress`. If your chain does not use these types, explicitly add the correct `Address`/`LookupSource` types. This new extensible format is mean to cater for all address types into the future, removing a lot of discrepancies between chains.
|
||||||
|
|
||||||
|
Contributed:
|
||||||
|
|
||||||
|
- Extraction of the block author on Moonbeam (Thanks to https://github.com/joelamouche)
|
||||||
|
- Cleanup logs with HTTP providers, no subs (Thanks to https://github.com/Tbaut)
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Allow `.slice` operator on the `Vec` type
|
||||||
|
- Apply `MultiAddress` as a default
|
||||||
|
- Adds support for the upcoming Polkadot 28 and Kusama 2028 runtimes
|
||||||
|
- Add checkpoint for Kusama 2027 upgrade
|
||||||
|
- Update all parachain types (as per latest Rococo)
|
||||||
|
- Correctly use relay blockNumber in parachain validation data
|
||||||
|
- remove information log for capabilities detection (creates confusion)
|
||||||
|
- Remove explicit references to `global`, use the `x-global` detection
|
||||||
|
- Remove explicit `module` in `package.json` (exports map available)
|
||||||
|
|
||||||
|
|
||||||
|
## 3.6.1 Jan 24, 2020
|
||||||
|
|
||||||
|
Upgrade priority: Medium if not already on at least 3.3.1. The next upgrade of Kusama/Polkadot requires it.
|
||||||
|
|
||||||
|
- **Breaking change** To support chains with multiple tokens, such as bridges, the `ChainProperties` type now returns an array of tokens and decimals (instead of singular values) in the `token{Decimals, Symbol}` getters. Additionally, this means that the `registry` interfaces has been changes, to `registry.chainDecimals: number[]` and `registry.chainTokens: string[]`. Where used the `[0]` index will return the first value if only interested in a single, for a straight conversion.
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Allow for the detection of on-chain capabilities as available (e.g. `AccountData`, `ValidatorPrefs`)
|
||||||
|
- Cater for multiple tokens and decimals in the chain the chain `system.properties` (as per the chain specification)
|
||||||
|
- Add a `instances: { [key]: [module1, module2] }` definition in teh bundle types, allowing for multiple instances (e.g. Balances)
|
||||||
|
- Adjust the `api-derive` for balances to retrieve values via `instances` as well as across multiple modules
|
||||||
|
- Ensure all types are registered for all metadata typegen steps
|
||||||
|
- Add `rpc.payment.queryFeeDetails` RPC endpoint
|
||||||
|
- Update types & metadata to latest Substrate
|
||||||
|
- Move the `@polkadot/x-rxjs` package into the common repo
|
||||||
|
- Allow doc generation for errors/events (markdown outputs)
|
||||||
|
|
||||||
|
|
||||||
|
## 3.5.1 Jan 18, 2020
|
||||||
|
|
||||||
|
Upgrade priority: Low. Recommended for parachain developers.
|
||||||
|
|
||||||
|
- **Important** The default for Substrate on the Address types are `MultiAddress`. It is recommended that chains add explicit definitions for `Address` and `LookupSource` in their types, instead of relying on the API-defaults. A future update will swap the API defaults to align with Substrate.
|
||||||
|
- **Important** Like the above changes in Substrate, the `AccountInfo` structure has also changed. It is recommended that chain developers explicitly add `AccountInfo: 'AccountInfoWithRefCount'` for the version with `refCount` on and `AccountInfoWithProviders` for the latest Substrate version. As per the above, the API defaults will be changed to align with Substrate.
|
||||||
|
|
||||||
|
Contributed:
|
||||||
|
|
||||||
|
- Apply correct TypeScript type for `toBigInt()` (Thanks to https://github.com/ianhe8x)
|
||||||
|
- Expand type definitions for storage key tuples (Thanks to https://github.com/monitz87)
|
||||||
|
- Adjust bounty derive to cater for non-council chains (Thanks to https://github.com/ekowalsk)
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Remove recursion in vector/struct U8a stream decoding
|
||||||
|
- Availability of staking made optional in session length calcs (era does require it)
|
||||||
|
- Updates to parachain types, ensuring it has coverage for all the latest
|
||||||
|
- Update all Rococo types to the latest (session keys, session reports, parachain indexes)
|
||||||
|
- Update known upgrade checkpoints fo WestEnd
|
||||||
|
- Add types of the lottery module in Substrate
|
||||||
|
- Add and extend types for the crowdloan module in Polkadot
|
||||||
|
- Adjust node-template to default to `MultiAddress` on specVersion >= 100
|
||||||
|
|
||||||
|
|
||||||
## 3.4.1 Jan 11, 2020
|
## 3.4.1 Jan 11, 2020
|
||||||
|
|
||||||
Upgrade priority: Low. Fixes for parachain types, `.entries()` (with no values) and `event.is(...)` checks, users of these interfaces will have benefit.
|
Upgrade priority: Low. Fixes for parachain types, `.entries()` (with no values) and `event.is(...)` checks, users of these interfaces will have benefit.
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
# @polkadot/api
|
# @polkadot/api
|
||||||
|
|
||||||
This library provides a clean wrapper around all the methods exposed by a Polkadot/Substrate network client and defines all the types exposed by a node. For complete documentation around the classes, interfaces and their use, visit the [documentation portal](https://polkadot.js.org/api/).
|
This library provides a clean wrapper around all the methods exposed by a Polkadot/Substrate network client and defines all the types exposed by a node. For complete documentation around the classes, interfaces and their use, visit the [documentation portal](https://polkadot.js.org/docs/api/).
|
||||||
|
|
||||||
If you are an existing user, please be sure to track the [CHANGELOG](CHANGELOG.md) and [UPGRADING](UPGRADING.md) guides when changing versions.
|
If you are an existing user, please be sure to track the [CHANGELOG](CHANGELOG.md) and [UPGRADING](UPGRADING.md) guides when changing versions.
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ The API is split up into a number of internal packages -
|
|||||||
- [@polkadot/api](packages/api/) The API library, providing both Promise and RxJS Observable-based interfaces. This is the main user-facing entry point.
|
- [@polkadot/api](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-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/api-metadata](packages/api-metadata/) Base extrinsic, storage and constant injectors for injection
|
||||||
- [@polkadot/rpc-core](packages/rpc-core/) Wrapper around all [JSON-RPC methods](https://polkadot.js.org/api/substrate/rpc.html) exposed by a Polkadot network client
|
- [@polkadot/rpc-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
|
- [@polkadot/rpc-provider](packages/rpc-provider/) Providers for connecting to nodes, including WebSockets and Http
|
||||||
|
|
||||||
Type definitions for interfaces as exposed by Polkadot & Substrate clients -
|
Type definitions for interfaces as exposed by Polkadot & Substrate clients -
|
||||||
|
|||||||
+2
-4
@@ -13,8 +13,7 @@ module.exports = Object.assign({}, config, {
|
|||||||
'@polkadot/typegen(.*)$': '<rootDir>/packages/typegen/src/$1',
|
'@polkadot/typegen(.*)$': '<rootDir>/packages/typegen/src/$1',
|
||||||
'@polkadot/types-known(.*)$': '<rootDir>/packages/types-known/src/$1',
|
'@polkadot/types-known(.*)$': '<rootDir>/packages/types-known/src/$1',
|
||||||
// eslint-disable-next-line sort-keys
|
// eslint-disable-next-line sort-keys
|
||||||
'@polkadot/types(.*)$': '<rootDir>/packages/types/src/$1',
|
'@polkadot/types(.*)$': '<rootDir>/packages/types/src/$1'
|
||||||
'@polkadot/x-rxjs(.*)$': '<rootDir>/packages/x-rxjs/src/$1'
|
|
||||||
},
|
},
|
||||||
modulePathIgnorePatterns: [
|
modulePathIgnorePatterns: [
|
||||||
'<rootDir>/packages/api/build',
|
'<rootDir>/packages/api/build',
|
||||||
@@ -25,8 +24,7 @@ module.exports = Object.assign({}, config, {
|
|||||||
'<rootDir>/packages/rpc-provider/build',
|
'<rootDir>/packages/rpc-provider/build',
|
||||||
'<rootDir>/packages/typegen/build',
|
'<rootDir>/packages/typegen/build',
|
||||||
'<rootDir>/packages/types/build',
|
'<rootDir>/packages/types/build',
|
||||||
'<rootDir>/packages/types-known/build',
|
'<rootDir>/packages/types-known/build'
|
||||||
'<rootDir>/packages/x-rxjs/build'
|
|
||||||
],
|
],
|
||||||
resolver: '@polkadot/dev/config/jest-resolver.cjs'
|
resolver: '@polkadot/dev/config/jest-resolver.cjs'
|
||||||
});
|
});
|
||||||
|
|||||||
+6
-6
@@ -8,7 +8,7 @@
|
|||||||
"packages/*"
|
"packages/*"
|
||||||
],
|
],
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"typescript": "^4.1.3"
|
"typescript": "^4.1.5"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "yarn build:interfaces && polkadot-dev-build-ts",
|
"build": "yarn build:interfaces && polkadot-dev-build-ts",
|
||||||
@@ -25,14 +25,14 @@
|
|||||||
"test:watch": "polkadot-dev-run-test --watch"
|
"test:watch": "polkadot-dev-run-test --watch"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.12.10",
|
"@babel/core": "^7.13.8",
|
||||||
"@babel/register": "^7.12.10",
|
"@babel/register": "^7.13.8",
|
||||||
"@babel/runtime": "^7.12.5",
|
"@babel/runtime": "^7.13.8",
|
||||||
"@polkadot/dev": "^0.61.24",
|
"@polkadot/dev": "^0.61.30",
|
||||||
"@polkadot/ts": "^0.3.59",
|
"@polkadot/ts": "^0.3.59",
|
||||||
"@polkadot/typegen": "workspace:packages/typegen",
|
"@polkadot/typegen": "workspace:packages/typegen",
|
||||||
"@types/jest": "^26.0.20",
|
"@types/jest": "^26.0.20",
|
||||||
"copyfiles": "^2.4.1"
|
"copyfiles": "^2.4.1"
|
||||||
},
|
},
|
||||||
"version": "3.4.1"
|
"version": "3.11.1"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@polkadot/api-contract",
|
"name": "@polkadot/api-contract",
|
||||||
"version": "3.4.1",
|
"version": "3.11.1",
|
||||||
"description": "Interfaces for interacting with contracts and contract ABIs",
|
"description": "Interfaces for interacting with contracts and contract ABIs",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "index.mjs",
|
"sideEffects": [
|
||||||
"sideEffects": false,
|
"./detectPackage.js",
|
||||||
|
"./detectPackage.mjs"
|
||||||
|
],
|
||||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||||
"maintainers": [],
|
"maintainers": [],
|
||||||
"contributors": [],
|
"contributors": [],
|
||||||
@@ -13,11 +15,11 @@
|
|||||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
|
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.12.5",
|
"@babel/runtime": "^7.13.8",
|
||||||
"@polkadot/api": "3.4.1",
|
"@polkadot/api": "3.11.1",
|
||||||
"@polkadot/types": "3.4.1",
|
"@polkadot/types": "3.11.1",
|
||||||
"@polkadot/util": "^5.2.3",
|
"@polkadot/util": "^5.9.2",
|
||||||
"@polkadot/x-rxjs": "3.4.1",
|
"@polkadot/x-rxjs": "^5.9.2",
|
||||||
"bn.js": "^4.11.9"
|
"bn.js": "^4.11.9"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,6 @@ export abstract class Base<ApiType extends ApiTypes> {
|
|||||||
this.registry = this.abi.registry;
|
this.registry = this.abi.registry;
|
||||||
this._decorateMethod = decorateMethod;
|
this._decorateMethod = decorateMethod;
|
||||||
|
|
||||||
assert(this.api.rx.tx.contracts && this.api.rx.tx.contracts.putCode, 'You need to connect to a node with the contracts module, the metadata does not enable api.tx.contracts on this instance');
|
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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,44 +6,17 @@ import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
|||||||
import type { AccountId, EventRecord, Hash } from '@polkadot/types/interfaces';
|
import type { AccountId, EventRecord, Hash } from '@polkadot/types/interfaces';
|
||||||
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
|
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
|
||||||
import type { AbiConstructor, BlueprintOptions } from '../types';
|
import type { AbiConstructor, BlueprintOptions } from '../types';
|
||||||
import type { BlueprintDeploy, ContractGeneric, MapConstructorExec } from './types';
|
import type { ContractGeneric, MapConstructorExec } from './types';
|
||||||
|
|
||||||
import BN from 'bn.js';
|
|
||||||
|
|
||||||
import { SubmittableResult } from '@polkadot/api';
|
import { SubmittableResult } from '@polkadot/api';
|
||||||
import { ApiBase } from '@polkadot/api/base';
|
import { ApiBase } from '@polkadot/api/base';
|
||||||
import { Bytes } from '@polkadot/types';
|
import { isUndefined, stringCamelCase } from '@polkadot/util';
|
||||||
import { compactAddLength, isUndefined, stringCamelCase, u8aToU8a } from '@polkadot/util';
|
|
||||||
import { randomAsU8a } from '@polkadot/util-crypto';
|
|
||||||
|
|
||||||
import { Abi } from '../Abi';
|
import { Abi } from '../Abi';
|
||||||
import { applyOnEvent, extractOptions, isOptions } from '../util';
|
import { applyOnEvent } from '../util';
|
||||||
import { Base } from './Base';
|
import { Base } from './Base';
|
||||||
import { Contract } from './Contract';
|
import { Contract } from './Contract';
|
||||||
|
import { createBluePrintTx, createBluePrintWithId, EMPTY_SALT, encodeSalt } from './util';
|
||||||
const EMPTY_SALT = new Uint8Array();
|
|
||||||
|
|
||||||
function createTx <ApiType extends ApiTypes> (fn: (options: BlueprintOptions, params: CodecArg[]) => SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>>): BlueprintDeploy<ApiType> {
|
|
||||||
return (options: BigInt | string | number | BN | BlueprintOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> =>
|
|
||||||
isOptions(options)
|
|
||||||
? fn(options, params)
|
|
||||||
: fn(...extractOptions(options, params));
|
|
||||||
}
|
|
||||||
|
|
||||||
function createWithId <T> (fn: (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: CodecArg[]) => T): ContractGeneric<BlueprintOptions, T> {
|
|
||||||
return (constructorOrId: AbiConstructor | string | number, options: BigInt | string | number | BN | BlueprintOptions, ...params: CodecArg[]): T =>
|
|
||||||
isOptions(options)
|
|
||||||
? fn(constructorOrId, options, params)
|
|
||||||
: fn(constructorOrId, ...extractOptions(options, params));
|
|
||||||
}
|
|
||||||
|
|
||||||
function encodeSalt (salt: Uint8Array | string | null = randomAsU8a()) {
|
|
||||||
return salt instanceof Bytes
|
|
||||||
? salt
|
|
||||||
: salt && salt.length
|
|
||||||
? compactAddLength(u8aToU8a(salt))
|
|
||||||
: EMPTY_SALT;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class BlueprintSubmittableResult<ApiType extends ApiTypes> extends SubmittableResult {
|
export class BlueprintSubmittableResult<ApiType extends ApiTypes> extends SubmittableResult {
|
||||||
public readonly contract?: Contract<ApiType>;
|
public readonly contract?: Contract<ApiType>;
|
||||||
@@ -73,13 +46,13 @@ export class Blueprint<ApiType extends ApiTypes> extends Base<ApiType> {
|
|||||||
super(api, abi, decorateMethod);
|
super(api, abi, decorateMethod);
|
||||||
|
|
||||||
this.codeHash = this.registry.createType('Hash', codeHash);
|
this.codeHash = this.registry.createType('Hash', codeHash);
|
||||||
this.createContract = createWithId(this.#deploy);
|
this.createContract = createBluePrintWithId(this.#deploy);
|
||||||
|
|
||||||
this.abi.constructors.forEach((c): void => {
|
this.abi.constructors.forEach((c): void => {
|
||||||
const messageName = stringCamelCase(c.identifier);
|
const messageName = stringCamelCase(c.identifier);
|
||||||
|
|
||||||
if (isUndefined(this.#tx[messageName])) {
|
if (isUndefined(this.#tx[messageName])) {
|
||||||
this.#tx[messageName] = createTx((o, p) => this.#deploy(c, o, p));
|
this.#tx[messageName] = createBluePrintTx((o, p) => this.#deploy(c, o, p));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -88,7 +61,7 @@ export class Blueprint<ApiType extends ApiTypes> extends Base<ApiType> {
|
|||||||
return this.#tx;
|
return this.#tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
#deploy = (constructorOrId: AbiConstructor | string| number, { gasLimit = 0, salt, value = 0 }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> => {
|
#deploy = (constructorOrId: AbiConstructor | string | number, { gasLimit = 0, salt, value = 0 }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> => {
|
||||||
const encodedSalt = encodeSalt(salt);
|
const encodedSalt = encodeSalt(salt);
|
||||||
const withSalt = this.api.tx.contracts.instantiate.meta.args.length === 5;
|
const withSalt = this.api.tx.contracts.instantiate.meta.args.length === 5;
|
||||||
const encoded = this.abi.findConstructor(constructorOrId).toU8a(params, withSalt ? EMPTY_SALT : encodedSalt);
|
const encoded = this.abi.findConstructor(constructorOrId).toU8a(params, withSalt ? EMPTY_SALT : encodedSalt);
|
||||||
@@ -99,7 +72,7 @@ export class Blueprint<ApiType extends ApiTypes> extends Base<ApiType> {
|
|||||||
: this.api.tx.contracts.instantiate(value, gasLimit, this.codeHash, encoded);
|
: this.api.tx.contracts.instantiate(value, gasLimit, this.codeHash, encoded);
|
||||||
|
|
||||||
return tx.withResultTransform((result: ISubmittableResult) =>
|
return tx.withResultTransform((result: ISubmittableResult) =>
|
||||||
new BlueprintSubmittableResult(result, applyOnEvent(result, 'Instantiated', ([record]: EventRecord[]) =>
|
new BlueprintSubmittableResult(result, applyOnEvent(result, ['Instantiated'], ([record]: EventRecord[]) =>
|
||||||
new Contract<ApiType>(this.api, this.abi, record.event.data[1] as AccountId, this._decorateMethod)
|
new Contract<ApiType>(this.api, this.abi, record.event.data[1] as AccountId, this._decorateMethod)
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -4,30 +4,39 @@
|
|||||||
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||||
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||||
import type { EventRecord, Hash } from '@polkadot/types/interfaces';
|
import type { EventRecord, Hash } from '@polkadot/types/interfaces';
|
||||||
import type { AnyJson, ISubmittableResult } from '@polkadot/types/types';
|
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
|
||||||
|
import type { AbiConstructor, BlueprintOptions } from '../types';
|
||||||
|
import type { MapConstructorExec } from './types';
|
||||||
|
|
||||||
import { SubmittableResult } from '@polkadot/api';
|
import { SubmittableResult } from '@polkadot/api';
|
||||||
import { ApiBase } from '@polkadot/api/base';
|
import { ApiBase } from '@polkadot/api/base';
|
||||||
import { assert, compactAddLength, isWasm, u8aToU8a } from '@polkadot/util';
|
import { assert, compactAddLength, isFunction, isUndefined, isWasm, stringCamelCase, u8aToU8a } from '@polkadot/util';
|
||||||
|
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||||
|
|
||||||
import { Abi } from '../Abi';
|
import { Abi } from '../Abi';
|
||||||
import { applyOnEvent } from '../util';
|
import { applyOnEvent } from '../util';
|
||||||
import { Base } from './Base';
|
import { Base } from './Base';
|
||||||
import { Blueprint } from './Blueprint';
|
import { Blueprint } from './Blueprint';
|
||||||
|
import { Contract } from './Contract';
|
||||||
|
import { createBluePrintTx, EMPTY_SALT, encodeSalt } from './util';
|
||||||
|
|
||||||
export class CodeSubmittableResult<ApiType extends ApiTypes> extends SubmittableResult {
|
export class CodeSubmittableResult<ApiType extends ApiTypes> extends SubmittableResult {
|
||||||
public readonly blueprint?: Blueprint<ApiType>;
|
public readonly blueprint?: Blueprint<ApiType>;
|
||||||
|
public readonly contract?: Contract<ApiType>;
|
||||||
|
|
||||||
constructor (result: ISubmittableResult, blueprint?: Blueprint<ApiType>) {
|
constructor (result: ISubmittableResult, blueprint?: Blueprint<ApiType>, contract?: Contract<ApiType>) {
|
||||||
super(result);
|
super(result);
|
||||||
|
|
||||||
this.blueprint = blueprint;
|
this.blueprint = blueprint;
|
||||||
|
this.contract = contract;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Code<ApiType extends ApiTypes> extends Base<ApiType> {
|
export class Code<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||||
public readonly code: Uint8Array;
|
public readonly code: Uint8Array;
|
||||||
|
|
||||||
|
readonly #tx: MapConstructorExec<ApiType> = {};
|
||||||
|
|
||||||
constructor (api: ApiBase<ApiType>, abi: AnyJson | Abi, wasm: Uint8Array | string | Buffer | null | undefined, decorateMethod: DecorateMethod<ApiType>) {
|
constructor (api: ApiBase<ApiType>, abi: AnyJson | Abi, wasm: Uint8Array | string | Buffer | null | undefined, decorateMethod: DecorateMethod<ApiType>) {
|
||||||
super(api, abi, decorateMethod);
|
super(api, abi, decorateMethod);
|
||||||
|
|
||||||
@@ -36,18 +45,79 @@ export class Code<ApiType extends ApiTypes> extends Base<ApiType> {
|
|||||||
: u8aToU8a(wasm);
|
: u8aToU8a(wasm);
|
||||||
|
|
||||||
assert(isWasm(this.code), 'No WASM code provided');
|
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));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Deploy the code bundle, creating a Blueprint.
|
* @description Deploy the code bundle, creating a Blueprint.
|
||||||
|
* @deprecated Use the `code.tx.<constructor>(...) format to put code and deploy
|
||||||
*/
|
*/
|
||||||
public createBlueprint (): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> {
|
public createBlueprint (): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> {
|
||||||
return this.api.tx.contracts
|
return this.api.tx.contracts
|
||||||
.putCode(compactAddLength(this.code))
|
.putCode(compactAddLength(this.code))
|
||||||
.withResultTransform((result: ISubmittableResult) =>
|
.withResultTransform((result: ISubmittableResult) =>
|
||||||
new CodeSubmittableResult(result, applyOnEvent(result, 'CodeStored', ([record]: EventRecord[]) =>
|
new CodeSubmittableResult(result, applyOnEvent(result, ['CodeStored'], ([record]: EventRecord[]) =>
|
||||||
new Blueprint<ApiType>(this.api, this.abi, record.event.data[0] as Hash, this._decorateMethod)
|
new Blueprint<ApiType>(this.api, this.abi, record.event.data[0] as Hash, this._decorateMethod)
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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);
|
||||||
|
}
|
||||||
|
|
||||||
|
public get tx (): MapConstructorExec<ApiType> {
|
||||||
|
return this.#tx;
|
||||||
|
}
|
||||||
|
|
||||||
|
#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>> => {
|
||||||
|
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>?])
|
||||||
|
) || []));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
|||||||
return this.api.tx.contracts
|
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) =>
|
.withResultTransform((result: ISubmittableResult) =>
|
||||||
new ContractSubmittableResult(result, applyOnEvent(result, 'ContractExecution', (records: EventRecord[]) =>
|
new ContractSubmittableResult(result, applyOnEvent(result, ['ContractExecution'], (records: EventRecord[]) =>
|
||||||
records
|
records
|
||||||
.map(({ event: { data: [, data] } }): DecodedEvent | null => {
|
.map(({ event: { data: [, data] } }): DecodedEvent | null => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ export const mockApi = {
|
|||||||
rx: {
|
rx: {
|
||||||
tx: {
|
tx: {
|
||||||
contracts: {
|
contracts: {
|
||||||
|
instantiate: (): never => {
|
||||||
|
throw new Error('mock');
|
||||||
|
},
|
||||||
putCode: (): never => {
|
putCode: (): never => {
|
||||||
throw new Error('mock');
|
throw new Error('mock');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import type { SubmittableResult } from '@polkadot/api';
|
||||||
|
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||||
|
import type { ApiTypes } from '@polkadot/api/types';
|
||||||
|
import type { CodecArg } from '@polkadot/types/types';
|
||||||
|
import type { AbiConstructor, BlueprintOptions } from '../types';
|
||||||
|
import type { BlueprintDeploy, ContractGeneric } from './types';
|
||||||
|
|
||||||
|
import BN from 'bn.js';
|
||||||
|
|
||||||
|
import { Bytes } from '@polkadot/types';
|
||||||
|
import { compactAddLength, u8aToU8a } from '@polkadot/util';
|
||||||
|
import { randomAsU8a } from '@polkadot/util-crypto';
|
||||||
|
|
||||||
|
import { extractOptions, isOptions } from '../util';
|
||||||
|
|
||||||
|
export const EMPTY_SALT = new Uint8Array();
|
||||||
|
|
||||||
|
export function createBluePrintTx <ApiType extends ApiTypes, R extends SubmittableResult> (fn: (options: BlueprintOptions, params: CodecArg[]) => SubmittableExtrinsic<ApiType, R>): BlueprintDeploy<ApiType> {
|
||||||
|
return (options: BigInt | string | number | BN | BlueprintOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType, R> =>
|
||||||
|
isOptions(options)
|
||||||
|
? fn(options, params)
|
||||||
|
: fn(...extractOptions(options, params));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createBluePrintWithId <T> (fn: (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: CodecArg[]) => T): ContractGeneric<BlueprintOptions, T> {
|
||||||
|
return (constructorOrId: AbiConstructor | string | number, options: BigInt | string | number | BN | BlueprintOptions, ...params: CodecArg[]): T =>
|
||||||
|
isOptions(options)
|
||||||
|
? fn(constructorOrId, options, params)
|
||||||
|
: fn(constructorOrId, ...extractOptions(options, params));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function encodeSalt (salt: Uint8Array | string | null = randomAsU8a()): Uint8Array {
|
||||||
|
return salt instanceof Bytes
|
||||||
|
? salt
|
||||||
|
: salt && salt.length
|
||||||
|
? compactAddLength(u8aToU8a(salt))
|
||||||
|
: EMPTY_SALT;
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import { packageInfo as apiInfo } from '@polkadot/api/packageInfo';
|
||||||
|
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||||
|
import { detectPackage } from '@polkadot/util';
|
||||||
|
|
||||||
|
import { packageInfo } from './packageInfo';
|
||||||
|
|
||||||
|
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [apiInfo, typesInfo]);
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
export { Abi } from './Abi';
|
import './detectPackage';
|
||||||
|
|
||||||
export { Blueprint as BlueprintRx, Code as CodeRx, Contract as ContractRx } from './rx';
|
export { Abi } from './Abi';
|
||||||
|
export { packageInfo } from './packageInfo';
|
||||||
export { Blueprint as BlueprintPromise, Code as CodePromise, Contract as ContractPromise } from './promise';
|
export { Blueprint as BlueprintPromise, Code as CodePromise, Contract as ContractPromise } from './promise';
|
||||||
|
export { Blueprint as BlueprintRx, Code as CodeRx, Contract as ContractRx } from './rx';
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// Copyright 2017-2021 @polkadot/dev authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
// Auto-generated by @polkadot/dev, do not edit
|
||||||
|
|
||||||
|
export const packageInfo = { name: '@polkadot/api-contract', version: '3.11.1' };
|
||||||
@@ -20,9 +20,9 @@ export function formatData (registry: Registry, data: Raw, { type }: TypeDef): C
|
|||||||
return createTypeUnsafe(registry, type, [data], { isPedantic: true });
|
return createTypeUnsafe(registry, type, [data], { isPedantic: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function applyOnEvent <T> (result: SubmittableResult, type: ContractEvents, fn: (records: EventRecord[]) => T): T | undefined {
|
export function applyOnEvent <T> (result: SubmittableResult, types: ContractEvents[], fn: (records: EventRecord[]) => T): T | undefined {
|
||||||
if (result.isInBlock || result.isFinalized) {
|
if (result.isInBlock || result.isFinalized) {
|
||||||
const records = result.filterRecords('contracts', type);
|
const records = result.filterRecords('contracts', types);
|
||||||
|
|
||||||
if (records.length) {
|
if (records.length) {
|
||||||
return fn(records);
|
return fn(records);
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@polkadot/api-derive",
|
"name": "@polkadot/api-derive",
|
||||||
"version": "3.4.1",
|
"version": "3.11.1",
|
||||||
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
|
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "index.mjs",
|
"sideEffects": [
|
||||||
"sideEffects": false,
|
"./detectPackage.js",
|
||||||
|
"./detectPackage.mjs"
|
||||||
|
],
|
||||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||||
"maintainers": [],
|
"maintainers": [],
|
||||||
"contributors": [],
|
"contributors": [],
|
||||||
@@ -13,17 +15,17 @@
|
|||||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
|
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.12.5",
|
"@babel/runtime": "^7.13.8",
|
||||||
"@polkadot/api": "3.4.1",
|
"@polkadot/api": "3.11.1",
|
||||||
"@polkadot/rpc-core": "3.4.1",
|
"@polkadot/rpc-core": "3.11.1",
|
||||||
"@polkadot/types": "3.4.1",
|
"@polkadot/types": "3.11.1",
|
||||||
"@polkadot/util": "^5.2.3",
|
"@polkadot/util": "^5.9.2",
|
||||||
"@polkadot/util-crypto": "^5.2.3",
|
"@polkadot/util-crypto": "^5.9.2",
|
||||||
"@polkadot/x-rxjs": "3.4.1",
|
"@polkadot/x-rxjs": "^5.9.2",
|
||||||
"bn.js": "^4.11.9"
|
"bn.js": "^4.11.9"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@polkadot/keyring": "^5.2.3",
|
"@polkadot/keyring": "^5.9.2",
|
||||||
"@polkadot/rpc-provider": "3.4.1"
|
"@polkadot/rpc-provider": "3.11.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||||
import type { AccountIndex } from '@polkadot/types/interfaces';
|
|
||||||
import type { Observable } from '@polkadot/x-rxjs';
|
import type { Observable } from '@polkadot/x-rxjs';
|
||||||
import type { AccountIndexes } from '../types';
|
import type { AccountIndexes } from '../types';
|
||||||
|
|
||||||
@@ -18,7 +17,7 @@ function queryAccounts (api: ApiInterfaceRx): Observable<AccountIndexes> {
|
|||||||
map((entries): AccountIndexes =>
|
map((entries): AccountIndexes =>
|
||||||
entries.reduce((indexes: AccountIndexes, [key, idOpt]): AccountIndexes => {
|
entries.reduce((indexes: AccountIndexes, [key, idOpt]): AccountIndexes => {
|
||||||
if (idOpt.isSome) {
|
if (idOpt.isSome) {
|
||||||
indexes[idOpt.unwrap()[0].toString()] = key.args[0] as AccountIndex;
|
indexes[idOpt.unwrap()[0].toString()] = key.args[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
return indexes;
|
return indexes;
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
|
||||||
import type { AccountData, AccountId, AccountIndex, AccountInfo, Address, Balance, Index } from '@polkadot/types/interfaces';
|
import type { AccountData, AccountId, AccountIndex, AccountInfo, Address, Balance, Index } from '@polkadot/types/interfaces';
|
||||||
import type { ITuple } from '@polkadot/types/types';
|
import type { ITuple } from '@polkadot/types/types';
|
||||||
import type { Observable } from '@polkadot/x-rxjs';
|
import type { Observable } from '@polkadot/x-rxjs';
|
||||||
import type { DeriveBalancesAccount } from '../types';
|
import type { DeriveBalancesAccount, DeriveBalancesAccountData } from '../types';
|
||||||
|
|
||||||
import { isFunction } from '@polkadot/util';
|
import { assert, isFunction } from '@polkadot/util';
|
||||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||||
|
|
||||||
import { memo } from '../util';
|
import { memo } from '../util';
|
||||||
|
|
||||||
type Result = [Balance, Balance, Balance, Balance, Index];
|
type BalanceResult = [Balance, Balance, Balance, Balance];
|
||||||
|
|
||||||
function calcBalances (api: ApiInterfaceRx, [accountId, [freeBalance, reservedBalance, frozenFee, frozenMisc, accountNonce]]: [AccountId, Result]): DeriveBalancesAccount {
|
type Result = [Index, BalanceResult[]];
|
||||||
|
|
||||||
|
function getBalance (api: ApiInterfaceRx, [freeBalance, reservedBalance, frozenFee, frozenMisc]: BalanceResult): DeriveBalancesAccountData {
|
||||||
return {
|
return {
|
||||||
accountId,
|
|
||||||
accountNonce,
|
|
||||||
freeBalance,
|
freeBalance,
|
||||||
frozenFee,
|
frozenFee,
|
||||||
frozenMisc,
|
frozenMisc,
|
||||||
@@ -27,6 +27,19 @@ function calcBalances (api: ApiInterfaceRx, [accountId, [freeBalance, reservedBa
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function calcBalances (api: ApiInterfaceRx, [accountId, [accountNonce, balances]]: [AccountId, Result]): DeriveBalancesAccount {
|
||||||
|
const primary = balances[0];
|
||||||
|
|
||||||
|
assert(primary, 'No balances retrieved for account');
|
||||||
|
|
||||||
|
return {
|
||||||
|
accountId,
|
||||||
|
accountNonce,
|
||||||
|
additional: balances.filter((_, index) => index !== 0).map((b) => getBalance(api, b)),
|
||||||
|
...getBalance(api, primary)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// old
|
// old
|
||||||
function queryBalancesFree (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
function queryBalancesFree (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
||||||
return api.queryMulti<[Balance, Balance, Index]>([
|
return api.queryMulti<[Balance, Balance, Index]>([
|
||||||
@@ -34,21 +47,25 @@ function queryBalancesFree (api: ApiInterfaceRx, accountId: AccountId): Observab
|
|||||||
[api.query.balances.reservedBalance, accountId],
|
[api.query.balances.reservedBalance, accountId],
|
||||||
[api.query.system.accountNonce, accountId]
|
[api.query.system.accountNonce, accountId]
|
||||||
]).pipe(
|
]).pipe(
|
||||||
map(([freeBalance, reservedBalance, accountNonce]): Result =>
|
map(([freeBalance, reservedBalance, accountNonce]): Result => [
|
||||||
[freeBalance, reservedBalance, api.registry.createType('Balance'), api.registry.createType('Balance'), accountNonce]
|
accountNonce,
|
||||||
)
|
[[freeBalance, reservedBalance, api.registry.createType('Balance'), api.registry.createType('Balance')]]
|
||||||
|
])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId, modules: string[] = ['balances']): Observable<Result> {
|
||||||
return api.queryMulti<[AccountData, Index]>([
|
const balances = modules.map((m): QueryableStorageMultiArg<'rxjs'> => [api.query[m].account, accountId]);
|
||||||
[api.query.balances.account, accountId],
|
const extract = (data: AccountData[]) =>
|
||||||
[api.query.system.accountNonce, accountId]
|
data.map(({ feeFrozen, free, miscFrozen, reserved }): BalanceResult => [free, reserved, feeFrozen, miscFrozen]);
|
||||||
]).pipe(
|
|
||||||
map(([{ feeFrozen, free, miscFrozen, reserved }, accountNonce]): Result =>
|
return isFunction(api.query.system.account)
|
||||||
[free, reserved, feeFrozen, miscFrozen, accountNonce]
|
? api.queryMulti<[AccountInfo, ...(AccountData[])]>([[api.query.system.account, accountId], ...balances]).pipe(
|
||||||
|
map(([{ nonce }, ...balances]): Result => [nonce, extract(balances)])
|
||||||
)
|
)
|
||||||
);
|
: api.queryMulti<[Index, ...(AccountData[])]>([[api.query.system.accountNonce, accountId], ...balances]).pipe(
|
||||||
|
map(([nonce, ...balances]): Result => [nonce, extract(balances)])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
||||||
@@ -60,7 +77,7 @@ function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Re
|
|||||||
: (infoOrTuple as [Index, AccountData])[1];
|
: (infoOrTuple as [Index, AccountData])[1];
|
||||||
const accountNonce = (infoOrTuple as AccountInfo).nonce || (infoOrTuple as [Index, AccountData])[0];
|
const accountNonce = (infoOrTuple as AccountInfo).nonce || (infoOrTuple as [Index, AccountData])[0];
|
||||||
|
|
||||||
return [free, reserved, feeFrozen, miscFrozen, accountNonce];
|
return [accountNonce, [[free, reserved, feeFrozen, miscFrozen]]];
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -81,19 +98,29 @@ function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Re
|
|||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
export function account (instanceId: string, api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAccount> {
|
export function account (instanceId: string, api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAccount> {
|
||||||
|
const balanceInstances = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), 'balances');
|
||||||
|
|
||||||
return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAccount> =>
|
return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAccount> =>
|
||||||
api.derive.accounts.accountId(address).pipe(
|
api.derive.accounts.accountId(address).pipe(
|
||||||
switchMap((accountId): Observable<[AccountId, Result]> =>
|
switchMap((accountId): Observable<[AccountId, Result]> =>
|
||||||
(accountId
|
(accountId
|
||||||
? combineLatest([
|
? combineLatest([
|
||||||
of(accountId),
|
of(accountId),
|
||||||
isFunction(api.query.system.account)
|
balanceInstances
|
||||||
? queryCurrent(api, accountId)
|
? queryBalancesAccount(api, accountId, balanceInstances)
|
||||||
: isFunction(api.query.balances.account)
|
: isFunction(api.query.system.account)
|
||||||
? queryBalancesAccount(api, accountId)
|
? queryCurrent(api, accountId)
|
||||||
: queryBalancesFree(api, accountId)
|
: isFunction(api.query.balances.account)
|
||||||
|
? queryBalancesAccount(api, accountId)
|
||||||
|
: queryBalancesFree(api, accountId)
|
||||||
|
])
|
||||||
|
: of([
|
||||||
|
api.registry.createType('AccountId'),
|
||||||
|
[
|
||||||
|
api.registry.createType('Index'),
|
||||||
|
[[api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Balance')]]
|
||||||
|
]
|
||||||
])
|
])
|
||||||
: of([api.registry.createType('AccountId'), [api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Index')]])
|
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
map((result): DeriveBalancesAccount => calcBalances(api, result))
|
map((result): DeriveBalancesAccount => calcBalances(api, result))
|
||||||
|
|||||||
@@ -1,21 +1,23 @@
|
|||||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
|
||||||
import type { Option, Vec } from '@polkadot/types';
|
import type { Option, Vec } from '@polkadot/types';
|
||||||
import type { AccountId, AccountIndex, Address, Balance, BalanceLock, BalanceLockTo212, BlockNumber, VestingInfo, VestingSchedule } from '@polkadot/types/interfaces';
|
import type { AccountId, AccountIndex, Address, Balance, BalanceLock, BalanceLockTo212, BlockNumber, VestingInfo, VestingSchedule } from '@polkadot/types/interfaces';
|
||||||
import type { Observable } from '@polkadot/x-rxjs';
|
import type { Observable } from '@polkadot/x-rxjs';
|
||||||
import type { DeriveBalancesAccount, DeriveBalancesAll } from '../types';
|
import type { DeriveBalancesAccount, DeriveBalancesAccountData, DeriveBalancesAll, DeriveBalancesAllAccountData } from '../types';
|
||||||
|
|
||||||
import BN from 'bn.js';
|
import BN from 'bn.js';
|
||||||
|
|
||||||
import { bnMax, isFunction } from '@polkadot/util';
|
import { bnMax } from '@polkadot/util';
|
||||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||||
|
|
||||||
import { memo } from '../util';
|
import { memo } from '../util';
|
||||||
|
|
||||||
type ResultBalance = [VestingInfo | null, (BalanceLock | BalanceLockTo212)[]];
|
type BalanceLocksEntry = Vec<BalanceLock | BalanceLockTo212>;
|
||||||
|
type BalanceLocks = BalanceLocksEntry[];
|
||||||
|
type ResultBalance = [VestingInfo | null, ((BalanceLock | BalanceLockTo212)[])[]];
|
||||||
type Result = [DeriveBalancesAccount, BlockNumber, ResultBalance];
|
type Result = [DeriveBalancesAccount, BlockNumber, ResultBalance];
|
||||||
|
|
||||||
interface AllLocked {
|
interface AllLocked {
|
||||||
@@ -50,8 +52,21 @@ function calcLocked (api: ApiInterfaceRx, bestNumber: BlockNumber, locks: (Balan
|
|||||||
return { allLocked, lockedBalance, lockedBreakdown, vestingLocked };
|
return { allLocked, lockedBalance, lockedBreakdown, vestingLocked };
|
||||||
}
|
}
|
||||||
|
|
||||||
function calcBalances (api: ApiInterfaceRx, [{ accountId, accountNonce, freeBalance, frozenFee, frozenMisc, reservedBalance, votingBalance }, bestNumber, [vesting, locks]]: Result): DeriveBalancesAll {
|
function calcShared (api: ApiInterfaceRx, bestNumber: BlockNumber, data: DeriveBalancesAccountData, locks: (BalanceLock | BalanceLockTo212)[]): DeriveBalancesAllAccountData {
|
||||||
const { allLocked, lockedBalance, lockedBreakdown, vestingLocked } = calcLocked(api, bestNumber, locks);
|
const { allLocked, lockedBalance, lockedBreakdown, vestingLocked } = calcLocked(api, bestNumber, locks);
|
||||||
|
const availableBalance = api.registry.createType('Balance', allLocked ? 0 : bnMax(new BN(0), data.freeBalance.sub(lockedBalance)));
|
||||||
|
|
||||||
|
return {
|
||||||
|
...data,
|
||||||
|
availableBalance,
|
||||||
|
lockedBalance,
|
||||||
|
lockedBreakdown,
|
||||||
|
vestingLocked
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function calcBalances (api: ApiInterfaceRx, [data, bestNumber, [vesting, allLocks]]: Result): DeriveBalancesAll {
|
||||||
|
const shared = calcShared(api, bestNumber, data, allLocks[0]);
|
||||||
// Calculate the vesting balances,
|
// Calculate the vesting balances,
|
||||||
// - offset = balance locked at startingBlock
|
// - offset = balance locked at startingBlock
|
||||||
// - perBlock is the unlock amount
|
// - perBlock is the unlock amount
|
||||||
@@ -59,29 +74,21 @@ function calcBalances (api: ApiInterfaceRx, [{ accountId, accountNonce, freeBala
|
|||||||
const isStarted = bestNumber.gt(startingBlock);
|
const isStarted = bestNumber.gt(startingBlock);
|
||||||
const vestedNow = isStarted ? perBlock.mul(bestNumber.sub(startingBlock)) : new BN(0);
|
const vestedNow = isStarted ? perBlock.mul(bestNumber.sub(startingBlock)) : new BN(0);
|
||||||
const vestedBalance = vestedNow.gt(vestingTotal) ? vestingTotal : api.registry.createType('Balance', vestedNow);
|
const vestedBalance = vestedNow.gt(vestingTotal) ? vestingTotal : api.registry.createType('Balance', vestedNow);
|
||||||
const isVesting = isStarted && !vestingLocked.isZero();
|
const isVesting = isStarted && !shared.vestingLocked.isZero();
|
||||||
const vestedClaimable = api.registry.createType('Balance', isVesting ? vestingLocked.sub(vestingTotal.sub(vestedBalance)) : 0);
|
const vestedClaimable = api.registry.createType('Balance', isVesting ? shared.vestingLocked.sub(vestingTotal.sub(vestedBalance)) : 0);
|
||||||
const availableBalance = api.registry.createType('Balance', allLocked ? 0 : bnMax(new BN(0), freeBalance.sub(lockedBalance)));
|
|
||||||
const vestingEndBlock = api.registry.createType('BlockNumber', isVesting ? vestingTotal.div(perBlock).add(startingBlock) : 0);
|
const vestingEndBlock = api.registry.createType('BlockNumber', isVesting ? vestingTotal.div(perBlock).add(startingBlock) : 0);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
accountId,
|
...shared,
|
||||||
accountNonce,
|
accountId: data.accountId,
|
||||||
availableBalance,
|
accountNonce: data.accountNonce,
|
||||||
freeBalance,
|
additional: allLocks.filter((_, index) => index !== 0).map((l, index) => calcShared(api, bestNumber, data.additional[index], l)),
|
||||||
frozenFee,
|
|
||||||
frozenMisc,
|
|
||||||
isVesting,
|
isVesting,
|
||||||
lockedBalance,
|
|
||||||
lockedBreakdown,
|
|
||||||
reservedBalance,
|
|
||||||
vestedBalance,
|
vestedBalance,
|
||||||
vestedClaimable,
|
vestedClaimable,
|
||||||
vestingEndBlock,
|
vestingEndBlock,
|
||||||
vestingLocked,
|
|
||||||
vestingPerBlock: perBlock,
|
vestingPerBlock: perBlock,
|
||||||
vestingTotal,
|
vestingTotal
|
||||||
votingBalance
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,28 +107,37 @@ function queryOld (api: ApiInterfaceRx, accountId: AccountId): Observable<Result
|
|||||||
vestingNew = api.registry.createType('VestingInfo', { locked, perBlock, startingBlock });
|
vestingNew = api.registry.createType('VestingInfo', { locked, perBlock, startingBlock });
|
||||||
}
|
}
|
||||||
|
|
||||||
return [vestingNew, locks];
|
return [vestingNew, [locks]];
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// current (balances vesting)
|
// current (balances, vesting)
|
||||||
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<ResultBalance> {
|
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId, balanceInstances: string[] = ['balances']): Observable<ResultBalance> {
|
||||||
|
const lockCalls = balanceInstances.map((m) => api.query[m].locks);
|
||||||
|
const lockEmpty = lockCalls.map((c) => !c);
|
||||||
|
const lockQueries = lockCalls.filter((c) => c).map((c): QueryableStorageMultiArg<'rxjs'> => [c, accountId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
api.query.vesting?.vesting
|
api.query.vesting?.vesting
|
||||||
? api.queryMulti<[Vec<BalanceLock>, Option<VestingInfo>]>([
|
? api.queryMulti<[Option<VestingInfo>, ...BalanceLocks]>([
|
||||||
[api.query.balances.locks, accountId],
|
[api.query.vesting.vesting, accountId],
|
||||||
[api.query.vesting.vesting, accountId]
|
...lockQueries
|
||||||
])
|
])
|
||||||
: api.query.balances.locks(accountId).pipe(
|
// TODO We need to check module instances here as well, not only the balances module
|
||||||
map((locks): [Vec<BalanceLock>, Option<VestingInfo>] =>
|
: lockQueries.length
|
||||||
[locks, api.registry.createType('Option<VestingInfo>')]
|
? api.queryMulti<[...(Vec<BalanceLock>)[]]>(lockQueries).pipe(
|
||||||
|
map((locks): [Option<VestingInfo>, ...BalanceLocks] =>
|
||||||
|
[api.registry.createType('Option<VestingInfo>'), ...locks]
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
: of([api.registry.createType('Option<VestingInfo>')] as [Option<VestingInfo>])
|
||||||
).pipe(
|
).pipe(
|
||||||
map(([locks, optVesting]): ResultBalance =>
|
map(([optVesting, ...locks]): ResultBalance => {
|
||||||
[optVesting.unwrapOr(null), locks]
|
let offset = -1;
|
||||||
)
|
|
||||||
|
return [optVesting.unwrapOr(null), lockEmpty.map((e) => e ? api.registry.createType('Vec<BalanceLock>') : locks[++offset])];
|
||||||
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,6 +157,8 @@ function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Re
|
|||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
export function all (instanceId: string, api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAll> {
|
export function all (instanceId: string, api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAll> {
|
||||||
|
const balanceInstances = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), 'balances');
|
||||||
|
|
||||||
return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAll> =>
|
return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAll> =>
|
||||||
api.derive.balances.account(address).pipe(
|
api.derive.balances.account(address).pipe(
|
||||||
switchMap((account): Observable<Result> =>
|
switchMap((account): Observable<Result> =>
|
||||||
@@ -148,11 +166,11 @@ export function all (instanceId: string, api: ApiInterfaceRx): (address: Account
|
|||||||
? combineLatest([
|
? combineLatest([
|
||||||
of(account),
|
of(account),
|
||||||
api.derive.chain.bestNumber(),
|
api.derive.chain.bestNumber(),
|
||||||
isFunction(api.query.system.account) || isFunction(api.query.balances.account)
|
api.query.system?.account || api.query.balances?.account
|
||||||
? queryCurrent(api, account.accountId)
|
? queryCurrent(api, account.accountId, balanceInstances)
|
||||||
: queryOld(api, account.accountId)
|
: queryOld(api, account.accountId)
|
||||||
])
|
])
|
||||||
: of([account, api.registry.createType('BlockNumber'), [null, api.registry.createType('Vec<BalanceLock>')]])
|
: of([account, api.registry.createType('BlockNumber'), [null, []]])
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
map((result): DeriveBalancesAll => calcBalances(api, result))
|
map((result): DeriveBalancesAll => calcBalances(api, result))
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ describe('bounties derive', () => {
|
|||||||
let storageKey: (index: number) => StorageKey;
|
let storageKey: (index: number) => StorageKey;
|
||||||
let defaultBounty: () => Bounty;
|
let defaultBounty: () => Bounty;
|
||||||
let emptyOption: <T extends Codec> (typeName: keyof InterfaceTypes) => Option<T>;
|
let emptyOption: <T extends Codec> (typeName: keyof InterfaceTypes) => Option<T>;
|
||||||
let optionOf: <T extends Codec> (value: T)=> Option<T>;
|
let optionOf: <T extends Codec> (value: T) => Option<T>;
|
||||||
let bountyIndex: (index: number) => BountyIndex;
|
let bountyIndex: (index: number) => BountyIndex;
|
||||||
let proposalIndex: (index: number) => ProposalIndex;
|
let proposalIndex: (index: number) => ProposalIndex;
|
||||||
let bytes: (value: string) => Bytes;
|
let bytes: (value: string) => Bytes;
|
||||||
@@ -59,7 +59,7 @@ describe('bounties derive', () => {
|
|||||||
bountyDescriptions: {
|
bountyDescriptions: {
|
||||||
multi: () => of([
|
multi: () => of([
|
||||||
optionOf(bytes('make polkadot even better')),
|
optionOf(bytes('make polkadot even better')),
|
||||||
optionOf(bytes('this will be totally ignored'))
|
optionOf(bytes('some other bounty'))
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,6 +117,28 @@ describe('bounties derive', () => {
|
|||||||
expect(result[1].proposals).toHaveLength(0);
|
expect(result[1].proposals).toHaveLength(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('when no council, returns bounties without motions', async () => {
|
||||||
|
const mockApi = {
|
||||||
|
...defaultMockApi,
|
||||||
|
query: {
|
||||||
|
...defaultMockApi.query,
|
||||||
|
council: null
|
||||||
|
}
|
||||||
|
} as unknown as ApiInterfaceRx;
|
||||||
|
|
||||||
|
const result = await bounties('', mockApi)().toPromise();
|
||||||
|
|
||||||
|
expect(result).toHaveLength(2);
|
||||||
|
expect(result[0].bounty.proposer.toString()).toEqual(DEFAULT_PROPOSER);
|
||||||
|
expect(result[0].description).toEqual('make polkadot even better');
|
||||||
|
expect(result[0].index.eq(0)).toBe(true);
|
||||||
|
expect(result[0].proposals).toHaveLength(0);
|
||||||
|
expect(result[1].bounty.proposer.toString()).toEqual(DEFAULT_PROPOSER);
|
||||||
|
expect(result[1].description).toEqual('some other bounty');
|
||||||
|
expect(result[1].index.eq(1)).toBe(true);
|
||||||
|
expect(result[1].proposals).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
it('combines bounties with motions', async () => {
|
it('combines bounties with motions', async () => {
|
||||||
const mockApi = {
|
const mockApi = {
|
||||||
...defaultMockApi,
|
...defaultMockApi,
|
||||||
|
|||||||
@@ -32,21 +32,21 @@ function parseResult ([maybeBounties, maybeDescriptions, ids, bountyProposals]:
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function bounties (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveBounties> {
|
export function bounties (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveBounties> {
|
||||||
const bountyBase = api.query.bounties ? api.query.bounties : api.query.treasury;
|
const bountyBase = api.query.bounties || api.query.treasury;
|
||||||
|
|
||||||
return memo(instanceId, (): Observable<DeriveBounties> =>
|
return memo(instanceId, (): Observable<DeriveBounties> =>
|
||||||
combineLatest([
|
combineLatest([
|
||||||
bountyBase.bountyCount<BountyIndex>(),
|
bountyBase.bountyCount<BountyIndex>(),
|
||||||
api.query.council.proposalCount<ProposalIndex>()
|
api.query.council ? api.query.council.proposalCount<ProposalIndex>() : of(0)
|
||||||
]).pipe(
|
]).pipe(
|
||||||
switchMap(() =>
|
switchMap(() =>
|
||||||
combineLatest([
|
combineLatest([
|
||||||
bountyBase.bounties.keys(),
|
bountyBase.bounties.keys<[BountyIndex]>(),
|
||||||
api.derive.council.proposals()
|
api.derive.council ? api.derive.council.proposals() : of([])
|
||||||
])
|
])
|
||||||
),
|
),
|
||||||
switchMap(([keys, proposals]): Observable<Result> => {
|
switchMap(([keys, proposals]): Observable<Result> => {
|
||||||
const ids = keys.map(({ args: [id] }) => id as BountyIndex);
|
const ids = keys.map(({ args: [id] }) => id);
|
||||||
|
|
||||||
return combineLatest([
|
return combineLatest([
|
||||||
bountyBase.bounties.multi<Option<Bounty>>(ids),
|
bountyBase.bounties.multi<Option<Bounty>>(ids),
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||||
import type { Vec } from '@polkadot/types';
|
import type { Vec } from '@polkadot/types';
|
||||||
import type { AccountId, Balance } from '@polkadot/types/interfaces';
|
import type { AccountId, Balance, Voter } from '@polkadot/types/interfaces';
|
||||||
import type { ITuple } from '@polkadot/types/types';
|
import type { ITuple } from '@polkadot/types/types';
|
||||||
import type { Observable } from '@polkadot/x-rxjs';
|
import type { Observable } from '@polkadot/x-rxjs';
|
||||||
import type { DeriveCouncilVote, DeriveCouncilVotes } from '../types';
|
import type { DeriveCouncilVote, DeriveCouncilVotes } from '../types';
|
||||||
@@ -13,18 +13,25 @@ import { map } from '@polkadot/x-rxjs/operators';
|
|||||||
|
|
||||||
import { memo } from '../util';
|
import { memo } from '../util';
|
||||||
|
|
||||||
|
// Voter is current tuple is 2.x-era
|
||||||
|
type VoteEntry = Voter | ITuple<[Balance, Vec<AccountId>]>;
|
||||||
|
|
||||||
|
function isVoter (value: VoteEntry): value is Voter {
|
||||||
|
return !Array.isArray(value);
|
||||||
|
}
|
||||||
|
|
||||||
function retrieveStakeOf (api: ApiInterfaceRx): Observable<[AccountId, Balance][]> {
|
function retrieveStakeOf (api: ApiInterfaceRx): Observable<[AccountId, Balance][]> {
|
||||||
return (api.query.electionsPhragmen || api.query.elections).stakeOf.entries<Balance>().pipe(
|
return (api.query.electionsPhragmen || api.query.elections).stakeOf.entries<Balance, [AccountId]>().pipe(
|
||||||
map((entries) =>
|
map((entries) =>
|
||||||
entries.map(([key, stake]) => [key.args[0] as AccountId, stake])
|
entries.map(([{ args: [accountId] }, stake]) => [accountId, stake])
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function retrieveVoteOf (api: ApiInterfaceRx): Observable<[AccountId, AccountId[]][]> {
|
function retrieveVoteOf (api: ApiInterfaceRx): Observable<[AccountId, AccountId[]][]> {
|
||||||
return (api.query.electionsPhragmen || api.query.elections).votesOf.entries<Vec<AccountId>>().pipe(
|
return (api.query.electionsPhragmen || api.query.elections).votesOf.entries<Vec<AccountId>, [AccountId]>().pipe(
|
||||||
map((entries) =>
|
map((entries) =>
|
||||||
entries.map(([key, votes]) => [key.args[0] as AccountId, votes])
|
entries.map(([{ args: [accountId] }, votes]) => [accountId, votes])
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -56,11 +63,14 @@ function retrievePrev (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
|
|||||||
function retrieveCurrent (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
|
function retrieveCurrent (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
|
||||||
const elections = (api.query.electionsPhragmen || api.query.elections);
|
const elections = (api.query.electionsPhragmen || api.query.elections);
|
||||||
|
|
||||||
return elections.voting.entries<ITuple<[Balance, Vec<AccountId>]>>().pipe(
|
return elections.voting.entries<VoteEntry, [AccountId]>().pipe(
|
||||||
map((entries): DeriveCouncilVotes =>
|
map((entries): DeriveCouncilVotes =>
|
||||||
entries.map(([key, [stake, votes]]): [AccountId, DeriveCouncilVote] =>
|
entries.map(([{ args: [accountId] }, value]): [AccountId, DeriveCouncilVote] => [
|
||||||
[key.args[0] as AccountId, { stake, votes }]
|
accountId,
|
||||||
)
|
isVoter(value)
|
||||||
|
? { stake: value.stake, votes: value.votes }
|
||||||
|
: { stake: value[0], votes: value[1] }
|
||||||
|
])
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ function schedulerEntries (api: ApiInterfaceRx): Observable<[BlockNumber[], Opti
|
|||||||
api.query.scheduler.agenda.keys()
|
api.query.scheduler.agenda.keys()
|
||||||
),
|
),
|
||||||
switchMap((keys) => {
|
switchMap((keys) => {
|
||||||
const blockNumbers = keys.map((key) => key.args[0] as BlockNumber);
|
const blockNumbers = keys.map(({ args: [blockNumber] }) => blockNumber);
|
||||||
|
|
||||||
return combineLatest([
|
return combineLatest([
|
||||||
of(blockNumbers),
|
of(blockNumbers),
|
||||||
|
|||||||
@@ -67,9 +67,9 @@ function extractVotes (mapped: [AccountId, Voting][], referendumId: BN): DeriveR
|
|||||||
}
|
}
|
||||||
|
|
||||||
function votesCurr (api: ApiInterfaceRx, referendumId: BN): Observable<DeriveReferendumVote[]> {
|
function votesCurr (api: ApiInterfaceRx, referendumId: BN): Observable<DeriveReferendumVote[]> {
|
||||||
return api.query.democracy.votingOf.entries<Voting>().pipe(
|
return api.query.democracy.votingOf.entries<Voting, [AccountId]>().pipe(
|
||||||
map((allVoting): DeriveReferendumVote[] => {
|
map((allVoting): DeriveReferendumVote[] => {
|
||||||
const mapped = allVoting.map(([key, voting]): [AccountId, Voting] => [key.args[0] as AccountId, voting]);
|
const mapped = allVoting.map(([{ args: [accountId] }, voting]): [AccountId, Voting] => [accountId, voting]);
|
||||||
const votes = extractVotes(mapped, referendumId);
|
const votes = extractVotes(mapped, referendumId);
|
||||||
const delegations = mapped
|
const delegations = mapped
|
||||||
.filter(([, voting]) => voting.isDelegating)
|
.filter(([, voting]) => voting.isDelegating)
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import { packageInfo as apiInfo } from '@polkadot/api/packageInfo';
|
||||||
|
import { packageInfo as coreInfo } from '@polkadot/rpc-core/packageInfo';
|
||||||
|
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||||
|
import { detectPackage } from '@polkadot/util';
|
||||||
|
|
||||||
|
import { packageInfo } from './packageInfo';
|
||||||
|
|
||||||
|
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [apiInfo, coreInfo, typesInfo]);
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||||
import type { u32, Vec } from '@polkadot/types';
|
import type { u32, Vec } from '@polkadot/types';
|
||||||
import type { AccountId, Balance, BlockNumber } from '@polkadot/types/interfaces';
|
import type { AccountId, Balance, BlockNumber, SeatHolder } from '@polkadot/types/interfaces';
|
||||||
import type { ITuple } from '@polkadot/types/types';
|
import type { ITuple } from '@polkadot/types/types';
|
||||||
import type { Observable } from '@polkadot/x-rxjs';
|
import type { Observable } from '@polkadot/x-rxjs';
|
||||||
import type { DeriveElectionsInfo } from './types';
|
import type { DeriveElectionsInfo } from './types';
|
||||||
@@ -12,14 +12,39 @@ import { map } from '@polkadot/x-rxjs/operators';
|
|||||||
|
|
||||||
import { memo } from '../util';
|
import { memo } from '../util';
|
||||||
|
|
||||||
function sortAccounts ([, balanceA]: ITuple<[AccountId, Balance]>, [, balanceB]: ITuple<[AccountId, Balance]>): number {
|
// SeatHolder is current tuple is 2.x-era Substrate
|
||||||
|
type Member = SeatHolder | ITuple<[AccountId, Balance]>;
|
||||||
|
|
||||||
|
type Candidate = AccountId | ITuple<[AccountId, Balance]>;
|
||||||
|
|
||||||
|
function isSeatHolder (value: Member): value is SeatHolder {
|
||||||
|
return !Array.isArray(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isCandidateTuple (value: Candidate): value is ITuple<[AccountId, Balance]> {
|
||||||
|
return Array.isArray(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAccountTuple (value: Member): [AccountId, Balance] {
|
||||||
|
return isSeatHolder(value)
|
||||||
|
? [value.who, value.stake]
|
||||||
|
: value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCandidate (value: Candidate): AccountId {
|
||||||
|
return isCandidateTuple(value)
|
||||||
|
? value[0]
|
||||||
|
: value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function sortAccounts ([, balanceA]: [AccountId, Balance], [, balanceB]: [AccountId, Balance]): number {
|
||||||
return balanceB.cmp(balanceA);
|
return balanceB.cmp(balanceA);
|
||||||
}
|
}
|
||||||
|
|
||||||
function queryElections (api: ApiInterfaceRx): Observable<DeriveElectionsInfo> {
|
function queryElections (api: ApiInterfaceRx): Observable<DeriveElectionsInfo> {
|
||||||
const section = api.query.electionsPhragmen ? 'electionsPhragmen' : 'elections';
|
const section = api.query.electionsPhragmen ? 'electionsPhragmen' : 'elections';
|
||||||
|
|
||||||
return api.queryMulti<[Vec<AccountId>, Vec<AccountId>, Vec<ITuple<[AccountId, Balance]>>, Vec<ITuple<[AccountId, Balance]>>]>([
|
return api.queryMulti<[Vec<AccountId>, Vec<Candidate>, Vec<Member>, Vec<Member>]>([
|
||||||
api.query.council.members,
|
api.query.council.members,
|
||||||
api.query[section].candidates,
|
api.query[section].candidates,
|
||||||
api.query[section].members,
|
api.query[section].members,
|
||||||
@@ -28,13 +53,13 @@ function queryElections (api: ApiInterfaceRx): Observable<DeriveElectionsInfo> {
|
|||||||
map(([councilMembers, candidates, members, runnersUp]): DeriveElectionsInfo => ({
|
map(([councilMembers, candidates, members, runnersUp]): DeriveElectionsInfo => ({
|
||||||
candidacyBond: api.consts[section].candidacyBond as Balance,
|
candidacyBond: api.consts[section].candidacyBond as Balance,
|
||||||
candidateCount: api.registry.createType('u32', candidates.length),
|
candidateCount: api.registry.createType('u32', candidates.length),
|
||||||
candidates,
|
candidates: candidates.map(getCandidate),
|
||||||
desiredRunnersUp: api.consts[section].desiredRunnersUp as u32,
|
desiredRunnersUp: api.consts[section].desiredRunnersUp as u32,
|
||||||
desiredSeats: api.consts[section].desiredMembers as u32,
|
desiredSeats: api.consts[section].desiredMembers as u32,
|
||||||
members: members.length
|
members: members.length
|
||||||
? members.sort(sortAccounts)
|
? members.map(getAccountTuple).sort(sortAccounts)
|
||||||
: councilMembers.map((accountId): [AccountId, Balance] => [accountId, api.registry.createType('Balance')]),
|
: councilMembers.map((accountId): [AccountId, Balance] => [accountId, api.registry.createType('Balance')]),
|
||||||
runnersUp: runnersUp.sort(sortAccounts),
|
runnersUp: runnersUp.map(getAccountTuple).sort(sortAccounts),
|
||||||
termDuration: api.consts[section].termDuration as BlockNumber,
|
termDuration: api.consts[section].termDuration as BlockNumber,
|
||||||
votingBond: api.consts[section].votingBond as Balance
|
votingBond: api.consts[section].votingBond as Balance
|
||||||
}))
|
}))
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import './detectPackage';
|
||||||
|
|
||||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||||
import type { AnyFunction } from '@polkadot/types/types';
|
import type { AnyFunction } from '@polkadot/types/types';
|
||||||
import type { Observable } from '@polkadot/x-rxjs';
|
import type { Observable } from '@polkadot/x-rxjs';
|
||||||
@@ -22,6 +24,7 @@ import * as technicalCommittee from './technicalCommittee';
|
|||||||
import * as treasury from './treasury';
|
import * as treasury from './treasury';
|
||||||
import * as tx from './tx';
|
import * as tx from './tx';
|
||||||
|
|
||||||
|
export { packageInfo } from './packageInfo';
|
||||||
export * from './type';
|
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, parachains, session, society, staking, technicalCommittee, treasury, tx };
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// Copyright 2017-2021 @polkadot/dev authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
// Auto-generated by @polkadot/dev, do not edit
|
||||||
|
|
||||||
|
export const packageInfo = { name: '@polkadot/api-derive', version: '3.11.1' };
|
||||||
@@ -35,6 +35,7 @@ function queryAura (api: ApiInterfaceRx): Observable<DeriveSessionInfo> {
|
|||||||
[
|
[
|
||||||
false,
|
false,
|
||||||
api.registry.createType('u64', 1),
|
api.registry.createType('u64', 1),
|
||||||
|
// we may have aura without staking (permissioned)
|
||||||
api.consts.staking?.sessionsPerEra || api.registry.createType('SessionIndex', 1)
|
api.consts.staking?.sessionsPerEra || api.registry.createType('SessionIndex', 1)
|
||||||
],
|
],
|
||||||
indexes
|
indexes
|
||||||
@@ -50,7 +51,8 @@ function queryBabe (api: ApiInterfaceRx): Observable<DeriveSessionInfo> {
|
|||||||
[
|
[
|
||||||
true,
|
true,
|
||||||
api.consts.babe.epochDuration,
|
api.consts.babe.epochDuration,
|
||||||
api.consts.staking.sessionsPerEra
|
// we may have babe without staking (permissioned)
|
||||||
|
api.consts.staking?.sessionsPerEra || api.registry.createType('SessionIndex', 1)
|
||||||
],
|
],
|
||||||
indexes
|
indexes
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
|||||||
|
|
||||||
import { memo } from '../util';
|
import { memo } from '../util';
|
||||||
|
|
||||||
|
type ResultSlotsNoSession = [u64, u64, u64];
|
||||||
type ResultSlots = [u64, u64, u64, Option<SessionIndex>];
|
type ResultSlots = [u64, u64, u64, Option<SessionIndex>];
|
||||||
type ResultSlotsFlat = [u64, u64, u64, SessionIndex];
|
type ResultSlotsFlat = [u64, u64, u64, SessionIndex];
|
||||||
|
|
||||||
@@ -39,19 +40,26 @@ function queryAura (api: ApiInterfaceRx): Observable<DeriveSessionProgress> {
|
|||||||
|
|
||||||
function queryBabe (api: ApiInterfaceRx): Observable<[DeriveSessionInfo, ResultSlotsFlat]> {
|
function queryBabe (api: ApiInterfaceRx): Observable<[DeriveSessionInfo, ResultSlotsFlat]> {
|
||||||
return api.derive.session.info().pipe(
|
return api.derive.session.info().pipe(
|
||||||
switchMap((info): Observable<[DeriveSessionInfo, ResultSlots]> =>
|
switchMap((info): Observable<[DeriveSessionInfo, ResultSlots | ResultSlotsNoSession]> =>
|
||||||
combineLatest([
|
combineLatest([
|
||||||
of(info),
|
of(info),
|
||||||
api.queryMulti<ResultSlots>([
|
// we may have no staking, but have babe (permissioned)
|
||||||
api.query.babe.currentSlot,
|
api.query.staking
|
||||||
api.query.babe.epochIndex,
|
? api.queryMulti<ResultSlots>([
|
||||||
api.query.babe.genesisSlot,
|
api.query.babe.currentSlot,
|
||||||
[api.query.staking.erasStartSessionIndex, info.activeEra]
|
api.query.babe.epochIndex,
|
||||||
])
|
api.query.babe.genesisSlot,
|
||||||
|
[api.query.staking.erasStartSessionIndex, info.activeEra]
|
||||||
|
])
|
||||||
|
: api.queryMulti<ResultSlotsNoSession>([
|
||||||
|
api.query.babe.currentSlot,
|
||||||
|
api.query.babe.epochIndex,
|
||||||
|
api.query.babe.genesisSlot
|
||||||
|
])
|
||||||
])
|
])
|
||||||
),
|
),
|
||||||
map(([info, [currentSlot, epochIndex, genesisSlot, optStartIndex]]): [DeriveSessionInfo, ResultSlotsFlat] => [
|
map(([info, [currentSlot, epochIndex, genesisSlot, optStartIndex]]): [DeriveSessionInfo, ResultSlotsFlat] => [
|
||||||
info, [currentSlot, epochIndex, genesisSlot, optStartIndex.unwrapOr(api.registry.createType('SessionIndex', 1))]
|
info, [currentSlot, epochIndex, genesisSlot, optStartIndex && optStartIndex.isSome ? optStartIndex.unwrap() : api.registry.createType('SessionIndex', 1)]
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||||
import type { StorageKey } from '@polkadot/types';
|
import type { StorageKey } from '@polkadot/types';
|
||||||
import type { EraIndex, Exposure } from '@polkadot/types/interfaces';
|
import type { AccountId, EraIndex, Exposure } from '@polkadot/types/interfaces';
|
||||||
import type { Observable } from '@polkadot/x-rxjs';
|
import type { Observable } from '@polkadot/x-rxjs';
|
||||||
import type { DeriveEraExposure, DeriveEraNominatorExposure, DeriveEraValidatorExposure } from '../types';
|
import type { DeriveEraExposure, DeriveEraNominatorExposure, DeriveEraValidatorExposure } from '../types';
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
|||||||
|
|
||||||
import { deriveCache, memo } from '../util';
|
import { deriveCache, memo } from '../util';
|
||||||
|
|
||||||
type KeysAndExposures = [StorageKey, Exposure][];
|
type KeysAndExposures = [StorageKey<[EraIndex, AccountId]>, Exposure][];
|
||||||
|
|
||||||
const CACHE_KEY = 'eraExposure';
|
const CACHE_KEY = 'eraExposure';
|
||||||
|
|
||||||
|
|||||||
@@ -1,55 +1,37 @@
|
|||||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
|
||||||
import type { EraIndex, Exposure } from '@polkadot/types/interfaces';
|
import type { EraIndex, Exposure } from '@polkadot/types/interfaces';
|
||||||
import type { Observable } from '@polkadot/x-rxjs';
|
import type { Observable } from '@polkadot/x-rxjs';
|
||||||
import type { DeriveOwnExposure } from '../types';
|
import type { DeriveOwnExposure } from '../types';
|
||||||
|
|
||||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
import { of } from '@polkadot/x-rxjs';
|
||||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||||
|
|
||||||
import { deriveCache, memo } from '../util';
|
import { memo } from '../util';
|
||||||
|
|
||||||
const CACHE_KEY = 'ownExposure';
|
export function _ownExposures (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveOwnExposure[]> {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
export function _ownExposure (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, era: EraIndex, withActive: boolean) => Observable<DeriveOwnExposure> {
|
return memo(instanceId, (accountId: Uint8Array | string, eras: EraIndex[], _withActive: boolean): Observable<DeriveOwnExposure[]> =>
|
||||||
return memo(instanceId, (accountId: Uint8Array | string, era: EraIndex, withActive: boolean): Observable<DeriveOwnExposure> => {
|
eras.length
|
||||||
const cacheKey = `${CACHE_KEY}-${era.toString()}-${accountId.toString()}`;
|
? api.queryMulti<Exposure[]>([
|
||||||
const cached = withActive
|
...eras.map((era): QueryableStorageMultiArg<'rxjs'> => [api.query.staking.erasStakersClipped, [era, accountId]]),
|
||||||
? undefined
|
...eras.map((era): QueryableStorageMultiArg<'rxjs'> => [api.query.staking.erasStakers, [era, accountId]])
|
||||||
: deriveCache.get<DeriveOwnExposure>(cacheKey);
|
|
||||||
|
|
||||||
return cached
|
|
||||||
? of(cached)
|
|
||||||
: api.queryMulti<[Exposure, Exposure]>([
|
|
||||||
[api.query.staking.erasStakersClipped, [era, accountId]],
|
|
||||||
[api.query.staking.erasStakers, [era, accountId]]
|
|
||||||
]).pipe(
|
]).pipe(
|
||||||
map(([clipped, exposure]): DeriveOwnExposure => {
|
map((all): DeriveOwnExposure[] =>
|
||||||
const value = { clipped, era, exposure };
|
eras.map((era, index) => ({ clipped: all[index], era, exposure: all[eras.length + index] }))
|
||||||
|
)
|
||||||
!withActive && deriveCache.set(cacheKey, value);
|
)
|
||||||
|
: of([])
|
||||||
return value;
|
);
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ownExposure (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, era: EraIndex) => Observable<DeriveOwnExposure> {
|
export function ownExposure (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, era: EraIndex) => Observable<DeriveOwnExposure> {
|
||||||
return memo(instanceId, (accountId: Uint8Array | string, era: EraIndex): Observable<DeriveOwnExposure> =>
|
return memo(instanceId, (accountId: Uint8Array | string, era: EraIndex): Observable<DeriveOwnExposure> =>
|
||||||
api.derive.staking._ownExposure(accountId, era, true)
|
api.derive.staking._ownExposures(accountId, [era], true).pipe(
|
||||||
);
|
map(([first]) => first)
|
||||||
}
|
)
|
||||||
|
|
||||||
export function _ownExposures (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveOwnExposure[]> {
|
|
||||||
return memo(instanceId, (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean): Observable<DeriveOwnExposure[]> =>
|
|
||||||
eras.length
|
|
||||||
? combineLatest(
|
|
||||||
eras.map((era) => api.derive.staking._ownExposure(accountId, era, withActive))
|
|
||||||
)
|
|
||||||
: of([])
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,62 +1,44 @@
|
|||||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
|
||||||
import type { Option } from '@polkadot/types';
|
import type { Option } from '@polkadot/types';
|
||||||
import type { BalanceOf, EraIndex, Perbill } from '@polkadot/types/interfaces';
|
import type { BalanceOf, EraIndex, Perbill } from '@polkadot/types/interfaces';
|
||||||
import type { ITuple } from '@polkadot/types/types';
|
import type { ITuple } from '@polkadot/types/types';
|
||||||
import type { Observable } from '@polkadot/x-rxjs';
|
import type { Observable } from '@polkadot/x-rxjs';
|
||||||
import type { DeriveStakerSlashes } from '../types';
|
import type { DeriveStakerSlashes } from '../types';
|
||||||
|
|
||||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
import { of } from '@polkadot/x-rxjs';
|
||||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||||
|
|
||||||
import { deriveCache, memo } from '../util';
|
import { memo } from '../util';
|
||||||
|
|
||||||
const CACHE_KEY = 'ownSlash';
|
export function _ownSlashes (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerSlashes[]> {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
export function _ownSlash (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, era: EraIndex, withActive: boolean) => Observable<DeriveStakerSlashes> {
|
return memo(instanceId, (accountId: Uint8Array | string, eras: EraIndex[], _withActive: boolean): Observable<DeriveStakerSlashes[]> =>
|
||||||
return memo(instanceId, (accountId: Uint8Array | string, era: EraIndex, withActive: boolean): Observable<DeriveStakerSlashes> => {
|
eras.length
|
||||||
const cacheKey = `${CACHE_KEY}-${era.toString()}-${accountId.toString()}`;
|
? api.queryMulti<(Option<ITuple<[Perbill, BalanceOf]>> | Option<BalanceOf>)[]>([
|
||||||
const cached = withActive
|
...eras.map((era): QueryableStorageMultiArg<'rxjs'> => [api.query.staking.validatorSlashInEra, [era, accountId]]),
|
||||||
? undefined
|
...eras.map((era): QueryableStorageMultiArg<'rxjs'> => [api.query.staking.nominatorSlashInEra, [era, accountId]])
|
||||||
: deriveCache.get<DeriveStakerSlashes>(cacheKey);
|
|
||||||
|
|
||||||
return cached
|
|
||||||
? of(cached)
|
|
||||||
: api.queryMulti<[Option<BalanceOf>, Option<ITuple<[Perbill, BalanceOf]>>]>([
|
|
||||||
[api.query.staking.nominatorSlashInEra, [era, accountId]],
|
|
||||||
[api.query.staking.validatorSlashInEra, [era, accountId]]
|
|
||||||
]).pipe(
|
]).pipe(
|
||||||
map(([optNom, optVal]): DeriveStakerSlashes => {
|
map((values): DeriveStakerSlashes[] =>
|
||||||
const value = {
|
eras.map((era, index) => ({
|
||||||
era,
|
era,
|
||||||
total: optVal.isSome
|
total: values[index].isSome
|
||||||
? optVal.unwrap()[1]
|
? (values[index].unwrap() as ITuple<[Perbill, BalanceOf]>)[1]
|
||||||
: optNom.unwrapOrDefault()
|
: (values[index + eras.length].unwrapOrDefault() as BalanceOf)
|
||||||
};
|
}))
|
||||||
|
)
|
||||||
!withActive && deriveCache.set(cacheKey, value);
|
)
|
||||||
|
: of([])
|
||||||
return value;
|
);
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ownSlash (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, era: EraIndex) => Observable<DeriveStakerSlashes> {
|
export function ownSlash (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, era: EraIndex) => Observable<DeriveStakerSlashes> {
|
||||||
return memo(instanceId, (accountId: Uint8Array | string, era: EraIndex): Observable<DeriveStakerSlashes> =>
|
return memo(instanceId, (accountId: Uint8Array | string, era: EraIndex): Observable<DeriveStakerSlashes> =>
|
||||||
api.derive.staking._ownSlash(accountId, era, true)
|
api.derive.staking._ownSlashes(accountId, [era], true).pipe(
|
||||||
);
|
map(([first]) => first)
|
||||||
}
|
)
|
||||||
|
|
||||||
export function _ownSlashes (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerSlashes[]> {
|
|
||||||
return memo(instanceId, (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean): Observable<DeriveStakerSlashes[]> =>
|
|
||||||
eras.length
|
|
||||||
? combineLatest(
|
|
||||||
eras.map((era) => api.derive.staking._ownSlash(accountId, era, withActive))
|
|
||||||
)
|
|
||||||
: of([])
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,36 +10,46 @@ import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
|||||||
|
|
||||||
import { memo } from '../util';
|
import { memo } from '../util';
|
||||||
|
|
||||||
export function _stakerExposure (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerExposure[]> {
|
export function _stakerExposures (instanceId: string, api: ApiInterfaceRx): (accountIds: (Uint8Array | string)[], eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerExposure[][]> {
|
||||||
return memo(instanceId, (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean): Observable<DeriveStakerExposure[]> => {
|
return memo(instanceId, (accountIds: (Uint8Array | string)[], eras: EraIndex[], withActive: boolean): Observable<DeriveStakerExposure[][]> => {
|
||||||
const stakerId = api.registry.createType('AccountId', accountId).toString();
|
const stakerIds = accountIds.map((a) => api.registry.createType('AccountId', a).toString());
|
||||||
|
|
||||||
return api.derive.staking._erasExposure(eras, withActive).pipe(
|
return api.derive.staking._erasExposure(eras, withActive).pipe(
|
||||||
map((exposures): DeriveStakerExposure[] =>
|
map((exposures): DeriveStakerExposure[][] =>
|
||||||
exposures.map(({ era, nominators: allNominators, validators: allValidators }): DeriveStakerExposure => {
|
stakerIds.map((stakerId) =>
|
||||||
const isValidator = !!allValidators[stakerId];
|
exposures.map(({ era, nominators: allNominators, validators: allValidators }): DeriveStakerExposure => {
|
||||||
const validators: DeriveEraValidatorExposure = {};
|
const isValidator = !!allValidators[stakerId];
|
||||||
const nominating = allNominators[stakerId] || [];
|
const validators: DeriveEraValidatorExposure = {};
|
||||||
|
const nominating = allNominators[stakerId] || [];
|
||||||
|
|
||||||
if (isValidator) {
|
if (isValidator) {
|
||||||
validators[stakerId] = allValidators[stakerId];
|
validators[stakerId] = allValidators[stakerId];
|
||||||
} else if (nominating) {
|
} else if (nominating) {
|
||||||
nominating.forEach(({ validatorId }): void => {
|
nominating.forEach(({ validatorId }): void => {
|
||||||
validators[validatorId] = allValidators[validatorId];
|
validators[validatorId] = allValidators[validatorId];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return { era, isEmpty: !Object.keys(validators).length, isValidator, nominating, validators };
|
return { era, isEmpty: !Object.keys(validators).length, isValidator, nominating, validators };
|
||||||
})
|
})
|
||||||
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function stakerExposure (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, withActive?: boolean) => Observable<DeriveStakerExposure[]> {
|
export function stakerExposures (instanceId: string, api: ApiInterfaceRx): (accountIds: (Uint8Array | string)[], withActive?: boolean) => Observable<DeriveStakerExposure[][]> {
|
||||||
return memo(instanceId, (accountId: Uint8Array | string, withActive = false): Observable<DeriveStakerExposure[]> =>
|
return memo(instanceId, (accountIds: (Uint8Array | string)[], withActive = false): Observable<DeriveStakerExposure[][]> =>
|
||||||
api.derive.staking.erasHistoric(withActive).pipe(
|
api.derive.staking.erasHistoric(withActive).pipe(
|
||||||
switchMap((eras) => api.derive.staking._stakerExposure(accountId, eras, withActive))
|
switchMap((eras) => api.derive.staking._stakerExposures(accountIds, eras, withActive))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function stakerExposure (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, withActive?: boolean) => Observable<DeriveStakerExposure[]> {
|
||||||
|
return memo(instanceId, (accountId: Uint8Array | string, withActive = false): Observable<DeriveStakerExposure[]> =>
|
||||||
|
api.derive.staking.stakerExposures([accountId, withActive]).pipe(
|
||||||
|
map(([first]) => first)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,45 +2,40 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||||
import type { Option } from '@polkadot/types';
|
import type { AccountId, EraIndex, StakingLedger } from '@polkadot/types/interfaces';
|
||||||
import type { AccountId, EraIndex, StakingLedger, StakingLedgerTo240 } from '@polkadot/types/interfaces';
|
|
||||||
import type { Observable } from '@polkadot/x-rxjs';
|
import type { Observable } from '@polkadot/x-rxjs';
|
||||||
import type { DeriveEraPoints, DeriveEraPrefs, DeriveEraRewards, DeriveEraValPrefs, DeriveStakerExposure, DeriveStakerReward, DeriveStakerRewardValidator } from '../types';
|
import type { DeriveEraPoints, DeriveEraPrefs, DeriveEraRewards, DeriveEraValPrefs, DeriveStakerExposure, DeriveStakerReward, DeriveStakerRewardValidator } from '../types';
|
||||||
import type { DeriveStakingQuery } from './types';
|
import type { DeriveStakingQuery } from './types';
|
||||||
|
|
||||||
import BN from 'bn.js';
|
import BN from 'bn.js';
|
||||||
|
|
||||||
import { isFunction } from '@polkadot/util';
|
import { BN_BILLION, BN_ZERO } from '@polkadot/util';
|
||||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||||
|
|
||||||
import { memo } from '../util';
|
import { memo } from '../util';
|
||||||
|
|
||||||
type ErasResult = [{ unwrapOr: (value: BN) => BN }, DeriveEraPoints[], DeriveEraPrefs[], DeriveEraRewards[]];
|
type ErasResult = [DeriveEraPoints[], DeriveEraPrefs[], DeriveEraRewards[]];
|
||||||
|
|
||||||
const ZERO = new BN(0);
|
function parseRewards (api: ApiInterfaceRx, stashId: AccountId, [erasPoints, erasPrefs, erasRewards]: ErasResult, exposures: DeriveStakerExposure[]): DeriveStakerReward[] {
|
||||||
const MIN_ONE = new BN(-1);
|
|
||||||
const COMM_DIV = new BN(1_000_000_000);
|
|
||||||
|
|
||||||
function parseRewards (api: ApiInterfaceRx, stashId: AccountId, [, erasPoints, erasPrefs, erasRewards]: ErasResult, exposures: DeriveStakerExposure[]): DeriveStakerReward[] {
|
|
||||||
return exposures.map(({ era, isEmpty, isValidator, nominating, validators: eraValidators }): DeriveStakerReward => {
|
return exposures.map(({ era, isEmpty, isValidator, nominating, validators: eraValidators }): DeriveStakerReward => {
|
||||||
const { eraPoints, validators: allValPoints } = erasPoints.find((p) => p.era.eq(era)) || { eraPoints: ZERO, validators: {} };
|
const { eraPoints, validators: allValPoints } = erasPoints.find((p) => p.era.eq(era)) || { eraPoints: BN_ZERO, validators: {} };
|
||||||
const { eraReward } = erasRewards.find((r) => r.era.eq(era)) || { eraReward: api.registry.createType('Balance') };
|
const { eraReward } = erasRewards.find((r) => r.era.eq(era)) || { eraReward: api.registry.createType('Balance') };
|
||||||
const { validators: allValPrefs } = erasPrefs.find((p) => p.era.eq(era)) || { validators: {} as DeriveEraValPrefs };
|
const { validators: allValPrefs } = erasPrefs.find((p) => p.era.eq(era)) || { validators: {} as DeriveEraValPrefs };
|
||||||
const validators: Record<string, DeriveStakerRewardValidator> = {};
|
const validators: Record<string, DeriveStakerRewardValidator> = {};
|
||||||
const stakerId = stashId.toString();
|
const stakerId = stashId.toString();
|
||||||
|
|
||||||
Object.entries(eraValidators).forEach(([validatorId, exposure]): void => {
|
Object.entries(eraValidators).forEach(([validatorId, exposure]): void => {
|
||||||
const valPoints = allValPoints[validatorId] || ZERO;
|
const valPoints = allValPoints[validatorId] || BN_ZERO;
|
||||||
const valComm = allValPrefs[validatorId]?.commission.unwrap() || ZERO;
|
const valComm = allValPrefs[validatorId]?.commission.unwrap() || BN_ZERO;
|
||||||
const expTotal = exposure.total.unwrap();
|
const expTotal = exposure.total.unwrap();
|
||||||
let avail = ZERO;
|
let avail = BN_ZERO;
|
||||||
let value: BN | undefined;
|
let value: BN | undefined;
|
||||||
|
|
||||||
if (!(expTotal.isZero() || valPoints.isZero() || eraPoints.isZero())) {
|
if (!(expTotal.isZero() || valPoints.isZero() || eraPoints.isZero())) {
|
||||||
avail = eraReward.mul(valPoints).div(eraPoints);
|
avail = eraReward.mul(valPoints).div(eraPoints);
|
||||||
|
|
||||||
const valCut = valComm.mul(avail).div(COMM_DIV);
|
const valCut = valComm.mul(avail).div(BN_BILLION);
|
||||||
let staked: BN;
|
let staked: BN;
|
||||||
|
|
||||||
if (validatorId === stakerId) {
|
if (validatorId === stakerId) {
|
||||||
@@ -50,10 +45,10 @@ function parseRewards (api: ApiInterfaceRx, stashId: AccountId, [, erasPoints, e
|
|||||||
|
|
||||||
staked = stakerExp
|
staked = stakerExp
|
||||||
? stakerExp.value.unwrap()
|
? stakerExp.value.unwrap()
|
||||||
: ZERO;
|
: BN_ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = avail.sub(valCut).imul(staked).div(expTotal).iadd(validatorId === stakerId ? valCut : ZERO);
|
value = avail.sub(valCut).imul(staked).div(expTotal).iadd(validatorId === stakerId ? valCut : BN_ZERO);
|
||||||
}
|
}
|
||||||
|
|
||||||
validators[validatorId] = {
|
validators[validatorId] = {
|
||||||
@@ -73,32 +68,25 @@ function parseRewards (api: ApiInterfaceRx, stashId: AccountId, [, erasPoints, e
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function uniqValidators (rewards: DeriveStakerReward[]): string[] {
|
function allUniqValidators (rewards: DeriveStakerReward[][]): [string[], string[][]] {
|
||||||
const uniq: string[] = [];
|
return rewards.reduce(([all, perStash]: [string[], string[][]], rewards) => {
|
||||||
|
const uniq: string[] = [];
|
||||||
|
|
||||||
rewards.forEach(({ validators }): void => {
|
perStash.push(uniq);
|
||||||
Object.keys(validators).forEach((validatorId): void => {
|
rewards.forEach(({ validators }) =>
|
||||||
if (!uniq.includes(validatorId)) {
|
Object.keys(validators).forEach((validatorId): void => {
|
||||||
uniq.push(validatorId);
|
if (!uniq.includes(validatorId)) {
|
||||||
}
|
uniq.push(validatorId);
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return uniq;
|
if (!all.includes(validatorId)) {
|
||||||
}
|
all.push(validatorId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
function isOldLedger (ledger?: StakingLedger | StakingLedgerTo240): ledger is StakingLedgerTo240 {
|
return [all, perStash];
|
||||||
return !!(ledger as StakingLedgerTo240)?.lastReward;
|
}, [[], []]);
|
||||||
}
|
|
||||||
|
|
||||||
function filterEra (era: EraIndex, stakingLedger: StakingLedger): boolean {
|
|
||||||
return isOldLedger(stakingLedger)
|
|
||||||
? era.gt(stakingLedger.lastReward.unwrapOr(MIN_ONE))
|
|
||||||
: !stakingLedger.claimedRewards.some((e) => e.eq(era));
|
|
||||||
}
|
|
||||||
|
|
||||||
function filterEras (eras: EraIndex[], stakingLedger: StakingLedger): EraIndex[] {
|
|
||||||
return eras.filter((era) => filterEra(era, stakingLedger));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeClaimed (validators: string[], queryValidators: DeriveStakingQuery[], reward: DeriveStakerReward): void {
|
function removeClaimed (validators: string[], queryValidators: DeriveStakingQuery[], reward: DeriveStakerReward): void {
|
||||||
@@ -121,43 +109,34 @@ function removeClaimed (validators: string[], queryValidators: DeriveStakingQuer
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterRewards (api: ApiInterfaceRx, eras: EraIndex[], { migrateEra, rewards, stakingLedger }: { migrateEra: BN, rewards: DeriveStakerReward[]; stakingLedger: StakingLedger }): Observable<DeriveStakerReward[]> {
|
function filterRewards (eras: EraIndex[], valInfo: [string, DeriveStakingQuery][], { rewards, stakingLedger }: { rewards: DeriveStakerReward[]; stakingLedger: StakingLedger }): DeriveStakerReward[] {
|
||||||
const validators = uniqValidators(rewards);
|
const filter = eras.filter((era) => !stakingLedger.claimedRewards.some((e) => e.eq(era)));
|
||||||
const filter = filterEras(eras, stakingLedger);
|
const validators = valInfo.map(([v]) => v);
|
||||||
|
const queryValidators = valInfo.map(([, q]) => q);
|
||||||
|
|
||||||
return api.derive.staking.queryMulti(validators, { withLedger: true }).pipe(
|
return rewards
|
||||||
map((queryValidators): DeriveStakerReward[] =>
|
.filter(({ isEmpty }) => !isEmpty)
|
||||||
rewards
|
.filter((reward): boolean => {
|
||||||
.filter(({ isEmpty }) => !isEmpty)
|
if (!filter.some((filter) => reward.era.eq(filter))) {
|
||||||
.filter((reward): boolean => {
|
return false;
|
||||||
if (!filter.some((filter) => reward.era.eq(filter))) {
|
}
|
||||||
return false;
|
|
||||||
} else if (reward.era.lt(migrateEra)) {
|
|
||||||
// we filter again here, the actual ledger may have changed, e.g. something has been claimed
|
|
||||||
return filterEra(reward.era, stakingLedger);
|
|
||||||
}
|
|
||||||
|
|
||||||
reward.isStakerPayout = true;
|
reward.isStakerPayout = true;
|
||||||
|
|
||||||
removeClaimed(validators, queryValidators, reward);
|
removeClaimed(validators, queryValidators, reward);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
.filter(({ validators }) => Object.keys(validators).length !== 0)
|
.filter(({ validators }) => Object.keys(validators).length !== 0)
|
||||||
.map((reward) => ({
|
.map((reward) => ({
|
||||||
...reward,
|
...reward,
|
||||||
nominators: reward.nominating.filter((n) => reward.validators[n.validatorId])
|
nominators: reward.nominating.filter((n) => reward.validators[n.validatorId])
|
||||||
}))
|
}));
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function _stakerRewardsEras (instanceId: string, api: ApiInterfaceRx): (eras: EraIndex[], withActive: boolean) => Observable<ErasResult> {
|
export function _stakerRewardsEras (instanceId: string, api: ApiInterfaceRx): (eras: EraIndex[], withActive: boolean) => Observable<ErasResult> {
|
||||||
return memo(instanceId, (eras: EraIndex[], withActive: boolean): Observable<ErasResult> =>
|
return memo(instanceId, (eras: EraIndex[], withActive: boolean): Observable<ErasResult> =>
|
||||||
combineLatest([
|
combineLatest([
|
||||||
isFunction(api.query.staking.migrateEra)
|
|
||||||
? api.query.staking.migrateEra<Option<EraIndex>>()
|
|
||||||
: of(api.registry.createType('Option<EraIndex>')),
|
|
||||||
api.derive.staking._erasPoints(eras, withActive),
|
api.derive.staking._erasPoints(eras, withActive),
|
||||||
api.derive.staking._erasPrefs(eras, withActive),
|
api.derive.staking._erasPrefs(eras, withActive),
|
||||||
api.derive.staking._erasRewards(eras, withActive)
|
api.derive.staking._erasRewards(eras, withActive)
|
||||||
@@ -165,23 +144,39 @@ export function _stakerRewardsEras (instanceId: string, api: ApiInterfaceRx): (e
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function _stakerRewards (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerReward[]> {
|
export function _stakerRewards (instanceId: string, api: ApiInterfaceRx): (accountIds: (Uint8Array | string)[], eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerReward[][]> {
|
||||||
return memo(instanceId, (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean): Observable<DeriveStakerReward[]> =>
|
return memo(instanceId, (accountIds: (Uint8Array | string)[], eras: EraIndex[], withActive: boolean): Observable<DeriveStakerReward[][]> =>
|
||||||
combineLatest([
|
combineLatest([
|
||||||
api.derive.staking.query(accountId, { withLedger: true }),
|
api.derive.staking.queryMulti(accountIds, { withLedger: true }),
|
||||||
api.derive.staking._stakerExposure(accountId, eras, withActive),
|
api.derive.staking._stakerExposures(accountIds, eras, withActive),
|
||||||
api.derive.staking._stakerRewardsEras(eras, withActive)
|
api.derive.staking._stakerRewardsEras(eras, withActive)
|
||||||
]).pipe(
|
]).pipe(
|
||||||
switchMap(([{ stakingLedger, stashId }, exposures, erasResult]): Observable<DeriveStakerReward[]> => {
|
switchMap(([queries, exposures, erasResult]): Observable<DeriveStakerReward[][]> => {
|
||||||
if (!stashId || !stakingLedger) {
|
const allRewards = queries.map(({ stakingLedger, stashId }, index): DeriveStakerReward[] =>
|
||||||
return of([]);
|
(!stashId || !stakingLedger)
|
||||||
|
? []
|
||||||
|
: parseRewards(api, stashId, erasResult, exposures[index])
|
||||||
|
);
|
||||||
|
|
||||||
|
if (withActive) {
|
||||||
|
return of(allRewards);
|
||||||
}
|
}
|
||||||
|
|
||||||
const rewards = parseRewards(api, stashId, erasResult, exposures);
|
const [allValidators, stashValidators] = allUniqValidators(allRewards);
|
||||||
|
|
||||||
return withActive
|
return api.derive.staking.queryMulti(allValidators, { withLedger: true }).pipe(
|
||||||
? of(rewards)
|
map((queriedVals): DeriveStakerReward[][] => {
|
||||||
: filterRewards(api, eras, { migrateEra: erasResult[0].unwrapOr(ZERO), rewards, stakingLedger });
|
return queries.map(({ stakingLedger }, index): DeriveStakerReward[] => {
|
||||||
|
const rewards = allRewards[index];
|
||||||
|
const ownValidators = stashValidators[index].map((validatorId): [string, DeriveStakingQuery] => [
|
||||||
|
validatorId,
|
||||||
|
queriedVals.find((q) => q.accountId.eq(validatorId)) as DeriveStakingQuery
|
||||||
|
]);
|
||||||
|
|
||||||
|
return filterRewards(eras, ownValidators, { rewards, stakingLedger });
|
||||||
|
});
|
||||||
|
})
|
||||||
|
);
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -190,7 +185,8 @@ export function _stakerRewards (instanceId: string, api: ApiInterfaceRx): (accou
|
|||||||
export function stakerRewards (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, withActive?: boolean) => Observable<DeriveStakerReward[]> {
|
export function stakerRewards (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, withActive?: boolean) => Observable<DeriveStakerReward[]> {
|
||||||
return memo(instanceId, (accountId: Uint8Array | string, withActive = false): Observable<DeriveStakerReward[]> =>
|
return memo(instanceId, (accountId: Uint8Array | string, withActive = false): Observable<DeriveStakerReward[]> =>
|
||||||
api.derive.staking.erasHistoric(withActive).pipe(
|
api.derive.staking.erasHistoric(withActive).pipe(
|
||||||
switchMap((eras) => api.derive.staking._stakerRewards(accountId, eras, withActive))
|
switchMap((eras) => api.derive.staking._stakerRewards([accountId], eras, withActive)),
|
||||||
|
map(([first]) => first)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -198,7 +194,7 @@ export function stakerRewards (instanceId: string, api: ApiInterfaceRx): (accoun
|
|||||||
export function stakerRewardsMultiEras (instanceId: string, api: ApiInterfaceRx): (accountIds: (Uint8Array | string)[], eras: EraIndex[]) => Observable<DeriveStakerReward[][]> {
|
export function stakerRewardsMultiEras (instanceId: string, api: ApiInterfaceRx): (accountIds: (Uint8Array | string)[], eras: EraIndex[]) => Observable<DeriveStakerReward[][]> {
|
||||||
return memo(instanceId, (accountIds: (Uint8Array | string)[], eras: EraIndex[]): Observable<DeriveStakerReward[][]> =>
|
return memo(instanceId, (accountIds: (Uint8Array | string)[], eras: EraIndex[]): Observable<DeriveStakerReward[][]> =>
|
||||||
accountIds.length && eras.length
|
accountIds.length && eras.length
|
||||||
? combineLatest(accountIds.map((acc) => api.derive.staking._stakerRewards(acc, eras, false)))
|
? api.derive.staking._stakerRewards(accountIds, eras, false)
|
||||||
: of([])
|
: of([])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { memo } from '../util';
|
|||||||
export function stashes (instanceId: string, api: ApiInterfaceRx): () => Observable<AccountId[]> {
|
export function stashes (instanceId: string, api: ApiInterfaceRx): () => Observable<AccountId[]> {
|
||||||
return memo(instanceId, (): Observable<AccountId[]> =>
|
return memo(instanceId, (): Observable<AccountId[]> =>
|
||||||
api.query.staking.validators.keys().pipe(
|
api.query.staking.validators.keys().pipe(
|
||||||
map((keys) => keys.map((key) => key.args[0] as AccountId).filter((a) => a))
|
map((keys) => keys.map(({ args: [validatorId] }) => validatorId).filter((a) => a))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export function nextElected (instanceId: string, api: ApiInterfaceRx): () => Obs
|
|||||||
// only populate for next era in the last session, so track both here - entries are not
|
// only populate for next era in the last session, so track both here - entries are not
|
||||||
// subscriptions, so we need a trigger - currentIndex acts as that trigger to refresh
|
// subscriptions, so we need a trigger - currentIndex acts as that trigger to refresh
|
||||||
switchMap(({ currentEra }) => api.query.staking.erasStakers.keys(currentEra)),
|
switchMap(({ currentEra }) => api.query.staking.erasStakers.keys(currentEra)),
|
||||||
map((keys) => keys.map((key) => key.args[1] as AccountId))
|
map((keys) => keys.map(({ args: [, accountId] }) => accountId))
|
||||||
)
|
)
|
||||||
: api.query.staking.currentElected<AccountId[]>()
|
: api.query.staking.currentElected<AccountId[]>()
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -4,19 +4,17 @@
|
|||||||
import type { AccountId, Digest } from '@polkadot/types/interfaces';
|
import type { AccountId, Digest } from '@polkadot/types/interfaces';
|
||||||
|
|
||||||
export function extractAuthor (digest: Digest, sessionValidators: AccountId[] = []): AccountId | undefined {
|
export function extractAuthor (digest: Digest, sessionValidators: AccountId[] = []): AccountId | undefined {
|
||||||
const [pitem] = digest.logs.filter(({ type }) => type === 'PreRuntime');
|
const [citem] = digest.logs.filter(({ type }) => type === 'Consensus');
|
||||||
|
|
||||||
// extract from the substrate 2.0 PreRuntime digest
|
if (citem) {
|
||||||
if (pitem) {
|
const [engine, data] = citem.asConsensus;
|
||||||
const [engine, data] = pitem.asPreRuntime;
|
|
||||||
|
|
||||||
return engine.extractAuthor(data, sessionValidators);
|
return engine.extractAuthor(data, sessionValidators);
|
||||||
} else {
|
} else {
|
||||||
const [citem] = digest.logs.filter(({ type }) => type === 'Consensus');
|
const [pitem] = digest.logs.filter(({ type }) => type === 'PreRuntime');
|
||||||
|
|
||||||
// extract author from the consensus (substrate 1.0, digest)
|
if (pitem) {
|
||||||
if (citem) {
|
const [engine, data] = pitem.asPreRuntime;
|
||||||
const [engine, data] = citem.asConsensus;
|
|
||||||
|
|
||||||
return engine.extractAuthor(data, sessionValidators);
|
return engine.extractAuthor(data, sessionValidators);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,7 @@ export * from './parachains/types';
|
|||||||
export * from './session/types';
|
export * from './session/types';
|
||||||
export * from './staking/types';
|
export * from './staking/types';
|
||||||
|
|
||||||
export interface DeriveBalancesAccount {
|
export interface DeriveBalancesAccountData {
|
||||||
accountId: AccountId;
|
|
||||||
accountNonce: Index;
|
|
||||||
freeBalance: Balance;
|
freeBalance: Balance;
|
||||||
frozenFee: Balance;
|
frozenFee: Balance;
|
||||||
frozenMisc: Balance;
|
frozenMisc: Balance;
|
||||||
@@ -23,16 +21,25 @@ export interface DeriveBalancesAccount {
|
|||||||
votingBalance: Balance;
|
votingBalance: Balance;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DeriveBalancesAll extends DeriveBalancesAccount {
|
export interface DeriveBalancesAccount extends DeriveBalancesAccountData {
|
||||||
isVesting: boolean;
|
accountId: AccountId;
|
||||||
|
accountNonce: Index;
|
||||||
|
additional: DeriveBalancesAccountData[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DeriveBalancesAllAccountData extends DeriveBalancesAccountData {
|
||||||
|
availableBalance: Balance;
|
||||||
lockedBalance: Balance;
|
lockedBalance: Balance;
|
||||||
lockedBreakdown: (BalanceLock | BalanceLockTo212)[];
|
lockedBreakdown: (BalanceLock | BalanceLockTo212)[];
|
||||||
availableBalance: Balance;
|
vestingLocked: Balance;
|
||||||
votingBalance: Balance;
|
}
|
||||||
|
|
||||||
|
export interface DeriveBalancesAll extends DeriveBalancesAccount, DeriveBalancesAllAccountData {
|
||||||
|
additional: DeriveBalancesAllAccountData[];
|
||||||
|
isVesting: boolean;
|
||||||
vestedBalance: Balance;
|
vestedBalance: Balance;
|
||||||
vestedClaimable: Balance;
|
vestedClaimable: Balance;
|
||||||
vestingEndBlock: BlockNumber;
|
vestingEndBlock: BlockNumber;
|
||||||
vestingLocked: Balance;
|
|
||||||
vestingPerBlock: Balance;
|
vestingPerBlock: Balance;
|
||||||
vestingTotal: Balance;
|
vestingTotal: Balance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import type { DeriveCache } from './types';
|
|||||||
|
|
||||||
const mapCache = new Map<string, any>();
|
const mapCache = new Map<string, any>();
|
||||||
|
|
||||||
const deriveMapCache: DeriveCache = {
|
export const deriveMapCache: DeriveCache = {
|
||||||
del: (key: string): void => {
|
del: (key: string): void => {
|
||||||
mapCache.delete(key);
|
mapCache.delete(key);
|
||||||
},
|
},
|
||||||
@@ -24,11 +24,9 @@ const deriveMapCache: DeriveCache = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const deriveNoopCache: DeriveCache = {
|
export const deriveNoopCache: DeriveCache = {
|
||||||
del: (): void => undefined,
|
del: (): void => undefined,
|
||||||
forEach: () => undefined,
|
forEach: () => undefined,
|
||||||
get: (): undefined => undefined,
|
get: (): undefined => undefined,
|
||||||
set: (_: string, value: unknown): unknown => value
|
set: (_: string, value: unknown): unknown => value
|
||||||
};
|
};
|
||||||
|
|
||||||
export { deriveMapCache, deriveNoopCache };
|
|
||||||
|
|||||||
+12
-13
@@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@polkadot/api",
|
"name": "@polkadot/api",
|
||||||
"version": "3.4.1",
|
"version": "3.11.1",
|
||||||
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
|
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "index.mjs",
|
|
||||||
"sideEffects": [
|
"sideEffects": [
|
||||||
"./detectPackage.js",
|
"./detectPackage.js",
|
||||||
"./detectPackage.mjs"
|
"./detectPackage.mjs"
|
||||||
@@ -16,17 +15,17 @@
|
|||||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
|
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.12.5",
|
"@babel/runtime": "^7.13.8",
|
||||||
"@polkadot/api-derive": "3.4.1",
|
"@polkadot/api-derive": "3.11.1",
|
||||||
"@polkadot/keyring": "^5.2.3",
|
"@polkadot/keyring": "^5.9.2",
|
||||||
"@polkadot/metadata": "3.4.1",
|
"@polkadot/metadata": "3.11.1",
|
||||||
"@polkadot/rpc-core": "3.4.1",
|
"@polkadot/rpc-core": "3.11.1",
|
||||||
"@polkadot/rpc-provider": "3.4.1",
|
"@polkadot/rpc-provider": "3.11.1",
|
||||||
"@polkadot/types": "3.4.1",
|
"@polkadot/types": "3.11.1",
|
||||||
"@polkadot/types-known": "3.4.1",
|
"@polkadot/types-known": "3.11.1",
|
||||||
"@polkadot/util": "^5.2.3",
|
"@polkadot/util": "^5.9.2",
|
||||||
"@polkadot/util-crypto": "^5.2.3",
|
"@polkadot/util-crypto": "^5.9.2",
|
||||||
"@polkadot/x-rxjs": "3.4.1",
|
"@polkadot/x-rxjs": "^5.9.2",
|
||||||
"bn.js": "^4.11.9",
|
"bn.js": "^4.11.9",
|
||||||
"eventemitter3": "^4.0.7"
|
"eventemitter3": "^4.0.7"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,12 @@
|
|||||||
|
|
||||||
import type { Vec, u16, u32, u64, u8 } from '@polkadot/types';
|
import type { Vec, u16, u32, u64, u8 } from '@polkadot/types';
|
||||||
import type { Codec } from '@polkadot/types/types';
|
import type { Codec } from '@polkadot/types/types';
|
||||||
import type { Balance, BalanceOf, BlockNumber, LockIdentifier, ModuleId, Moment, Perbill, Percent, Permill, RuntimeDbWeight } from '@polkadot/types/interfaces/runtime';
|
import type { Balance, BalanceOf, BlockNumber, LockIdentifier, ModuleId, Moment, Perbill, Percent, Permill, RuntimeDbWeight, Weight } from '@polkadot/types/interfaces/runtime';
|
||||||
import type { SessionIndex } from '@polkadot/types/interfaces/session';
|
import type { SessionIndex } from '@polkadot/types/interfaces/session';
|
||||||
import type { EraIndex } from '@polkadot/types/interfaces/staking';
|
import type { EraIndex } from '@polkadot/types/interfaces/staking';
|
||||||
|
import type { RuntimeVersion } from '@polkadot/types/interfaces/state';
|
||||||
import type { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
|
import type { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
|
||||||
import type { BlockWeights } from '@polkadot/types/interfaces/system';
|
import type { BlockLength, BlockWeights } from '@polkadot/types/interfaces/system';
|
||||||
import type { ApiTypes } from '@polkadot/api/types';
|
import type { ApiTypes } from '@polkadot/api/types';
|
||||||
|
|
||||||
declare module '@polkadot/api/types/consts' {
|
declare module '@polkadot/api/types/consts' {
|
||||||
@@ -17,6 +18,9 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* The number of **slots** that an epoch takes. We couple sessions to
|
* 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.
|
* 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.
|
||||||
**/
|
**/
|
||||||
epochDuration: u64 & AugmentedConst<ApiType>;
|
epochDuration: u64 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
@@ -49,6 +53,10 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
* The delay period for which a bounty beneficiary need to wait before claim the payout.
|
* The delay period for which a bounty beneficiary need to wait before claim the payout.
|
||||||
**/
|
**/
|
||||||
bountyDepositPayoutDelay: BlockNumber & AugmentedConst<ApiType>;
|
bountyDepositPayoutDelay: BlockNumber & AugmentedConst<ApiType>;
|
||||||
|
/**
|
||||||
|
* Bounty duration in blocks.
|
||||||
|
**/
|
||||||
|
bountyUpdatePeriod: BlockNumber & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Minimum value for a bounty.
|
* Minimum value for a bounty.
|
||||||
**/
|
**/
|
||||||
@@ -65,28 +73,61 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
contracts: {
|
contracts: {
|
||||||
[key: string]: Codec;
|
[key: string]: Codec;
|
||||||
/**
|
/**
|
||||||
* The maximum nesting level of a call/instantiate stack. A reasonable default
|
* The maximum number of tries that can be queued for deletion.
|
||||||
* value is 100.
|
|
||||||
**/
|
**/
|
||||||
maxDepth: u32 & AugmentedConst<ApiType>;
|
deletionQueueDepth: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The maximum size of a storage value in bytes. A reasonable default is 16 KiB.
|
* The maximum amount of weight that can be consumed per block for lazy trie removal.
|
||||||
**/
|
**/
|
||||||
maxValueSize: u32 & AugmentedConst<ApiType>;
|
deletionWeightLimit: Weight & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Price of a byte of storage per one block interval. Should be greater than 0.
|
* The balance every contract needs to deposit to stay alive indefinitely.
|
||||||
|
*
|
||||||
|
* This is different from the [`Self::TombstoneDeposit`] because this only needs to be
|
||||||
|
* deposited while the contract is alive. Costs for additional storage are added to
|
||||||
|
* this base cost.
|
||||||
|
*
|
||||||
|
* This is a simple way to ensure that contracts with empty storage eventually get deleted by
|
||||||
|
* making them pay rent. This creates an incentive to remove them early in order to save rent.
|
||||||
**/
|
**/
|
||||||
rentByteFee: BalanceOf & AugmentedConst<ApiType>;
|
depositPerContract: BalanceOf & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The amount of funds a contract should deposit in order to offset
|
* The balance a contract needs to deposit per storage byte to stay alive indefinitely.
|
||||||
* the cost of one byte.
|
|
||||||
*
|
*
|
||||||
* Let's suppose the deposit is 1,000 BU (balance units)/byte and the rent is 1 BU/byte/day,
|
* Let's suppose the deposit is 1,000 BU (balance units)/byte and the rent is 1 BU/byte/day,
|
||||||
* then a contract with 1,000,000 BU that uses 1,000 bytes of storage would pay no rent.
|
* then a contract with 1,000,000 BU that uses 1,000 bytes of storage would pay no rent.
|
||||||
* But if the balance reduced to 500,000 BU and the storage stayed the same at 1,000,
|
* But if the balance reduced to 500,000 BU and the storage stayed the same at 1,000,
|
||||||
* then it would pay 500 BU/day.
|
* then it would pay 500 BU/day.
|
||||||
**/
|
**/
|
||||||
rentDepositOffset: BalanceOf & AugmentedConst<ApiType>;
|
depositPerStorageByte: BalanceOf & AugmentedConst<ApiType>;
|
||||||
|
/**
|
||||||
|
* The balance a contract needs to deposit per storage item to stay alive indefinitely.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* When a contract hasn't enough balance deposited to stay alive indefinitely it needs
|
||||||
|
* to pay per block for the storage it consumes that is not covered by the deposit.
|
||||||
|
* This determines how high this rent payment is per block as a fraction of the deposit.
|
||||||
|
**/
|
||||||
|
rentFraction: Perbill & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Number of block delay an extrinsic claim surcharge has.
|
* Number of block delay an extrinsic claim surcharge has.
|
||||||
*
|
*
|
||||||
@@ -94,15 +135,6 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
* for current_block - delay
|
* for current_block - delay
|
||||||
**/
|
**/
|
||||||
signedClaimHandicap: BlockNumber & AugmentedConst<ApiType>;
|
signedClaimHandicap: BlockNumber & AugmentedConst<ApiType>;
|
||||||
/**
|
|
||||||
* A size offset for an contract. A just created account with untouched storage will have that
|
|
||||||
* much of storage from the perspective of the state rent.
|
|
||||||
*
|
|
||||||
* This is a simple way to ensure that contracts with empty storage eventually get deleted
|
|
||||||
* by making them pay rent. This creates an incentive to remove them early in order to save
|
|
||||||
* rent.
|
|
||||||
**/
|
|
||||||
storageSizeOffset: u32 & AugmentedConst<ApiType>;
|
|
||||||
/**
|
/**
|
||||||
* Reward that is received by the party whose touch has led
|
* Reward that is received by the party whose touch has led
|
||||||
* to removal of a contract.
|
* to removal of a contract.
|
||||||
@@ -152,6 +184,22 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
**/
|
**/
|
||||||
votingPeriod: BlockNumber & AugmentedConst<ApiType>;
|
votingPeriod: BlockNumber & AugmentedConst<ApiType>;
|
||||||
};
|
};
|
||||||
|
electionProviderMultiPhase: {
|
||||||
|
[key: string]: Codec;
|
||||||
|
/**
|
||||||
|
* Duration of the signed phase.
|
||||||
|
**/
|
||||||
|
signedPhase: BlockNumber & AugmentedConst<ApiType>;
|
||||||
|
/**
|
||||||
|
* The minimum amount of improvement to the solution score that defines a solution as
|
||||||
|
* "better" (in any phase).
|
||||||
|
**/
|
||||||
|
solutionImprovementThreshold: Perbill & AugmentedConst<ApiType>;
|
||||||
|
/**
|
||||||
|
* Duration of the unsigned phase.
|
||||||
|
**/
|
||||||
|
unsignedPhase: BlockNumber & AugmentedConst<ApiType>;
|
||||||
|
};
|
||||||
elections: {
|
elections: {
|
||||||
[key: string]: Codec;
|
[key: string]: Codec;
|
||||||
candidacyBond: BalanceOf & AugmentedConst<ApiType>;
|
candidacyBond: BalanceOf & AugmentedConst<ApiType>;
|
||||||
@@ -159,7 +207,8 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
desiredRunnersUp: u32 & AugmentedConst<ApiType>;
|
desiredRunnersUp: u32 & AugmentedConst<ApiType>;
|
||||||
moduleId: LockIdentifier & AugmentedConst<ApiType>;
|
moduleId: LockIdentifier & AugmentedConst<ApiType>;
|
||||||
termDuration: BlockNumber & AugmentedConst<ApiType>;
|
termDuration: BlockNumber & AugmentedConst<ApiType>;
|
||||||
votingBond: BalanceOf & AugmentedConst<ApiType>;
|
votingBondBase: BalanceOf & AugmentedConst<ApiType>;
|
||||||
|
votingBondFactor: BalanceOf & AugmentedConst<ApiType>;
|
||||||
};
|
};
|
||||||
identity: {
|
identity: {
|
||||||
[key: string]: Codec;
|
[key: string]: Codec;
|
||||||
@@ -199,6 +248,11 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
**/
|
**/
|
||||||
deposit: BalanceOf & AugmentedConst<ApiType>;
|
deposit: BalanceOf & AugmentedConst<ApiType>;
|
||||||
};
|
};
|
||||||
|
lottery: {
|
||||||
|
[key: string]: Codec;
|
||||||
|
maxCalls: u32 & AugmentedConst<ApiType>;
|
||||||
|
moduleId: ModuleId & AugmentedConst<ApiType>;
|
||||||
|
};
|
||||||
multisig: {
|
multisig: {
|
||||||
[key: string]: Codec;
|
[key: string]: Codec;
|
||||||
/**
|
/**
|
||||||
@@ -343,11 +397,15 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
system: {
|
system: {
|
||||||
[key: string]: Codec;
|
[key: string]: Codec;
|
||||||
/**
|
/**
|
||||||
* The maximum number of blocks to allow in mortal eras.
|
* Maximum number of block number to block hash mappings to keep (oldest pruned first).
|
||||||
**/
|
**/
|
||||||
blockHashCount: BlockNumber & AugmentedConst<ApiType>;
|
blockHashCount: BlockNumber & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The weight configuration (limits & base values) for each class of extrinsics and block.
|
* The maximum length of a block (in bytes).
|
||||||
|
**/
|
||||||
|
blockLength: BlockLength & AugmentedConst<ApiType>;
|
||||||
|
/**
|
||||||
|
* Block & extrinsics weights: base values and limits.
|
||||||
**/
|
**/
|
||||||
blockWeights: BlockWeights & AugmentedConst<ApiType>;
|
blockWeights: BlockWeights & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
@@ -362,6 +420,10 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
* an identifier of the chain.
|
* an identifier of the chain.
|
||||||
**/
|
**/
|
||||||
ss58Prefix: u8 & AugmentedConst<ApiType>;
|
ss58Prefix: u8 & AugmentedConst<ApiType>;
|
||||||
|
/**
|
||||||
|
* Get the chain's current version.
|
||||||
|
**/
|
||||||
|
version: RuntimeVersion & AugmentedConst<ApiType>;
|
||||||
};
|
};
|
||||||
timestamp: {
|
timestamp: {
|
||||||
[key: string]: Codec;
|
[key: string]: Codec;
|
||||||
|
|||||||
@@ -11,6 +11,14 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
* Transfer amount should be non-zero.
|
* Transfer amount should be non-zero.
|
||||||
**/
|
**/
|
||||||
AmountZero: AugmentedError<ApiType>;
|
AmountZero: AugmentedError<ApiType>;
|
||||||
|
/**
|
||||||
|
* Invalid metadata given.
|
||||||
|
**/
|
||||||
|
BadMetadata: AugmentedError<ApiType>;
|
||||||
|
/**
|
||||||
|
* Some internal state is broken.
|
||||||
|
**/
|
||||||
|
BadState: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Invalid witness data given.
|
* Invalid witness data given.
|
||||||
**/
|
**/
|
||||||
@@ -176,9 +184,17 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
**/
|
**/
|
||||||
CodeNotFound: AugmentedError<ApiType>;
|
CodeNotFound: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The code supplied to `put_code` exceeds the limit specified in the current schedule.
|
* The code supplied to `instantiate_with_code` exceeds the limit specified in the
|
||||||
|
* current schedule.
|
||||||
**/
|
**/
|
||||||
CodeTooLarge: AugmentedError<ApiType>;
|
CodeTooLarge: AugmentedError<ApiType>;
|
||||||
|
/**
|
||||||
|
* A contract could not be evicted because it has enough balance to pay rent.
|
||||||
|
*
|
||||||
|
* This can be returned from [`Pallet::claim_surcharge`] because the target
|
||||||
|
* contract has enough balance to pay for its rent.
|
||||||
|
**/
|
||||||
|
ContractNotEvictable: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Contract trapped during execution.
|
* Contract trapped during execution.
|
||||||
**/
|
**/
|
||||||
@@ -187,6 +203,18 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
* Input passed to a contract API function failed to decode as expected type.
|
* Input passed to a contract API function failed to decode as expected type.
|
||||||
**/
|
**/
|
||||||
DecodingFailed: AugmentedError<ApiType>;
|
DecodingFailed: AugmentedError<ApiType>;
|
||||||
|
/**
|
||||||
|
* Removal of a contract failed because the deletion queue is full.
|
||||||
|
*
|
||||||
|
* This can happen when either calling [`Pallet::claim_surcharge`] or `seal_terminate`.
|
||||||
|
* The queue is filled by deleting contracts and emptied by a fixed amount each block.
|
||||||
|
* Trying again during another block is the only way to resolve this issue.
|
||||||
|
**/
|
||||||
|
DeletionQueueFull: AugmentedError<ApiType>;
|
||||||
|
/**
|
||||||
|
* A contract with the same AccountId already exists.
|
||||||
|
**/
|
||||||
|
DuplicateContract: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The topics passed to `seal_deposit_events` contains at least one duplicate.
|
* The topics passed to `seal_deposit_events` contains at least one duplicate.
|
||||||
**/
|
**/
|
||||||
@@ -229,6 +257,12 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
* its contructor. No contracts are allowed to exist below that threshold.
|
* its contructor. No contracts are allowed to exist below that threshold.
|
||||||
**/
|
**/
|
||||||
NewContractNotFunded: AugmentedError<ApiType>;
|
NewContractNotFunded: AugmentedError<ApiType>;
|
||||||
|
/**
|
||||||
|
* The chain does not provide a chain extension. Calling the chain extension results
|
||||||
|
* in this error. Note that this usually shouldn't happen as deploying such contracts
|
||||||
|
* is rejected.
|
||||||
|
**/
|
||||||
|
NoChainExtension: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The contract that was called is either no contract at all (a plain account)
|
* The contract that was called is either no contract at all (a plain account)
|
||||||
* or is a tombstone.
|
* or is a tombstone.
|
||||||
@@ -256,6 +290,13 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
* of a tombstone.
|
* of a tombstone.
|
||||||
**/
|
**/
|
||||||
ReentranceDenied: AugmentedError<ApiType>;
|
ReentranceDenied: AugmentedError<ApiType>;
|
||||||
|
/**
|
||||||
|
* A storage modification exhausted the 32bit type that holds the storage size.
|
||||||
|
*
|
||||||
|
* This can either happen when the accumulated storage in bytes is too large or
|
||||||
|
* when number of storage items is too large.
|
||||||
|
**/
|
||||||
|
StorageExhausted: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The amount of topics passed to `seal_deposit_events` exceeds the limit.
|
* The amount of topics passed to `seal_deposit_events` exceeds the limit.
|
||||||
**/
|
**/
|
||||||
@@ -458,6 +499,21 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
**/
|
**/
|
||||||
WrongUpperBound: AugmentedError<ApiType>;
|
WrongUpperBound: AugmentedError<ApiType>;
|
||||||
};
|
};
|
||||||
|
electionProviderMultiPhase: {
|
||||||
|
[key: string]: AugmentedError<ApiType>;
|
||||||
|
/**
|
||||||
|
* Submission was too early.
|
||||||
|
**/
|
||||||
|
PreDispatchEarlySubmission: AugmentedError<ApiType>;
|
||||||
|
/**
|
||||||
|
* Submission was too weak, score-wise.
|
||||||
|
**/
|
||||||
|
PreDispatchWeakSubmission: AugmentedError<ApiType>;
|
||||||
|
/**
|
||||||
|
* Wrong number of winners presented.
|
||||||
|
**/
|
||||||
|
PreDispatchWrongWinnerCount: AugmentedError<ApiType>;
|
||||||
|
};
|
||||||
elections: {
|
elections: {
|
||||||
[key: string]: AugmentedError<ApiType>;
|
[key: string]: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
@@ -468,10 +524,6 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
* Candidate does not have enough funds.
|
* Candidate does not have enough funds.
|
||||||
**/
|
**/
|
||||||
InsufficientCandidateFunds: AugmentedError<ApiType>;
|
InsufficientCandidateFunds: AugmentedError<ApiType>;
|
||||||
/**
|
|
||||||
* The provided count of number of candidates is incorrect.
|
|
||||||
**/
|
|
||||||
InvalidCandidateCount: AugmentedError<ApiType>;
|
|
||||||
/**
|
/**
|
||||||
* The renouncing origin presented a wrong `Renouncing` parameter.
|
* The renouncing origin presented a wrong `Renouncing` parameter.
|
||||||
**/
|
**/
|
||||||
@@ -484,6 +536,10 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
* The provided count of number of votes is incorrect.
|
* The provided count of number of votes is incorrect.
|
||||||
**/
|
**/
|
||||||
InvalidVoteCount: AugmentedError<ApiType>;
|
InvalidVoteCount: AugmentedError<ApiType>;
|
||||||
|
/**
|
||||||
|
* The provided count of number of candidates is incorrect.
|
||||||
|
**/
|
||||||
|
InvalidWitnessData: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Cannot vote with stake less than minimum balance.
|
* Cannot vote with stake less than minimum balance.
|
||||||
**/
|
**/
|
||||||
@@ -515,7 +571,7 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
/**
|
/**
|
||||||
* Runner cannot re-submit candidacy.
|
* Runner cannot re-submit candidacy.
|
||||||
**/
|
**/
|
||||||
RunnerSubmit: AugmentedError<ApiType>;
|
RunnerUpSubmit: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Cannot vote more than candidates.
|
* Cannot vote more than candidates.
|
||||||
**/
|
**/
|
||||||
@@ -650,6 +706,10 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
* The data to be stored is already stored.
|
* The data to be stored is already stored.
|
||||||
**/
|
**/
|
||||||
AlreadyStored: AugmentedError<ApiType>;
|
AlreadyStored: AugmentedError<ApiType>;
|
||||||
|
/**
|
||||||
|
* The maximum weight information provided was too low.
|
||||||
|
**/
|
||||||
|
MaxWeightTooLow: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Threshold must be 2 or greater.
|
* Threshold must be 2 or greater.
|
||||||
**/
|
**/
|
||||||
@@ -690,10 +750,6 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
* A timepoint was given, yet no multisig operation is underway.
|
* A timepoint was given, yet no multisig operation is underway.
|
||||||
**/
|
**/
|
||||||
UnexpectedTimepoint: AugmentedError<ApiType>;
|
UnexpectedTimepoint: AugmentedError<ApiType>;
|
||||||
/**
|
|
||||||
* The maximum weight information provided was too low.
|
|
||||||
**/
|
|
||||||
WeightTooLow: AugmentedError<ApiType>;
|
|
||||||
/**
|
/**
|
||||||
* A different timepoint was given to the multisig operation that is underway.
|
* A different timepoint was given to the multisig operation that is underway.
|
||||||
**/
|
**/
|
||||||
@@ -752,6 +808,10 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
* This user has already vouched for this recovery
|
* This user has already vouched for this recovery
|
||||||
**/
|
**/
|
||||||
AlreadyVouched: AugmentedError<ApiType>;
|
AlreadyVouched: AugmentedError<ApiType>;
|
||||||
|
/**
|
||||||
|
* Some internal state is broken.
|
||||||
|
**/
|
||||||
|
BadState: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The friend must wait until the delay period to vouch for this recovery
|
* The friend must wait until the delay period to vouch for this recovery
|
||||||
**/
|
**/
|
||||||
@@ -830,6 +890,10 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
* Invalid ownership proof.
|
* Invalid ownership proof.
|
||||||
**/
|
**/
|
||||||
InvalidProof: AugmentedError<ApiType>;
|
InvalidProof: AugmentedError<ApiType>;
|
||||||
|
/**
|
||||||
|
* Key setting account is not live, so it's impossible to associate keys.
|
||||||
|
**/
|
||||||
|
NoAccount: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
* No associated validator ID for account.
|
* No associated validator ID for account.
|
||||||
**/
|
**/
|
||||||
@@ -928,6 +992,14 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
* Controller is already paired.
|
* Controller is already paired.
|
||||||
**/
|
**/
|
||||||
AlreadyPaired: AugmentedError<ApiType>;
|
AlreadyPaired: AugmentedError<ApiType>;
|
||||||
|
/**
|
||||||
|
* Internal state has become somehow corrupted and the operation cannot continue.
|
||||||
|
**/
|
||||||
|
BadState: AugmentedError<ApiType>;
|
||||||
|
/**
|
||||||
|
* 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.
|
* The call is not allowed at the given time due to restrictions of election period.
|
||||||
**/
|
**/
|
||||||
@@ -1043,6 +1115,10 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
* The snapshot data of the current window is missing.
|
* The snapshot data of the current window is missing.
|
||||||
**/
|
**/
|
||||||
SnapshotUnavailable: AugmentedError<ApiType>;
|
SnapshotUnavailable: AugmentedError<ApiType>;
|
||||||
|
/**
|
||||||
|
* Too many nomination targets supplied.
|
||||||
|
**/
|
||||||
|
TooManyTargets: AugmentedError<ApiType>;
|
||||||
};
|
};
|
||||||
sudo: {
|
sudo: {
|
||||||
[key: string]: AugmentedError<ApiType>;
|
[key: string]: AugmentedError<ApiType>;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
|
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
|
||||||
import type { Bytes, Option, Vec, bool, u16, u32 } from '@polkadot/types';
|
import type { Bytes, Option, Vec, bool, u16, u32, u8 } from '@polkadot/types';
|
||||||
import type { ITuple } from '@polkadot/types/types';
|
import type { ITuple } from '@polkadot/types/types';
|
||||||
import type { TAssetBalance } from '@polkadot/types/interfaces/assets';
|
import type { TAssetBalance } from '@polkadot/types/interfaces/assets';
|
||||||
import type { BalanceStatus } from '@polkadot/types/interfaces/balances';
|
import type { BalanceStatus } from '@polkadot/types/interfaces/balances';
|
||||||
@@ -11,6 +11,7 @@ import type { PropIndex, ReferendumIndex } from '@polkadot/types/interfaces/demo
|
|||||||
import type { VoteThreshold } from '@polkadot/types/interfaces/elections';
|
import type { VoteThreshold } from '@polkadot/types/interfaces/elections';
|
||||||
import type { AuthorityList } from '@polkadot/types/interfaces/grandpa';
|
import type { AuthorityList } from '@polkadot/types/interfaces/grandpa';
|
||||||
import type { RegistrarIndex } from '@polkadot/types/interfaces/identity';
|
import type { RegistrarIndex } from '@polkadot/types/interfaces/identity';
|
||||||
|
import type { CallIndex } from '@polkadot/types/interfaces/lottery';
|
||||||
import type { Kind, OpaqueTimeSlot } from '@polkadot/types/interfaces/offences';
|
import type { Kind, OpaqueTimeSlot } from '@polkadot/types/interfaces/offences';
|
||||||
import type { ProxyType } from '@polkadot/types/interfaces/proxy';
|
import type { ProxyType } from '@polkadot/types/interfaces/proxy';
|
||||||
import type { AccountId, AccountIndex, AssetId, Balance, BlockNumber, CallHash, Hash, PhantomData } from '@polkadot/types/interfaces/runtime';
|
import type { AccountId, AccountIndex, AssetId, Balance, BlockNumber, CallHash, Hash, PhantomData } from '@polkadot/types/interfaces/runtime';
|
||||||
@@ -26,6 +27,14 @@ declare module '@polkadot/api/types/events' {
|
|||||||
export interface AugmentedEvents<ApiType> {
|
export interface AugmentedEvents<ApiType> {
|
||||||
assets: {
|
assets: {
|
||||||
[key: string]: AugmentedEvent<ApiType>;
|
[key: string]: AugmentedEvent<ApiType>;
|
||||||
|
/**
|
||||||
|
* Some asset `asset_id` was frozen. \[asset_id\]
|
||||||
|
**/
|
||||||
|
AssetFrozen: AugmentedEvent<ApiType, [AssetId]>;
|
||||||
|
/**
|
||||||
|
* Some asset `asset_id` was thawed. \[asset_id\]
|
||||||
|
**/
|
||||||
|
AssetThawed: AugmentedEvent<ApiType, [AssetId]>;
|
||||||
/**
|
/**
|
||||||
* Some assets were destroyed. \[asset_id, owner, balance\]
|
* Some assets were destroyed. \[asset_id, owner, balance\]
|
||||||
**/
|
**/
|
||||||
@@ -58,6 +67,10 @@ declare module '@polkadot/api/types/events' {
|
|||||||
* The maximum amount of zombies allowed has changed. \[asset_id, max_zombies\]
|
* The maximum amount of zombies allowed has changed. \[asset_id, max_zombies\]
|
||||||
**/
|
**/
|
||||||
MaxZombiesChanged: AugmentedEvent<ApiType, [AssetId, u32]>;
|
MaxZombiesChanged: AugmentedEvent<ApiType, [AssetId, u32]>;
|
||||||
|
/**
|
||||||
|
* New metadata has been set for an asset. \[asset_id, name, symbol, decimals\]
|
||||||
|
**/
|
||||||
|
MetadataSet: AugmentedEvent<ApiType, [AssetId, Bytes, Bytes, u8]>;
|
||||||
/**
|
/**
|
||||||
* The owner changed \[asset_id, owner\]
|
* The owner changed \[asset_id, owner\]
|
||||||
**/
|
**/
|
||||||
@@ -147,45 +160,71 @@ declare module '@polkadot/api/types/events' {
|
|||||||
contracts: {
|
contracts: {
|
||||||
[key: string]: AugmentedEvent<ApiType>;
|
[key: string]: AugmentedEvent<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Code with the specified hash has been stored.
|
* A code with the specified hash was removed.
|
||||||
* \[code_hash\]
|
* \[code_hash\]
|
||||||
|
*
|
||||||
|
* This happens when the last contract that uses this code hash was removed or evicted.
|
||||||
|
**/
|
||||||
|
CodeRemoved: AugmentedEvent<ApiType, [Hash]>;
|
||||||
|
/**
|
||||||
|
* Code with the specified hash has been stored. \[code_hash\]
|
||||||
**/
|
**/
|
||||||
CodeStored: AugmentedEvent<ApiType, [Hash]>;
|
CodeStored: AugmentedEvent<ApiType, [Hash]>;
|
||||||
/**
|
/**
|
||||||
* An event deposited upon execution of a contract from the account.
|
* A custom event emitted by the contract.
|
||||||
* \[account, data\]
|
* \[contract, data\]
|
||||||
**/
|
|
||||||
ContractExecution: AugmentedEvent<ApiType, [AccountId, Bytes]>;
|
|
||||||
/**
|
|
||||||
* Contract has been evicted and is now in tombstone state.
|
|
||||||
* \[contract, tombstone\]
|
|
||||||
*
|
*
|
||||||
* # Params
|
* # Params
|
||||||
*
|
*
|
||||||
* - `contract`: `AccountId`: The account ID of the evicted contract.
|
* - `contract`: The contract that emitted the event.
|
||||||
* - `tombstone`: `bool`: True if the evicted contract left behind a tombstone.
|
* - `data`: Data supplied by the contract. Metadata generated during contract
|
||||||
|
* compilation is needed to decode it.
|
||||||
**/
|
**/
|
||||||
Evicted: AugmentedEvent<ApiType, [AccountId, bool]>;
|
ContractEmitted: AugmentedEvent<ApiType, [AccountId, Bytes]>;
|
||||||
/**
|
/**
|
||||||
* Contract deployed by address at the specified address. \[owner, contract\]
|
* Contract has been evicted and is now in tombstone state. \[contract\]
|
||||||
|
**/
|
||||||
|
Evicted: AugmentedEvent<ApiType, [AccountId]>;
|
||||||
|
/**
|
||||||
|
* Contract deployed by address at the specified address. \[deployer, contract\]
|
||||||
**/
|
**/
|
||||||
Instantiated: AugmentedEvent<ApiType, [AccountId, AccountId]>;
|
Instantiated: AugmentedEvent<ApiType, [AccountId, AccountId]>;
|
||||||
/**
|
/**
|
||||||
* Restoration for a contract has been successful.
|
* Restoration of a contract has been successful.
|
||||||
* \[donor, dest, code_hash, rent_allowance\]
|
* \[restorer, dest, code_hash, rent_allowance\]
|
||||||
*
|
*
|
||||||
* # Params
|
* # Params
|
||||||
*
|
*
|
||||||
* - `donor`: `AccountId`: Account ID of the restoring contract
|
* - `restorer`: Account ID of the restoring contract.
|
||||||
* - `dest`: `AccountId`: Account ID of the restored contract
|
* - `dest`: Account ID of the restored contract.
|
||||||
* - `code_hash`: `Hash`: Code hash of the restored contract
|
* - `code_hash`: Code hash of the restored contract.
|
||||||
* - `rent_allowance: `Balance`: Rent allowance of the restored contract
|
* - `rent_allowance`: Rent allowance of the restored contract.
|
||||||
**/
|
**/
|
||||||
Restored: AugmentedEvent<ApiType, [AccountId, AccountId, Hash, Balance]>;
|
Restored: AugmentedEvent<ApiType, [AccountId, AccountId, Hash, Balance]>;
|
||||||
/**
|
/**
|
||||||
* Triggered when the current \[schedule\] is updated.
|
* Triggered when the current schedule is updated.
|
||||||
|
* \[version\]
|
||||||
|
*
|
||||||
|
* # Params
|
||||||
|
*
|
||||||
|
* - `version`: The version of the newly set schedule.
|
||||||
**/
|
**/
|
||||||
ScheduleUpdated: AugmentedEvent<ApiType, [u32]>;
|
ScheduleUpdated: AugmentedEvent<ApiType, [u32]>;
|
||||||
|
/**
|
||||||
|
* Contract has been terminated without leaving a tombstone.
|
||||||
|
* \[contract, beneficiary\]
|
||||||
|
*
|
||||||
|
* # Params
|
||||||
|
*
|
||||||
|
* - `contract`: The contract that was terminated.
|
||||||
|
* - `beneficiary`: The account that received the contracts remaining balance.
|
||||||
|
*
|
||||||
|
* # Note
|
||||||
|
*
|
||||||
|
* The only way for a contract to be removed without a tombstone and emitting
|
||||||
|
* this event is by calling `seal_terminate`.
|
||||||
|
**/
|
||||||
|
Terminated: AugmentedEvent<ApiType, [AccountId, AccountId]>;
|
||||||
};
|
};
|
||||||
council: {
|
council: {
|
||||||
[key: string]: AugmentedEvent<ApiType>;
|
[key: string]: AugmentedEvent<ApiType>;
|
||||||
@@ -306,10 +345,44 @@ declare module '@polkadot/api/types/events' {
|
|||||||
**/
|
**/
|
||||||
Vetoed: AugmentedEvent<ApiType, [AccountId, Hash, BlockNumber]>;
|
Vetoed: AugmentedEvent<ApiType, [AccountId, Hash, BlockNumber]>;
|
||||||
};
|
};
|
||||||
|
electionProviderMultiPhase: {
|
||||||
|
[key: string]: AugmentedEvent<ApiType>;
|
||||||
|
/**
|
||||||
|
* The election has been finalized, with `Some` of the given computation, or else if the
|
||||||
|
* election failed, `None`.
|
||||||
|
**/
|
||||||
|
ElectionFinalized: AugmentedEvent<ApiType, [Option<ElectionCompute>]>;
|
||||||
|
/**
|
||||||
|
* An account has been rewarded for their signed submission being finalized.
|
||||||
|
**/
|
||||||
|
Rewarded: AugmentedEvent<ApiType, [AccountId]>;
|
||||||
|
/**
|
||||||
|
* The signed phase of the given round has started.
|
||||||
|
**/
|
||||||
|
SignedPhaseStarted: AugmentedEvent<ApiType, [u32]>;
|
||||||
|
/**
|
||||||
|
* An account has been slashed for submitting an invalid signed submission.
|
||||||
|
**/
|
||||||
|
Slashed: AugmentedEvent<ApiType, [AccountId]>;
|
||||||
|
/**
|
||||||
|
* A solution was stored with the given compute.
|
||||||
|
*
|
||||||
|
* If the solution is signed, this means that it hasn't yet been processed. If the
|
||||||
|
* solution is unsigned, this means that it has also been processed.
|
||||||
|
**/
|
||||||
|
SolutionStored: AugmentedEvent<ApiType, [ElectionCompute]>;
|
||||||
|
/**
|
||||||
|
* The unsigned phase of the given round has started.
|
||||||
|
**/
|
||||||
|
UnsignedPhaseStarted: AugmentedEvent<ApiType, [u32]>;
|
||||||
|
};
|
||||||
elections: {
|
elections: {
|
||||||
[key: string]: AugmentedEvent<ApiType>;
|
[key: string]: AugmentedEvent<ApiType>;
|
||||||
/**
|
/**
|
||||||
* A candidate was slashed due to failing to obtain a seat as member or runner-up
|
* A \[candidate\] was slashed by \[amount\] due to failing to obtain a seat as member or
|
||||||
|
* runner-up.
|
||||||
|
*
|
||||||
|
* Note that old members and runners-up are also candidates.
|
||||||
**/
|
**/
|
||||||
CandidateSlashed: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
CandidateSlashed: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||||
/**
|
/**
|
||||||
@@ -326,10 +399,6 @@ declare module '@polkadot/api/types/events' {
|
|||||||
* `EmptyTerm`.
|
* `EmptyTerm`.
|
||||||
**/
|
**/
|
||||||
MemberKicked: AugmentedEvent<ApiType, [AccountId]>;
|
MemberKicked: AugmentedEvent<ApiType, [AccountId]>;
|
||||||
/**
|
|
||||||
* A \[member\] has renounced their candidacy.
|
|
||||||
**/
|
|
||||||
MemberRenounced: AugmentedEvent<ApiType, [AccountId]>;
|
|
||||||
/**
|
/**
|
||||||
* A new term with \[new_members\]. This indicates that enough candidates existed to run the
|
* 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
|
* election, not that enough have has been elected. The inner value must be examined for
|
||||||
@@ -338,14 +407,13 @@ declare module '@polkadot/api/types/events' {
|
|||||||
**/
|
**/
|
||||||
NewTerm: AugmentedEvent<ApiType, [Vec<ITuple<[AccountId, Balance]>>]>;
|
NewTerm: AugmentedEvent<ApiType, [Vec<ITuple<[AccountId, Balance]>>]>;
|
||||||
/**
|
/**
|
||||||
* A seat holder (member or runner-up) was slashed due to failing to retaining their position.
|
* Someone has renounced their candidacy.
|
||||||
|
**/
|
||||||
|
Renounced: AugmentedEvent<ApiType, [AccountId]>;
|
||||||
|
/**
|
||||||
|
* A \[seat holder\] was slashed by \[amount\] by being forcefully removed from the set.
|
||||||
**/
|
**/
|
||||||
SeatHolderSlashed: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
SeatHolderSlashed: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||||
/**
|
|
||||||
* A voter was reported with the the report being successful or not.
|
|
||||||
* \[voter, reporter, success\]
|
|
||||||
**/
|
|
||||||
VoterReported: AugmentedEvent<ApiType, [AccountId, AccountId, bool]>;
|
|
||||||
};
|
};
|
||||||
grandpa: {
|
grandpa: {
|
||||||
[key: string]: AugmentedEvent<ApiType>;
|
[key: string]: AugmentedEvent<ApiType>;
|
||||||
@@ -437,6 +505,25 @@ declare module '@polkadot/api/types/events' {
|
|||||||
**/
|
**/
|
||||||
IndexFrozen: AugmentedEvent<ApiType, [AccountIndex, AccountId]>;
|
IndexFrozen: AugmentedEvent<ApiType, [AccountIndex, AccountId]>;
|
||||||
};
|
};
|
||||||
|
lottery: {
|
||||||
|
[key: string]: AugmentedEvent<ApiType>;
|
||||||
|
/**
|
||||||
|
* A new set of calls have been set!
|
||||||
|
**/
|
||||||
|
CallsUpdated: AugmentedEvent<ApiType, []>;
|
||||||
|
/**
|
||||||
|
* A lottery has been started!
|
||||||
|
**/
|
||||||
|
LotteryStarted: AugmentedEvent<ApiType, []>;
|
||||||
|
/**
|
||||||
|
* A ticket has been bought!
|
||||||
|
**/
|
||||||
|
TicketBought: AugmentedEvent<ApiType, [AccountId, CallIndex]>;
|
||||||
|
/**
|
||||||
|
* A winner has been chosen!
|
||||||
|
**/
|
||||||
|
Winner: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||||
|
};
|
||||||
multisig: {
|
multisig: {
|
||||||
[key: string]: AugmentedEvent<ApiType>;
|
[key: string]: AugmentedEvent<ApiType>;
|
||||||
/**
|
/**
|
||||||
@@ -622,6 +709,10 @@ declare module '@polkadot/api/types/events' {
|
|||||||
* \[era_index, validator_payout, remainder\]
|
* \[era_index, validator_payout, remainder\]
|
||||||
**/
|
**/
|
||||||
EraPayout: AugmentedEvent<ApiType, [EraIndex, Balance, Balance]>;
|
EraPayout: AugmentedEvent<ApiType, [EraIndex, Balance, Balance]>;
|
||||||
|
/**
|
||||||
|
* A nominator has been kicked from a validator. \[nominator, stash\]
|
||||||
|
**/
|
||||||
|
Kicked: AugmentedEvent<ApiType, [AccountId, AccountId]>;
|
||||||
/**
|
/**
|
||||||
* An old slashing report from a prior era was discarded because it could
|
* An old slashing report from a prior era was discarded because it could
|
||||||
* not be processed. \[session_index\]
|
* not be processed. \[session_index\]
|
||||||
|
|||||||
@@ -3,26 +3,27 @@
|
|||||||
|
|
||||||
import type { Bytes, Data, Option, U8aFixed, Vec, bool, u32, u64 } from '@polkadot/types';
|
import type { Bytes, Data, Option, U8aFixed, Vec, bool, u32, u64 } from '@polkadot/types';
|
||||||
import type { AnyNumber, ITuple, Observable } from '@polkadot/types/types';
|
import type { AnyNumber, ITuple, Observable } from '@polkadot/types/types';
|
||||||
import type { AssetBalance, AssetDetails } from '@polkadot/types/interfaces/assets';
|
import type { AssetBalance, AssetDetails, AssetMetadata } from '@polkadot/types/interfaces/assets';
|
||||||
import type { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
|
import type { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
|
||||||
import type { BabeAuthorityWeight, MaybeRandomness, NextConfigDescriptor, Randomness } from '@polkadot/types/interfaces/babe';
|
import type { BabeAuthorityWeight, MaybeRandomness, NextConfigDescriptor, Randomness } from '@polkadot/types/interfaces/babe';
|
||||||
import type { AccountData, BalanceLock } from '@polkadot/types/interfaces/balances';
|
import type { AccountData, BalanceLock } from '@polkadot/types/interfaces/balances';
|
||||||
import type { ProposalIndex, Votes } from '@polkadot/types/interfaces/collective';
|
import type { ProposalIndex, Votes } from '@polkadot/types/interfaces/collective';
|
||||||
import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
|
import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
|
||||||
import type { CodeHash, ContractInfo, PrefabWasmModule, Schedule } from '@polkadot/types/interfaces/contracts';
|
import type { CodeHash, ContractInfo, DeletedContract, PrefabWasmModule, Schedule } from '@polkadot/types/interfaces/contracts';
|
||||||
import type { PreimageStatus, PropIndex, Proposal, ReferendumIndex, ReferendumInfo, Voting } from '@polkadot/types/interfaces/democracy';
|
import type { PreimageStatus, PropIndex, Proposal, ReferendumIndex, ReferendumInfo, Voting } from '@polkadot/types/interfaces/democracy';
|
||||||
import type { VoteThreshold } from '@polkadot/types/interfaces/elections';
|
import type { VoteThreshold } from '@polkadot/types/interfaces/elections';
|
||||||
import type { SetId, StoredPendingChange, StoredState } from '@polkadot/types/interfaces/grandpa';
|
import type { SetId, StoredPendingChange, StoredState } from '@polkadot/types/interfaces/grandpa';
|
||||||
import type { RegistrarInfo, Registration } from '@polkadot/types/interfaces/identity';
|
import type { RegistrarInfo, Registration } from '@polkadot/types/interfaces/identity';
|
||||||
import type { AuthIndex } from '@polkadot/types/interfaces/imOnline';
|
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 { DeferredOffenceOf, Kind, OffenceDetails, OpaqueTimeSlot, ReportIdOf } from '@polkadot/types/interfaces/offences';
|
||||||
import type { ProxyAnnouncement, ProxyDefinition } from '@polkadot/types/interfaces/proxy';
|
import type { ProxyAnnouncement, ProxyDefinition } from '@polkadot/types/interfaces/proxy';
|
||||||
import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
|
import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
|
||||||
import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber, Hash, KeyTypeId, Moment, OpaqueCall, Perbill, Releases, ValidatorId } from '@polkadot/types/interfaces/runtime';
|
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 { Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler';
|
||||||
import type { Keys, SessionIndex } from '@polkadot/types/interfaces/session';
|
import type { Keys, SessionIndex } from '@polkadot/types/interfaces/session';
|
||||||
import type { Bid, BidKind, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
|
import type { Bid, BidKind, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
|
||||||
import type { ActiveEraInfo, ElectionResult, ElectionScore, ElectionStatus, EraIndex, EraRewardPoints, Exposure, Forcing, Nominations, RewardDestination, SlashingSpans, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
|
import type { ActiveEraInfo, 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 { AccountInfo, ConsumedWeight, DigestOf, EventIndex, EventRecord, LastRuntimeUpgradeInfo, Phase } from '@polkadot/types/interfaces/system';
|
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 { Bounty, BountyIndex, OpenTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
|
||||||
import type { Multiplier } from '@polkadot/types/interfaces/txpayment';
|
import type { Multiplier } from '@polkadot/types/interfaces/txpayment';
|
||||||
@@ -42,6 +43,10 @@ declare module '@polkadot/api/types/storage' {
|
|||||||
* Details of an asset.
|
* Details of an asset.
|
||||||
**/
|
**/
|
||||||
asset: AugmentedQuery<ApiType, (arg: AssetId | AnyNumber | Uint8Array) => Observable<Option<AssetDetails>>, [AssetId]> & QueryableStorageEntry<ApiType, [AssetId]>;
|
asset: AugmentedQuery<ApiType, (arg: AssetId | AnyNumber | Uint8Array) => Observable<Option<AssetDetails>>, [AssetId]> & QueryableStorageEntry<ApiType, [AssetId]>;
|
||||||
|
/**
|
||||||
|
* Metadata of an asset.
|
||||||
|
**/
|
||||||
|
metadata: AugmentedQuery<ApiType, (arg: AssetId | AnyNumber | Uint8Array) => Observable<AssetMetadata>, [AssetId]> & QueryableStorageEntry<ApiType, [AssetId]>;
|
||||||
};
|
};
|
||||||
authorship: {
|
authorship: {
|
||||||
[key: string]: QueryableStorageEntry<ApiType>;
|
[key: string]: QueryableStorageEntry<ApiType>;
|
||||||
@@ -73,7 +78,7 @@ declare module '@polkadot/api/types/storage' {
|
|||||||
/**
|
/**
|
||||||
* Current slot number.
|
* Current slot number.
|
||||||
**/
|
**/
|
||||||
currentSlot: AugmentedQuery<ApiType, () => Observable<u64>, []> & QueryableStorageEntry<ApiType, []>;
|
currentSlot: AugmentedQuery<ApiType, () => Observable<Slot>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
/**
|
/**
|
||||||
* Current epoch index.
|
* Current epoch index.
|
||||||
**/
|
**/
|
||||||
@@ -82,7 +87,7 @@ declare module '@polkadot/api/types/storage' {
|
|||||||
* The slot at which the first epoch actually started. This is 0
|
* The slot at which the first epoch actually started. This is 0
|
||||||
* until the first block of the chain.
|
* until the first block of the chain.
|
||||||
**/
|
**/
|
||||||
genesisSlot: AugmentedQuery<ApiType, () => Observable<u64>, []> & QueryableStorageEntry<ApiType, []>;
|
genesisSlot: AugmentedQuery<ApiType, () => Observable<Slot>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
/**
|
/**
|
||||||
* Temporary value (cleared at block finalization) which is `Some`
|
* Temporary value (cleared at block finalization) which is `Some`
|
||||||
* if per-block initialization has already been called for current block.
|
* if per-block initialization has already been called for current block.
|
||||||
@@ -96,6 +101,10 @@ declare module '@polkadot/api/types/storage' {
|
|||||||
* execution context should always yield zero.
|
* execution context should always yield zero.
|
||||||
**/
|
**/
|
||||||
lateness: AugmentedQuery<ApiType, () => Observable<BlockNumber>, []> & QueryableStorageEntry<ApiType, []>;
|
lateness: AugmentedQuery<ApiType, () => Observable<BlockNumber>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
|
/**
|
||||||
|
* Next epoch authorities.
|
||||||
|
**/
|
||||||
|
nextAuthorities: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[AuthorityId, BabeAuthorityWeight]>>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
/**
|
/**
|
||||||
* Next epoch configuration, if changed.
|
* Next epoch configuration, if changed.
|
||||||
**/
|
**/
|
||||||
@@ -139,7 +148,7 @@ declare module '@polkadot/api/types/storage' {
|
|||||||
/**
|
/**
|
||||||
* The balance of an account.
|
* The balance of an account.
|
||||||
*
|
*
|
||||||
* NOTE: This is only used in the case that this module is used to store balances.
|
* NOTE: This is only used in the case that this pallet is used to store balances.
|
||||||
**/
|
**/
|
||||||
account: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<AccountData>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
account: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<AccountData>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
||||||
/**
|
/**
|
||||||
@@ -197,6 +206,13 @@ declare module '@polkadot/api/types/storage' {
|
|||||||
* Current cost schedule for contracts.
|
* Current cost schedule for contracts.
|
||||||
**/
|
**/
|
||||||
currentSchedule: AugmentedQuery<ApiType, () => Observable<Schedule>, []> & QueryableStorageEntry<ApiType, []>;
|
currentSchedule: AugmentedQuery<ApiType, () => Observable<Schedule>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
|
/**
|
||||||
|
* Evicted contracts that await child trie deletion.
|
||||||
|
*
|
||||||
|
* Child trie deletion is a heavy operation depending on the amount of storage items
|
||||||
|
* stored in said trie. Therefore this operation is performed lazily in `on_initialize`.
|
||||||
|
**/
|
||||||
|
deletionQueue: AugmentedQuery<ApiType, () => Observable<Vec<DeletedContract>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
/**
|
/**
|
||||||
* A mapping from an original code hash to the original code, untouched by instrumentation.
|
* A mapping from an original code hash to the original code, untouched by instrumentation.
|
||||||
**/
|
**/
|
||||||
@@ -307,31 +323,78 @@ declare module '@polkadot/api/types/storage' {
|
|||||||
**/
|
**/
|
||||||
votingOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Voting>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
votingOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Voting>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
||||||
};
|
};
|
||||||
|
electionProviderMultiPhase: {
|
||||||
|
[key: string]: QueryableStorageEntry<ApiType>;
|
||||||
|
/**
|
||||||
|
* Current phase.
|
||||||
|
**/
|
||||||
|
currentPhase: AugmentedQuery<ApiType, () => Observable<Phase>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
|
/**
|
||||||
|
* Desired number of targets to elect for this round.
|
||||||
|
*
|
||||||
|
* Only exists when [`Snapshot`] is present.
|
||||||
|
**/
|
||||||
|
desiredTargets: AugmentedQuery<ApiType, () => Observable<Option<u32>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
|
/**
|
||||||
|
* Current best solution, signed or unsigned, queued to be returned upon `elect`.
|
||||||
|
**/
|
||||||
|
queuedSolution: AugmentedQuery<ApiType, () => Observable<Option<ReadySolution>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
|
/**
|
||||||
|
* Internal counter for the number of rounds.
|
||||||
|
*
|
||||||
|
* This is useful for de-duplication of transactions submitted to the pool, and general
|
||||||
|
* diagnostics of the pallet.
|
||||||
|
*
|
||||||
|
* This is merely incremented once per every time that an upstream `elect` is called.
|
||||||
|
**/
|
||||||
|
round: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
|
/**
|
||||||
|
* Snapshot data of the round.
|
||||||
|
*
|
||||||
|
* This is created at the beginning of the signed phase and cleared upon calling `elect`.
|
||||||
|
**/
|
||||||
|
snapshot: AugmentedQuery<ApiType, () => Observable<Option<RoundSnapshot>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
|
/**
|
||||||
|
* The metadata of the [`RoundSnapshot`]
|
||||||
|
*
|
||||||
|
* Only exists when [`Snapshot`] is present.
|
||||||
|
**/
|
||||||
|
snapshotMetadata: AugmentedQuery<ApiType, () => Observable<Option<SolutionOrSnapshotSize>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
|
};
|
||||||
elections: {
|
elections: {
|
||||||
[key: string]: QueryableStorageEntry<ApiType>;
|
[key: string]: QueryableStorageEntry<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The present candidate list. Sorted based on account-id. A current member or runner-up
|
* The present candidate list. A current member or runner-up can never enter this vector
|
||||||
* can never enter this vector and is always implicitly assumed to be a candidate.
|
* and is always implicitly assumed to be a candidate.
|
||||||
|
*
|
||||||
|
* Second element is the deposit.
|
||||||
|
*
|
||||||
|
* Invariant: Always sorted based on account id.
|
||||||
**/
|
**/
|
||||||
candidates: AugmentedQuery<ApiType, () => Observable<Vec<AccountId>>, []> & QueryableStorageEntry<ApiType, []>;
|
candidates: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[AccountId, BalanceOf]>>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
/**
|
/**
|
||||||
* The total number of vote rounds that have happened, excluding the upcoming one.
|
* The total number of vote rounds that have happened, excluding the upcoming one.
|
||||||
**/
|
**/
|
||||||
electionRounds: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
|
electionRounds: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
/**
|
/**
|
||||||
* The current elected membership. Sorted based on account id.
|
* The current elected members.
|
||||||
|
*
|
||||||
|
* Invariant: Always sorted based on account id.
|
||||||
**/
|
**/
|
||||||
members: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[AccountId, BalanceOf]>>>, []> & QueryableStorageEntry<ApiType, []>;
|
members: AugmentedQuery<ApiType, () => Observable<Vec<SeatHolder>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
/**
|
/**
|
||||||
* The current runners_up. Sorted based on low to high merit (worse to best).
|
* The current reserved runners-up.
|
||||||
|
*
|
||||||
|
* Invariant: Always sorted based on rank (worse to best). Upon removal of a member, the
|
||||||
|
* last (i.e. _best_) runner-up will be replaced.
|
||||||
**/
|
**/
|
||||||
runnersUp: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[AccountId, BalanceOf]>>>, []> & QueryableStorageEntry<ApiType, []>;
|
runnersUp: AugmentedQuery<ApiType, () => Observable<Vec<SeatHolder>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
/**
|
/**
|
||||||
* Votes and locked stake of a particular voter.
|
* Votes and locked stake of a particular voter.
|
||||||
*
|
*
|
||||||
* TWOX-NOTE: SAFE as `AccountId` is a crypto hash
|
* TWOX-NOTE: SAFE as `AccountId` is a crypto hash.
|
||||||
**/
|
**/
|
||||||
voting: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ITuple<[BalanceOf, Vec<AccountId>]>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
voting: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Voter>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
||||||
};
|
};
|
||||||
grandpa: {
|
grandpa: {
|
||||||
[key: string]: QueryableStorageEntry<ApiType>;
|
[key: string]: QueryableStorageEntry<ApiType>;
|
||||||
@@ -396,7 +459,7 @@ declare module '@polkadot/api/types/storage' {
|
|||||||
imOnline: {
|
imOnline: {
|
||||||
[key: string]: QueryableStorageEntry<ApiType>;
|
[key: string]: QueryableStorageEntry<ApiType>;
|
||||||
/**
|
/**
|
||||||
* For each session index, we keep a mapping of `T::ValidatorId` to the
|
* For each session index, we keep a mapping of `ValidatorId<T>` to the
|
||||||
* number of blocks authored by the given authority.
|
* 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: AugmentedQueryDoubleMap<ApiType, (key1: SessionIndex | AnyNumber | Uint8Array, key2: ValidatorId | string | Uint8Array) => Observable<u32>, [SessionIndex, ValidatorId]> & QueryableStorageEntry<ApiType, [SessionIndex, ValidatorId]>;
|
||||||
@@ -426,6 +489,34 @@ declare module '@polkadot/api/types/storage' {
|
|||||||
**/
|
**/
|
||||||
accounts: AugmentedQuery<ApiType, (arg: AccountIndex | AnyNumber | Uint8Array) => Observable<Option<ITuple<[AccountId, BalanceOf, bool]>>>, [AccountIndex]> & QueryableStorageEntry<ApiType, [AccountIndex]>;
|
accounts: AugmentedQuery<ApiType, (arg: AccountIndex | AnyNumber | Uint8Array) => Observable<Option<ITuple<[AccountId, BalanceOf, bool]>>>, [AccountIndex]> & QueryableStorageEntry<ApiType, [AccountIndex]>;
|
||||||
};
|
};
|
||||||
|
lottery: {
|
||||||
|
[key: string]: QueryableStorageEntry<ApiType>;
|
||||||
|
/**
|
||||||
|
* The calls stored in this pallet to be used in an active lottery if configured
|
||||||
|
* by `Config::ValidateCall`.
|
||||||
|
**/
|
||||||
|
callIndices: AugmentedQuery<ApiType, () => Observable<Vec<CallIndex>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
|
/**
|
||||||
|
* The configuration for the current lottery.
|
||||||
|
**/
|
||||||
|
lottery: AugmentedQuery<ApiType, () => Observable<Option<LotteryConfig>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
|
lotteryIndex: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
|
/**
|
||||||
|
* Users who have purchased a ticket. (Lottery Index, Tickets Purchased)
|
||||||
|
**/
|
||||||
|
participants: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ITuple<[u32, Vec<CallIndex>]>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
||||||
|
/**
|
||||||
|
* Each ticket's owner.
|
||||||
|
*
|
||||||
|
* May have residual storage from previous lotteries. Use `TicketsCount` to see which ones
|
||||||
|
* are actually valid ticket mappings.
|
||||||
|
**/
|
||||||
|
tickets: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Option<AccountId>>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
|
||||||
|
/**
|
||||||
|
* Total number of tickets sold.
|
||||||
|
**/
|
||||||
|
ticketsCount: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
|
};
|
||||||
mmr: {
|
mmr: {
|
||||||
[key: string]: QueryableStorageEntry<ApiType>;
|
[key: string]: QueryableStorageEntry<ApiType>;
|
||||||
/**
|
/**
|
||||||
@@ -670,6 +761,12 @@ declare module '@polkadot/api/types/storage' {
|
|||||||
* set, it might be active or not.
|
* set, it might be active or not.
|
||||||
**/
|
**/
|
||||||
currentEra: AugmentedQuery<ApiType, () => Observable<Option<EraIndex>>, []> & QueryableStorageEntry<ApiType, []>;
|
currentEra: AugmentedQuery<ApiType, () => Observable<Option<EraIndex>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
|
/**
|
||||||
|
* The last planned session scheduled by the session pallet.
|
||||||
|
*
|
||||||
|
* This is basically in sync with the call to [`SessionManager::new_session`].
|
||||||
|
**/
|
||||||
|
currentPlannedSession: AugmentedQuery<ApiType, () => Observable<SessionIndex>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
/**
|
/**
|
||||||
* The earliest era for which we have a pending, unapplied slash.
|
* The earliest era for which we have a pending, unapplied slash.
|
||||||
**/
|
**/
|
||||||
@@ -677,6 +774,8 @@ declare module '@polkadot/api/types/storage' {
|
|||||||
/**
|
/**
|
||||||
* Flag to control the execution of the offchain election. When `Open(_)`, we accept
|
* Flag to control the execution of the offchain election. When `Open(_)`, we accept
|
||||||
* solutions to be submitted.
|
* solutions to be submitted.
|
||||||
|
*
|
||||||
|
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
|
||||||
**/
|
**/
|
||||||
eraElectionStatus: AugmentedQuery<ApiType, () => Observable<ElectionStatus>, []> & QueryableStorageEntry<ApiType, []>;
|
eraElectionStatus: AugmentedQuery<ApiType, () => Observable<ElectionStatus>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
/**
|
/**
|
||||||
@@ -756,6 +855,8 @@ declare module '@polkadot/api/types/storage' {
|
|||||||
/**
|
/**
|
||||||
* True if the current **planned** session is final. Note that this does not take era
|
* True if the current **planned** session is final. Note that this does not take era
|
||||||
* forcing into account.
|
* forcing into account.
|
||||||
|
*
|
||||||
|
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
|
||||||
**/
|
**/
|
||||||
isCurrentSessionFinal: AugmentedQuery<ApiType, () => Observable<bool>, []> & QueryableStorageEntry<ApiType, []>;
|
isCurrentSessionFinal: AugmentedQuery<ApiType, () => Observable<bool>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
/**
|
/**
|
||||||
@@ -782,10 +883,14 @@ declare module '@polkadot/api/types/storage' {
|
|||||||
* The next validator set. At the end of an era, if this is available (potentially from the
|
* 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
|
* result of an offchain worker), it is immediately used. Otherwise, the on-chain election
|
||||||
* is executed.
|
* is executed.
|
||||||
|
*
|
||||||
|
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
|
||||||
**/
|
**/
|
||||||
queuedElected: AugmentedQuery<ApiType, () => Observable<Option<ElectionResult>>, []> & QueryableStorageEntry<ApiType, []>;
|
queuedElected: AugmentedQuery<ApiType, () => Observable<Option<ElectionResult>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
/**
|
/**
|
||||||
* The score of the current [`QueuedElected`].
|
* 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, []>;
|
queuedScore: AugmentedQuery<ApiType, () => Observable<Option<ElectionScore>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
/**
|
/**
|
||||||
@@ -801,11 +906,15 @@ declare module '@polkadot/api/types/storage' {
|
|||||||
/**
|
/**
|
||||||
* Snapshot of nominators at the beginning of the current election window. This should only
|
* Snapshot of nominators at the beginning of the current election window. This should only
|
||||||
* have a value when [`EraElectionStatus`] == `ElectionStatus::Open(_)`.
|
* 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, []>;
|
snapshotNominators: AugmentedQuery<ApiType, () => Observable<Option<Vec<AccountId>>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
/**
|
/**
|
||||||
* Snapshot of validators at the beginning of the current election window. This should only
|
* Snapshot of validators at the beginning of the current election window. This should only
|
||||||
* have a value when [`EraElectionStatus`] == `ElectionStatus::Open(_)`.
|
* 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, []>;
|
snapshotValidators: AugmentedQuery<ApiType, () => Observable<Option<Vec<AccountId>>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
/**
|
/**
|
||||||
@@ -817,7 +926,7 @@ declare module '@polkadot/api/types/storage' {
|
|||||||
* True if network has been upgraded to this version.
|
* True if network has been upgraded to this version.
|
||||||
* Storage version of the pallet.
|
* Storage version of the pallet.
|
||||||
*
|
*
|
||||||
* This is set to v3.0.0 for new networks.
|
* This is set to v5.0.0 for new networks.
|
||||||
**/
|
**/
|
||||||
storageVersion: AugmentedQuery<ApiType, () => Observable<Releases>, []> & QueryableStorageEntry<ApiType, []>;
|
storageVersion: AugmentedQuery<ApiType, () => Observable<Releases>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
/**
|
/**
|
||||||
@@ -912,6 +1021,11 @@ declare module '@polkadot/api/types/storage' {
|
|||||||
* Hash of the previous block.
|
* Hash of the previous block.
|
||||||
**/
|
**/
|
||||||
parentHash: AugmentedQuery<ApiType, () => Observable<Hash>, []> & QueryableStorageEntry<ApiType, []>;
|
parentHash: AugmentedQuery<ApiType, () => Observable<Hash>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
|
/**
|
||||||
|
* True if we have upgraded so that AccountInfo contains two types of `RefCount`. False
|
||||||
|
* (default) if not.
|
||||||
|
**/
|
||||||
|
upgradedToDualRefCount: AugmentedQuery<ApiType, () => Observable<bool>, []> & QueryableStorageEntry<ApiType, []>;
|
||||||
/**
|
/**
|
||||||
* True if we have upgraded so that `type RefCount` is `u32`. False (default) if not.
|
* True if we have upgraded so that `type RefCount` is `u32`. False (default) if not.
|
||||||
**/
|
**/
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ import type { PrefixedStorageKey } from '@polkadot/types/interfaces/childstate';
|
|||||||
import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
|
import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
|
||||||
import type { ContractCallRequest, ContractExecResult } from '@polkadot/types/interfaces/contracts';
|
import type { ContractCallRequest, ContractExecResult } from '@polkadot/types/interfaces/contracts';
|
||||||
import type { CreatedBlock } from '@polkadot/types/interfaces/engine';
|
import type { CreatedBlock } from '@polkadot/types/interfaces/engine';
|
||||||
import type { EthAccount, EthCallRequest, EthFilter, EthLog, EthReceipt, EthRichBlock, EthSubKind, EthSubParams, EthSyncStatus, EthTransaction, EthTransactionRequest, EthWork } from '@polkadot/types/interfaces/eth';
|
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';
|
import type { Extrinsic } from '@polkadot/types/interfaces/extrinsics';
|
||||||
import type { EncodedFinalityProofs, JustificationNotification, ReportedRoundStates } from '@polkadot/types/interfaces/grandpa';
|
import type { EncodedFinalityProofs, JustificationNotification, ReportedRoundStates } from '@polkadot/types/interfaces/grandpa';
|
||||||
import type { StorageKind } from '@polkadot/types/interfaces/offchain';
|
import type { StorageKind } from '@polkadot/types/interfaces/offchain';
|
||||||
import type { RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
|
import type { FeeDetails, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
|
||||||
import type { RpcMethods } from '@polkadot/types/interfaces/rpc';
|
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 { 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 } from '@polkadot/types/interfaces/state';
|
||||||
@@ -188,6 +188,14 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
|||||||
* Returns the code at given address at given time (block number).
|
* Returns the code at given address at given time (block number).
|
||||||
**/
|
**/
|
||||||
getCode: AugmentedRpc<(address: H160 | string | Uint8Array, number?: BlockNumber | AnyNumber | Uint8Array) => Observable<Bytes>>;
|
getCode: AugmentedRpc<(address: H160 | string | Uint8Array, number?: BlockNumber | AnyNumber | Uint8Array) => Observable<Bytes>>;
|
||||||
|
/**
|
||||||
|
* Returns filter changes since last poll.
|
||||||
|
**/
|
||||||
|
getFilterChanges: AugmentedRpc<(index: U256 | AnyNumber | Uint8Array) => Observable<EthFilterChanges>>;
|
||||||
|
/**
|
||||||
|
* Returns all logs matching given filter (in a range 'from' - 'to').
|
||||||
|
**/
|
||||||
|
getFilterLogs: AugmentedRpc<(index: U256 | AnyNumber | Uint8Array) => Observable<Vec<EthLog>>>;
|
||||||
/**
|
/**
|
||||||
* Returns logs matching given filter object.
|
* Returns logs matching given filter object.
|
||||||
**/
|
**/
|
||||||
@@ -248,6 +256,18 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
|||||||
* Returns true if client is actively mining new blocks.
|
* Returns true if client is actively mining new blocks.
|
||||||
**/
|
**/
|
||||||
mining: AugmentedRpc<() => Observable<bool>>;
|
mining: AugmentedRpc<() => Observable<bool>>;
|
||||||
|
/**
|
||||||
|
* Returns id of new block filter.
|
||||||
|
**/
|
||||||
|
newBlockFilter: AugmentedRpc<() => Observable<U256>>;
|
||||||
|
/**
|
||||||
|
* Returns id of new filter.
|
||||||
|
**/
|
||||||
|
newFilter: AugmentedRpc<(filter: EthFilter | { fromBlock?: any; toBlock?: any; blockHash?: any; address?: any; topics?: any } | string | Uint8Array) => Observable<U256>>;
|
||||||
|
/**
|
||||||
|
* Returns id of new block filter.
|
||||||
|
**/
|
||||||
|
newPendingTransactionFilter: AugmentedRpc<() => Observable<U256>>;
|
||||||
/**
|
/**
|
||||||
* Returns protocol version encoded as a string (quotes are necessary).
|
* Returns protocol version encoded as a string (quotes are necessary).
|
||||||
**/
|
**/
|
||||||
@@ -276,6 +296,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
|||||||
* Returns an object with data about the sync status or false.
|
* Returns an object with data about the sync status or false.
|
||||||
**/
|
**/
|
||||||
syncing: AugmentedRpc<() => Observable<EthSyncStatus>>;
|
syncing: AugmentedRpc<() => Observable<EthSyncStatus>>;
|
||||||
|
/**
|
||||||
|
* Uninstalls filter.
|
||||||
|
**/
|
||||||
|
uninstallFilter: AugmentedRpc<(index: U256 | AnyNumber | Uint8Array) => Observable<bool>>;
|
||||||
};
|
};
|
||||||
grandpa: {
|
grandpa: {
|
||||||
/**
|
/**
|
||||||
@@ -309,13 +333,17 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
|||||||
/**
|
/**
|
||||||
* Get offchain local storage under given key and prefix
|
* Get offchain local storage under given key and prefix
|
||||||
**/
|
**/
|
||||||
localStorageGet: AugmentedRpc<(kind: StorageKind | '__UNUSED' | 'PERSISTENT' | 'LOCAL' | number | Uint8Array, key: Bytes | string | Uint8Array) => Observable<Option<Bytes>>>;
|
localStorageGet: AugmentedRpc<(kind: StorageKind | 'PERSISTENT' | 'LOCAL' | number | Uint8Array, key: Bytes | string | Uint8Array) => Observable<Option<Bytes>>>;
|
||||||
/**
|
/**
|
||||||
* Set offchain local storage under given key and prefix
|
* Set offchain local storage under given key and prefix
|
||||||
**/
|
**/
|
||||||
localStorageSet: AugmentedRpc<(kind: StorageKind | '__UNUSED' | 'PERSISTENT' | 'LOCAL' | number | Uint8Array, key: Bytes | string | Uint8Array, value: Bytes | string | Uint8Array) => Observable<Null>>;
|
localStorageSet: AugmentedRpc<(kind: StorageKind | 'PERSISTENT' | 'LOCAL' | number | Uint8Array, key: Bytes | string | Uint8Array, value: Bytes | string | Uint8Array) => Observable<Null>>;
|
||||||
};
|
};
|
||||||
payment: {
|
payment: {
|
||||||
|
/**
|
||||||
|
* Query the detailed fee of a given encoded extrinsic
|
||||||
|
**/
|
||||||
|
queryFeeDetails: AugmentedRpc<(extrinsic: Bytes | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<FeeDetails>>;
|
||||||
/**
|
/**
|
||||||
* Retrieves the fee information for an encoded extrinsic
|
* Retrieves the fee information for an encoded extrinsic
|
||||||
**/
|
**/
|
||||||
|
|||||||
+271
-180
@@ -1,24 +1,24 @@
|
|||||||
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
|
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
|
||||||
import type { Bytes, Compact, Data, Option, U8aFixed, Vec, bool, u16, u32, u64 } from '@polkadot/types';
|
import type { Bytes, Compact, Data, Option, U8aFixed, Vec, bool, u16, u32, u64, u8 } from '@polkadot/types';
|
||||||
import type { AnyNumber, ITuple } from '@polkadot/types/types';
|
import type { AnyNumber, ITuple } from '@polkadot/types/types';
|
||||||
import type { TAssetBalance } from '@polkadot/types/interfaces/assets';
|
import type { TAssetBalance } from '@polkadot/types/interfaces/assets';
|
||||||
import type { BabeEquivocationProof } from '@polkadot/types/interfaces/babe';
|
import type { BabeEquivocationProof } from '@polkadot/types/interfaces/babe';
|
||||||
import type { MemberCount, ProposalIndex } from '@polkadot/types/interfaces/collective';
|
import type { MemberCount, ProposalIndex } from '@polkadot/types/interfaces/collective';
|
||||||
import type { CodeHash, Gas, Schedule } from '@polkadot/types/interfaces/contracts';
|
import type { CodeHash, Schedule } from '@polkadot/types/interfaces/contracts';
|
||||||
import type { AccountVote, Conviction, PropIndex, Proposal, ReferendumIndex } from '@polkadot/types/interfaces/democracy';
|
import type { AccountVote, Conviction, PropIndex, Proposal, ReferendumIndex } from '@polkadot/types/interfaces/democracy';
|
||||||
import type { DefunctVoter, Renouncing } from '@polkadot/types/interfaces/elections';
|
import type { Renouncing } from '@polkadot/types/interfaces/elections';
|
||||||
import type { Extrinsic, Signature } from '@polkadot/types/interfaces/extrinsics';
|
import type { Extrinsic, Signature } from '@polkadot/types/interfaces/extrinsics';
|
||||||
import type { GrandpaEquivocationProof, KeyOwnerProof } from '@polkadot/types/interfaces/grandpa';
|
import type { GrandpaEquivocationProof, KeyOwnerProof } from '@polkadot/types/interfaces/grandpa';
|
||||||
import type { IdentityFields, IdentityInfo, IdentityJudgement, RegistrarIndex } from '@polkadot/types/interfaces/identity';
|
import type { IdentityFields, IdentityInfo, IdentityJudgement, RegistrarIndex } from '@polkadot/types/interfaces/identity';
|
||||||
import type { Heartbeat } from '@polkadot/types/interfaces/imOnline';
|
import type { Heartbeat } from '@polkadot/types/interfaces/imOnline';
|
||||||
import type { ProxyType } from '@polkadot/types/interfaces/proxy';
|
import type { ProxyType } from '@polkadot/types/interfaces/proxy';
|
||||||
import type { AccountId, AccountIndex, Address, AssetId, Balance, BalanceOf, BlockNumber, Call, CallHashOf, ChangesTrieConfiguration, Hash, Header, KeyValue, LookupSource, Moment, OpaqueCall, Perbill, Percent, Weight } from '@polkadot/types/interfaces/runtime';
|
import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber, Call, CallHashOf, ChangesTrieConfiguration, Hash, Header, KeyValue, LookupSource, Moment, OpaqueCall, Perbill, Percent, Weight } from '@polkadot/types/interfaces/runtime';
|
||||||
import type { Period, Priority } from '@polkadot/types/interfaces/scheduler';
|
import type { Period, Priority } from '@polkadot/types/interfaces/scheduler';
|
||||||
import type { Keys } from '@polkadot/types/interfaces/session';
|
import type { Keys } from '@polkadot/types/interfaces/session';
|
||||||
import type { SocietyJudgement } from '@polkadot/types/interfaces/society';
|
import type { SocietyJudgement } from '@polkadot/types/interfaces/society';
|
||||||
import type { CompactAssignments, ElectionScore, ElectionSize, EraIndex, RewardDestination, ValidatorIndex, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
|
import type { CompactAssignments, ElectionScore, ElectionSize, EraIndex, RawSolution, RewardDestination, SolutionOrSnapshotSize, ValidatorIndex, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
|
||||||
import type { Key } from '@polkadot/types/interfaces/system';
|
import type { Key } from '@polkadot/types/interfaces/system';
|
||||||
import type { BountyIndex } from '@polkadot/types/interfaces/treasury';
|
import type { BountyIndex } from '@polkadot/types/interfaces/treasury';
|
||||||
import type { Timepoint } from '@polkadot/types/interfaces/utility';
|
import type { Timepoint } from '@polkadot/types/interfaces/utility';
|
||||||
@@ -46,7 +46,7 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* Weight: `O(1)`
|
* Weight: `O(1)`
|
||||||
* Modes: Post-existence of `who`; Pre & post Zombie-status of `who`.
|
* Modes: Post-existence of `who`; Pre & post Zombie-status of `who`.
|
||||||
**/
|
**/
|
||||||
burn: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, who: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, amount: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<TAssetBalance>]>;
|
burn: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, who: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, amount: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<TAssetBalance>]>;
|
||||||
/**
|
/**
|
||||||
* Issue a new class of fungible assets from a public origin.
|
* Issue a new class of fungible assets from a public origin.
|
||||||
*
|
*
|
||||||
@@ -72,7 +72,7 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
*
|
*
|
||||||
* Weight: `O(1)`
|
* Weight: `O(1)`
|
||||||
**/
|
**/
|
||||||
create: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, admin: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, maxZombies: u32 | AnyNumber | Uint8Array, minBalance: TAssetBalance | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, u32, TAssetBalance]>;
|
create: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, admin: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, maxZombies: u32 | AnyNumber | Uint8Array, minBalance: TAssetBalance | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, u32, TAssetBalance]>;
|
||||||
/**
|
/**
|
||||||
* Destroy a class of fungible assets owned by the sender.
|
* Destroy a class of fungible assets owned by the sender.
|
||||||
*
|
*
|
||||||
@@ -109,7 +109,7 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
*
|
*
|
||||||
* Weight: `O(1)`
|
* Weight: `O(1)`
|
||||||
**/
|
**/
|
||||||
forceCreate: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, owner: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, maxZombies: Compact<u32> | AnyNumber | Uint8Array, minBalance: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<u32>, Compact<TAssetBalance>]>;
|
forceCreate: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, owner: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, maxZombies: Compact<u32> | AnyNumber | Uint8Array, minBalance: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<u32>, Compact<TAssetBalance>]>;
|
||||||
/**
|
/**
|
||||||
* Destroy a class of fungible assets.
|
* Destroy a class of fungible assets.
|
||||||
*
|
*
|
||||||
@@ -144,7 +144,7 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* Modes: Pre-existence of `dest`; Post-existence of `source`; Prior & post zombie-status
|
* Modes: Pre-existence of `dest`; Post-existence of `source`; Prior & post zombie-status
|
||||||
* of `source`; Account pre-existence of `dest`.
|
* of `source`; Account pre-existence of `dest`.
|
||||||
**/
|
**/
|
||||||
forceTransfer: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, source: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, dest: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, amount: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, LookupSource, Compact<TAssetBalance>]>;
|
forceTransfer: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, source: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, dest: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, amount: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, LookupSource, Compact<TAssetBalance>]>;
|
||||||
/**
|
/**
|
||||||
* Disallow further unprivileged transfers from an account.
|
* Disallow further unprivileged transfers from an account.
|
||||||
*
|
*
|
||||||
@@ -157,7 +157,19 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
*
|
*
|
||||||
* Weight: `O(1)`
|
* Weight: `O(1)`
|
||||||
**/
|
**/
|
||||||
freeze: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, who: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource]>;
|
freeze: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, who: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource]>;
|
||||||
|
/**
|
||||||
|
* Disallow further unprivileged transfers for the asset class.
|
||||||
|
*
|
||||||
|
* Origin must be Signed and the sender should be the Freezer of the asset `id`.
|
||||||
|
*
|
||||||
|
* - `id`: The identifier of the asset to be frozen.
|
||||||
|
*
|
||||||
|
* Emits `Frozen`.
|
||||||
|
*
|
||||||
|
* Weight: `O(1)`
|
||||||
|
**/
|
||||||
|
freezeAsset: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>]>;
|
||||||
/**
|
/**
|
||||||
* Mint assets of a particular class.
|
* Mint assets of a particular class.
|
||||||
*
|
*
|
||||||
@@ -172,8 +184,47 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* Weight: `O(1)`
|
* Weight: `O(1)`
|
||||||
* Modes: Pre-existing balance of `beneficiary`; Account pre-existence of `beneficiary`.
|
* Modes: Pre-existing balance of `beneficiary`; Account pre-existence of `beneficiary`.
|
||||||
**/
|
**/
|
||||||
mint: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, beneficiary: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, amount: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<TAssetBalance>]>;
|
mint: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, beneficiary: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, amount: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<TAssetBalance>]>;
|
||||||
|
/**
|
||||||
|
* Set the maximum number of zombie accounts for an asset.
|
||||||
|
*
|
||||||
|
* Origin must be Signed and the sender should be the Owner of the asset `id`.
|
||||||
|
*
|
||||||
|
* Funds of sender are reserved according to the formula:
|
||||||
|
* `AssetDepositBase + AssetDepositPerZombie * max_zombies` taking into account
|
||||||
|
* any already reserved funds.
|
||||||
|
*
|
||||||
|
* - `id`: The identifier of the asset to update zombie count.
|
||||||
|
* - `max_zombies`: The new number of zombies allowed for this asset.
|
||||||
|
*
|
||||||
|
* Emits `MaxZombiesChanged`.
|
||||||
|
*
|
||||||
|
* Weight: `O(1)`
|
||||||
|
**/
|
||||||
setMaxZombies: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, maxZombies: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, Compact<u32>]>;
|
setMaxZombies: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, maxZombies: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, Compact<u32>]>;
|
||||||
|
/**
|
||||||
|
* Set the metadata for an asset.
|
||||||
|
*
|
||||||
|
* NOTE: There is no `unset_metadata` call. Simply pass an empty name, symbol,
|
||||||
|
* and 0 decimals to this function to remove the metadata of an asset and
|
||||||
|
* return your deposit.
|
||||||
|
*
|
||||||
|
* Origin must be Signed and the sender should be the Owner of the asset `id`.
|
||||||
|
*
|
||||||
|
* Funds of sender are reserved according to the formula:
|
||||||
|
* `MetadataDepositBase + MetadataDepositPerByte * (name.len + symbol.len)` taking into
|
||||||
|
* account any already reserved funds.
|
||||||
|
*
|
||||||
|
* - `id`: The identifier of the asset to update.
|
||||||
|
* - `name`: The user friendly name of this asset. Limited in length by `StringLimit`.
|
||||||
|
* - `symbol`: The exchange symbol for this asset. Limited in length by `StringLimit`.
|
||||||
|
* - `decimals`: The number of decimals this asset uses to represent one unit.
|
||||||
|
*
|
||||||
|
* Emits `MaxZombiesChanged`.
|
||||||
|
*
|
||||||
|
* Weight: `O(1)`
|
||||||
|
**/
|
||||||
|
setMetadata: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, name: Bytes | string | Uint8Array, symbol: Bytes | string | Uint8Array, decimals: u8 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, Bytes, Bytes, u8]>;
|
||||||
/**
|
/**
|
||||||
* Change the Issuer, Admin and Freezer of an asset.
|
* Change the Issuer, Admin and Freezer of an asset.
|
||||||
*
|
*
|
||||||
@@ -188,7 +239,7 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
*
|
*
|
||||||
* Weight: `O(1)`
|
* Weight: `O(1)`
|
||||||
**/
|
**/
|
||||||
setTeam: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, issuer: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, admin: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, freezer: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, LookupSource, LookupSource]>;
|
setTeam: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, issuer: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, admin: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, freezer: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, LookupSource, LookupSource]>;
|
||||||
/**
|
/**
|
||||||
* Allow unprivileged transfers from an account again.
|
* Allow unprivileged transfers from an account again.
|
||||||
*
|
*
|
||||||
@@ -201,7 +252,19 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
*
|
*
|
||||||
* Weight: `O(1)`
|
* Weight: `O(1)`
|
||||||
**/
|
**/
|
||||||
thaw: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, who: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource]>;
|
thaw: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, who: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource]>;
|
||||||
|
/**
|
||||||
|
* Allow unprivileged transfers for the asset again.
|
||||||
|
*
|
||||||
|
* Origin must be Signed and the sender should be the Admin of the asset `id`.
|
||||||
|
*
|
||||||
|
* - `id`: The identifier of the asset to be frozen.
|
||||||
|
*
|
||||||
|
* Emits `Thawed`.
|
||||||
|
*
|
||||||
|
* Weight: `O(1)`
|
||||||
|
**/
|
||||||
|
thawAsset: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>]>;
|
||||||
/**
|
/**
|
||||||
* Move some assets from the sender account to another.
|
* Move some assets from the sender account to another.
|
||||||
*
|
*
|
||||||
@@ -222,7 +285,7 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* Modes: Pre-existence of `target`; Post-existence of sender; Prior & post zombie-status
|
* Modes: Pre-existence of `target`; Post-existence of sender; Prior & post zombie-status
|
||||||
* of sender; Account pre-existence of `target`.
|
* of sender; Account pre-existence of `target`.
|
||||||
**/
|
**/
|
||||||
transfer: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, amount: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<TAssetBalance>]>;
|
transfer: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, target: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, amount: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<TAssetBalance>]>;
|
||||||
/**
|
/**
|
||||||
* Change the Owner of an asset.
|
* Change the Owner of an asset.
|
||||||
*
|
*
|
||||||
@@ -235,7 +298,7 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
*
|
*
|
||||||
* Weight: `O(1)`
|
* Weight: `O(1)`
|
||||||
**/
|
**/
|
||||||
transferOwnership: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, owner: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource]>;
|
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]>;
|
||||||
};
|
};
|
||||||
authorship: {
|
authorship: {
|
||||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||||
@@ -275,7 +338,7 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* not assumed to be in the overlay.
|
* not assumed to be in the overlay.
|
||||||
* # </weight>
|
* # </weight>
|
||||||
**/
|
**/
|
||||||
forceTransfer: AugmentedSubmittable<(source: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, dest: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, LookupSource, Compact<Balance>]>;
|
forceTransfer: AugmentedSubmittable<(source: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, dest: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, LookupSource, Compact<Balance>]>;
|
||||||
/**
|
/**
|
||||||
* Set the balances of a given account.
|
* Set the balances of a given account.
|
||||||
*
|
*
|
||||||
@@ -296,7 +359,7 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* - DB Weight: 1 Read, 1 Write to `who`
|
* - DB Weight: 1 Read, 1 Write to `who`
|
||||||
* # </weight>
|
* # </weight>
|
||||||
**/
|
**/
|
||||||
setBalance: AugmentedSubmittable<(who: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, newFree: Compact<Balance> | AnyNumber | Uint8Array, newReserved: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<Balance>, Compact<Balance>]>;
|
setBalance: AugmentedSubmittable<(who: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, newFree: Compact<Balance> | AnyNumber | Uint8Array, newReserved: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<Balance>, Compact<Balance>]>;
|
||||||
/**
|
/**
|
||||||
* Transfer some liquid free balance to another account.
|
* Transfer some liquid free balance to another account.
|
||||||
*
|
*
|
||||||
@@ -326,21 +389,21 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* - Origin account is already in memory, so no DB operations for them.
|
* - Origin account is already in memory, so no DB operations for them.
|
||||||
* # </weight>
|
* # </weight>
|
||||||
**/
|
**/
|
||||||
transfer: AugmentedSubmittable<(dest: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<Balance>]>;
|
transfer: 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>]>;
|
||||||
/**
|
/**
|
||||||
* Same as the [`transfer`] call, but with a check that the transfer will not kill the
|
* Same as the [`transfer`] call, but with a check that the transfer will not kill the
|
||||||
* origin account.
|
* origin account.
|
||||||
*
|
*
|
||||||
* 99% of the time you want [`transfer`] instead.
|
* 99% of the time you want [`transfer`] instead.
|
||||||
*
|
*
|
||||||
* [`transfer`]: struct.Module.html#method.transfer
|
* [`transfer`]: struct.Pallet.html#method.transfer
|
||||||
* # <weight>
|
* # <weight>
|
||||||
* - Cheaper than transfer because account cannot be killed.
|
* - Cheaper than transfer because account cannot be killed.
|
||||||
* - Base Weight: 51.4 µs
|
* - Base Weight: 51.4 µs
|
||||||
* - DB Weight: 1 Read and 1 Write to dest (sender is in overlay already)
|
* - DB Weight: 1 Read and 1 Write to dest (sender is in overlay already)
|
||||||
* #</weight>
|
* #</weight>
|
||||||
**/
|
**/
|
||||||
transferKeepAlive: AugmentedSubmittable<(dest: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<Balance>]>;
|
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>]>;
|
||||||
};
|
};
|
||||||
bounties: {
|
bounties: {
|
||||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||||
@@ -378,7 +441,7 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* - O(1).
|
* - O(1).
|
||||||
* # </weight>
|
* # </weight>
|
||||||
**/
|
**/
|
||||||
awardBounty: AugmentedSubmittable<(bountyId: Compact<BountyIndex> | AnyNumber | Uint8Array, beneficiary: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BountyIndex>, LookupSource]>;
|
awardBounty: AugmentedSubmittable<(bountyId: Compact<BountyIndex> | AnyNumber | Uint8Array, beneficiary: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BountyIndex>, LookupSource]>;
|
||||||
/**
|
/**
|
||||||
* Claim the payout from an awarded bounty after payout delay.
|
* Claim the payout from an awarded bounty after payout delay.
|
||||||
*
|
*
|
||||||
@@ -441,7 +504,7 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* - O(1).
|
* - O(1).
|
||||||
* # </weight>
|
* # </weight>
|
||||||
**/
|
**/
|
||||||
proposeCurator: AugmentedSubmittable<(bountyId: Compact<BountyIndex> | AnyNumber | Uint8Array, curator: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, fee: Compact<BalanceOf> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BountyIndex>, LookupSource, Compact<BalanceOf>]>;
|
proposeCurator: AugmentedSubmittable<(bountyId: Compact<BountyIndex> | AnyNumber | Uint8Array, curator: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, fee: Compact<BalanceOf> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BountyIndex>, LookupSource, Compact<BalanceOf>]>;
|
||||||
/**
|
/**
|
||||||
* Unassign curator from a bounty.
|
* Unassign curator from a bounty.
|
||||||
*
|
*
|
||||||
@@ -475,36 +538,51 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* * If no account exists and the call value is not less than `existential_deposit`,
|
* * If no account exists and the call value is not less than `existential_deposit`,
|
||||||
* a regular account will be created and any value will be transferred.
|
* a regular account will be created and any value will be transferred.
|
||||||
**/
|
**/
|
||||||
call: AugmentedSubmittable<(dest: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, value: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Gas> | AnyNumber | Uint8Array, data: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<BalanceOf>, Compact<Gas>, Bytes]>;
|
call: AugmentedSubmittable<(dest: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, value: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Weight> | AnyNumber | Uint8Array, data: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<BalanceOf>, Compact<Weight>, Bytes]>;
|
||||||
/**
|
/**
|
||||||
* Allows block producers to claim a small reward for evicting a contract. If a block producer
|
* Allows block producers to claim a small reward for evicting a contract. If a block
|
||||||
* fails to do so, a regular users will be allowed to claim the reward.
|
* producer fails to do so, a regular users will be allowed to claim the reward.
|
||||||
*
|
*
|
||||||
* If contract is not evicted as a result of this call, no actions are taken and
|
* In case of a successful eviction no fees are charged from the sender. However, the
|
||||||
* the sender is not eligible for the reward.
|
* reward is capped by the total amount of rent that was payed by the contract while
|
||||||
|
* it was alive.
|
||||||
|
*
|
||||||
|
* If contract is not evicted as a result of this call, [`Error::ContractNotEvictable`]
|
||||||
|
* is returned and the sender is not eligible for the reward.
|
||||||
**/
|
**/
|
||||||
claimSurcharge: AugmentedSubmittable<(dest: AccountId | string | Uint8Array, auxSender: Option<AccountId> | null | object | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId, Option<AccountId>]>;
|
claimSurcharge: AugmentedSubmittable<(dest: AccountId | string | Uint8Array, auxSender: Option<AccountId> | null | object | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId, Option<AccountId>]>;
|
||||||
/**
|
/**
|
||||||
* Instantiates a new contract from the `code_hash` generated by `put_code`,
|
* Instantiates a contract from a previously deployed wasm binary.
|
||||||
* optionally transferring some balance.
|
|
||||||
*
|
*
|
||||||
* The supplied `salt` is used for contract address deriviation. See `fn contract_address`.
|
* This function is identical to [`Self::instantiate_with_code`] but without the
|
||||||
|
* code deployment step. Instead, the `code_hash` of an on-chain deployed wasm binary
|
||||||
|
* must be supplied.
|
||||||
|
**/
|
||||||
|
instantiate: AugmentedSubmittable<(endowment: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Weight> | AnyNumber | Uint8Array, codeHash: CodeHash | string | Uint8Array, data: Bytes | string | Uint8Array, salt: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BalanceOf>, Compact<Weight>, CodeHash, Bytes, Bytes]>;
|
||||||
|
/**
|
||||||
|
* Instantiates a new contract from the supplied `code` optionally transferring
|
||||||
|
* some balance.
|
||||||
|
*
|
||||||
|
* This is the only function that can deploy new code to the chain.
|
||||||
|
*
|
||||||
|
* # Parameters
|
||||||
|
*
|
||||||
|
* * `endowment`: The balance to transfer from the `origin` to the newly created contract.
|
||||||
|
* * `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`].
|
||||||
*
|
*
|
||||||
* Instantiation is executed as follows:
|
* Instantiation is executed as follows:
|
||||||
*
|
*
|
||||||
|
* - The supplied `code` is instrumented, deployed, and a `code_hash` is created for that code.
|
||||||
|
* - If the `code_hash` already exists on the chain the underlying `code` will be shared.
|
||||||
* - The destination address is computed based on the sender, code_hash and the salt.
|
* - The destination address is computed based on the sender, code_hash and the salt.
|
||||||
* - The smart-contract account is created at the computed address.
|
* - The smart-contract account is created at the computed address.
|
||||||
* - The `ctor_code` is executed in the context of the newly-created account. Buffer returned
|
* - The `endowment` is transferred to the new account.
|
||||||
* after the execution is saved as the `code` of the account. That code will be invoked
|
* - The `deploy` function is executed in the context of the newly-created account.
|
||||||
* upon any call received by this account.
|
|
||||||
* - The contract is initialized.
|
|
||||||
**/
|
**/
|
||||||
instantiate: AugmentedSubmittable<(endowment: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Gas> | AnyNumber | Uint8Array, codeHash: CodeHash | string | Uint8Array, data: Bytes | string | Uint8Array, salt: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BalanceOf>, Compact<Gas>, CodeHash, Bytes, Bytes]>;
|
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]>;
|
||||||
/**
|
|
||||||
* Stores the given binary Wasm code into the chain's storage and returns its `codehash`.
|
|
||||||
* You can instantiate contracts only with stored code.
|
|
||||||
**/
|
|
||||||
putCode: AugmentedSubmittable<(code: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Bytes]>;
|
|
||||||
/**
|
/**
|
||||||
* Updates the schedule for metering contracts.
|
* Updates the schedule for metering contracts.
|
||||||
*
|
*
|
||||||
@@ -984,8 +1062,41 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
**/
|
**/
|
||||||
vote: AugmentedSubmittable<(refIndex: Compact<ReferendumIndex> | AnyNumber | Uint8Array, vote: AccountVote | { Standard: any } | { Split: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ReferendumIndex>, AccountVote]>;
|
vote: AugmentedSubmittable<(refIndex: Compact<ReferendumIndex> | AnyNumber | Uint8Array, vote: AccountVote | { Standard: any } | { Split: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ReferendumIndex>, AccountVote]>;
|
||||||
};
|
};
|
||||||
|
electionProviderMultiPhase: {
|
||||||
|
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||||
|
/**
|
||||||
|
* Submit a solution for the unsigned phase.
|
||||||
|
*
|
||||||
|
* The dispatch origin fo this call must be __none__.
|
||||||
|
*
|
||||||
|
* This submission is checked on the fly. Moreover, this unsigned solution is only
|
||||||
|
* validated when submitted to the pool from the **local** node. Effectively, this means
|
||||||
|
* that only active validators can submit this transaction when authoring a block (similar
|
||||||
|
* to an inherent).
|
||||||
|
*
|
||||||
|
* To prevent any incorrect solution (and thus wasted time/weight), this transaction will
|
||||||
|
* panic if the solution submitted by the validator is invalid in any way, effectively
|
||||||
|
* putting their authoring reward at risk.
|
||||||
|
*
|
||||||
|
* 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]>;
|
||||||
|
};
|
||||||
elections: {
|
elections: {
|
||||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
[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.
|
||||||
|
*
|
||||||
|
* This is an root function to be used only for cleaning the state.
|
||||||
|
*
|
||||||
|
* The dispatch origin of this call must be root.
|
||||||
|
*
|
||||||
|
* # <weight>
|
||||||
|
* The total number of voters and those that are defunct must be provided as witness data.
|
||||||
|
* # </weight>
|
||||||
|
**/
|
||||||
|
cleanDefunctVoters: AugmentedSubmittable<(numVoters: u32 | AnyNumber | Uint8Array, numDefunct: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32]>;
|
||||||
/**
|
/**
|
||||||
* Remove a particular member from the set. This is effective immediately and the bond of
|
* Remove a particular member from the set. This is effective immediately and the bond of
|
||||||
* the outgoing member is slashed.
|
* the outgoing member is slashed.
|
||||||
@@ -993,125 +1104,59 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* If a runner-up is available, then the best runner-up will be removed and replaces the
|
* If a runner-up is available, then the best runner-up will be removed and replaces the
|
||||||
* outgoing member. Otherwise, a new phragmen election is started.
|
* outgoing member. Otherwise, a new phragmen election is started.
|
||||||
*
|
*
|
||||||
|
* The dispatch origin of this call must be root.
|
||||||
|
*
|
||||||
* Note that this does not affect the designated block number of the next election.
|
* Note that this does not affect the designated block number of the next election.
|
||||||
*
|
*
|
||||||
* # <weight>
|
* # <weight>
|
||||||
* If we have a replacement:
|
* If we have a replacement, we use a small weight. Else, since this is a root call and
|
||||||
* - Base weight: 50.93 µs
|
* will go into phragmen, we assume full block for now.
|
||||||
* - State reads:
|
|
||||||
* - RunnersUp.len()
|
|
||||||
* - Members, RunnersUp (remove_and_replace_member)
|
|
||||||
* - State writes:
|
|
||||||
* - Members, RunnersUp (remove_and_replace_member)
|
|
||||||
* Else, since this is a root call and will go into phragmen, we assume full block for now.
|
|
||||||
* # </weight>
|
* # </weight>
|
||||||
**/
|
**/
|
||||||
removeMember: AugmentedSubmittable<(who: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, hasReplacement: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, bool]>;
|
removeMember: AugmentedSubmittable<(who: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, hasReplacement: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, bool]>;
|
||||||
/**
|
/**
|
||||||
* Remove `origin` as a voter. This removes the lock and returns the bond.
|
* Remove `origin` as a voter.
|
||||||
*
|
*
|
||||||
* # <weight>
|
* This removes the lock and returns the deposit.
|
||||||
* Base weight: 36.8 µs
|
*
|
||||||
* All state access is from do_remove_voter.
|
* The dispatch origin of this call must be signed and be a voter.
|
||||||
* State reads:
|
|
||||||
* - Voting
|
|
||||||
* - [AccountData(who)]
|
|
||||||
* State writes:
|
|
||||||
* - Voting
|
|
||||||
* - Locks
|
|
||||||
* - [AccountData(who)]
|
|
||||||
* # </weight>
|
|
||||||
**/
|
**/
|
||||||
removeVoter: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
|
removeVoter: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
|
||||||
/**
|
/**
|
||||||
* Renounce one's intention to be a candidate for the next election round. 3 potential
|
* Renounce one's intention to be a candidate for the next election round. 3 potential
|
||||||
* outcomes exist:
|
* outcomes exist:
|
||||||
* - `origin` is a candidate and not elected in any set. In this case, the bond is
|
*
|
||||||
|
* - `origin` is a candidate and not elected in any set. In this case, the deposit is
|
||||||
* unreserved, returned and origin is removed as a candidate.
|
* unreserved, returned and origin is removed as a candidate.
|
||||||
* - `origin` is a current runner-up. In this case, the bond is unreserved, returned and
|
* - `origin` is a current runner-up. In this case, the deposit is unreserved, returned and
|
||||||
* origin is removed as a runner-up.
|
* origin is removed as a runner-up.
|
||||||
* - `origin` is a current member. In this case, the bond is unreserved and origin is
|
* - `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.
|
* removed as a member, consequently not being a candidate for the next round anymore.
|
||||||
* Similar to [`remove_voter`], if replacement runners exists, they are immediately used.
|
* Similar to [`remove_members`], if replacement runners exists, they are immediately used.
|
||||||
* <weight>
|
* If the prime is renouncing, then no prime will exist until the next round.
|
||||||
* If a candidate is renouncing:
|
*
|
||||||
* Base weight: 17.28 µs
|
* The dispatch origin of this call must be signed, and have one of the above roles.
|
||||||
* Complexity of candidate_count: 0.235 µs
|
*
|
||||||
* State reads:
|
* # <weight>
|
||||||
* - Candidates
|
* The type of renouncing must be provided as witness data.
|
||||||
* - [AccountBalance(who) (unreserve)]
|
* # </weight>
|
||||||
* State writes:
|
|
||||||
* - Candidates
|
|
||||||
* - [AccountBalance(who) (unreserve)]
|
|
||||||
* If member is renouncing:
|
|
||||||
* Base weight: 46.25 µs
|
|
||||||
* State reads:
|
|
||||||
* - Members, RunnersUp (remove_and_replace_member),
|
|
||||||
* - [AccountData(who) (unreserve)]
|
|
||||||
* State writes:
|
|
||||||
* - Members, RunnersUp (remove_and_replace_member),
|
|
||||||
* - [AccountData(who) (unreserve)]
|
|
||||||
* If runner is renouncing:
|
|
||||||
* Base weight: 46.25 µs
|
|
||||||
* State reads:
|
|
||||||
* - RunnersUp (remove_and_replace_member),
|
|
||||||
* - [AccountData(who) (unreserve)]
|
|
||||||
* State writes:
|
|
||||||
* - RunnersUp (remove_and_replace_member),
|
|
||||||
* - [AccountData(who) (unreserve)]
|
|
||||||
* </weight>
|
|
||||||
**/
|
**/
|
||||||
renounceCandidacy: AugmentedSubmittable<(renouncing: Renouncing | { Member: any } | { RunnerUp: any } | { Candidate: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Renouncing]>;
|
renounceCandidacy: AugmentedSubmittable<(renouncing: Renouncing | { Member: any } | { RunnerUp: any } | { Candidate: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Renouncing]>;
|
||||||
/**
|
/**
|
||||||
* Report `target` for being an defunct voter. In case of a valid report, the reporter is
|
* Submit oneself for candidacy. A fixed amount of deposit is recorded.
|
||||||
* rewarded by the bond amount of `target`. Otherwise, the reporter itself is removed and
|
|
||||||
* their bond is slashed.
|
|
||||||
*
|
*
|
||||||
* A defunct voter is defined to be:
|
* All candidates are wiped at the end of the term. They either become a member/runner-up,
|
||||||
* - a voter whose current submitted votes are all invalid. i.e. all of them are no
|
* or leave the system while their deposit is slashed.
|
||||||
* longer a candidate nor an active member or a runner-up.
|
|
||||||
*
|
*
|
||||||
|
* The dispatch origin of this call must be signed.
|
||||||
*
|
*
|
||||||
* The origin must provide the number of current candidates and votes of the reported target
|
* ### Warning
|
||||||
* for the purpose of accurate weight calculation.
|
*
|
||||||
|
* Even if a candidate ends up being a member, they must call [`Call::renounce_candidacy`]
|
||||||
|
* to get their deposit back. Losing the spot in an election will always lead to a slash.
|
||||||
*
|
*
|
||||||
* # <weight>
|
* # <weight>
|
||||||
* No Base weight based on min square analysis.
|
* The number of current candidates must be provided as witness data.
|
||||||
* Complexity of candidate_count: 1.755 µs
|
|
||||||
* Complexity of vote_count: 18.51 µs
|
|
||||||
* State reads:
|
|
||||||
* - Voting(reporter)
|
|
||||||
* - Candidate.len()
|
|
||||||
* - Voting(Target)
|
|
||||||
* - Candidates, Members, RunnersUp (is_defunct_voter)
|
|
||||||
* State writes:
|
|
||||||
* - Lock(reporter || target)
|
|
||||||
* - [AccountBalance(reporter)] + AccountBalance(target)
|
|
||||||
* - Voting(reporter || target)
|
|
||||||
* Note: the db access is worse with respect to db, which is when the report is correct.
|
|
||||||
* # </weight>
|
|
||||||
**/
|
|
||||||
reportDefunctVoter: AugmentedSubmittable<(defunct: DefunctVoter | { who?: any; voteCount?: any; candidateCount?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [DefunctVoter]>;
|
|
||||||
/**
|
|
||||||
* Submit oneself for candidacy.
|
|
||||||
*
|
|
||||||
* A candidate will either:
|
|
||||||
* - Lose at the end of the term and forfeit their deposit.
|
|
||||||
* - Win and become a member. Members will eventually get their stash back.
|
|
||||||
* - Become a runner-up. Runners-ups are reserved members in case one gets forcefully
|
|
||||||
* removed.
|
|
||||||
*
|
|
||||||
* # <weight>
|
|
||||||
* Base weight = 33.33 µs
|
|
||||||
* Complexity of candidate_count: 0.375 µs
|
|
||||||
* State reads:
|
|
||||||
* - Candidates
|
|
||||||
* - Members
|
|
||||||
* - RunnersUp
|
|
||||||
* - [AccountBalance(who)]
|
|
||||||
* State writes:
|
|
||||||
* - [AccountBalance(who)]
|
|
||||||
* - Candidates
|
|
||||||
* # </weight>
|
* # </weight>
|
||||||
**/
|
**/
|
||||||
submitCandidacy: AugmentedSubmittable<(candidateCount: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<u32>]>;
|
submitCandidacy: AugmentedSubmittable<(candidateCount: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<u32>]>;
|
||||||
@@ -1119,28 +1164,25 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* Vote for a set of candidates for the upcoming round of election. This can be called to
|
* Vote for a set of candidates for the upcoming round of election. This can be called to
|
||||||
* set the initial votes, or update already existing votes.
|
* set the initial votes, or update already existing votes.
|
||||||
*
|
*
|
||||||
* Upon initial voting, `value` units of `who`'s balance is locked and a bond amount is
|
* Upon initial voting, `value` units of `who`'s balance is locked and a deposit amount is
|
||||||
* reserved.
|
* reserved. The deposit is based on the number of votes and can be updated over time.
|
||||||
*
|
*
|
||||||
* The `votes` should:
|
* The `votes` should:
|
||||||
* - not be empty.
|
* - not be empty.
|
||||||
* - be less than the number of possible candidates. Note that all current members and
|
* - be less than the number of possible candidates. Note that all current members and
|
||||||
* runners-up are also automatically candidates for the next round.
|
* runners-up are also automatically candidates for the next round.
|
||||||
*
|
*
|
||||||
* It is the responsibility of the caller to not place all of their balance into the lock
|
* If `value` is more than `who`'s total balance, then the maximum of the two is used.
|
||||||
* and keep some for further transactions.
|
*
|
||||||
|
* The dispatch origin of this call must be signed.
|
||||||
|
*
|
||||||
|
* ### Warning
|
||||||
|
*
|
||||||
|
* It is the responsibility of the caller to **NOT** place all of their balance into the
|
||||||
|
* lock and keep some for further operations.
|
||||||
*
|
*
|
||||||
* # <weight>
|
* # <weight>
|
||||||
* Base weight: 47.93 µs
|
* We assume the maximum weight among all 3 cases: vote_equal, vote_more and vote_less.
|
||||||
* State reads:
|
|
||||||
* - Candidates.len() + Members.len() + RunnersUp.len()
|
|
||||||
* - Voting (is_voter)
|
|
||||||
* - Lock
|
|
||||||
* - [AccountBalance(who) (unreserve + total_balance)]
|
|
||||||
* State writes:
|
|
||||||
* - Voting
|
|
||||||
* - Lock
|
|
||||||
* - [AccountBalance(who) (unreserve -- only when creating a new voter)]
|
|
||||||
* # </weight>
|
* # </weight>
|
||||||
**/
|
**/
|
||||||
vote: AugmentedSubmittable<(votes: Vec<AccountId> | (AccountId | string | Uint8Array)[], value: Compact<BalanceOf> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Vec<AccountId>, Compact<BalanceOf>]>;
|
vote: AugmentedSubmittable<(votes: Vec<AccountId> | (AccountId | string | Uint8Array)[], value: Compact<BalanceOf> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Vec<AccountId>, Compact<BalanceOf>]>;
|
||||||
@@ -1204,7 +1246,7 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* The dispatch origin for this call must be _Signed_ and the sender must have a registered
|
* The dispatch origin for this call must be _Signed_ and the sender must have a registered
|
||||||
* sub identity of `sub`.
|
* sub identity of `sub`.
|
||||||
**/
|
**/
|
||||||
addSub: AugmentedSubmittable<(sub: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, data: Data | { None: any } | { Raw: any } | { BlakeTwo256: any } | { Sha256: any } | { Keccak256: any } | { ShaThree256: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Data]>;
|
addSub: AugmentedSubmittable<(sub: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, data: Data | { None: any } | { Raw: any } | { BlakeTwo256: any } | { Sha256: any } | { Keccak256: any } | { ShaThree256: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Data]>;
|
||||||
/**
|
/**
|
||||||
* Cancel a previous request.
|
* Cancel a previous request.
|
||||||
*
|
*
|
||||||
@@ -1267,7 +1309,7 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* - One event.
|
* - One event.
|
||||||
* # </weight>
|
* # </weight>
|
||||||
**/
|
**/
|
||||||
killIdentity: AugmentedSubmittable<(target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>;
|
killIdentity: AugmentedSubmittable<(target: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>;
|
||||||
/**
|
/**
|
||||||
* Provide a judgement for an account's identity.
|
* Provide a judgement for an account's identity.
|
||||||
*
|
*
|
||||||
@@ -1289,7 +1331,7 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* - One event.
|
* - One event.
|
||||||
* # </weight>
|
* # </weight>
|
||||||
**/
|
**/
|
||||||
provideJudgement: AugmentedSubmittable<(regIndex: Compact<RegistrarIndex> | AnyNumber | Uint8Array, target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, judgement: IdentityJudgement | { Unknown: any } | { FeePaid: any } | { Reasonable: any } | { KnownGood: any } | { OutOfDate: any } | { LowQuality: any } | { Erroneous: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<RegistrarIndex>, LookupSource, IdentityJudgement]>;
|
provideJudgement: AugmentedSubmittable<(regIndex: Compact<RegistrarIndex> | AnyNumber | Uint8Array, target: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, judgement: IdentityJudgement | { Unknown: any } | { FeePaid: any } | { Reasonable: any } | { KnownGood: any } | { OutOfDate: any } | { LowQuality: any } | { Erroneous: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<RegistrarIndex>, LookupSource, IdentityJudgement]>;
|
||||||
/**
|
/**
|
||||||
* Remove the sender as a sub-account.
|
* Remove the sender as a sub-account.
|
||||||
*
|
*
|
||||||
@@ -1312,14 +1354,14 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* The dispatch origin for this call must be _Signed_ and the sender must have a registered
|
* The dispatch origin for this call must be _Signed_ and the sender must have a registered
|
||||||
* sub identity of `sub`.
|
* sub identity of `sub`.
|
||||||
**/
|
**/
|
||||||
removeSub: AugmentedSubmittable<(sub: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>;
|
removeSub: AugmentedSubmittable<(sub: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>;
|
||||||
/**
|
/**
|
||||||
* Alter the associated name of the given sub-account.
|
* Alter the associated name of the given sub-account.
|
||||||
*
|
*
|
||||||
* The dispatch origin for this call must be _Signed_ and the sender must have a registered
|
* The dispatch origin for this call must be _Signed_ and the sender must have a registered
|
||||||
* sub identity of `sub`.
|
* sub identity of `sub`.
|
||||||
**/
|
**/
|
||||||
renameSub: AugmentedSubmittable<(sub: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, data: Data | { None: any } | { Raw: any } | { BlakeTwo256: any } | { Sha256: any } | { Keccak256: any } | { ShaThree256: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Data]>;
|
renameSub: AugmentedSubmittable<(sub: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, data: Data | { None: any } | { Raw: any } | { BlakeTwo256: any } | { Sha256: any } | { Keccak256: any } | { ShaThree256: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Data]>;
|
||||||
/**
|
/**
|
||||||
* Request a judgement from a registrar.
|
* Request a judgement from a registrar.
|
||||||
*
|
*
|
||||||
@@ -1568,6 +1610,52 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
**/
|
**/
|
||||||
transfer: AugmentedSubmittable<(updated: AccountId | string | Uint8Array, index: AccountIndex | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId, AccountIndex]>;
|
transfer: AugmentedSubmittable<(updated: AccountId | string | Uint8Array, index: AccountIndex | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId, AccountIndex]>;
|
||||||
};
|
};
|
||||||
|
lottery: {
|
||||||
|
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||||
|
/**
|
||||||
|
* Buy a ticket to enter the lottery.
|
||||||
|
*
|
||||||
|
* This extrinsic acts as a passthrough function for `call`. In all
|
||||||
|
* situations where `call` alone would succeed, this extrinsic should
|
||||||
|
* succeed.
|
||||||
|
*
|
||||||
|
* If `call` is successful, then we will attempt to purchase a ticket,
|
||||||
|
* which may fail silently. To detect success of a ticket purchase, you
|
||||||
|
* should listen for the `TicketBought` event.
|
||||||
|
*
|
||||||
|
* This extrinsic must be called by a signed origin.
|
||||||
|
**/
|
||||||
|
buyTicket: AugmentedSubmittable<(call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Call]>;
|
||||||
|
/**
|
||||||
|
* Set calls in storage which can be used to purchase a lottery ticket.
|
||||||
|
*
|
||||||
|
* This function only matters if you use the `ValidateCall` implementation
|
||||||
|
* provided by this pallet, which uses storage to determine the valid calls.
|
||||||
|
*
|
||||||
|
* This extrinsic must be called by the Manager origin.
|
||||||
|
**/
|
||||||
|
setCalls: AugmentedSubmittable<(calls: Vec<Call> | (Call | { callIndex?: any; args?: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [Vec<Call>]>;
|
||||||
|
/**
|
||||||
|
* Start a lottery using the provided configuration.
|
||||||
|
*
|
||||||
|
* This extrinsic must be called by the `ManagerOrigin`.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
*
|
||||||
|
* * `price`: The cost of a single ticket.
|
||||||
|
* * `length`: How long the lottery should run for starting at the current block.
|
||||||
|
* * `delay`: How long after the lottery end we should wait before picking a winner.
|
||||||
|
* * `repeat`: If the lottery should repeat when completed.
|
||||||
|
**/
|
||||||
|
startLottery: AugmentedSubmittable<(price: BalanceOf | AnyNumber | Uint8Array, length: BlockNumber | AnyNumber | Uint8Array, delay: BlockNumber | AnyNumber | Uint8Array, repeat: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [BalanceOf, BlockNumber, BlockNumber, bool]>;
|
||||||
|
/**
|
||||||
|
* If a lottery is repeating, you can use this to stop the repeat.
|
||||||
|
* The lottery will continue to run to completion.
|
||||||
|
*
|
||||||
|
* This extrinsic must be called by the `ManagerOrigin`.
|
||||||
|
**/
|
||||||
|
stopRepeat: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
|
||||||
|
};
|
||||||
multisig: {
|
multisig: {
|
||||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||||
/**
|
/**
|
||||||
@@ -2481,7 +2569,7 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* Total Complexity: O(M + logM + C)
|
* Total Complexity: O(M + logM + C)
|
||||||
* # </weight>
|
* # </weight>
|
||||||
**/
|
**/
|
||||||
vote: AugmentedSubmittable<(candidate: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, approve: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, bool]>;
|
vote: AugmentedSubmittable<(candidate: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, approve: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, bool]>;
|
||||||
/**
|
/**
|
||||||
* As a member, vouch for someone to join society by placing a bid on their behalf.
|
* As a member, vouch for someone to join society by placing a bid on their behalf.
|
||||||
*
|
*
|
||||||
@@ -2556,7 +2644,7 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* - Write: Bonded, Payee, [Origin Account], Locks, Ledger
|
* - Write: Bonded, Payee, [Origin Account], Locks, Ledger
|
||||||
* # </weight>
|
* # </weight>
|
||||||
**/
|
**/
|
||||||
bond: AugmentedSubmittable<(controller: LookupSource | Address | AccountId | AccountIndex | 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 } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<BalanceOf>, RewardDestination]>;
|
||||||
/**
|
/**
|
||||||
* Add some extra amount that have appeared in the stash `free_balance` into the balance up
|
* Add some extra amount that have appeared in the stash `free_balance` into the balance up
|
||||||
* for staking.
|
* for staking.
|
||||||
@@ -2676,6 +2764,22 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* # </weight>
|
* # </weight>
|
||||||
**/
|
**/
|
||||||
increaseValidatorCount: AugmentedSubmittable<(additional: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<u32>]>;
|
increaseValidatorCount: AugmentedSubmittable<(additional: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<u32>]>;
|
||||||
|
/**
|
||||||
|
* Remove the given nominations from the calling validator.
|
||||||
|
*
|
||||||
|
* Effects will be felt at the beginning of the next era.
|
||||||
|
*
|
||||||
|
* The dispatch origin for this call must be _Signed_ by the controller, not the stash.
|
||||||
|
* And, it can be only called when [`EraElectionStatus`] is `Closed`. The controller
|
||||||
|
* account should represent a validator.
|
||||||
|
*
|
||||||
|
* - `who`: A list of nominator stash accounts who are nominating this validator which
|
||||||
|
* should no longer be nominating this validator.
|
||||||
|
*
|
||||||
|
* Note: Making this call only makes sense if you first set the validator preferences to
|
||||||
|
* block any further nominations.
|
||||||
|
**/
|
||||||
|
kick: AugmentedSubmittable<(who: Vec<LookupSource> | (LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [Vec<LookupSource>]>;
|
||||||
/**
|
/**
|
||||||
* Declare the desire to nominate `targets` for the origin controller.
|
* Declare the desire to nominate `targets` for the origin controller.
|
||||||
*
|
*
|
||||||
@@ -2697,7 +2801,7 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* - Writes: Validators, Nominators
|
* - Writes: Validators, Nominators
|
||||||
* # </weight>
|
* # </weight>
|
||||||
**/
|
**/
|
||||||
nominate: AugmentedSubmittable<(targets: Vec<LookupSource> | (LookupSource | Address | AccountId | AccountIndex | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [Vec<LookupSource>]>;
|
nominate: AugmentedSubmittable<(targets: Vec<LookupSource> | (LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [Vec<LookupSource>]>;
|
||||||
/**
|
/**
|
||||||
* Pay out all the stakers behind a single validator for a single era.
|
* Pay out all the stakers behind a single validator for a single era.
|
||||||
*
|
*
|
||||||
@@ -2730,9 +2834,9 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
**/
|
**/
|
||||||
payoutStakers: AugmentedSubmittable<(validatorStash: AccountId | string | Uint8Array, era: EraIndex | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId, EraIndex]>;
|
payoutStakers: AugmentedSubmittable<(validatorStash: AccountId | string | Uint8Array, era: EraIndex | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId, EraIndex]>;
|
||||||
/**
|
/**
|
||||||
* Remove all data structure concerning a staker/stash once its balance is zero.
|
* Remove all data structure concerning a staker/stash once its balance is at the minimum.
|
||||||
* This is essentially equivalent to `withdraw_unbonded` except it can be called by anyone
|
* This is essentially equivalent to `withdraw_unbonded` except it can be called by anyone
|
||||||
* and the target `stash` must have no funds left.
|
* and the target `stash` must have no funds left beyond the ED.
|
||||||
*
|
*
|
||||||
* This can be called from any origin.
|
* This can be called from any origin.
|
||||||
*
|
*
|
||||||
@@ -2792,7 +2896,7 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* - Write: Bonded, Ledger New Controller, Ledger Old Controller
|
* - Write: Bonded, Ledger New Controller, Ledger Old Controller
|
||||||
* # </weight>
|
* # </weight>
|
||||||
**/
|
**/
|
||||||
setController: AugmentedSubmittable<(controller: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>;
|
setController: AugmentedSubmittable<(controller: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>;
|
||||||
/**
|
/**
|
||||||
* Set `HistoryDepth` value. This function will delete any history information
|
* Set `HistoryDepth` value. This function will delete any history information
|
||||||
* when `HistoryDepth` is reduced.
|
* when `HistoryDepth` is reduced.
|
||||||
@@ -3025,7 +3129,7 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* - One DB change.
|
* - One DB change.
|
||||||
* # </weight>
|
* # </weight>
|
||||||
**/
|
**/
|
||||||
setKey: AugmentedSubmittable<(updated: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>;
|
setKey: AugmentedSubmittable<(updated: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>;
|
||||||
/**
|
/**
|
||||||
* Authenticates the sudo key and dispatches a function call with `Root` origin.
|
* Authenticates the sudo key and dispatches a function call with `Root` origin.
|
||||||
*
|
*
|
||||||
@@ -3052,7 +3156,7 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* - Weight of derivative `call` execution + 10,000.
|
* - Weight of derivative `call` execution + 10,000.
|
||||||
* # </weight>
|
* # </weight>
|
||||||
**/
|
**/
|
||||||
sudoAs: AugmentedSubmittable<(who: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Call]>;
|
sudoAs: AugmentedSubmittable<(who: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Call]>;
|
||||||
/**
|
/**
|
||||||
* Authenticates the sudo key and dispatches a function call with `Root` origin.
|
* Authenticates the sudo key and dispatches a function call with `Root` origin.
|
||||||
* This function does not check the weight of the call, and instead allows the
|
* This function does not check the weight of the call, and instead allows the
|
||||||
@@ -3167,19 +3271,6 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* # </weight>
|
* # </weight>
|
||||||
**/
|
**/
|
||||||
setStorage: AugmentedSubmittable<(items: Vec<KeyValue> | (KeyValue)[]) => SubmittableExtrinsic<ApiType>, [Vec<KeyValue>]>;
|
setStorage: AugmentedSubmittable<(items: Vec<KeyValue> | (KeyValue)[]) => SubmittableExtrinsic<ApiType>, [Vec<KeyValue>]>;
|
||||||
/**
|
|
||||||
* Kill the sending account, assuming there are no references outstanding and the composite
|
|
||||||
* data is equal to its default value.
|
|
||||||
*
|
|
||||||
* # <weight>
|
|
||||||
* - `O(1)`
|
|
||||||
* - 1 storage read and deletion.
|
|
||||||
* --------------------
|
|
||||||
* Base Weight: 8.626 µs
|
|
||||||
* No DB Read or Write operations because caller is already in overlay
|
|
||||||
* # </weight>
|
|
||||||
**/
|
|
||||||
suicide: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
|
|
||||||
};
|
};
|
||||||
technicalCommittee: {
|
technicalCommittee: {
|
||||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||||
@@ -3552,7 +3643,7 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* - DbWrites: `ProposalCount`, `Proposals`, `origin account`
|
* - DbWrites: `ProposalCount`, `Proposals`, `origin account`
|
||||||
* # </weight>
|
* # </weight>
|
||||||
**/
|
**/
|
||||||
proposeSpend: AugmentedSubmittable<(value: Compact<BalanceOf> | AnyNumber | Uint8Array, beneficiary: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BalanceOf>, LookupSource]>;
|
proposeSpend: AugmentedSubmittable<(value: Compact<BalanceOf> | AnyNumber | Uint8Array, beneficiary: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BalanceOf>, LookupSource]>;
|
||||||
/**
|
/**
|
||||||
* Reject a proposed spend. The original deposit will be slashed.
|
* Reject a proposed spend. The original deposit will be slashed.
|
||||||
*
|
*
|
||||||
@@ -3643,7 +3734,7 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* - Writes: Vesting Storage, Balances Locks, Target Account, Source Account
|
* - Writes: Vesting Storage, Balances Locks, Target Account, Source Account
|
||||||
* # </weight>
|
* # </weight>
|
||||||
**/
|
**/
|
||||||
forceVestedTransfer: AugmentedSubmittable<(source: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, schedule: VestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, LookupSource, VestingInfo]>;
|
forceVestedTransfer: AugmentedSubmittable<(source: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, 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, LookupSource, VestingInfo]>;
|
||||||
/**
|
/**
|
||||||
* Unlock any vested funds of the sender account.
|
* Unlock any vested funds of the sender account.
|
||||||
*
|
*
|
||||||
@@ -3677,7 +3768,7 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* - Writes: Vesting Storage, Balances Locks, Target Account
|
* - Writes: Vesting Storage, Balances Locks, Target Account
|
||||||
* # </weight>
|
* # </weight>
|
||||||
**/
|
**/
|
||||||
vestOther: AugmentedSubmittable<(target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>;
|
vestOther: AugmentedSubmittable<(target: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>;
|
||||||
/**
|
/**
|
||||||
* Create a vested transfer.
|
* Create a vested transfer.
|
||||||
*
|
*
|
||||||
@@ -3696,7 +3787,7 @@ declare module '@polkadot/api/types/submittable' {
|
|||||||
* - Writes: Vesting Storage, Balances Locks, Target Account, [Sender Account]
|
* - Writes: Vesting Storage, Balances Locks, Target Account, [Sender Account]
|
||||||
* # </weight>
|
* # </weight>
|
||||||
**/
|
**/
|
||||||
vestedTransfer: AugmentedSubmittable<(target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, schedule: VestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, VestingInfo]>;
|
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]>;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import type { ApiInterfaceRx, ApiTypes, DecoratedErrors, DecoratedEvents, Decora
|
|||||||
|
|
||||||
import { assertReturn } from '@polkadot/util';
|
import { assertReturn } from '@polkadot/util';
|
||||||
|
|
||||||
import { packageInfo } from '../detectPackage';
|
import { packageInfo } from '../packageInfo';
|
||||||
import { Init } from './Init';
|
import { Init } from './Init';
|
||||||
|
|
||||||
interface PkgJson {
|
interface PkgJson {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import type { Text } from '@polkadot/types';
|
import type { Text } from '@polkadot/types';
|
||||||
import type { ChainProperties, Hash, RuntimeVersion, SignedBlock } from '@polkadot/types/interfaces';
|
import type { ChainProperties, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||||
import type { Registry } from '@polkadot/types/types';
|
import type { Registry } from '@polkadot/types/types';
|
||||||
import type { Observable, Subscription } from '@polkadot/x-rxjs';
|
import type { Observable, Subscription } from '@polkadot/x-rxjs';
|
||||||
import type { ApiBase, ApiOptions, ApiTypes, DecorateMethod } from '../types';
|
import type { ApiBase, ApiOptions, ApiTypes, DecorateMethod } from '../types';
|
||||||
@@ -12,14 +12,14 @@ import BN from 'bn.js';
|
|||||||
|
|
||||||
import { Metadata } from '@polkadot/metadata';
|
import { Metadata } from '@polkadot/metadata';
|
||||||
import { TypeRegistry } from '@polkadot/types/create';
|
import { TypeRegistry } from '@polkadot/types/create';
|
||||||
import { LATEST_EXTRINSIC_VERSION } from '@polkadot/types/extrinsic/Extrinsic';
|
import { getSpecAlias, getSpecExtensions, getSpecHasher, getSpecRpc, getSpecTypes, getUpgradeVersion } from '@polkadot/types-known';
|
||||||
import { getSpecAlias, getSpecRpc, getSpecTypes, getUpgradeVersion } from '@polkadot/types-known';
|
import { assert, BN_ZERO, logger, u8aEq, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||||
import { assert, BN_ZERO, logger, u8aEq, u8aToU8a } from '@polkadot/util';
|
|
||||||
import { cryptoWaitReady } from '@polkadot/util-crypto';
|
import { cryptoWaitReady } from '@polkadot/util-crypto';
|
||||||
import { of } from '@polkadot/x-rxjs';
|
import { of } from '@polkadot/x-rxjs';
|
||||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||||
|
|
||||||
import { Decorate } from './Decorate';
|
import { Decorate } from './Decorate';
|
||||||
|
import { detectedCapabilities } from './util';
|
||||||
|
|
||||||
const KEEPALIVE_INTERVAL = 15000;
|
const KEEPALIVE_INTERVAL = 15000;
|
||||||
const DEFAULT_BLOCKNUMBER = { unwrap: () => BN_ZERO };
|
const DEFAULT_BLOCKNUMBER = { unwrap: () => BN_ZERO };
|
||||||
@@ -36,10 +36,6 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
|||||||
constructor (options: ApiOptions, type: ApiTypes, decorateMethod: DecorateMethod<ApiType>) {
|
constructor (options: ApiOptions, type: ApiTypes, decorateMethod: DecorateMethod<ApiType>) {
|
||||||
super(options, type, decorateMethod);
|
super(options, type, decorateMethod);
|
||||||
|
|
||||||
if (!this.hasSubscriptions) {
|
|
||||||
l.warn('Api will be available in a limited mode since the provider does not support subscriptions');
|
|
||||||
}
|
|
||||||
|
|
||||||
// all injected types added to the registry for overrides
|
// all injected types added to the registry for overrides
|
||||||
this.registry.setKnownTypes(options);
|
this.registry.setKnownTypes(options);
|
||||||
|
|
||||||
@@ -63,9 +59,14 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
|||||||
this._rx.signer = options.signer;
|
this._rx.signer = options.signer;
|
||||||
|
|
||||||
this._rpcCore.setRegistrySwap((hash: string | Uint8Array) => this.getBlockRegistry(hash));
|
this._rpcCore.setRegistrySwap((hash: string | Uint8Array) => this.getBlockRegistry(hash));
|
||||||
this._rpcCore.provider.on('disconnected', this.#onProviderDisconnect);
|
|
||||||
this._rpcCore.provider.on('error', this.#onProviderError);
|
if (this.hasSubscriptions) {
|
||||||
this._rpcCore.provider.on('connected', this.#onProviderConnect);
|
this._rpcCore.provider.on('disconnected', this.#onProviderDisconnect);
|
||||||
|
this._rpcCore.provider.on('error', this.#onProviderError);
|
||||||
|
this._rpcCore.provider.on('connected', this.#onProviderConnect);
|
||||||
|
} else {
|
||||||
|
l.warn('Api will be available in a limited mode since the provider does not support subscriptions');
|
||||||
|
}
|
||||||
|
|
||||||
// If the provider was instantiated earlier, and has already emitted a
|
// If the provider was instantiated earlier, and has already emitted a
|
||||||
// 'connected' event, then the `on('connected')` won't fire anymore. To
|
// 'connected' event, then the `on('connected')` won't fire anymore. To
|
||||||
@@ -83,13 +84,17 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
|||||||
registry.setChainProperties(chainProps || this.registry.getChainProperties());
|
registry.setChainProperties(chainProps || this.registry.getChainProperties());
|
||||||
registry.setKnownTypes(this._options);
|
registry.setKnownTypes(this._options);
|
||||||
registry.register(getSpecTypes(registry, chain, version.specName, version.specVersion));
|
registry.register(getSpecTypes(registry, chain, version.specName, version.specVersion));
|
||||||
|
registry.setHasher(getSpecHasher(registry, chain, version.specName));
|
||||||
|
|
||||||
// for bundled types, pull through the aliases defined
|
// for bundled types, pull through the aliases defined
|
||||||
if (registry.knownTypes.typesBundle) {
|
if (registry.knownTypes.typesBundle) {
|
||||||
registry.knownTypes.typesAlias = getSpecAlias(registry, chain, version.specName);
|
registry.knownTypes.typesAlias = getSpecAlias(registry, chain, version.specName);
|
||||||
}
|
}
|
||||||
|
|
||||||
registry.setMetadata(metadata, undefined, this._options.signedExtensions);
|
registry.setMetadata(metadata, undefined, {
|
||||||
|
...getSpecExtensions(registry, chain, version.specName),
|
||||||
|
...(this._options.signedExtensions || {})
|
||||||
|
});
|
||||||
|
|
||||||
return registry;
|
return registry;
|
||||||
}
|
}
|
||||||
@@ -135,6 +140,11 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
|||||||
// nothing has been found, construct new
|
// nothing has been found, construct new
|
||||||
const metadata = await this._rpcCore.state.getMetadata(header.parentHash).toPromise();
|
const metadata = await this._rpcCore.state.getMetadata(header.parentHash).toPromise();
|
||||||
const registry = this._initRegistry(new TypeRegistry(), this._runtimeChain as Text, version, metadata);
|
const registry = this._initRegistry(new TypeRegistry(), 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, metadata, metadataConsts: null, registry, specVersion: version.specVersion };
|
||||||
|
|
||||||
this.#registries.push(result);
|
this.#registries.push(result);
|
||||||
@@ -180,6 +190,19 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
|||||||
return [source.genesisHash, source.runtimeMetadata];
|
return [source.genesisHash, source.runtimeMetadata];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _detectCapabilities (registry?: Registry, blockHash?: string | Uint8Array): void {
|
||||||
|
detectedCapabilities(this._rx, blockHash)
|
||||||
|
.toPromise()
|
||||||
|
.then((types): void => {
|
||||||
|
if (Object.keys(types).length) {
|
||||||
|
(registry || this.registry).register(types as Record<string, string>);
|
||||||
|
|
||||||
|
l.debug(`Capabilities detected${blockHash ? ` (${u8aToHex(u8aToU8a(blockHash))})` : ''}: ${JSON.stringify(types)}`);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(l.error);
|
||||||
|
}
|
||||||
|
|
||||||
// subscribe to metadata updates, inject the types on changes
|
// subscribe to metadata updates, inject the types on changes
|
||||||
private _subscribeUpdates (): void {
|
private _subscribeUpdates (): void {
|
||||||
if (this.#updateSub || !this.hasSubscriptions) {
|
if (this.#updateSub || !this.hasSubscriptions) {
|
||||||
@@ -212,6 +235,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
|||||||
// clear the registry types to ensure that we override correctly
|
// clear the registry types to ensure that we override correctly
|
||||||
this._initRegistry(thisRegistry.registry.init(), this._runtimeChain as Text, version, metadata);
|
this._initRegistry(thisRegistry.registry.init(), this._runtimeChain as Text, version, metadata);
|
||||||
this.injectMetadata(metadata, false, thisRegistry.registry);
|
this.injectMetadata(metadata, false, thisRegistry.registry);
|
||||||
|
this._detectCapabilities(thisRegistry.registry);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
@@ -261,25 +285,15 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
|||||||
return [genesisHash, metadata];
|
return [genesisHash, metadata];
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _initFromMeta (metadata: Metadata): Promise<boolean> {
|
private _initFromMeta (metadata: Metadata): boolean {
|
||||||
const metaExtrinsic = metadata.asLatest.extrinsic;
|
this._extrinsicType = metadata.asLatest.extrinsic.version.toNumber();
|
||||||
|
|
||||||
// only inject if we are not a clone (global init)
|
|
||||||
if (metaExtrinsic.version.gt(BN_ZERO)) {
|
|
||||||
this._extrinsicType = metaExtrinsic.version.toNumber();
|
|
||||||
} else if (!this._options.source) {
|
|
||||||
// detect the extrinsic version in-use based on the last block
|
|
||||||
const { block: { extrinsics: [firstTx] } }: SignedBlock = await this._rpcCore.chain.getBlock().toPromise();
|
|
||||||
|
|
||||||
// If we haven't sync-ed to 1 yes, this won't have any values
|
|
||||||
this._extrinsicType = firstTx ? firstTx.type : LATEST_EXTRINSIC_VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._rx.extrinsicType = this._extrinsicType;
|
this._rx.extrinsicType = this._extrinsicType;
|
||||||
this._rx.genesisHash = this._genesisHash;
|
this._rx.genesisHash = this._genesisHash;
|
||||||
this._rx.runtimeVersion = this._runtimeVersion;
|
this._rx.runtimeVersion = this._runtimeVersion as RuntimeVersion; // must be set here
|
||||||
|
|
||||||
|
// inject metadata and adjust the types as detected
|
||||||
this.injectMetadata(metadata, true);
|
this.injectMetadata(metadata, true);
|
||||||
|
this._detectCapabilities();
|
||||||
|
|
||||||
// derive is last, since it uses the decorated rx
|
// derive is last, since it uses the decorated rx
|
||||||
this._rx.derive = this._decorateDeriveRx(this._rxDecorateMethod);
|
this._rx.derive = this._decorateDeriveRx(this._rxDecorateMethod);
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
// 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, Releases | null];
|
||||||
|
|
||||||
|
type DetectedKeys = keyof Pick<InterfaceTypes, 'AccountInfo' | 'ValidatorPrefs'>;
|
||||||
|
|
||||||
|
type DetectedValues = keyof InterfaceTypes;
|
||||||
|
|
||||||
|
interface DetectedTypes extends Record<DetectedKeys, DetectedValues> {
|
||||||
|
AccountInfo: 'AccountInfoWithRefCount' | 'AccountInfoWithProviders',
|
||||||
|
ValidatorPrefs: 'ValidatorPrefsWithBlocked' | 'ValidatorPrefsWithCommission';
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapCapabilities ([systemRefcount32, systemRefcountDual, stakingVersion]: Extracted): Partial<DetectedTypes> {
|
||||||
|
const types: Partial<DetectedTypes> = {};
|
||||||
|
|
||||||
|
// AccountInfo
|
||||||
|
if (systemRefcountDual && systemRefcountDual.isTrue) {
|
||||||
|
types.AccountInfo = 'AccountInfoWithProviders';
|
||||||
|
} else if (systemRefcount32 && systemRefcount32.isTrue) {
|
||||||
|
types.AccountInfo = 'AccountInfoWithRefCount';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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.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)
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,25 +1,14 @@
|
|||||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
// For esm, this should be import.meta.url or to get the same behavior as __dirname, we can use
|
import { packageInfo as deriveInfo } from '@polkadot/api-derive/packageInfo';
|
||||||
//
|
import { packageInfo as metaInfo } from '@polkadot/metadata/packageInfo';
|
||||||
// new URL(import.meta.url).pathname)
|
import { packageInfo as coreInfo } from '@polkadot/rpc-core/packageInfo';
|
||||||
//
|
import { packageInfo as providerInfo } from '@polkadot/rpc-provider/packageInfo';
|
||||||
// The issue is the WP4 has "some" issues with import.meta.url. So because of bundlers, we can't have
|
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||||
// nice things... In this case it is even worse since import.meta.url won't even make it compile, so
|
import { packageInfo as knownInfo } from '@polkadot/types-known/packageInfo';
|
||||||
// there is a complete dead end with usage thereof
|
|
||||||
//
|
|
||||||
// When that is fixed, a solution is to have both .js & .mjs files, with the following content -
|
|
||||||
//
|
|
||||||
// cjs: util.detectPackage(packageInfo, () => __dirname);
|
|
||||||
// esm: detectPackage(packageInfo, () => import.meta.url);
|
|
||||||
//
|
|
||||||
// With the above we additionally need a .d.ts to just export the packageInfo
|
|
||||||
|
|
||||||
import { detectPackage } from '@polkadot/util';
|
import { detectPackage } from '@polkadot/util';
|
||||||
|
|
||||||
import packageInfo from './package-info.json';
|
import { packageInfo } from './packageInfo';
|
||||||
|
|
||||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname);
|
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [deriveInfo, metaInfo, coreInfo, providerInfo, typesInfo, knownInfo]);
|
||||||
|
|
||||||
export { packageInfo };
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import './detectPackage';
|
|||||||
export { Keyring } from '@polkadot/keyring';
|
export { Keyring } from '@polkadot/keyring';
|
||||||
export { WsProvider } from '@polkadot/rpc-provider/ws';
|
export { WsProvider } from '@polkadot/rpc-provider/ws';
|
||||||
|
|
||||||
|
export { packageInfo } from './packageInfo';
|
||||||
export { ApiPromise } from './promise';
|
export { ApiPromise } from './promise';
|
||||||
export { ApiRx } from './rx';
|
|
||||||
|
|
||||||
export { SubmittableResult } from './submittable';
|
export { SubmittableResult } from './submittable';
|
||||||
|
export { ApiRx } from './rx';
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// Copyright 2017-2021 @polkadot/dev authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
// Auto-generated by @polkadot/dev, do not edit
|
||||||
|
|
||||||
|
export const packageInfo = { name: '@polkadot/api', version: '3.11.1' };
|
||||||
@@ -12,7 +12,7 @@ import { hexToU8a } from '@polkadot/util';
|
|||||||
import { SingleAccountSigner } from '../../test/util';
|
import { SingleAccountSigner } from '../../test/util';
|
||||||
import { ApiPromise } from '.';
|
import { ApiPromise } from '.';
|
||||||
|
|
||||||
const TRANSFER_SIG = '0x7a10e5ed9a14284eca7bea53f81631981dddda5a3d2dee973b136475947264801465726e4829ae3994d9058df638d959d4e043c7f1924299546790dda1dea20a';
|
const TRANSFER_SIG = '0x54f39e43f32376a5ab6cdfd4d0ce57802aa9ff85514a7ffa9f2a949078f02beca16af87427c45fe60d54aa847fd241d127ed39e21b101806f6b1f50f7a82500b';
|
||||||
|
|
||||||
describe('ApiPromise', (): void => {
|
describe('ApiPromise', (): void => {
|
||||||
const registry = new TypeRegistry();
|
const registry = new TypeRegistry();
|
||||||
|
|||||||
@@ -66,14 +66,14 @@ export class SubmittableResult implements ISubmittableResult {
|
|||||||
/**
|
/**
|
||||||
* @description Filters EventRecords for the specified method & section (there could be multiple)
|
* @description Filters EventRecords for the specified method & section (there could be multiple)
|
||||||
*/
|
*/
|
||||||
public filterRecords (section: string, method: string): EventRecord[] {
|
public filterRecords (section: string, method: string | string[]): EventRecord[] {
|
||||||
return filterAndApply(this.events, section, [method], recordIdentity);
|
return filterAndApply(this.events, section, Array.isArray(method) ? method : [method], recordIdentity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Finds an EventRecord for the specified method & section
|
* @description Finds an EventRecord for the specified method & section
|
||||||
*/
|
*/
|
||||||
public findRecord (section: string, method: string): EventRecord | undefined {
|
public findRecord (section: string, method: string | string[]): EventRecord | undefined {
|
||||||
return this.filterRecords(section, method)[0];
|
return this.filterRecords(section, method)[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ export interface ApiOptions extends RegisteredTypes {
|
|||||||
/**
|
/**
|
||||||
* @description Any chain-specific signed extensions that are now well-known
|
* @description Any chain-specific signed extensions that are now well-known
|
||||||
*/
|
*/
|
||||||
signedExtensions?: Record<string, ExtDef>;
|
signedExtensions?: ExtDef;
|
||||||
/**
|
/**
|
||||||
* @description An external signer which will be used to sign extrinsic when account passed in is not KeyringPair
|
* @description An external signer which will be used to sign extrinsic when account passed in is not KeyringPair
|
||||||
*/
|
*/
|
||||||
@@ -81,7 +81,7 @@ export interface ApiInterfaceRx {
|
|||||||
hasSubscriptions: boolean;
|
hasSubscriptions: boolean;
|
||||||
registry: Registry;
|
registry: Registry;
|
||||||
runtimeMetadata: Metadata;
|
runtimeMetadata: Metadata;
|
||||||
runtimeVersion?: RuntimeVersion;
|
runtimeVersion: RuntimeVersion;
|
||||||
query: QueryableStorage<'rxjs'>;
|
query: QueryableStorage<'rxjs'>;
|
||||||
queryMulti: QueryableStorageMulti<'rxjs'>;
|
queryMulti: QueryableStorageMulti<'rxjs'>;
|
||||||
rpc: DecoratedRpc<'rxjs', RpcInterface>;
|
rpc: DecoratedRpc<'rxjs', RpcInterface>;
|
||||||
|
|||||||
@@ -35,19 +35,19 @@ export type QueryableStorageEntry<ApiType extends ApiTypes, A extends AnyTuple =
|
|||||||
// eslint-disable-next-line no-use-before-define
|
// eslint-disable-next-line no-use-before-define
|
||||||
: AugmentedQuery<'promise', GenericStorageEntryFunction, A> & StorageEntryPromiseOverloads;
|
: AugmentedQuery<'promise', GenericStorageEntryFunction, A> & StorageEntryPromiseOverloads;
|
||||||
|
|
||||||
export interface StorageEntryBase<ApiType extends ApiTypes, F extends AnyFunction, 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>;
|
at: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(hash: Hash | Uint8Array | string, ...args: Parameters<F>) => PromiseOrObs<ApiType, T>;
|
||||||
creator: StorageEntry;
|
creator: StorageEntry;
|
||||||
entries: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(arg?: Parameters<F>[0]) => PromiseOrObs<ApiType, [StorageKey, T][]>;
|
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>>>(hash: Hash | Uint8Array | string, arg?: Parameters<F>[0]) => PromiseOrObs<ApiType, [StorageKey, 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][]>;
|
||||||
entriesPaged: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, [StorageKey, 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>;
|
hash: (...args: Parameters<F>) => PromiseOrObs<ApiType, Hash>;
|
||||||
is: (key: IStorageKey<AnyTuple>) => key is IStorageKey<A>;
|
is: (key: IStorageKey<AnyTuple>) => key is IStorageKey<A>;
|
||||||
key: (...args: Parameters<F>) => string;
|
key: (...args: Parameters<F>) => string;
|
||||||
keyPrefix: () => string;
|
keyPrefix: () => string;
|
||||||
keys: (arg?: any) => PromiseOrObs<ApiType, StorageKey[]>;
|
keys: <K extends AnyTuple = A> (arg?: any) => PromiseOrObs<ApiType, StorageKey<K>[]>;
|
||||||
keysAt: (hash: Hash | Uint8Array | string, arg?: any) => PromiseOrObs<ApiType, StorageKey[]>;
|
keysAt: <K extends AnyTuple = A> (hash: Hash | Uint8Array | string, arg?: any) => PromiseOrObs<ApiType, StorageKey<K>[]>;
|
||||||
keysPaged: (opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, StorageKey[]>;
|
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
|
// @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][]>;
|
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][]>;
|
||||||
size: (...args: Parameters<F>) => PromiseOrObs<ApiType, u64>;
|
size: (...args: Parameters<F>) => PromiseOrObs<ApiType, u64>;
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@polkadot/metadata",
|
"name": "@polkadot/metadata",
|
||||||
"version": "3.4.1",
|
"version": "3.11.1",
|
||||||
"description": "Helpers to extract information from runtime metadata",
|
"description": "Helpers to extract information from runtime metadata",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "index.mjs",
|
|
||||||
"sideEffects": [
|
"sideEffects": [
|
||||||
"./detectPackage.js",
|
"./detectPackage.js",
|
||||||
"./detectPackage.mjs"
|
"./detectPackage.mjs"
|
||||||
@@ -16,14 +15,14 @@
|
|||||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
|
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.12.5",
|
"@babel/runtime": "^7.13.8",
|
||||||
"@polkadot/types": "3.4.1",
|
"@polkadot/types": "3.11.1",
|
||||||
"@polkadot/types-known": "3.4.1",
|
"@polkadot/types-known": "3.11.1",
|
||||||
"@polkadot/util": "^5.2.3",
|
"@polkadot/util": "^5.9.2",
|
||||||
"@polkadot/util-crypto": "^5.2.3",
|
"@polkadot/util-crypto": "^5.9.2",
|
||||||
"bn.js": "^4.11.9"
|
"bn.js": "^4.11.9"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@polkadot/keyring": "^5.2.3"
|
"@polkadot/keyring": "^5.9.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// 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 } from '@polkadot/types/interfaces/metadata';
|
||||||
import type { Registry } from '@polkadot/types/types';
|
import type { AnyJson, Registry } from '@polkadot/types/types';
|
||||||
|
|
||||||
import { Struct } from '@polkadot/types/codec';
|
import { Struct } from '@polkadot/types/codec';
|
||||||
import { assert } from '@polkadot/util';
|
import { assert } from '@polkadot/util';
|
||||||
@@ -126,4 +126,16 @@ export class MetadataVersioned extends Struct {
|
|||||||
public getUniqTypes (throwError: boolean): string[] {
|
public getUniqTypes (throwError: boolean): string[] {
|
||||||
return getUniqTypes(this.registry, this.asLatest, throwError);
|
return getUniqTypes(this.registry, this.asLatest, throwError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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)
|
||||||
|
// eslint-disable-next-line no-unused-expressions
|
||||||
|
this.asLatest;
|
||||||
|
|
||||||
|
return super.toJSON();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ const registry = new TypeRegistry();
|
|||||||
const metadata = new Metadata(registry, metadataStatic);
|
const metadata = new Metadata(registry, metadataStatic);
|
||||||
|
|
||||||
registry.setMetadata(metadata);
|
registry.setMetadata(metadata);
|
||||||
|
registry.register({ Address: 'IndicesLookupSource', LookupSource: 'IndicesLookupSource' });
|
||||||
|
|
||||||
const extrinsics = decorateExtrinsics(registry, metadata.asLatest, metadata.version);
|
const extrinsics = decorateExtrinsics(registry, metadata.asLatest, metadata.version);
|
||||||
|
|
||||||
|
|||||||
@@ -30,4 +30,4 @@ export function expandMetadata (registry: Registry, metadata: Metadata): Decorat
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export { decorateConstants, decorateExtrinsics, decorateStorage };
|
export { decorateConstants, decorateErrors, decorateEvents, decorateExtrinsics, decorateStorage };
|
||||||
|
|||||||
@@ -1,25 +1,10 @@
|
|||||||
// Copyright 2017-2021 @polkadot/metadata authors & contributors
|
// Copyright 2017-2021 @polkadot/metadata authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
// For esm, this should be import.meta.url or to get the same behavior as __dirname, we can use
|
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||||
//
|
import { packageInfo as knownInfo } from '@polkadot/types-known/packageInfo';
|
||||||
// new URL(import.meta.url).pathname)
|
|
||||||
//
|
|
||||||
// The issue is the WP4 has "some" issues with import.meta.url. So because of bundlers, we can't have
|
|
||||||
// nice things... In this case it is even worse since import.meta.url won't even make it compile, so
|
|
||||||
// there is a complete dead end with usage thereof
|
|
||||||
//
|
|
||||||
// When that is fixed, a solution is to have both .js & .mjs files, with the following content -
|
|
||||||
//
|
|
||||||
// cjs: util.detectPackage(packageInfo, () => __dirname);
|
|
||||||
// esm: detectPackage(packageInfo, () => import.meta.url);
|
|
||||||
//
|
|
||||||
// With the above we additionally need a .d.ts to just export the packageInfo
|
|
||||||
|
|
||||||
import { detectPackage } from '@polkadot/util';
|
import { detectPackage } from '@polkadot/util';
|
||||||
|
|
||||||
import packageInfo from './package-info.json';
|
import { packageInfo } from './packageInfo';
|
||||||
|
|
||||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname);
|
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [typesInfo, knownInfo]);
|
||||||
|
|
||||||
export { packageInfo };
|
|
||||||
|
|||||||
@@ -5,3 +5,4 @@ import './detectPackage';
|
|||||||
|
|
||||||
export { Metadata } from './Metadata';
|
export { Metadata } from './Metadata';
|
||||||
export { decorateConstants, decorateExtrinsics, decorateStorage, expandMetadata } from './decorate';
|
export { decorateConstants, decorateExtrinsics, decorateStorage, expandMetadata } from './decorate';
|
||||||
|
export { packageInfo } from './packageInfo';
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// Copyright 2017-2021 @polkadot/dev authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
// Auto-generated by @polkadot/dev, do not edit
|
||||||
|
|
||||||
|
export const packageInfo = { name: '@polkadot/metadata', version: '3.11.1' };
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -1,10 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@polkadot/rpc-core",
|
"name": "@polkadot/rpc-core",
|
||||||
"version": "3.4.1",
|
"version": "3.11.1",
|
||||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "index.mjs",
|
"sideEffects": [
|
||||||
"sideEffects": false,
|
"./detectPackage.js",
|
||||||
|
"./detectPackage.mjs"
|
||||||
|
],
|
||||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||||
"maintainers": [],
|
"maintainers": [],
|
||||||
"contributors": [],
|
"contributors": [],
|
||||||
@@ -13,14 +15,14 @@
|
|||||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
|
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.12.5",
|
"@babel/runtime": "^7.13.8",
|
||||||
"@polkadot/metadata": "3.4.1",
|
"@polkadot/metadata": "3.11.1",
|
||||||
"@polkadot/rpc-provider": "3.4.1",
|
"@polkadot/rpc-provider": "3.11.1",
|
||||||
"@polkadot/types": "3.4.1",
|
"@polkadot/types": "3.11.1",
|
||||||
"@polkadot/util": "^5.2.3",
|
"@polkadot/util": "^5.9.2",
|
||||||
"@polkadot/x-rxjs": "3.4.1"
|
"@polkadot/x-rxjs": "^5.9.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@polkadot/keyring": "^5.2.3"
|
"@polkadot/keyring": "^5.9.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// Copyright 2017-2021 @polkadot/rpc-core authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import { packageInfo as metaInfo } from '@polkadot/metadata/packageInfo';
|
||||||
|
import { packageInfo as providerInfo } from '@polkadot/rpc-provider/packageInfo';
|
||||||
|
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||||
|
import { detectPackage } from '@polkadot/util';
|
||||||
|
|
||||||
|
import { packageInfo } from './packageInfo';
|
||||||
|
|
||||||
|
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [metaInfo, providerInfo, typesInfo]);
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
// Copyright 2017-2021 @polkadot/rpc-core authors & contributors
|
// Copyright 2017-2021 @polkadot/rpc-core authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import './detectPackage';
|
||||||
|
|
||||||
import type { ProviderInterface, ProviderInterfaceCallback } from '@polkadot/rpc-provider/types';
|
import type { ProviderInterface, ProviderInterfaceCallback } from '@polkadot/rpc-provider/types';
|
||||||
import type { StorageKey, Vec } from '@polkadot/types';
|
import type { StorageKey, Vec } from '@polkadot/types';
|
||||||
import type { Hash } from '@polkadot/types/interfaces';
|
import type { Hash } from '@polkadot/types/interfaces';
|
||||||
@@ -18,6 +20,8 @@ import { publishReplay, refCount } from '@polkadot/x-rxjs/operators';
|
|||||||
|
|
||||||
import { drr, refCountDelay } from './util';
|
import { drr, refCountDelay } from './util';
|
||||||
|
|
||||||
|
export { packageInfo } from './packageInfo';
|
||||||
|
|
||||||
interface StorageChangeSetJSON {
|
interface StorageChangeSetJSON {
|
||||||
block: string;
|
block: string;
|
||||||
changes: [string, string | null][];
|
changes: [string, string | null][];
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// Copyright 2017-2021 @polkadot/dev authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
// Auto-generated by @polkadot/dev, do not edit
|
||||||
|
|
||||||
|
export const packageInfo = { name: '@polkadot/rpc-core', version: '3.11.1' };
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@polkadot/rpc-provider",
|
"name": "@polkadot/rpc-provider",
|
||||||
"version": "3.4.1",
|
"version": "3.11.1",
|
||||||
"description": "Transport providers for the API",
|
"description": "Transport providers for the API",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "index.mjs",
|
"sideEffects": [
|
||||||
"sideEffects": false,
|
"./detectPackage.js",
|
||||||
|
"./detectPackage.mjs"
|
||||||
|
],
|
||||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||||
"maintainers": [],
|
"maintainers": [],
|
||||||
"contributors": [],
|
"contributors": [],
|
||||||
@@ -13,19 +15,20 @@
|
|||||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
|
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.12.5",
|
"@babel/runtime": "^7.13.8",
|
||||||
"@polkadot/types": "3.4.1",
|
"@polkadot/types": "3.11.1",
|
||||||
"@polkadot/util": "^5.2.3",
|
"@polkadot/util": "^5.9.2",
|
||||||
"@polkadot/util-crypto": "^5.2.3",
|
"@polkadot/util-crypto": "^5.9.2",
|
||||||
"@polkadot/x-fetch": "^5.2.3",
|
"@polkadot/x-fetch": "^5.9.2",
|
||||||
"@polkadot/x-ws": "^5.2.3",
|
"@polkadot/x-global": "^5.9.2",
|
||||||
|
"@polkadot/x-ws": "^5.9.2",
|
||||||
"bn.js": "^4.11.9",
|
"bn.js": "^4.11.9",
|
||||||
"eventemitter3": "^4.0.7"
|
"eventemitter3": "^4.0.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@polkadot/keyring": "^5.2.3",
|
"@polkadot/keyring": "^5.9.2",
|
||||||
"@polkadot/metadata": "3.4.1",
|
"@polkadot/metadata": "3.11.1",
|
||||||
"mock-socket": "^9.0.3",
|
"mock-socket": "^9.0.3",
|
||||||
"nock": "^13.0.5"
|
"nock": "^13.0.9"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// Copyright 2017-2021 @polkadot/rpc-provider authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||||
|
import { detectPackage } from '@polkadot/util';
|
||||||
|
|
||||||
|
import { packageInfo } from './packageInfo';
|
||||||
|
|
||||||
|
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [typesInfo]);
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
// Copyright 2017-2021 @polkadot/rpc-provider authors & contributors
|
// Copyright 2017-2021 @polkadot/rpc-provider authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import './detectPackage';
|
||||||
|
|
||||||
export { HttpProvider } from './http';
|
export { HttpProvider } from './http';
|
||||||
|
export { packageInfo } from './packageInfo';
|
||||||
export { WsProvider } from './ws';
|
export { WsProvider } from './ws';
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// Copyright 2017-2021 @polkadot/dev authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
// Auto-generated by @polkadot/dev, do not edit
|
||||||
|
|
||||||
|
export const packageInfo = { name: '@polkadot/rpc-provider', version: '3.11.1' };
|
||||||
@@ -8,6 +8,7 @@ import type { JsonRpcResponse, ProviderInterface, ProviderInterfaceCallback, Pro
|
|||||||
import EventEmitter from 'eventemitter3';
|
import EventEmitter from 'eventemitter3';
|
||||||
|
|
||||||
import { assert, isChildClass, isNull, isUndefined, logger } from '@polkadot/util';
|
import { assert, isChildClass, isNull, isUndefined, logger } from '@polkadot/util';
|
||||||
|
import { xglobal } from '@polkadot/x-global';
|
||||||
import { WebSocket } from '@polkadot/x-ws';
|
import { WebSocket } from '@polkadot/x-ws';
|
||||||
|
|
||||||
import { RpcCoder } from '../coder';
|
import { RpcCoder } from '../coder';
|
||||||
@@ -41,6 +42,16 @@ const RETRY_DELAY = 1000;
|
|||||||
|
|
||||||
const l = logger('api-ws');
|
const l = logger('api-ws');
|
||||||
|
|
||||||
|
function eraseRecord<T> (record: Record<string, T>, cb?: (item: T) => void): void {
|
||||||
|
Object.keys(record).forEach((key): void => {
|
||||||
|
if (cb) {
|
||||||
|
cb(record[key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete record[key];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* # @polkadot/rpc-provider/ws
|
* # @polkadot/rpc-provider/ws
|
||||||
*
|
*
|
||||||
@@ -160,7 +171,7 @@ export class WsProvider implements ProviderInterface {
|
|||||||
public async connect (): Promise<void> {
|
public async connect (): Promise<void> {
|
||||||
try {
|
try {
|
||||||
this.#endpointIndex = (this.#endpointIndex + 1) % this.#endpoints.length;
|
this.#endpointIndex = (this.#endpointIndex + 1) % this.#endpoints.length;
|
||||||
this.#websocket = typeof global.WebSocket !== 'undefined' && isChildClass(global.WebSocket, WebSocket)
|
this.#websocket = typeof xglobal.WebSocket !== 'undefined' && isChildClass(xglobal.WebSocket, WebSocket)
|
||||||
? new WebSocket(this.#endpoints[this.#endpointIndex])
|
? new WebSocket(this.#endpoints[this.#endpointIndex])
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore - WS may be an instance of w3cwebsocket, which supports headers
|
// @ts-ignore - WS may be an instance of w3cwebsocket, which supports headers
|
||||||
@@ -188,14 +199,16 @@ export class WsProvider implements ProviderInterface {
|
|||||||
* @description Connect, never throwing an error, but rather forcing a retry
|
* @description Connect, never throwing an error, but rather forcing a retry
|
||||||
*/
|
*/
|
||||||
public async connectWithRetry (): Promise<void> {
|
public async connectWithRetry (): Promise<void> {
|
||||||
try {
|
if (this.#autoConnectMs > 0) {
|
||||||
await this.connect();
|
try {
|
||||||
} catch (error) {
|
await this.connect();
|
||||||
setTimeout((): void => {
|
} catch (error) {
|
||||||
this.connectWithRetry().catch((): void => {
|
setTimeout((): void => {
|
||||||
// does not throw
|
this.connectWithRetry().catch((): void => {
|
||||||
});
|
// does not throw
|
||||||
}, this.#autoConnectMs || RETRY_DELAY);
|
});
|
||||||
|
}, this.#autoConnectMs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,8 +255,8 @@ export class WsProvider implements ProviderInterface {
|
|||||||
* @param params Encoded parameters as applicable for the method
|
* @param params Encoded parameters as applicable for the method
|
||||||
* @param subscription Subscription details (internally used)
|
* @param subscription Subscription details (internally used)
|
||||||
*/
|
*/
|
||||||
public send (method: string, params: any[], subscription?: SubscriptionHandler): Promise<any> {
|
public send <T = any> (method: string, params: any[], subscription?: SubscriptionHandler): Promise<T> {
|
||||||
return new Promise((resolve, reject): void => {
|
return new Promise<T>((resolve, reject): void => {
|
||||||
try {
|
try {
|
||||||
assert(this.isConnected && !isNull(this.#websocket), 'WebSocket is not connected');
|
assert(this.isConnected && !isNull(this.#websocket), 'WebSocket is not connected');
|
||||||
|
|
||||||
@@ -295,10 +308,8 @@ export class WsProvider implements ProviderInterface {
|
|||||||
* })
|
* })
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
public async subscribe (type: string, method: string, params: any[], callback: ProviderInterfaceCallback): Promise<number | string> {
|
public subscribe (type: string, method: string, params: any[], callback: ProviderInterfaceCallback): Promise<number | string> {
|
||||||
const id = await this.send(method, params, { callback, type }) as Promise<number | string>;
|
return this.send<number | string>(method, params, { callback, type });
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -319,9 +330,13 @@ export class WsProvider implements ProviderInterface {
|
|||||||
|
|
||||||
delete this.#subscriptions[subscription];
|
delete this.#subscriptions[subscription];
|
||||||
|
|
||||||
const result = await this.send(method, [id]) as Promise<boolean>;
|
try {
|
||||||
|
return this.isConnected && !isNull(this.#websocket)
|
||||||
return result;
|
? this.send<boolean>(method, [id])
|
||||||
|
: true;
|
||||||
|
} catch (error) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#emit = (type: ProviderInterfaceEmitted, ...args: any[]): void => {
|
#emit = (type: ProviderInterfaceEmitted, ...args: any[]): void => {
|
||||||
@@ -329,12 +344,17 @@ export class WsProvider implements ProviderInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#onSocketClose = (event: CloseEvent): void => {
|
#onSocketClose = (event: CloseEvent): void => {
|
||||||
|
const error = new Error(`disconnected from ${this.#endpoints[this.#endpointIndex]}: ${event.code}:: ${event.reason || getWSErrorString(event.code)}`);
|
||||||
|
|
||||||
if (this.#autoConnectMs > 0) {
|
if (this.#autoConnectMs > 0) {
|
||||||
l.error(`disconnected from ${this.#endpoints[this.#endpointIndex]}: ${event.code}:: ${event.reason || getWSErrorString(event.code)}`);
|
l.error(error.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#isConnected = false;
|
this.#isConnected = false;
|
||||||
this.#emit('disconnected');
|
this.#emit('disconnected');
|
||||||
|
// reject all hanging requests
|
||||||
|
eraseRecord(this.#handlers, (handler) => handler.callback(error, undefined));
|
||||||
|
eraseRecord(this.#waitingForId);
|
||||||
|
|
||||||
if (this.#autoConnectMs > 0) {
|
if (this.#autoConnectMs > 0) {
|
||||||
setTimeout((): void => {
|
setTimeout((): void => {
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
|
|
||||||
import nock from 'nock';
|
import nock from 'nock';
|
||||||
|
|
||||||
const TEST_HTTP_URL = 'http://localhost:9944';
|
export const TEST_HTTP_URL = 'http://localhost:9944';
|
||||||
|
|
||||||
function mockHttp (requests: any[]): any {
|
export function mockHttp (requests: any[]): any {
|
||||||
nock.cleanAll();
|
nock.cleanAll();
|
||||||
|
|
||||||
return requests.reduce((scope, request: any): nock.Scope => {
|
return requests.reduce((scope, request: any): nock.Scope => {
|
||||||
@@ -21,8 +21,3 @@ function mockHttp (requests: any[]): any {
|
|||||||
});
|
});
|
||||||
}, nock(TEST_HTTP_URL));
|
}, nock(TEST_HTTP_URL));
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
|
||||||
TEST_HTTP_URL,
|
|
||||||
mockHttp
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
import { Server, WebSocket } from 'mock-socket';
|
import { Server, WebSocket } from 'mock-socket';
|
||||||
|
|
||||||
const TEST_WS_URL = 'ws://localhost:9955';
|
|
||||||
|
|
||||||
interface Scope {
|
interface Scope {
|
||||||
body: { [index: string]: Record<string, any> };
|
body: { [index: string]: Record<string, any> };
|
||||||
requests: number;
|
requests: number;
|
||||||
@@ -29,6 +27,8 @@ interface ReplyDef {
|
|||||||
|
|
||||||
global.WebSocket = WebSocket;
|
global.WebSocket = WebSocket;
|
||||||
|
|
||||||
|
export const TEST_WS_URL = 'ws://localhost:9955';
|
||||||
|
|
||||||
// should be JSONRPC def return
|
// should be JSONRPC def return
|
||||||
function createError ({ error: { code, message }, id }: ErrorDef): any {
|
function createError ({ error: { code, message }, id }: ErrorDef): any {
|
||||||
return {
|
return {
|
||||||
@@ -51,7 +51,7 @@ function createReply ({ id, reply: { result } }: ReplyDef): any {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// scope definition returned
|
// scope definition returned
|
||||||
function mockWs (requests: ({ method: string } & ErrorDef)[], wsUrl: string = TEST_WS_URL): Scope {
|
export function mockWs (requests: ({ method: string } & ErrorDef)[], wsUrl: string = TEST_WS_URL): Scope {
|
||||||
const server = new Server(wsUrl);
|
const server = new Server(wsUrl);
|
||||||
|
|
||||||
let requestCount = 0;
|
let requestCount = 0;
|
||||||
@@ -85,8 +85,3 @@ function mockWs (requests: ({ method: string } & ErrorDef)[], wsUrl: string = TE
|
|||||||
|
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
|
||||||
TEST_WS_URL,
|
|
||||||
mockWs
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@polkadot/typegen",
|
"name": "@polkadot/typegen",
|
||||||
"version": "3.4.1",
|
"version": "3.11.1",
|
||||||
"description": "Type generation scripts",
|
"description": "Type generation scripts",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "index.mjs",
|
"sideEffects": [
|
||||||
"sideEffects": false,
|
"./detectPackage.js",
|
||||||
|
"./detectPackage.mjs"
|
||||||
|
],
|
||||||
"bin": {
|
"bin": {
|
||||||
"polkadot-types-chain-info": "./scripts/polkadot-types-chain-info.js",
|
"polkadot-types-chain-info": "./scripts/polkadot-types-chain-info.js",
|
||||||
"polkadot-types-from-chain": "./scripts/polkadot-types-from-chain.js",
|
"polkadot-types-from-chain": "./scripts/polkadot-types-from-chain.js",
|
||||||
@@ -20,20 +22,20 @@
|
|||||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/typegen#readme",
|
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/typegen#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "^7.12.10",
|
"@babel/core": "^7.13.8",
|
||||||
"@babel/register": "^7.12.10",
|
"@babel/register": "^7.13.8",
|
||||||
"@babel/runtime": "^7.12.5",
|
"@babel/runtime": "^7.13.8",
|
||||||
"@polkadot/api": "3.4.1",
|
"@polkadot/api": "3.11.1",
|
||||||
"@polkadot/metadata": "3.4.1",
|
"@polkadot/metadata": "3.11.1",
|
||||||
"@polkadot/rpc-provider": "3.4.1",
|
"@polkadot/rpc-provider": "3.11.1",
|
||||||
"@polkadot/types": "3.4.1",
|
"@polkadot/types": "3.11.1",
|
||||||
"@polkadot/util": "^5.2.3",
|
"@polkadot/util": "^5.9.2",
|
||||||
"handlebars": "^4.7.6",
|
"handlebars": "^4.7.7",
|
||||||
"websocket": "^1.0.33",
|
"websocket": "^1.0.33",
|
||||||
"yargs": "^16.2.0"
|
"yargs": "^16.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/websocket": "^1.0.1",
|
"@types/websocket": "^1.0.1",
|
||||||
"@types/yargs": "^15.0.12"
|
"@types/yargs": "^16.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import { packageInfo as apiInfo } from '@polkadot/api/packageInfo';
|
||||||
|
import { packageInfo as metaInfo } from '@polkadot/metadata/packageInfo';
|
||||||
|
import { packageInfo as providerInfo } from '@polkadot/rpc-provider/packageInfo';
|
||||||
|
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||||
|
import { detectPackage } from '@polkadot/util';
|
||||||
|
|
||||||
|
import { packageInfo } from './packageInfo';
|
||||||
|
|
||||||
|
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [apiInfo, metaInfo, providerInfo, typesInfo]);
|
||||||
@@ -19,7 +19,7 @@ function generate (metaHex: string, pkg: string | undefined, output: string, isS
|
|||||||
: {};
|
: {};
|
||||||
|
|
||||||
generateDefaultConsts(path.join(process.cwd(), output, 'augment-api-consts.ts'), metaHex, extraTypes, isStrict);
|
generateDefaultConsts(path.join(process.cwd(), output, 'augment-api-consts.ts'), metaHex, extraTypes, isStrict);
|
||||||
generateDefaultErrors(path.join(process.cwd(), output, 'augment-api-errors.ts'), metaHex, isStrict);
|
generateDefaultErrors(path.join(process.cwd(), output, 'augment-api-errors.ts'), metaHex, extraTypes, isStrict);
|
||||||
generateDefaultEvents(path.join(process.cwd(), output, 'augment-api-events.ts'), metaHex, extraTypes, isStrict);
|
generateDefaultEvents(path.join(process.cwd(), output, 'augment-api-events.ts'), metaHex, extraTypes, isStrict);
|
||||||
generateDefaultQuery(path.join(process.cwd(), output, 'augment-api-query.ts'), metaHex, extraTypes, isStrict);
|
generateDefaultQuery(path.join(process.cwd(), output, 'augment-api-query.ts'), metaHex, extraTypes, isStrict);
|
||||||
generateDefaultRpc(path.join(process.cwd(), output, 'augment-api-rpc.ts'), extraTypes);
|
generateDefaultRpc(path.join(process.cwd(), output, 'augment-api-rpc.ts'), extraTypes);
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import type { Metadata } from '@polkadot/metadata/Metadata';
|
||||||
|
import type { ExtraTypes } from './types';
|
||||||
|
|
||||||
import Handlebars from 'handlebars';
|
import Handlebars from 'handlebars';
|
||||||
|
|
||||||
import { Metadata } from '@polkadot/metadata/Metadata';
|
|
||||||
import staticData from '@polkadot/metadata/static';
|
|
||||||
import { TypeRegistry } from '@polkadot/types/create';
|
|
||||||
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
|
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
|
||||||
import { stringCamelCase } from '@polkadot/util';
|
import { stringCamelCase } from '@polkadot/util';
|
||||||
|
|
||||||
import { compareName, createImports, formatType, readTemplate, registerDefinitions, setImports, writeFile } from '../util';
|
import { compareName, createImports, formatType, initMeta, readTemplate, setImports, writeFile } from '../util';
|
||||||
|
|
||||||
const template = readTemplate('consts');
|
const template = readTemplate('consts');
|
||||||
const generateForMetaTemplate = Handlebars.compile(template);
|
const generateForMetaTemplate = Handlebars.compile(template);
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
function generateForMeta (meta: Metadata, dest: string, extraTypes: Record<string, Record<string, { types: Record<string, any> }>>, isStrict: boolean): void {
|
function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes, isStrict: boolean): void {
|
||||||
writeFile(dest, (): string => {
|
writeFile(dest, (): string => {
|
||||||
const allTypes: Record<string, Record<string, { types: Record<string, unknown> }>> = { '@polkadot/types/interfaces': defaultDefs, ...extraTypes };
|
const allTypes = { '@polkadot/types/interfaces': defaultDefs, ...extraTypes };
|
||||||
const imports = createImports(allTypes);
|
const imports = createImports(allTypes);
|
||||||
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
||||||
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
||||||
@@ -74,14 +74,8 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: Record<strin
|
|||||||
|
|
||||||
// Call `generateForMeta()` with current static metadata
|
// Call `generateForMeta()` with current static metadata
|
||||||
/** @internal */
|
/** @internal */
|
||||||
export function generateDefaultConsts (dest = 'packages/api/src/augment/consts.ts', data = staticData, extraTypes: Record<string, Record<string, { types: Record<string, any> }>> = {}, isStrict = false): void {
|
export function generateDefaultConsts (dest = 'packages/api/src/augment/consts.ts', data?: string, extraTypes: ExtraTypes = {}, isStrict = false): void {
|
||||||
const registry = new TypeRegistry();
|
const { metadata } = initMeta(data, extraTypes);
|
||||||
|
|
||||||
registerDefinitions(registry, extraTypes);
|
|
||||||
|
|
||||||
const metadata = new Metadata(registry, data);
|
|
||||||
|
|
||||||
registry.setMetadata(metadata);
|
|
||||||
|
|
||||||
return generateForMeta(metadata, dest, extraTypes, isStrict);
|
return generateForMeta(metadata, dest, extraTypes, isStrict);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import type { Metadata } from '@polkadot/metadata/Metadata';
|
||||||
|
import type { ExtraTypes } from './types';
|
||||||
|
|
||||||
import Handlebars from 'handlebars';
|
import Handlebars from 'handlebars';
|
||||||
|
|
||||||
import { Metadata } from '@polkadot/metadata/Metadata';
|
|
||||||
import staticData from '@polkadot/metadata/static';
|
|
||||||
import { TypeRegistry } from '@polkadot/types/create';
|
|
||||||
import { stringCamelCase } from '@polkadot/util';
|
import { stringCamelCase } from '@polkadot/util';
|
||||||
|
|
||||||
import { compareName, createImports, readTemplate, writeFile } from '../util';
|
import { compareName, createImports, initMeta, readTemplate, writeFile } from '../util';
|
||||||
|
|
||||||
const template = readTemplate('errors');
|
const template = readTemplate('errors');
|
||||||
const generateForMetaTemplate = Handlebars.compile(template);
|
const generateForMetaTemplate = Handlebars.compile(template);
|
||||||
@@ -50,11 +50,8 @@ function generateForMeta (meta: Metadata, dest: string, isStrict: boolean): void
|
|||||||
|
|
||||||
// Call `generateForMeta()` with current static metadata
|
// Call `generateForMeta()` with current static metadata
|
||||||
/** @internal */
|
/** @internal */
|
||||||
export function generateDefaultErrors (dest = 'packages/api/src/augment/errors.ts', data = staticData, isStrict = false): void {
|
export function generateDefaultErrors (dest = 'packages/api/src/augment/errors.ts', data?: string, extraTypes: ExtraTypes = {}, isStrict = false): void {
|
||||||
const registry = new TypeRegistry();
|
const { metadata } = initMeta(data, extraTypes);
|
||||||
const metadata = new Metadata(registry, data);
|
|
||||||
|
|
||||||
registry.setMetadata(metadata);
|
|
||||||
|
|
||||||
return generateForMeta(metadata, dest, isStrict);
|
return generateForMeta(metadata, dest, isStrict);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import type { Metadata } from '@polkadot/metadata/Metadata';
|
||||||
|
import type { ExtraTypes } from './types';
|
||||||
|
|
||||||
import Handlebars from 'handlebars';
|
import Handlebars from 'handlebars';
|
||||||
|
|
||||||
import { Metadata } from '@polkadot/metadata/Metadata';
|
|
||||||
import staticData from '@polkadot/metadata/static';
|
|
||||||
import { TypeRegistry } from '@polkadot/types/create';
|
|
||||||
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
|
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
|
||||||
import { stringCamelCase } from '@polkadot/util';
|
import { stringCamelCase } from '@polkadot/util';
|
||||||
|
|
||||||
import { compareName, createImports, formatType, readTemplate, registerDefinitions, setImports, writeFile } from '../util';
|
import { compareName, createImports, formatType, initMeta, readTemplate, setImports, writeFile } from '../util';
|
||||||
|
|
||||||
const template = readTemplate('events');
|
const template = readTemplate('events');
|
||||||
const generateForMetaTemplate = Handlebars.compile(template);
|
const generateForMetaTemplate = Handlebars.compile(template);
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
function generateForMeta (meta: Metadata, dest: string, extraTypes: Record<string, Record<string, { types: Record<string, any> }>>, isStrict: boolean): void {
|
function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes, isStrict: boolean): void {
|
||||||
writeFile(dest, (): string => {
|
writeFile(dest, (): string => {
|
||||||
const allTypes: Record<string, Record<string, { types: Record<string, unknown> }>> = { '@polkadot/types/interfaces': defaultDefs, ...extraTypes };
|
const allTypes = { '@polkadot/types/interfaces': defaultDefs, ...extraTypes };
|
||||||
const imports = createImports(allTypes);
|
const imports = createImports(allTypes);
|
||||||
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
||||||
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
||||||
@@ -67,14 +67,8 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: Record<strin
|
|||||||
|
|
||||||
// Call `generateForMeta()` with current static metadata
|
// Call `generateForMeta()` with current static metadata
|
||||||
/** @internal */
|
/** @internal */
|
||||||
export function generateDefaultEvents (dest = 'packages/api/src/augment/events.ts', data = staticData, extraTypes: Record<string, Record<string, { types: Record<string, any> }>> = {}, isStrict = false): void {
|
export function generateDefaultEvents (dest = 'packages/api/src/augment/events.ts', data?: string, extraTypes: ExtraTypes = {}, isStrict = false): void {
|
||||||
const registry = new TypeRegistry();
|
const { metadata } = initMeta(data, extraTypes);
|
||||||
|
|
||||||
registerDefinitions(registry, extraTypes);
|
|
||||||
|
|
||||||
const metadata = new Metadata(registry, data);
|
|
||||||
|
|
||||||
registry.setMetadata(metadata);
|
|
||||||
|
|
||||||
return generateForMeta(metadata, dest, extraTypes, isStrict);
|
return generateForMeta(metadata, dest, extraTypes, isStrict);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ export function generateInterfaceTypes (importDefinitions: { [importPath: string
|
|||||||
return generateInterfaceTypesTemplate({
|
return generateInterfaceTypesTemplate({
|
||||||
headerType: 'defs',
|
headerType: 'defs',
|
||||||
imports,
|
imports,
|
||||||
items,
|
items: items.sort((a, b) => a.localeCompare(b)),
|
||||||
types
|
types
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,19 +1,18 @@
|
|||||||
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import type { Metadata } from '@polkadot/metadata/Metadata';
|
||||||
import type { StorageEntryMetadataLatest } from '@polkadot/types/interfaces/metadata';
|
import type { StorageEntryMetadataLatest } from '@polkadot/types/interfaces/metadata';
|
||||||
import type { Registry } from '@polkadot/types/types';
|
import type { Registry } from '@polkadot/types/types';
|
||||||
|
import type { ExtraTypes } from './types';
|
||||||
|
|
||||||
import Handlebars from 'handlebars';
|
import Handlebars from 'handlebars';
|
||||||
|
|
||||||
import { Metadata } from '@polkadot/metadata/Metadata';
|
|
||||||
import staticData from '@polkadot/metadata/static';
|
|
||||||
import { TypeRegistry } from '@polkadot/types/create';
|
|
||||||
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
|
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
|
||||||
import { unwrapStorageType } from '@polkadot/types/primitive/StorageKey';
|
import { unwrapStorageType } from '@polkadot/types/primitive/StorageKey';
|
||||||
import { stringCamelCase } from '@polkadot/util';
|
import { stringCamelCase } from '@polkadot/util';
|
||||||
|
|
||||||
import { compareName, createImports, formatType, getSimilarTypes, readTemplate, registerDefinitions, setImports, TypeImports, writeFile } from '../util';
|
import { compareName, createImports, formatType, getSimilarTypes, initMeta, readTemplate, setImports, TypeImports, writeFile } from '../util';
|
||||||
import { ModuleTypes } from '../util/imports';
|
import { ModuleTypes } from '../util/imports';
|
||||||
|
|
||||||
// From a storage entry metadata, we return [args, returnType]
|
// From a storage entry metadata, we return [args, returnType]
|
||||||
@@ -67,9 +66,9 @@ const template = readTemplate('query');
|
|||||||
const generateForMetaTemplate = Handlebars.compile(template);
|
const generateForMetaTemplate = Handlebars.compile(template);
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
function generateForMeta (registry: Registry, meta: Metadata, dest: string, extraTypes: Record<string, Record<string, { types: Record<string, any> }>>, isStrict: boolean): void {
|
function generateForMeta (registry: Registry, meta: Metadata, dest: string, extraTypes: ExtraTypes, isStrict: boolean): void {
|
||||||
writeFile(dest, (): string => {
|
writeFile(dest, (): string => {
|
||||||
const allTypes: Record<string, Record<string, { types: Record<string, any> }>> = { '@polkadot/types/interfaces': defaultDefs, ...extraTypes };
|
const allTypes: ExtraTypes = { '@polkadot/types/interfaces': defaultDefs, ...extraTypes };
|
||||||
const imports = createImports(allTypes);
|
const imports = createImports(allTypes);
|
||||||
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
||||||
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
||||||
@@ -130,14 +129,8 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
|
|||||||
|
|
||||||
// Call `generateForMeta()` with current static metadata
|
// Call `generateForMeta()` with current static metadata
|
||||||
/** @internal */
|
/** @internal */
|
||||||
export function generateDefaultQuery (dest = 'packages/api/src/augment/query.ts', data = staticData, extraTypes: Record<string, Record<string, { types: Record<string, any> }>> = {}, isStrict = false): void {
|
export function generateDefaultQuery (dest = 'packages/api/src/augment/query.ts', data?: string, extraTypes: ExtraTypes = {}, isStrict = false): void {
|
||||||
const registry = new TypeRegistry();
|
const { metadata, registry } = initMeta(data, extraTypes);
|
||||||
|
|
||||||
registerDefinitions(registry, extraTypes);
|
|
||||||
|
|
||||||
const metadata = new Metadata(registry, data);
|
|
||||||
|
|
||||||
registry.setMetadata(metadata);
|
|
||||||
|
|
||||||
return generateForMeta(registry, metadata, dest, extraTypes, isStrict);
|
return generateForMeta(registry, metadata, dest, extraTypes, isStrict);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import type { TypeRegistry } from '@polkadot/types/create';
|
||||||
import type { Definitions } from '@polkadot/types/types';
|
import type { Definitions } from '@polkadot/types/types';
|
||||||
|
import type { ExtraTypes } from './types';
|
||||||
|
|
||||||
import Handlebars from 'handlebars';
|
import Handlebars from 'handlebars';
|
||||||
|
|
||||||
import { TypeRegistry } from '@polkadot/types/create';
|
|
||||||
import * as defaultDefinitions from '@polkadot/types/interfaces/definitions';
|
import * as defaultDefinitions from '@polkadot/types/interfaces/definitions';
|
||||||
|
|
||||||
import { createImports, formatType, getSimilarTypes, readTemplate, registerDefinitions, setImports, writeFile } from '../util';
|
import { createImports, formatType, getSimilarTypes, initMeta, readTemplate, setImports, writeFile } from '../util';
|
||||||
|
|
||||||
interface ItemDef {
|
interface ItemDef {
|
||||||
args: string;
|
args: string;
|
||||||
@@ -29,9 +30,9 @@ const template = readTemplate('rpc');
|
|||||||
const generateRpcTypesTemplate = Handlebars.compile(template);
|
const generateRpcTypesTemplate = Handlebars.compile(template);
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
export function generateRpcTypes (registry: TypeRegistry, importDefinitions: Record<string, Definitions>, dest: string, extraTypes: Record<string, Record<string, { types: Record<string, any> }>> = {}): void {
|
export function generateRpcTypes (registry: TypeRegistry, importDefinitions: Record<string, Definitions>, dest: string, extraTypes: ExtraTypes = {}): void {
|
||||||
writeFile(dest, (): string => {
|
writeFile(dest, (): string => {
|
||||||
const allTypes: Record<string, Record<string, { types: Record<string, any> }>> = { '@polkadot/types/interfaces': importDefinitions, ...extraTypes };
|
const allTypes: ExtraTypes = { '@polkadot/types/interfaces': importDefinitions, ...extraTypes };
|
||||||
const imports = createImports(allTypes);
|
const imports = createImports(allTypes);
|
||||||
const definitions = imports.definitions as Record<string, Definitions>;
|
const definitions = imports.definitions as Record<string, Definitions>;
|
||||||
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
||||||
@@ -141,10 +142,8 @@ export function generateRpcTypes (registry: TypeRegistry, importDefinitions: Rec
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function generateDefaultRpc (dest = 'packages/api/src/augment/rpc.ts', extraTypes: Record<string, Record<string, { types: Record<string, any> }>> = {}): void {
|
export function generateDefaultRpc (dest = 'packages/api/src/augment/rpc.ts', extraTypes: ExtraTypes = {}): void {
|
||||||
const registry = new TypeRegistry();
|
const { registry } = initMeta(undefined, extraTypes);
|
||||||
|
|
||||||
registerDefinitions(registry, extraTypes);
|
|
||||||
|
|
||||||
generateRpcTypes(
|
generateRpcTypes(
|
||||||
registry,
|
registry,
|
||||||
|
|||||||
@@ -87,12 +87,12 @@ function tsInt (definitions: Record<string, ModuleTypes>, def: TypeDef, imports:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
function tsResultGetter (definitions: Record<string, ModuleTypes>, resultName = '', getter: 'Ok' | 'Error', def: TypeDef, imports: TypeImports): string {
|
function tsResultGetter (definitions: Record<string, ModuleTypes>, resultName = '', getter: 'Ok' | 'Err' | 'Error', def: TypeDef, imports: TypeImports): string {
|
||||||
const { info, type } = def;
|
const { info, type } = def;
|
||||||
const asGetter = type === 'Null'
|
const asGetter = type === 'Null'
|
||||||
? ''
|
? ''
|
||||||
: createGetter(definitions, `as${getter}`, info === TypeDefInfo.Tuple ? formatType(definitions, def, imports) : type, imports);
|
: (getter === 'Error' ? ' /** @deprecated Use asErr */\n' : '') + createGetter(definitions, `as${getter}`, info === TypeDefInfo.Tuple ? formatType(definitions, def, imports) : type, imports);
|
||||||
const isGetter = createGetter(definitions, `is${getter}`, 'boolean', imports);
|
const isGetter = (getter === 'Error' ? ' /** @deprecated Use isErr */\n' : '') + createGetter(definitions, `is${getter}`, 'boolean', imports);
|
||||||
|
|
||||||
switch (info) {
|
switch (info) {
|
||||||
case TypeDefInfo.Plain:
|
case TypeDefInfo.Plain:
|
||||||
@@ -110,6 +110,8 @@ function tsResultGetter (definitions: Record<string, ModuleTypes>, resultName =
|
|||||||
function tsResult (definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
|
function tsResult (definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
|
||||||
const [okDef, errorDef] = (def.sub as TypeDef[]);
|
const [okDef, errorDef] = (def.sub as TypeDef[]);
|
||||||
const inner = [
|
const inner = [
|
||||||
|
tsResultGetter(definitions, def.name, 'Err', errorDef, imports),
|
||||||
|
// @deprecated, use Err
|
||||||
tsResultGetter(definitions, def.name, 'Error', errorDef, imports),
|
tsResultGetter(definitions, def.name, 'Error', errorDef, imports),
|
||||||
tsResultGetter(definitions, def.name, 'Ok', okDef, imports)
|
tsResultGetter(definitions, def.name, 'Ok', okDef, imports)
|
||||||
].join('');
|
].join('');
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import type { Metadata } from '@polkadot/metadata/Metadata';
|
||||||
import type { Registry } from '@polkadot/types/types';
|
import type { Registry } from '@polkadot/types/types';
|
||||||
|
import type { ExtraTypes } from './types';
|
||||||
|
|
||||||
import Handlebars from 'handlebars';
|
import Handlebars from 'handlebars';
|
||||||
|
|
||||||
import { Metadata } from '@polkadot/metadata/Metadata';
|
|
||||||
import staticData from '@polkadot/metadata/static';
|
|
||||||
import { TypeRegistry } from '@polkadot/types/create';
|
|
||||||
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
|
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
|
||||||
import { Text } from '@polkadot/types/primitive';
|
import { Text } from '@polkadot/types/primitive';
|
||||||
import { stringCamelCase } from '@polkadot/util';
|
import { stringCamelCase } from '@polkadot/util';
|
||||||
|
|
||||||
import { compareName, createImports, formatType, getSimilarTypes, readTemplate, registerDefinitions, setImports, writeFile } from '../util';
|
import { compareName, createImports, formatType, getSimilarTypes, initMeta, readTemplate, setImports, writeFile } from '../util';
|
||||||
|
|
||||||
const MAPPED_NAMES: Record<string, string> = {
|
const MAPPED_NAMES: Record<string, string> = {
|
||||||
new: 'updated'
|
new: 'updated'
|
||||||
@@ -28,9 +27,9 @@ const template = readTemplate('tx');
|
|||||||
const generateForMetaTemplate = Handlebars.compile(template);
|
const generateForMetaTemplate = Handlebars.compile(template);
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
function generateForMeta (registry: Registry, meta: Metadata, dest: string, extraTypes: Record<string, Record<string, { types: Record<string, any> }>>, isStrict: boolean): void {
|
function generateForMeta (registry: Registry, meta: Metadata, dest: string, extraTypes: ExtraTypes, isStrict: boolean): void {
|
||||||
writeFile(dest, (): string => {
|
writeFile(dest, (): string => {
|
||||||
const allTypes: Record<string, Record<string, { types: Record<string, any> }>> = { '@polkadot/types/interfaces': defaultDefs, ...extraTypes };
|
const allTypes: ExtraTypes = { '@polkadot/types/interfaces': defaultDefs, ...extraTypes };
|
||||||
const imports = createImports(allTypes);
|
const imports = createImports(allTypes);
|
||||||
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
||||||
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
||||||
@@ -93,14 +92,8 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
|
|||||||
|
|
||||||
// Call `generateForMeta()` with current static metadata
|
// Call `generateForMeta()` with current static metadata
|
||||||
/** @internal */
|
/** @internal */
|
||||||
export function generateDefaultTx (dest = 'packages/api/src/augment/tx.ts', data = staticData, extraTypes: Record<string, Record<string, { types: Record<string, any> }>> = {}, isStrict = false): void {
|
export function generateDefaultTx (dest = 'packages/api/src/augment/tx.ts', data?: string, extraTypes: ExtraTypes = {}, isStrict = false): void {
|
||||||
const registry = new TypeRegistry();
|
const { metadata, registry } = initMeta(data, extraTypes);
|
||||||
|
|
||||||
registerDefinitions(registry, extraTypes);
|
|
||||||
|
|
||||||
const metadata = new Metadata(registry, data);
|
|
||||||
|
|
||||||
registry.setMetadata(metadata);
|
|
||||||
|
|
||||||
return generateForMeta(registry, metadata, dest, extraTypes, isStrict);
|
return generateForMeta(registry, metadata, dest, extraTypes, isStrict);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
export type ExtraTypes = Record<string, Record<string, { types: Record<string, any> }>>;
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import './detectPackage';
|
||||||
|
|
||||||
|
export { packageInfo } from './packageInfo';
|
||||||
export { formatType } from './util/formatting';
|
export { formatType } from './util/formatting';
|
||||||
|
|||||||
@@ -275,6 +275,7 @@ function addEvents (metadata: MetadataLatest): string {
|
|||||||
const args = func.args.map((type): string => '`' + type.toString() + '`').join(', ');
|
const args = func.args.map((type): string => '`' + type.toString() + '`').join(', ');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
interface: '`' + `api.events.${stringCamelCase(meta.name)}.${methodName}.is` + '`',
|
||||||
name: `${methodName}(${args})`,
|
name: `${methodName}(${args})`,
|
||||||
...(func.documentation.length && { summary: func.documentation })
|
...(func.documentation.length && { summary: func.documentation })
|
||||||
};
|
};
|
||||||
@@ -296,6 +297,7 @@ function addErrors (metadata: MetadataLatest): string {
|
|||||||
items: moduleMetadata.errors
|
items: moduleMetadata.errors
|
||||||
.sort(sortByName)
|
.sort(sortByName)
|
||||||
.map((error) => ({
|
.map((error) => ({
|
||||||
|
interface: '`' + `api.errors.${stringCamelCase(moduleMetadata.name)}.${error.name.toString()}.is` + '`',
|
||||||
name: error.name.toString(),
|
name: error.name.toString(),
|
||||||
...(error.documentation.length && { summary: error.documentation })
|
...(error.documentation.length && { summary: error.documentation })
|
||||||
})),
|
})),
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// Copyright 2017-2021 @polkadot/dev authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
// Auto-generated by @polkadot/dev, do not edit
|
||||||
|
|
||||||
|
export const packageInfo = { name: '@polkadot/typegen', version: '3.11.1' };
|
||||||
@@ -70,8 +70,8 @@ export function setImports (allDefs: Record<string, ModuleTypes>, imports: TypeI
|
|||||||
setImports(allDefs, imports, [typeDef.sub.type]);
|
setImports(allDefs, imports, [typeDef.sub.type]);
|
||||||
}
|
}
|
||||||
} else if (type.includes('[') && type.includes('|')) {
|
} else if (type.includes('[') && type.includes('|')) {
|
||||||
// We split the types
|
// We split the types (we already dod the check above, so safe-path should not be caught)
|
||||||
const splitTypes = /\[\s?(.+?)\s?\]/.exec(type)![1].split(/\s?\|\s?/);
|
const splitTypes = (/\[\s?(.+?)\s?\]/.exec(type) || ['', ''])[1].split(/\s?\|\s?/);
|
||||||
|
|
||||||
setImports(allDefs, imports, splitTypes);
|
setImports(allDefs, imports, splitTypes);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ export * from './docs';
|
|||||||
export * from './file';
|
export * from './file';
|
||||||
export * from './formatting';
|
export * from './formatting';
|
||||||
export * from './imports';
|
export * from './imports';
|
||||||
|
export * from './initMeta';
|
||||||
export * from './register';
|
export * from './register';
|
||||||
|
|
||||||
export const compareName = (a: { name: { toString(): string } }, b: { name: { toString(): string } }): number =>
|
export const compareName = (a: { name: { toString(): string } }, b: { name: { toString(): string } }): number =>
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import type { ExtraTypes } from '../generate/types';
|
||||||
|
|
||||||
|
import { Metadata } from '@polkadot/metadata/Metadata';
|
||||||
|
import staticData from '@polkadot/metadata/static';
|
||||||
|
import { TypeRegistry } from '@polkadot/types/create';
|
||||||
|
|
||||||
|
import { registerDefinitions } from './register';
|
||||||
|
|
||||||
|
interface Result {
|
||||||
|
metadata: Metadata;
|
||||||
|
registry: TypeRegistry;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function initMeta (data = staticData, extraTypes: ExtraTypes = {}): Result {
|
||||||
|
const registry = new TypeRegistry();
|
||||||
|
|
||||||
|
registerDefinitions(registry, extraTypes);
|
||||||
|
|
||||||
|
const metadata = new Metadata(registry, data);
|
||||||
|
|
||||||
|
registry.setMetadata(metadata);
|
||||||
|
|
||||||
|
return { metadata, registry };
|
||||||
|
}
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@polkadot/types-known",
|
"name": "@polkadot/types-known",
|
||||||
"version": "3.4.1",
|
"version": "3.11.1",
|
||||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "index.mjs",
|
"sideEffects": [
|
||||||
"sideEffects": false,
|
"./detectPackage.js",
|
||||||
|
"./detectPackage.mjs"
|
||||||
|
],
|
||||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||||
"maintainers": [],
|
"maintainers": [],
|
||||||
"contributors": [],
|
"contributors": [],
|
||||||
@@ -13,9 +15,10 @@
|
|||||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
|
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.12.5",
|
"@babel/runtime": "^7.13.8",
|
||||||
"@polkadot/types": "3.4.1",
|
"@polkadot/networks": "^5.9.2",
|
||||||
"@polkadot/util": "^5.2.3",
|
"@polkadot/types": "3.11.1",
|
||||||
|
"@polkadot/util": "^5.9.2",
|
||||||
"bn.js": "^4.11.9"
|
"bn.js": "^4.11.9"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// Copyright 2017-2021 @polkadot/types-known authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
|
||||||
|
import { detectPackage } from '@polkadot/util';
|
||||||
|
|
||||||
|
import { packageInfo } from './packageInfo';
|
||||||
|
|
||||||
|
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [typesInfo]);
|
||||||
@@ -1,10 +1,13 @@
|
|||||||
// Copyright 2017-2021 @polkadot/types-known authors & contributors
|
// Copyright 2017-2021 @polkadot/types-known authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import './detectPackage';
|
||||||
|
|
||||||
import type BN from 'bn.js';
|
import type BN from 'bn.js';
|
||||||
import type { Text } from '@polkadot/types';
|
import type { Text } from '@polkadot/types';
|
||||||
|
import type { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types';
|
||||||
import type { Hash } from '@polkadot/types/interfaces';
|
import type { Hash } from '@polkadot/types/interfaces';
|
||||||
import type { ChainUpgradeVersion, DefinitionRpc, DefinitionRpcSub, OverrideModuleType, OverrideVersionedType, Registry, RegistryTypes } from '@polkadot/types/types';
|
import type { ChainUpgradeVersion, CodecHasher, DefinitionRpc, DefinitionRpcSub, OverrideModuleType, OverrideVersionedType, Registry, RegistryTypes } from '@polkadot/types/types';
|
||||||
|
|
||||||
import { bnToBn, isUndefined } from '@polkadot/util';
|
import { bnToBn, isUndefined } from '@polkadot/util';
|
||||||
|
|
||||||
@@ -13,6 +16,8 @@ import typesModules from './modules';
|
|||||||
import typesSpec from './spec';
|
import typesSpec from './spec';
|
||||||
import upgrades from './upgrades';
|
import upgrades from './upgrades';
|
||||||
|
|
||||||
|
export { packageInfo } from './packageInfo';
|
||||||
|
|
||||||
// flatten a VersionedType[] into a Record<string, string>
|
// flatten a VersionedType[] into a Record<string, string>
|
||||||
/** @internal */
|
/** @internal */
|
||||||
function filterVersions (versions: OverrideVersionedType[] = [], specVersion: number): RegistryTypes {
|
function filterVersions (versions: OverrideVersionedType[] = [], specVersion: number): RegistryTypes {
|
||||||
@@ -37,6 +42,19 @@ export function getModuleTypes ({ knownTypes }: Registry, section: string): Over
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Based on the chain and runtimeVersion, get the applicable signed extensions (ready for registration)
|
||||||
|
*/
|
||||||
|
export function getSpecExtensions ({ knownTypes }: Registry, chainName: Text | string, specName: Text | string): ExtDef {
|
||||||
|
const _chainName = chainName.toString();
|
||||||
|
const _specName = specName.toString();
|
||||||
|
|
||||||
|
return {
|
||||||
|
...(knownTypes.typesBundle?.spec?.[_specName]?.signedExtensions || {}),
|
||||||
|
...(knownTypes.typesBundle?.chain?.[_chainName]?.signedExtensions || {})
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Based on the chain and runtimeVersion, get the applicable types (ready for registration)
|
* @description Based on the chain and runtimeVersion, get the applicable types (ready for registration)
|
||||||
*/
|
*/
|
||||||
@@ -60,6 +78,13 @@ export function getSpecTypes ({ knownTypes }: Registry, chainName: Text | string
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getSpecHasher ({ knownTypes }: Registry, chainName: Text | string, specName: Text | string): CodecHasher | null {
|
||||||
|
const _chainName = chainName.toString();
|
||||||
|
const _specName = specName.toString();
|
||||||
|
|
||||||
|
return knownTypes.hasher || knownTypes.typesBundle?.chain?.[_chainName]?.hasher || knownTypes.typesBundle?.spec?.[_specName]?.hasher || null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Based on the chain and runtimeVersion, get the applicable rpc definitions (ready for registration)
|
* @description Based on the chain and runtimeVersion, get the applicable rpc definitions (ready for registration)
|
||||||
*/
|
*/
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user