Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6490217ec | ||
|
|
601cc62d70 | ||
|
|
201480be56 | ||
|
|
519823bc0e | ||
|
|
0b134c1eb8 | ||
|
|
e6e96aa9c9 | ||
|
|
84d0d8594e | ||
|
|
6be25966d8 | ||
|
|
a5eb11e5f3 | ||
|
|
19f87aac4d | ||
|
|
b217a59310 | ||
|
|
2de7a3c130 | ||
|
|
deecf4853e | ||
|
|
8889e69341 | ||
|
|
14194a363e | ||
|
|
9c50e81ab9 | ||
|
|
6505e73355 | ||
|
|
cefeb37ae6 | ||
|
|
9e29e89baf | ||
|
|
b82c90679d | ||
|
|
eeb8d20e58 | ||
|
|
b891edbd37 | ||
|
|
2ee3afcd61 | ||
|
|
328630fb17 | ||
|
|
325080cf71 | ||
|
|
549a536328 | ||
|
|
23f41a0bab | ||
|
|
5e0c0ba91a | ||
|
|
812a077e63 | ||
|
|
6ba28c8ad2 | ||
|
|
6cd0074ce4 | ||
|
|
b3d592357f | ||
|
|
f499946f1f | ||
|
|
56e28bed7f | ||
|
|
c76fb20a83 | ||
|
|
9d4b0ea56a | ||
|
|
f9d569ddd1 | ||
|
|
7221a3637c | ||
|
|
438c830366 | ||
|
|
3d0fd5a6a8 | ||
|
|
de57876c7f | ||
|
|
b24a1ff350 | ||
|
|
5f8c623179 | ||
|
|
00026a173f | ||
|
|
8da895efd4 | ||
|
|
89d029eca3 | ||
|
|
ac2a7eea67 | ||
|
|
4f0e573adf | ||
|
|
8417eff2b3 | ||
|
|
4aa5693906 | ||
|
|
982665c337 | ||
|
|
6dce57b394 | ||
|
|
ca7edf1593 | ||
|
|
59e069f091 | ||
|
|
65ff5c8f30 | ||
|
|
1c327c60d9 | ||
|
|
de9f033d99 | ||
|
|
9c913fb482 | ||
|
|
e19e530c1c | ||
|
|
aa91e0b8b5 | ||
|
|
9a6ba2fe0f | ||
|
|
de853d9cc0 | ||
|
|
07063134b8 | ||
|
|
20b8cd762d | ||
|
|
bd3338c3df | ||
|
|
4c328964d5 | ||
|
|
70e5e2b60a | ||
|
|
4329c0a411 | ||
|
|
0713afa0e0 | ||
|
|
8b518a909b | ||
|
|
794f1fe398 | ||
|
|
51423e20b5 | ||
|
|
d4b27ba670 | ||
|
|
8ca194a3d2 | ||
|
|
5fd2c70924 | ||
|
|
d36ee7de2f | ||
|
|
3683f9e5ff | ||
|
|
18c302d2cf | ||
|
|
1686f8b357 | ||
|
|
15158b763c | ||
|
|
f5f338a9ae | ||
|
|
458dec53dc | ||
|
|
ab05045686 | ||
|
|
b2c84eb461 | ||
|
|
1ee1d70d55 | ||
|
|
7de647ec0b | ||
|
|
cedbd8fa06 | ||
|
|
cba34b4b65 | ||
|
|
1a99d67c77 | ||
|
|
2a5c5ce3fe | ||
|
|
e4ca0a1c64 | ||
|
|
e6018f2f75 | ||
|
|
a9b4f8d841 | ||
|
|
7fe68857a0 | ||
|
|
4f63fc77a3 | ||
|
|
6e2ad7789e | ||
|
|
edb856c94f | ||
|
|
2f215fe2de | ||
|
|
ffa1279c64 | ||
|
|
83aca87dac | ||
|
|
bf782f6f65 | ||
|
|
7adad82786 | ||
|
|
693cf855f0 | ||
|
|
854a520517 | ||
|
|
6e6fc98cd1 | ||
|
|
3db15e73a5 | ||
|
|
215b659a9a | ||
|
|
7ef945d15b | ||
|
|
73ec345fcc | ||
|
|
c1c537a3b5 | ||
|
|
dc64076c79 | ||
|
|
da8ff51615 | ||
|
|
60b1bc87a4 | ||
|
|
7ed1857589 | ||
|
|
4c0e60f3d6 | ||
|
|
20ed3bb5fe | ||
|
|
be3f9c8fe8 | ||
|
|
e850955e55 | ||
|
|
eb5ee9860b | ||
|
|
f31bbdde02 | ||
|
|
f67c435378 | ||
|
|
bf9a60a202 | ||
|
|
9c3c07fa9b | ||
|
|
11786ca102 | ||
|
|
ffaea83e3e | ||
|
|
954540b944 | ||
|
|
204cf6769d | ||
|
|
f319bc4c50 | ||
|
|
7b9a11ac25 | ||
|
|
5d2feca2d4 | ||
|
|
dd97e9daee | ||
|
|
be258a1f7c | ||
|
|
72e9474f6f | ||
|
|
d1f63a7864 | ||
|
|
07ca18502b | ||
|
|
cddbe411f7 | ||
|
|
ffa60d1cfa | ||
|
|
88193b6a75 | ||
|
|
cc4a4607f1 | ||
|
|
6c25d0ab0d | ||
|
|
fbbbcd2612 | ||
|
|
dd57b1a007 | ||
|
|
47d0e68f7d | ||
|
|
7b6397215d | ||
|
|
5739b69757 | ||
|
|
2ca79f2f70 | ||
|
|
8fb64f77cd | ||
|
|
d1f86ce78e | ||
|
|
64ff226535 | ||
|
|
e762746ff0 | ||
|
|
ce5c8f7443 | ||
|
|
fc4cbb608c | ||
|
|
7ac3043f83 | ||
|
|
44b56fb0cb | ||
|
|
758ce567e5 | ||
|
|
cb5308b476 | ||
|
|
a9211690be | ||
|
|
a7db14a261 | ||
|
|
3a1f284fa8 | ||
|
|
a0b6c42629 | ||
|
|
f77ae4d99f | ||
|
|
5fa9af8fd3 | ||
|
|
1ff029dc11 | ||
|
|
4c8c9fbb07 | ||
|
|
7057cf365b | ||
|
|
d1bc48e936 | ||
|
|
2dee50f019 | ||
|
|
fa76378702 | ||
|
|
e855da1f13 | ||
|
|
adffde368c | ||
|
|
5278138cc3 | ||
|
|
98249a282e | ||
|
|
b7eeb992cd | ||
|
|
01daf32646 | ||
|
|
51a866fd35 | ||
|
|
53401e29ea | ||
|
|
774f41e6db | ||
|
|
1ca3b295a4 | ||
|
|
82828d8e09 | ||
|
|
131055c1d5 | ||
|
|
bd2e690261 | ||
|
|
1a2ca8ea38 | ||
|
|
0c98593aee | ||
|
|
416e2fbc96 | ||
|
|
c04fb9073e | ||
|
|
4f85ceb2c3 | ||
|
|
9196ce85a0 | ||
|
|
26734bf8bf | ||
|
|
53959d482d | ||
|
|
0a0f110c42 | ||
|
|
47f1350652 | ||
|
|
3c3b7290c2 | ||
|
|
006c686c18 | ||
|
|
44d4a07005 | ||
|
|
6e61be960c | ||
|
|
bd57359dc5 | ||
|
|
10bc6b4060 | ||
|
|
9e681c0666 | ||
|
|
e969382fd0 | ||
|
|
1949a13810 | ||
|
|
362262c4e1 | ||
|
|
ddd5eab7f5 | ||
|
|
1da6193f34 | ||
|
|
c4e553ad80 | ||
|
|
0b83a61600 | ||
|
|
382f7d75c8 | ||
|
|
88e4518f64 | ||
|
|
b1a657d68a | ||
|
|
067f17b28b | ||
|
|
99073e2a88 | ||
|
|
f9a42e47e7 | ||
|
|
b80d72edbd | ||
|
|
1f7b9f7f3a | ||
|
|
843efb2146 | ||
|
|
3619fabe5f | ||
|
|
bf598e392e | ||
|
|
f026137545 | ||
|
|
2264f53a43 | ||
|
|
8ba4029633 | ||
|
|
05cb2cef5a | ||
|
|
3a70594594 | ||
|
|
019cb58dd1 | ||
|
|
d487490ca0 | ||
|
|
b9fad61da0 | ||
|
|
77bf33b4e4 | ||
|
|
7ed7c9d3a8 | ||
|
|
0d2896630d | ||
|
|
74dbff32df | ||
|
|
4653cc0d84 | ||
|
|
50e115f6a1 | ||
|
|
8a5a86e8b3 | ||
|
|
48ef5af93f | ||
|
|
e5c20be666 | ||
|
|
6bf0d5eea9 | ||
|
|
21c57b60a1 | ||
|
|
b1dff22954 | ||
|
|
a3d0cb0999 | ||
|
|
bf946c20db | ||
|
|
664d2c8ab6 | ||
|
|
01a4d6b4a9 | ||
|
|
18454083db | ||
|
|
191abe4e08 | ||
|
|
97fbb4732d | ||
|
|
01f3666cc7 | ||
|
|
468fcdccaa | ||
|
|
c8dd26b0da | ||
|
|
61d5dec63a | ||
|
|
64a4bb2e17 | ||
|
|
f78bf9dde1 | ||
|
|
b7ba654e48 | ||
|
|
532a252fe0 | ||
|
|
614cf4e484 | ||
|
|
c576c689d0 | ||
|
|
d86cd94fe2 | ||
|
|
762b16ea13 | ||
|
|
09a72c0f31 | ||
|
|
eded5fede2 | ||
|
|
704df82b1d | ||
|
|
46efc10939 | ||
|
|
74cf8aa30c | ||
|
|
7a60ab81f8 | ||
|
|
c1d7ca67d5 | ||
|
|
7e1eb0fab0 | ||
|
|
af76d7fb04 | ||
|
|
afbe072ad5 | ||
|
|
d86c5be413 | ||
|
|
a695d2a5b5 | ||
|
|
1c087967d3 | ||
|
|
906732bcdc | ||
|
|
c9352af81c | ||
|
|
e2e8e3fedd | ||
|
|
3ca07a5bc8 | ||
|
|
89700f98c5 | ||
|
|
0cae3cf0fa | ||
|
|
eade586044 | ||
|
|
c227c6625c | ||
|
|
4cb8462d50 | ||
|
|
1d671d531c | ||
|
|
a49cd799dd | ||
|
|
8ed2bda3a8 | ||
|
|
2aabbe3cce | ||
|
|
7b37cc79a3 | ||
|
|
34a719e443 | ||
|
|
b440c9b0ea | ||
|
|
03e9a9676f | ||
|
|
094d6f7a1c | ||
|
|
33fd1b1c78 | ||
|
|
9968aa4606 | ||
|
|
9c337422a5 | ||
|
|
cc432e2291 | ||
|
|
aaff64404a | ||
|
|
bfe788cd31 | ||
|
|
883b191ae7 | ||
|
|
fa46debb90 | ||
|
|
ed4af1d04b | ||
|
|
4cea617b13 | ||
|
|
26b6a59725 | ||
|
|
35c63a52c8 | ||
|
|
61bc20aa7b | ||
|
|
db59fbff25 | ||
|
|
49b3104d04 | ||
|
|
2338ecc2d7 | ||
|
|
bab8c852a4 | ||
|
|
cba17aeb55 | ||
|
|
deca8ad216 | ||
|
|
fb4c840549 | ||
|
|
610234c1a1 | ||
|
|
7f39c573ce | ||
|
|
114c437671 | ||
|
|
e12f2f67c6 | ||
|
|
0c61850ad6 | ||
|
|
8b1a7a8584 | ||
|
|
4b6b0305e6 | ||
|
|
3b758a0d64 | ||
|
|
ea2c320f33 | ||
|
|
306857ae07 | ||
|
|
448ecd13bb | ||
|
|
011e24bd49 | ||
|
|
099992627b | ||
|
|
74e20864a6 | ||
|
|
d006f051a3 | ||
|
|
f1fe498801 | ||
|
|
1f2cd5a6f7 | ||
|
|
d6239cbe56 | ||
|
|
d82bb63acb | ||
|
|
a3ae4cf5d2 | ||
|
|
6b74ea39c2 | ||
|
|
87aab2eca5 | ||
|
|
1c6a2582f3 | ||
|
|
ea49095334 | ||
|
|
b2daf7482f | ||
|
|
b0165e41e7 | ||
|
|
0a27f63423 | ||
|
|
20d8a31258 | ||
|
|
ca186a4b2c | ||
|
|
7bd593c8f7 | ||
|
|
75220eb54f | ||
|
|
dde7d49598 | ||
|
|
a31921b88e | ||
|
|
a4c5ca45b2 | ||
|
|
c44cb1858e | ||
|
|
f89867a9ae | ||
|
|
be4b9a4133 | ||
|
|
46b1429da9 | ||
|
|
a70af20eba | ||
|
|
09dc78d6b1 | ||
|
|
921e329d18 | ||
|
|
f86aebf7e1 | ||
|
|
eef1c5327b | ||
|
|
2c25936e2c | ||
|
|
734213a2f9 | ||
|
|
16e0ea9315 | ||
|
|
c87ba33893 | ||
|
|
2875fdf2cf | ||
|
|
e73c147275 | ||
|
|
f080d6ed1c | ||
|
|
8ea07727ba | ||
|
|
3c47c3fdc3 |
+1
-1
@@ -1 +1 @@
|
||||
8
|
||||
17
|
||||
|
||||
+1
-1
@@ -4,6 +4,6 @@ exclude_patterns:
|
||||
- "**/*.test.js"
|
||||
- "**/*.test.ts"
|
||||
- "docs/**/*.js"
|
||||
- "packages/api/src/query.types.ts"
|
||||
- "packages/api/src/types/augment/"
|
||||
- "packages/types/src/interfaces/"
|
||||
- "packages/types/src/scripts/"
|
||||
|
||||
@@ -53,3 +53,15 @@ jobs:
|
||||
run: |
|
||||
yarn install --frozen-lockfile
|
||||
yarn polkadot-dev-ghact-docs
|
||||
|
||||
dummy:
|
||||
name: Dummy
|
||||
if: "contains(github.event.head_commit.message, '[CI Skip]')"
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [12.x]
|
||||
steps:
|
||||
- name: dummy
|
||||
run: |
|
||||
echo "Dummy skip step"
|
||||
|
||||
@@ -12,6 +12,7 @@ tmp/
|
||||
.env.production.local
|
||||
.npmrc
|
||||
.rpt2_cache
|
||||
.vscode/
|
||||
cc-test-reporter
|
||||
lerna-debug.log*
|
||||
npm-debug.log*
|
||||
|
||||
@@ -1,3 +1,76 @@
|
||||
# 1.1.1
|
||||
|
||||
- Add support for `balances.account` in all applicable derives (incl. `vesting` module)
|
||||
- Inject and use SignedExtensions by name from V11 metadata (V4 extrinsics only)
|
||||
- Add typings for `api.tx.*.*` - the `polkadot-types-from-chain` now also generates these
|
||||
- Remove additional V1-only derives `(staking.recentlyOffline`, `balances.nominatorsFor`)
|
||||
- Add `.isMax()` on int values, an opposite of `isZero()` (e.g. `u128`, as well as derived, e.g. `Balances`)
|
||||
- Add `.keyPrefix()` to all `api.query.*` complementing the `.key()` call, both returning a hex string
|
||||
- Council derives now takes bootstrapping (member, no elections) into account
|
||||
- Account derives now allow for an optional indices module (not required)
|
||||
- Adjust balances fees derivation with optional transfer and creation fees (removed in Substrate)
|
||||
- Adjust enum `.toJSON()` to return type name as specified
|
||||
|
||||
# 1.0.1
|
||||
|
||||
- **Breaking change** Drop support for Substrate v1 chain in all derives
|
||||
- Return unsub functions from provider .on emitters (Thanks to https://github.com/jak-pan)
|
||||
- `ApiPromise.isReady` now rejects on unrecoverable errors (Thanks to https://github.com/laec)
|
||||
- Add `polkadot-types-from-chain` & `polkadot-types-from-defs` TypeScript generators to `@polkadot/types`
|
||||
- Only decorate derives where relevant parent `api.query.*` is available
|
||||
- Support `.entries(arg?: any)` lookups on DoubleMaps (in addition to previously supported maps)
|
||||
- Allow v9 metadata to parse even in cases where it was wrongly deployed pre-v10
|
||||
- Allow type-aliases on a per-module basis (e.g. `Judgement` in identity as well as society)
|
||||
- Allow passing `{ signer }` to both `api.tx.*` and `api.sign` (in addition to `api.setSigner`)
|
||||
- Add derives for the society module
|
||||
- Don't map empty tuples, e.. `()` to `Null`, rather keep them empty
|
||||
- Add lookups to the metadata errors via `findMetaError`
|
||||
- Update metadata and types for the latest Substrate & Polkadot versions
|
||||
- Support metadata V11 as per latest Substrate
|
||||
- Remove support for un-deployed metadata
|
||||
- Remove old known types for Substrate V1
|
||||
|
||||
# 0.100.1
|
||||
|
||||
- **Important** This will the the last API version with Substrate 1.x support. Although you will still be able to use subsequent versions with older chans, dependent libraries such as sr25519 may not be compatible.
|
||||
- Add support for the Substrate identity module
|
||||
- Remove the `codec/Data` type, to remove a conflict with Substrate. This type is now named `Raw`
|
||||
- Fix for linked maps using `Option`
|
||||
- Add support for `BTreeSet` (Thanks to https://github.com/satellitex)
|
||||
- Add support for Metadata v10
|
||||
- Add support for latest Polkadot/Substrate types
|
||||
- Add `paymentInfo` to submittables to calculate fees
|
||||
|
||||
# 0.99.1
|
||||
|
||||
- **Breaking change** The `Data` and `U8a` type has been renamed and just replaced with the `Raw` type
|
||||
- **Breaking change** The `api.derive.staking.info` has been split into 2 - `staking.query` for non-balance related information (more effective) and `staking.account` that enhances query for all the information previously found `.info`
|
||||
- Cleanup `DoubleMap` hashing to always hash over the full value (in the case of `Vec<T>`, this includes the length)
|
||||
- Update democracy derives to take care of nextTally and lowestU*nbaked
|
||||
- Add additional derives for both council & treasury
|
||||
- Alignment with latest Polkadot/Substrate master branch types
|
||||
|
||||
# 0.98.1
|
||||
|
||||
- Make the TypeScript generation script mor re-usable (Thanks to https://github.com/xlc)
|
||||
- Add `.entries()` for all map-types, returning storage keys and values
|
||||
- Add `.signAsync` to submittable extrinsics (Thanks to https://github.com/c410-f3r)
|
||||
- Cleanup circular references between internal dependencies
|
||||
- Support for new Substrate democracy with preimages in derive
|
||||
- Alignment of types with Substrate/Polkadot master branches
|
||||
|
||||
# 0.97.1
|
||||
|
||||
- **Breaking change** Add the passing on an explicit `Registry` to all calls to `createType` as well as all codec classes. If you are upgrading form an older version, use the [migration guide](UPGRADING.md) to walk through the changes required.
|
||||
- **Breaking change** The metadata classes have been moved from `@polkadot/types` into `@polkadot/metadata`. If you explicitly create `Metadata` classes, you now would need to do so with the `import Metadata from '@polkadot/metadata';` This is a decorated class, where the previous metadata is now available on `Metadata.metadata`, alongside decorated `consts.*`', `tx.*` and `query.*`.
|
||||
- **Breaking change** Session `Keys` defaults to 4 keys now (Substrate master), depending on your node config, you would want to override with e.g. `Keys: 'SessionKeys3'` (1, 2, 3, 4, 5 & 6)
|
||||
- **Breaking change** `ValidatorPrefs` now default to the new percentage commission model, to use the previous `validatorPayment`, you can override with `ValidatorPrefs: 'ValidatorPrefsTo196'`
|
||||
- `api.derive.*` now has built-in memomization
|
||||
- Various fixes and cleanups to `api.derive.*` including era length progress and vesting calculations
|
||||
- Aligned all types with the latest Polkadot & Substrate, including Kusama CC3
|
||||
- Support for Metadata V9, which adjusts the hashing methods of storage entries
|
||||
- Support for Metadata V10 (still un-released), which includes prefixed map support
|
||||
|
||||
# 0.96.1
|
||||
|
||||
- Updated types for latest Kusama
|
||||
|
||||
+90
-6
@@ -2,7 +2,91 @@
|
||||
|
||||
This is an upgrade guide for users of the API. It does not attempt to detail each version (the [CHANGELOG](CHANGELOG.md) has all the changes between versions), but rather tries to explain the rationale behind major breaking changes and how users of the API should handle this.
|
||||
|
||||
While we try to keep the user-facing interfaces as stable as possible, sometimes you just need to make additions to move forward and improve things down the road, as painful as they may be. Like you, we are also users of the API, and eat our own dogfood - and as such, feel any pains introduced first.
|
||||
While we try to keep the user-facing interfaces as stable as possible, sometimes you just need to make additions to move forward and improve things down the road, as painful as they may be. Like you, we are also users of the API, and eat our own dog food - and as such, feel any pains introduced first.
|
||||
|
||||
|
||||
## 0.97.1 (and newer)
|
||||
|
||||
The 0.97 series lays the groundwork to allow type registration to be ties to a specific chain and a specific Api instance. In the past, 2 Api instances in the same process would share types, which mean that you could not connect to 2 independent chains with different types. This is very problematic for Polkadot chains, where the idea is to connect to multiple chains.
|
||||
|
||||
When using the Api, a new `Registry` will be created on using `new Api(...)` or `Api.create(...)` and this will be transparently passed when creating types. In the cases where you create type instances explicitly or create type classes for injection, you would need to make adjustments.
|
||||
|
||||
### Type classes
|
||||
|
||||
In a number of instances, developers are creating classes and making these available for interacting with their chains. For instance, an example of a custom type could be -
|
||||
|
||||
```js
|
||||
import { Struct, Text, u32 } from '@polkadot/types';
|
||||
|
||||
export class Preferences extends Struct {
|
||||
constructor (value?: ahy) {
|
||||
super({
|
||||
name: Text,
|
||||
id: u32
|
||||
}, value);
|
||||
}
|
||||
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
In the current iteration, the underlying `@polkadot/types` bases structures now require a `Registry` to be passed as the first parameter. This means that the above signature would be adjusted to -
|
||||
|
||||
```js
|
||||
// the next import is only required for TypeScript
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
import { Struct, Text, u32 } from '@polkadot/types';
|
||||
|
||||
export class Preferences extends Struct {
|
||||
constructor (registry: Registry, value?: ahy) {
|
||||
super(registry, {
|
||||
name: Text,
|
||||
id: u32
|
||||
}, value);
|
||||
}
|
||||
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Where the type is used or returned from the API, the `Registry` will be automatically passed to class creation.
|
||||
|
||||
### createType
|
||||
|
||||
Previously, when creating a type instance such as `BlockNumber`, you would do `api.createType('BlockNumber', <initValue>)`, this is unchanged. In the cases where you directly import from `@polkadot/types`, the following pattern is required -
|
||||
|
||||
```js
|
||||
import { createType } from '@polkadot/types';
|
||||
|
||||
...
|
||||
const blockNumber = createType(api.registry, 'BlockNumber', 12345);
|
||||
```
|
||||
|
||||
In some cases, you would want to explicitly pass a `Registry` interface to the API, instead of relying on it explicitly. This is generally applicable in the cases where you want to use the `createType` independently from the API -
|
||||
|
||||
```js
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import { TypeRegistry, createType } from '@polkadot/types';
|
||||
|
||||
...
|
||||
const registry = new TypeRegistry();
|
||||
const blockNumber = createType(registry, 'BlockNumber', 12345);
|
||||
const api = await ApiPromise.create({ registry });
|
||||
```
|
||||
|
||||
### Extrinsic metadata
|
||||
|
||||
In some applications, the undocumented `findFunction` has been used to determine the Api has the metadata for a specific extrinsic. The has been exposed on top of `GenericCall`, and it typically used in applications such as signers. Along with the compulsory registry, the above functions have been moved to the `Registry` itself, so if you previously had -
|
||||
|
||||
```js
|
||||
const { meta, method, section } = GenericCall.findFunction(extrinsic.callIndex);
|
||||
```
|
||||
|
||||
You need to change it to -
|
||||
|
||||
```js
|
||||
const { meta, method, section } = registry.findMetaCall(extrinsic.callIndex);
|
||||
```
|
||||
|
||||
## 0.90.1 (and newer), from 0.81.1 (and older)
|
||||
|
||||
@@ -29,10 +113,10 @@ To better align with the actual types from the metadata, and avoid (too much) co
|
||||
|
||||
The [@polkadot/api](packages/api) has always handled the conversion of types for parameters when making calls or queries. For example, when making a transfer to `BOB` (address), any of the following is valid -
|
||||
|
||||
- `api.tx.balances.transfer(BOB, 12345)` - value specied as a number
|
||||
- `api.tx.balances.transfer(BOB, '12345')` - value specied as a string
|
||||
- `api.tx.balances.transfer(BOB, '0x3039')` - value specied as a hex
|
||||
- `api.tx.balances.transfer(BOB, new BN(12345))` - value specied as a [BN](https://github.com/indutny/bn.js/)
|
||||
- `api.tx.balances.transfer(BOB, 12345)` - value specified as a number
|
||||
- `api.tx.balances.transfer(BOB, '12345')` - value specified as a string
|
||||
- `api.tx.balances.transfer(BOB, '0x3039')` - value specified as a hex
|
||||
- `api.tx.balances.transfer(BOB, new BN(12345))` - value specified as a [BN](https://github.com/indutny/bn.js/)
|
||||
|
||||
Internally the API will take the input and convert the value into a `Balance`, serialize it using the SCALE codec and transfer it to the node. In some cases users would construct the `Balance` type manually, by importing the class and calling `new` on it. This last approach has now been removed, and where classes are still available (limited reach), discouraged.
|
||||
|
||||
@@ -108,7 +192,7 @@ export class MyStruct extends Struct {
|
||||
}
|
||||
```
|
||||
|
||||
Internally the [@polkadot/types](packages/types) package now only defines classes where there are specific encoding logic applied. For all other types, the definitions are done via a JSON-like format and then the TypeScript definitions are generated from these. (In a world where nodes inject types and the type definitions are not needed, this functionality will be useful to allow TS devs to auto-generate type definitions based on what the node defines.)
|
||||
Internally the [@polkadot/types](packages/types) package now only defines classes where there are specific encoding logic applied. For all other types, the definitions are done via a JSON-like format and then the TypeScript definitions are generated from these. (In a world where nodes inject types and the type definitions are not needed, this functionality will be useful to allow TS developers to auto-generate type definitions based on what the node defines.)
|
||||
|
||||
### Signing transactions (Signer interface)
|
||||
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ yarn polkadot-dev-build-ts
|
||||
copy_folder "api" "api"
|
||||
copy_folder "api-contract" "api-contract"
|
||||
copy_folder "api-derive" "api-derive"
|
||||
copy_folder "api-metadata" "api-metadata"
|
||||
copy_folder "metadata" "metadata"
|
||||
copy_folder "rpc-core" "rpc-core"
|
||||
copy_folder "rpc-provider" "rpc-provider"
|
||||
copy_folder "type-jsonrpc" "jsonrpc"
|
||||
|
||||
@@ -45,6 +45,7 @@ module.exports = {
|
||||
['start/types.extend.md', 'Extending types'],
|
||||
['start/extrinsic.extend.md', 'Extending extrinsics'],
|
||||
['start/typescript.md', 'TypeScript interfaces'],
|
||||
['start/typescript.user.md', 'TypeScript user generated'],
|
||||
['start/FAQ.md', 'FAQ']
|
||||
]
|
||||
},
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
- [Type basics](start/types.basics.md)
|
||||
- [Type extension](start/types.extend.md)
|
||||
- [TypeScript interfaces](start/typescript.md)
|
||||
- [TypeScript user generated](start/typescript.user.md)
|
||||
|
||||
## Packages
|
||||
|
||||
|
||||
@@ -46,11 +46,6 @@ As of this writing, there are still some gray areas to type detection, specifica
|
||||
- `.at` & `.multi` on `api.query` does not (yet) have a `<TypeOverride>` interface. This means `as <TypeOverride>` casts are presently needed for these results
|
||||
- `api.queryMulti` does not (yet) allow you to provide a hint to the types returned, this ties to the previous point
|
||||
|
||||
In addition to expanding the type coverage, we wish to make the actual generation script for the types from `@polkadot/types/interfaces` available in 2 ways -
|
||||
## Adding user types
|
||||
|
||||
- allowing you to point to a folder of types and auto-generate the TypeScript typings from those. (Which is akin to what we do internally). This would allow a reduction in type classes explicitly written and injected.
|
||||
- once the metadata itself supports full type definitions, the script can be used to generate interface definitions specifically tailored for a chain
|
||||
|
||||
## And that's a wrap
|
||||
|
||||
This brings us to the end of our overview and jump through the API. While the documentation is still very much and ever evolving item, we can encourage you to try out what you have learned with some [examples](../examples). As we [indicated right at the start of this journey](README.md#help-us-help-others), if there are areas for improvement, let us know.
|
||||
In addition to the generated and available interfaces, there is also the ability to [create TypeScript interfaces from your own definitions and well as your on-chain modules](typescript.user.md).
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
# TypeScript user generated
|
||||
|
||||
In the previous section we looked at the TypeScript definitions that are available and is generated from both the chain and definitions. Here we will expand upon the use of the infrastructure created to define types as part of the `@polkadot/types` library and see how to use them to generate your onw defintions and chain types.
|
||||
|
||||
## Definitions
|
||||
|
||||
A large part of the type definitions are defined not as classes, but rather as structures from which type definitions are extracted and that can be used as-is to let the API know how to decode a type. By now you should be familiar with [type extensions](types.extend.md), but effectively the [types library does exactly the same](https://github.com/polkadot-js/api/tree/master/packages/types/src/interfaces).
|
||||
|
||||
To create TypeScript-aware definitions and keep your files in a single place, you can follow the same approach. Assuming you have a package named `@MeInc/stuff` where you have the definitions in an `stuff/interfaces` folder. Each sub-folder would indicate a runtime module, e.g.
|
||||
|
||||
- `stuff/interfaces/<module>/definitions.ts` for each module (`types.ts` & `index.ts` will be generated)
|
||||
- `stuff/interfaces/defnitions.ts` importing all sub-definitions`
|
||||
|
||||
With this structure setup, you can generate TypeScript defintions.
|
||||
|
||||
In the root of your project (with the `@polkadot/api`), you can run `yarn polkadot-types-from-defs --input ./stuff/interfaces --package @MeInc/stuff/interfaces` which will create `types.ts` and `index.ts` files with the generated types. You can use these in exactly the same way as you would use your types from `@polkadot/types/interfaces`.
|
||||
|
||||
## Chain modules
|
||||
|
||||
In the same way as the type library provides defaults from a substrate-base chain, you can also, directly from chain from metadata, generate a complete `api.{consts,query}.*` defintion for your specific chain. The command will create 2 files, `{consts, query}.types.ts` which you can either use to augment the TypeScript defintions, or replace those in `@polkadot/api/*` with your versions (copy, TypeScript replacement or browser/node aliassing).
|
||||
|
||||
In the root of your project, you can run `yarn polkadot-types-from-chain --endpoint wss://<url> --output ./stuff` and it will create the required output. (Here you can specify an optional `--package @MeInc/stuff` to read definitions for the targetted output folder with the specified package name.)
|
||||
|
||||
## And that's a wrap
|
||||
|
||||
This brings us to the end of our overview and jump through the API. While the documentation is still very much and ever evolving item, we can encourage you to try out what you have learned with some [examples](../examples). As we [indicated right at the start of this journey](README.md#help-us-help-others), if there are areas for improvement, let us know.
|
||||
+4
-3
@@ -6,8 +6,8 @@ module.exports = Object.assign({}, config, {
|
||||
moduleNameMapper: {
|
||||
'@polkadot/api-contract(.*)$': '<rootDir>/packages/api-contract/src/$1',
|
||||
'@polkadot/api-derive(.*)$': '<rootDir>/packages/api-derive/src/$1',
|
||||
'@polkadot/api-metadata(.*)$': '<rootDir>/packages/api-metadata/src/$1',
|
||||
'@polkadot/api(.*)$': '<rootDir>/packages/api/src/$1',
|
||||
'@polkadot/metadata(.*)$': '<rootDir>/packages/metadata/src/$1',
|
||||
'@polkadot/rpc-(core|provider)(.*)$': '<rootDir>/packages/rpc-$1/src/$2',
|
||||
'@polkadot/jsonrpc(.*)$': '<rootDir>/packages/type-jsonrpc/src/$1',
|
||||
'@polkadot/types(.*)$': '<rootDir>/packages/types/src/$1'
|
||||
@@ -16,7 +16,7 @@ module.exports = Object.assign({}, config, {
|
||||
'<rootDir>/packages/api/build',
|
||||
'<rootDir>/packages/api-derive/build',
|
||||
'<rootDir>/packages/api-contract/build',
|
||||
'<rootDir>/packages/api-metadata/build',
|
||||
'<rootDir>/packages/metadata/build',
|
||||
'<rootDir>/packages/rpc-core/build',
|
||||
'<rootDir>/packages/rpc-provider/build',
|
||||
'<rootDir>/packages/type-jsonrpc/build',
|
||||
@@ -31,5 +31,6 @@ module.exports = Object.assign({}, config, {
|
||||
ws_local_polkadot_alex: 'ws://127.0.0.1:9949/',
|
||||
ws_substrate_1: 'wss://substrate-rpc.parity.io/',
|
||||
ws_polkadot_alex: 'wss://poc3-rpc.polkadot.io/'
|
||||
}
|
||||
},
|
||||
resolver: './jest.resolver.js'
|
||||
});
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright 2017-2020 @polkadot/util authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const path = require('path');
|
||||
|
||||
module.exports = function resolver (file, config) {
|
||||
if (file.includes('package.json')) {
|
||||
console.error(file, config);
|
||||
return path.join(config.basedir.replace('/src', '/'), file);
|
||||
}
|
||||
|
||||
return config.defaultResolver(file, config);
|
||||
};
|
||||
+1
-1
@@ -9,5 +9,5 @@
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "0.96.1"
|
||||
"version": "1.1.1"
|
||||
}
|
||||
|
||||
+8
-10
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "0.96.1",
|
||||
"version": "1.1.1",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"yarn": "^1.10.1"
|
||||
@@ -9,11 +9,12 @@
|
||||
],
|
||||
"resolutions": {
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"typescript": "^3.7.2"
|
||||
"typescript": "^3.7.5"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn build:interfaces && polkadot-dev-build-ts",
|
||||
"build:interfaces": "node packages/types/src/scripts/interfacesTsWrapper.js",
|
||||
"circular": "madge --circular --extensions ts ./",
|
||||
"docs": "node packages/types/src/scripts/MetadataMdWrapper.js && polkadot-dev-build-docs",
|
||||
"chain:info": "node packages/types/src/scripts/extractChainWrapper.js",
|
||||
"lint": "eslint --ext .js,.jsx,.ts,.tsx . && tsc --noEmit --pretty",
|
||||
@@ -21,17 +22,14 @@
|
||||
"postinstall": "polkadot-dev-yarn-only",
|
||||
"test": "jest --coverage --runInBand --testPathIgnorePatterns e2e",
|
||||
"test:all": "jest",
|
||||
"test:e2e": "jest packages/api/test/e2e",
|
||||
"test:e2e-docker": "TEST_DOCKER=1 jest packages/api/test/e2e",
|
||||
"test:e2e-remote": "TEST_REMOTE=1 jest packages/api/test/e2e",
|
||||
"test:one": "jest",
|
||||
"test:watch": "jest --coverage --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.7.0",
|
||||
"@babel/register": "^7.7.0",
|
||||
"@babel/runtime": "^7.6.3",
|
||||
"@polkadot/dev": "^0.32.0-beta.13",
|
||||
"@polkadot/ts": "^0.1.84"
|
||||
"@babel/core": "^7.8.3",
|
||||
"@babel/register": "^7.8.3",
|
||||
"@babel/runtime": "^7.8.3",
|
||||
"@polkadot/dev": "^0.33.3",
|
||||
"@polkadot/ts": "^0.2.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
Interfaces to allow for the encoding and decoding of Substrate contract ABIs.
|
||||
|
||||
```js
|
||||
import {ApiPromise, WsProvider } from '@polkadot/api';
|
||||
import { Abi } from '@polkadot/api-contract';
|
||||
|
||||
const abi = new Abi(<...JSON ABI...>);
|
||||
const wsProvider = new WsProvider(<...Node Url...>);
|
||||
const api = await ApiPromise.create({ provider: wsProvider });
|
||||
const abi = new Abi(api.registry, <...JSON ABI...>);
|
||||
|
||||
api.tx.contracts
|
||||
.call(<contract addr>, <value>, <max gas>, abi.messages.<method name>(<...params...>))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-contract",
|
||||
"version": "0.96.1",
|
||||
"version": "1.1.1",
|
||||
"description": "Interfaces for interacting with contracts and contract ABIs",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -26,7 +26,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.7.1",
|
||||
"@polkadot/types": "^0.96.1"
|
||||
"@babel/runtime": "^7.8.3",
|
||||
"@polkadot/types": "^1.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import incrementerAbi from '../test/contracts/incrementer.json';
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import incrementerAbi from '../test/contracts/incrementer.json';
|
||||
import { Abi } from '.';
|
||||
|
||||
describe('Abi', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
describe('incrementer', (): void => {
|
||||
let abi: Abi;
|
||||
|
||||
beforeEach((): void => {
|
||||
abi = new Abi(incrementerAbi);
|
||||
abi = new Abi(registry, incrementerAbi);
|
||||
});
|
||||
|
||||
it('has the attached methods', (): void => {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
import { AbiConstructors, AbiMessages, ContractABI, ContractABIPre, ContractABIFn, InterfaceAbi } from './types';
|
||||
|
||||
import { stringCamelCase } from '@polkadot/util';
|
||||
|
||||
import ContractRegistry from './ContractRegistry';
|
||||
@@ -14,8 +16,8 @@ export default class ContractAbi extends ContractRegistry implements InterfaceAb
|
||||
|
||||
public readonly messages: AbiMessages;
|
||||
|
||||
constructor (abi: ContractABIPre) {
|
||||
super(abi);
|
||||
constructor (registry: Registry, abi: ContractABIPre) {
|
||||
super(registry, abi);
|
||||
[this.abi, this.constructors, this.messages] = this.decodeAbi(abi);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { CodecArg, Constructor, TypeDef } from '@polkadot/types/types';
|
||||
import { CodecArg, Constructor, Registry, TypeDef } from '@polkadot/types/types';
|
||||
import { ContractABIArgBasePre, ContractABIContract, ContractABIContractPre, ContractABIEvent, ContractABIEventPre, ContractABIFn, ContractABIFnArg, ContractABIMessage, ContractABIMessageBase, ContractABIMessagePre, ContractABI, ContractABIMessageCommon, ContractABIPre, ContractABIRange, ContractABIRangePre, ContractABIStorage, ContractABIStorageLayout, ContractABIStorageLayoutPre, ContractABIStoragePre, ContractABIStorageStruct, ContractABIStorageStructPre, ContractABITypePre } from './types';
|
||||
import { Compact, u32, createClass, createType, encodeType } from '@polkadot/types';
|
||||
|
||||
import { Compact, u32, createClass, createType, encodeType } from '@polkadot/types';
|
||||
import { assert, hexToU8a, isNumber, isString, isNull, isObject, isUndefined, stringCamelCase, isHex, hexToNumber } from '@polkadot/util';
|
||||
|
||||
import MetaRegistry from './MetaRegistry';
|
||||
|
||||
// parse a selector, this can be a number (older) or of [<hex>, <hex>, ...]. However,
|
||||
// just catch everything (since this is now non-standard for u32 anyway)
|
||||
function parseSelector (fnname: string, input: ContractABIMessageCommon['selector']): u32 {
|
||||
function parseSelector (registry: Registry, fnname: string, input: ContractABIMessageCommon['selector']): u32 {
|
||||
if (isNumber(input)) {
|
||||
return createType('u32', input);
|
||||
return createType(registry, 'u32', input);
|
||||
} else if (isHex(input)) {
|
||||
return createType('u32', hexToU8a(input));
|
||||
return createType(registry, 'u32', hexToU8a(input));
|
||||
} else if (typeof input === 'string') {
|
||||
try {
|
||||
const array = JSON.parse(input);
|
||||
|
||||
assert(array.length === 4, `${fnname}: Invalid selector length`);
|
||||
|
||||
return createType('u32', Uint8Array.from(
|
||||
return createType(registry, 'u32', Uint8Array.from(
|
||||
// the as number[] is here to pacify TS, it doesn't quite know how to handle the cb
|
||||
(array as number[]).map((value: string | number): number =>
|
||||
isHex(value)
|
||||
@@ -39,8 +39,9 @@ function parseSelector (fnname: string, input: ContractABIMessageCommon['selecto
|
||||
throw new Error(`${fnname}: Unable to parse selector`);
|
||||
}
|
||||
|
||||
function createArgClass (args: ContractABIFnArg[], baseDef: Record<string, string>): Constructor {
|
||||
function createArgClass (registry: Registry, args: ContractABIFnArg[], baseDef: Record<string, string>): Constructor {
|
||||
return createClass(
|
||||
registry,
|
||||
JSON.stringify(
|
||||
args.reduce((base: Record<string, any>, { name, type }): Record<string, any> => {
|
||||
base[name] = type.displayName || encodeType(type);
|
||||
@@ -87,7 +88,7 @@ export default class ContractRegistry extends MetaRegistry {
|
||||
assert(isNumber(name) && isString(this.stringAt(name)), `Expected name for ${fnname}`);
|
||||
assert(isNull(returnType) || (isNumber(returnType.ty) && isObject(this.typeDefAt(returnType.ty))), `Expected return_type for ${fnname}`);
|
||||
|
||||
parseSelector(fnname, selector);
|
||||
parseSelector(this.registry, fnname, selector);
|
||||
this.validateArgs(fnname, message.args);
|
||||
});
|
||||
}
|
||||
@@ -113,12 +114,13 @@ export default class ContractRegistry extends MetaRegistry {
|
||||
type
|
||||
};
|
||||
});
|
||||
const Clazz = createArgClass(args, isUndefined(message.selector) ? {} : { __selector: 'u32' });
|
||||
const baseStruct: { [index: string]: any } = { __selector: isUndefined(message.selector) ? undefined : parseSelector(name, message.selector) };
|
||||
const Clazz = createArgClass(this.registry, args, isUndefined(message.selector) ? {} : { __selector: 'u32' });
|
||||
const baseStruct: { [index: string]: any } = { __selector: isUndefined(message.selector) ? undefined : parseSelector(this.registry, name, message.selector) };
|
||||
const encoder = (...params: CodecArg[]): Uint8Array => {
|
||||
assert(params.length === args.length, `Expected ${args.length} arguments to contract ${name}, found ${params.length}`);
|
||||
|
||||
const u8a = new Clazz(
|
||||
this.registry,
|
||||
args.reduce((mapped, { name }, index): Record<string, CodecArg> => {
|
||||
mapped[name] = params[index];
|
||||
|
||||
|
||||
@@ -1,33 +1,42 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import MetaRegistry from './MetaRegistry';
|
||||
|
||||
import erc20Abi from '../test/contracts/Erc20.json';
|
||||
import erc20Cmp from '../test/compare/erc20.test.json';
|
||||
import sharedVecAbi from '../test/contracts/SharedVecV2.json';
|
||||
import sharedVecCmp from '../test/compare/shared-vec.test.json';
|
||||
import test001Abi from '../test/abi/test001.json';
|
||||
import test001Cmp from '../test/compare/test001.cmp.json';
|
||||
|
||||
function compare (meta: MetaRegistry, other: any): void {
|
||||
try {
|
||||
expect(meta.typeDefs).toEqual(other);
|
||||
} catch (error) {
|
||||
console.error(JSON.stringify(meta.typeDefs));
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
describe('MetaRegistry', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
describe('construction', (): void => {
|
||||
it('initializes from a contract ABI (ERC20)', (): void => {
|
||||
const metaRegistry = new MetaRegistry(erc20Abi);
|
||||
fs.writeFile(path.join(__dirname, '../test/compare/erc20.test.json'), JSON.stringify(metaRegistry.typeDefs, null, 2), function (err): void {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
expect(true).toBe(true);
|
||||
compare(new MetaRegistry(registry, erc20Abi), erc20Cmp);
|
||||
});
|
||||
|
||||
it('initializes from a contract ABI (SharedVec)', (): void => {
|
||||
const metaRegistry = new MetaRegistry(sharedVecAbi);
|
||||
fs.writeFile(path.join(__dirname, '../test/compare/shared-vec.test.json'), JSON.stringify(metaRegistry.typeDefs, null, 2), function (err): void {
|
||||
if (err) throw err;
|
||||
});
|
||||
compare(new MetaRegistry(registry, sharedVecAbi), sharedVecCmp);
|
||||
});
|
||||
|
||||
expect(true).toBe(true);
|
||||
it('initializes from a contract ABI (Other, test001)', (): void => {
|
||||
compare(new MetaRegistry(registry, test001Abi), test001Cmp);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { MetaRegistryItem, MetaRegistryJson, MetaTypeDefClikeEnum, MetaType, MetaTypeDefEnum, MetaTypeDefEnumVariant, MetaTypeDefEnumVariantStruct, MetaTypeDefEnumVariantTupleStruct, MetaTypeDefEnumVariantUnit, MetaTypeDefStruct, MetaTypeDefStructField, MetaTypeDefTupleStruct, MetaTypeDefUnion, MetaTypeIdCustom, MetaTypeIdVec, MetaTypeIdVecFixed, MetaTypeInfo, StringIndex, TypeDef, TypeDefInfo, TypeIndex } from '@polkadot/types/types';
|
||||
import { MetaRegistryItem, MetaRegistryJson, MetaTypeDefClikeEnum, MetaType, MetaTypeDefEnum, MetaTypeDefEnumVariant, MetaTypeDefEnumVariantStruct, MetaTypeDefEnumVariantTupleStruct, MetaTypeDefEnumVariantUnit, MetaTypeDefStruct, MetaTypeDefStructField, MetaTypeDefTupleStruct, MetaTypeDefUnion, MetaTypeIdCustom, MetaTypeIdVec, MetaTypeIdVecFixed, MetaTypeInfo, Registry, StringIndex, TypeDef, TypeDefInfo, TypeIndex } from '@polkadot/types/types';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
import { displayType, withTypeString } from '@polkadot/types';
|
||||
@@ -34,13 +34,16 @@ function detectedType ({ def, id }: MetaType): MetaTypeInfo {
|
||||
}
|
||||
|
||||
class MetadataRegistryLookup {
|
||||
public readonly registry: Registry;
|
||||
|
||||
protected _strings: string[] = [];
|
||||
|
||||
protected _types: MetaType[] = [];
|
||||
|
||||
public typeDefs: TypeDef[] = [];
|
||||
|
||||
constructor ({ registry: { strings, types } }: MetaRegistryJson) {
|
||||
constructor (registry: Registry, { registry: { strings, types } }: MetaRegistryJson) {
|
||||
this.registry = registry;
|
||||
this._strings = strings;
|
||||
this._types = types;
|
||||
}
|
||||
@@ -102,8 +105,8 @@ class MetadataRegistryLookup {
|
||||
}
|
||||
|
||||
export default class MetaRegistry extends MetadataRegistryLookup {
|
||||
constructor (json: MetaRegistryJson) {
|
||||
super(json);
|
||||
constructor (registry: Registry, json: MetaRegistryJson) {
|
||||
super(registry, json);
|
||||
|
||||
// Generate TypeDefs for each provided registry type
|
||||
this._types.forEach((_, index: number): void => this.setTypeDefAtIndex(index + 1));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -41,7 +41,7 @@ export default class Blueprint<ApiType extends ApiTypes> extends BaseWithTx<ApiT
|
||||
constructor (api: ApiObject<ApiType>, abi: ContractABIPre | Abi, decorateMethod: DecorateMethod<ApiType>, codeHash: string | Hash) {
|
||||
super(api, abi, decorateMethod);
|
||||
|
||||
this.codeHash = createType('Hash', codeHash);
|
||||
this.codeHash = createType(this.registry, 'Hash', codeHash);
|
||||
}
|
||||
|
||||
public deployContract (constructorIndex = 0, endowment: number | BN, maxGas: number | BN, ...params: any[]): BlueprintCreate<ApiType> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -41,10 +41,10 @@ export default class Contract<ApiType extends ApiTypes> extends BaseWithTxAndRpc
|
||||
|
||||
return {
|
||||
send: this.decorateMethod(
|
||||
as === 'rpc'
|
||||
as === 'rpc' && this.hasRpcContractsCall
|
||||
? (account: IKeyringPair | string | AccountId | Address): ContractCallResult<'rpc'> => {
|
||||
return this.rpcContractsCall(
|
||||
createType('ContractCallRequest', {
|
||||
createType(this.registry, 'ContractCallRequest', {
|
||||
origin: account,
|
||||
dest: this.address.toString(),
|
||||
value,
|
||||
@@ -54,7 +54,7 @@ export default class Contract<ApiType extends ApiTypes> extends BaseWithTxAndRpc
|
||||
)
|
||||
.pipe(
|
||||
map((result: ContractExecResult): ContractCallOutcome =>
|
||||
this.createOutcome(result, createType('AccountId', account), def, params)
|
||||
this.createOutcome(result, createType(this.registry, 'AccountId', account), def, params)
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -74,8 +74,8 @@ export default class Contract<ApiType extends ApiTypes> extends BaseWithTxAndRpc
|
||||
const { data } = result.asSuccess;
|
||||
|
||||
output = message.returnType
|
||||
? formatData(data, message.returnType)
|
||||
: createType('Data', data);
|
||||
? formatData(this.registry, data, message.returnType)
|
||||
: createType(this.registry, 'Raw', data);
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -92,6 +92,6 @@ export default class Contract<ApiType extends ApiTypes> extends BaseWithTxAndRpc
|
||||
constructor (api: ApiObject<ApiType>, abi: ContractABIPre | Abi, decorateMethod: DecorateMethod<ApiType>, address: string | AccountId | Address) {
|
||||
super(api, abi, decorateMethod);
|
||||
|
||||
this.address = createType('Address', address);
|
||||
this.address = createType(this.registry, 'Address', address);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
// Copyright 2017-2019 @polkadot/api authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiTypes, DecorateMethod, DecoratedRpc, SubmittableModuleExtrinsics } from '@polkadot/api/types';
|
||||
import { RpcInterface } from '@polkadot/rpc-core/types';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
import { ApiObject, ContractABIMessage, ContractABIPre, ContractBase, ContractMessage } from '../types';
|
||||
import { RpcInterface } from '@polkadot/rpc-core/jsonrpc.types';
|
||||
|
||||
import { assert, stringCamelCase } from '@polkadot/util';
|
||||
import { assert, isFunction, stringCamelCase } from '@polkadot/util';
|
||||
import Abi from '../Abi';
|
||||
|
||||
export abstract class Base<ApiType extends ApiTypes> implements ContractBase<ApiType> {
|
||||
@@ -16,10 +17,13 @@ export abstract class Base<ApiType extends ApiTypes> implements ContractBase<Api
|
||||
|
||||
public readonly decorateMethod: DecorateMethod<ApiType>;
|
||||
|
||||
public readonly registry: Registry;
|
||||
|
||||
constructor (api: ApiObject<ApiType>, abi: ContractABIPre | Abi, decorateMethod: DecorateMethod<ApiType>) {
|
||||
this.abi = abi instanceof Abi
|
||||
? abi
|
||||
: new Abi(abi);
|
||||
: new Abi(api.registry, abi);
|
||||
this.registry = api.registry;
|
||||
this.api = api;
|
||||
this.decorateMethod = decorateMethod;
|
||||
}
|
||||
@@ -62,13 +66,13 @@ export abstract class BaseWithTx<ApiType extends ApiTypes> extends Base<ApiType>
|
||||
}
|
||||
|
||||
export abstract class BaseWithTxAndRpcCall<ApiType extends ApiTypes> extends BaseWithTx<ApiType> {
|
||||
public get hasRpcContractsCall (): boolean {
|
||||
return isFunction(this.api.rx.rpc.contracts?.call);
|
||||
}
|
||||
|
||||
protected get rpcContractsCall (): DecoratedRpc<'rxjs', RpcInterface>['contracts']['call'] {
|
||||
assert(this.hasRpcContractsCall, 'You need to connect to a node with the contracts.call RPC method.');
|
||||
|
||||
return this.api.rx.rpc.contracts.call;
|
||||
}
|
||||
|
||||
constructor (api: ApiObject<ApiType>, abi: ContractABIPre | Abi, decorateMethod: DecorateMethod<ApiType>) {
|
||||
super(api, abi, decorateMethod);
|
||||
|
||||
assert(this.api.rx.rpc.contracts && this.api.rx.tx.contracts.call, 'You need to connect to a node with the contracts module, the metadata does not enable api.rpc.contracts.call on this instance');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
// Copyright 2017-2019 @polkadot/rpc-core authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/rpc-core authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Codec, TypeDefInfo, TypeDef } from '@polkadot/types/types';
|
||||
import { Codec, Registry, TypeDefInfo, TypeDef } from '@polkadot/types/types';
|
||||
|
||||
import { Data, Option, createClass } from '@polkadot/types';
|
||||
import { Option, Raw, createClass } from '@polkadot/types';
|
||||
import { createTypeUnsafe } from '@polkadot/types/codec';
|
||||
|
||||
export function formatData (data: Data, { info, type }: TypeDef): Codec {
|
||||
const u8a = data.toU8a();
|
||||
|
||||
export function formatData (registry: Registry, data: Raw, { info, type }: TypeDef): Codec {
|
||||
if (info === TypeDefInfo.Option) {
|
||||
return new Option(
|
||||
createClass(type),
|
||||
createTypeUnsafe(type, [u8a], true)
|
||||
registry,
|
||||
createClass(registry, type),
|
||||
createTypeUnsafe(registry, type, [data], true)
|
||||
);
|
||||
}
|
||||
|
||||
return createTypeUnsafe(type, [u8a], true);
|
||||
return createTypeUnsafe(registry, type, [data], true);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,467 @@
|
||||
{
|
||||
"registry": {
|
||||
"strings": [
|
||||
"StorageAndEnv",
|
||||
"app",
|
||||
"__ink_private",
|
||||
"__ink_storage",
|
||||
"__storage",
|
||||
"Storage",
|
||||
"value",
|
||||
"Value",
|
||||
"ink_core",
|
||||
"storage",
|
||||
"cell",
|
||||
"SyncCell",
|
||||
"sync_cell",
|
||||
"Key",
|
||||
"key",
|
||||
"name",
|
||||
"vec",
|
||||
"Vec",
|
||||
"elems",
|
||||
"__env",
|
||||
"EnvAccess",
|
||||
"env2",
|
||||
"env_access",
|
||||
"immutable",
|
||||
"TestEnv",
|
||||
"test",
|
||||
"accessor",
|
||||
"DefaultSrmlTypes",
|
||||
"types",
|
||||
"access",
|
||||
"EnvAccessMut",
|
||||
"mutable",
|
||||
"env",
|
||||
"PhantomData",
|
||||
"buffer",
|
||||
"has_interacted",
|
||||
"has_returned_value",
|
||||
"new",
|
||||
"init_value",
|
||||
"bool",
|
||||
"default",
|
||||
"flip",
|
||||
"get"
|
||||
],
|
||||
"types": [
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 1,
|
||||
"custom.namespace": [
|
||||
2,
|
||||
2,
|
||||
3,
|
||||
4
|
||||
],
|
||||
"custom.params": []
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 5,
|
||||
"type": 2
|
||||
},
|
||||
{
|
||||
"name": 20,
|
||||
"type": 14
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 6,
|
||||
"custom.namespace": [
|
||||
2,
|
||||
2,
|
||||
3,
|
||||
4
|
||||
],
|
||||
"custom.params": []
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 7,
|
||||
"type": 3
|
||||
},
|
||||
{
|
||||
"name": 16,
|
||||
"type": 9
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 8,
|
||||
"custom.namespace": [
|
||||
9,
|
||||
10,
|
||||
7
|
||||
],
|
||||
"custom.params": [
|
||||
4
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 11,
|
||||
"type": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "bool",
|
||||
"def": "builtin"
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 12,
|
||||
"custom.namespace": [
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
13
|
||||
],
|
||||
"custom.params": [
|
||||
4
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 11,
|
||||
"type": 6
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 14,
|
||||
"custom.namespace": [
|
||||
9,
|
||||
10,
|
||||
15
|
||||
],
|
||||
"custom.params": []
|
||||
},
|
||||
"def": {
|
||||
"tuple_struct.types": [
|
||||
7
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"array.len": 32,
|
||||
"array.type": 8
|
||||
},
|
||||
"def": "builtin"
|
||||
},
|
||||
{
|
||||
"id": "u8",
|
||||
"def": "builtin"
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 8,
|
||||
"custom.namespace": [
|
||||
9,
|
||||
10,
|
||||
7
|
||||
],
|
||||
"custom.params": [
|
||||
10
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 11,
|
||||
"type": 13
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "str",
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 17,
|
||||
"type": 11
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 18,
|
||||
"custom.namespace": [],
|
||||
"custom.params": [
|
||||
8
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 19,
|
||||
"type": 12
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"slice.type": 8
|
||||
},
|
||||
"def": "builtin"
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 12,
|
||||
"custom.namespace": [
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
13
|
||||
],
|
||||
"custom.params": [
|
||||
10
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 11,
|
||||
"type": 6
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 21,
|
||||
"custom.namespace": [
|
||||
9,
|
||||
22,
|
||||
23,
|
||||
24
|
||||
],
|
||||
"custom.params": [
|
||||
15
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 30,
|
||||
"type": 17
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 25,
|
||||
"custom.namespace": [
|
||||
9,
|
||||
22,
|
||||
26,
|
||||
27
|
||||
],
|
||||
"custom.params": [
|
||||
16
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 28,
|
||||
"custom.namespace": [
|
||||
9,
|
||||
22,
|
||||
29
|
||||
],
|
||||
"custom.params": []
|
||||
},
|
||||
"def": {
|
||||
"clike_enum.variants": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 31,
|
||||
"custom.namespace": [
|
||||
9,
|
||||
22,
|
||||
23,
|
||||
32
|
||||
],
|
||||
"custom.params": [
|
||||
15
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 33,
|
||||
"type": 18
|
||||
},
|
||||
{
|
||||
"name": 35,
|
||||
"type": 11
|
||||
},
|
||||
{
|
||||
"name": 36,
|
||||
"type": 4
|
||||
},
|
||||
{
|
||||
"name": 37,
|
||||
"type": 4
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": {
|
||||
"custom.name": 34,
|
||||
"custom.namespace": [],
|
||||
"custom.params": [
|
||||
15
|
||||
]
|
||||
},
|
||||
"def": {
|
||||
"tuple_struct.types": []
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"storage": {
|
||||
"struct.type": 1,
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 10,
|
||||
"layout": {
|
||||
"struct.type": 2,
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 7,
|
||||
"layout": {
|
||||
"struct.type": 3,
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 11,
|
||||
"layout": {
|
||||
"range.offset": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"range.len": 1,
|
||||
"range.elem_type": 4
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": 16,
|
||||
"layout": {
|
||||
"struct.type": 9,
|
||||
"struct.fields": [
|
||||
{
|
||||
"name": 11,
|
||||
"layout": {
|
||||
"range.offset": "0x0000000000000000000000000000000000000000000000000000000000000001",
|
||||
"range.len": 1,
|
||||
"range.elem_type": 10
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"contract": {
|
||||
"name": 2,
|
||||
"constructors": [
|
||||
{
|
||||
"name": 38,
|
||||
"selector": "[\"0x5E\",\"0xBD\",\"0x88\",\"0xD6\"]",
|
||||
"args": [
|
||||
{
|
||||
"name": 16,
|
||||
"type": {
|
||||
"ty": 11,
|
||||
"display_name": [
|
||||
18
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": 39,
|
||||
"type": {
|
||||
"ty": 4,
|
||||
"display_name": [
|
||||
40
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"docs": [
|
||||
"Constructor that initializes the `bool` value to the given `init_value`."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": 41,
|
||||
"selector": "[\"0x02\",\"0x22\",\"0xFF\",\"0x18\"]",
|
||||
"args": [],
|
||||
"docs": [
|
||||
"Constructor that initializes the `bool` value to `false`.",
|
||||
"",
|
||||
"Constructors can delegate to other constructors."
|
||||
]
|
||||
}
|
||||
],
|
||||
"messages": [
|
||||
{
|
||||
"name": 42,
|
||||
"selector": "[\"0x8C\",\"0x97\",\"0xDB\",\"0x39\"]",
|
||||
"mutates": true,
|
||||
"args": [],
|
||||
"return_type": null,
|
||||
"docs": [
|
||||
"A message that can be called on instantiated contracts.",
|
||||
"This one flips the value of the stored `bool` from `true`",
|
||||
"to `false` and vice versa."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": 43,
|
||||
"selector": "[\"0x25\",\"0x44\",\"0x4A\",\"0xFE\"]",
|
||||
"mutates": false,
|
||||
"args": [],
|
||||
"return_type": {
|
||||
"ty": 4,
|
||||
"display_name": [
|
||||
40
|
||||
]
|
||||
},
|
||||
"docs": [
|
||||
"Simply returns the current value of our `bool`."
|
||||
]
|
||||
}
|
||||
],
|
||||
"events": [],
|
||||
"docs": []
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
[
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"total_supply\": \"{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u128>\" }<u128>\", \"balances\": \"{ \"len\": \"{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u32>\" }<u32>\", \"entries\": \"{ \"cells_key\": \"([u8;32])\" }<{ \"_enum\": { \"Occupied\": \"({ \"key\": \"AccountId\", \"val\": \"u128\" }<([u8;32]), u128>)\", \"Removed\": \"Null\"\" }\" }<([u8;32]), u128>>\" }<([u8;32]), u128>\", \"allowances\": \"{ \"len\": \"{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u32>\" }<u32>\", \"entries\": \"{ \"cells_key\": \"([u8;32])\" }<{ \"_enum\": { \"Occupied\": \"({ \"key\": \"(AccountId, AccountId)\", \"val\": \"u128\" }<(AccountId, AccountId), u128>)\", \"Removed\": \"Null\"\" }\" }<(AccountId, AccountId), u128>>\" }<(AccountId, AccountId), u128>\" }",
|
||||
"type": "{\"total_supply\":\"{\\\"cell\\\":\\\"{\\\\\\\"cell\\\\\\\":\\\\\\\"([u8;32])\\\\\\\"}\\\"}\",\"balances\":\"{\\\"len\\\":\\\"{\\\\\\\"cell\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"cell\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"([u8;32])\\\\\\\\\\\\\\\"}\\\\\\\"}\\\",\\\"entries\\\":\\\"{\\\\\\\"cells_key\\\\\\\":\\\\\\\"([u8;32])\\\\\\\"}\\\"}\",\"allowances\":\"{\\\"len\\\":\\\"{\\\\\\\"cell\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"cell\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"([u8;32])\\\\\\\\\\\\\\\"}\\\\\\\"}\\\",\\\"entries\\\":\\\"{\\\\\\\"cells_key\\\\\\\":\\\\\\\"([u8;32])\\\\\\\"}\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u128>\" }",
|
||||
"type": "{\"cell\":\"{\\\"cell\\\":\\\"([u8;32])\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"([u8;32])\" }",
|
||||
"type": "{\"cell\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -54,15 +54,15 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"len\": \"{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u32>\" }<u32>\", \"entries\": \"{ \"cells_key\": \"([u8;32])\" }<{ \"_enum\": { \"Occupied\": \"({ \"key\": \"AccountId\", \"val\": \"u128\" }<([u8;32]), u128>)\", \"Removed\": \"Null\"\" }\" }<([u8;32]), u128>>\" }",
|
||||
"type": "{\"len\":\"{\\\"cell\\\":\\\"{\\\\\\\"cell\\\\\\\":\\\\\\\"([u8;32])\\\\\\\"}\\\"}\",\"entries\":\"{\\\"cells_key\\\":\\\"([u8;32])\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u32>\" }",
|
||||
"type": "{\"cell\":\"{\\\"cell\\\":\\\"([u8;32])\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"([u8;32])\" }",
|
||||
"type": "{\"cell\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -107,7 +107,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cells_key\": \"([u8;32])\" }",
|
||||
"type": "{\"cells_key\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -136,7 +136,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 3,
|
||||
"type": "{ \"_enum\": { \"Occupied\": \"({ \"key\": \"AccountId\", \"val\": \"u128\" }<([u8;32]), u128>)\", \"Removed\": \"Null\"\" }\" }",
|
||||
"type": "{\"_enum\":{\"Occupied\":\"({\\\"key\\\":\\\"([u8;32])\\\",\\\"val\\\":\\\"u128\\\"})\",\"Removed\":\"Null\"}}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -144,11 +144,11 @@
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"key\": \"AccountId\", \"val\": \"u128\" }",
|
||||
"type": "{\"key\":\"([u8;32])\",\"val\":\"u128\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -178,7 +178,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -205,7 +205,7 @@
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
"type": "({ \"key\": \"AccountId\", \"val\": \"u128\" }<([u8;32]), u128>)"
|
||||
"type": "({\"key\":\"([u8;32])\",\"val\":\"u128\"})"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
@@ -218,7 +218,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -251,7 +251,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -278,15 +278,15 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"len\": \"{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u32>\" }<u32>\", \"entries\": \"{ \"cells_key\": \"([u8;32])\" }<{ \"_enum\": { \"Occupied\": \"({ \"key\": \"(AccountId, AccountId)\", \"val\": \"u128\" }<(AccountId, AccountId), u128>)\", \"Removed\": \"Null\"\" }\" }<(AccountId, AccountId), u128>>\" }",
|
||||
"type": "{\"len\":\"{\\\"cell\\\":\\\"{\\\\\\\"cell\\\\\\\":\\\\\\\"([u8;32])\\\\\\\"}\\\"}\",\"entries\":\"{\\\"cells_key\\\":\\\"([u8;32])\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u32>\" }",
|
||||
"type": "{\"cell\":\"{\\\"cell\\\":\\\"([u8;32])\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"([u8;32])\" }",
|
||||
"type": "{\"cell\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -331,7 +331,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cells_key\": \"([u8;32])\" }",
|
||||
"type": "{\"cells_key\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -360,7 +360,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 3,
|
||||
"type": "{ \"_enum\": { \"Occupied\": \"({ \"key\": \"(AccountId, AccountId)\", \"val\": \"u128\" }<(AccountId, AccountId), u128>)\", \"Removed\": \"Null\"\" }\" }",
|
||||
"type": "{\"_enum\":{\"Occupied\":\"({\\\"key\\\":\\\"(([u8;32]), ([u8;32]))\\\",\\\"val\\\":\\\"u128\\\"})\",\"Removed\":\"Null\"}}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -368,15 +368,15 @@
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"key\": \"(AccountId, AccountId)\", \"val\": \"u128\" }",
|
||||
"type": "{\"key\":\"(([u8;32]), ([u8;32]))\",\"val\":\"u128\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "(AccountId, AccountId)",
|
||||
"type": "(([u8;32]), ([u8;32]))",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -397,7 +397,7 @@
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -430,11 +430,11 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "(AccountId, AccountId)",
|
||||
"type": "(([u8;32]), ([u8;32]))",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -455,7 +455,7 @@
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -484,7 +484,7 @@
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
"type": "({ \"key\": \"(AccountId, AccountId)\", \"val\": \"u128\" }<(AccountId, AccountId), u128>)"
|
||||
"type": "({\"key\":\"(([u8;32]), ([u8;32]))\",\"val\":\"u128\"})"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
@@ -497,11 +497,11 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "(AccountId, AccountId)",
|
||||
"type": "(([u8;32]), ([u8;32]))",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -522,7 +522,7 @@
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -557,11 +557,11 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "(AccountId, AccountId)",
|
||||
"type": "(([u8;32]), ([u8;32]))",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -582,7 +582,7 @@
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -615,11 +615,11 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u128>\" }",
|
||||
"type": "{\"cell\":\"{\\\"cell\\\":\\\"([u8;32])\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"([u8;32])\" }",
|
||||
"type": "{\"cell\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -668,7 +668,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"([u8;32])\" }",
|
||||
"type": "{\"cell\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -740,15 +740,15 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"len\": \"{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u32>\" }<u32>\", \"entries\": \"{ \"cells_key\": \"([u8;32])\" }<{ \"_enum\": { \"Occupied\": \"({ \"key\": \"AccountId\", \"val\": \"u128\" }<([u8;32]), u128>)\", \"Removed\": \"Null\"\" }\" }<([u8;32]), u128>>\" }",
|
||||
"type": "{\"len\":\"{\\\"cell\\\":\\\"{\\\\\\\"cell\\\\\\\":\\\\\\\"([u8;32])\\\\\\\"}\\\"}\",\"entries\":\"{\\\"cells_key\\\":\\\"([u8;32])\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u32>\" }",
|
||||
"type": "{\"cell\":\"{\\\"cell\\\":\\\"([u8;32])\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"([u8;32])\" }",
|
||||
"type": "{\"cell\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -793,7 +793,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cells_key\": \"([u8;32])\" }",
|
||||
"type": "{\"cells_key\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -822,7 +822,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 3,
|
||||
"type": "{ \"_enum\": { \"Occupied\": \"({ \"key\": \"AccountId\", \"val\": \"u128\" }<([u8;32]), u128>)\", \"Removed\": \"Null\"\" }\" }",
|
||||
"type": "{\"_enum\":{\"Occupied\":\"({\\\"key\\\":\\\"([u8;32])\\\",\\\"val\\\":\\\"u128\\\"})\",\"Removed\":\"Null\"}}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -830,11 +830,11 @@
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"key\": \"AccountId\", \"val\": \"u128\" }",
|
||||
"type": "{\"key\":\"([u8;32])\",\"val\":\"u128\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -864,7 +864,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -891,7 +891,7 @@
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
"type": "({ \"key\": \"AccountId\", \"val\": \"u128\" }<([u8;32]), u128>)"
|
||||
"type": "({\"key\":\"([u8;32])\",\"val\":\"u128\"})"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
@@ -904,7 +904,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -937,7 +937,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -964,7 +964,7 @@
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -985,11 +985,11 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u32>\" }",
|
||||
"type": "{\"cell\":\"{\\\"cell\\\":\\\"([u8;32])\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"([u8;32])\" }",
|
||||
"type": "{\"cell\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -1038,7 +1038,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"([u8;32])\" }",
|
||||
"type": "{\"cell\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -1073,7 +1073,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cells_key\": \"([u8;32])\" }",
|
||||
"type": "{\"cells_key\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -1102,7 +1102,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 3,
|
||||
"type": "{ \"_enum\": { \"Occupied\": \"({ \"key\": \"AccountId\", \"val\": \"u128\" }<([u8;32]), u128>)\", \"Removed\": \"Null\"\" }\" }",
|
||||
"type": "{\"_enum\":{\"Occupied\":\"({\\\"key\\\":\\\"([u8;32])\\\",\\\"val\\\":\\\"u128\\\"})\",\"Removed\":\"Null\"}}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -1110,11 +1110,11 @@
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"key\": \"AccountId\", \"val\": \"u128\" }",
|
||||
"type": "{\"key\":\"([u8;32])\",\"val\":\"u128\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1144,7 +1144,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1171,7 +1171,7 @@
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
"type": "({ \"key\": \"AccountId\", \"val\": \"u128\" }<([u8;32]), u128>)"
|
||||
"type": "({\"key\":\"([u8;32])\",\"val\":\"u128\"})"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
@@ -1184,7 +1184,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1213,7 +1213,7 @@
|
||||
},
|
||||
{
|
||||
"info": 3,
|
||||
"type": "{ \"_enum\": { \"Occupied\": \"({ \"key\": \"AccountId\", \"val\": \"u128\" }<([u8;32]), u128>)\", \"Removed\": \"Null\"\" }\" }",
|
||||
"type": "{\"_enum\":{\"Occupied\":\"({\\\"key\\\":\\\"([u8;32])\\\",\\\"val\\\":\\\"u128\\\"})\",\"Removed\":\"Null\"}}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -1221,11 +1221,11 @@
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"key\": \"AccountId\", \"val\": \"u128\" }",
|
||||
"type": "{\"key\":\"([u8;32])\",\"val\":\"u128\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1255,7 +1255,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1282,7 +1282,7 @@
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
"type": "({ \"key\": \"AccountId\", \"val\": \"u128\" }<([u8;32]), u128>)"
|
||||
"type": "({\"key\":\"([u8;32])\",\"val\":\"u128\"})"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
@@ -1295,7 +1295,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1322,11 +1322,11 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"key\": \"AccountId\", \"val\": \"u128\" }",
|
||||
"type": "{\"key\":\"([u8;32])\",\"val\":\"u128\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1356,7 +1356,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1383,15 +1383,15 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"len\": \"{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u32>\" }<u32>\", \"entries\": \"{ \"cells_key\": \"([u8;32])\" }<{ \"_enum\": { \"Occupied\": \"({ \"key\": \"(AccountId, AccountId)\", \"val\": \"u128\" }<(AccountId, AccountId), u128>)\", \"Removed\": \"Null\"\" }\" }<(AccountId, AccountId), u128>>\" }",
|
||||
"type": "{\"len\":\"{\\\"cell\\\":\\\"{\\\\\\\"cell\\\\\\\":\\\\\\\"([u8;32])\\\\\\\"}\\\"}\",\"entries\":\"{\\\"cells_key\\\":\\\"([u8;32])\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u32>\" }",
|
||||
"type": "{\"cell\":\"{\\\"cell\\\":\\\"([u8;32])\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"([u8;32])\" }",
|
||||
"type": "{\"cell\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -1436,7 +1436,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cells_key\": \"([u8;32])\" }",
|
||||
"type": "{\"cells_key\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -1465,7 +1465,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 3,
|
||||
"type": "{ \"_enum\": { \"Occupied\": \"({ \"key\": \"(AccountId, AccountId)\", \"val\": \"u128\" }<(AccountId, AccountId), u128>)\", \"Removed\": \"Null\"\" }\" }",
|
||||
"type": "{\"_enum\":{\"Occupied\":\"({\\\"key\\\":\\\"(([u8;32]), ([u8;32]))\\\",\\\"val\\\":\\\"u128\\\"})\",\"Removed\":\"Null\"}}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -1473,15 +1473,15 @@
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"key\": \"(AccountId, AccountId)\", \"val\": \"u128\" }",
|
||||
"type": "{\"key\":\"(([u8;32]), ([u8;32]))\",\"val\":\"u128\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "(AccountId, AccountId)",
|
||||
"type": "(([u8;32]), ([u8;32]))",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1502,7 +1502,7 @@
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1535,11 +1535,11 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "(AccountId, AccountId)",
|
||||
"type": "(([u8;32]), ([u8;32]))",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1560,7 +1560,7 @@
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1589,7 +1589,7 @@
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
"type": "({ \"key\": \"(AccountId, AccountId)\", \"val\": \"u128\" }<(AccountId, AccountId), u128>)"
|
||||
"type": "({\"key\":\"(([u8;32]), ([u8;32]))\",\"val\":\"u128\"})"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
@@ -1602,11 +1602,11 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "(AccountId, AccountId)",
|
||||
"type": "(([u8;32]), ([u8;32]))",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1627,7 +1627,7 @@
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1662,11 +1662,11 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "(AccountId, AccountId)",
|
||||
"type": "(([u8;32]), ([u8;32]))",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1687,7 +1687,7 @@
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1716,11 +1716,11 @@
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"type": "(AccountId, AccountId)",
|
||||
"type": "(([u8;32]), ([u8;32]))",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1741,7 +1741,7 @@
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1764,7 +1764,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cells_key\": \"([u8;32])\" }",
|
||||
"type": "{\"cells_key\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -1793,7 +1793,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 3,
|
||||
"type": "{ \"_enum\": { \"Occupied\": \"({ \"key\": \"(AccountId, AccountId)\", \"val\": \"u128\" }<(AccountId, AccountId), u128>)\", \"Removed\": \"Null\"\" }\" }",
|
||||
"type": "{\"_enum\":{\"Occupied\":\"({\\\"key\\\":\\\"(([u8;32]), ([u8;32]))\\\",\\\"val\\\":\\\"u128\\\"})\",\"Removed\":\"Null\"}}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -1801,15 +1801,15 @@
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"key\": \"(AccountId, AccountId)\", \"val\": \"u128\" }",
|
||||
"type": "{\"key\":\"(([u8;32]), ([u8;32]))\",\"val\":\"u128\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "(AccountId, AccountId)",
|
||||
"type": "(([u8;32]), ([u8;32]))",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1830,7 +1830,7 @@
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1863,11 +1863,11 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "(AccountId, AccountId)",
|
||||
"type": "(([u8;32]), ([u8;32]))",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1888,7 +1888,7 @@
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1917,7 +1917,7 @@
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
"type": "({ \"key\": \"(AccountId, AccountId)\", \"val\": \"u128\" }<(AccountId, AccountId), u128>)"
|
||||
"type": "({\"key\":\"(([u8;32]), ([u8;32]))\",\"val\":\"u128\"})"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
@@ -1930,11 +1930,11 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "(AccountId, AccountId)",
|
||||
"type": "(([u8;32]), ([u8;32]))",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1955,7 +1955,7 @@
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1986,7 +1986,7 @@
|
||||
},
|
||||
{
|
||||
"info": 3,
|
||||
"type": "{ \"_enum\": { \"Occupied\": \"({ \"key\": \"(AccountId, AccountId)\", \"val\": \"u128\" }<(AccountId, AccountId), u128>)\", \"Removed\": \"Null\"\" }\" }",
|
||||
"type": "{\"_enum\":{\"Occupied\":\"({\\\"key\\\":\\\"(([u8;32]), ([u8;32]))\\\",\\\"val\\\":\\\"u128\\\"})\",\"Removed\":\"Null\"}}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -1994,15 +1994,15 @@
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"key\": \"(AccountId, AccountId)\", \"val\": \"u128\" }",
|
||||
"type": "{\"key\":\"(([u8;32]), ([u8;32]))\",\"val\":\"u128\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "(AccountId, AccountId)",
|
||||
"type": "(([u8;32]), ([u8;32]))",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -2023,7 +2023,7 @@
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -2056,11 +2056,11 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "(AccountId, AccountId)",
|
||||
"type": "(([u8;32]), ([u8;32]))",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -2081,7 +2081,7 @@
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -2110,7 +2110,7 @@
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
"type": "({ \"key\": \"(AccountId, AccountId)\", \"val\": \"u128\" }<(AccountId, AccountId), u128>)"
|
||||
"type": "({\"key\":\"(([u8;32]), ([u8;32]))\",\"val\":\"u128\"})"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
@@ -2123,11 +2123,11 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "(AccountId, AccountId)",
|
||||
"type": "(([u8;32]), ([u8;32]))",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -2148,7 +2148,7 @@
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -2177,15 +2177,15 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"key\": \"(AccountId, AccountId)\", \"val\": \"u128\" }",
|
||||
"type": "{\"key\":\"(([u8;32]), ([u8;32]))\",\"val\":\"u128\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "(AccountId, AccountId)",
|
||||
"type": "(([u8;32]), ([u8;32]))",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -2206,7 +2206,7 @@
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -2239,11 +2239,11 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "(AccountId, AccountId)",
|
||||
"type": "(([u8;32]), ([u8;32]))",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -2264,7 +2264,7 @@
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -2300,7 +2300,7 @@
|
||||
"type": "Option<([u8;32])>",
|
||||
"sub": {
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -2323,7 +2323,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -2344,4 +2344,4 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
[
|
||||
{
|
||||
"info": 7,
|
||||
"info": 8,
|
||||
"type": "{\"value\": {\"cell\": {\"cell\": ([u8;32])}}}",
|
||||
"name": "Flipper",
|
||||
"namespace": "flipper::normal",
|
||||
"sub": [
|
||||
{
|
||||
"info": 7,
|
||||
"info": 8,
|
||||
"type": "{\"cell\": {\"cell\": ([u8;32])}}",
|
||||
"name": "value",
|
||||
"namespace": "ink_core::storage::value",
|
||||
"params": [
|
||||
{
|
||||
"info": 5,
|
||||
"info": 6,
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"sub": [
|
||||
{
|
||||
"info": 7,
|
||||
"info": 8,
|
||||
"type": "{\"cell\": ([u8;32])}",
|
||||
"name": "cell",
|
||||
"namespace": "ink_core::storage::cell::sync_cell",
|
||||
"params": [
|
||||
{
|
||||
"info": 5,
|
||||
"info": 6,
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"sub": [
|
||||
{
|
||||
"info": 8,
|
||||
"info": 9,
|
||||
"type": "([u8;32])",
|
||||
"name": "cell",
|
||||
"namespace": "ink_core::storage::key",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"info": 11,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": ""
|
||||
},
|
||||
"sub": {
|
||||
"info": 5,
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"index": 0
|
||||
@@ -57,44 +57,44 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"info": 7,
|
||||
"info": 8,
|
||||
"type": "{\"cell\": {\"cell\": ([u8;32])}}",
|
||||
"name": "Value",
|
||||
"namespace": "ink_core::storage::value",
|
||||
"params": [
|
||||
{
|
||||
"info": 5,
|
||||
"info": 6,
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"sub": [
|
||||
{
|
||||
"info": 7,
|
||||
"info": 8,
|
||||
"type": "{\"cell\": ([u8;32])}",
|
||||
"name": "cell",
|
||||
"namespace": "ink_core::storage::cell::sync_cell",
|
||||
"params": [
|
||||
{
|
||||
"info": 5,
|
||||
"info": 6,
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"sub": [
|
||||
{
|
||||
"info": 8,
|
||||
"info": 9,
|
||||
"type": "([u8;32])",
|
||||
"name": "cell",
|
||||
"namespace": "ink_core::storage::key",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"info": 11,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": ""
|
||||
},
|
||||
"sub": {
|
||||
"info": 5,
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"index": 0
|
||||
@@ -106,36 +106,36 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"info": 5,
|
||||
"info": 6,
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"info": 7,
|
||||
"info": 8,
|
||||
"type": "{\"cell\": ([u8;32])}",
|
||||
"name": "SyncCell",
|
||||
"namespace": "ink_core::storage::cell::sync_cell",
|
||||
"params": [
|
||||
{
|
||||
"info": 5,
|
||||
"info": 6,
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"sub": [
|
||||
{
|
||||
"info": 8,
|
||||
"info": 9,
|
||||
"type": "([u8;32])",
|
||||
"name": "cell",
|
||||
"namespace": "ink_core::storage::key",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"info": 11,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": ""
|
||||
},
|
||||
"sub": {
|
||||
"info": 5,
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"index": 0
|
||||
@@ -145,20 +145,20 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"info": 8,
|
||||
"info": 9,
|
||||
"type": "([u8;32])",
|
||||
"name": "Key",
|
||||
"namespace": "ink_core::storage::key",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"info": 11,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": ""
|
||||
},
|
||||
"sub": {
|
||||
"info": 5,
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"index": 0
|
||||
@@ -166,19 +166,19 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"info": 11,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": ""
|
||||
},
|
||||
"sub": {
|
||||
"info": 5,
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
}
|
||||
},
|
||||
{
|
||||
"info": 5,
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
}
|
||||
]
|
||||
@@ -1,29 +1,29 @@
|
||||
[
|
||||
{
|
||||
"info": 9,
|
||||
"info": 10,
|
||||
"type": "{ \"value\": \"{ \"cell\": \"{ \"cell\": \"([u8;32])\"} }<u32>\"} }<u32>\"} }",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"info": 10,
|
||||
"type": "{ \"cell\": \"{ \"cell\": \"([u8;32])\"} }<u32>\"} }",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"info": 10,
|
||||
"type": "{ \"cell\": \"([u8;32])\"} }",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"info": 11,
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
"info": 13,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": "u8"
|
||||
},
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "u8"
|
||||
},
|
||||
"index": 0
|
||||
@@ -37,7 +37,7 @@
|
||||
"namespace": "ink_core::storage::cell::sync_cell",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "u32"
|
||||
}
|
||||
]
|
||||
@@ -47,7 +47,7 @@
|
||||
"namespace": "ink_core::storage::value",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "u32"
|
||||
}
|
||||
]
|
||||
@@ -57,26 +57,26 @@
|
||||
"namespace": "incrementer::normal"
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"info": 10,
|
||||
"type": "{ \"cell\": \"{ \"cell\": \"([u8;32])\"} }<u32>\"} }",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"info": 10,
|
||||
"type": "{ \"cell\": \"([u8;32])\"} }",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"info": 11,
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
"info": 13,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": "u8"
|
||||
},
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "u8"
|
||||
},
|
||||
"index": 0
|
||||
@@ -90,7 +90,7 @@
|
||||
"namespace": "ink_core::storage::cell::sync_cell",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "u32"
|
||||
}
|
||||
]
|
||||
@@ -100,32 +100,32 @@
|
||||
"namespace": "ink_core::storage::value",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "u32"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "u32"
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"info": 10,
|
||||
"type": "{ \"cell\": \"([u8;32])\"} }",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"info": 11,
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
"info": 13,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": "u8"
|
||||
},
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "u8"
|
||||
},
|
||||
"index": 0
|
||||
@@ -139,24 +139,24 @@
|
||||
"namespace": "ink_core::storage::cell::sync_cell",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "u32"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"info": 11,
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
"info": 13,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": "u8"
|
||||
},
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "u8"
|
||||
},
|
||||
"index": 0
|
||||
@@ -166,23 +166,23 @@
|
||||
"namespace": "ink_core::storage::key"
|
||||
},
|
||||
{
|
||||
"info": 12,
|
||||
"info": 13,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": "u8"
|
||||
},
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "u8"
|
||||
}
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "u8"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
@@ -1,19 +1,19 @@
|
||||
[
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"mutators\": \"{ \"len\": \"{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u32>\" }<u32>\", \"entries\": \"{ \"cells_key\": \"([u8;32])\" }<{ \"_enum\": { \"Occupied\": \"({ \"key\": \"AccountId\", \"val\": \"{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }\" }<([u8;32]), { \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }>)\", \"Removed\": \"Null\"\" }\" }<([u8;32]), { \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }>>\" }<([u8;32]), { \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }>\", \"vec\": \"{ \"len\": \"{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u32>\" }<u32>\", \"cells\": \"{ \"cells_key\": \"([u8;32])\" }<i32>\" }<i32>\" }",
|
||||
"type": "{\"mutators\":\"{\\\"len\\\":\\\"{\\\\\\\"cell\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"cell\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"([u8;32])\\\\\\\\\\\\\\\"}\\\\\\\"}\\\",\\\"entries\\\":\\\"{\\\\\\\"cells_key\\\\\\\":\\\\\\\"([u8;32])\\\\\\\"}\\\"}\",\"vec\":\"{\\\"len\\\":\\\"{\\\\\\\"cell\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"cell\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"([u8;32])\\\\\\\\\\\\\\\"}\\\\\\\"}\\\",\\\"cells\\\":\\\"{\\\\\\\"cells_key\\\\\\\":\\\\\\\"([u8;32])\\\\\\\"}\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"len\": \"{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u32>\" }<u32>\", \"entries\": \"{ \"cells_key\": \"([u8;32])\" }<{ \"_enum\": { \"Occupied\": \"({ \"key\": \"AccountId\", \"val\": \"{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }\" }<([u8;32]), { \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }>)\", \"Removed\": \"Null\"\" }\" }<([u8;32]), { \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }>>\" }",
|
||||
"type": "{\"len\":\"{\\\"cell\\\":\\\"{\\\\\\\"cell\\\\\\\":\\\\\\\"([u8;32])\\\\\\\"}\\\"}\",\"entries\":\"{\\\"cells_key\\\":\\\"([u8;32])\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u32>\" }",
|
||||
"type": "{\"cell\":\"{\\\"cell\\\":\\\"([u8;32])\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"([u8;32])\" }",
|
||||
"type": "{\"cell\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -58,7 +58,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cells_key\": \"([u8;32])\" }",
|
||||
"type": "{\"cells_key\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -87,7 +87,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 3,
|
||||
"type": "{ \"_enum\": { \"Occupied\": \"({ \"key\": \"AccountId\", \"val\": \"{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }\" }<([u8;32]), { \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }>)\", \"Removed\": \"Null\"\" }\" }",
|
||||
"type": "{\"_enum\":{\"Occupied\":\"({\\\"key\\\":\\\"([u8;32])\\\",\\\"val\\\":\\\"{\\\\\\\"begin\\\\\\\":\\\\\\\"Option<u32>\\\\\\\",\\\\\\\"end\\\\\\\":\\\\\\\"Option<u32>\\\\\\\"}\\\"})\",\"Removed\":\"Null\"}}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -95,11 +95,11 @@
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"key\": \"AccountId\", \"val\": \"{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }\" }",
|
||||
"type": "{\"key\":\"([u8;32])\",\"val\":\"{\\\"begin\\\":\\\"Option<u32>\\\",\\\"end\\\":\\\"Option<u32>\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -120,7 +120,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }",
|
||||
"type": "{\"begin\":\"Option<u32>\",\"end\":\"Option<u32>\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 5,
|
||||
@@ -162,7 +162,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -183,7 +183,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }",
|
||||
"type": "{\"begin\":\"Option<u32>\",\"end\":\"Option<u32>\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 5,
|
||||
@@ -223,7 +223,7 @@
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
"type": "({ \"key\": \"AccountId\", \"val\": \"{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }\" }<([u8;32]), { \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }>)"
|
||||
"type": "({\"key\":\"([u8;32])\",\"val\":\"{\\\"begin\\\":\\\"Option<u32>\\\",\\\"end\\\":\\\"Option<u32>\\\"}\"})"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
@@ -236,7 +236,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -257,7 +257,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }",
|
||||
"type": "{\"begin\":\"Option<u32>\",\"end\":\"Option<u32>\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 5,
|
||||
@@ -303,7 +303,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -324,7 +324,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }",
|
||||
"type": "{\"begin\":\"Option<u32>\",\"end\":\"Option<u32>\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 5,
|
||||
@@ -364,15 +364,15 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"len\": \"{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u32>\" }<u32>\", \"cells\": \"{ \"cells_key\": \"([u8;32])\" }<i32>\" }",
|
||||
"type": "{\"len\":\"{\\\"cell\\\":\\\"{\\\\\\\"cell\\\\\\\":\\\\\\\"([u8;32])\\\\\\\"}\\\"}\",\"cells\":\"{\\\"cells_key\\\":\\\"([u8;32])\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u32>\" }",
|
||||
"type": "{\"cell\":\"{\\\"cell\\\":\\\"([u8;32])\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"([u8;32])\" }",
|
||||
"type": "{\"cell\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -417,7 +417,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cells_key\": \"([u8;32])\" }",
|
||||
"type": "{\"cells_key\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -466,15 +466,15 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"len\": \"{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u32>\" }<u32>\", \"entries\": \"{ \"cells_key\": \"([u8;32])\" }<{ \"_enum\": { \"Occupied\": \"({ \"key\": \"AccountId\", \"val\": \"{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }\" }<([u8;32]), { \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }>)\", \"Removed\": \"Null\"\" }\" }<([u8;32]), { \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }>>\" }",
|
||||
"type": "{\"len\":\"{\\\"cell\\\":\\\"{\\\\\\\"cell\\\\\\\":\\\\\\\"([u8;32])\\\\\\\"}\\\"}\",\"entries\":\"{\\\"cells_key\\\":\\\"([u8;32])\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u32>\" }",
|
||||
"type": "{\"cell\":\"{\\\"cell\\\":\\\"([u8;32])\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"([u8;32])\" }",
|
||||
"type": "{\"cell\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -519,7 +519,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cells_key\": \"([u8;32])\" }",
|
||||
"type": "{\"cells_key\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -548,7 +548,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 3,
|
||||
"type": "{ \"_enum\": { \"Occupied\": \"({ \"key\": \"AccountId\", \"val\": \"{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }\" }<([u8;32]), { \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }>)\", \"Removed\": \"Null\"\" }\" }",
|
||||
"type": "{\"_enum\":{\"Occupied\":\"({\\\"key\\\":\\\"([u8;32])\\\",\\\"val\\\":\\\"{\\\\\\\"begin\\\\\\\":\\\\\\\"Option<u32>\\\\\\\",\\\\\\\"end\\\\\\\":\\\\\\\"Option<u32>\\\\\\\"}\\\"})\",\"Removed\":\"Null\"}}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -556,11 +556,11 @@
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"key\": \"AccountId\", \"val\": \"{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }\" }",
|
||||
"type": "{\"key\":\"([u8;32])\",\"val\":\"{\\\"begin\\\":\\\"Option<u32>\\\",\\\"end\\\":\\\"Option<u32>\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -581,7 +581,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }",
|
||||
"type": "{\"begin\":\"Option<u32>\",\"end\":\"Option<u32>\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 5,
|
||||
@@ -623,7 +623,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -644,7 +644,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }",
|
||||
"type": "{\"begin\":\"Option<u32>\",\"end\":\"Option<u32>\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 5,
|
||||
@@ -684,7 +684,7 @@
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
"type": "({ \"key\": \"AccountId\", \"val\": \"{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }\" }<([u8;32]), { \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }>)"
|
||||
"type": "({\"key\":\"([u8;32])\",\"val\":\"{\\\"begin\\\":\\\"Option<u32>\\\",\\\"end\\\":\\\"Option<u32>\\\"}\"})"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
@@ -697,7 +697,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -718,7 +718,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }",
|
||||
"type": "{\"begin\":\"Option<u32>\",\"end\":\"Option<u32>\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 5,
|
||||
@@ -764,7 +764,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -785,7 +785,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }",
|
||||
"type": "{\"begin\":\"Option<u32>\",\"end\":\"Option<u32>\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 5,
|
||||
@@ -825,7 +825,7 @@
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -862,7 +862,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }",
|
||||
"type": "{\"begin\":\"Option<u32>\",\"end\":\"Option<u32>\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 5,
|
||||
@@ -919,11 +919,11 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u32>\" }",
|
||||
"type": "{\"cell\":\"{\\\"cell\\\":\\\"([u8;32])\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"([u8;32])\" }",
|
||||
"type": "{\"cell\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -968,7 +968,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"([u8;32])\" }",
|
||||
"type": "{\"cell\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -1024,7 +1024,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cells_key\": \"([u8;32])\" }",
|
||||
"type": "{\"cells_key\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -1053,7 +1053,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 3,
|
||||
"type": "{ \"_enum\": { \"Occupied\": \"({ \"key\": \"AccountId\", \"val\": \"{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }\" }<([u8;32]), { \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }>)\", \"Removed\": \"Null\"\" }\" }",
|
||||
"type": "{\"_enum\":{\"Occupied\":\"({\\\"key\\\":\\\"([u8;32])\\\",\\\"val\\\":\\\"{\\\\\\\"begin\\\\\\\":\\\\\\\"Option<u32>\\\\\\\",\\\\\\\"end\\\\\\\":\\\\\\\"Option<u32>\\\\\\\"}\\\"})\",\"Removed\":\"Null\"}}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -1061,11 +1061,11 @@
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"key\": \"AccountId\", \"val\": \"{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }\" }",
|
||||
"type": "{\"key\":\"([u8;32])\",\"val\":\"{\\\"begin\\\":\\\"Option<u32>\\\",\\\"end\\\":\\\"Option<u32>\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1086,7 +1086,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }",
|
||||
"type": "{\"begin\":\"Option<u32>\",\"end\":\"Option<u32>\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 5,
|
||||
@@ -1128,7 +1128,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1149,7 +1149,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }",
|
||||
"type": "{\"begin\":\"Option<u32>\",\"end\":\"Option<u32>\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 5,
|
||||
@@ -1189,7 +1189,7 @@
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
"type": "({ \"key\": \"AccountId\", \"val\": \"{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }\" }<([u8;32]), { \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }>)"
|
||||
"type": "({\"key\":\"([u8;32])\",\"val\":\"{\\\"begin\\\":\\\"Option<u32>\\\",\\\"end\\\":\\\"Option<u32>\\\"}\"})"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
@@ -1202,7 +1202,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1223,7 +1223,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }",
|
||||
"type": "{\"begin\":\"Option<u32>\",\"end\":\"Option<u32>\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 5,
|
||||
@@ -1265,7 +1265,7 @@
|
||||
},
|
||||
{
|
||||
"info": 3,
|
||||
"type": "{ \"_enum\": { \"Occupied\": \"({ \"key\": \"AccountId\", \"val\": \"{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }\" }<([u8;32]), { \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }>)\", \"Removed\": \"Null\"\" }\" }",
|
||||
"type": "{\"_enum\":{\"Occupied\":\"({\\\"key\\\":\\\"([u8;32])\\\",\\\"val\\\":\\\"{\\\\\\\"begin\\\\\\\":\\\\\\\"Option<u32>\\\\\\\",\\\\\\\"end\\\\\\\":\\\\\\\"Option<u32>\\\\\\\"}\\\"})\",\"Removed\":\"Null\"}}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -1273,11 +1273,11 @@
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"key\": \"AccountId\", \"val\": \"{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }\" }",
|
||||
"type": "{\"key\":\"([u8;32])\",\"val\":\"{\\\"begin\\\":\\\"Option<u32>\\\",\\\"end\\\":\\\"Option<u32>\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1298,7 +1298,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }",
|
||||
"type": "{\"begin\":\"Option<u32>\",\"end\":\"Option<u32>\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 5,
|
||||
@@ -1340,7 +1340,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1361,7 +1361,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }",
|
||||
"type": "{\"begin\":\"Option<u32>\",\"end\":\"Option<u32>\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 5,
|
||||
@@ -1401,7 +1401,7 @@
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
"type": "({ \"key\": \"AccountId\", \"val\": \"{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }\" }<([u8;32]), { \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }>)"
|
||||
"type": "({\"key\":\"([u8;32])\",\"val\":\"{\\\"begin\\\":\\\"Option<u32>\\\",\\\"end\\\":\\\"Option<u32>\\\"}\"})"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
@@ -1414,7 +1414,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1435,7 +1435,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }",
|
||||
"type": "{\"begin\":\"Option<u32>\",\"end\":\"Option<u32>\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 5,
|
||||
@@ -1475,11 +1475,11 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"key\": \"AccountId\", \"val\": \"{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }\" }",
|
||||
"type": "{\"key\":\"([u8;32])\",\"val\":\"{\\\"begin\\\":\\\"Option<u32>\\\",\\\"end\\\":\\\"Option<u32>\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1500,7 +1500,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }",
|
||||
"type": "{\"begin\":\"Option<u32>\",\"end\":\"Option<u32>\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 5,
|
||||
@@ -1542,7 +1542,7 @@
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"type": "AccountId",
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
@@ -1563,7 +1563,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"begin\": \"Option<u32><u32>\", \"end\": \"Option<u32><u32>\" }",
|
||||
"type": "{\"begin\":\"Option<u32>\",\"end\":\"Option<u32>\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 5,
|
||||
@@ -1603,15 +1603,15 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"len\": \"{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u32>\" }<u32>\", \"cells\": \"{ \"cells_key\": \"([u8;32])\" }<i32>\" }",
|
||||
"type": "{\"len\":\"{\\\"cell\\\":\\\"{\\\\\\\"cell\\\\\\\":\\\\\\\"([u8;32])\\\\\\\"}\\\"}\",\"cells\":\"{\\\"cells_key\\\":\\\"([u8;32])\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"{ \"cell\": \"([u8;32])\" }<u32>\" }",
|
||||
"type": "{\"cell\":\"{\\\"cell\\\":\\\"([u8;32])\\\"}\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cell\": \"([u8;32])\" }",
|
||||
"type": "{\"cell\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -1656,7 +1656,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cells_key\": \"([u8;32])\" }",
|
||||
"type": "{\"cells_key\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -1705,7 +1705,7 @@
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"type": "{ \"cells_key\": \"([u8;32])\" }",
|
||||
"type": "{\"cells_key\":\"([u8;32])\"}",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -1810,4 +1810,4 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-derive",
|
||||
"version": "0.96.1",
|
||||
"version": "1.1.1",
|
||||
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,11 +27,11 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.7.1",
|
||||
"@polkadot/api": "^0.96.1",
|
||||
"@polkadot/types": "^0.96.1"
|
||||
"@babel/runtime": "^7.8.3",
|
||||
"@polkadot/api": "^1.1.1",
|
||||
"@polkadot/types": "^1.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^1.7.0-beta.5"
|
||||
"@polkadot/keyring": "^2.2.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -7,11 +7,11 @@ import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { createType } from '@polkadot/types';
|
||||
import { isU8a } from '@polkadot/util';
|
||||
import { decodeAddress } from '@polkadot/util-crypto';
|
||||
import { createType } from '@polkadot/types';
|
||||
|
||||
import { drr } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
export type AccountIdAndIndex = [AccountId?, AccountIndex?];
|
||||
|
||||
@@ -23,14 +23,14 @@ function retrieve (api: ApiInterfaceRx, address: Address | AccountId | AccountIn
|
||||
: decodeAddress((address || '').toString());
|
||||
|
||||
if (decoded.length === 32) {
|
||||
const accountId = createType('AccountId', decoded);
|
||||
const accountId = createType(api.registry, 'AccountId', decoded);
|
||||
|
||||
return api.derive.accounts.idToIndex(accountId).pipe(
|
||||
map((accountIndex): AccountIdAndIndex => [accountId, accountIndex] as AccountIdAndIndex)
|
||||
);
|
||||
}
|
||||
|
||||
const accountIndex = createType('AccountIndex', decoded);
|
||||
const accountIndex = createType(api.registry, 'AccountIndex', decoded);
|
||||
|
||||
return api.derive.accounts.indexToId(accountIndex).pipe(
|
||||
map((accountId): AccountIdAndIndex => [accountId, accountIndex] as AccountIdAndIndex)
|
||||
@@ -54,6 +54,6 @@ function retrieve (api: ApiInterfaceRx, address: Address | AccountId | AccountIn
|
||||
* ```
|
||||
*/
|
||||
export function idAndIndex (api: ApiInterfaceRx): (address?: Address | AccountId | AccountIndex | string | null) => Observable<AccountIdAndIndex> {
|
||||
return (address?: Address | AccountId | AccountIndex | string | null): Observable<AccountIdAndIndex> =>
|
||||
retrieve(api, address).pipe(drr());
|
||||
return memo((address?: Address | AccountId | AccountIndex | string | null): Observable<AccountIdAndIndex> =>
|
||||
retrieve(api, address));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -9,7 +9,7 @@ import { Observable } from 'rxjs';
|
||||
import { map, startWith } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
|
||||
import { drr } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
/**
|
||||
* @name idToIndex
|
||||
@@ -26,12 +26,11 @@ import { drr } from '../util';
|
||||
* ```
|
||||
*/
|
||||
export function idToIndex (api: ApiInterfaceRx): (accountId: AccountId | string) => Observable<AccountIndex | undefined> {
|
||||
return (accountId: AccountId | string): Observable<AccountIndex | undefined> =>
|
||||
return memo((accountId: AccountId | string): Observable<AccountIndex | undefined> =>
|
||||
api.derive.accounts.indexes().pipe(
|
||||
startWith({}),
|
||||
map((indexes: AccountIndexes): AccountIndex | undefined =>
|
||||
(indexes || {})[accountId.toString()]
|
||||
),
|
||||
drr()
|
||||
);
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId, AccountIndex } from '@polkadot/types/interfaces';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map, startWith } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { ENUMSET_SIZE } from '@polkadot/types/primitive/Generic/AccountIndex';
|
||||
import { createType, ClassOf, Vec } from '@polkadot/types';
|
||||
import { ClassOf, Vec, createType } from '@polkadot/types';
|
||||
|
||||
import { drr } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
/**
|
||||
* @name indexToId
|
||||
@@ -26,19 +26,18 @@ import { drr } from '../util';
|
||||
* ```
|
||||
*/
|
||||
export function indexToId (api: ApiInterfaceRx): (accountIndex: AccountIndex | string) => Observable<AccountId | undefined> {
|
||||
const querySection = api.query.indices || api.query.balances;
|
||||
|
||||
return (_accountIndex: AccountIndex | string): Observable<AccountId | undefined> => {
|
||||
const accountIndex = _accountIndex instanceof ClassOf('AccountIndex')
|
||||
return memo((_accountIndex: AccountIndex | string): Observable<AccountId | undefined> => {
|
||||
const accountIndex = _accountIndex instanceof ClassOf(api.registry, 'AccountIndex')
|
||||
? _accountIndex
|
||||
: createType('AccountIndex', _accountIndex);
|
||||
: createType(api.registry, 'AccountIndex', _accountIndex);
|
||||
|
||||
return querySection.enumSet<Vec<AccountId>>(accountIndex.div(ENUMSET_SIZE)).pipe(
|
||||
startWith([]),
|
||||
map((accounts): AccountId | undefined =>
|
||||
(accounts || [])[accountIndex.mod(ENUMSET_SIZE).toNumber()]
|
||||
),
|
||||
drr()
|
||||
);
|
||||
};
|
||||
return api.query.indices.enumSet
|
||||
? api.query.indices.enumSet<Vec<AccountId>>(accountIndex.div(ENUMSET_SIZE)).pipe(
|
||||
startWith([]),
|
||||
map((accounts): AccountId | undefined =>
|
||||
(accounts || [])[accountIndex.mod(ENUMSET_SIZE).toNumber()]
|
||||
)
|
||||
)
|
||||
: of(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -6,12 +6,12 @@ import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { AccountId, AccountIndex } from '@polkadot/types/interfaces';
|
||||
import { AccountIndexes } from '../types';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { ENUMSET_SIZE } from '@polkadot/types/primitive/Generic/AccountIndex';
|
||||
import { createType } from '@polkadot/types';
|
||||
import { Vec, createType } from '@polkadot/types';
|
||||
|
||||
import { drr } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
const enumsetSize = ENUMSET_SIZE.toNumber();
|
||||
|
||||
@@ -31,27 +31,30 @@ const enumsetSize = ENUMSET_SIZE.toNumber();
|
||||
* ```
|
||||
*/
|
||||
export function indexes (api: ApiInterfaceRx): () => Observable<AccountIndexes> {
|
||||
return (): Observable<AccountIndexes> =>
|
||||
api.query.indices.nextEnumSet<AccountIndex>().pipe(
|
||||
// use the nextEnumSet (which is a counter of the number of sets) to construct
|
||||
// a range of values to query [0, 1, 2, ...]. Retrieve the full enum set for the
|
||||
// specific index - each query can return up to ENUMSET_SIZE (64) records, each
|
||||
// containing an AccountId
|
||||
switchMap((next: AccountIndex): Observable<any> =>
|
||||
api.query.indices.enumSet.multi([...Array(next.toNumber() + 1).keys()]) as Observable<any>
|
||||
),
|
||||
map((all: (AccountId[] | undefined)[]): AccountIndexes =>
|
||||
(all || []).reduce((result, list, outerIndex): AccountIndexes => {
|
||||
return memo((): Observable<AccountIndexes> =>
|
||||
(api.query.indices.nextEnumSet
|
||||
? api.query.indices.nextEnumSet<AccountIndex>().pipe(
|
||||
// use the nextEnumSet (which is a counter of the number of sets) to construct
|
||||
// a range of values to query [0, 1, 2, ...]. Retrieve the full enum set for the
|
||||
// specific index - each query can return up to ENUMSET_SIZE (64) records, each
|
||||
// containing an AccountId
|
||||
switchMap((next: AccountIndex): Observable<Vec<AccountId>[]> =>
|
||||
api.query.indices.enumSet.multi<Vec<AccountId>>([...Array(next.toNumber() + 1).keys()])
|
||||
)
|
||||
)
|
||||
: of([] as AccountId[][])
|
||||
).pipe(
|
||||
map((all: AccountId[][]): AccountIndexes =>
|
||||
all.reduce((result: AccountIndexes, list, outerIndex): AccountIndexes => {
|
||||
(list || []).forEach((accountId, innerIndex): void => {
|
||||
// re-create the index based on position 0 is [0][0] and likewise
|
||||
// 64 (0..63 in first) is [1][0] (the first index value in set 2)
|
||||
const index = (outerIndex * enumsetSize) + innerIndex;
|
||||
|
||||
result[accountId.toString()] = createType('AccountIndex', index);
|
||||
result[accountId.toString()] = createType(api.registry, 'AccountIndex', index);
|
||||
});
|
||||
|
||||
return result;
|
||||
}, {} as AccountIndexes)),
|
||||
drr()
|
||||
);
|
||||
}, {}))
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1,31 +1,102 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { AccountId, AccountIndex, Address, Balance } from '@polkadot/types/interfaces';
|
||||
import { Codec } from '@polkadot/types/types';
|
||||
import { DeriveAccountInfo } from '../types';
|
||||
import { AccountId, AccountIndex, Address, Balance, Registration } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { DeriveAccountInfo, DeriveAccountRegistration } from '../types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { Bytes, Option, u32 } from '@polkadot/types';
|
||||
import { Bytes, Data, Option, u32 } from '@polkadot/types';
|
||||
import { u8aToString } from '@polkadot/util';
|
||||
|
||||
import { drr } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
function dataAsString (data: Data): string | undefined {
|
||||
return data.isRaw
|
||||
? u8aToString(data.asRaw.toU8a(true))
|
||||
: data.isSha256
|
||||
? data.asSha256.toHex()
|
||||
: undefined;
|
||||
}
|
||||
|
||||
function retrieveNick (api: ApiInterfaceRx, accountId?: AccountId): Observable<string | undefined> {
|
||||
return accountId && api.query.nicks
|
||||
? api.query.nicks
|
||||
.nameOf<Option<[Bytes, Balance] & Codec>>(accountId)
|
||||
.pipe(
|
||||
map((nameOf): string | undefined =>
|
||||
nameOf?.isSome
|
||||
? u8aToString(nameOf.unwrap()[0]).substr(0, (api.consts.nicks.maxLength as u32).toNumber())
|
||||
: undefined
|
||||
)
|
||||
)
|
||||
: of(undefined);
|
||||
return ((
|
||||
accountId && api.query.nicks?.nameOf
|
||||
? api.query.nicks.nameOf<Option<ITuple<[Bytes, Balance]>>>(accountId)
|
||||
: of(undefined)
|
||||
) as Observable<Option<ITuple<[Bytes, Balance]>> | undefined>).pipe(
|
||||
map((nameOf): string | undefined =>
|
||||
nameOf?.isSome
|
||||
? u8aToString(nameOf.unwrap()[0]).substr(0, (api.consts.nicks.maxLength as u32).toNumber())
|
||||
: undefined
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function extractIdentity (identityOfOpt?: Option<Registration>, superOf?: [AccountId, Data]): DeriveAccountRegistration {
|
||||
if (!identityOfOpt?.isSome) {
|
||||
return { judgements: [] };
|
||||
}
|
||||
|
||||
const { info, judgements } = identityOfOpt.unwrap();
|
||||
const topDisplay = dataAsString(info.display);
|
||||
|
||||
return {
|
||||
display: superOf
|
||||
? dataAsString(superOf[1]) || topDisplay
|
||||
: topDisplay,
|
||||
displayParent: superOf
|
||||
? topDisplay
|
||||
: undefined,
|
||||
email: dataAsString(info.email),
|
||||
image: dataAsString(info.image),
|
||||
legal: dataAsString(info.legal),
|
||||
parent: superOf
|
||||
? superOf[0]
|
||||
: undefined,
|
||||
pgp: info.pgpFingerprint.isSome
|
||||
? info.pgpFingerprint.unwrap().toHex()
|
||||
: undefined,
|
||||
riot: dataAsString(info.riot),
|
||||
twitter: dataAsString(info.twitter),
|
||||
web: dataAsString(info.web),
|
||||
judgements
|
||||
};
|
||||
}
|
||||
|
||||
function retrieveIdentity (api: ApiInterfaceRx, accountId?: AccountId): Observable<DeriveAccountRegistration> {
|
||||
return ((
|
||||
accountId && api.query.identity?.identityOf
|
||||
? api.queryMulti([
|
||||
[api.query.identity.identityOf, accountId],
|
||||
[api.query.identity.superOf, accountId]
|
||||
])
|
||||
: of([undefined, undefined])
|
||||
) as Observable<[Option<Registration> | undefined, Option<ITuple<[AccountId, Data]>> | undefined]>).pipe(
|
||||
switchMap(([identityOfOpt, superOfOpt]): Observable<[Option<Registration> | undefined, [AccountId, Data] | undefined]> => {
|
||||
if (identityOfOpt?.isSome) {
|
||||
// this identity has something set
|
||||
return of([identityOfOpt, undefined]);
|
||||
} else if (superOfOpt?.isSome) {
|
||||
const superOf = superOfOpt.unwrap();
|
||||
|
||||
// we have a super
|
||||
return combineLatest([
|
||||
api.query.identity.identityOf<Option<Registration>>(superOf[0]),
|
||||
of(superOf)
|
||||
]);
|
||||
}
|
||||
|
||||
// nothing of value returned
|
||||
return of([undefined, undefined]);
|
||||
}),
|
||||
map(([identityOfOpt, superOf]): DeriveAccountRegistration =>
|
||||
extractIdentity(identityOfOpt, superOf)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,17 +104,17 @@ function retrieveNick (api: ApiInterfaceRx, accountId?: AccountId): Observable<s
|
||||
* @description Returns aux. info with regards to an account, current that includes the accountId, accountIndex and nickname
|
||||
*/
|
||||
export function info (api: ApiInterfaceRx): (address?: AccountIndex | AccountId | Address | string | null) => Observable<DeriveAccountInfo> {
|
||||
return (address?: AccountIndex | AccountId | Address | string | null): Observable<DeriveAccountInfo> =>
|
||||
return memo((address?: AccountIndex | AccountId | Address | string | null): Observable<DeriveAccountInfo> =>
|
||||
api.derive.accounts.idAndIndex(address).pipe(
|
||||
switchMap(([accountId, accountIndex]): Observable<[DeriveAccountInfo, string?]> =>
|
||||
switchMap(([accountId, accountIndex]): Observable<[Partial<DeriveAccountInfo>, DeriveAccountRegistration, string?]> =>
|
||||
combineLatest([
|
||||
of({ accountId, accountIndex }),
|
||||
retrieveIdentity(api, accountId),
|
||||
retrieveNick(api, accountId)
|
||||
])
|
||||
),
|
||||
map(([{ accountId, accountIndex }, nickname]): DeriveAccountInfo => ({
|
||||
accountId, accountIndex, nickname
|
||||
})),
|
||||
drr()
|
||||
);
|
||||
map(([{ accountId, accountIndex }, identity, nickname]): DeriveAccountInfo => ({
|
||||
accountId, accountIndex, identity, nickname
|
||||
}))
|
||||
));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId, AccountData, AccountIndex, Address, Balance, Index } from '@polkadot/types/interfaces';
|
||||
import { DerivedBalancesAccount } from '../types';
|
||||
|
||||
import { combineLatest, of, Observable } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { createType } from '@polkadot/types';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type Result = [Balance, Balance, Balance, Balance, Index];
|
||||
|
||||
function calcBalances (api: ApiInterfaceRx, [accountId, [freeBalance, reservedBalance, frozenFee, frozenMisc, accountNonce]]: [AccountId, Result]): DerivedBalancesAccount {
|
||||
return {
|
||||
accountId,
|
||||
accountNonce,
|
||||
freeBalance,
|
||||
frozenFee,
|
||||
frozenMisc,
|
||||
reservedBalance,
|
||||
votingBalance: createType(api.registry, 'Balance', freeBalance.add(reservedBalance))
|
||||
};
|
||||
}
|
||||
|
||||
// old
|
||||
function queryOld (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
||||
return api.queryMulti<[Balance, Balance, Index]>([
|
||||
[api.query.balances.freeBalance, accountId],
|
||||
[api.query.balances.reservedBalance, accountId],
|
||||
[api.query.system.accountNonce, accountId]
|
||||
]).pipe(
|
||||
map(([freeBalance, reservedBalance, accountNonce]): Result =>
|
||||
[freeBalance, reservedBalance, createType(api.registry, 'Balance'), createType(api.registry, 'Balance'), accountNonce]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
||||
return api.queryMulti<[AccountData, Index]>([
|
||||
[api.query.balances.account, accountId],
|
||||
[api.query.system.accountNonce, accountId]
|
||||
]).pipe(
|
||||
map(([{ free, reserved, miscFrozen, feeFrozen }, accountNonce]): Result =>
|
||||
[free, reserved, feeFrozen, miscFrozen, accountNonce]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name account
|
||||
* @param {( AccountIndex | AccountId | Address | string )} address - An accounts Id in different formats.
|
||||
* @returns An object containing the results of various balance queries
|
||||
* @example
|
||||
* <BR>
|
||||
*
|
||||
* ```javascript
|
||||
* const ALICE = 'F7Hs';
|
||||
*
|
||||
* api.derive.balances.all(ALICE, ({ accountId, lockedBalance }) => {
|
||||
* console.log(`The account ${accountId} has a locked balance ${lockedBalance} units.`);
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function account (api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DerivedBalancesAccount> {
|
||||
return memo((address: AccountIndex | AccountId | Address | string): Observable<DerivedBalancesAccount> =>
|
||||
api.derive.accounts.info(address).pipe(
|
||||
switchMap(({ accountId }): Observable<[AccountId, Result]> =>
|
||||
(accountId
|
||||
? combineLatest([
|
||||
of(accountId),
|
||||
api.query.balances.account
|
||||
? queryCurrent(api, accountId)
|
||||
: queryOld(api, accountId)
|
||||
])
|
||||
: of([createType(api.registry, 'AccountId'), [createType(api.registry, 'Balance'), createType(api.registry, 'Balance'), createType(api.registry, 'Balance'), createType(api.registry, 'Balance'), createType(api.registry, 'Index')]])
|
||||
)
|
||||
),
|
||||
map((result): DerivedBalancesAccount => calcBalances(api, result))
|
||||
));
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId, AccountIndex, Address, Balance, BalanceLock, BlockNumber, Index, VestingSchedule } from '@polkadot/types/interfaces';
|
||||
import { DerivedBalances } from '../types';
|
||||
import { AccountId, AccountIndex, Address, Balance, BalanceLock, BalanceLockTo212, BlockNumber, VestingInfo, VestingSchedule } from '@polkadot/types/interfaces';
|
||||
import { DerivedBalancesAccount, DerivedBalancesAll } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { combineLatest, of, Observable } from 'rxjs';
|
||||
@@ -12,52 +12,101 @@ import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Option, Vec, createType } from '@polkadot/types';
|
||||
import { bnMax } from '@polkadot/util';
|
||||
|
||||
import { drr } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
type ResultBalance = [Balance, Balance, BalanceLock[], Option<VestingSchedule>];
|
||||
type Result = [AccountId, BlockNumber, ResultBalance, Index];
|
||||
type ResultBalance = [VestingInfo | null, (BalanceLock | BalanceLockTo212)[]];
|
||||
type Result = [DerivedBalancesAccount, BlockNumber, ResultBalance];
|
||||
|
||||
function calcBalances ([accountId, bestNumber, [freeBalance, reservedBalance, locks, vesting], accountNonce]: Result): DerivedBalances {
|
||||
let lockedBalance = createType('Balance');
|
||||
let lockedBreakdown: BalanceLock[] = [];
|
||||
function calcBalances (api: ApiInterfaceRx, [{ accountId, accountNonce, freeBalance, frozenFee, frozenMisc, reservedBalance, votingBalance }, bestNumber, [vesting, locks]]: Result): DerivedBalancesAll {
|
||||
let lockedBalance = createType(api.registry, 'Balance');
|
||||
let lockedBreakdown: (BalanceLock | BalanceLockTo212)[] = [];
|
||||
|
||||
if (Array.isArray(locks)) {
|
||||
// only get the locks that are valid until passed the current block
|
||||
lockedBreakdown = locks.filter(({ until }): boolean => bestNumber && until.gt(bestNumber));
|
||||
lockedBreakdown = (locks as BalanceLockTo212[]).filter(({ until }): boolean => !until || (bestNumber && until.gt(bestNumber)));
|
||||
|
||||
const notAll = lockedBreakdown.filter(({ amount }): boolean => !amount.isMax());
|
||||
|
||||
// get the maximum of the locks according to https://github.com/paritytech/substrate/blob/master/srml/balances/src/lib.rs#L699
|
||||
if (lockedBreakdown.length) {
|
||||
lockedBalance = createType('Balance', bnMax(...lockedBreakdown.map(({ amount }): Balance => amount)));
|
||||
if (notAll.length) {
|
||||
lockedBalance = createType(api.registry, 'Balance', bnMax(...notAll.map(({ amount }): Balance => amount)));
|
||||
}
|
||||
}
|
||||
|
||||
// offset = balance locked at genesis, perBlock is the unlock amount
|
||||
const { offset: vestingTotal, perBlock } = vesting.unwrapOr(createType('VestingSchedule'));
|
||||
const vestedNow = createType('Balance', perBlock.mul(bestNumber));
|
||||
const vestedBalance = createType('Balance', vestedNow.gt(vestingTotal) ? new BN(0) : bnMax(new BN(0), freeBalance.sub(vestingTotal).add(vestedNow)));
|
||||
const availableBalance = createType('Balance', bnMax(new BN(0), (vestedBalance.gtn(0) ? vestedBalance : freeBalance).sub(lockedBalance)));
|
||||
// Calculate the vesting balances,
|
||||
// - offset = balance locked at startingBlock
|
||||
// - perBlock is the unlock amount
|
||||
const { locked: vestingTotal, perBlock, startingBlock } = vesting || createType(api.registry, 'VestingInfo');
|
||||
const isStarted = bestNumber.gt(startingBlock);
|
||||
const vestedBalance = createType(api.registry, 'Balance', isStarted ? perBlock.mul(bestNumber.sub(startingBlock)) : 0);
|
||||
const isVesting = isStarted && vestedBalance.lt(vestingTotal);
|
||||
|
||||
// The available balance & vested has an interplay here
|
||||
// "
|
||||
// vesting is a guarantee that the account's balance will never go below a certain amount. so it functions in the opposite way, a bit like a lock that is monotonically decreasing rather than a liquid amount that is monotonically increasing.
|
||||
// locks function as the same guarantee - that a balance will not be lower than a particular amount.
|
||||
// because of this you can see that if there is a "vesting lock" that guarantees the balance cannot go below 200, and a "staking lock" that guarantees the balance cannot drop below 300, then we just have two guarantees of which the first is irrelevant.
|
||||
// i.e. (balance >= 200 && balance >= 300) == (balance >= 300)
|
||||
// ""
|
||||
const floating = freeBalance.sub(lockedBalance);
|
||||
const extraReceived = isVesting ? freeBalance.sub(vestingTotal) : new BN(0);
|
||||
const availableBalance = createType(api.registry, 'Balance', bnMax(new BN(0), isVesting && floating.gt(vestedBalance) ? vestedBalance.add(extraReceived) : floating));
|
||||
|
||||
return {
|
||||
accountId,
|
||||
accountNonce,
|
||||
availableBalance,
|
||||
freeBalance,
|
||||
frozenFee,
|
||||
frozenMisc,
|
||||
isVesting,
|
||||
lockedBalance,
|
||||
lockedBreakdown,
|
||||
reservedBalance,
|
||||
vestedBalance,
|
||||
vestingTotal,
|
||||
votingBalance: createType('Balance', freeBalance.add(reservedBalance))
|
||||
votingBalance
|
||||
};
|
||||
}
|
||||
|
||||
function queryBalances (api: ApiInterfaceRx, accountId: AccountId): Observable<ResultBalance> {
|
||||
return api.queryMulti<[Balance, Balance, Vec<BalanceLock>, Option<VestingSchedule>]>([
|
||||
[api.query.balances.freeBalance, accountId],
|
||||
[api.query.balances.reservedBalance, accountId],
|
||||
// old
|
||||
function queryOld (api: ApiInterfaceRx, accountId: AccountId): Observable<ResultBalance> {
|
||||
return api.queryMulti<[Vec<BalanceLock>, Option<VestingSchedule>]>([
|
||||
[api.query.balances.locks, accountId],
|
||||
[api.query.balances.vesting, accountId]
|
||||
]);
|
||||
]).pipe(
|
||||
map(([locks, optVesting]): ResultBalance => {
|
||||
let vestingNew = null;
|
||||
|
||||
if (optVesting.isSome) {
|
||||
const { offset: locked, perBlock, startingBlock } = optVesting.unwrap();
|
||||
|
||||
vestingNew = createType(api.registry, 'VestingInfo', { locked, perBlock, startingBlock });
|
||||
}
|
||||
|
||||
return [vestingNew, locks];
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// current (balances vesting)
|
||||
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<ResultBalance> {
|
||||
return (
|
||||
api.query.vesting.vesting
|
||||
? api.queryMulti<[Vec<BalanceLock>, Option<VestingInfo>]>([
|
||||
[api.query.balances.locks, accountId],
|
||||
[api.query.vesting.vesting, accountId]
|
||||
])
|
||||
: api.query.balances.locks(accountId).pipe(
|
||||
map((locks): [Vec<BalanceLock>, Option<VestingInfo>] =>
|
||||
[locks, createType(api.registry, 'Option<VestingInfo>')]
|
||||
)
|
||||
)
|
||||
).pipe(
|
||||
map(([locks, optVesting]): ResultBalance =>
|
||||
[optVesting.unwrapOr(null), locks]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,26 +124,21 @@ function queryBalances (api: ApiInterfaceRx, accountId: AccountId): Observable<R
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function all (api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DerivedBalances> {
|
||||
return (address: AccountIndex | AccountId | Address | string): Observable<DerivedBalances> =>
|
||||
api.derive.accounts.info(address).pipe(
|
||||
switchMap(({ accountId }): Observable<Result> =>
|
||||
(accountId
|
||||
export function all (api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DerivedBalancesAll> {
|
||||
return memo((address: AccountIndex | AccountId | Address | string): Observable<DerivedBalancesAll> =>
|
||||
api.derive.balances.account(address).pipe(
|
||||
switchMap((account): Observable<Result> =>
|
||||
(!account.accountId.isEmpty
|
||||
? combineLatest([
|
||||
of(accountId),
|
||||
of(account),
|
||||
api.derive.chain.bestNumber(),
|
||||
queryBalances(api, accountId),
|
||||
// FIXME This is having issues with Kusama, only use accountNonce atm
|
||||
// api.rpc.account && api.rpc.account.nextIndex
|
||||
// ? api.rpc.account.nextIndex(accountId)
|
||||
// // otherwise we end up with this: type 'Codec | Index' is not assignable to type 'Index'.
|
||||
// : api.query.system.accountNonce<Index>(accountId)
|
||||
api.query.system.accountNonce<Index>(accountId)
|
||||
api.query.balances.account
|
||||
? queryCurrent(api, account.accountId)
|
||||
: queryOld(api, account.accountId)
|
||||
])
|
||||
: of([createType('AccountId'), createType('BlockNumber'), [createType('Balance'), createType('Balance'), createType('Vec<BalanceLock>'), createType('Option<VestingSchedule>', null)], createType('Index')])
|
||||
: of([account, createType(api.registry, 'BlockNumber'), [null, createType(api.registry, 'Vec<BalanceLock>')]])
|
||||
)
|
||||
),
|
||||
map(calcBalances),
|
||||
drr()
|
||||
);
|
||||
map((result): DerivedBalancesAll => calcBalances(api, result))
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -8,33 +8,22 @@ import { DerivedFees } from '../types';
|
||||
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { createType } from '@polkadot/types';
|
||||
|
||||
import { drr } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
type Result = [Balance, Balance, Balance, Balance, Balance];
|
||||
|
||||
function queryV2 (api: ApiInterfaceRx): Observable<Result> {
|
||||
const paymentBase = api.consts.transactionPayment || api.consts.balances;
|
||||
|
||||
function query (api: ApiInterfaceRx): Observable<Result> {
|
||||
return of([
|
||||
// get values from api.const for substrate versions post spec_version: 101
|
||||
// https://github.com/paritytech/substrate/pull/2883/files#diff-5e5e1c3aec9ddfde0a9054d062ab3db9R131
|
||||
api.consts.balances.creationFee as Balance,
|
||||
api.consts.balances.existentialDeposit as Balance,
|
||||
api.consts.balances.transferFee as Balance,
|
||||
paymentBase.transactionBaseFee as Balance,
|
||||
paymentBase.transactionByteFee as Balance
|
||||
]);
|
||||
}
|
||||
// deprecated - remove
|
||||
(api.consts.balances.creationFee as Balance) || createType(api.registry, 'Balance'),
|
||||
(api.consts.balances.transferFee as Balance) || createType(api.registry, 'Balance'),
|
||||
|
||||
function queryV1 (api: ApiInterfaceRx): Observable<Result> {
|
||||
return api.queryMulti<Result>([
|
||||
// Support older versions and get values from storage
|
||||
api.query.balances.creationFee,
|
||||
api.query.balances.existentialDeposit,
|
||||
api.query.balances.transferFee,
|
||||
api.query.balances.transactionBaseFee,
|
||||
api.query.balances.transactionByteFee
|
||||
// current
|
||||
api.consts.balances.existentialDeposit,
|
||||
api.consts.transactionPayment.transactionBaseFee,
|
||||
api.consts.transactionPayment.transactionByteFee
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -52,19 +41,14 @@ function queryV1 (api: ApiInterfaceRx): Observable<Result> {
|
||||
* ```
|
||||
*/
|
||||
export function fees (api: ApiInterfaceRx): () => Observable<DerivedFees> {
|
||||
const query = api.consts.balances
|
||||
? queryV2
|
||||
: queryV1;
|
||||
|
||||
return (): Observable<DerivedFees> =>
|
||||
return memo((): Observable<DerivedFees> =>
|
||||
query(api).pipe(
|
||||
map(([creationFee, existentialDeposit, transferFee, transactionBaseFee, transactionByteFee]): DerivedFees => ({
|
||||
map(([creationFee, transferFee, existentialDeposit, transactionBaseFee, transactionByteFee]): DerivedFees => ({
|
||||
creationFee,
|
||||
existentialDeposit,
|
||||
transactionBaseFee,
|
||||
transactionByteFee,
|
||||
transferFee
|
||||
})),
|
||||
drr()
|
||||
);
|
||||
}))
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { all } from './all';
|
||||
|
||||
export * from './account';
|
||||
export * from './fees';
|
||||
export * from './votingBalances';
|
||||
export * from './votingBalancesNominatorsFor';
|
||||
|
||||
const votingBalance = all;
|
||||
|
||||
|
||||
@@ -1,25 +1,22 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
|
||||
import { DerivedBalancesAccount } from '../types';
|
||||
|
||||
import { combineLatest, Observable, of } from 'rxjs';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
|
||||
import { DerivedBalances } from '../types';
|
||||
import { drr } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function votingBalances (api: ApiInterfaceRx): (addresses?: (AccountId | AccountIndex | Address | string)[]) => Observable<DerivedBalances[]> {
|
||||
return (addresses?: (AccountId | AccountIndex | Address | string)[]): Observable<DerivedBalances[]> =>
|
||||
(
|
||||
!addresses || !addresses.length
|
||||
? of([] as DerivedBalances[])
|
||||
: combineLatest(
|
||||
addresses.map((accountId): Observable<DerivedBalances> =>
|
||||
api.derive.balances.all(accountId))
|
||||
)
|
||||
).pipe(
|
||||
drr()
|
||||
);
|
||||
export function votingBalances (api: ApiInterfaceRx): (addresses?: (AccountId | AccountIndex | Address | string)[]) => Observable<DerivedBalancesAccount[]> {
|
||||
return memo((addresses?: (AccountId | AccountIndex | Address | string)[]): Observable<DerivedBalancesAccount[]> =>
|
||||
!addresses || !addresses.length
|
||||
? of([] as DerivedBalancesAccount[])
|
||||
: combineLatest(
|
||||
addresses.map((accountId): Observable<DerivedBalancesAccount> =>
|
||||
api.derive.balances.account(accountId))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
|
||||
import { DerivedBalances } from '../types';
|
||||
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Vec } from '@polkadot/types';
|
||||
|
||||
import { drr } from '../util';
|
||||
|
||||
export function votingBalancesNominatorsFor (api: ApiInterfaceRx): (address: AccountId | AccountIndex | Address | string) => Observable<DerivedBalances[]> {
|
||||
return (address: AccountId | AccountIndex | Address | string): Observable<DerivedBalances[]> =>
|
||||
api.derive.accounts.info(address).pipe(
|
||||
switchMap(({ accountId }): Observable<AccountId[]> =>
|
||||
accountId
|
||||
? api.query.staking.nominatorsFor<Vec<AccountId>>(accountId)
|
||||
: of([] as AccountId[])
|
||||
),
|
||||
switchMap((accounts): Observable<DerivedBalances[]> =>
|
||||
api.derive.balances.votingBalances(accounts)
|
||||
),
|
||||
drr()
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
|
||||
import { drr } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
/**
|
||||
* @name bestNumber
|
||||
@@ -23,9 +23,8 @@ import { drr } from '../util';
|
||||
* ```
|
||||
*/
|
||||
export function bestNumber (api: ApiInterfaceRx): () => Observable<BlockNumber> {
|
||||
return (): Observable<BlockNumber> =>
|
||||
return memo((): Observable<BlockNumber> =>
|
||||
api.derive.chain.subscribeNewHeads().pipe(
|
||||
map((header: Header): BlockNumber => header.number.unwrap()),
|
||||
drr()
|
||||
);
|
||||
map((header: Header): BlockNumber => header.number.unwrap())
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
|
||||
import { drr } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
/**
|
||||
* @name bestNumberFinalized
|
||||
@@ -24,9 +24,8 @@ import { drr } from '../util';
|
||||
* ```
|
||||
*/
|
||||
export function bestNumberFinalized (api: ApiInterfaceRx): () => Observable<BlockNumber> {
|
||||
return (): Observable<BlockNumber> =>
|
||||
return memo((): Observable<BlockNumber> =>
|
||||
api.rpc.chain.subscribeFinalizedHeads().pipe(
|
||||
map((header): BlockNumber => header.number.unwrap()),
|
||||
drr()
|
||||
);
|
||||
map((header): BlockNumber => header.number.unwrap())
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -9,7 +9,7 @@ import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { createType } from '@polkadot/types';
|
||||
|
||||
import { drr } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
/**
|
||||
* @name bestNumberLag
|
||||
@@ -25,14 +25,13 @@ import { drr } from '../util';
|
||||
* ```
|
||||
*/
|
||||
export function bestNumberLag (api: ApiInterfaceRx): () => Observable<BlockNumber> {
|
||||
return (): Observable<BlockNumber> =>
|
||||
return memo((): Observable<BlockNumber> =>
|
||||
combineLatest([
|
||||
api.derive.chain.bestNumber(),
|
||||
api.derive.chain.bestNumberFinalized()
|
||||
]).pipe(
|
||||
map(([bestNumber, bestNumberFinalized]): BlockNumber =>
|
||||
createType('BlockNumber', bestNumber.sub(bestNumberFinalized))
|
||||
),
|
||||
drr()
|
||||
);
|
||||
createType(api.registry, 'BlockNumber', bestNumber.sub(bestNumberFinalized))
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -11,7 +11,7 @@ import { catchError, map } from 'rxjs/operators';
|
||||
import { Vec } from '@polkadot/types';
|
||||
|
||||
import { HeaderExtended } from '../type';
|
||||
import { drr } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
/**
|
||||
* @name bestNumberFinalized
|
||||
@@ -28,7 +28,7 @@ import { drr } from '../util';
|
||||
* ```
|
||||
*/
|
||||
export function getHeader (api: ApiInterfaceRx): (hash: Uint8Array | string) => Observable<HeaderExtended | undefined> {
|
||||
return (hash: Uint8Array | string): Observable<HeaderExtended | undefined> =>
|
||||
return memo((hash: Uint8Array | string): Observable<HeaderExtended | undefined> =>
|
||||
combineLatest([
|
||||
api.rpc.chain.getHeader(hash),
|
||||
api.query.session
|
||||
@@ -36,14 +36,13 @@ export function getHeader (api: ApiInterfaceRx): (hash: Uint8Array | string) =>
|
||||
: of([])
|
||||
]).pipe(
|
||||
map(([header, validators]): HeaderExtended =>
|
||||
new HeaderExtended(header, validators)
|
||||
new HeaderExtended(api.registry, header, validators)
|
||||
),
|
||||
catchError((): Observable<undefined> =>
|
||||
// where rpc.chain.getHeader throws, we will land here - it can happen that
|
||||
// we supplied an invalid hash. (Due to defaults, storeage will have an
|
||||
// empty value, so only the RPC is affected). So return undefined
|
||||
of()
|
||||
),
|
||||
drr()
|
||||
);
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
|
||||
import { Observable, combineLatest } from 'rxjs';
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { HeaderExtended } from '../type';
|
||||
import { drr } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
/**
|
||||
* @name subscribeNewHeads
|
||||
@@ -24,14 +24,15 @@ import { drr } from '../util';
|
||||
* ```
|
||||
*/
|
||||
export function subscribeNewHeads (api: ApiInterfaceRx): () => Observable<HeaderExtended> {
|
||||
return (): Observable<HeaderExtended> =>
|
||||
return memo((): Observable<HeaderExtended> =>
|
||||
combineLatest([
|
||||
api.rpc.chain.subscribeNewHeads(),
|
||||
api.derive.staking.validators()
|
||||
api.query.session
|
||||
? api.query.session.validators()
|
||||
: of([])
|
||||
]).pipe(
|
||||
map(([header, { validators }]): HeaderExtended =>
|
||||
new HeaderExtended(header, validators)
|
||||
),
|
||||
drr()
|
||||
);
|
||||
map(([header, validators]): HeaderExtended =>
|
||||
new HeaderExtended(api.registry, header, validators)
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export * from './proposals';
|
||||
@@ -0,0 +1,43 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Hash, Proposal, Votes } from '@polkadot/types/interfaces';
|
||||
import { DerivedCollectiveProposal } from '../types';
|
||||
|
||||
import { combineLatest, Observable, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { Option } from '@polkadot/types';
|
||||
|
||||
type Result = [Hash[], Option<Proposal>[], Option<Votes>[]];
|
||||
|
||||
export function proposals (api: ApiInterfaceRx, section: 'council' | 'technicalCommittee'): () => Observable<DerivedCollectiveProposal[]> {
|
||||
return (): Observable<DerivedCollectiveProposal[]> =>
|
||||
api.query[section]
|
||||
? api.query[section].proposals().pipe(
|
||||
switchMap((hashes: Hash[]): Observable<Result> =>
|
||||
hashes.length
|
||||
? combineLatest([
|
||||
of(hashes),
|
||||
api.query[section].proposalOf.multi<Option<Proposal>>(hashes),
|
||||
api.query[section].voting.multi<Option<Votes>>(hashes)
|
||||
])
|
||||
: of([[], [], []])
|
||||
),
|
||||
map(([hashes, proposals, votes]: Result): DerivedCollectiveProposal[] =>
|
||||
proposals
|
||||
.map((proposalOpt, index): DerivedCollectiveProposal | null =>
|
||||
proposalOpt.isSome
|
||||
? {
|
||||
hash: hashes[index],
|
||||
proposal: proposalOpt.unwrap(),
|
||||
votes: votes[index].unwrapOr(null)
|
||||
}
|
||||
: null
|
||||
)
|
||||
.filter((proposal): boolean => !!proposal) as DerivedCollectiveProposal[]
|
||||
)
|
||||
)
|
||||
: of([] as DerivedCollectiveProposal[]);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -8,85 +8,27 @@ import { DerivedContractFees } from '../types';
|
||||
import BN from 'bn.js';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { createType } from '@polkadot/types';
|
||||
|
||||
import { drr } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
type ResultV2 = [BN, BN, BN, BN, BN, BN, BN, BN, BN, BN];
|
||||
|
||||
const ZERO = new BN(0);
|
||||
|
||||
// parse the result
|
||||
function parseResult ([callBaseFee, contractFee, createBaseFee, creationFee, rentByteFee, rentDepositOffset, tombstoneDeposit, transactionBaseFee, transactionByteFee, transferFee]: ResultV2): DerivedContractFees {
|
||||
return {
|
||||
callBaseFee,
|
||||
contractFee,
|
||||
createBaseFee,
|
||||
creationFee,
|
||||
rentByteFee,
|
||||
rentDepositOffset,
|
||||
tombstoneDeposit,
|
||||
transactionBaseFee,
|
||||
transactionByteFee,
|
||||
transferFee
|
||||
};
|
||||
}
|
||||
|
||||
// Only for 1.0 support. rentByteFee, rentDepositOffset, tombstoneDeposit are not available in substrate 1.0.
|
||||
// TODO remove this once 1.0 support is dropped
|
||||
function queryV1 (api: ApiInterfaceRx): Observable<DerivedContractFees> {
|
||||
return (
|
||||
api.queryMulti([
|
||||
api.query.contract.callBaseFee,
|
||||
api.query.contract.contractFee,
|
||||
api.query.contract.createBaseFee,
|
||||
api.query.contract.creationFee,
|
||||
api.query.contract.transactionBaseFee,
|
||||
api.query.contract.transactionByteFee,
|
||||
api.query.contract.transferFee
|
||||
]) as unknown as Observable<BN[]>
|
||||
).pipe(
|
||||
map(([callBaseFee, contractFee, createBaseFee, creationFee, transactionBaseFee, transactionByteFee, transferFee]): DerivedContractFees =>
|
||||
// We've done this on purpose, i.e. so we can just copy the name/order from the parse above and
|
||||
// see gaps, in this case those are filled with `ZERO`
|
||||
parseResult([
|
||||
callBaseFee, contractFee, createBaseFee, creationFee, ZERO, ZERO, ZERO, transactionBaseFee, transactionByteFee, transferFee
|
||||
])
|
||||
),
|
||||
drr()
|
||||
);
|
||||
}
|
||||
|
||||
// query via query (early v2, non-current, support to be dropped])
|
||||
function queryQuery (api: ApiInterfaceRx): Observable<ResultV2> {
|
||||
const queryBase = api.query.contracts || api.query.contract;
|
||||
|
||||
return api.queryMulti([
|
||||
queryBase.callBaseFee,
|
||||
queryBase.contractFee,
|
||||
queryBase.createBaseFee,
|
||||
queryBase.creationFee,
|
||||
queryBase.rentByteFee,
|
||||
queryBase.rentDepositOffset,
|
||||
queryBase.tombstoneDeposit,
|
||||
queryBase.transactionBaseFee,
|
||||
queryBase.transactionByteFee,
|
||||
queryBase.transferFee
|
||||
]) as unknown as Observable<ResultV2>;
|
||||
}
|
||||
type ResultV2 = [BN, BN, BN, BN, BN, BN, BN, BN, BN];
|
||||
|
||||
// query via constants (current applicable path)
|
||||
function queryConstants (api: ApiInterfaceRx): Observable<ResultV2> {
|
||||
return of([
|
||||
// deprecated
|
||||
api.consts.contracts.creationFee || createType(api.registry, 'Balance'),
|
||||
api.consts.contracts.transferFee || createType(api.registry, 'Balance'),
|
||||
|
||||
// current
|
||||
api.consts.contracts.callBaseFee,
|
||||
api.consts.contracts.contractFee,
|
||||
api.consts.contracts.createBaseFee,
|
||||
api.consts.contracts.creationFee,
|
||||
api.consts.contracts.rentByteFee,
|
||||
api.consts.contracts.rentDepositOffset,
|
||||
api.consts.contracts.tombstoneDeposit,
|
||||
api.consts.contracts.transactionBaseFee,
|
||||
api.consts.contracts.transactionByteFee,
|
||||
api.consts.contracts.transferFee
|
||||
api.consts.contracts.transactionByteFee
|
||||
]) as unknown as Observable<ResultV2>;
|
||||
}
|
||||
|
||||
@@ -104,23 +46,19 @@ function queryConstants (api: ApiInterfaceRx): Observable<ResultV2> {
|
||||
* ```
|
||||
*/
|
||||
export function fees (api: ApiInterfaceRx): () => Observable<DerivedContractFees> {
|
||||
return (): Observable<DerivedContractFees> => {
|
||||
if (api.query.contract && !api.query.contract.rentByteFee) {
|
||||
return queryV1(api);
|
||||
}
|
||||
|
||||
return (
|
||||
api.consts.contracts
|
||||
? queryConstants(api)
|
||||
: queryQuery(api)
|
||||
).pipe(
|
||||
map(([callBaseFee, contractFee, createBaseFee, creationFee, rentByteFee, rentDepositOffset, tombstoneDeposit, transactionBaseFee, transactionByteFee, transferFee]): DerivedContractFees =>
|
||||
// We've done this on purpose, i.e. so we can just copy the name/order from the parse above and see gaps
|
||||
parseResult([
|
||||
callBaseFee, contractFee, createBaseFee, creationFee, rentByteFee, rentDepositOffset, tombstoneDeposit, transactionBaseFee, transactionByteFee, transferFee
|
||||
])
|
||||
),
|
||||
drr()
|
||||
return memo((): Observable<DerivedContractFees> => {
|
||||
return queryConstants(api).pipe(
|
||||
map(([creationFee, transferFee, callBaseFee, contractFee, rentByteFee, rentDepositOffset, tombstoneDeposit, transactionBaseFee, transactionByteFee]): DerivedContractFees => ({
|
||||
callBaseFee,
|
||||
contractFee,
|
||||
creationFee,
|
||||
rentByteFee,
|
||||
rentDepositOffset,
|
||||
tombstoneDeposit,
|
||||
transactionBaseFee,
|
||||
transactionByteFee,
|
||||
transferFee
|
||||
}))
|
||||
);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export * from './proposals';
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { DerivedCollectiveProposals } from '../types';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { proposals as collectiveProposals } from '../collective';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function proposals (api: ApiInterfaceRx): () => Observable<DerivedCollectiveProposals> {
|
||||
return memo(collectiveProposals(api, 'council'));
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export * from './proposals';
|
||||
export * from './referendumInfos';
|
||||
export * from './referendums';
|
||||
export * from './referendumVotesFor';
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId, Balance, BlockNumber, Hash, PropIndex, Proposal } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { DeriveProposal } from '../types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Bytes, Option, Vec, createType } from '@polkadot/types';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
export type PreImage = Option<ITuple<[Bytes, AccountId, Balance, BlockNumber]>>;
|
||||
|
||||
type Depositors = Option<ITuple<[Balance, Vec<AccountId>]>>;
|
||||
type Proposals = Vec<ITuple<[PropIndex, Hash, AccountId]>>;
|
||||
|
||||
interface Result {
|
||||
depositors: Depositors[];
|
||||
preimages: PreImage[];
|
||||
proposals: Proposals;
|
||||
}
|
||||
|
||||
function parse (api: ApiInterfaceRx, { depositors, proposals, preimages }: Result): DeriveProposal[] {
|
||||
return proposals
|
||||
.filter(([, , proposer], index): boolean =>
|
||||
!!(depositors[index]?.isSome) && !proposer.isEmpty
|
||||
)
|
||||
.map(([propIndex, hash, proposer], index): DeriveProposal => {
|
||||
const preimage = preimages[index].unwrapOr(null);
|
||||
const depositor = depositors[index].unwrap();
|
||||
let proposal: undefined | Proposal;
|
||||
|
||||
// we could end up in a situation where the proposal is non-decodable, e.g. after an upgrade
|
||||
if (preimage) {
|
||||
try {
|
||||
proposal = createType(api.registry, 'Proposal', preimage[0].toU8a(true));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
balance: depositor[0],
|
||||
hash,
|
||||
index: propIndex,
|
||||
preimage: preimage
|
||||
? {
|
||||
at: preimage[3],
|
||||
balance: preimage[2],
|
||||
proposer: preimage[1]
|
||||
}
|
||||
: undefined,
|
||||
proposal,
|
||||
proposer,
|
||||
seconds: depositor[1]
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function proposals (api: ApiInterfaceRx): () => Observable<DeriveProposal[]> {
|
||||
return memo((): Observable<DeriveProposal[]> =>
|
||||
api.query.democracy?.publicProps
|
||||
? api.query.democracy.publicProps<Proposals>().pipe(
|
||||
switchMap((proposals) =>
|
||||
combineLatest([
|
||||
of(proposals),
|
||||
api.query.democracy.preimages.multi<PreImage>(
|
||||
proposals.map(([, hash]): Hash => hash)),
|
||||
api.query.democracy.depositOf.multi<Depositors>(
|
||||
proposals.map(([index]): PropIndex => index))
|
||||
])
|
||||
),
|
||||
map(([proposals, preimages, depositors]): DeriveProposal[] =>
|
||||
parse(api, { depositors, proposals, preimages })
|
||||
)
|
||||
)
|
||||
: of([] as DeriveProposal[])
|
||||
);
|
||||
}
|
||||
@@ -1,38 +1,64 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ReferendumInfo } from '@polkadot/types/interfaces/democracy';
|
||||
import { DerivedReferendum } from '../types';
|
||||
import { PreImage } from './proposals';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Option } from '@polkadot/types';
|
||||
import { isNull } from '@polkadot/util';
|
||||
import { Option, createType } from '@polkadot/types';
|
||||
|
||||
import { ReferendumInfoExtended } from '../type';
|
||||
import { drr } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function constructInfo (index: BN | number, optionInfo?: Option<ReferendumInfo>): Option<ReferendumInfoExtended> {
|
||||
const info = optionInfo
|
||||
? optionInfo.unwrapOr(null)
|
||||
function constructInfo (api: ApiInterfaceRx, index: BN | number, _info: Option<ReferendumInfo>, _preimage?: PreImage): DerivedReferendum | null {
|
||||
const preImage = _preimage?.isSome
|
||||
? _preimage.unwrap()
|
||||
: null;
|
||||
const info = _info.unwrapOr(null);
|
||||
|
||||
return new Option<ReferendumInfoExtended>(
|
||||
ReferendumInfoExtended,
|
||||
isNull(info)
|
||||
? null
|
||||
: new ReferendumInfoExtended(info, index)
|
||||
if (!info) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
index: createType(api.registry, 'PropIndex', index),
|
||||
info,
|
||||
hash: info.proposalHash,
|
||||
proposal: preImage
|
||||
? createType(api.registry, 'Proposal', preImage[0].toU8a(true))
|
||||
: undefined,
|
||||
preimage: preImage
|
||||
? {
|
||||
at: preImage[3],
|
||||
balance: preImage[2],
|
||||
proposer: preImage[1]
|
||||
}
|
||||
: undefined
|
||||
};
|
||||
}
|
||||
|
||||
export function retrieveInfo (api: ApiInterfaceRx, index: BN | number, info: Option<ReferendumInfo>): Observable<DerivedReferendum | null> {
|
||||
return ((
|
||||
info?.isSome
|
||||
? api.query.democracy.preimages<PreImage>(info.unwrap().proposalHash)
|
||||
: of(undefined)
|
||||
) as Observable<PreImage | undefined>).pipe(
|
||||
map((preimage?: PreImage): DerivedReferendum | null =>
|
||||
constructInfo(api, index, info, preimage)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function referendumInfo (api: ApiInterfaceRx): (index: BN | number) => Observable<Option<ReferendumInfoExtended>> {
|
||||
return (index: BN | number): Observable<Option<ReferendumInfoExtended>> =>
|
||||
export function referendumInfo (api: ApiInterfaceRx): (index: BN | number) => Observable<DerivedReferendum | null> {
|
||||
return memo((index: BN | number): Observable<DerivedReferendum | null> =>
|
||||
api.query.democracy.referendumInfoOf<Option<ReferendumInfo>>(index).pipe(
|
||||
map((optionInfo): Option<ReferendumInfoExtended> =>
|
||||
constructInfo(index, optionInfo)
|
||||
),
|
||||
drr()
|
||||
);
|
||||
switchMap((info): Observable<DerivedReferendum | null> =>
|
||||
retrieveInfo(api, index, info)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,31 +1,35 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ReferendumInfo } from '@polkadot/types/interfaces/democracy';
|
||||
import { DerivedReferendum } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Option, Vec } from '@polkadot/types';
|
||||
import { Option } from '@polkadot/types';
|
||||
|
||||
import { ReferendumInfoExtended } from '../type';
|
||||
import { drr } from '../util';
|
||||
import { constructInfo } from './referendumInfo';
|
||||
import { memo } from '../util';
|
||||
import { retrieveInfo } from './referendumInfo';
|
||||
|
||||
export function referendumInfos (api: ApiInterfaceRx): (ids?: (BN | number)[]) => Observable<Option<ReferendumInfoExtended>[]> {
|
||||
return (ids: (BN | number)[] = []): Observable<Option<ReferendumInfoExtended>[]> =>
|
||||
export function referendumInfos (api: ApiInterfaceRx): (ids?: (BN | number)[]) => Observable<DerivedReferendum[]> {
|
||||
return memo((ids: (BN | number)[] = []): Observable<DerivedReferendum[]> =>
|
||||
(
|
||||
!ids || !ids.length
|
||||
!ids?.length
|
||||
? of([] as Option<ReferendumInfo>[])
|
||||
: api.query.democracy.referendumInfoOf.multi(ids) as Observable<Vec<Option<ReferendumInfo>>>
|
||||
: api.query.democracy.referendumInfoOf.multi<Option<ReferendumInfo>>(ids)
|
||||
).pipe(
|
||||
map((infos): Option<ReferendumInfoExtended>[] =>
|
||||
ids.map((id, index): Option<ReferendumInfoExtended> =>
|
||||
constructInfo(id, infos[index])
|
||||
switchMap((infos): Observable<(DerivedReferendum | null)[]> =>
|
||||
combineLatest(
|
||||
...ids.map((id, index): Observable<DerivedReferendum | null> =>
|
||||
retrieveInfo(api, id, infos[index])
|
||||
)
|
||||
)
|
||||
),
|
||||
drr()
|
||||
);
|
||||
map((infos): DerivedReferendum[] =>
|
||||
infos.filter((referendum): boolean => !!referendum) as DerivedReferendum[]
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -10,26 +10,25 @@ import { map, switchMap } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Vec, createType } from '@polkadot/types';
|
||||
|
||||
import { DerivedBalances, DerivedReferendumVote } from '../types';
|
||||
import { drr } from '../util';
|
||||
import { DerivedBalancesAccount, DerivedReferendumVote } from '../types';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function referendumVotesFor (api: ApiInterfaceRx): (referendumId: BN | number) => Observable<DerivedReferendumVote[]> {
|
||||
return (referendumId: BN | number): Observable<DerivedReferendumVote[]> =>
|
||||
return memo((referendumId: BN | number): Observable<DerivedReferendumVote[]> =>
|
||||
api.query.democracy.votersFor<Vec<AccountId>>(referendumId).pipe(
|
||||
switchMap((votersFor): Observable<[Vec<AccountId>, Vote[], DerivedBalances[]]> =>
|
||||
switchMap((votersFor): Observable<[Vec<AccountId>, Vote[], DerivedBalancesAccount[]]> =>
|
||||
combineLatest([
|
||||
of(votersFor),
|
||||
api.derive.democracy.votes(referendumId as BN, votersFor),
|
||||
api.derive.democracy.votes(referendumId, votersFor),
|
||||
api.derive.balances.votingBalances(votersFor)
|
||||
])
|
||||
),
|
||||
map(([votersFor, votes, balances]): DerivedReferendumVote[] =>
|
||||
votersFor.map((accountId, index): DerivedReferendumVote => ({
|
||||
accountId,
|
||||
balance: balances[index].votingBalance || createType('Balance'),
|
||||
vote: votes[index] || createType('Vote')
|
||||
} as unknown as DerivedReferendumVote))
|
||||
),
|
||||
drr()
|
||||
);
|
||||
balance: balances[index].votingBalance || createType(api.registry, 'Balance'),
|
||||
vote: votes[index] || createType(api.registry, 'Vote')
|
||||
} as DerivedReferendumVote))
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1,33 +1,34 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ReferendumIndex } from '@polkadot/types/interfaces/democracy';
|
||||
import { DerivedReferendum } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Option } from '@polkadot/types';
|
||||
|
||||
import { ReferendumInfoExtended } from '../type';
|
||||
import { drr } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function referendums (api: ApiInterfaceRx): () => Observable<Option<ReferendumInfoExtended>[]> {
|
||||
return (): Observable<Option<ReferendumInfoExtended>[]> =>
|
||||
api.queryMulti<[ReferendumIndex, ReferendumIndex]>([
|
||||
api.query.democracy.nextTally,
|
||||
api.query.democracy.referendumCount
|
||||
]).pipe(
|
||||
switchMap(([nextTally, referendumCount]): Observable<Option<ReferendumInfoExtended>[]> =>
|
||||
referendumCount && nextTally && referendumCount.gt(nextTally) && referendumCount.gtn(0)
|
||||
? api.derive.democracy.referendumInfos(
|
||||
[...Array(referendumCount.sub(nextTally).toNumber())].map((_, i): BN =>
|
||||
nextTally.addn(i)
|
||||
export function referendums (api: ApiInterfaceRx): () => Observable<DerivedReferendum[]> {
|
||||
return memo((): Observable<DerivedReferendum[]> =>
|
||||
api.query.democracy?.lowestUnbaked
|
||||
? api.queryMulti<[ReferendumIndex, ReferendumIndex]>([
|
||||
api.query.democracy.lowestUnbaked,
|
||||
api.query.democracy.referendumCount
|
||||
]).pipe(
|
||||
switchMap(([earliest, referendumCount]): Observable<DerivedReferendum[]> =>
|
||||
referendumCount?.gt(earliest) && referendumCount?.gtn(0)
|
||||
? api.derive.democracy.referendumInfos(
|
||||
[...Array(referendumCount.sub(earliest).toNumber())].map((_, i): BN =>
|
||||
earliest.addn(i)
|
||||
)
|
||||
)
|
||||
)
|
||||
: of([])
|
||||
),
|
||||
drr()
|
||||
);
|
||||
: of([])
|
||||
)
|
||||
)
|
||||
: of([] as DerivedReferendum[])
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -8,17 +8,16 @@ import BN from 'bn.js';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
|
||||
import { drr } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function votes (api: ApiInterfaceRx): (referendumId: BN, accountIds?: AccountId[]) => Observable<Vote[]> {
|
||||
return (referendumId: BN, accountIds: AccountId[] = []): Observable<Vote[]> =>
|
||||
(
|
||||
!accountIds || !accountIds.length
|
||||
? of([] as Vote[])
|
||||
: api.query.democracy.voteOf.multi<Vote>(
|
||||
accountIds.map((accountId): [BN, AccountId] =>
|
||||
[referendumId, accountId]
|
||||
)
|
||||
export function votes (api: ApiInterfaceRx): (referendumId: BN | number, accountIds?: AccountId[]) => Observable<Vote[]> {
|
||||
return memo((referendumId: BN | number, accountIds: AccountId[] = []): Observable<Vote[]> =>
|
||||
!accountIds || !accountIds.length
|
||||
? of([] as Vote[])
|
||||
: api.query.democracy.voteOf.multi<Vote>(
|
||||
accountIds.map((accountId): [BN | number, AccountId] =>
|
||||
[referendumId, accountId]
|
||||
)
|
||||
).pipe(drr());
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId, ApprovalFlag, SetIndex } from '@polkadot/types/interfaces';
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Vec } from '@polkadot/types';
|
||||
import { switchMap, map } from 'rxjs/operators';
|
||||
import { approvalFlagsToBools } from '../util/approvalFlagsToBools';
|
||||
import { drr } from '../util';
|
||||
|
||||
/**
|
||||
* @name approvalsOf
|
||||
* @returns A nested array of boolean approvals for the given account in each voter set index, converted from its ApprovalFlag(s).
|
||||
* @example
|
||||
* <BR>
|
||||
*
|
||||
* ```javascript
|
||||
* api.derive.elections.approvalsOf(ALICE, (approvals) => {
|
||||
* // approvals === [[false], [true, false], ...]
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function approvalsOf (api: ApiInterfaceRx): (who: AccountId) => Observable<boolean[][]> {
|
||||
return (who: AccountId | string): Observable<boolean[][]> =>
|
||||
api.query.elections.nextVoterSet<SetIndex>().pipe(
|
||||
switchMap((nextVoterSet: SetIndex): Observable<Vec<ApprovalFlag>[]> =>
|
||||
api.query.elections.approvalsOf.multi(
|
||||
[...Array(nextVoterSet.toNumber() + 1).keys()].map((i): [string, number] => [
|
||||
who.toString(), i]
|
||||
)
|
||||
) as any as Observable<Vec<ApprovalFlag>[]>
|
||||
),
|
||||
map((votes: Vec<ApprovalFlag>[]): boolean[][] =>
|
||||
votes.map((flags: Vec<ApprovalFlag>): boolean[] =>
|
||||
approvalFlagsToBools(flags)
|
||||
)
|
||||
),
|
||||
drr()
|
||||
);
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId, ApprovalFlag, SetIndex } from '@polkadot/types/interfaces';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Vec } from '@polkadot/types';
|
||||
|
||||
import { approvalFlagsToBools } from '../util/approvalFlagsToBools';
|
||||
import { drr } from '../util';
|
||||
|
||||
/**
|
||||
* @name approvalsOfAt
|
||||
* @returns An array of boolean approvals for the account and set index, converted from the returned ApprovalFlag.
|
||||
* @example
|
||||
* <BR>
|
||||
*
|
||||
* ```javascript
|
||||
* api.derive.elections.approvalsOfAt(ALICE, new BN(0), (approvals) => {
|
||||
* // approvals === [false, true, ...]
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function approvalsOfAt (api: ApiInterfaceRx): (who: AccountId, at: SetIndex) => Observable<boolean[]> {
|
||||
return (who: AccountId | string, at: SetIndex | BN | number): Observable<boolean[]> =>
|
||||
api.query.elections.approvalsOf<Vec<ApprovalFlag>>([who.toString(), at]).pipe(
|
||||
map((flags: Vec<ApprovalFlag>): boolean[] => approvalFlagsToBools(flags)),
|
||||
drr()
|
||||
);
|
||||
}
|
||||
@@ -1,9 +1,5 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export * from './approvalsOf';
|
||||
export * from './approvalsOfAt';
|
||||
export * from './info';
|
||||
export * from './voters';
|
||||
export * from './voterPositions';
|
||||
|
||||
@@ -1,81 +1,43 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId, Balance, BlockNumber, SetIndex, VoteIndex } from '@polkadot/types/interfaces';
|
||||
import { Codec } from '@polkadot/types/types';
|
||||
import { AccountId, Balance, BlockNumber } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
|
||||
import { Observable, combineLatest } from 'rxjs';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { createType, Vec, u32 } from '@polkadot/types';
|
||||
|
||||
import { DerivedElectionsInfo } from '../types';
|
||||
import { drr } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
type ResultElectionsInner = [u32, u32, Vec<[AccountId, BlockNumber] & Codec>, SetIndex, BlockNumber, VoteIndex, SetIndex];
|
||||
type ResultElections = [Vec<AccountId>, ResultElectionsInner];
|
||||
|
||||
function deriveElections ([candidates, [candidateCount, desiredSeats, members, nextVoterSet, termDuration, voteCount, voterCount]]: ResultElections): DerivedElectionsInfo {
|
||||
return {
|
||||
candidates,
|
||||
candidateCount,
|
||||
desiredSeats,
|
||||
nextVoterSet,
|
||||
members: members.map(([accountId]): [AccountId, Balance] => [accountId, createType('Balance')]),
|
||||
runnersUp: [],
|
||||
termDuration,
|
||||
voteCount,
|
||||
voterCount
|
||||
};
|
||||
function sortAccounts ([, balanceA]: ITuple<[AccountId, Balance]>, [, balanceB]: ITuple<[AccountId, Balance]>): number {
|
||||
return balanceB.cmp(balanceA);
|
||||
}
|
||||
|
||||
function queryElections (api: ApiInterfaceRx): Observable<DerivedElectionsInfo> {
|
||||
// NOTE We have an issue where candidates can return `null` for an empty array
|
||||
return combineLatest([
|
||||
api.query.elections.candidates<Vec<AccountId>>(),
|
||||
api.queryMulti<ResultElectionsInner>([
|
||||
api.query.elections.candidateCount,
|
||||
api.query.elections.desiredSeats,
|
||||
api.query.elections.members,
|
||||
api.query.elections.nextVoterSet,
|
||||
api.query.elections.termDuration,
|
||||
api.query.elections.voteCount,
|
||||
api.query.elections.voterCount
|
||||
])
|
||||
]).pipe(map(deriveElections));
|
||||
}
|
||||
const section = api.query.electionsPhragmen ? 'electionsPhragmen' : 'elections';
|
||||
|
||||
function derivePhragmen (candidates: AccountId[], members: [AccountId, Balance][], runnersUp: [AccountId, Balance][], candidacyBond: Balance, desiredSeats: u32, termDuration: BlockNumber, votingBond: Balance): DerivedElectionsInfo {
|
||||
return {
|
||||
candidates,
|
||||
candidateCount: createType('u32', candidates.length),
|
||||
candidacyBond,
|
||||
desiredSeats,
|
||||
members,
|
||||
runnersUp,
|
||||
termDuration,
|
||||
votingBond
|
||||
};
|
||||
}
|
||||
|
||||
function queryPhragmen (api: ApiInterfaceRx): Observable<DerivedElectionsInfo> {
|
||||
// NOTE We have an issue where candidates can return `null` for an empty array, hence
|
||||
// we are not using multi queries here, so empty array is empty (instead of space-filled)
|
||||
return combineLatest([
|
||||
api.query.electionsPhragmen.candidates<Vec<AccountId>>(),
|
||||
api.query.electionsPhragmen.members<Vec<[AccountId, Balance] & Codec>>(),
|
||||
api.query.electionsPhragmen.runnersUp<Vec<[AccountId, Balance] & Codec>>()
|
||||
return api.queryMulti<[Vec<AccountId>, Vec<AccountId>, Vec<ITuple<[AccountId, Balance]>>, Vec<ITuple<[AccountId, Balance]>>]>([
|
||||
api.query.council.members,
|
||||
api.query[section].candidates,
|
||||
api.query[section].members,
|
||||
api.query[section].runnersUp
|
||||
]).pipe(
|
||||
map(([candidates, members, runnersUp]): DerivedElectionsInfo => derivePhragmen(
|
||||
map(([councilMembers, candidates, members, runnersUp]): DerivedElectionsInfo => ({
|
||||
candidates,
|
||||
members,
|
||||
runnersUp,
|
||||
api.consts.electionsPhragmen.candidacyBond as Balance,
|
||||
api.consts.electionsPhragmen.desiredMembers as u32,
|
||||
api.consts.electionsPhragmen.termDuration as BlockNumber,
|
||||
api.consts.electionsPhragmen.votingBond as Balance
|
||||
))
|
||||
candidateCount: createType(api.registry, 'u32', candidates.length),
|
||||
candidacyBond: api.consts[section].candidacyBond as Balance,
|
||||
desiredSeats: api.consts[section].desiredMembers as u32,
|
||||
members: members.length
|
||||
? members.sort(sortAccounts)
|
||||
: councilMembers.map((accountId): [AccountId, Balance] => [accountId, createType(api.registry, 'Balance')]),
|
||||
runnersUp: runnersUp.sort(sortAccounts),
|
||||
termDuration: api.consts[section].termDuration as BlockNumber,
|
||||
votingBond: api.consts[section].votingBond as Balance
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -93,10 +55,5 @@ function queryPhragmen (api: ApiInterfaceRx): Observable<DerivedElectionsInfo> {
|
||||
* ```
|
||||
*/
|
||||
export function info (api: ApiInterfaceRx): () => Observable<DerivedElectionsInfo> {
|
||||
const query = api.query.electionsPhragmen
|
||||
? queryPhragmen
|
||||
: queryElections;
|
||||
|
||||
return (): Observable<DerivedElectionsInfo> =>
|
||||
query(api).pipe(drr());
|
||||
return memo((): Observable<DerivedElectionsInfo> => queryElections(api));
|
||||
}
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId, SetIndex } from '@polkadot/types/interfaces';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Vec, Option, createType } from '@polkadot/types';
|
||||
import { DerivedVoterPositions } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { of, combineLatest, Observable } from 'rxjs';
|
||||
import { switchMap, map } from 'rxjs/operators';
|
||||
|
||||
import { drr } from '../util';
|
||||
|
||||
/**
|
||||
* @name voterPositions
|
||||
* @returns An mapping of all current voter accounts to their voter set and global index.
|
||||
* @example
|
||||
* <BR>
|
||||
*
|
||||
* ```javascript
|
||||
* api.derive.elections.voterPositions((voters) => {
|
||||
* const { index, setIndex, globalIndex } = voters[ALICE];
|
||||
* console.log(`ALICE is a voter at index ${index} in voter set ${setIndex}, with global index ${globalIndex}.`);
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function voterPositions (api: ApiInterfaceRx): () => Observable<DerivedVoterPositions> {
|
||||
return (): Observable<DerivedVoterPositions> =>
|
||||
api.query.elections.nextVoterSet<SetIndex>().pipe(
|
||||
switchMap((nextVoterSet: SetIndex): Observable<[BN, Vec<Option<AccountId>>[]]> => combineLatest(
|
||||
of(api.consts.elections.voterSetSize) as any as Observable<BN>,
|
||||
api.query.elections.voters.multi([...Array(+nextVoterSet + 1).keys()].map((_, i): [number] => [i])) as any as Observable<Vec<Option<AccountId>>[]>
|
||||
)),
|
||||
map((result: [BN, Vec<Option<AccountId>>[]]): DerivedVoterPositions => {
|
||||
const [setSize, voters] = result;
|
||||
|
||||
return voters.reduce((result: DerivedVoterPositions, vec, setIndex): DerivedVoterPositions => {
|
||||
vec.forEach((e, index): void => {
|
||||
// re-create the index based on position 0 is [0][0] and likewise
|
||||
// 64 (0..63 in first) is [1][0] (the first index value in set 2)
|
||||
const accountId: AccountId | null = e.unwrapOr(null);
|
||||
|
||||
if (accountId) {
|
||||
result[accountId.toString()] = {
|
||||
globalIndex: setSize.muln(setIndex).addn(index),
|
||||
index: new BN(index),
|
||||
setIndex: createType('SetIndex', setIndex)
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}, {});
|
||||
}),
|
||||
drr()
|
||||
);
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { AccountId } from '@polkadot/types/interfaces';
|
||||
import { DerivedVoterPositions } from '../types';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { createType, Vec } from '@polkadot/types';
|
||||
|
||||
import { drr } from '../util';
|
||||
|
||||
/**
|
||||
* @name voters
|
||||
* @returns An array of all current voters from all sets.
|
||||
* @example
|
||||
* <BR>
|
||||
*
|
||||
* ```javascript
|
||||
* api.derive.elections.voters((voters) => {
|
||||
* console.log(`There are ${voters.length} current voters.`);
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function voters (api: ApiInterfaceRx): () => Observable<Vec<AccountId>> {
|
||||
return (): Observable<Vec<AccountId>> =>
|
||||
api.derive.elections.voterPositions().pipe(
|
||||
map((voterPositions: DerivedVoterPositions): Vec<AccountId> =>
|
||||
createType(
|
||||
'Vec<AccountId>',
|
||||
Object.entries(voterPositions)
|
||||
.sort((a, b): number => a[1].globalIndex.cmp(b[1].globalIndex))
|
||||
.map(([accountId]): AccountId => createType('AccountId', accountId))
|
||||
)
|
||||
),
|
||||
drr()
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -10,20 +10,22 @@ import { map, switchMap } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Bytes, Option, u32 } from '@polkadot/types';
|
||||
|
||||
import { drr } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
/**
|
||||
* @description Return a boolean array indicating whether the passed accounts had received heartbeats in the current session
|
||||
*/
|
||||
export function receivedHeartbeats (api: ApiInterfaceRx): () => Observable<DerivedHeartbeats> {
|
||||
return (): Observable<DerivedHeartbeats> =>
|
||||
api.query.imOnline?.receivedHeartbeats && api.query.imOnline.authoredBlocks
|
||||
return memo((): Observable<DerivedHeartbeats> =>
|
||||
api.query.imOnline?.receivedHeartbeats
|
||||
? api.derive.staking.overview().pipe(
|
||||
switchMap(({ currentIndex, validators }): Observable<[AccountId[], Option<Bytes>[], u32[]]> =>
|
||||
combineLatest([
|
||||
of(validators),
|
||||
api.query.imOnline.receivedHeartbeats.multi<Option<Bytes>>(validators.map((_address, index): [SessionIndex, number] => [currentIndex, index])),
|
||||
api.query.imOnline.authoredBlocks.multi<u32>(validators.map((address): [SessionIndex, AccountId] => [currentIndex, address]))
|
||||
api.query.imOnline.receivedHeartbeats.multi<Option<Bytes>>(
|
||||
validators.map((_address, index): [SessionIndex, number] => [currentIndex, index])),
|
||||
api.query.imOnline.authoredBlocks.multi<u32>(
|
||||
validators.map((address): [SessionIndex, AccountId] => [currentIndex, address]))
|
||||
])
|
||||
),
|
||||
map(([validators, heartbeats, numBlocks]): DerivedHeartbeats =>
|
||||
@@ -35,8 +37,7 @@ export function receivedHeartbeats (api: ApiInterfaceRx): () => Observable<Deriv
|
||||
isOnline: !heartbeats[index].isEmpty || numBlocks[index].gtn(0)
|
||||
}
|
||||
}), {})
|
||||
),
|
||||
drr()
|
||||
)
|
||||
)
|
||||
: of({});
|
||||
: of({}));
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Observable, from } from 'rxjs';
|
||||
import ApiRx from '@polkadot/api/rx/Api';
|
||||
import MockProvider from '@polkadot/rpc-provider/mock';
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import { ExactDerive } from '.';
|
||||
|
||||
@@ -26,8 +27,10 @@ const testFunction = (api: ApiRx): any => {
|
||||
};
|
||||
|
||||
describe('derive', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
describe('builtin', (): void => {
|
||||
const api = new ApiRx({ provider: new MockProvider() });
|
||||
const api = new ApiRx({ provider: new MockProvider(registry), registry });
|
||||
|
||||
beforeAll((done): void => {
|
||||
api.isReady.subscribe((): void => done());
|
||||
@@ -42,7 +45,6 @@ describe('derive', (): void => {
|
||||
testFunction(api)('balances', 'fees', []);
|
||||
testFunction(api)('balances', 'votingBalance', []);
|
||||
testFunction(api)('balances', 'votingBalances', []);
|
||||
testFunction(api)('balances', 'votingBalancesNominatorsFor', []);
|
||||
|
||||
testFunction(api)('chain', 'bestNumber', []);
|
||||
testFunction(api)('chain', 'bestNumberFinalized', []);
|
||||
@@ -52,18 +54,13 @@ describe('derive', (): void => {
|
||||
testFunction(api)('democracy', 'referendumVotesFor', []);
|
||||
testFunction(api)('democracy', 'votes', []);
|
||||
|
||||
testFunction(api)('elections', 'approvalsOf', []);
|
||||
// FIXME This one has an additional check which mock doesnt (yet) cater for
|
||||
// testFunction(api)('elections', 'approvalsOfAt', []);
|
||||
testFunction(api)('elections', 'info', []);
|
||||
testFunction(api)('elections', 'voters', []);
|
||||
|
||||
testFunction(api)('session', 'eraLength', []);
|
||||
testFunction(api)('session', 'eraProgress', []);
|
||||
testFunction(api)('session', 'sessionProgress', []);
|
||||
|
||||
testFunction(api)('staking', 'info', []);
|
||||
testFunction(api)('staking', 'recentlyOffline', []);
|
||||
testFunction(api)('staking', 'account', []);
|
||||
testFunction(api)('staking', 'controllers', []);
|
||||
});
|
||||
|
||||
@@ -77,7 +74,8 @@ describe('derive', (): void => {
|
||||
test: (): any => (): Observable<any> => from([1, 2, 3])
|
||||
}
|
||||
},
|
||||
provider: new MockProvider()
|
||||
provider: new MockProvider(registry),
|
||||
registry
|
||||
});
|
||||
|
||||
beforeAll((done): void => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -11,14 +11,20 @@ import * as accounts from './accounts';
|
||||
import * as balances from './balances';
|
||||
import * as chain from './chain';
|
||||
import * as contracts from './contracts';
|
||||
import * as council from './council';
|
||||
import * as democracy from './democracy';
|
||||
import * as elections from './elections';
|
||||
import * as imOnline from './imOnline';
|
||||
import * as session from './session';
|
||||
import * as society from './society';
|
||||
import * as staking from './staking';
|
||||
import * as technicalCommittee from './technicalCommittee';
|
||||
import * as treasury from './treasury';
|
||||
|
||||
export * from './type';
|
||||
|
||||
export const derive = { accounts, balances, chain, contracts, council, democracy, elections, imOnline, session, society, staking, technicalCommittee, treasury };
|
||||
|
||||
type DeriveSection<Section> = {
|
||||
[Method in keyof Section]: Section[Method] extends AnyFunction
|
||||
? ReturnType<Section[Method]> // ReturnType<Section[Method]> will be the inner function, i.e. without (api) argument
|
||||
@@ -30,13 +36,35 @@ type DeriveAllSections<AllSections> = {
|
||||
|
||||
export type DeriveCustom = Record<string, Record<string, (api: ApiInterfaceRx) => (...args: any[]) => Observable<any>>>;
|
||||
|
||||
export type ExactDerive = DeriveAllSections<typeof derive>;
|
||||
|
||||
// Enable derive only if some of these modules are available
|
||||
const deriveAvail: Record<string, string[]> = {
|
||||
contracts: ['contracts'],
|
||||
council: ['council'],
|
||||
democracy: ['democracy'],
|
||||
elections: ['electionsPhragmen', 'elections'],
|
||||
imOnline: ['imOnline'],
|
||||
session: ['session'],
|
||||
society: ['society'],
|
||||
staking: ['staking'],
|
||||
technicalCommittee: ['technicalCommittee'],
|
||||
treasury: ['treasury']
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an object that will inject `api` into all the functions inside
|
||||
* `allSections`, and keep the object architecture of `allSections`.
|
||||
*/
|
||||
/** @internal */
|
||||
function injectFunctions<AllSections> (api: ApiInterfaceRx, allSections: AllSections): DeriveAllSections<AllSections> {
|
||||
const queryKeys = Object.keys(api.query);
|
||||
|
||||
return Object
|
||||
.keys(allSections)
|
||||
.filter((sectionName): boolean =>
|
||||
!deriveAvail[sectionName] || deriveAvail[sectionName].some((query): boolean => queryKeys.includes(query))
|
||||
)
|
||||
.reduce((deriveAcc, sectionName): DeriveAllSections<AllSections> => {
|
||||
const section = allSections[sectionName as keyof AllSections];
|
||||
|
||||
@@ -56,11 +84,9 @@ function injectFunctions<AllSections> (api: ApiInterfaceRx, allSections: AllSect
|
||||
}, {} as DeriveAllSections<AllSections>);
|
||||
}
|
||||
|
||||
export const derive = { accounts, balances, chain, contracts, democracy, elections, imOnline, session, staking };
|
||||
export type ExactDerive = DeriveAllSections<typeof derive>;
|
||||
|
||||
// FIXME The return type of this function should be {...ExactDerive, ...DeriveCustom}
|
||||
// For now we just drop the custom derive typings
|
||||
/** @internal */
|
||||
export default function decorateDerive (api: ApiInterfaceRx, custom: DeriveCustom = {}): ExactDerive {
|
||||
return {
|
||||
...injectFunctions(api, derive),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -9,12 +9,11 @@ import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
|
||||
import { drr } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function eraLength (api: ApiInterfaceRx): () => Observable<BlockNumber> {
|
||||
return (): Observable<BlockNumber> =>
|
||||
return memo((): Observable<BlockNumber> =>
|
||||
api.derive.session.info().pipe(
|
||||
map(({ eraLength }: DerivedSessionInfo): BlockNumber => eraLength),
|
||||
drr()
|
||||
);
|
||||
map(({ eraLength }: DerivedSessionInfo): BlockNumber => eraLength)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -9,12 +9,11 @@ import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
|
||||
import { drr } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function eraProgress (api: ApiInterfaceRx): () => Observable<BlockNumber> {
|
||||
return (): Observable<BlockNumber> =>
|
||||
return memo((): Observable<BlockNumber> =>
|
||||
api.derive.session.info().pipe(
|
||||
map(({ eraProgress }: DerivedSessionInfo): BlockNumber => eraProgress),
|
||||
drr()
|
||||
);
|
||||
map(({ eraProgress }: DerivedSessionInfo): BlockNumber => eraProgress)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -6,22 +6,26 @@ import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { EraIndex, SessionIndex } from '@polkadot/types/interfaces';
|
||||
import { DeriveSessionIndexes } from '../types';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { u32 } from '@polkadot/types';
|
||||
import { createType, u32 as U32 } from '@polkadot/types';
|
||||
|
||||
import { drr } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function indexes (api: ApiInterfaceRx): () => Observable<DeriveSessionIndexes> {
|
||||
return (): Observable<DeriveSessionIndexes> =>
|
||||
api.queryMulti<[SessionIndex, EraIndex, u32]>([
|
||||
api.query.session.currentIndex,
|
||||
api.query.staking.currentEra,
|
||||
api.query.staking.validatorCount
|
||||
]).pipe(
|
||||
return memo((): Observable<DeriveSessionIndexes> =>
|
||||
(
|
||||
// Some chains (eg. very limited node-template), does not have session
|
||||
api.query.session && api.query.staking
|
||||
? api.queryMulti<[SessionIndex, EraIndex, U32]>([
|
||||
api.query.session.currentIndex,
|
||||
api.query.staking.currentEra,
|
||||
api.query.staking.validatorCount
|
||||
])
|
||||
: of([createType(api.registry, 'SessionIndex', 1), createType(api.registry, 'EraIndex', 1), createType(api.registry, 'u32')])
|
||||
).pipe(
|
||||
map(([currentIndex, currentEra, validatorCount]): DeriveSessionIndexes => ({
|
||||
currentIndex, currentEra, validatorCount
|
||||
})),
|
||||
drr()
|
||||
);
|
||||
}))
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1,97 +1,46 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { BlockNumber, SessionIndex } from '@polkadot/types/interfaces';
|
||||
import { SessionIndex } from '@polkadot/types/interfaces';
|
||||
import { DerivedSessionInfo, DeriveSessionIndexes } from '../types';
|
||||
|
||||
import { Observable, combineLatest } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Option, u64, createType } from '@polkadot/types';
|
||||
import { u64, createType } from '@polkadot/types';
|
||||
|
||||
import { drr } from '../util';
|
||||
|
||||
type ResultV1Session = [Option<BlockNumber>, BlockNumber, BlockNumber, SessionIndex];
|
||||
type ResultV1 = [BlockNumber, DeriveSessionIndexes, ResultV1Session];
|
||||
import { memo } from '../util';
|
||||
|
||||
type ResultSlots = [u64, u64, u64, SessionIndex];
|
||||
type ResultType = [boolean, u64, SessionIndex];
|
||||
type Result = [ResultType, DeriveSessionIndexes, ResultSlots];
|
||||
|
||||
// internal helper to just split the logic - take all inputs, do the calculations and combine
|
||||
function createDerivedV1 ([bestNumber, { currentIndex, validatorCount }, [_lastLengthChange, sessionLength, lastEraLengthChange, sessionsPerEra]]: ResultV1): DerivedSessionInfo {
|
||||
const lastLengthChange = _lastLengthChange?.unwrapOr(null) || createType('BlockNumber');
|
||||
const sessionProgress = bestNumber
|
||||
.sub(lastLengthChange)
|
||||
.add(sessionLength)
|
||||
.mod(sessionLength);
|
||||
const currentEra = currentIndex
|
||||
.sub(lastEraLengthChange)
|
||||
.mod(sessionsPerEra);
|
||||
const eraProgress = currentEra
|
||||
.mul(sessionLength)
|
||||
.add(sessionProgress);
|
||||
|
||||
return {
|
||||
currentEra: createType('EraIndex', currentEra),
|
||||
currentIndex,
|
||||
eraLength: createType('BlockNumber', sessionLength.mul(sessionsPerEra)),
|
||||
eraProgress: createType('BlockNumber', eraProgress),
|
||||
isEpoch: false,
|
||||
lastEraLengthChange,
|
||||
lastLengthChange,
|
||||
sessionLength,
|
||||
sessionsPerEra,
|
||||
sessionProgress: createType('BlockNumber', sessionProgress),
|
||||
validatorCount
|
||||
};
|
||||
}
|
||||
|
||||
function createDerivedLatest ([[hasBabe, epochDuration, sessionsPerEra], { currentIndex, currentEra, validatorCount }, [currentSlot, epochIndex, epochOrGenesisStartSlot, currentEraStartSessionIndex]]: Result): DerivedSessionInfo {
|
||||
function createDerivedLatest (api: ApiInterfaceRx, [[hasBabe, epochDuration, sessionsPerEra], { currentIndex, currentEra, validatorCount }, [currentSlot, epochIndex, epochOrGenesisStartSlot, currentEraStartSessionIndex]]: Result): DerivedSessionInfo {
|
||||
const epochStartSlot = epochIndex.mul(epochDuration).add(epochOrGenesisStartSlot);
|
||||
const sessionProgress = currentSlot.sub(epochStartSlot);
|
||||
const eraProgress = currentIndex.sub(currentEraStartSessionIndex).add(sessionProgress);
|
||||
|
||||
// console.log(sessionProgress);
|
||||
const eraProgress = currentIndex.sub(currentEraStartSessionIndex).mul(epochDuration).add(sessionProgress);
|
||||
|
||||
return {
|
||||
currentEra,
|
||||
currentIndex,
|
||||
eraLength: createType('BlockNumber', sessionsPerEra.mul(epochDuration)),
|
||||
eraProgress: createType('BlockNumber', eraProgress),
|
||||
eraLength: createType(api.registry, 'BlockNumber', sessionsPerEra.mul(epochDuration)),
|
||||
eraProgress: createType(api.registry, 'BlockNumber', eraProgress),
|
||||
isEpoch: hasBabe,
|
||||
lastEraLengthChange: createType('BlockNumber'),
|
||||
lastLengthChange: createType('BlockNumber', epochStartSlot),
|
||||
sessionLength: epochDuration,
|
||||
sessionsPerEra,
|
||||
sessionProgress: createType('BlockNumber', sessionProgress),
|
||||
sessionProgress: createType(api.registry, 'BlockNumber', sessionProgress),
|
||||
validatorCount
|
||||
};
|
||||
}
|
||||
|
||||
function infoV1 (api: ApiInterfaceRx): Observable<DerivedSessionInfo> {
|
||||
return combineLatest([
|
||||
api.derive.chain.bestNumber(),
|
||||
api.derive.session.indexes(),
|
||||
api.queryMulti<ResultV1Session>([
|
||||
api.query.session.lastLengthChange,
|
||||
api.query.session.sessionLength,
|
||||
api.query.staking.lastEraLengthChange,
|
||||
api.query.staking.sessionsPerEra
|
||||
])
|
||||
]).pipe(
|
||||
map(createDerivedV1)
|
||||
);
|
||||
}
|
||||
|
||||
function infoLatestAura (api: ApiInterfaceRx): Observable<DerivedSessionInfo> {
|
||||
return api.derive.session.indexes().pipe(
|
||||
map((indexes): DerivedSessionInfo =>
|
||||
createDerivedLatest([
|
||||
[false, createType('u64', 1), api.consts.staking.sessionsPerEra as SessionIndex],
|
||||
createDerivedLatest(api, [
|
||||
[false, createType(api.registry, 'u64', 1), api.consts.staking?.sessionsPerEra || createType(api.registry, 'SessionIndex', 1)],
|
||||
indexes,
|
||||
[createType('u64', 1), createType('u64', 1), createType('u64', 1), createType('SessionIndex', 1)]
|
||||
[createType(api.registry, 'u64', 1), createType(api.registry, 'u64', 1), createType(api.registry, 'u64', 1), createType(api.registry, 'SessionIndex', 1)]
|
||||
])
|
||||
)
|
||||
);
|
||||
@@ -108,8 +57,8 @@ function infoLatestBabe (api: ApiInterfaceRx): Observable<DerivedSessionInfo> {
|
||||
])
|
||||
]).pipe(
|
||||
map(([indexes, slots]: [DeriveSessionIndexes, ResultSlots]): DerivedSessionInfo =>
|
||||
createDerivedLatest([
|
||||
[true, api.consts.babe.epochDuration as u64, api.consts.staking.sessionsPerEra as SessionIndex],
|
||||
createDerivedLatest(api, [
|
||||
[true, api.consts.babe.epochDuration, api.consts.staking.sessionsPerEra],
|
||||
indexes,
|
||||
slots
|
||||
])
|
||||
@@ -121,12 +70,10 @@ function infoLatestBabe (api: ApiInterfaceRx): Observable<DerivedSessionInfo> {
|
||||
* @description Retrieves all the session and era info and calculates specific values on it as the length of the session and eras
|
||||
*/
|
||||
export function info (api: ApiInterfaceRx): () => Observable<DerivedSessionInfo> {
|
||||
const query = api.consts.staking
|
||||
? api.consts.babe
|
||||
? infoLatestBabe // 2.x with Babe
|
||||
: infoLatestAura // 2.x with Aura (not all info there)
|
||||
: infoV1;
|
||||
const query = api.consts.babe
|
||||
? infoLatestBabe // 2.x with Babe
|
||||
: infoLatestAura; // 2.x with Aura (not all info there)
|
||||
|
||||
return (): Observable<DerivedSessionInfo> =>
|
||||
query(api).pipe(drr());
|
||||
return memo((): Observable<DerivedSessionInfo> =>
|
||||
query(api));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -9,12 +9,11 @@ import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
|
||||
import { drr } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function sessionProgress (api: ApiInterfaceRx): () => Observable<BlockNumber> {
|
||||
return (): Observable<BlockNumber> =>
|
||||
return memo((): Observable<BlockNumber> =>
|
||||
api.derive.session.info().pipe(
|
||||
map(({ sessionProgress }: DerivedSessionInfo): BlockNumber => sessionProgress),
|
||||
drr()
|
||||
);
|
||||
map(({ sessionProgress }: DerivedSessionInfo): BlockNumber => sessionProgress)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { AccountId, BalanceOf, Bid, BidKind } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { DeriveSocietyCandidate } from '../types';
|
||||
|
||||
import { combineLatest, of, Observable } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { Option, Vec } from '@polkadot/types';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type ResultSuspend = Option<ITuple<[BalanceOf, BidKind]>>;
|
||||
type Result = [Bid[], ResultSuspend[]]
|
||||
|
||||
/**
|
||||
* @description Get the candidate info for a society
|
||||
*/
|
||||
export function candidates (api: ApiInterfaceRx): () => Observable<DeriveSocietyCandidate[]> {
|
||||
return memo((): Observable<DeriveSocietyCandidate[]> =>
|
||||
api.query.society.candidates<Vec<Bid>>().pipe(
|
||||
switchMap((candidates: Vec<Bid>): Observable<Result> =>
|
||||
combineLatest([
|
||||
of(candidates),
|
||||
api.query.society.suspendedCandidates.multi<ResultSuspend>(
|
||||
candidates.map(({ who }): AccountId => who))
|
||||
])
|
||||
),
|
||||
map(([candidates, suspended]: Result): DeriveSocietyCandidate[] =>
|
||||
candidates.map(({ who, kind, value }, index) => ({
|
||||
accountId: who,
|
||||
isSuspended: suspended[index].isSome,
|
||||
kind,
|
||||
value
|
||||
}))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export * from './candidates';
|
||||
export * from './info';
|
||||
export * from './member';
|
||||
export * from './members';
|
||||
@@ -0,0 +1,41 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { AccountId, BalanceOf, Bid } from '@polkadot/types/interfaces';
|
||||
import { DeriveSociety } from '../types';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Option, Vec, u32 } from '@polkadot/types';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type Result = [Vec<Bid>, Option<AccountId>, Option<AccountId>, Option<AccountId>, u32, BalanceOf]
|
||||
|
||||
/**
|
||||
* @description Get the overall info for a society
|
||||
*/
|
||||
export function info (api: ApiInterfaceRx): () => Observable<DeriveSociety> {
|
||||
return memo((): Observable<DeriveSociety> =>
|
||||
api.queryMulti<Result>([
|
||||
api.query.society.bids,
|
||||
api.query.society.defender,
|
||||
api.query.society.founder,
|
||||
api.query.society.head,
|
||||
api.query.society.maxMembers,
|
||||
api.query.society.pot
|
||||
]).pipe(
|
||||
map(([bids, defender, founder, head, maxMembers, pot]: Result): DeriveSociety => ({
|
||||
bids,
|
||||
defender: defender.unwrapOr(undefined),
|
||||
hasDefender: (defender.isSome && head.isSome && !head.eq(defender)) || false,
|
||||
head: head.unwrapOr(undefined),
|
||||
founder: founder.unwrapOr(undefined),
|
||||
maxMembers,
|
||||
pot
|
||||
}))
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { AccountId, Balance, BlockNumber, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { DeriveSocietyMember } from '../types';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { bool, Option, Vec } from '@polkadot/types';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type Result = [Vec<ITuple<[BlockNumber, Balance]>>, StrikeCount, Option<SocietyVote>, bool, Option<VouchingStatus>];
|
||||
|
||||
/**
|
||||
* @description Get the member info for a society
|
||||
*/
|
||||
export function member (api: ApiInterfaceRx): (accountId: AccountId) => Observable<DeriveSocietyMember> {
|
||||
return memo((accountId: AccountId): Observable<DeriveSocietyMember> =>
|
||||
api.queryMulti<Result>([
|
||||
[api.query.society.payouts, accountId],
|
||||
[api.query.society.strikes, accountId],
|
||||
[api.query.society.defenderVotes, accountId],
|
||||
[api.query.society.suspendedMembers, accountId],
|
||||
[api.query.society.vouching, accountId]
|
||||
]).pipe(
|
||||
map(([payouts, strikes, defenderVote, suspended, vouching]: Result): DeriveSocietyMember => ({
|
||||
accountId,
|
||||
payouts,
|
||||
isSuspended: suspended.isTrue,
|
||||
strikes,
|
||||
vote: defenderVote.unwrapOr(undefined),
|
||||
vouching: vouching.unwrapOr(undefined)
|
||||
}))
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { AccountId } from '@polkadot/types/interfaces';
|
||||
import { DeriveSocietyMember } from '../types';
|
||||
|
||||
import { combineLatest, Observable } from 'rxjs';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
/**
|
||||
* @description Get the member info for a society
|
||||
*/
|
||||
export function members (api: ApiInterfaceRx): () => Observable<DeriveSocietyMember[]> {
|
||||
return memo((): Observable<DeriveSocietyMember[]> =>
|
||||
api.query.society.members<AccountId[]>().pipe(
|
||||
switchMap((members): Observable<DeriveSocietyMember[]> =>
|
||||
combineLatest(members.map((accountId): Observable<DeriveSocietyMember> =>
|
||||
api.derive.society.member(accountId)
|
||||
))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Balance, BlockNumber, StakingLedger, UnlockChunk } from '@polkadot/types/interfaces';
|
||||
import { DerivedSessionInfo, DerivedStakingAccount, DerivedStakingQuery, DerivedUnlocking } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { combineLatest, Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { createType } from '@polkadot/types';
|
||||
|
||||
import { isUndefined } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
// groups the supplied chunks by era, i.e. { [era]: BN(total of values) }
|
||||
function groupByEra (list: UnlockChunk[]): Record<string, BN> {
|
||||
return list.reduce((map: Record<string, BN>, { era, value }): Record<string, BN> => {
|
||||
const key = era.toString();
|
||||
|
||||
map[key] = !map[key]
|
||||
? value.unwrap()
|
||||
: map[key].add(value.unwrap());
|
||||
|
||||
return map;
|
||||
}, {});
|
||||
}
|
||||
|
||||
// calculate the remaining blocks in a specific unlock era
|
||||
function remainingBlocks (api: ApiInterfaceRx, era: BN, sessionInfo: DerivedSessionInfo): BlockNumber {
|
||||
const remaining = era.sub(sessionInfo.currentEra);
|
||||
|
||||
// on the Rust side the current-era >= era-for-unlock (removal done on >)
|
||||
return createType(api.registry, 'BlockNumber', remaining.gtn(0)
|
||||
? remaining
|
||||
.subn(1)
|
||||
.mul(sessionInfo.eraLength)
|
||||
.add(sessionInfo.eraLength.sub(sessionInfo.eraProgress))
|
||||
: 0
|
||||
);
|
||||
}
|
||||
|
||||
function calculateUnlocking (api: ApiInterfaceRx, stakingLedger: StakingLedger | undefined, sessionInfo: DerivedSessionInfo): DerivedUnlocking[] | undefined {
|
||||
if (isUndefined(stakingLedger)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const unlockingChunks = stakingLedger.unlocking.filter(({ era }): boolean =>
|
||||
remainingBlocks(api, era.unwrap(), sessionInfo).gtn(0)
|
||||
);
|
||||
|
||||
if (!unlockingChunks.length) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// group the unlock chunks that have the same era and sum their values
|
||||
const groupedResult = groupByEra(unlockingChunks);
|
||||
const results = Object.entries(groupedResult).map(([eraString, value]): DerivedUnlocking => ({
|
||||
value: createType(api.registry, 'Balance', value),
|
||||
remainingBlocks: remainingBlocks(api, new BN(eraString), sessionInfo)
|
||||
}));
|
||||
|
||||
return results.length ? results : undefined;
|
||||
}
|
||||
|
||||
function redeemableSum (api: ApiInterfaceRx, stakingLedger: StakingLedger | undefined, sessionInfo: DerivedSessionInfo): Balance {
|
||||
if (isUndefined(stakingLedger)) {
|
||||
return createType(api.registry, 'Balance');
|
||||
}
|
||||
|
||||
return createType(api.registry, 'Balance', stakingLedger.unlocking.reduce((total, { era, value }): BN => {
|
||||
return remainingBlocks(api, era.unwrap(), sessionInfo).eqn(0)
|
||||
? total.add(value.unwrap())
|
||||
: total;
|
||||
}, new BN(0)));
|
||||
}
|
||||
|
||||
function parseResult (api: ApiInterfaceRx, sessionInfo: DerivedSessionInfo, query: DerivedStakingQuery): DerivedStakingAccount {
|
||||
return {
|
||||
...query,
|
||||
redeemable: redeemableSum(api, query.stakingLedger, sessionInfo),
|
||||
unlocking: calculateUnlocking(api, query.stakingLedger, sessionInfo)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @description From a stash, retrieve the controllerId and fill in all the relevant staking details
|
||||
*/
|
||||
export function account (api: ApiInterfaceRx): (accountId: Uint8Array | string) => Observable<DerivedStakingAccount> {
|
||||
return memo((accountId: Uint8Array | string): Observable<DerivedStakingAccount> =>
|
||||
combineLatest([
|
||||
api.derive.session.info(),
|
||||
api.derive.staking.query(accountId)
|
||||
]).pipe(
|
||||
map(([sessionInfo, query]: [DerivedSessionInfo, DerivedStakingQuery]) =>
|
||||
parseResult(api, sessionInfo, query))
|
||||
));
|
||||
}
|
||||
@@ -1,24 +1,26 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { AccountId } from '@polkadot/types/interfaces';
|
||||
import { Codec } from '@polkadot/types/types';
|
||||
import { AccountId, ValidatorPrefs } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
import { Option } from '@polkadot/types';
|
||||
import { Option, Vec } from '@polkadot/types';
|
||||
|
||||
import { drr } from '../util';
|
||||
import { memo } from '../util';
|
||||
|
||||
type DeriveControllers = [AccountId[], Option<AccountId>[]];
|
||||
|
||||
/**
|
||||
* @description From the list of stash accounts, retrieve the list of controllers
|
||||
*/
|
||||
export function controllers (api: ApiInterfaceRx): () => Observable<[AccountId[], Option<AccountId>[]]> {
|
||||
return (): Observable<[AccountId[], Option<AccountId>[]]> =>
|
||||
api.query.staking.validators<[AccountId[]] & Codec>().pipe(
|
||||
switchMap(([stashIds]): Observable<[AccountId[], Option<AccountId>[]]> =>
|
||||
export function controllers (api: ApiInterfaceRx): () => Observable<DeriveControllers> {
|
||||
return memo((): Observable<[AccountId[], Option<AccountId>[]]> =>
|
||||
api.query.staking.validators<ITuple<[Vec<AccountId>, Vec<ValidatorPrefs>]>>().pipe(
|
||||
switchMap(([stashIds]): Observable<DeriveControllers> =>
|
||||
combineLatest([
|
||||
of(stashIds),
|
||||
// for V2, don't return all the controllers, we call bonded at a later point
|
||||
@@ -26,7 +28,6 @@ export function controllers (api: ApiInterfaceRx): () => Observable<[AccountId[]
|
||||
? of([])
|
||||
: api.query.staking.bonded.multi<Option<AccountId>>(stashIds)
|
||||
])
|
||||
),
|
||||
drr()
|
||||
);
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user