Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
981407f00f | ||
|
|
74f7098e0a | ||
|
|
c2e46bf16d | ||
|
|
78b26d2d40 | ||
|
|
e4d5be85f6 | ||
|
|
23b5601eeb | ||
|
|
859679ce09 | ||
|
|
71543c2351 | ||
|
|
edae5057c8 | ||
|
|
8dd450ded4 | ||
|
|
bc2061723e | ||
|
|
5753e37307 | ||
|
|
e74da70a9d | ||
|
|
737bbc225a | ||
|
|
9313551559 | ||
|
|
5b8f53f050 | ||
|
|
7358e4715b | ||
|
|
a9005d86d6 | ||
|
|
788c05d86e | ||
|
|
de6ba69631 | ||
|
|
4153fed250 | ||
|
|
c68b89831e | ||
|
|
01c9c5ed53 | ||
|
|
573fb135a7 | ||
|
|
0ee7256e37 | ||
|
|
9829ee558c | ||
|
|
34b563dd48 | ||
|
|
f6bb200146 | ||
|
|
af36e3a52c | ||
|
|
c50c7ae6ef | ||
|
|
61739d5ba1 | ||
|
|
34c4a6055e | ||
|
|
27dabdaf52 | ||
|
|
2ee3242f41 | ||
|
|
67ae9627af | ||
|
|
29f7e12df6 | ||
|
|
a4bb2c8268 | ||
|
|
6521c5f533 | ||
|
|
6925c18821 | ||
|
|
9269d94677 | ||
|
|
d438814ad6 | ||
|
|
bc205a350b | ||
|
|
6bf6fddd28 | ||
|
|
23f8eb9713 | ||
|
|
8ab3097328 | ||
|
|
644d0e6c2e | ||
|
|
6a69fdfbbf | ||
|
|
16e9a64941 | ||
|
|
f3cbc070ea | ||
|
|
df22526229 | ||
|
|
3739bdaa89 | ||
|
|
1f55f38bd2 | ||
|
|
c9deb0d88f | ||
|
|
eecfb39463 | ||
|
|
51bb27da42 | ||
|
|
9c0d296e87 | ||
|
|
0793e0bf8c | ||
|
|
e9ad88d50e | ||
|
|
fbe24c04b8 | ||
|
|
8a7d4d3be3 | ||
|
|
61c9a3bb93 | ||
|
|
3721a11f34 | ||
|
|
21039dec1f | ||
|
|
1393f565d8 | ||
|
|
1530e55f9d | ||
|
|
c982505f73 | ||
|
|
ec8c0d3e8b | ||
|
|
8cb0269676 | ||
|
|
27f460cfe3 | ||
|
|
e98e8d6a0d | ||
|
|
2f94662837 | ||
|
|
d46d6a9acd | ||
|
|
093d2cfa7c | ||
|
|
35b31a21dc | ||
|
|
8b9741a722 | ||
|
|
d5cfa9b0e9 | ||
|
|
129d1214fe | ||
|
|
abb3375c3a | ||
|
|
4cfa06b43f | ||
|
|
8fa80ac0f6 | ||
|
|
2d011c68df | ||
|
|
640ef4bdab | ||
|
|
cdd20c0b99 | ||
|
|
3a12123bf9 | ||
|
|
5657d5395b | ||
|
|
66b1108c5c | ||
|
|
7bf7e207c2 | ||
|
|
01098395ec | ||
|
|
3e21dfdc03 | ||
|
|
a400fb2362 | ||
|
|
44172aa359 | ||
|
|
82cab2827a | ||
|
|
a198eb1515 | ||
|
|
6e67cd6c97 | ||
|
|
e51e89df56 | ||
|
|
e46fd07d39 | ||
|
|
b2cf9aed83 | ||
|
|
c632030437 | ||
|
|
9dc683d289 | ||
|
|
6cef6190b1 | ||
|
|
75dd443d79 | ||
|
|
13dacb591d | ||
|
|
429bf5456e | ||
|
|
527c0f5015 | ||
|
|
527ab27bee | ||
|
|
7991403022 | ||
|
|
61d2e6c5e5 | ||
|
|
e005a3fc0c | ||
|
|
2dfb0fb59a | ||
|
|
70c011e7e2 | ||
|
|
8134322626 | ||
|
|
60152749bb | ||
|
|
b257e120d4 | ||
|
|
6dc75acd21 | ||
|
|
a04400170c | ||
|
|
e3f16e6066 | ||
|
|
c3b697d52d | ||
|
|
645fb58e82 | ||
|
|
474e509507 | ||
|
|
df9aff3bac | ||
|
|
caface921e | ||
|
|
ba9cc785c1 | ||
|
|
4ff9b51af2 | ||
|
|
2c20a9f395 | ||
|
|
ee17aa7464 | ||
|
|
2d01a7b593 | ||
|
|
000e8089d9 | ||
|
|
43000b6aaf | ||
|
|
0f8b204db8 | ||
|
|
679f4103e1 | ||
|
|
6c61708eff | ||
|
|
f0ce53f5a5 | ||
|
|
d826ac85fa | ||
|
|
18a81fbbcb | ||
|
|
9ab59c9241 | ||
|
|
0161996cf6 | ||
|
|
99463a3f1d | ||
|
|
cec4c69374 | ||
|
|
44077c7cf6 | ||
|
|
ac7b1bdeeb | ||
|
|
1c86333b5f | ||
|
|
da4108ff9b | ||
|
|
0c5fc15935 | ||
|
|
970039775d | ||
|
|
2ddcd59ed0 | ||
|
|
a4519495ad | ||
|
|
a9c9fb5769 | ||
|
|
0e928a2a11 | ||
|
|
756b24f10a | ||
|
|
85a37b2604 | ||
|
|
e0e8d37a64 | ||
|
|
4c4fd2afd1 | ||
|
|
926d1e55d1 | ||
|
|
491e7cd155 | ||
|
|
ed2d6e8d0e | ||
|
|
714f72d6c3 | ||
|
|
8671171061 | ||
|
|
45b176de7d | ||
|
|
1901b8899d | ||
|
|
9ead0103a9 | ||
|
|
af0bcc80e8 | ||
|
|
e0b7dd13e0 | ||
|
|
9e13b6f54e | ||
|
|
6aa5a2dd0c | ||
|
|
361f9e4419 | ||
|
|
1ca00c7633 | ||
|
|
83f36e466f | ||
|
|
e685923102 | ||
|
|
3aaa6db190 | ||
|
|
a98b6b9bf8 | ||
|
|
fc0148fd41 | ||
|
|
1dc04ec8bd | ||
|
|
3c2617fe5c | ||
|
|
9e20006d24 | ||
|
|
dcd5a0b620 | ||
|
|
6f5b852bf7 | ||
|
|
22e4abc903 | ||
|
|
b5e37c020d | ||
|
|
a806e4a2ee | ||
|
|
9164637c44 | ||
|
|
1ba8f71da1 | ||
|
|
91693bf587 | ||
|
|
e6a99b9f07 | ||
|
|
f6d9ba2471 | ||
|
|
af24955bc7 | ||
|
|
3e66807716 | ||
|
|
f34d48ad09 | ||
|
|
0d7be67499 | ||
|
|
7804794233 | ||
|
|
c7a68a4e05 | ||
|
|
811f9f7868 | ||
|
|
d9acf1cfea | ||
|
|
0967dbba6b | ||
|
|
025a745258 | ||
|
|
88eb4fd6e5 | ||
|
|
0dcdffd59c | ||
|
|
1f39ad264a | ||
|
|
e357a08118 | ||
|
|
d6b2b4a1a3 | ||
|
|
47f2ee725f | ||
|
|
1028e14761 | ||
|
|
5fdefa9e58 | ||
|
|
80209da5c5 | ||
|
|
bbdf0e3192 | ||
|
|
9ee1c0bf13 | ||
|
|
5490947384 | ||
|
|
b1788be796 | ||
|
|
f4ec312656 | ||
|
|
e1057603fc | ||
|
|
0268e398c1 | ||
|
|
757d45b39e | ||
|
|
4f57a5a611 | ||
|
|
987896e323 | ||
|
|
1b9d3bf38e | ||
|
|
b8a0f39da4 | ||
|
|
e4e20f8a88 | ||
|
|
131729e438 | ||
|
|
4672439bce | ||
|
|
0b11fc98b9 | ||
|
|
ece0a4b19a | ||
|
|
1dac7e3f1b | ||
|
|
3e1c93d4a8 | ||
|
|
19e9af02d8 | ||
|
|
2200cc2fab | ||
|
|
33990b6d02 | ||
|
|
333313fd6a | ||
|
|
33fd09c053 | ||
|
|
7dadac7344 | ||
|
|
340554a659 | ||
|
|
236ad16406 | ||
|
|
aae4671db5 | ||
|
|
d0f9eb7d03 | ||
|
|
d6106b3253 | ||
|
|
9740c282d8 | ||
|
|
f65b5c77ec | ||
|
|
0f920ee77d | ||
|
|
62d1415d1b | ||
|
|
f8792e09c9 | ||
|
|
8d4b03d066 | ||
|
|
5d3c728cf0 | ||
|
|
04340de6ae | ||
|
|
d709a5b3be | ||
|
|
1d3dfc77a3 | ||
|
|
a72d33ad24 | ||
|
|
e4948ef579 | ||
|
|
f9812585b8 | ||
|
|
e2654dd2f8 | ||
|
|
5f0ea88a42 | ||
|
|
69be690be6 | ||
|
|
67d4637786 | ||
|
|
d2557a3cac | ||
|
|
e2911a33c4 | ||
|
|
9b45901760 | ||
|
|
450f53d563 | ||
|
|
5374c863ad | ||
|
|
ce29ae6e0e | ||
|
|
d420c65c2b | ||
|
|
427ae64fab | ||
|
|
173c40b0e5 | ||
|
|
208fbb24d5 | ||
|
|
9ee563e3f6 | ||
|
|
70acb27218 | ||
|
|
dd29ebbeae | ||
|
|
b01935122f | ||
|
|
71d54821e0 | ||
|
|
5df3e1605a | ||
|
|
50737b7ef7 | ||
|
|
ecc86f797c | ||
|
|
ff020d14e4 | ||
|
|
ff36cb97c2 | ||
|
|
01f2fe7c86 | ||
|
|
948d8cccc1 | ||
|
|
da2e2f89c9 | ||
|
|
6b4fd110a1 | ||
|
|
a48eba101c | ||
|
|
78b9d29fa0 | ||
|
|
92c9ce15d6 | ||
|
|
11c4239614 | ||
|
|
0cb7b34ff0 | ||
|
|
a74382c539 | ||
|
|
beccc2ed9b | ||
|
|
c29f66c7c5 | ||
|
|
dba23e3923 | ||
|
|
f633b3d6c1 | ||
|
|
b1c7409c59 | ||
|
|
a2423b1004 | ||
|
|
c0f1bf7f1e | ||
|
|
8e6a1c8fb1 | ||
|
|
92ee9ab339 | ||
|
|
70f1fa5514 | ||
|
|
37f49b30de | ||
|
|
8b4d3872d7 | ||
|
|
4e2ab3d11c | ||
|
|
b1291bfbe3 | ||
|
|
026ef3c4ed | ||
|
|
158fe79c43 | ||
|
|
c467efdb3b | ||
|
|
b1d0eb9597 | ||
|
|
3b9149d3ac | ||
|
|
a9e8388cc8 | ||
|
|
a33265e5ed | ||
|
|
1d6bfb69ff | ||
|
|
96f32c63fd | ||
|
|
07b69fe635 | ||
|
|
a579f3e09c | ||
|
|
6559b1ad11 | ||
|
|
f7da1d0fb2 | ||
|
|
94e57f6dcf | ||
|
|
1364c45d16 | ||
|
|
54b5b38ba6 | ||
|
|
944f4ddf1d | ||
|
|
895d44fe9f | ||
|
|
eccc6cc2c9 | ||
|
|
a7c2d11a56 | ||
|
|
a71744bd16 | ||
|
|
0e52e8fe23 | ||
|
|
2769336344 | ||
|
|
522906695f | ||
|
|
f7c968b7a6 | ||
|
|
c1b7660122 | ||
|
|
811a2291ed | ||
|
|
90cc148383 | ||
|
|
b652bdc2de | ||
|
|
f6942cc0f0 | ||
|
|
8e852db87c | ||
|
|
75f97bb1ff | ||
|
|
c8d7e971bc | ||
|
|
09aa046ab4 | ||
|
|
25e29d9565 | ||
|
|
c396b963ee | ||
|
|
46be42705b | ||
|
|
d65eb7a27f | ||
|
|
a1a73cbf01 | ||
|
|
72e03138e8 | ||
|
|
b0e7440ca6 | ||
|
|
4847988a94 | ||
|
|
a58be22764 | ||
|
|
f6af257051 | ||
|
|
790e0ebdcf | ||
|
|
1db2cfbedf | ||
|
|
8a75c9bac0 | ||
|
|
ab05224c71 | ||
|
|
986e8fbb20 | ||
|
|
2906b02e41 | ||
|
|
683c37b171 | ||
|
|
20bdc6e63d | ||
|
|
b200b20972 | ||
|
|
7a4fe4fe5f | ||
|
|
aa6ec6c9dc | ||
|
|
0871e074c7 | ||
|
|
aa7d34dca1 | ||
|
|
65b4d5bb43 | ||
|
|
acc1edaddc | ||
|
|
ba9b9c6fa2 | ||
|
|
aa4f593d79 | ||
|
|
dd2dde5701 | ||
|
|
033cba718d | ||
|
|
c4470eba14 | ||
|
|
fb2bc42fe0 | ||
|
|
d3b13bceb0 | ||
|
|
0fc5e1d387 | ||
|
|
ce6c25e4e2 | ||
|
|
165381d79a | ||
|
|
2da3f16bda | ||
|
|
02c349093b | ||
|
|
82873c44f8 | ||
|
|
7afc696da3 | ||
|
|
4e0d430504 | ||
|
|
0b091fa935 | ||
|
|
4db33b6caf | ||
|
|
4dd0372702 | ||
|
|
98b01a462d | ||
|
|
03570f2f11 | ||
|
|
f810e65ea2 | ||
|
|
c04b63e4af | ||
|
|
98a2ef9d72 | ||
|
|
999e69b031 | ||
|
|
79e99fd6e3 | ||
|
|
d91460b79d | ||
|
|
b1f7b72043 | ||
|
|
5a1fd4a1bb | ||
|
|
3ec469bbaf | ||
|
|
091ee7624a | ||
|
|
1918547fdc | ||
|
|
a8a956c85d | ||
|
|
143febf807 | ||
|
|
af9437f80a | ||
|
|
5cf585c8dd | ||
|
|
e6dbbfae34 | ||
|
|
8993844739 | ||
|
|
21d0622f84 | ||
|
|
e787c08bd9 | ||
|
|
ce6d9424e6 |
+9
-1
@@ -4,4 +4,12 @@
|
||||
1.11.2
|
||||
1.12.2
|
||||
1.17.2
|
||||
1.31.2
|
||||
1.31.2
|
||||
2.8.2
|
||||
3.2.2
|
||||
3.2.3
|
||||
|
||||
3.3.2
|
||||
3.6.2
|
||||
3.6.3
|
||||
3.6.4
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const base = require('@polkadot/dev/config/eslint');
|
||||
const base = require('@polkadot/dev/config/eslint.cjs');
|
||||
|
||||
module.exports = {
|
||||
...base,
|
||||
|
||||
+46
-7
File diff suppressed because one or more lines are too long
+46
-21
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Vendored
-55
File diff suppressed because one or more lines are too long
+55
File diff suppressed because one or more lines are too long
+1
-3
@@ -9,7 +9,5 @@ plugins:
|
||||
spec: "@yarnpkg/plugin-interactive-tools"
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
|
||||
spec: "@yarnpkg/plugin-version"
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
|
||||
spec: "@yarnpkg/plugin-workspace-tools"
|
||||
|
||||
yarnPath: .yarn/releases/yarn-2.3.3.cjs
|
||||
yarnPath: .yarn/releases/yarn-2.4.0.cjs
|
||||
|
||||
+252
-1
@@ -1,5 +1,256 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 3.7.1 Feb 1, 2021
|
||||
|
||||
Upgrade priority: Low. However recommended for current Substrate master, Polkadot and Rococo users and those wishing to support the upcoming Polkadot 28 runtime with the new `MultiAddress`.
|
||||
|
||||
- **Breaking change** As indicated in the 3.5.1 release notes, the `Address`/`LookupSource` defaults have now been adjusted for `MultiAddress`. If your chain does not use these types, explicitly add the correct `Address`/`LookupSource` types. This new extensible format is mean to cater for all address types into the future, removing a lot of discrepancies between chains.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Extraction of the block author on Moonbeam (Thanks to https://github.com/joelamouche)
|
||||
- Cleanup logs with HTTP providers, no subs (Thanks to https://github.com/Tbaut)
|
||||
|
||||
Changes:
|
||||
|
||||
- Allow `.slice` operator on the `Vec` type
|
||||
- Apply `MultiAddress` as a default
|
||||
- Adds support for the upcoming Polkadot 28 and Kusama 2028 runtimes
|
||||
- Add checkpoint for Kusama 2027 upgrade
|
||||
- Update all parachain types (as per latest Rococo)
|
||||
- Correctly use relay blockNumber in parachain validation data
|
||||
- remove information log for capabilities detection (creates confusion)
|
||||
- Remove explicit references to `global`, use the `x-global` detection
|
||||
- Remove explicit `module` in `package.json` (exports map available)
|
||||
|
||||
|
||||
## 3.6.1 Jan 24, 2020
|
||||
|
||||
Upgrade priority: Medium if not already on at least 3.3.1. The next upgrade of Kusama/Polkadot requires it.
|
||||
|
||||
- **Breaking change** To support chains with multiple tokens, such as bridges, the `ChainProperties` type now returns an array of tokens and decimals (instead of singular values) in the `token{Decimals, Symbol}` getters. Additionally, this means that the `registry` interfaces has been changes, to `registry.chainDecimals: number[]` and `registry.chainTokens: string[]`. Where used the `[0]` index will return the first value if only interested in a single, for a straight conversion.
|
||||
|
||||
Changes:
|
||||
|
||||
- Allow for the detection of on-chain capabilities as available (e.g. `AccountData`, `ValidatorPrefs`)
|
||||
- Cater for multiple tokens and decimals in the chain the chain `system.properties` (as per the chain specification)
|
||||
- Add a `instances: { [key]: [module1, module2] }` definition in teh bundle types, allowing for multiple instances (e.g. Balances)
|
||||
- Adjust the `api-derive` for balances to retrieve values via `instances` as well as across multiple modules
|
||||
- Ensure all types are registered for all metadata typegen steps
|
||||
- Add `rpc.payment.queryFeeDetails` RPC endpoint
|
||||
- Update types & metadata to latest Substrate
|
||||
- Move the `@polkadot/x-rxjs` package into the common repo
|
||||
- Allow doc generation for errors/events (markdown outputs)
|
||||
|
||||
|
||||
## 3.5.1 Jan 18, 2020
|
||||
|
||||
Upgrade priority: Low. Recommended for parachain developers.
|
||||
|
||||
- **Important** The default for Substrate on the Address types are `MultiAddress`. It is recommended that chains add explicit definitions for `Address` and `LookupSource` in their types, instead of relying on the API-defaults. A future update will swap the API defaults to align with Substrate.
|
||||
- **Important** Like the above changes in Substrate, the `AccountInfo` structure has also changed. It is recommended that chain developers explicitly add `AccountInfo: 'AccountInfoWithRefCount'` for the version with `refCount` on and `AccountInfoWithProviders` for the latest Substrate version. As per the above, the API defaults will be changed to align with Substrate.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Apply correct TypeScript type for `toBigInt()` (Thanks to https://github.com/ianhe8x)
|
||||
- Expand type definitions for storage key tuples (Thanks to https://github.com/monitz87)
|
||||
- Adjust bounty derive to cater for non-council chains (Thanks to https://github.com/ekowalsk)
|
||||
|
||||
Changes:
|
||||
|
||||
- Remove recursion in vector/struct U8a stream decoding
|
||||
- Availability of staking made optional in session length calcs (era does require it)
|
||||
- Updates to parachain types, ensuring it has coverage for all the latest
|
||||
- Update all Rococo types to the latest (session keys, session reports, parachain indexes)
|
||||
- Update known upgrade checkpoints fo WestEnd
|
||||
- Add types of the lottery module in Substrate
|
||||
- Add and extend types for the crowdloan module in Polkadot
|
||||
- Adjust node-template to default to `MultiAddress` on specVersion >= 100
|
||||
|
||||
|
||||
## 3.4.1 Jan 11, 2020
|
||||
|
||||
Upgrade priority: Low. Fixes for parachain types, `.entries()` (with no values) and `event.is(...)` checks, users of these interfaces will have benefit.
|
||||
|
||||
- **Breaking change** The `derive.chain.{getBlock, subscribeNewBlocks}` now return `SignedBlockExtended`, all with the actual extrinsics and events mapped. Users of the latter interface should take note.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Fix `SessionKeys{6-9}` definitions (Thanks to https://github.com/icodezjb)
|
||||
- Support `Vec<(a, b)>` in enums (Thanks to https://github.com/monitz87)
|
||||
- Add motions to bounty derive (Thanks to https://github.com/ekowalsk)
|
||||
|
||||
Changes:
|
||||
|
||||
- `derive.chain.getBlock()` now maps events to extrinsics via `.extrinsics` getter
|
||||
- Ensure dispatchInfo is extracted on failed extrinsics (`getBlock` derive)
|
||||
- Allow specification of additional signed extrinsic via API options
|
||||
- Add missing parachain types, `ParaGenesisArgs`
|
||||
- Correct `EthTransaction` type (as per the correct cargo crate)
|
||||
- Update with latest contract types for Substrate master
|
||||
- Update alias mapping for asset palette (including Substrate starting defaults)
|
||||
- Allow `.entries()` call where 0 keys are present
|
||||
- Fix `.is` on events not checking the correct index
|
||||
- Construction of `i*` types ow correctly checks for max positive/negative
|
||||
|
||||
|
||||
## 3.3.1 Jan 4, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for users of frontier evm module with additional types.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Expand bounty derives (Thanks to https://github.com/ekowalsk)
|
||||
- Adjust known-types (Thanks to https://github.com/mikiquantum)
|
||||
|
||||
Changes:
|
||||
|
||||
- Parallelize the API-init RPC calls for faster overall startup
|
||||
- Add `ExitReason` types for the frontier evm module
|
||||
- Adjust checks for indexed/non-indexed module checks (metadata decoration)
|
||||
- Apply module aliases on constants (aligning with events, extrinsics)
|
||||
- Allow for use of `system.ss58Prefix` as exposed (current Substrate master)
|
||||
- Correct use of api-contract `blockWeights.maxBlock` in estimation
|
||||
- Build metadata docs & interfaces with section aliases
|
||||
- Update to latest Substrate master metadata in tests
|
||||
|
||||
|
||||
## 3.2.1 Dec 27, 2020
|
||||
|
||||
Upgrade priority: Low. Recommended for users of parachains.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Adjust metadata `.asV12` type signature (Thanks to https://github.com/yjhmelody)
|
||||
|
||||
Changes:
|
||||
|
||||
- Add `api.{errors, events, query, tx}.<section>.<name>.is(...)`
|
||||
- Remove support for staking pre Substrate 2.0
|
||||
- Add all frontier types & RPCs
|
||||
- Support `AccountInfo` with new provider/consumer refCount structure
|
||||
- Additional Cumulus parachain types
|
||||
- Consistently format number JSON based on bitLength
|
||||
- Cleanup metadata -> api dependencies
|
||||
- Update `@polkadot/util` to 5.2.1
|
||||
|
||||
|
||||
## 3.1.1 Dec 20, 2020
|
||||
|
||||
Upgrade priority: Low. Recommended for users of parachains.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Additional parachain types (Thanks to https://github.com/joelamouche)
|
||||
- Support for multi queries with `HttpProvider` (Thanks to https://github.com/ianhe8x)
|
||||
- Configurable error logging with `createTypeUnsafe` (Thanks to https://github.com/dvdplm)
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust core type creation, removing storage duplication
|
||||
- Update parachain types to support Rococo v1
|
||||
- Adjust bounties derive to cater for new Substrate namespaces (& move to bounties)
|
||||
- Mark `detectPackage` as known side-effect
|
||||
- Add `detectPackage` to `@polkadot/metadata` (a number of requests on this)
|
||||
- Adjust x-rxjs wrapper to expose all methods, incl. Node.js esm fixes
|
||||
- Update to latest Substrate static metadata
|
||||
- Update `@polkadot/util` to 5.1.1
|
||||
|
||||
|
||||
## 3.0.1 Dec 14, 2020
|
||||
|
||||
Upgrade priority: Low. Recommended for the next Kusama/Polkadot upgrades due to additional types and those following chains following Substrate master closely.
|
||||
|
||||
**Important** While this package contains no external interface changes, it now compiles and ships both cjs and esm modules. This means that modern bundlers will have more information for tree-shaking available. Additionally when using Node with `.mjs` extensions, the esm version imports will be used on recent Node versions. Adding an export map, as here, may have some impacts so a major semver bump is advised. There may be (small) dragons hiding in the dark corners...
|
||||
|
||||
Contributed:
|
||||
|
||||
- Injection of derives via typesBundle (Thanks to https://github.com/pr0fedt)
|
||||
- Added derives for bounties (Thanks to https://github.com/krzysztof-jelski)
|
||||
|
||||
Changes:
|
||||
|
||||
- Build and expose both cjs and esm via exports map
|
||||
- Inject RPC definitions for typesBundle, allowing per-spec configuration
|
||||
- Added `query.<section>.<method>.sizeAt(hash, [...params])` for all storage
|
||||
- Add new Substrate consumed Weight types
|
||||
- Expand `SessionKeys<n>` definitions (up to 9)
|
||||
- Cleanup circular `Type` <-> `Text` definitions
|
||||
- Cleanup circular `Metadata` <-> `TypeRegistry` imports
|
||||
- Update `@polkadot/util` to 5.0.1
|
||||
|
||||
|
||||
## 2.10.1 Dec 7, 2020
|
||||
|
||||
Upgrade priority: Low. Recommended when following Substrate master and/or parachains development, contains the latest types for both.
|
||||
|
||||
- **Breaking change** If using the `staking.query` derive, you now need to pass flags as to which values to retrieve
|
||||
|
||||
Changes:
|
||||
|
||||
- Ensure that maximum era is limited to `consts.system.blockHashCount` (don't overflow on very low blocktimes)
|
||||
- Apply current Polkadot master parachain types
|
||||
- Apply current Substrate master asset types
|
||||
- Add `system_{addLogFilter, resetLogFilter}` RPCs
|
||||
- Adjust tests for latest Substrate metadata
|
||||
- Adjust staking derives to be more performant (flags indicate which query values to retrieve)
|
||||
- Add account derive to cater for the availability of identities
|
||||
- Use `import type` in all cases
|
||||
|
||||
|
||||
## 2.9.1 Nov 30, 2020
|
||||
|
||||
Upgrade priority: Low. No major changes when on at least 2.8.2. Users encouraged to upgrade to at least that patch.
|
||||
|
||||
- **Breaking change** The API will now not attempt to queue calls made while not connected and send on connection. Rather when making a call and the RPC node is not connected, an error will be thrown.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Add typegen capability for custom RPCs (Thanks to https://github.com/holygits)
|
||||
|
||||
Changes:
|
||||
|
||||
- Remove rpc-core send queue, only allow sends while connected
|
||||
- Adjust staking derive for `electedInfo` to contain details of current validators
|
||||
- Extract identity-only derive from `accounts.info` for simpler reusability
|
||||
- Add types for Substrate master node (to allow for consistent swapping to `MultiAddress`)
|
||||
- Adjust `Bytes` with `.slice` to be consistent for `Uint8array` extensions (already released in 2.8.2 as a bugfix)
|
||||
|
||||
|
||||
## 2.8.1 Nov 23, 2020
|
||||
|
||||
Upgrade priority: Low. Recommended if using Substrate master with new `MultiAddress`.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Export `derive.chain.getBlock` (Thanks to https://github.com/lovesh)
|
||||
|
||||
Changes:
|
||||
|
||||
- Expand `MultiAddress` construction with multi type detection
|
||||
- Rename `GenericLookupSource` to `IndicesLookupSource` (internal use)
|
||||
- Cleanup list retrievals with `Raw` data results for undecodable entries
|
||||
- Export actual version via `RegistryMetadata`
|
||||
- Dedupe bn.js (one version shared between dependencies)
|
||||
|
||||
|
||||
## 2.7.1 Nov 16, 2020
|
||||
|
||||
Upgrade priority: Medium. Recommended for users of Polkadot/Kusama and api-contract users.
|
||||
|
||||
Changes:
|
||||
|
||||
- Allow for `ExtrinsicSignature` overrides (defaults to `MultiSignature`)
|
||||
- Update api-contract `Blueprint` to allow for optional salt (auto if not provided)
|
||||
- Support for ink! `.contract` files (in addition to ABI `.json`)
|
||||
- Fix contract event decoding with pass-through of raw `Bytes`
|
||||
- Fix support for enum encoding in api-contract
|
||||
- Support new contract `Schedule` type as per Substrate
|
||||
- Update Kusama/Polkadot known upgrade blocks
|
||||
- Adjust typegen generated `@polkadot/types` imports
|
||||
- Adjust internal `@polkadot/types` imports/exports (overall bundle sizes)
|
||||
|
||||
|
||||
## 2.6.1 Nov 9, 2020
|
||||
|
||||
Upgrade priority: Low. Should be done alongside an update to `@polkadot/util` to 4.0
|
||||
@@ -7,7 +258,7 @@ Upgrade priority: Low. Should be done alongside an update to `@polkadot/util` to
|
||||
Changes:
|
||||
|
||||
- Adjust auto-gas to contract RPC call to 5 * 10 ^ 12 (align with Rust)
|
||||
- Adjust derive AccountId check to take Ethereum-compatible chains into account
|
||||
- Adjust derive `AccountId` check to take Ethereum-compatible chains into account
|
||||
- Fallback for chains with invalid council proposal data in derives
|
||||
- Bump static v12 Metadata (tests) to latest Substrate version
|
||||
- Bump `@polkadot/{util,util-crypto}` to 4.0 (optimized WASM layers)
|
||||
|
||||
@@ -28,19 +28,3 @@ The API is split up into a number of internal packages -
|
||||
Type definitions for interfaces as exposed by Polkadot & Substrate clients -
|
||||
|
||||
- [@polkadot/types](packages/types/) Codecs for all Polkadot and Substrate primitives
|
||||
|
||||
## development
|
||||
|
||||
Contributions are welcome!
|
||||
|
||||
To start off, this repo (along with others in the [@polkadot](https://github.com/polkadot-js/) family) uses yarn workspaces to organise the code. As such, after cloning, its dependencies _should_ be installed via `yarn`, not via npm; the latter will result in broken dependencies.
|
||||
|
||||
To get started -
|
||||
|
||||
1. Clone the repo locally, via `git clone https://github.com/polkadot-js/api <optional local path>`
|
||||
2. Ensure that you have a recent version of Node.js, for development purposes [Node 10](https://nodejs.org/en/) is recommended.
|
||||
3. Ensure that you have a recent version of Yarn, for development purposes [Yarn >=1.10.1](https://yarnpkg.com/docs/install) is required.
|
||||
4. Install the dependencies by running `yarn`
|
||||
5. Build the everything via `yarn run build`
|
||||
6. You can also launch the API Docs, via `yarn vuepress dev docs`
|
||||
7. Access the docs via [http://localhost:8080](http://localhost:8080)
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
module.exports = require('@polkadot/dev/config/babel');
|
||||
module.exports = require('@polkadot/dev/config/babel-config-cjs.cjs');
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const config = require('@polkadot/dev/config/jest');
|
||||
const config = require('@polkadot/dev/config/jest.cjs');
|
||||
|
||||
module.exports = Object.assign({}, config, {
|
||||
moduleNameMapper: {
|
||||
@@ -26,5 +26,5 @@ module.exports = Object.assign({}, config, {
|
||||
'<rootDir>/packages/types/build',
|
||||
'<rootDir>/packages/types-known/build'
|
||||
],
|
||||
resolver: '@polkadot/dev/config/jest-resolver'
|
||||
resolver: '@polkadot/dev/config/jest-resolver.cjs'
|
||||
});
|
||||
|
||||
+12
-10
@@ -3,14 +3,16 @@
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"license": "Apache-2",
|
||||
"private": true,
|
||||
"type": "commonjs",
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
],
|
||||
"resolutions": {
|
||||
"typescript": "^4.0.5"
|
||||
"typescript": "^4.1.3"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn build:interfaces && polkadot-dev-build-ts && (cd packages/typegen && copyfiles scripts/* build)",
|
||||
"build": "yarn build:interfaces && polkadot-dev-build-ts",
|
||||
"build:extra": "(cd packages/typegen && copyfiles scripts/* build)",
|
||||
"build:interfaces": "polkadot-types-internal-interfaces",
|
||||
"build:release": "polkadot-ci-ghact-build",
|
||||
"docs:metadata": "polkadot-types-internal-metadata",
|
||||
@@ -23,14 +25,14 @@
|
||||
"test:watch": "polkadot-dev-run-test --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.12.3",
|
||||
"@babel/register": "^7.12.1",
|
||||
"@babel/runtime": "^7.12.1",
|
||||
"@polkadot/dev": "^0.59.20",
|
||||
"@polkadot/ts": "^0.3.53",
|
||||
"@babel/core": "^7.12.10",
|
||||
"@babel/register": "^7.12.10",
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@polkadot/dev": "^0.61.24",
|
||||
"@polkadot/ts": "^0.3.59",
|
||||
"@polkadot/typegen": "workspace:packages/typegen",
|
||||
"@types/jest": "^26.0.15",
|
||||
"copyfiles": "^2.4.0"
|
||||
"@types/jest": "^26.0.20",
|
||||
"copyfiles": "^2.4.1"
|
||||
},
|
||||
"version": "2.6.1"
|
||||
"version": "3.7.1"
|
||||
}
|
||||
|
||||
@@ -1,36 +1,22 @@
|
||||
{
|
||||
"name": "@polkadot/api-contract",
|
||||
"version": "2.6.1",
|
||||
"version": "3.7.1",
|
||||
"description": "Interfaces for interacting with contracts and contract ABIs",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
"Polkadot",
|
||||
"ABI"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [
|
||||
"Jaco Greeff <jacogr@gmail.com>"
|
||||
],
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
"license": "Apache-2.0",
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"registry": "https://registry.npmjs.org"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/polkadot-js/api.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/polkadot-js/api/issues"
|
||||
},
|
||||
"repository": "github:polkadot-js/api",
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.1",
|
||||
"@polkadot/api": "2.6.1",
|
||||
"@polkadot/types": "2.6.1",
|
||||
"@polkadot/util": "^4.0.1",
|
||||
"bn.js": "^5.1.3",
|
||||
"rxjs": "^6.6.3"
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@polkadot/api": "3.7.1",
|
||||
"@polkadot/types": "3.7.1",
|
||||
"@polkadot/util": "^5.5.1",
|
||||
"@polkadot/x-rxjs": "^5.5.1",
|
||||
"bn.js": "^4.11.9"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import Abi from './Abi';
|
||||
|
||||
import * as testContracts from '../test/contracts';
|
||||
|
||||
const abis: Record<string, any> = { ...testContracts };
|
||||
import abis from '../test/contracts';
|
||||
import { Abi } from '.';
|
||||
|
||||
interface JSONAbi {
|
||||
spec: {
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AnyJson, Codec, CodecArg } from '@polkadot/types/types';
|
||||
import { ChainProperties, ContractConstructorSpec, ContractEventSpec, ContractMessageSpec, ContractMessageParamSpec, ContractProject } from '@polkadot/types/interfaces';
|
||||
import { AbiConstructor, AbiEvent, AbiMessage, AbiParam, DecodedEvent, DecodedMessage } from './types';
|
||||
import type { Bytes } from '@polkadot/types';
|
||||
import type { ChainProperties, ContractConstructorSpec, ContractEventSpec, ContractMessageParamSpec, ContractMessageSpec, ContractProject } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson, Codec, CodecArg } from '@polkadot/types/types';
|
||||
import type { AbiConstructor, AbiEvent, AbiMessage, AbiParam, DecodedEvent, DecodedMessage } from './types';
|
||||
|
||||
import { assert, assertReturn, compactAddLength, compactStripLength, isNumber, isObject, isString, logger, stringCamelCase, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
|
||||
import MetaRegistry from './MetaRegistry';
|
||||
import { MetaRegistry } from './MetaRegistry';
|
||||
|
||||
const EMPTY_U8A = new Uint8Array();
|
||||
|
||||
const l = logger('Abi');
|
||||
|
||||
@@ -21,7 +24,7 @@ function findMessage <T extends AbiMessage> (list: T[], messageOrId: T | string
|
||||
return assertReturn(message, `Attempted to call an invalid contract interface, ${JSON.stringify(messageOrId)}`);
|
||||
}
|
||||
|
||||
export default class Abi {
|
||||
export class Abi {
|
||||
readonly #events: AbiEvent[];
|
||||
|
||||
public readonly constructors: AbiConstructor[];
|
||||
@@ -74,7 +77,7 @@ export default class Abi {
|
||||
/**
|
||||
* Warning: Unstable API, bound to change
|
||||
*/
|
||||
public decodeEvent (data: Uint8Array): DecodedEvent {
|
||||
public decodeEvent (data: Bytes | Uint8Array): DecodedEvent {
|
||||
const index = data[0];
|
||||
const event = this.#events[index];
|
||||
|
||||
@@ -151,8 +154,8 @@ export default class Abi {
|
||||
identifier: spec.name.toString(),
|
||||
index,
|
||||
selector: spec.selector,
|
||||
toU8a: (params: CodecArg[]) =>
|
||||
this.#encodeArgs(spec, args, params)
|
||||
toU8a: (params: CodecArg[], additional?: Uint8Array) =>
|
||||
this.#encodeArgs(spec, args, params, additional)
|
||||
};
|
||||
|
||||
return message;
|
||||
@@ -182,13 +185,14 @@ export default class Abi {
|
||||
return message.fromU8a(trimmed.subarray(4));
|
||||
}
|
||||
|
||||
#encodeArgs = ({ name, selector }: ContractMessageSpec | ContractConstructorSpec, args: AbiParam[], data: CodecArg[]): Uint8Array => {
|
||||
#encodeArgs = ({ name, selector }: ContractMessageSpec | ContractConstructorSpec, args: AbiParam[], data: CodecArg[], additional = EMPTY_U8A): Uint8Array => {
|
||||
assert(data.length === args.length, `Expected ${args.length} arguments to contract message '${name.toString()}', found ${data.length}`);
|
||||
|
||||
return compactAddLength(
|
||||
u8aConcat(
|
||||
this.registry.createType('ContractSelector', selector).toU8a(),
|
||||
...args.map(({ type }, index) => this.registry.createType(type.type as 'Text', data[index]).toU8a())
|
||||
...args.map(({ type }, index) => this.registry.createType(type.type as 'Text', data[index]).toU8a()),
|
||||
additional
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import Abi from './Abi';
|
||||
|
||||
import * as testContracts from '../test/contracts';
|
||||
|
||||
const abis: Record<string, any> = { ...testContracts };
|
||||
import abis from '../test/contracts';
|
||||
import { Abi } from '.';
|
||||
|
||||
describe('MetaRegistry', (): void => {
|
||||
Object.keys(abis).forEach((abiName) => {
|
||||
@@ -33,6 +30,6 @@ describe('MetaRegistry', (): void => {
|
||||
});
|
||||
|
||||
it('stores base project as JSON', (): void => {
|
||||
expect(new Abi(abis.dns).json).toEqual(abis.dns);
|
||||
expect(new Abi(abis.ink_dns).json).toEqual(abis.ink_dns);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ContractDisplayName, ChainProperties, SiField, SiLookupTypeId, SiType, SiTypeDefArray, SiTypeDefVariant, SiTypeDefSequence, SiTypeDefTuple, SiVariant } from '@polkadot/types/interfaces';
|
||||
import { InterfaceTypes, TypeDef, TypeDefInfo } from '@polkadot/types/types';
|
||||
import type { ChainProperties, ContractDisplayName, SiField, SiLookupTypeId, SiType, SiTypeDefArray, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiVariant } from '@polkadot/types/interfaces';
|
||||
import type { InterfaceTypes, TypeDef } from '@polkadot/types/types';
|
||||
|
||||
import { TypeRegistry, withTypeString } from '@polkadot/types/create';
|
||||
import { TypeDefInfo } from '@polkadot/types/types';
|
||||
import { assert, isUndefined } from '@polkadot/util';
|
||||
import { TypeRegistry, withTypeString } from '@polkadot/types';
|
||||
|
||||
interface PartialTypeSpec {
|
||||
readonly type: SiLookupTypeId;
|
||||
@@ -24,7 +25,7 @@ const PRIMITIVE_ALIAS: Record<string, keyof InterfaceTypes> = {
|
||||
|
||||
const PRIMITIVE_ALWAYS = ['AccountId', 'AccountIndex', 'Address', 'Balance'];
|
||||
|
||||
export default class MetaRegistry extends TypeRegistry {
|
||||
export class MetaRegistry extends TypeRegistry {
|
||||
public readonly metaTypeDefs: TypeDef[] = [];
|
||||
|
||||
#siTypes: SiType[] = [];
|
||||
@@ -119,7 +120,7 @@ export default class MetaRegistry extends TypeRegistry {
|
||||
: {}
|
||||
),
|
||||
...(type.params.length > 0
|
||||
? { params: type.params.map((type) => this.getMetaTypeDef({ type })) }
|
||||
? { sub: type.params.map((type) => this.getMetaTypeDef({ type })) }
|
||||
: {}
|
||||
),
|
||||
...typeDef
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import { AnyJson, Registry } from '@polkadot/types/types';
|
||||
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import type { AnyJson, Registry } from '@polkadot/types/types';
|
||||
|
||||
import ApiBase from '@polkadot/api/base';
|
||||
import { ApiBase } from '@polkadot/api/base';
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import { Abi } from '../Abi';
|
||||
|
||||
export default abstract class Base<ApiType extends ApiTypes> {
|
||||
export abstract class Base<ApiType extends ApiTypes> {
|
||||
public readonly abi: Abi;
|
||||
|
||||
public readonly api: ApiBase<ApiType>;
|
||||
|
||||
@@ -1,22 +1,49 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import { AccountId, EventRecord, Hash } from '@polkadot/types/interfaces';
|
||||
import { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
|
||||
import { AbiConstructor } from '../types';
|
||||
import { MapConstructorExec } from './types';
|
||||
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import type { AccountId, EventRecord, Hash } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
|
||||
import type { AbiConstructor, BlueprintOptions } from '../types';
|
||||
import type { BlueprintDeploy, ContractGeneric, MapConstructorExec } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { SubmittableResult } from '@polkadot/api';
|
||||
import ApiBase from '@polkadot/api/base';
|
||||
import { isUndefined, stringCamelCase } from '@polkadot/util';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import { applyOnEvent } from '../util';
|
||||
import Base from './Base';
|
||||
import Contract from './Contract';
|
||||
import { SubmittableResult } from '@polkadot/api';
|
||||
import { ApiBase } from '@polkadot/api/base';
|
||||
import { Bytes } from '@polkadot/types';
|
||||
import { compactAddLength, isUndefined, stringCamelCase, u8aToU8a } from '@polkadot/util';
|
||||
import { randomAsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import { Abi } from '../Abi';
|
||||
import { applyOnEvent, extractOptions, isOptions } from '../util';
|
||||
import { Base } from './Base';
|
||||
import { Contract } from './Contract';
|
||||
|
||||
const EMPTY_SALT = new Uint8Array();
|
||||
|
||||
function createTx <ApiType extends ApiTypes> (fn: (options: BlueprintOptions, params: CodecArg[]) => SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>>): BlueprintDeploy<ApiType> {
|
||||
return (options: BigInt | string | number | BN | BlueprintOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> =>
|
||||
isOptions(options)
|
||||
? fn(options, params)
|
||||
: fn(...extractOptions(options, params));
|
||||
}
|
||||
|
||||
function createWithId <T> (fn: (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: CodecArg[]) => T): ContractGeneric<BlueprintOptions, T> {
|
||||
return (constructorOrId: AbiConstructor | string | number, options: BigInt | string | number | BN | BlueprintOptions, ...params: CodecArg[]): T =>
|
||||
isOptions(options)
|
||||
? fn(constructorOrId, options, params)
|
||||
: fn(constructorOrId, ...extractOptions(options, params));
|
||||
}
|
||||
|
||||
function encodeSalt (salt: Uint8Array | string | null = randomAsU8a()) {
|
||||
return salt instanceof Bytes
|
||||
? salt
|
||||
: salt && salt.length
|
||||
? compactAddLength(u8aToU8a(salt))
|
||||
: EMPTY_SALT;
|
||||
}
|
||||
|
||||
export class BlueprintSubmittableResult<ApiType extends ApiTypes> extends SubmittableResult {
|
||||
public readonly contract?: Contract<ApiType>;
|
||||
@@ -28,22 +55,31 @@ export class BlueprintSubmittableResult<ApiType extends ApiTypes> extends Submit
|
||||
}
|
||||
}
|
||||
|
||||
export default class Blueprint<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
export class Blueprint<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
/**
|
||||
* @description The on-chain code hash for this blueprint
|
||||
*/
|
||||
public readonly codeHash: Hash;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @description Deprecated. Use `.tx.<constructorName>`. Creates a contract in a non-deterministic way.
|
||||
*/
|
||||
public readonly createContract: ContractGeneric<BlueprintOptions, SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>>>;
|
||||
|
||||
readonly #tx: MapConstructorExec<ApiType> = {};
|
||||
|
||||
constructor (api: ApiBase<ApiType>, abi: AnyJson | Abi, codeHash: string | Hash | Uint8Array, decorateMethod: DecorateMethod<ApiType>) {
|
||||
super(api, abi, decorateMethod);
|
||||
|
||||
this.codeHash = this.registry.createType('Hash', codeHash);
|
||||
this.createContract = createWithId(this.#deploy);
|
||||
|
||||
this.abi.constructors.forEach((c): void => {
|
||||
const messageName = stringCamelCase(c.identifier);
|
||||
|
||||
if (isUndefined(this.#tx[messageName])) {
|
||||
this.#tx[messageName] = (endowment: BigInt | string | number | BN, gasLimit: BigInt | string | number | BN, ...params: CodecArg[]) =>
|
||||
this.#deploy(c, endowment, gasLimit, params);
|
||||
this.#tx[messageName] = createTx((o, p) => this.#deploy(c, o, p));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -52,17 +88,20 @@ export default class Blueprint<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
return this.#tx;
|
||||
}
|
||||
|
||||
#deploy = (constructorOrId: AbiConstructor | string| number, endowment: BigInt | string | number | BN, gasLimit: BigInt | string | number | BN, params: CodecArg[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> => {
|
||||
return this.api.tx.contracts
|
||||
.instantiate(endowment, gasLimit, this.codeHash, this.abi.findConstructor(constructorOrId).toU8a(params))
|
||||
.withResultTransform((result: ISubmittableResult) =>
|
||||
new BlueprintSubmittableResult(result, applyOnEvent(result, 'Instantiated', ([record]: EventRecord[]) =>
|
||||
new Contract<ApiType>(this.api, this.abi, record.event.data[1] as AccountId, this._decorateMethod)
|
||||
))
|
||||
);
|
||||
}
|
||||
#deploy = (constructorOrId: AbiConstructor | string| number, { gasLimit = 0, salt, value = 0 }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> => {
|
||||
const encodedSalt = encodeSalt(salt);
|
||||
const withSalt = this.api.tx.contracts.instantiate.meta.args.length === 5;
|
||||
const encoded = this.abi.findConstructor(constructorOrId).toU8a(params, withSalt ? EMPTY_SALT : encodedSalt);
|
||||
const tx = withSalt
|
||||
? this.api.tx.contracts.instantiate(value, gasLimit, this.codeHash, encoded, encodedSalt)
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore old style with salt included
|
||||
: this.api.tx.contracts.instantiate(value, gasLimit, this.codeHash, encoded);
|
||||
|
||||
public createContract (constructorOrId: AbiConstructor | string| number, endowment: BigInt | string | number | BN, gasLimit: BigInt | string | number | BN, ...params: CodecArg[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> {
|
||||
return this.#deploy(constructorOrId, endowment, gasLimit, params);
|
||||
return tx.withResultTransform((result: ISubmittableResult) =>
|
||||
new BlueprintSubmittableResult(result, applyOnEvent(result, 'Instantiated', ([record]: EventRecord[]) =>
|
||||
new Contract<ApiType>(this.api, this.abi, record.event.data[1] as AccountId, this._decorateMethod)
|
||||
))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import { decorateMethod } from '@polkadot/api/promise';
|
||||
|
||||
import contractFlipper from '../../test/contracts/ink/flipper.contract.json';
|
||||
import abiFlipper from '../../test/contracts/ink/flipper.json';
|
||||
import { Code } from './Code';
|
||||
import { mockApi } from './mock';
|
||||
|
||||
const wasmFlipper = fs.readFileSync(path.join(__dirname, '../../test/contracts/ink/flipper.wasm'));
|
||||
|
||||
describe('Code', (): void => {
|
||||
it('can construct with an individual ABI/WASM combo', (): void => {
|
||||
expect(
|
||||
() => new Code(mockApi, abiFlipper, wasmFlipper, decorateMethod)
|
||||
).not.toThrow();
|
||||
});
|
||||
|
||||
it('can construct with an .contract ABI', (): void => {
|
||||
expect(
|
||||
() => new Code(mockApi, contractFlipper, null, decorateMethod)
|
||||
).not.toThrow();
|
||||
});
|
||||
});
|
||||
@@ -1,19 +1,19 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import { EventRecord, Hash } from '@polkadot/types/interfaces';
|
||||
import { AnyJson, ISubmittableResult } from '@polkadot/types/types';
|
||||
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import type { EventRecord, Hash } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson, ISubmittableResult } from '@polkadot/types/types';
|
||||
|
||||
import { SubmittableResult } from '@polkadot/api';
|
||||
import ApiBase from '@polkadot/api/base';
|
||||
import { compactAddLength, u8aToU8a } from '@polkadot/util';
|
||||
import { ApiBase } from '@polkadot/api/base';
|
||||
import { assert, compactAddLength, isWasm, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import { Abi } from '../Abi';
|
||||
import { applyOnEvent } from '../util';
|
||||
import Base from './Base';
|
||||
import Blueprint from './Blueprint';
|
||||
import { Base } from './Base';
|
||||
import { Blueprint } from './Blueprint';
|
||||
|
||||
export class CodeSubmittableResult<ApiType extends ApiTypes> extends SubmittableResult {
|
||||
public readonly blueprint?: Blueprint<ApiType>;
|
||||
@@ -25,15 +25,22 @@ export class CodeSubmittableResult<ApiType extends ApiTypes> extends Submittable
|
||||
}
|
||||
}
|
||||
|
||||
export default class Code<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
export class Code<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
public readonly code: Uint8Array;
|
||||
|
||||
constructor (api: ApiBase<ApiType>, abi: AnyJson | Abi, wasm: Uint8Array | string | Buffer, decorateMethod: DecorateMethod<ApiType>) {
|
||||
constructor (api: ApiBase<ApiType>, abi: AnyJson | Abi, wasm: Uint8Array | string | Buffer | null | undefined, decorateMethod: DecorateMethod<ApiType>) {
|
||||
super(api, abi, decorateMethod);
|
||||
|
||||
this.code = u8aToU8a(wasm);
|
||||
this.code = isWasm(this.abi.project.source.wasm)
|
||||
? this.abi.project.source.wasm
|
||||
: u8aToU8a(wasm);
|
||||
|
||||
assert(isWasm(this.code), 'No WASM code provided');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Deploy the code bundle, creating a Blueprint.
|
||||
*/
|
||||
public createBlueprint (): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> {
|
||||
return this.api.tx.contracts
|
||||
.putCode(compactAddLength(this.code))
|
||||
|
||||
@@ -1,28 +1,51 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import { AccountId, ContractExecResult, EventRecord } from '@polkadot/types/interfaces';
|
||||
import { AnyJson, CodecArg, ISubmittableResult, Registry } from '@polkadot/types/types';
|
||||
import { AbiMessage, ContractCallOutcome, DecodedEvent } from '../types';
|
||||
import { ContractRead, MapMessageExec, MapMessageRead } from './types';
|
||||
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import type { Bytes } from '@polkadot/types';
|
||||
import type { AccountId, ContractExecResult, EventRecord, Weight } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson, CodecArg, ISubmittableResult, Registry } from '@polkadot/types/types';
|
||||
import type { AbiMessage, ContractCallOutcome, ContractOptions, DecodedEvent } from '../types';
|
||||
import type { ContractCallResult, ContractCallSend, ContractGeneric, ContractQuery, ContractTx, MapMessageQuery, MapMessageTx } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { SubmittableResult } from '@polkadot/api';
|
||||
import ApiBase from '@polkadot/api/base';
|
||||
import { assert, bnToBn, isFunction, isUndefined, logger, stringCamelCase } from '@polkadot/util';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import { applyOnEvent, formatData } from '../util';
|
||||
import Base from './Base';
|
||||
import { SubmittableResult } from '@polkadot/api';
|
||||
import { ApiBase } from '@polkadot/api/base';
|
||||
import { assert, bnToBn, isFunction, isUndefined, logger, stringCamelCase } from '@polkadot/util';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { Abi } from '../Abi';
|
||||
import { applyOnEvent, extractOptions, formatData, isOptions } from '../util';
|
||||
import { Base } from './Base';
|
||||
|
||||
// As per Rust, 5 * GAS_PER_SEC
|
||||
const MAX_CALL_GAS = new BN(5_000_000_000_000).subn(1);
|
||||
const ERROR_NO_CALL = 'Your node does not expose the contracts.call RPC. This is most probably due to a runtime configuration.';
|
||||
const l = logger('Contract');
|
||||
|
||||
function createQuery <ApiType extends ApiTypes> (fn: (origin: string | AccountId | Uint8Array, options: ContractOptions, params: CodecArg[]) => ContractCallResult<ApiType, ContractCallOutcome>): ContractQuery<ApiType> {
|
||||
return (origin: string | AccountId | Uint8Array, options: BigInt | string | number | BN | ContractOptions, ...params: CodecArg[]): ContractCallResult<ApiType, ContractCallOutcome> =>
|
||||
isOptions(options)
|
||||
? fn(origin, options, params)
|
||||
: fn(origin, ...extractOptions(options, params));
|
||||
}
|
||||
|
||||
function createTx <ApiType extends ApiTypes> (fn: (options: ContractOptions, params: CodecArg[]) => SubmittableExtrinsic<ApiType>): ContractTx<ApiType> {
|
||||
return (options: BigInt | string | number | BN | ContractOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType> =>
|
||||
isOptions(options)
|
||||
? fn(options, params)
|
||||
: fn(...extractOptions(options, params));
|
||||
}
|
||||
|
||||
function createWithId <T> (fn: (messageOrId: AbiMessage | string | number, options: ContractOptions, params: CodecArg[]) => T): ContractGeneric<ContractOptions, T> {
|
||||
return (messageOrId: AbiMessage | string | number, options: BigInt | string | number | BN | ContractOptions, ...params: CodecArg[]): T =>
|
||||
isOptions(options)
|
||||
? fn(messageOrId, options, params)
|
||||
: fn(messageOrId, ...extractOptions(options, params));
|
||||
}
|
||||
|
||||
export class ContractSubmittableResult extends SubmittableResult {
|
||||
public readonly contractEvents?: DecodedEvent[];
|
||||
|
||||
@@ -60,29 +83,44 @@ function mapExecResult (registry: Registry, json: Record<string, AnyJson>): Cont
|
||||
return registry.createType('ContractExecResult', { result: { err: { other: 'unknown' } } });
|
||||
}
|
||||
|
||||
export default class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
/**
|
||||
* @description The on-chain address for this contract
|
||||
*/
|
||||
public readonly address: AccountId;
|
||||
|
||||
readonly #tx: MapMessageExec<ApiType> = {};
|
||||
/**
|
||||
* @deprecated
|
||||
* @description Deprecated. Use `.tx.<messageName>` to send a transaction.
|
||||
*/
|
||||
public readonly exec: ContractGeneric<ContractOptions, SubmittableExtrinsic<ApiType>>;
|
||||
|
||||
readonly #query: MapMessageRead<ApiType> = {};
|
||||
/**
|
||||
* @deprecated
|
||||
* @description Deprecated. Use `.tx.<messageName>` to send a transaction.
|
||||
*/
|
||||
public readonly read: ContractGeneric<ContractOptions, ContractCallSend<ApiType>>;
|
||||
|
||||
readonly #query: MapMessageQuery<ApiType> = {};
|
||||
|
||||
readonly #tx: MapMessageTx<ApiType> = {};
|
||||
|
||||
constructor (api: ApiBase<ApiType>, abi: AnyJson | Abi, address: string | AccountId, decorateMethod: DecorateMethod<ApiType>) {
|
||||
super(api, abi, decorateMethod);
|
||||
|
||||
this.address = this.registry.createType('AccountId', address);
|
||||
this.exec = createWithId(this.#exec);
|
||||
this.read = createWithId(this.#read);
|
||||
|
||||
this.abi.messages.forEach((m): void => {
|
||||
const messageName = stringCamelCase(m.identifier);
|
||||
|
||||
if (isUndefined(this.#tx[messageName])) {
|
||||
this.#tx[messageName] = (value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]) =>
|
||||
this.#exec(m, value, gasLimit, params);
|
||||
this.#tx[messageName] = createTx((o, p) => this.#exec(m, o, p));
|
||||
}
|
||||
|
||||
if (isUndefined(this.#query[messageName])) {
|
||||
this.#query[messageName] = (origin: string | AccountId | Uint8Array, value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]) =>
|
||||
this.#read(m, value, gasLimit, params).send(origin);
|
||||
this.#query[messageName] = createQuery((f, o, p) => this.#read(m, o, p).send(f));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -91,13 +129,13 @@ export default class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
return isFunction(this.api.rx.rpc.contracts?.call);
|
||||
}
|
||||
|
||||
public get query (): MapMessageRead<ApiType> {
|
||||
public get query (): MapMessageQuery<ApiType> {
|
||||
assert(this.hasRpcContractsCall, ERROR_NO_CALL);
|
||||
|
||||
return this.#query;
|
||||
}
|
||||
|
||||
public get tx (): MapMessageExec<ApiType> {
|
||||
public get tx (): MapMessageTx<ApiType> {
|
||||
return this.#tx;
|
||||
}
|
||||
|
||||
@@ -107,11 +145,14 @@ export default class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
return gasLimit.lten(0)
|
||||
? isCall
|
||||
? MAX_CALL_GAS
|
||||
: this.api.consts.system.maximumBlockWeight.muln(64).divn(100)
|
||||
: (this.api.consts.system.blockWeights
|
||||
? this.api.consts.system.blockWeights.maxBlock
|
||||
: this.api.consts.system.maximumBlockWeight as Weight
|
||||
).muln(64).divn(100)
|
||||
: gasLimit;
|
||||
}
|
||||
|
||||
#exec = (messageOrId: AbiMessage | string | number, value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, params: CodecArg[]): SubmittableExtrinsic<ApiType> => {
|
||||
#exec = (messageOrId: AbiMessage | string | number, { gasLimit = 0, value = 0 }: ContractOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType> => {
|
||||
return this.api.tx.contracts
|
||||
.call(this.address, value, this.#getGas(gasLimit), this.abi.findMessage(messageOrId).toU8a(params))
|
||||
.withResultTransform((result: ISubmittableResult) =>
|
||||
@@ -119,7 +160,7 @@ export default class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
records
|
||||
.map(({ event: { data: [, data] } }): DecodedEvent | null => {
|
||||
try {
|
||||
return this.abi.decodeEvent(data.toU8a());
|
||||
return this.abi.decodeEvent(data as Bytes);
|
||||
} catch (error) {
|
||||
l.error(`Unable to decode contract event: ${(error as Error).message}`);
|
||||
|
||||
@@ -131,7 +172,7 @@ export default class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
);
|
||||
}
|
||||
|
||||
#read = (messageOrId: AbiMessage | string | number, value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, params: CodecArg[]): ContractRead<ApiType> => {
|
||||
#read = (messageOrId: AbiMessage | string | number, { gasLimit = 0, value = 0 }: ContractOptions, params: CodecArg[]): ContractCallSend<ApiType> => {
|
||||
assert(this.hasRpcContractsCall, ERROR_NO_CALL);
|
||||
|
||||
const message = this.abi.findMessage(messageOrId);
|
||||
@@ -160,12 +201,4 @@ export default class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
public exec (messageOrId: AbiMessage | string | number, value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]): SubmittableExtrinsic<ApiType> {
|
||||
return this.#exec(messageOrId, value, gasLimit, params);
|
||||
}
|
||||
|
||||
public read (messageOrId: AbiMessage | string | number, value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]): ContractRead<ApiType> {
|
||||
return this.#read(messageOrId, value, gasLimit, params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { default as Blueprint, BlueprintSubmittableResult } from './Blueprint';
|
||||
export { default as Code, CodeSubmittableResult } from './Code';
|
||||
export { default as Contract } from './Contract';
|
||||
export { Blueprint, BlueprintSubmittableResult } from './Blueprint';
|
||||
export { Code, CodeSubmittableResult } from './Code';
|
||||
export { Contract } from './Contract';
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiBase } from '@polkadot/api/base';
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
export const mockApi = {
|
||||
registry,
|
||||
rx: {
|
||||
tx: {
|
||||
contracts: {
|
||||
putCode: (): never => {
|
||||
throw new Error('mock');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} as unknown as ApiBase<'promise'>;
|
||||
@@ -1,31 +1,50 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiTypes, ObsInnerType } from '@polkadot/api/types';
|
||||
import { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import { AccountId } from '@polkadot/types/interfaces';
|
||||
import { CodecArg } from '@polkadot/types/types';
|
||||
import { ContractCallOutcome } from '../types';
|
||||
import type BN from 'bn.js';
|
||||
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import type { ApiTypes, ObsInnerType } from '@polkadot/api/types';
|
||||
import type { AccountId } from '@polkadot/types/interfaces';
|
||||
import type { CodecArg } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { AbiMessage, BlueprintOptions, ContractCallOutcome, ContractOptions } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Observable } from 'rxjs';
|
||||
export interface BlueprintDeploy<ApiType extends ApiTypes> {
|
||||
(options: BlueprintOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
|
||||
(value: BigInt | string | number | BN, gasLimit: BigInt | string | number | BN, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
|
||||
}
|
||||
|
||||
type ContractCallResult<ApiType extends ApiTypes, T> = ApiType extends 'rxjs'
|
||||
export interface ContractQuery<ApiType extends ApiTypes> {
|
||||
(origin: AccountId | string | Uint8Array, options: ContractOptions, ...params: CodecArg[]): ContractCallResult<ApiType, ContractCallOutcome>;
|
||||
(origin: AccountId | string | Uint8Array, value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]): ContractCallResult<ApiType, ContractCallOutcome>;
|
||||
}
|
||||
|
||||
export interface ContractTx<ApiType extends ApiTypes> {
|
||||
(options: ContractOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
|
||||
(value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
|
||||
}
|
||||
|
||||
export interface ContractGeneric<O, T> {
|
||||
(messageOrId: AbiMessage | string | number, options: O, ...params: CodecArg[]): T;
|
||||
(messageOrId: AbiMessage | string | number, value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]): T;
|
||||
}
|
||||
|
||||
export type ContractCallResult<ApiType extends ApiTypes, T> = ApiType extends 'rxjs'
|
||||
? Observable<Observable<T>>
|
||||
: Promise<ObsInnerType<Observable<T>>>;
|
||||
|
||||
export interface ContractRead<ApiType extends ApiTypes> {
|
||||
export interface ContractCallSend<ApiType extends ApiTypes> {
|
||||
send (account: string | AccountId | Uint8Array): ContractCallResult<ApiType, ContractCallOutcome>;
|
||||
}
|
||||
|
||||
export interface MapConstructorExec<ApiType extends ApiTypes> {
|
||||
[message: string]: (endowment: BigInt | string | number | BN, gasLimit: BigInt | string | number | BN, ...params: CodecArg[]) => SubmittableExtrinsic<ApiType>;
|
||||
[message: string]: BlueprintDeploy<ApiType>;
|
||||
}
|
||||
|
||||
export interface MapMessageExec<ApiType extends ApiTypes> {
|
||||
[message: string]: (value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]) => SubmittableExtrinsic<ApiType>;
|
||||
export interface MapMessageTx<ApiType extends ApiTypes> {
|
||||
[message: string]: ContractTx<ApiType>;
|
||||
}
|
||||
|
||||
export interface MapMessageRead<ApiType extends ApiTypes> {
|
||||
[message: string]: (origin: AccountId | string | Uint8Array, value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]) => ContractCallResult<ApiType, ContractCallOutcome>;
|
||||
export interface MapMessageQuery<ApiType extends ApiTypes> {
|
||||
[message: string]: ContractQuery<ApiType>;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Simple non-runnable checks to test type definitions in the editor itself
|
||||
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import { createTestPairs, TestKeyringMap } from '@polkadot/keyring/testingPairs';
|
||||
|
||||
import abiIncrementer from '../test/contracts/ink/incrementer.json';
|
||||
import { BlueprintPromise, ContractPromise } from '.';
|
||||
|
||||
async function checkBlueprint (api: ApiPromise, pairs: TestKeyringMap): Promise<void> {
|
||||
const blueprint = new BlueprintPromise(api, abiIncrementer, '0x1234');
|
||||
|
||||
// new style
|
||||
await blueprint.tx.new({ gasLimit: 456, salt: '0x1234', value: 123 }, 42).signAndSend(pairs.bob);
|
||||
await blueprint.tx.new({ gasLimit: 456, value: 123 }, 42).signAndSend(pairs.bob);
|
||||
|
||||
// old style
|
||||
await blueprint.tx.new(123, 456, 42).signAndSend(pairs.bob);
|
||||
}
|
||||
|
||||
async function checkContract (api: ApiPromise, pairs: TestKeyringMap): Promise<void> {
|
||||
const contract = new ContractPromise(api, abiIncrementer, '0x1234');
|
||||
|
||||
// queries
|
||||
await contract.query.get(pairs.alice.address, {});
|
||||
await contract.query.get(pairs.alice.address, 0, 0);
|
||||
|
||||
// execute
|
||||
await contract.tx.inc({ gasLimit: 1234 }, 123).signAndSend(pairs.eve);
|
||||
await contract.tx.inc(123, 456, 69).signAndSend(pairs.eve);
|
||||
|
||||
// deprecated
|
||||
await contract.read('get', {}).send(pairs.eve.address);
|
||||
await contract.exec('inc', {}, 123).signAndSend(pairs.dave);
|
||||
}
|
||||
|
||||
async function main (): Promise<void> {
|
||||
const api = await ApiPromise.create();
|
||||
const pairs = createTestPairs();
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
Promise.all([
|
||||
checkBlueprint(api, pairs),
|
||||
checkContract(api, pairs)
|
||||
]);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
main().catch(console.error);
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { default as Abi } from './Abi';
|
||||
export { Abi } from './Abi';
|
||||
|
||||
export { Blueprint as BlueprintRx, Code as CodeRx, Contract as ContractRx } from './rx';
|
||||
export { Blueprint as BlueprintPromise, Code as CodePromise, Contract as ContractPromise } from './promise';
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Hash } from '@polkadot/types/interfaces';
|
||||
import { AnyJson } from '@polkadot/types/types';
|
||||
import type { Hash } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson } from '@polkadot/types/types';
|
||||
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import { decorateMethod } from '@polkadot/api/promise';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import BaseBlueprint from '../base/Blueprint';
|
||||
import { Abi } from '../Abi';
|
||||
import { Blueprint as BaseBlueprint } from '../base';
|
||||
|
||||
export default class Blueprint extends BaseBlueprint<'promise'> {
|
||||
export class Blueprint extends BaseBlueprint<'promise'> {
|
||||
constructor (api: ApiPromise, abi: AnyJson | Abi, codeHash: string | Hash) {
|
||||
super(api, abi, codeHash, decorateMethod);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import type { ApiPromise } from '@polkadot/api';
|
||||
import type { AnyJson } from '@polkadot/types/types';
|
||||
|
||||
import { decorateMethod } from '@polkadot/api/promise';
|
||||
import { AnyJson } from '@polkadot/types/types';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import BaseCode from '../base/Code';
|
||||
import { Abi } from '../Abi';
|
||||
import { Code as BaseCode } from '../base';
|
||||
|
||||
export default class Code extends BaseCode<'promise'> {
|
||||
constructor (api: ApiPromise, abi: AnyJson | Abi, wasm: Uint8Array | string | Buffer) {
|
||||
export class Code extends BaseCode<'promise'> {
|
||||
constructor (api: ApiPromise, abi: AnyJson | Abi, wasm: Uint8Array | string | Buffer | null | undefined) {
|
||||
super(api, abi, wasm, decorateMethod);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId } from '@polkadot/types/interfaces';
|
||||
import { AnyJson } from '@polkadot/types/types';
|
||||
import type { AccountId } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson } from '@polkadot/types/types';
|
||||
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import { decorateMethod } from '@polkadot/api/promise';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import BaseContract from '../base/Contract';
|
||||
import { Abi } from '../Abi';
|
||||
import { Contract as BaseContract } from '../base';
|
||||
|
||||
export default class Contract extends BaseContract<'promise'> {
|
||||
export class Contract extends BaseContract<'promise'> {
|
||||
constructor (api: ApiPromise, abi: AnyJson | Abi, address: string | AccountId) {
|
||||
super(api, abi, address, decorateMethod);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { default as Blueprint } from './Blueprint';
|
||||
export { default as Code } from './Code';
|
||||
export { default as Contract } from './Contract';
|
||||
export { Blueprint } from './Blueprint';
|
||||
export { Code } from './Code';
|
||||
export { Contract } from './Contract';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { BlueprintSubmittableResult as BaseBlueprintSubmittableResult, CodeSubmittableResult as BaseCodeSubmittableResult } from '../base';
|
||||
import type { BlueprintSubmittableResult as BaseBlueprintSubmittableResult, CodeSubmittableResult as BaseCodeSubmittableResult } from '../base';
|
||||
|
||||
export type BlueprintSubmittableResult = BaseBlueprintSubmittableResult<'promise'>;
|
||||
export type CodeSubmittableResult = BaseCodeSubmittableResult<'promise'>;
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Hash } from '@polkadot/types/interfaces';
|
||||
import { AnyJson } from '@polkadot/types/types';
|
||||
import type { Hash } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson } from '@polkadot/types/types';
|
||||
|
||||
import { ApiRx } from '@polkadot/api';
|
||||
import { decorateMethod } from '@polkadot/api/rx';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import BaseBlueprint from '../base/Blueprint';
|
||||
import { Abi } from '../Abi';
|
||||
import { Blueprint as BaseBlueprint } from '../base';
|
||||
|
||||
export default class Blueprint extends BaseBlueprint<'rxjs'> {
|
||||
export class Blueprint extends BaseBlueprint<'rxjs'> {
|
||||
constructor (api: ApiRx, abi: AnyJson | Abi, codeHash: string | Hash) {
|
||||
super(api, abi, codeHash, decorateMethod);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AnyJson } from '@polkadot/types/types';
|
||||
import type { ApiRx } from '@polkadot/api';
|
||||
import type { AnyJson } from '@polkadot/types/types';
|
||||
|
||||
import { ApiRx } from '@polkadot/api';
|
||||
import { decorateMethod } from '@polkadot/api/rx';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import BaseCode from '../base/Code';
|
||||
import { Abi } from '../Abi';
|
||||
import { Code as BaseCode } from '../base';
|
||||
|
||||
export default class Code extends BaseCode<'rxjs'> {
|
||||
constructor (api: ApiRx, abi: AnyJson | Abi, wasm: Uint8Array | string | Buffer) {
|
||||
export class Code extends BaseCode<'rxjs'> {
|
||||
constructor (api: ApiRx, abi: AnyJson | Abi, wasm: Uint8Array | string | Buffer | null | undefined) {
|
||||
super(api, abi, wasm, decorateMethod);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId } from '@polkadot/types/interfaces';
|
||||
import { AnyJson } from '@polkadot/types/types';
|
||||
import type { AccountId } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson } from '@polkadot/types/types';
|
||||
|
||||
import { ApiRx } from '@polkadot/api';
|
||||
import { decorateMethod } from '@polkadot/api/rx';
|
||||
|
||||
import Abi from '../Abi';
|
||||
import BaseContract from '../base/Contract';
|
||||
import { Abi } from '../Abi';
|
||||
import { Contract as BaseContract } from '../base';
|
||||
|
||||
export default class Contract extends BaseContract<'rxjs'> {
|
||||
export class Contract extends BaseContract<'rxjs'> {
|
||||
constructor (api: ApiRx, abi: AnyJson | Abi, address: string | AccountId) {
|
||||
super(api, abi, address, decorateMethod);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { default as Blueprint } from './Blueprint';
|
||||
export { default as Code } from './Code';
|
||||
export { default as Contract } from './Contract';
|
||||
export { Blueprint } from './Blueprint';
|
||||
export { Code } from './Code';
|
||||
export { Contract } from './Contract';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { BlueprintSubmittableResult as BaseBlueprintSubmittableResult, CodeSubmittableResult as BaseCodeSubmittableResult } from '../base';
|
||||
import type { BlueprintSubmittableResult as BaseBlueprintSubmittableResult, CodeSubmittableResult as BaseCodeSubmittableResult } from '../base';
|
||||
|
||||
export type BlueprintSubmittableResult = BaseBlueprintSubmittableResult<'promise'>;
|
||||
export type CodeSubmittableResult = BaseCodeSubmittableResult<'promise'>;
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiTypes } from '@polkadot/api/types';
|
||||
import { ContractExecResultResult, ContractSelector } from '@polkadot/types/interfaces';
|
||||
import { Codec, CodecArg, TypeDef } from '@polkadot/types/types';
|
||||
|
||||
import ApiBase from '@polkadot/api/base';
|
||||
import { Text, u64 } from '@polkadot/types';
|
||||
|
||||
import Abi from './Abi';
|
||||
import type BN from 'bn.js';
|
||||
import type { ApiBase } from '@polkadot/api/base';
|
||||
import type { ApiTypes } from '@polkadot/api/types';
|
||||
import type { Text, u64 } from '@polkadot/types';
|
||||
import type { ContractExecResultResult, ContractSelector } from '@polkadot/types/interfaces';
|
||||
import type { Codec, CodecArg, TypeDef } from '@polkadot/types/types';
|
||||
import type { Abi } from '.';
|
||||
|
||||
export interface ContractBase<ApiType extends ApiTypes> {
|
||||
readonly abi: Abi;
|
||||
@@ -42,7 +41,7 @@ export interface AbiMessage {
|
||||
isPayable?: boolean;
|
||||
returnType?: TypeDef | null;
|
||||
selector: ContractSelector;
|
||||
toU8a: (params: CodecArg[]) => Uint8Array;
|
||||
toU8a: (params: CodecArg[], additional?: Uint8Array) => Uint8Array;
|
||||
}
|
||||
|
||||
export type AbiConstructor = AbiMessage;
|
||||
@@ -68,3 +67,14 @@ export interface DecodedMessage {
|
||||
args: Codec[];
|
||||
message: AbiMessage;
|
||||
}
|
||||
|
||||
export interface BlueprintOptions {
|
||||
gasLimit?: BigInt | string | number | BN;
|
||||
salt?: Uint8Array | string | null;
|
||||
value?: BigInt | string | number | BN;
|
||||
}
|
||||
|
||||
export interface ContractOptions {
|
||||
gasLimit?: BigInt | BN | string | number;
|
||||
value?: BigInt | BN | string | number;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,23 @@
|
||||
// Copyright 2017-2020 @polkadot/rpc-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/rpc-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { SubmittableResult } from '@polkadot/api';
|
||||
import { EventRecord } from '@polkadot/types/interfaces';
|
||||
import { Codec, Registry, TypeDef } from '@polkadot/types/types';
|
||||
import type { SubmittableResult } from '@polkadot/api';
|
||||
import type { Raw } from '@polkadot/types';
|
||||
import type { EventRecord } from '@polkadot/types/interfaces';
|
||||
import type { Codec, CodecArg, Registry, TypeDef } from '@polkadot/types/types';
|
||||
import type { BlueprintOptions, ContractOptions } from './types';
|
||||
|
||||
import { Raw, createTypeUnsafe } from '@polkadot/types';
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { createTypeUnsafe } from '@polkadot/types/create';
|
||||
import { isBigInt, isBn, isNumber, isString } from '@polkadot/util';
|
||||
|
||||
type ContractEvents = 'CodeStored' | 'ContractExecution' | 'Instantiated';
|
||||
|
||||
type TOptions = BlueprintOptions | ContractOptions;
|
||||
|
||||
export function formatData (registry: Registry, data: Raw, { type }: TypeDef): Codec {
|
||||
return createTypeUnsafe(registry, type, [data], true);
|
||||
return createTypeUnsafe(registry, type, [data], { isPedantic: true });
|
||||
}
|
||||
|
||||
export function applyOnEvent <T> (result: SubmittableResult, type: ContractEvents, fn: (records: EventRecord[]) => T): T | undefined {
|
||||
@@ -24,3 +31,13 @@ export function applyOnEvent <T> (result: SubmittableResult, type: ContractEvent
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function isOptions <T> (options: BigInt | string | number | BN | T): options is T {
|
||||
return !(isBn(options) || isBigInt(options) || isNumber(options) || isString(options));
|
||||
}
|
||||
|
||||
export function extractOptions <T extends TOptions> (value: BigInt | string | number | BN, params: CodecArg[]): [T, CodecArg[]] {
|
||||
const gasLimit = params.shift() as BN;
|
||||
|
||||
return [{ gasLimit, value } as T, params];
|
||||
}
|
||||
|
||||
+6
-61
@@ -29,15 +29,6 @@
|
||||
{
|
||||
"displayName": "Entry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"params": [
|
||||
{
|
||||
"displayName": "Hash",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "Hash"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
@@ -66,6 +57,7 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"Hash\"}}"
|
||||
},
|
||||
{
|
||||
@@ -108,15 +100,6 @@
|
||||
{
|
||||
"displayName": "ValueEntry",
|
||||
"namespace": "ink_storage::collections::hashmap",
|
||||
"params": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
@@ -131,6 +114,7 @@
|
||||
"name": "key_index"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"type": "{\"value\":\"AccountId\",\"key_index\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
@@ -141,38 +125,6 @@
|
||||
},
|
||||
{
|
||||
"displayName": "Result",
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"displayName": "Error",
|
||||
"namespace": "dns::dns",
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 0
|
||||
},
|
||||
"info": 6,
|
||||
"name": "NameAlreadyExists",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 1
|
||||
},
|
||||
"info": 6,
|
||||
"name": "CallerIsNotOwner",
|
||||
"type": "Null"
|
||||
}
|
||||
],
|
||||
"type": "{ _enum: [\"NameAlreadyExists\", \"CallerIsNotOwner\"] }"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"sub": [
|
||||
{
|
||||
"name": "Ok",
|
||||
@@ -203,9 +155,10 @@
|
||||
"type": "Null"
|
||||
}
|
||||
],
|
||||
"type": "{ _enum: [\"NameAlreadyExists\", \"CallerIsNotOwner\"] }"
|
||||
"type": "{\"_enum\":[\"NameAlreadyExists\",\"CallerIsNotOwner\"]}"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"type": "Result<(), Error>"
|
||||
},
|
||||
{
|
||||
@@ -235,25 +188,17 @@
|
||||
"type": "Null"
|
||||
}
|
||||
],
|
||||
"type": "{ _enum: [\"NameAlreadyExists\", \"CallerIsNotOwner\"] }"
|
||||
"type": "{\"_enum\":[\"NameAlreadyExists\",\"CallerIsNotOwner\"]}"
|
||||
},
|
||||
{
|
||||
"displayName": "Option",
|
||||
"params": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"info": 5,
|
||||
"sub": {
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
},
|
||||
"info": 5,
|
||||
"type": "Option<AccountId>"
|
||||
}
|
||||
]
|
||||
+4
-46
@@ -33,15 +33,6 @@
|
||||
{
|
||||
"displayName": "Entry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"params": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
@@ -70,6 +61,7 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
|
||||
},
|
||||
{
|
||||
@@ -112,13 +104,6 @@
|
||||
{
|
||||
"displayName": "ValueEntry",
|
||||
"namespace": "ink_storage::collections::hashmap",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u128"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
@@ -131,32 +116,12 @@
|
||||
"name": "key_index"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"type": "{\"value\":\"u128\",\"key_index\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
"displayName": "Entry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"type": "(AccountId, AccountId)"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
@@ -197,6 +162,7 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId, AccountId)\"}}"
|
||||
},
|
||||
{
|
||||
@@ -223,21 +189,13 @@
|
||||
},
|
||||
{
|
||||
"displayName": "Option",
|
||||
"params": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"info": 5,
|
||||
"sub": {
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
},
|
||||
"info": 5,
|
||||
"type": "Option<AccountId>"
|
||||
}
|
||||
]
|
||||
+10
-151
@@ -29,13 +29,6 @@
|
||||
{
|
||||
"displayName": "Entry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
@@ -62,6 +55,7 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"u32\"}}"
|
||||
},
|
||||
{
|
||||
@@ -85,15 +79,6 @@
|
||||
{
|
||||
"displayName": "ValueEntry",
|
||||
"namespace": "ink_storage::collections::hashmap",
|
||||
"params": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
@@ -108,6 +93,7 @@
|
||||
"name": "key_index"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"type": "{\"value\":\"AccountId\",\"key_index\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
@@ -132,15 +118,6 @@
|
||||
{
|
||||
"displayName": "Entry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"params": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
@@ -169,18 +146,12 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
|
||||
},
|
||||
{
|
||||
"displayName": "ValueEntry",
|
||||
"namespace": "ink_storage::collections::hashmap",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
@@ -193,32 +164,12 @@
|
||||
"name": "key_index"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"type": "{\"value\":\"u32\",\"key_index\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
"displayName": "Entry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"type": "(AccountId, AccountId)"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
@@ -259,6 +210,7 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId, AccountId)\"}}"
|
||||
},
|
||||
{
|
||||
@@ -282,13 +234,6 @@
|
||||
{
|
||||
"displayName": "ValueEntry",
|
||||
"namespace": "ink_storage::collections::hashmap",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
@@ -301,6 +246,7 @@
|
||||
"name": "key_index"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"type": "{\"value\":\"bool\",\"key_index\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
@@ -309,105 +255,17 @@
|
||||
},
|
||||
{
|
||||
"displayName": "Option",
|
||||
"params": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"info": 5,
|
||||
"sub": {
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
},
|
||||
"info": 5,
|
||||
"type": "Option<AccountId>"
|
||||
},
|
||||
{
|
||||
"displayName": "Result",
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"displayName": "Error",
|
||||
"namespace": "erc721::erc721",
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 0
|
||||
},
|
||||
"info": 6,
|
||||
"name": "NotOwner",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 1
|
||||
},
|
||||
"info": 6,
|
||||
"name": "NotApproved",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 2
|
||||
},
|
||||
"info": 6,
|
||||
"name": "TokenExists",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 3
|
||||
},
|
||||
"info": 6,
|
||||
"name": "TokenNotFound",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 4
|
||||
},
|
||||
"info": 6,
|
||||
"name": "CannotInsert",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 5
|
||||
},
|
||||
"info": 6,
|
||||
"name": "CannotRemove",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 6
|
||||
},
|
||||
"info": 6,
|
||||
"name": "CannotFetchValue",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 7
|
||||
},
|
||||
"info": 6,
|
||||
"name": "NotAllowed",
|
||||
"type": "Null"
|
||||
}
|
||||
],
|
||||
"type": "{ _enum: [\"NotOwner\", \"NotApproved\", \"TokenExists\", \"TokenNotFound\", \"CannotInsert\", \"CannotRemove\", \"CannotFetchValue\", \"NotAllowed\"] }"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"sub": [
|
||||
{
|
||||
"name": "Ok",
|
||||
@@ -486,9 +344,10 @@
|
||||
"type": "Null"
|
||||
}
|
||||
],
|
||||
"type": "{ _enum: [\"NotOwner\", \"NotApproved\", \"TokenExists\", \"TokenNotFound\", \"CannotInsert\", \"CannotRemove\", \"CannotFetchValue\", \"NotAllowed\"] }"
|
||||
"type": "{\"_enum\":[\"NotOwner\",\"NotApproved\",\"TokenExists\",\"TokenNotFound\",\"CannotInsert\",\"CannotRemove\",\"CannotFetchValue\",\"NotAllowed\"]}"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"type": "Result<(), Error>"
|
||||
},
|
||||
{
|
||||
@@ -566,6 +425,6 @@
|
||||
"type": "Null"
|
||||
}
|
||||
],
|
||||
"type": "{ _enum: [\"NotOwner\", \"NotApproved\", \"TokenExists\", \"TokenNotFound\", \"CannotInsert\", \"CannotRemove\", \"CannotFetchValue\", \"NotAllowed\"] }"
|
||||
"type": "{\"_enum\":[\"NotOwner\",\"NotApproved\",\"TokenExists\",\"TokenNotFound\",\"CannotInsert\",\"CannotRemove\",\"CannotFetchValue\",\"NotAllowed\"]}"
|
||||
}
|
||||
]
|
||||
+12
-180
@@ -29,25 +29,6 @@
|
||||
{
|
||||
"displayName": "Entry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"type": "(u32, AccountId)"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
@@ -86,6 +67,7 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(u32, AccountId)\"}}"
|
||||
},
|
||||
{
|
||||
@@ -144,14 +126,6 @@
|
||||
{
|
||||
"displayName": "ValueEntry",
|
||||
"namespace": "ink_storage::collections::hashmap",
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"type": "()"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
@@ -165,6 +139,7 @@
|
||||
"name": "key_index"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"type": "{\"value\":\"()\",\"key_index\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
@@ -175,13 +150,6 @@
|
||||
{
|
||||
"displayName": "Entry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
@@ -208,18 +176,12 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"u32\"}}"
|
||||
},
|
||||
{
|
||||
"displayName": "ValueEntry",
|
||||
"namespace": "ink_storage::collections::hashmap",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
@@ -232,58 +194,12 @@
|
||||
"name": "key_index"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"type": "{\"value\":\"u32\",\"key_index\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
"displayName": "Entry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"params": [
|
||||
{
|
||||
"displayName": "Transaction",
|
||||
"namespace": "multisig_plain::multisig_plain",
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId",
|
||||
"name": "callee"
|
||||
},
|
||||
{
|
||||
"info": 12,
|
||||
"length": 4,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "[u8;4]",
|
||||
"name": "selector"
|
||||
},
|
||||
{
|
||||
"info": 11,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "Vec<u8>",
|
||||
"name": "input"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u128",
|
||||
"name": "transferred_value"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u64",
|
||||
"name": "gas_limit"
|
||||
}
|
||||
],
|
||||
"type": "{\"callee\":\"AccountId\",\"selector\":\"[u8;4]\",\"input\":\"Vec<u8>\",\"transferred_value\":\"u128\",\"gas_limit\":\"u64\"}"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
@@ -350,6 +266,7 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"Transaction\"}}"
|
||||
},
|
||||
{
|
||||
@@ -424,15 +341,6 @@
|
||||
{
|
||||
"displayName": "Entry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"params": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
@@ -461,6 +369,7 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
|
||||
},
|
||||
{
|
||||
@@ -523,19 +432,6 @@
|
||||
},
|
||||
{
|
||||
"displayName": "Result",
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"type": "()"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"sub": [
|
||||
{
|
||||
"name": "Ok",
|
||||
@@ -550,26 +446,11 @@
|
||||
"type": "()"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"type": "Result<(), ()>"
|
||||
},
|
||||
{
|
||||
"displayName": "Result",
|
||||
"params": [
|
||||
{
|
||||
"info": 11,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "Vec<u8>"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"type": "()"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"sub": [
|
||||
{
|
||||
"name": "Ok",
|
||||
@@ -587,56 +468,15 @@
|
||||
"type": "()"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"type": "Result<Vec<u8>, ()>"
|
||||
},
|
||||
{
|
||||
"displayName": "Result",
|
||||
"params": [
|
||||
{
|
||||
"displayName": "Option",
|
||||
"params": [
|
||||
{
|
||||
"info": 11,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "Vec<u8>"
|
||||
}
|
||||
],
|
||||
"info": 5,
|
||||
"sub": {
|
||||
"info": 11,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "Vec<u8>"
|
||||
},
|
||||
"type": "Option<Vec<u8>>"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"type": "()"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"sub": [
|
||||
{
|
||||
"name": "Ok",
|
||||
"displayName": "Option",
|
||||
"params": [
|
||||
{
|
||||
"info": 11,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "Vec<u8>"
|
||||
}
|
||||
],
|
||||
"info": 5,
|
||||
"sub": {
|
||||
"info": 11,
|
||||
"sub": {
|
||||
@@ -645,6 +485,7 @@
|
||||
},
|
||||
"type": "Vec<u8>"
|
||||
},
|
||||
"info": 5,
|
||||
"type": "Option<Vec<u8>>"
|
||||
},
|
||||
{
|
||||
@@ -654,21 +495,11 @@
|
||||
"type": "()"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"type": "Result<Option<Vec<u8>>, ()>"
|
||||
},
|
||||
{
|
||||
"displayName": "Option",
|
||||
"params": [
|
||||
{
|
||||
"info": 11,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "Vec<u8>"
|
||||
}
|
||||
],
|
||||
"info": 5,
|
||||
"sub": {
|
||||
"info": 11,
|
||||
"sub": {
|
||||
@@ -677,6 +508,7 @@
|
||||
},
|
||||
"type": "Vec<u8>"
|
||||
},
|
||||
"info": 5,
|
||||
"type": "Option<Vec<u8>>"
|
||||
}
|
||||
]
|
||||
]
|
||||
@@ -0,0 +1,422 @@
|
||||
[
|
||||
{
|
||||
"info": 6,
|
||||
"type": "i32"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
{
|
||||
"displayName": "Variant",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"name": "None",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"displayName": "Weekday",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 0
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Monday",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 1
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Tuesday",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 2
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Wednesday",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 3
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Thursday",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 4
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Friday",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 5
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Saturday",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 6
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Sunday",
|
||||
"type": "Null"
|
||||
}
|
||||
],
|
||||
"type": "{\"_enum\":[\"Monday\",\"Tuesday\",\"Wednesday\",\"Thursday\",\"Friday\",\"Saturday\",\"Sunday\"]}",
|
||||
"name": "Weekday"
|
||||
},
|
||||
{
|
||||
"displayName": "TupleMaybeSigned",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "i32",
|
||||
"name": "Signed"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32",
|
||||
"name": "Unsigned"
|
||||
}
|
||||
],
|
||||
"type": "{\"_enum\":{\"Signed\":\"i32\",\"Unsigned\":\"u32\"}}",
|
||||
"name": "TupleMaybeSigned"
|
||||
},
|
||||
{
|
||||
"displayName": "NamedMaybeSigned",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "i32",
|
||||
"name": "value"
|
||||
}
|
||||
],
|
||||
"name": "Signed",
|
||||
"type": "{\"value\":\"i32\"}"
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32",
|
||||
"name": "value"
|
||||
}
|
||||
],
|
||||
"name": "Unsigned",
|
||||
"type": "{\"value\":\"u32\"}"
|
||||
}
|
||||
],
|
||||
"type": "{\"_enum\":{\"Signed\":\"{\\\"value\\\":\\\"i32\\\"}\",\"Unsigned\":\"{\\\"value\\\":\\\"u32\\\"}\"}}",
|
||||
"name": "NamedMaybeSigned"
|
||||
},
|
||||
{
|
||||
"displayName": "Color",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"name": "Red",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"name": "Blue",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"name": "Green",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"name": "Yellow",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "r"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "g"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "b"
|
||||
}
|
||||
],
|
||||
"name": "Rgb",
|
||||
"type": "{\"r\":\"u8\",\"g\":\"u8\",\"b\":\"u8\"}"
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "r"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "g"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "b"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "a"
|
||||
}
|
||||
],
|
||||
"name": "Rgba",
|
||||
"type": "{\"r\":\"u8\",\"g\":\"u8\",\"b\":\"u8\",\"a\":\"u8\"}"
|
||||
}
|
||||
],
|
||||
"type": "{\"_enum\":{\"Red\":\"()\",\"Blue\":\"()\",\"Green\":\"()\",\"Yellow\":\"()\",\"Rgb\":\"{\\\"r\\\":\\\"u8\\\",\\\"g\\\":\\\"u8\\\",\\\"b\\\":\\\"u8\\\"}\",\"Rgba\":\"{\\\"r\\\":\\\"u8\\\",\\\"g\\\":\\\"u8\\\",\\\"b\\\":\\\"u8\\\",\\\"a\\\":\\\"u8\\\"}\"}}",
|
||||
"name": "Color"
|
||||
}
|
||||
],
|
||||
"type": "{\"_enum\":{\"None\":\"()\",\"Weekday\":\"Weekday\",\"TupleMaybeSigned\":\"TupleMaybeSigned\",\"NamedMaybeSigned\":\"NamedMaybeSigned\",\"Color\":\"Color\"}}"
|
||||
},
|
||||
{
|
||||
"displayName": "Weekday",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 0
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Monday",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 1
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Tuesday",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 2
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Wednesday",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 3
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Thursday",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 4
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Friday",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 5
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Saturday",
|
||||
"type": "Null"
|
||||
},
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 6
|
||||
},
|
||||
"info": 6,
|
||||
"name": "Sunday",
|
||||
"type": "Null"
|
||||
}
|
||||
],
|
||||
"type": "{\"_enum\":[\"Monday\",\"Tuesday\",\"Wednesday\",\"Thursday\",\"Friday\",\"Saturday\",\"Sunday\"]}"
|
||||
},
|
||||
{
|
||||
"displayName": "TupleMaybeSigned",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "i32",
|
||||
"name": "Signed"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32",
|
||||
"name": "Unsigned"
|
||||
}
|
||||
],
|
||||
"type": "{\"_enum\":{\"Signed\":\"i32\",\"Unsigned\":\"u32\"}}"
|
||||
},
|
||||
{
|
||||
"displayName": "NamedMaybeSigned",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "i32",
|
||||
"name": "value"
|
||||
}
|
||||
],
|
||||
"name": "Signed",
|
||||
"type": "{\"value\":\"i32\"}"
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u32",
|
||||
"name": "value"
|
||||
}
|
||||
],
|
||||
"name": "Unsigned",
|
||||
"type": "{\"value\":\"u32\"}"
|
||||
}
|
||||
],
|
||||
"type": "{\"_enum\":{\"Signed\":\"{\\\"value\\\":\\\"i32\\\"}\",\"Unsigned\":\"{\\\"value\\\":\\\"u32\\\"}\"}}"
|
||||
},
|
||||
{
|
||||
"displayName": "Color",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"name": "Red",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"name": "Blue",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"name": "Green",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [],
|
||||
"name": "Yellow",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "r"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "g"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "b"
|
||||
}
|
||||
],
|
||||
"name": "Rgb",
|
||||
"type": "{\"r\":\"u8\",\"g\":\"u8\",\"b\":\"u8\"}"
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "r"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "g"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "b"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u8",
|
||||
"name": "a"
|
||||
}
|
||||
],
|
||||
"name": "Rgba",
|
||||
"type": "{\"r\":\"u8\",\"g\":\"u8\",\"b\":\"u8\",\"a\":\"u8\"}"
|
||||
}
|
||||
],
|
||||
"type": "{\"_enum\":{\"Red\":\"()\",\"Blue\":\"()\",\"Green\":\"()\",\"Yellow\":\"()\",\"Rgb\":\"{\\\"r\\\":\\\"u8\\\",\\\"g\\\":\\\"u8\\\",\\\"b\\\":\\\"u8\\\"}\",\"Rgba\":\"{\\\"r\\\":\\\"u8\\\",\\\"g\\\":\\\"u8\\\",\\\"b\\\":\\\"u8\\\",\\\"a\\\":\\\"u8\\\"}\"}}"
|
||||
}
|
||||
]
|
||||
+5
-47
@@ -33,15 +33,6 @@
|
||||
{
|
||||
"displayName": "Entry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"params": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
@@ -70,6 +61,7 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
|
||||
},
|
||||
{
|
||||
@@ -112,13 +104,6 @@
|
||||
{
|
||||
"displayName": "ValueEntry",
|
||||
"namespace": "ink_storage::collections::hashmap",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"type": "u128"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
@@ -131,32 +116,12 @@
|
||||
"name": "key_index"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"type": "{\"value\":\"u128\",\"key_index\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
"displayName": "Entry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"params": [
|
||||
{
|
||||
"info": 10,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"type": "(AccountId, AccountId)"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
@@ -197,6 +162,7 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId, AccountId)\"}}"
|
||||
},
|
||||
{
|
||||
@@ -227,21 +193,13 @@
|
||||
},
|
||||
{
|
||||
"displayName": "Option",
|
||||
"params": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"info": 5,
|
||||
"sub": {
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"type": "AccountId"
|
||||
},
|
||||
"info": 5,
|
||||
"type": "Option<AccountId>"
|
||||
}
|
||||
]
|
||||
]
|
||||
@@ -1,6 +1,21 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './ink';
|
||||
export * from './solang';
|
||||
export * from './user';
|
||||
import * as ink from './ink';
|
||||
import * as solang from './solang';
|
||||
import * as user from './user';
|
||||
|
||||
const all: Record<string, any> = {};
|
||||
|
||||
function addExport (type: string, abis: Record<string, any>): void {
|
||||
Object.keys(abis).forEach((key): void => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
all[`${type}_${key}`] = abis[key];
|
||||
});
|
||||
}
|
||||
|
||||
addExport('ink', ink);
|
||||
addExport('solang', solang);
|
||||
addExport('user', user);
|
||||
|
||||
export default all;
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
{
|
||||
"metadataVersion": "0.1.0",
|
||||
"source": {
|
||||
"hash": "0x98086d5ccadd437459b812682380250f51a3034272cd1108e499acc0cafe9f42",
|
||||
"language": "ink! 3.0.0-rc2",
|
||||
"compiler": "rustc 1.49.0-nightly",
|
||||
"wasm": "0x0061736d01000000012c0860027f7f0060037f7f7f0060017f017f60017f006000017f60037f7f7f017f60047f7f7f7f0060017f017e02880106057365616c30107365616c5f6765745f73746f726167650005057365616c30107365616c5f7365745f73746f726167650001057365616c30167365616c5f76616c75655f7472616e736665727265640000057365616c300a7365616c5f696e7075740000057365616c300b7365616c5f72657475726e000103656e76066d656d6f72790201021003121102020002000100070303060402040503010608017f01418080040b071102066465706c6f7900100463616c6c00120a8e1111c90101017f230041406a22012400200141206a200041186a290300370300200141186a200041106a290300370300200141106a200041086a2903003703002001420037032820012000290300370308200141086a1006200141808001360234200141a4800436023020014180800136023841a48004200141386a10002100200141306a20012802381007024002400240024020000e0401000002000b000b20012001290330370338200141386a100841ff017122004102470d01000b000b200141406b240020004100470b6001037e200029032021012000420137032020002001200029030022027c22013703002000200029030822032001200254ad7c22013703082000200029031022022001200354ad7c2201370310200020002903182001200254ad7c37031820000b4901037f230041106b22022400200028020421032000410036020420002802002104200041a48004360200200241086a200120042003100f20002002290308370200200241106a24000b4201027f230041106b22012400200141086a2000100b20012d0009210020012d00082102200141106a240041024101410220004101461b410020001b20024101711b0b8f0101017f230041406a22022400200241206a200141186a290300370300200241186a200141106a290300370300200241106a200141086a2903003703002002420037032820022001290300370308200241086a1006200241386a41808001360200200241a48004360234200241003602302002200241306a2000100a200228020020022802041001200241406b24000b9d0101037f230041106b22032400200141086a220428020021052004410036020020012802042104200141a48004360204200320023a000f2003410120042005100f024020032802044101460440200328020020032d000f3a000020014100360208200141a480043602042005450d0120012005417f6a3602082001200441016a3602042000410136020420002004360200200341106a24000f0b000b000b4801027f230041106b22022400200241003a000f024020012002410f6a4101101345044020022d000f21010c010b410121030b200020013a0001200020033a0000200241106a24000b890101027f230041106b22012400200142003c000c200142003e0208027f0340200241044604402001280208210241000c020b20012000100b20012d0000410171450440200141086a20026a20012d00013a00002001200241016a22023a000c0c010b0b200241ff01710440200141003a000c0b4100210241010b200141106a2400ad2002ad420886840b2201017f230041106b220124002001200036020c2001410c6a2802002d0000100e000b4601017f230041206b22012400200141186a41808001360200200141a4800436021420014100360210200141086a200141106a2000100a41002001280208200128020c1004000b2300410020014d0440200320014f044020002001360204200020023602000f0b000b000b15004100101141ff0171410274418080046a2802000bd80502057f017e230041306b220124000240027f024002402000044020014180800136020c200141a48004360208200141086a10142001200129030837031041012103200141106a100c2206a722054101710440410121020c030b200642ffffffffff1f832206422088a721002006421888a721042006421088a72102200541087641ff01712205411e470440200541c00147200041f3014772200241ff017141960147720d0241002102200441ff017141a501460d030c020b200041d60047200241ff017141dc0047720d014100210241002103200441ff017141a401470d010c020b20014180800136020c200141a48004360208200141086a101420012001290308370310410321020240200141106a100c2206a722044101710d00200642ffffffffff1f832206422088a721002006421888a721032006421088a7210202400240200441087641ff0171220441ea00470440200441d101472000412b4772200241ff017141830147720d02200341ff017141d100460d010c020b200041e20147200241ff0171413747720d0141022102200341ff01714112470d010c020b41032102200141106a100841ff017122004102460d01200041004721020c010b410321020b4106200241034622030d021a4106200220031b22024102460440200141286a4200370300200141206a4200370300200141186a4200370300200142003703104100200141106a100941080c030b200141286a4200370300200141206a4200370300200141186a4200370300200142003703102002410171200141106a100941080c020b41012102410121030b410620020d001a2003450d01200141286a4200370300200141206a4200370300200141186a420037030020014200370310200141106a1005410173200141106a100941080b200141306a24000f0b200141286a4200370300200141206a4200370300200141186a4200370300200142003703102001200141106a10053a0008200141086a100d000ba90102027f027e230041206b22002400200041808001360204200041a4800436020020004180800136021041a48004200041106a100220002000280210100720002000290300370308200041186a2201420037030020004200370310027f4101200041086a200041106a411010130d001a200129030021022000290310210341000b200220038450457245044041011011200041206a240041ff0171410274418080046a2802000f0b000b45000240200028020420024f047f2001200028020020021015200028020422012002490d012000200120026b3602042000200028020020026a36020041000541010b0f0b000b3301017f230041106b220124002001200028020436020c20002802002001410c6a10032000200128020c1007200141106a24000b2c01017f037f2002200346047f200005200020036a200120036a2d00003a0000200341016a21030c010b0b1a0b0b250100418080040b1d0100000002000000030000000400000005000000060000000700000008"
|
||||
},
|
||||
"contract": {
|
||||
"name": "flipper",
|
||||
"version": "3.0.0-rc2",
|
||||
"authors": [
|
||||
"Parity Technologies <admin@parity.io>"
|
||||
]
|
||||
},
|
||||
"spec": {
|
||||
"constructors": [
|
||||
{
|
||||
"args": [
|
||||
{
|
||||
"name": "init_value",
|
||||
"type": {
|
||||
"displayName": [
|
||||
"bool"
|
||||
],
|
||||
"type": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"docs": [
|
||||
" Creates a new flipper smart contract initialized with the given value."
|
||||
],
|
||||
"name": [
|
||||
"new"
|
||||
],
|
||||
"selector": "0xd183512b"
|
||||
},
|
||||
{
|
||||
"args": [],
|
||||
"docs": [
|
||||
" Creates a new flipper smart contract initialized to `false`."
|
||||
],
|
||||
"name": [
|
||||
"default"
|
||||
],
|
||||
"selector": "0x6a3712e2"
|
||||
}
|
||||
],
|
||||
"docs": [],
|
||||
"events": [],
|
||||
"messages": [
|
||||
{
|
||||
"args": [],
|
||||
"docs": [
|
||||
" Flips the current value of the Flipper's bool."
|
||||
],
|
||||
"mutates": true,
|
||||
"name": [
|
||||
"flip"
|
||||
],
|
||||
"payable": false,
|
||||
"returnType": null,
|
||||
"selector": "0xc096a5f3"
|
||||
},
|
||||
{
|
||||
"args": [],
|
||||
"docs": [
|
||||
" Returns the current value of the Flipper's bool."
|
||||
],
|
||||
"mutates": false,
|
||||
"name": [
|
||||
"get"
|
||||
],
|
||||
"payable": false,
|
||||
"returnType": {
|
||||
"displayName": [
|
||||
"bool"
|
||||
],
|
||||
"type": 1
|
||||
},
|
||||
"selector": "0x1e5ca456"
|
||||
}
|
||||
]
|
||||
},
|
||||
"storage": {
|
||||
"struct": {
|
||||
"fields": [
|
||||
{
|
||||
"layout": {
|
||||
"cell": {
|
||||
"key": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"ty": 1
|
||||
}
|
||||
},
|
||||
"name": "value"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"types": [
|
||||
{
|
||||
"def": {
|
||||
"primitive": "bool"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { default as delegator } from './delegator.json';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { default as ints256 } from './ints256.json';
|
||||
|
||||
@@ -0,0 +1,528 @@
|
||||
{
|
||||
"metadataVersion": "0.1.0",
|
||||
"source": {
|
||||
"hash": "0x1a37c380fe02fe3b670480dff1393b0401788955315d092e39fcc06047f1413c",
|
||||
"language": "ink! 3.0.0-rc2",
|
||||
"compiler": "rustc 1.49.0-nightly"
|
||||
},
|
||||
"contract": {
|
||||
"name": "enum_example",
|
||||
"version": "0.1.0",
|
||||
"authors": [
|
||||
"[your_name] <[your_email]>"
|
||||
]
|
||||
},
|
||||
"spec": {
|
||||
"constructors": [
|
||||
{
|
||||
"args": [],
|
||||
"docs": [],
|
||||
"name": [
|
||||
"new"
|
||||
],
|
||||
"selector": "0xd183512b"
|
||||
}
|
||||
],
|
||||
"docs": [],
|
||||
"events": [],
|
||||
"messages": [
|
||||
{
|
||||
"args": [
|
||||
{
|
||||
"name": "variant",
|
||||
"type": {
|
||||
"displayName": [
|
||||
"Variant"
|
||||
],
|
||||
"type": 4
|
||||
}
|
||||
}
|
||||
],
|
||||
"docs": [],
|
||||
"mutates": true,
|
||||
"name": [
|
||||
"set_variant"
|
||||
],
|
||||
"payable": false,
|
||||
"returnType": null,
|
||||
"selector": "0x4fa6b9cf"
|
||||
},
|
||||
{
|
||||
"args": [],
|
||||
"docs": [],
|
||||
"mutates": false,
|
||||
"name": [
|
||||
"get_variant"
|
||||
],
|
||||
"payable": false,
|
||||
"returnType": {
|
||||
"displayName": [
|
||||
"Variant"
|
||||
],
|
||||
"type": 4
|
||||
},
|
||||
"selector": "0x1d5962d1"
|
||||
}
|
||||
]
|
||||
},
|
||||
"storage": {
|
||||
"struct": {
|
||||
"fields": [
|
||||
{
|
||||
"layout": {
|
||||
"enum": {
|
||||
"dispatchKey": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"variants": {
|
||||
"0": {
|
||||
"fields": []
|
||||
},
|
||||
"1": {
|
||||
"fields": [
|
||||
{
|
||||
"layout": {
|
||||
"enum": {
|
||||
"dispatchKey": "0x0100000000000000000000000000000000000000000000000000000000000000",
|
||||
"variants": {
|
||||
"0": {
|
||||
"fields": []
|
||||
},
|
||||
"1": {
|
||||
"fields": []
|
||||
},
|
||||
"2": {
|
||||
"fields": []
|
||||
},
|
||||
"3": {
|
||||
"fields": []
|
||||
},
|
||||
"4": {
|
||||
"fields": []
|
||||
},
|
||||
"5": {
|
||||
"fields": []
|
||||
},
|
||||
"6": {
|
||||
"fields": []
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"name": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"2": {
|
||||
"fields": [
|
||||
{
|
||||
"layout": {
|
||||
"enum": {
|
||||
"dispatchKey": "0x0100000000000000000000000000000000000000000000000000000000000000",
|
||||
"variants": {
|
||||
"0": {
|
||||
"fields": [
|
||||
{
|
||||
"layout": {
|
||||
"cell": {
|
||||
"key": "0x0200000000000000000000000000000000000000000000000000000000000000",
|
||||
"ty": 1
|
||||
}
|
||||
},
|
||||
"name": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"1": {
|
||||
"fields": [
|
||||
{
|
||||
"layout": {
|
||||
"cell": {
|
||||
"key": "0x0200000000000000000000000000000000000000000000000000000000000000",
|
||||
"ty": 2
|
||||
}
|
||||
},
|
||||
"name": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"name": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"3": {
|
||||
"fields": [
|
||||
{
|
||||
"layout": {
|
||||
"enum": {
|
||||
"dispatchKey": "0x0100000000000000000000000000000000000000000000000000000000000000",
|
||||
"variants": {
|
||||
"0": {
|
||||
"fields": [
|
||||
{
|
||||
"layout": {
|
||||
"cell": {
|
||||
"key": "0x0200000000000000000000000000000000000000000000000000000000000000",
|
||||
"ty": 1
|
||||
}
|
||||
},
|
||||
"name": "value"
|
||||
}
|
||||
]
|
||||
},
|
||||
"1": {
|
||||
"fields": [
|
||||
{
|
||||
"layout": {
|
||||
"cell": {
|
||||
"key": "0x0200000000000000000000000000000000000000000000000000000000000000",
|
||||
"ty": 2
|
||||
}
|
||||
},
|
||||
"name": "value"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"name": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"4": {
|
||||
"fields": [
|
||||
{
|
||||
"layout": {
|
||||
"enum": {
|
||||
"dispatchKey": "0x0100000000000000000000000000000000000000000000000000000000000000",
|
||||
"variants": {
|
||||
"0": {
|
||||
"fields": []
|
||||
},
|
||||
"1": {
|
||||
"fields": []
|
||||
},
|
||||
"2": {
|
||||
"fields": []
|
||||
},
|
||||
"3": {
|
||||
"fields": []
|
||||
},
|
||||
"4": {
|
||||
"fields": [
|
||||
{
|
||||
"layout": {
|
||||
"cell": {
|
||||
"key": "0x0200000000000000000000000000000000000000000000000000000000000000",
|
||||
"ty": 3
|
||||
}
|
||||
},
|
||||
"name": "r"
|
||||
},
|
||||
{
|
||||
"layout": {
|
||||
"cell": {
|
||||
"key": "0x0300000000000000000000000000000000000000000000000000000000000000",
|
||||
"ty": 3
|
||||
}
|
||||
},
|
||||
"name": "g"
|
||||
},
|
||||
{
|
||||
"layout": {
|
||||
"cell": {
|
||||
"key": "0x0400000000000000000000000000000000000000000000000000000000000000",
|
||||
"ty": 3
|
||||
}
|
||||
},
|
||||
"name": "b"
|
||||
}
|
||||
]
|
||||
},
|
||||
"5": {
|
||||
"fields": [
|
||||
{
|
||||
"layout": {
|
||||
"cell": {
|
||||
"key": "0x0200000000000000000000000000000000000000000000000000000000000000",
|
||||
"ty": 3
|
||||
}
|
||||
},
|
||||
"name": "r"
|
||||
},
|
||||
{
|
||||
"layout": {
|
||||
"cell": {
|
||||
"key": "0x0300000000000000000000000000000000000000000000000000000000000000",
|
||||
"ty": 3
|
||||
}
|
||||
},
|
||||
"name": "g"
|
||||
},
|
||||
{
|
||||
"layout": {
|
||||
"cell": {
|
||||
"key": "0x0400000000000000000000000000000000000000000000000000000000000000",
|
||||
"ty": 3
|
||||
}
|
||||
},
|
||||
"name": "b"
|
||||
},
|
||||
{
|
||||
"layout": {
|
||||
"cell": {
|
||||
"key": "0x0500000000000000000000000000000000000000000000000000000000000000",
|
||||
"ty": 3
|
||||
}
|
||||
},
|
||||
"name": "a"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"name": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"name": "last"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"types": [
|
||||
{
|
||||
"def": {
|
||||
"primitive": "i32"
|
||||
}
|
||||
},
|
||||
{
|
||||
"def": {
|
||||
"primitive": "u32"
|
||||
}
|
||||
},
|
||||
{
|
||||
"def": {
|
||||
"primitive": "u8"
|
||||
}
|
||||
},
|
||||
{
|
||||
"def": {
|
||||
"variant": {
|
||||
"variants": [
|
||||
{
|
||||
"name": "None"
|
||||
},
|
||||
{
|
||||
"fields": [
|
||||
{
|
||||
"type": 5
|
||||
}
|
||||
],
|
||||
"name": "Weekday"
|
||||
},
|
||||
{
|
||||
"fields": [
|
||||
{
|
||||
"type": 6
|
||||
}
|
||||
],
|
||||
"name": "TupleMaybeSigned"
|
||||
},
|
||||
{
|
||||
"fields": [
|
||||
{
|
||||
"type": 7
|
||||
}
|
||||
],
|
||||
"name": "NamedMaybeSigned"
|
||||
},
|
||||
{
|
||||
"fields": [
|
||||
{
|
||||
"type": 8
|
||||
}
|
||||
],
|
||||
"name": "Color"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"path": [
|
||||
"enum_example",
|
||||
"enum_example",
|
||||
"Variant"
|
||||
]
|
||||
},
|
||||
{
|
||||
"def": {
|
||||
"variant": {
|
||||
"variants": [
|
||||
{
|
||||
"discriminant": 0,
|
||||
"name": "Monday"
|
||||
},
|
||||
{
|
||||
"discriminant": 1,
|
||||
"name": "Tuesday"
|
||||
},
|
||||
{
|
||||
"discriminant": 2,
|
||||
"name": "Wednesday"
|
||||
},
|
||||
{
|
||||
"discriminant": 3,
|
||||
"name": "Thursday"
|
||||
},
|
||||
{
|
||||
"discriminant": 4,
|
||||
"name": "Friday"
|
||||
},
|
||||
{
|
||||
"discriminant": 5,
|
||||
"name": "Saturday"
|
||||
},
|
||||
{
|
||||
"discriminant": 6,
|
||||
"name": "Sunday"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"path": [
|
||||
"enum_example",
|
||||
"enum_example",
|
||||
"Weekday"
|
||||
]
|
||||
},
|
||||
{
|
||||
"def": {
|
||||
"variant": {
|
||||
"variants": [
|
||||
{
|
||||
"fields": [
|
||||
{
|
||||
"type": 1
|
||||
}
|
||||
],
|
||||
"name": "Signed"
|
||||
},
|
||||
{
|
||||
"fields": [
|
||||
{
|
||||
"type": 2
|
||||
}
|
||||
],
|
||||
"name": "Unsigned"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"path": [
|
||||
"enum_example",
|
||||
"enum_example",
|
||||
"TupleMaybeSigned"
|
||||
]
|
||||
},
|
||||
{
|
||||
"def": {
|
||||
"variant": {
|
||||
"variants": [
|
||||
{
|
||||
"fields": [
|
||||
{
|
||||
"name": "value",
|
||||
"type": 1
|
||||
}
|
||||
],
|
||||
"name": "Signed"
|
||||
},
|
||||
{
|
||||
"fields": [
|
||||
{
|
||||
"name": "value",
|
||||
"type": 2
|
||||
}
|
||||
],
|
||||
"name": "Unsigned"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"path": [
|
||||
"enum_example",
|
||||
"enum_example",
|
||||
"NamedMaybeSigned"
|
||||
]
|
||||
},
|
||||
{
|
||||
"def": {
|
||||
"variant": {
|
||||
"variants": [
|
||||
{
|
||||
"name": "Red"
|
||||
},
|
||||
{
|
||||
"name": "Blue"
|
||||
},
|
||||
{
|
||||
"name": "Green"
|
||||
},
|
||||
{
|
||||
"name": "Yellow"
|
||||
},
|
||||
{
|
||||
"fields": [
|
||||
{
|
||||
"name": "r",
|
||||
"type": 3
|
||||
},
|
||||
{
|
||||
"name": "g",
|
||||
"type": 3
|
||||
},
|
||||
{
|
||||
"name": "b",
|
||||
"type": 3
|
||||
}
|
||||
],
|
||||
"name": "Rgb"
|
||||
},
|
||||
{
|
||||
"fields": [
|
||||
{
|
||||
"name": "r",
|
||||
"type": 3
|
||||
},
|
||||
{
|
||||
"name": "g",
|
||||
"type": 3
|
||||
},
|
||||
{
|
||||
"name": "b",
|
||||
"type": 3
|
||||
},
|
||||
{
|
||||
"name": "a",
|
||||
"type": 3
|
||||
}
|
||||
],
|
||||
"name": "Rgba"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"path": [
|
||||
"enum_example",
|
||||
"enum_example",
|
||||
"Color"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
@@ -1,5 +1,6 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { default as assetTransfer } from './assetTransfer.json';
|
||||
export { default as enumExample } from './enumExample.json';
|
||||
export { default as withString } from './withString.json';
|
||||
|
||||
@@ -1,44 +1,28 @@
|
||||
{
|
||||
"name": "@polkadot/api-derive",
|
||||
"version": "2.6.1",
|
||||
"version": "3.7.1",
|
||||
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
"Polkadot",
|
||||
"Promise",
|
||||
"RxJs"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [
|
||||
"Jaco Greeff <jacogr@gmail.com>"
|
||||
],
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
"license": "Apache-2.0",
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"registry": "https://registry.npmjs.org"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/polkadot-js/api.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/polkadot-js/api/issues"
|
||||
},
|
||||
"repository": "github:polkadot-js/api",
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.1",
|
||||
"@polkadot/api": "2.6.1",
|
||||
"@polkadot/rpc-core": "2.6.1",
|
||||
"@polkadot/types": "2.6.1",
|
||||
"@polkadot/util": "^4.0.1",
|
||||
"@polkadot/util-crypto": "^4.0.1",
|
||||
"bn.js": "^5.1.3",
|
||||
"memoizee": "^0.4.14",
|
||||
"rxjs": "^6.6.3"
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@polkadot/api": "3.7.1",
|
||||
"@polkadot/rpc-core": "3.7.1",
|
||||
"@polkadot/types": "3.7.1",
|
||||
"@polkadot/util": "^5.5.1",
|
||||
"@polkadot/util-crypto": "^5.5.1",
|
||||
"@polkadot/x-rxjs": "^5.5.1",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^4.0.1",
|
||||
"@polkadot/rpc-provider": "2.6.1"
|
||||
"@polkadot/keyring": "^5.5.1",
|
||||
"@polkadot/rpc-provider": "3.7.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { isU8a, assertReturn } from '@polkadot/util';
|
||||
import { assertReturn, isU8a } from '@polkadot/util';
|
||||
import { decodeAddress } from '@polkadot/util-crypto';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { AccountId, Address, Balance } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { DeriveAccountFlags } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Vec } from '@polkadot/types';
|
||||
import type { AccountId, Address, Balance } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveAccountFlags } from '../types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Vec } from '@polkadot/types';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
|
||||
import { AccountIdAndIndex } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { AccountIdAndIndex } from '../types';
|
||||
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { isU8a } from '@polkadot/util';
|
||||
import { decodeAddress } from '@polkadot/util-crypto';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
function retrieve (api: ApiInterfaceRx, address: Address | AccountId | AccountIndex | string | null | undefined): Observable<AccountIdAndIndex> {
|
||||
function retrieve (api: ApiInterfaceRx, address: Address | AccountId | AccountIndex | Uint8Array | string | null | undefined): Observable<AccountIdAndIndex> {
|
||||
try {
|
||||
// yes, this can fail, don't care too much, catch will catch it
|
||||
const decoded = isU8a(address)
|
||||
@@ -39,7 +40,7 @@ function retrieve (api: ApiInterfaceRx, address: Address | AccountId | AccountIn
|
||||
|
||||
/**
|
||||
* @name idAndIndex
|
||||
* @param {(Address | AccountId | AccountIndex | string | null)} address - An accounts address in various formats.
|
||||
* @param {(Address | AccountId | AccountIndex | Uint8Array | string | null)} address - An accounts address in various formats.
|
||||
* @description An array containing the [[AccountId]] and [[AccountIndex]] as optional values.
|
||||
* @example
|
||||
* <BR>
|
||||
@@ -50,7 +51,7 @@ function retrieve (api: ApiInterfaceRx, address: Address | AccountId | AccountIn
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function idAndIndex (instanceId: string, api: ApiInterfaceRx): (address?: Address | AccountId | AccountIndex | string | null) => Observable<AccountIdAndIndex> {
|
||||
return memo(instanceId, (address?: Address | AccountId | AccountIndex | string | null): Observable<AccountIdAndIndex> =>
|
||||
export function idAndIndex (instanceId: string, api: ApiInterfaceRx): (address?: Address | AccountId | AccountIndex | Uint8Array | string | null) => Observable<AccountIdAndIndex> {
|
||||
return memo(instanceId, (address?: Address | AccountId | AccountIndex | Uint8Array | string | null): Observable<AccountIdAndIndex> =>
|
||||
retrieve(api, address));
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId, AccountIndex } from '@polkadot/types/interfaces';
|
||||
import { AccountIndexes } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AccountId, AccountIndex } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { AccountIndexes } from '../types';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Data, Option } from '@polkadot/types';
|
||||
import type { AccountId, IdentityInfoAdditional, Registration } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveAccountRegistration, DeriveHasIdentity } from '../types';
|
||||
|
||||
import { isHex, u8aToString } from '@polkadot/util';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
const UNDEF_HEX = { toHex: () => undefined };
|
||||
|
||||
function dataAsString (data: Data): string | undefined {
|
||||
return data.isRaw
|
||||
? u8aToString(data.asRaw.toU8a(true))
|
||||
: data.isNone
|
||||
? undefined
|
||||
: data.toHex();
|
||||
}
|
||||
|
||||
function extractOther (additional: IdentityInfoAdditional[]): Record<string, string> {
|
||||
return additional.reduce((other: Record<string, string>, [_key, _value]): Record<string, string> => {
|
||||
const key = dataAsString(_key);
|
||||
const value = dataAsString(_value);
|
||||
|
||||
if (key && value) {
|
||||
other[key] = value;
|
||||
}
|
||||
|
||||
return other;
|
||||
}, {});
|
||||
}
|
||||
|
||||
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,
|
||||
displayParent: superOf && topDisplay,
|
||||
email: dataAsString(info.email),
|
||||
image: dataAsString(info.image),
|
||||
judgements,
|
||||
legal: dataAsString(info.legal),
|
||||
other: extractOther(info.additional),
|
||||
parent: superOf && superOf[0],
|
||||
pgp: info.pgpFingerprint.unwrapOr(UNDEF_HEX).toHex(),
|
||||
riot: dataAsString(info.riot),
|
||||
twitter: dataAsString(info.twitter),
|
||||
web: dataAsString(info.web)
|
||||
};
|
||||
}
|
||||
|
||||
function getParent (api: ApiInterfaceRx, identityOfOpt: Option<Registration> | undefined, superOfOpt: Option<ITuple<[AccountId, Data]>> | undefined): 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]);
|
||||
}
|
||||
|
||||
function getBase (api: ApiInterfaceRx, accountId?: AccountId | Uint8Array | string): Observable<[Option<Registration> | undefined, Option<ITuple<[AccountId, Data]>> | undefined]> {
|
||||
return accountId && api.query.identity?.identityOf
|
||||
? api.queryMulti<[Option<Registration>, Option<ITuple<[AccountId, Data]>>]>([
|
||||
[api.query.identity.identityOf, accountId],
|
||||
[api.query.identity.superOf, accountId]
|
||||
])
|
||||
: of([undefined, undefined]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name identity
|
||||
* @description Returns identity info for an account
|
||||
*/
|
||||
export function identity (instanceId: string, api: ApiInterfaceRx): (accountId?: AccountId | Uint8Array | string) => Observable<DeriveAccountRegistration> {
|
||||
return memo(instanceId, (accountId?: AccountId | Uint8Array | string): Observable<DeriveAccountRegistration> =>
|
||||
getBase(api, accountId).pipe(
|
||||
switchMap(([identityOfOpt, superOfOpt]) => getParent(api, identityOfOpt, superOfOpt)),
|
||||
map(([identityOfOpt, superOf]) => extractIdentity(identityOfOpt, superOf))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function hasIdentity (instanceId: string, api: ApiInterfaceRx): (accountId: AccountId | Uint8Array | string) => Observable<DeriveHasIdentity> {
|
||||
return memo(instanceId, (accountId: AccountId | Uint8Array | string): Observable<DeriveHasIdentity> =>
|
||||
api.derive.accounts.hasIdentityMulti([accountId]).pipe(
|
||||
map(([first]) => first)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function hasIdentityMulti (instanceId: string, api: ApiInterfaceRx): (accountIds: (AccountId | Uint8Array | string)[]) => Observable<DeriveHasIdentity[]> {
|
||||
return memo(instanceId, (accountIds: (AccountId | Uint8Array | string)[]): Observable<DeriveHasIdentity[]> =>
|
||||
api.query.identity?.identityOf
|
||||
? combineLatest([
|
||||
api.query.identity.identityOf.multi<Option<Registration>>(accountIds),
|
||||
api.query.identity.superOf.multi<Option<ITuple<[AccountId, Data]>>>(accountIds)
|
||||
]).pipe(
|
||||
map(([identities, supers]) =>
|
||||
identities.map((identityOfOpt, index): DeriveHasIdentity => {
|
||||
const superOfOpt = supers[index];
|
||||
const parentId = superOfOpt && superOfOpt.isSome
|
||||
? superOfOpt.unwrap()[0].toString()
|
||||
: undefined;
|
||||
let display: string | undefined;
|
||||
|
||||
if (identityOfOpt && identityOfOpt.isSome) {
|
||||
const value = dataAsString(identityOfOpt.unwrap().info.display);
|
||||
|
||||
if (value && !isHex(value)) {
|
||||
display = value;
|
||||
}
|
||||
}
|
||||
|
||||
return { display, hasIdentity: !!(display || parentId), parentId };
|
||||
})
|
||||
)
|
||||
)
|
||||
: of(accountIds.map(() => ({ hasIdentity: false })))
|
||||
);
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './accountId';
|
||||
export * from './flags';
|
||||
export * from './idAndIndex';
|
||||
export * from './idToIndex';
|
||||
export * from './identity';
|
||||
export * from './indexToId';
|
||||
export * from './indexes';
|
||||
export * from './info';
|
||||
|
||||
@@ -1,40 +1,17 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId, AccountIndex, BalanceOf } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Option } from '@polkadot/types';
|
||||
import type { AccountId, AccountIndex, BalanceOf } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map, startWith } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { ENUMSET_SIZE } from '@polkadot/types/generic/AccountIndex';
|
||||
import { Option, Vec } from '@polkadot/types';
|
||||
import { isFunction } from '@polkadot/util';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
function queryEnumSet (api: ApiInterfaceRx, _accountIndex: AccountIndex | string): Observable<AccountId | undefined> {
|
||||
const accountIndex = _accountIndex instanceof api.registry.createClass('AccountIndex')
|
||||
? _accountIndex
|
||||
: api.registry.createType('AccountIndex', _accountIndex);
|
||||
|
||||
return api.query.indices.enumSet<Vec<AccountId>>(accountIndex.div(ENUMSET_SIZE)).pipe(
|
||||
startWith([]),
|
||||
map((accounts): AccountId | undefined =>
|
||||
(accounts || [])[accountIndex.mod(ENUMSET_SIZE).toNumber()]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// current
|
||||
function query (api: ApiInterfaceRx, accountIndex: AccountIndex | string): Observable<AccountId | undefined> {
|
||||
return api.query.indices.accounts<Option<ITuple<[AccountId, BalanceOf]>>>(accountIndex).pipe(
|
||||
map((optResult): AccountId | undefined =>
|
||||
optResult.unwrapOr([])[0]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name indexToId
|
||||
* @param {( AccountIndex | string )} accountIndex - An accounts index in different formats.
|
||||
@@ -51,9 +28,11 @@ function query (api: ApiInterfaceRx, accountIndex: AccountIndex | string): Obser
|
||||
export function indexToId (instanceId: string, api: ApiInterfaceRx): (accountIndex: AccountIndex | string) => Observable<AccountId | undefined> {
|
||||
return memo(instanceId, (accountIndex: AccountIndex | string): Observable<AccountId | undefined> =>
|
||||
api.query.indices
|
||||
? isFunction(api.query.indices.accounts)
|
||||
? query(api, accountIndex)
|
||||
: queryEnumSet(api, accountIndex)
|
||||
? api.query.indices.accounts<Option<ITuple<[AccountId, BalanceOf]>>>(accountIndex).pipe(
|
||||
map((optResult): AccountId | undefined =>
|
||||
optResult.unwrapOr([])[0]
|
||||
)
|
||||
)
|
||||
: of(undefined)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,53 +1,23 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { AccountId, AccountIndex } from '@polkadot/types/interfaces';
|
||||
import { AccountIndexes } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { AccountIndexes } from '../types';
|
||||
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map, startWith, switchMap } from 'rxjs/operators';
|
||||
import { ENUMSET_SIZE } from '@polkadot/types/generic/AccountIndex';
|
||||
import { Vec } from '@polkadot/types';
|
||||
import { isFunction } from '@polkadot/util';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map, startWith } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
const enumsetSize = ENUMSET_SIZE.toNumber();
|
||||
|
||||
let indicesCache: AccountIndexes | null = null;
|
||||
|
||||
function queryEnumSet (api: ApiInterfaceRx): Observable<AccountIndexes> {
|
||||
return api.query.indices.nextEnumSet<AccountIndex>().pipe(
|
||||
// use the nextEnumSet (which is a counter of the number of sets) to construct
|
||||
// a range of values to query [0, 1, 2, ...]. Retrieve the full enum set for the
|
||||
// specific index - each query can return up to ENUMSET_SIZE (64) records, each
|
||||
// containing an AccountId
|
||||
switchMap((next: AccountIndex): Observable<Vec<AccountId>[]> =>
|
||||
api.query.indices.enumSet.multi<Vec<AccountId>>([...Array(next.toNumber() + 1).keys()])
|
||||
),
|
||||
map((all: AccountId[][]): AccountIndexes =>
|
||||
all.reduce((indexes: 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;
|
||||
|
||||
indexes[accountId.toString()] = api.registry.createType('AccountIndex', index);
|
||||
});
|
||||
|
||||
return indexes;
|
||||
}, {})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function queryAccounts (api: ApiInterfaceRx): Observable<AccountIndexes> {
|
||||
return api.query.indices.accounts.entries().pipe(
|
||||
map((entries): AccountIndexes =>
|
||||
entries.reduce((indexes: AccountIndexes, [key, idOpt]): AccountIndexes => {
|
||||
if (idOpt.isSome) {
|
||||
indexes[idOpt.unwrap()[0].toString()] = key.args[0] as AccountIndex;
|
||||
indexes[idOpt.unwrap()[0].toString()] = key.args[0];
|
||||
}
|
||||
|
||||
return indexes;
|
||||
@@ -77,9 +47,7 @@ export function indexes (instanceId: string, api: ApiInterfaceRx): () => Observa
|
||||
? of(indicesCache)
|
||||
: (
|
||||
api.query.indices
|
||||
? isFunction(api.query.indices.accounts)
|
||||
? queryAccounts(api).pipe(startWith({}))
|
||||
: queryEnumSet(api).pipe(startWith({}))
|
||||
? queryAccounts(api).pipe(startWith({}))
|
||||
: of({} as AccountIndexes)
|
||||
).pipe(
|
||||
map((indices): AccountIndexes => {
|
||||
|
||||
@@ -1,28 +1,19 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { AccountId, AccountIndex, Address, Balance, IdentityInfoAdditional, Registration } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { DeriveAccountInfo, DeriveAccountRegistration } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Bytes, Option, u32 } from '@polkadot/types';
|
||||
import type { AccountId, AccountIndex, Address, Balance } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveAccountInfo, DeriveAccountRegistration } from '../types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { Bytes, Data, Option, u32 } from '@polkadot/types';
|
||||
import { u8aToString } from '@polkadot/util';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
const UNDEF_HEX = { toHex: () => undefined };
|
||||
|
||||
function dataAsString (data: Data): string | undefined {
|
||||
return data.isRaw
|
||||
? u8aToString(data.asRaw.toU8a(true))
|
||||
: data.isNone
|
||||
? undefined
|
||||
: data.toHex();
|
||||
}
|
||||
|
||||
function retrieveNick (api: ApiInterfaceRx, accountId?: AccountId): Observable<string | undefined> {
|
||||
return ((
|
||||
accountId && api.query.nicks?.nameOf
|
||||
@@ -37,86 +28,17 @@ function retrieveNick (api: ApiInterfaceRx, accountId?: AccountId): Observable<s
|
||||
);
|
||||
}
|
||||
|
||||
function extractOther (additional: IdentityInfoAdditional[]): Record<string, string> {
|
||||
return additional.reduce((other: Record<string, string>, [_key, _value]): Record<string, string> => {
|
||||
const key = dataAsString(_key);
|
||||
const value = dataAsString(_value);
|
||||
|
||||
if (key && value) {
|
||||
other[key] = value;
|
||||
}
|
||||
|
||||
return other;
|
||||
}, {});
|
||||
}
|
||||
|
||||
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,
|
||||
displayParent: superOf && topDisplay,
|
||||
email: dataAsString(info.email),
|
||||
image: dataAsString(info.image),
|
||||
judgements,
|
||||
legal: dataAsString(info.legal),
|
||||
other: extractOther(info.additional),
|
||||
parent: superOf && superOf[0],
|
||||
pgp: info.pgpFingerprint.unwrapOr(UNDEF_HEX).toHex(),
|
||||
riot: dataAsString(info.riot),
|
||||
twitter: dataAsString(info.twitter),
|
||||
web: dataAsString(info.web)
|
||||
};
|
||||
}
|
||||
|
||||
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)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name info
|
||||
* @description Returns aux. info with regards to an account, current that includes the accountId, accountIndex and nickname
|
||||
*/
|
||||
export function info (instanceId: string, api: ApiInterfaceRx): (address?: AccountIndex | AccountId | Address | string | null) => Observable<DeriveAccountInfo> {
|
||||
return memo(instanceId, (address?: AccountIndex | AccountId | Address | string | null): Observable<DeriveAccountInfo> =>
|
||||
export function info (instanceId: string, api: ApiInterfaceRx): (address?: AccountIndex | AccountId | Address | Uint8Array | string | null) => Observable<DeriveAccountInfo> {
|
||||
return memo(instanceId, (address?: AccountIndex | AccountId | Address | Uint8Array | string | null): Observable<DeriveAccountInfo> =>
|
||||
api.derive.accounts.idAndIndex(address).pipe(
|
||||
switchMap(([accountId, accountIndex]): Observable<[Partial<DeriveAccountInfo>, DeriveAccountRegistration, string?]> =>
|
||||
combineLatest([
|
||||
of({ accountId, accountIndex }),
|
||||
retrieveIdentity(api, accountId),
|
||||
api.derive.accounts.identity(accountId),
|
||||
retrieveNick(api, accountId)
|
||||
])
|
||||
),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId, AccountIndex, RegistrationJudgement } from '@polkadot/types/interfaces';
|
||||
import type { AccountId, AccountIndex, RegistrationJudgement } from '@polkadot/types/interfaces';
|
||||
|
||||
export type AccountIdAndIndex = [AccountId?, AccountIndex?];
|
||||
|
||||
@@ -35,3 +35,9 @@ export interface DeriveAccountInfo {
|
||||
identity: DeriveAccountRegistration;
|
||||
nickname?: string;
|
||||
}
|
||||
|
||||
export interface DeriveHasIdentity {
|
||||
display?: string;
|
||||
hasIdentity: boolean;
|
||||
parentId?: string;
|
||||
}
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId, AccountData, AccountIndex, AccountInfo, Address, Balance, Index } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { DeriveBalancesAccount } from '../types';
|
||||
import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
|
||||
import type { AccountData, AccountId, AccountIndex, AccountInfo, Address, Balance, Index } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveBalancesAccount, DeriveBalancesAccountData } from '../types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { isFunction } from '@polkadot/util';
|
||||
import { assert, isFunction } from '@polkadot/util';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type Result = [Balance, Balance, Balance, Balance, Index];
|
||||
type BalanceResult = [Balance, Balance, Balance, Balance];
|
||||
|
||||
function calcBalances (api: ApiInterfaceRx, [accountId, [freeBalance, reservedBalance, frozenFee, frozenMisc, accountNonce]]: [AccountId, Result]): DeriveBalancesAccount {
|
||||
type Result = [Index, BalanceResult[]];
|
||||
|
||||
function getBalance (api: ApiInterfaceRx, [freeBalance, reservedBalance, frozenFee, frozenMisc]: BalanceResult): DeriveBalancesAccountData {
|
||||
return {
|
||||
accountId,
|
||||
accountNonce,
|
||||
freeBalance,
|
||||
frozenFee,
|
||||
frozenMisc,
|
||||
@@ -26,6 +27,19 @@ function calcBalances (api: ApiInterfaceRx, [accountId, [freeBalance, reservedBa
|
||||
};
|
||||
}
|
||||
|
||||
function calcBalances (api: ApiInterfaceRx, [accountId, [accountNonce, balances]]: [AccountId, Result]): DeriveBalancesAccount {
|
||||
const primary = balances[0];
|
||||
|
||||
assert(primary, 'No balances retrieved for account');
|
||||
|
||||
return {
|
||||
accountId,
|
||||
accountNonce,
|
||||
additional: balances.filter((_, index) => index !== 0).map((b) => getBalance(api, b)),
|
||||
...getBalance(api, primary)
|
||||
};
|
||||
}
|
||||
|
||||
// old
|
||||
function queryBalancesFree (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
||||
return api.queryMulti<[Balance, Balance, Index]>([
|
||||
@@ -33,21 +47,25 @@ function queryBalancesFree (api: ApiInterfaceRx, accountId: AccountId): Observab
|
||||
[api.query.balances.reservedBalance, accountId],
|
||||
[api.query.system.accountNonce, accountId]
|
||||
]).pipe(
|
||||
map(([freeBalance, reservedBalance, accountNonce]): Result =>
|
||||
[freeBalance, reservedBalance, api.registry.createType('Balance'), api.registry.createType('Balance'), accountNonce]
|
||||
)
|
||||
map(([freeBalance, reservedBalance, accountNonce]): Result => [
|
||||
accountNonce,
|
||||
[[freeBalance, reservedBalance, api.registry.createType('Balance'), api.registry.createType('Balance')]]
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
||||
return api.queryMulti<[AccountData, Index]>([
|
||||
[api.query.balances.account, accountId],
|
||||
[api.query.system.accountNonce, accountId]
|
||||
]).pipe(
|
||||
map(([{ feeFrozen, free, miscFrozen, reserved }, accountNonce]): Result =>
|
||||
[free, reserved, feeFrozen, miscFrozen, accountNonce]
|
||||
function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId, modules: string[] = ['balances']): Observable<Result> {
|
||||
const balances = modules.map((m): QueryableStorageMultiArg<'rxjs'> => [api.query[m].account, accountId]);
|
||||
const extract = (data: AccountData[]) =>
|
||||
data.map(({ feeFrozen, free, miscFrozen, reserved }): BalanceResult => [free, reserved, feeFrozen, miscFrozen]);
|
||||
|
||||
return isFunction(api.query.system.account)
|
||||
? api.queryMulti<[AccountInfo, ...(AccountData[])]>([[api.query.system.account, accountId], ...balances]).pipe(
|
||||
map(([{ nonce }, ...balances]): Result => [nonce, extract(balances)])
|
||||
)
|
||||
);
|
||||
: api.queryMulti<[Index, ...(AccountData[])]>([[api.query.system.accountNonce, accountId], ...balances]).pipe(
|
||||
map(([nonce, ...balances]): Result => [nonce, extract(balances)])
|
||||
);
|
||||
}
|
||||
|
||||
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
||||
@@ -59,7 +77,7 @@ function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Re
|
||||
: (infoOrTuple as [Index, AccountData])[1];
|
||||
const accountNonce = (infoOrTuple as AccountInfo).nonce || (infoOrTuple as [Index, AccountData])[0];
|
||||
|
||||
return [free, reserved, feeFrozen, miscFrozen, accountNonce];
|
||||
return [accountNonce, [[free, reserved, feeFrozen, miscFrozen]]];
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -80,19 +98,29 @@ function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Re
|
||||
* ```
|
||||
*/
|
||||
export function account (instanceId: string, api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAccount> {
|
||||
const balanceInstances = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), 'balances');
|
||||
|
||||
return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAccount> =>
|
||||
api.derive.accounts.accountId(address).pipe(
|
||||
switchMap((accountId): Observable<[AccountId, Result]> =>
|
||||
(accountId
|
||||
? combineLatest([
|
||||
of(accountId),
|
||||
isFunction(api.query.system.account)
|
||||
? queryCurrent(api, accountId)
|
||||
: isFunction(api.query.balances.account)
|
||||
? queryBalancesAccount(api, accountId)
|
||||
: queryBalancesFree(api, accountId)
|
||||
balanceInstances
|
||||
? queryBalancesAccount(api, accountId, balanceInstances)
|
||||
: isFunction(api.query.system.account)
|
||||
? queryCurrent(api, accountId)
|
||||
: isFunction(api.query.balances.account)
|
||||
? queryBalancesAccount(api, accountId)
|
||||
: queryBalancesFree(api, accountId)
|
||||
])
|
||||
: of([
|
||||
api.registry.createType('AccountId'),
|
||||
[
|
||||
api.registry.createType('Index'),
|
||||
[[api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Balance')]]
|
||||
]
|
||||
])
|
||||
: of([api.registry.createType('AccountId'), [api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Index')]])
|
||||
)
|
||||
),
|
||||
map((result): DeriveBalancesAccount => calcBalances(api, result))
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId, AccountIndex, Address, Balance, BalanceLock, BalanceLockTo212, BlockNumber, VestingInfo, VestingSchedule } from '@polkadot/types/interfaces';
|
||||
import { DeriveBalancesAccount, DeriveBalancesAll } from '../types';
|
||||
import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
|
||||
import type { Option, Vec } from '@polkadot/types';
|
||||
import type { AccountId, AccountIndex, Address, Balance, BalanceLock, BalanceLockTo212, BlockNumber, VestingInfo, VestingSchedule } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveBalancesAccount, DeriveBalancesAccountData, DeriveBalancesAll, DeriveBalancesAllAccountData } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
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 { bnMax, isFunction } from '@polkadot/util';
|
||||
|
||||
import { bnMax } from '@polkadot/util';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type ResultBalance = [VestingInfo | null, (BalanceLock | BalanceLockTo212)[]];
|
||||
type BalanceLocksEntry = Vec<BalanceLock | BalanceLockTo212>;
|
||||
type BalanceLocks = BalanceLocksEntry[];
|
||||
type ResultBalance = [VestingInfo | null, ((BalanceLock | BalanceLockTo212)[])[]];
|
||||
type Result = [DeriveBalancesAccount, BlockNumber, ResultBalance];
|
||||
|
||||
interface AllLocked {
|
||||
@@ -48,8 +52,21 @@ function calcLocked (api: ApiInterfaceRx, bestNumber: BlockNumber, locks: (Balan
|
||||
return { allLocked, lockedBalance, lockedBreakdown, vestingLocked };
|
||||
}
|
||||
|
||||
function calcBalances (api: ApiInterfaceRx, [{ accountId, accountNonce, freeBalance, frozenFee, frozenMisc, reservedBalance, votingBalance }, bestNumber, [vesting, locks]]: Result): DeriveBalancesAll {
|
||||
function calcShared (api: ApiInterfaceRx, bestNumber: BlockNumber, data: DeriveBalancesAccountData, locks: (BalanceLock | BalanceLockTo212)[]): DeriveBalancesAllAccountData {
|
||||
const { allLocked, lockedBalance, lockedBreakdown, vestingLocked } = calcLocked(api, bestNumber, locks);
|
||||
const availableBalance = api.registry.createType('Balance', allLocked ? 0 : bnMax(new BN(0), data.freeBalance.sub(lockedBalance)));
|
||||
|
||||
return {
|
||||
...data,
|
||||
availableBalance,
|
||||
lockedBalance,
|
||||
lockedBreakdown,
|
||||
vestingLocked
|
||||
};
|
||||
}
|
||||
|
||||
function calcBalances (api: ApiInterfaceRx, [data, bestNumber, [vesting, allLocks]]: Result): DeriveBalancesAll {
|
||||
const shared = calcShared(api, bestNumber, data, allLocks[0]);
|
||||
// Calculate the vesting balances,
|
||||
// - offset = balance locked at startingBlock
|
||||
// - perBlock is the unlock amount
|
||||
@@ -57,29 +74,21 @@ function calcBalances (api: ApiInterfaceRx, [{ accountId, accountNonce, freeBala
|
||||
const isStarted = bestNumber.gt(startingBlock);
|
||||
const vestedNow = isStarted ? perBlock.mul(bestNumber.sub(startingBlock)) : new BN(0);
|
||||
const vestedBalance = vestedNow.gt(vestingTotal) ? vestingTotal : api.registry.createType('Balance', vestedNow);
|
||||
const isVesting = isStarted && !vestingLocked.isZero();
|
||||
const vestedClaimable = api.registry.createType('Balance', isVesting ? vestingLocked.sub(vestingTotal.sub(vestedBalance)) : 0);
|
||||
const availableBalance = api.registry.createType('Balance', allLocked ? 0 : bnMax(new BN(0), freeBalance.sub(lockedBalance)));
|
||||
const isVesting = isStarted && !shared.vestingLocked.isZero();
|
||||
const vestedClaimable = api.registry.createType('Balance', isVesting ? shared.vestingLocked.sub(vestingTotal.sub(vestedBalance)) : 0);
|
||||
const vestingEndBlock = api.registry.createType('BlockNumber', isVesting ? vestingTotal.div(perBlock).add(startingBlock) : 0);
|
||||
|
||||
return {
|
||||
accountId,
|
||||
accountNonce,
|
||||
availableBalance,
|
||||
freeBalance,
|
||||
frozenFee,
|
||||
frozenMisc,
|
||||
...shared,
|
||||
accountId: data.accountId,
|
||||
accountNonce: data.accountNonce,
|
||||
additional: allLocks.filter((_, index) => index !== 0).map((l, index) => calcShared(api, bestNumber, data.additional[index], l)),
|
||||
isVesting,
|
||||
lockedBalance,
|
||||
lockedBreakdown,
|
||||
reservedBalance,
|
||||
vestedBalance,
|
||||
vestedClaimable,
|
||||
vestingEndBlock,
|
||||
vestingLocked,
|
||||
vestingPerBlock: perBlock,
|
||||
vestingTotal,
|
||||
votingBalance
|
||||
vestingTotal
|
||||
};
|
||||
}
|
||||
|
||||
@@ -98,28 +107,37 @@ function queryOld (api: ApiInterfaceRx, accountId: AccountId): Observable<Result
|
||||
vestingNew = api.registry.createType('VestingInfo', { locked, perBlock, startingBlock });
|
||||
}
|
||||
|
||||
return [vestingNew, locks];
|
||||
return [vestingNew, [locks]];
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// current (balances vesting)
|
||||
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<ResultBalance> {
|
||||
// current (balances, vesting)
|
||||
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId, balanceInstances: string[] = ['balances']): Observable<ResultBalance> {
|
||||
const lockCalls = balanceInstances.map((m) => api.query[m].locks);
|
||||
const lockEmpty = lockCalls.map((c) => !c);
|
||||
const lockQueries = lockCalls.filter((c) => c).map((c): QueryableStorageMultiArg<'rxjs'> => [c, accountId]);
|
||||
|
||||
return (
|
||||
api.query.vesting?.vesting
|
||||
? api.queryMulti<[Vec<BalanceLock>, Option<VestingInfo>]>([
|
||||
[api.query.balances.locks, accountId],
|
||||
[api.query.vesting.vesting, accountId]
|
||||
? api.queryMulti<[Option<VestingInfo>, ...BalanceLocks]>([
|
||||
[api.query.vesting.vesting, accountId],
|
||||
...lockQueries
|
||||
])
|
||||
: api.query.balances.locks(accountId).pipe(
|
||||
map((locks): [Vec<BalanceLock>, Option<VestingInfo>] =>
|
||||
[locks, api.registry.createType('Option<VestingInfo>')]
|
||||
// TODO We need to check module instances here as well, not only the balances module
|
||||
: lockQueries.length
|
||||
? api.queryMulti<[...(Vec<BalanceLock>)[]]>(lockQueries).pipe(
|
||||
map((locks): [Option<VestingInfo>, ...BalanceLocks] =>
|
||||
[api.registry.createType('Option<VestingInfo>'), ...locks]
|
||||
)
|
||||
)
|
||||
)
|
||||
: of([api.registry.createType('Option<VestingInfo>')] as [Option<VestingInfo>])
|
||||
).pipe(
|
||||
map(([locks, optVesting]): ResultBalance =>
|
||||
[optVesting.unwrapOr(null), locks]
|
||||
)
|
||||
map(([optVesting, ...locks]): ResultBalance => {
|
||||
let offset = -1;
|
||||
|
||||
return [optVesting.unwrapOr(null), lockEmpty.map((e) => e ? api.registry.createType('Vec<BalanceLock>') : locks[++offset])];
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -139,6 +157,8 @@ function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Re
|
||||
* ```
|
||||
*/
|
||||
export function all (instanceId: string, api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAll> {
|
||||
const balanceInstances = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), 'balances');
|
||||
|
||||
return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAll> =>
|
||||
api.derive.balances.account(address).pipe(
|
||||
switchMap((account): Observable<Result> =>
|
||||
@@ -146,11 +166,11 @@ export function all (instanceId: string, api: ApiInterfaceRx): (address: Account
|
||||
? combineLatest([
|
||||
of(account),
|
||||
api.derive.chain.bestNumber(),
|
||||
isFunction(api.query.system.account) || isFunction(api.query.balances.account)
|
||||
? queryCurrent(api, account.accountId)
|
||||
api.query.system?.account || api.query.balances?.account
|
||||
? queryCurrent(api, account.accountId, balanceInstances)
|
||||
: queryOld(api, account.accountId)
|
||||
])
|
||||
: of([account, api.registry.createType('BlockNumber'), [null, api.registry.createType('Vec<BalanceLock>')]])
|
||||
: of([account, api.registry.createType('BlockNumber'), [null, []]])
|
||||
)
|
||||
),
|
||||
map((result): DeriveBalancesAll => calcBalances(api, result))
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Balance } from '@polkadot/types/interfaces';
|
||||
import { DeriveFees } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Balance } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveFees } from '../types';
|
||||
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { all } from './all';
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
|
||||
import { DeriveBalancesAccount } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveBalancesAccount } from '../types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx, SubmittableExtrinsic } from '@polkadot/api/types';
|
||||
import type { Bytes, Option, StorageKey } from '@polkadot/types';
|
||||
import type { Bounty, BountyIndex, ProposalIndex } from '@polkadot/types/interfaces';
|
||||
import type { Codec, InterfaceTypes } from '@polkadot/types/types';
|
||||
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import { DeriveCollectiveProposal } from '@polkadot/api-derive/types';
|
||||
import { Proposal } from '@polkadot/types/interfaces';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
|
||||
import { BountyFactory } from '../../test/bountyFactory';
|
||||
import { BytesFactory } from '../../test/bytesFactory';
|
||||
import { createApiWithAugmentations } from '../../test/helpers';
|
||||
import { ProposalFactory } from '../../test/proposalFactory';
|
||||
import { bounties } from '.';
|
||||
|
||||
const DEFAULT_PROPOSER = '5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM';
|
||||
|
||||
describe('bounties derive', () => {
|
||||
let storageKey: (index: number) => StorageKey;
|
||||
let defaultBounty: () => Bounty;
|
||||
let emptyOption: <T extends Codec> (typeName: keyof InterfaceTypes) => Option<T>;
|
||||
let optionOf: <T extends Codec> (value: T)=> Option<T>;
|
||||
let bountyIndex: (index: number) => BountyIndex;
|
||||
let proposalIndex: (index: number) => ProposalIndex;
|
||||
let bytes: (value: string) => Bytes;
|
||||
let api: ApiPromise;
|
||||
let createProposal: (method: SubmittableExtrinsic<'promise'>) => Proposal;
|
||||
let defaultMockApi: ApiInterfaceRx;
|
||||
|
||||
beforeAll(() => {
|
||||
api = createApiWithAugmentations();
|
||||
|
||||
({ bountyIndex, defaultBounty, emptyOption, optionOf, storageKey } = new BountyFactory(api));
|
||||
({ bytes } = new BytesFactory(api.registry));
|
||||
({ createProposal, proposalIndex } = new ProposalFactory(api));
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
defaultMockApi = {
|
||||
derive: {
|
||||
council: {
|
||||
proposals: () => of([] as DeriveCollectiveProposal[])
|
||||
}
|
||||
},
|
||||
query: {
|
||||
council: {
|
||||
proposalCount: () => of(proposalIndex(2))
|
||||
},
|
||||
treasury: {
|
||||
bounties: {
|
||||
keys: () => of([storageKey(0), storageKey(1)]),
|
||||
multi: () => of([optionOf(defaultBounty()), optionOf(defaultBounty())])
|
||||
},
|
||||
bountyCount: () => of(bountyIndex(2)),
|
||||
bountyDescriptions: {
|
||||
multi: () => of([
|
||||
optionOf(bytes('make polkadot even better')),
|
||||
optionOf(bytes('some other bounty'))
|
||||
])
|
||||
}
|
||||
}
|
||||
},
|
||||
tx: api.tx
|
||||
} as unknown as ApiInterfaceRx;
|
||||
});
|
||||
|
||||
it('creates storage key', function () {
|
||||
expect(storageKey(194).args[0].eq(194)).toBe(true);
|
||||
});
|
||||
|
||||
it('creates proposal', function () {
|
||||
expect(createProposal(api.tx.balances.transfer('5EYCAe5ijiYfyeZ2JJCGq56LmPyNRAKzpG4QkoQkkQNB5e6Z', 1))).toBeTruthy();
|
||||
});
|
||||
|
||||
it('combines bounties with descriptions', async () => {
|
||||
const mockApi = {
|
||||
...defaultMockApi,
|
||||
query: {
|
||||
...defaultMockApi.query,
|
||||
treasury: {
|
||||
bounties: {
|
||||
keys: () => of([storageKey(0), storageKey(2), storageKey(3)]),
|
||||
multi: () => of([optionOf(defaultBounty()), emptyOption('Bounty'), optionOf(defaultBounty())])
|
||||
},
|
||||
bountyCount: () => of(bountyIndex(3)),
|
||||
bountyDescriptions: {
|
||||
multi: () => of([
|
||||
optionOf(bytes('make polkadot even better')),
|
||||
optionOf(bytes('this will be totally ignored')),
|
||||
emptyOption('Bytes')
|
||||
])
|
||||
}
|
||||
}
|
||||
}
|
||||
} as unknown as ApiInterfaceRx;
|
||||
|
||||
const result = await bounties('', mockApi)().toPromise();
|
||||
|
||||
expect(result).toHaveLength(2);
|
||||
expect(result[0].bounty.proposer.toString()).toEqual(DEFAULT_PROPOSER);
|
||||
expect(result[0].description).toEqual('make polkadot even better');
|
||||
expect(result[0].index.eq(0)).toBe(true);
|
||||
expect(result[1].bounty.proposer.toString()).toEqual(DEFAULT_PROPOSER);
|
||||
expect(result[1].description).toEqual('');
|
||||
expect(result[1].index.eq(3)).toBe(true);
|
||||
});
|
||||
|
||||
it('returns motions', async () => {
|
||||
const result = await bounties('', defaultMockApi)().toPromise();
|
||||
|
||||
expect(result).toHaveLength(2);
|
||||
expect(result[0].proposals).toHaveLength(0);
|
||||
expect(result[1].proposals).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('when no council, returns bounties without motions', async () => {
|
||||
const mockApi = {
|
||||
...defaultMockApi,
|
||||
query: {
|
||||
...defaultMockApi.query,
|
||||
council: null
|
||||
}
|
||||
} as unknown as ApiInterfaceRx;
|
||||
|
||||
const result = await bounties('', mockApi)().toPromise();
|
||||
|
||||
expect(result).toHaveLength(2);
|
||||
expect(result[0].bounty.proposer.toString()).toEqual(DEFAULT_PROPOSER);
|
||||
expect(result[0].description).toEqual('make polkadot even better');
|
||||
expect(result[0].index.eq(0)).toBe(true);
|
||||
expect(result[0].proposals).toHaveLength(0);
|
||||
expect(result[1].bounty.proposer.toString()).toEqual(DEFAULT_PROPOSER);
|
||||
expect(result[1].description).toEqual('some other bounty');
|
||||
expect(result[1].index.eq(1)).toBe(true);
|
||||
expect(result[1].proposals).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('combines bounties with motions', async () => {
|
||||
const mockApi = {
|
||||
...defaultMockApi,
|
||||
derive: {
|
||||
council: {
|
||||
proposals: () => of([
|
||||
{ proposal: createProposal(api.tx.bounties.approveBounty(1)) },
|
||||
{ proposal: createProposal(api.tx.treasury.approveProposal(1)) }] as DeriveCollectiveProposal[])
|
||||
}
|
||||
}
|
||||
} as unknown as ApiInterfaceRx;
|
||||
|
||||
const result = await bounties('', mockApi)().toPromise();
|
||||
|
||||
expect(result).toHaveLength(2);
|
||||
expect(result[0].proposals).toHaveLength(0);
|
||||
expect(result[1].proposals).toHaveLength(1);
|
||||
expect(result[1].proposals[0].proposal.method).toEqual('approveBounty');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,61 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { DeriveBounties, DeriveCollectiveProposal } from '@polkadot/api-derive/types';
|
||||
import type { Bytes, Option, StorageKey } from '@polkadot/types';
|
||||
import type { Bounty, BountyIndex, ProposalIndex } from '@polkadot/types/interfaces';
|
||||
|
||||
import { memo } from '@polkadot/api-derive/util';
|
||||
import { combineLatest, Observable, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { filterBountiesProposals } from './helpers/filterBountyProposals';
|
||||
|
||||
type Result = [Option<Bounty>[], Option<Bytes>[], BountyIndex[], DeriveCollectiveProposal[]];
|
||||
|
||||
function parseResult ([maybeBounties, maybeDescriptions, ids, bountyProposals]: Result): DeriveBounties {
|
||||
const bounties: DeriveBounties = [];
|
||||
|
||||
maybeBounties.forEach((bounty, index) => {
|
||||
if (bounty.isSome) {
|
||||
bounties.push({
|
||||
bounty: bounty.unwrap(),
|
||||
description: maybeDescriptions[index].unwrapOrDefault().toUtf8(),
|
||||
index: ids[index],
|
||||
proposals: bountyProposals.filter((bountyProposal) => ids[index].eq(bountyProposal.proposal.args[0]))
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return bounties;
|
||||
}
|
||||
|
||||
export function bounties (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveBounties> {
|
||||
const bountyBase = api.query.bounties ? api.query.bounties : api.query.treasury;
|
||||
|
||||
return memo(instanceId, (): Observable<DeriveBounties> =>
|
||||
combineLatest([
|
||||
bountyBase.bountyCount<BountyIndex>(),
|
||||
api.query.council ? api.query.council.proposalCount<ProposalIndex>() : of(0)
|
||||
]).pipe(
|
||||
switchMap(() =>
|
||||
combineLatest([
|
||||
bountyBase.bounties.keys(),
|
||||
api.derive.council ? api.derive.council.proposals() : of([])
|
||||
])
|
||||
),
|
||||
switchMap(([keys, proposals]): Observable<Result> => {
|
||||
const ids = (keys as StorageKey<[BountyIndex]>[]).map(({ args: [id] }) => id);
|
||||
|
||||
return combineLatest([
|
||||
bountyBase.bounties.multi<Option<Bounty>>(ids),
|
||||
bountyBase.bountyDescriptions.multi<Option<Bytes>>(ids),
|
||||
of(ids),
|
||||
of(filterBountiesProposals(api, proposals))
|
||||
]);
|
||||
}),
|
||||
map(parseResult)
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { DeriveCollectiveProposal } from '@polkadot/api-derive/types';
|
||||
|
||||
export function filterBountiesProposals (api: ApiInterfaceRx, allProposals: DeriveCollectiveProposal[]): DeriveCollectiveProposal[] {
|
||||
const bountyTxBase = api.tx.bounties ? api.tx.bounties : api.tx.treasury;
|
||||
const bountyProposalCalls = [bountyTxBase.approveBounty, bountyTxBase.closeBounty, bountyTxBase.proposeCurator, bountyTxBase.unassignCurator];
|
||||
|
||||
return allProposals.filter((proposal) => bountyProposalCalls.find((bountyCall) => bountyCall.is(proposal.proposal)));
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './bounties';
|
||||
@@ -1,11 +1,11 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { BlockNumber } from '@polkadot/types/interfaces';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { BlockNumber } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { BlockNumber } from '@polkadot/types/interfaces';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { BlockNumber } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { BlockNumber } from '@polkadot/types/interfaces';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { BlockNumber } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { Observable, combineLatest } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { combineLatest } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { catchError, map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { SignedBlockExtended } from '../type';
|
||||
import { memo } from '../util';
|
||||
@@ -17,25 +18,26 @@ import { memo } from '../util';
|
||||
* <BR>
|
||||
*
|
||||
* ```javascript
|
||||
* const { author, number } = await api.derive.chain.getHeader('0x123...456');
|
||||
* const { author, block } = await api.derive.chain.getBlock('0x123...456');
|
||||
*
|
||||
* console.log(`block #${number} was authored by ${author}`);
|
||||
* console.log(`block #${block.header.number} was authored by ${author}`);
|
||||
* ```
|
||||
*/
|
||||
export function getHeader (instanceId: string, api: ApiInterfaceRx): (hash: Uint8Array | string) => Observable<SignedBlockExtended | undefined> {
|
||||
export function getBlock (instanceId: string, api: ApiInterfaceRx): (hash: Uint8Array | string) => Observable<SignedBlockExtended | undefined> {
|
||||
return memo(instanceId, (hash: Uint8Array | string): Observable<SignedBlockExtended | undefined> =>
|
||||
combineLatest([
|
||||
api.rpc.chain.getBlock(hash),
|
||||
api.query.system.events.at(hash),
|
||||
api.query.session
|
||||
? api.query.session.validators.at(hash)
|
||||
: of([])
|
||||
]).pipe(
|
||||
map(([signedBlock, validators]): SignedBlockExtended =>
|
||||
new SignedBlockExtended(api.registry, signedBlock, validators)
|
||||
map(([signedBlock, events, validators]): SignedBlockExtended =>
|
||||
new SignedBlockExtended(api.registry, signedBlock, events, 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
|
||||
// we supplied an invalid hash. (Due to defaults, storage will have an
|
||||
// empty value, so only the RPC is affected). So return undefined
|
||||
of()
|
||||
)
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { catchError, map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { HeaderExtended } from '../type';
|
||||
import { memo } from '../util';
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './bestNumber';
|
||||
export * from './bestNumberFinalized';
|
||||
export * from './bestNumberLag';
|
||||
export * from './getHeader';
|
||||
export * from './getBlock';
|
||||
export * from './subscribeNewBlocks';
|
||||
export * from './subscribeNewHeads';
|
||||
|
||||
@@ -1,32 +1,35 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { EventRecord, Hash, SignedBlock } from '@polkadot/types/interfaces';
|
||||
import { FullNewBlock } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AccountId, EventRecord, SignedBlock } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { SignedBlockExtended } from '../type';
|
||||
import { memo } from '../util';
|
||||
|
||||
/**
|
||||
* @name subscribeNewBlocks
|
||||
* @returns The latest block & events for that block
|
||||
*/
|
||||
export function subscribeNewBlocks (instanceId: string, api: ApiInterfaceRx): () => Observable<FullNewBlock> {
|
||||
return memo(instanceId, (): Observable<FullNewBlock> =>
|
||||
export function subscribeNewBlocks (instanceId: string, api: ApiInterfaceRx): () => Observable<SignedBlockExtended> {
|
||||
return memo(instanceId, (): Observable<SignedBlockExtended> =>
|
||||
api.derive.chain.subscribeNewHeads().pipe(
|
||||
switchMap((header): Observable<[Hash, EventRecord[], SignedBlock]> => {
|
||||
switchMap((header): Observable<[SignedBlock, EventRecord[], AccountId[] | undefined]> => {
|
||||
const blockHash = header.hash;
|
||||
|
||||
return combineLatest(
|
||||
of(blockHash),
|
||||
api.rpc.chain.getBlock(blockHash),
|
||||
api.query.system.events.at(blockHash),
|
||||
api.rpc.chain.getBlock(header.hash)
|
||||
of(header.validators)
|
||||
);
|
||||
}),
|
||||
map(([blockHash, events, block]) => ({ block: block.block, blockHash, blockNumber: block.block.header.number.unwrap(), events, justification: block.justification }))
|
||||
map(([block, events, validators]) =>
|
||||
new SignedBlockExtended(api.registry, block, events, validators)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { HeaderExtended } from '../type';
|
||||
import { memo } from '../util';
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Block, BlockNumber, EventRecord, Hash, Justification } from '@polkadot/types/interfaces';
|
||||
|
||||
export interface FullNewBlock {
|
||||
block: Block;
|
||||
blockHash: Hash;
|
||||
blockNumber: BlockNumber;
|
||||
events: EventRecord[];
|
||||
justification: Justification;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './proposals';
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Hash, Proposal, Votes } from '@polkadot/types/interfaces';
|
||||
import { DeriveCollectiveProposal } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Option } from '@polkadot/types';
|
||||
import type { Hash, Proposal, Votes } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveCollectiveProposal } from '../types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { catchError, map, switchMap } from 'rxjs/operators';
|
||||
import { Option } from '@polkadot/types';
|
||||
import { isFunction } from '@polkadot/util';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { catchError, map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { DeriveContractFees } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveContractFees } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './fees';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './proposals';
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Hash } from '@polkadot/types/interfaces';
|
||||
import { DeriveCollectiveProposal } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Hash } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveCollectiveProposal } from '../types';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { proposal as collectiveProposal, proposals as collectiveProposals } from '../collective';
|
||||
import { memo } from '../util';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId, Balance } from '@polkadot/types/interfaces';
|
||||
import type { AccountId, Balance } from '@polkadot/types/interfaces';
|
||||
|
||||
export interface DeriveCouncilVote {
|
||||
stake: Balance;
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId, Balance } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { DeriveCouncilVote, DeriveCouncilVotes } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Vec } from '@polkadot/types';
|
||||
import type { AccountId, Balance } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveCouncilVote, DeriveCouncilVotes } from '../types';
|
||||
|
||||
import { Observable, combineLatest } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Vec } from '@polkadot/types';
|
||||
import { combineLatest } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId } from '@polkadot/types/interfaces';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { DeriveCouncilVote } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AccountId } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveCouncilVote } from '../types';
|
||||
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function votesOf (instanceId: string, api: ApiInterfaceRx): (accountId: string | Uint8Array | AccountId) => Observable<DeriveCouncilVote> {
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { BlockNumber, Hash, ReferendumIndex, Scheduled } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { DeriveDispatch, DeriveProposalImage } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Option, u64, Vec } from '@polkadot/types';
|
||||
import type { BlockNumber, Hash, ReferendumIndex, Scheduled } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveDispatch, DeriveProposalImage } from '../types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Option, Vec, u64 } from '@polkadot/types';
|
||||
import { isFunction, stringToHex } from '@polkadot/util';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
@@ -50,7 +51,7 @@ function schedulerEntries (api: ApiInterfaceRx): Observable<[BlockNumber[], Opti
|
||||
api.query.scheduler.agenda.keys()
|
||||
),
|
||||
switchMap((keys) => {
|
||||
const blockNumbers = keys.map((key) => key.args[0] as BlockNumber);
|
||||
const blockNumbers = keys.map((key) => key.args[0]);
|
||||
|
||||
return combineLatest([
|
||||
of(blockNumbers),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './dispatchQueue';
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { AccountId, ReferendumInfo, ReferendumInfoFinished, ReferendumInfoTo239, Vote, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { DeriveDemocracyLock } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Option } from '@polkadot/types';
|
||||
import type { AccountId, ReferendumInfo, ReferendumInfoFinished, ReferendumInfoTo239, Vote, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveDemocracyLock } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { Option } from '@polkadot/types';
|
||||
|
||||
import { BN_ZERO, isUndefined } from '@polkadot/util';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Hash, VoteThreshold } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { DeriveProposalExternal } from '../types';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Option } from '@polkadot/types';
|
||||
import type { Hash, VoteThreshold } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveProposalExternal } from '../types';
|
||||
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Option } from '@polkadot/types';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user