Compare commits

..
104 Commits
Author SHA1 Message Date
Github Actions 9bae65864d [CI Skip] release/stable 1.34.1
skip-checks: true
2020-09-21 07:27:20 +00:00
Jaco Greeff 172143f2eb 1.34 (#2628) 2020-09-21 09:16:45 +02:00
Github Actions 3162f15a1d [CI Skip] release/beta 1.34.0-beta.14
skip-checks: true
2020-09-20 16:10:59 +00:00
Wei Tang af074500b6 Add support to extract PoW author (#2627)
* Add PoW engine ID and author fetching logic

* Fix Pow CID order
2020-09-20 18:00:21 +02:00
Github Actions 5e2a1753af [CI Skip] release/beta 1.34.0-beta.13
skip-checks: true
2020-09-19 06:56:59 +00:00
Jaco Greeff 375dadbe35 Optional votingOf for democracy locks (#2626) 2020-09-19 08:46:35 +02:00
Github Actions f799a63610 [CI Skip] release/beta 1.34.0-beta.12
skip-checks: true
2020-09-18 05:24:48 +00:00
Jaco Greeff eda5edbd40 Explicit Decorate creation with Metadata (#2622)
* Explicit Decorate creation with Metadata

* typo

* Update generator

* Adjust Registry findMetaError sig
2020-09-18 07:14:11 +02:00
Github Actions d0fefb342f [CI Skip] release/beta 1.34.0-beta.11
skip-checks: true
2020-09-17 21:25:01 +00:00
Jaco Greeff b56c1a8282 Explicit tie of metadata to registry (not implicit) (#2621)
* Explicit tie of metadata to registry (not implicit)

* Update type generation

* Test updates

* Revert non-problematic

* Cleanup mocks

* Updata metadata tests

* CHANGELOG

* linting
2020-09-17 23:15:09 +02:00
Jaco Greeff cdd6544e20 SPDX (#2619) 2020-09-17 16:31:06 +02:00
Github Actions 12068a8722 [CI Skip] release/beta 1.34.0-beta.10
skip-checks: true
2020-09-17 13:05:24 +00:00
Jaco Greeff 4596e434dd accountNextIndex on nonce = -1 (#2618) 2020-09-17 14:54:06 +02:00
Github Actions 6c00a5a408 [CI Skip] release/beta 1.34.0-beta.9
skip-checks: true
2020-09-17 08:18:32 +00:00
Jaco Greeff c10e4d3fc1 Use polyfills from polkadot-js (#2616)
* Use polyfills from polkadot-js

* no empty catch

* Non-working asjustments

* Adjust WS mocking

* Bump polyfills

* Bumps

* Restore common
2020-09-17 10:05:34 +02:00
Github Actions 597aa3d607 [CI Skip] release/beta 1.34.0-beta.8
skip-checks: true
2020-09-16 09:44:55 +00:00
Jaco Greeff 2edad85250 Refresh all type decorations on upgrade (#2615)
* Refresh all type decorations on upgrade

* Cleanups

* calls/events not part of init
2020-09-16 11:32:52 +02:00
Github Actions 5f0c6ecd1b [CI Skip] release/beta 1.34.0-beta.7
skip-checks: true
2020-09-16 07:06:46 +00:00
Jaco Greeff 2a36987140 Bump deps (incl. isomorphic-fetch replacement) (#2614)
* Bump deps (incl. isomorphic-fetch replacement)

* Bump ts
2020-09-16 08:53:50 +02:00
Github Actions 12ea37d1ec [CI Skip] release/beta 1.34.0-beta.6
skip-checks: true
2020-09-15 19:33:42 +00:00
Jaco Greeff 3dca518cd7 Explicit help in signer error (#2610) 2020-09-15 21:21:56 +02:00
Jaco Greeff 5f7057dbbf Update known upgrade blocks for Polkadot (#2611) 2020-09-15 21:21:30 +02:00
Github Actions aac6b3bc7b [CI Skip] release/beta 1.34.0-beta.5
skip-checks: true
2020-09-15 12:40:43 +00:00
Jaco Greeff 7a5a975048 Sameness check for v12 indexes (#2609)
* Sameness check for indexes

* Update with older support
2020-09-15 14:27:43 +02:00
Github Actions 46d05dd7af [CI Skip] release/beta 1.34.0-beta.4
skip-checks: true
2020-09-15 09:28:38 +00:00
Jaco Greeff 177cdb97fd Expand extrinsic decoding example (#2608) 2020-09-15 11:15:38 +02:00
Github Actions 2b0bae12c7 [CI Skip] release/beta 1.34.0-beta.3
skip-checks: true
2020-09-14 20:50:36 +00:00
Jaco Greeff 24d8915005 toCallsOnly for v12 (#2606) 2020-09-14 22:37:59 +02:00
Github Actions 180bfbbf6f [CI Skip] release/beta 1.34.0-beta.2
skip-checks: true
2020-09-14 14:16:54 +00:00
Jaco Greeff 918bb73547 Ensure that ignored map params yield an error on iterKey (#2605) 2020-09-14 16:05:37 +02:00
Github Actions 41ffa2bf00 [CI Skip] release/beta 1.34.0-beta.1
skip-checks: true
2020-09-14 11:19:37 +00:00
Jaco Greeff e425a38a7c Cleanups for WebSocket class detection and creation (#2604)
* Cleanups for WebSocket class detection and creation

* Create change
2020-09-14 13:08:28 +02:00
Github Actions c616cd51c5 [CI Skip] release/beta 1.34.0-beta.0
skip-checks: true
2020-09-14 10:49:11 +00:00
Jaco Greeff dac3261a16 Support for Metadata v12 (#2599)
* Support for Metadata v12

* v12 static data

* Treat 255 as reserved

* Point static to v12
2020-09-14 12:35:30 +02:00
Github Actions 28355424bd [CI Skip] release/stable 1.33.1
skip-checks: true
2020-09-14 07:11:20 +00:00
Jaco Greeff e7be062522 1.33 (#2602) 2020-09-14 08:58:21 +02:00
Github Actions ed5b5eeaa6 [CI Skip] release/beta 1.33.0-beta.6
skip-checks: true
2020-09-13 12:34:01 +00:00
Jaco Greeff ad8ad42344 Map Websocket error codes to short descriptions (#2601) 2020-09-13 14:23:00 +02:00
Github Actions f311e5d57f [CI Skip] release/beta 1.33.0-beta.5
skip-checks: true
2020-09-10 06:43:32 +00:00
Jaco Greeff 065f39ba6d Explicit hash to paymentInfo for query (#2598)
* Explicit hash to paymentInfo for query

* CHANGELOG
2020-09-10 08:30:16 +02:00
Github Actions 64bf72a6d7 [CI Skip] release/beta 1.33.0-beta.4
skip-checks: true
2020-09-10 00:50:50 +00:00
Jaco Greeff b59b60ae1f Use source registry in clones (#2597) 2020-09-10 02:38:07 +02:00
Github Actions e5b7e7f16f [CI Skip] release/beta 1.33.0-beta.3
skip-checks: true
2020-09-09 16:56:29 +00:00
Jaco Greeff c2705bdfda Set runtimeChain from source (#2595)
* Set runtimeChain from source

* Update packages/api/src/base/index.ts

* Update CHANGELOG.md
2020-09-09 18:44:47 +02:00
Github Actions 373eb06713 [CI Skip] release/beta 1.33.0-beta.2
skip-checks: true
2020-09-09 11:43:42 +00:00
Jaco Greeff 45c2c40a3e derive.staking.stakerPrefs (#2594) 2020-09-09 13:31:06 +02:00
Github Actions 3b110d7d7f [CI Skip] release/beta 1.33.0-beta.1
skip-checks: true
2020-09-09 08:55:49 +00:00
Jaco Greeff 0a8d2e5ac1 Allow as-signed paymentInfo on any extrinsic (#2593)
* Allow as-signed paymentInfo on any extrinsic

* Bumps
2020-09-09 10:43:59 +02:00
Github Actions d0bf8b8d82 [CI Skip] release/beta 1.33.0-beta.0
skip-checks: true
2020-09-07 11:39:53 +00:00
Jaco Greeff 2c3ef10513 Optimize heartbeat retrievals (#2590) 2020-09-07 13:28:43 +02:00
Github Actions 92022bda94 [CI Skip] release/stable 1.32.1
skip-checks: true
2020-09-07 07:22:50 +00:00
Jaco Greeff 609581430f 1.32 (#2589)
* 1.32

* CHANGELOG
2020-09-07 09:10:35 +02:00
Github Actions ec083f623d [CI Skip] release/beta 1.32.0-beta.25
skip-checks: true
2020-09-06 16:18:27 +00:00
Jaco Greeff 395dc79ef7 Adjust derive.staking.query (no opt) (#2588)
* Adjust derive.staking.query (no opt)

* Rewrite
2020-09-06 18:06:37 +02:00
Github Actions a968fe05b5 [CI Skip] release/beta 1.32.0-beta.24
skip-checks: true
2020-09-06 11:05:18 +00:00
Jaco Greeff 4b3b853c27 Extract derive for staking keys (#2587)
* Extract derive for staking keys

* CHANGELOG
2020-09-06 12:53:46 +02:00
Github Actions ea5843f7c9 [CI Skip] release/beta 1.32.0-beta.23
skip-checks: true
2020-09-06 08:04:07 +00:00
Jaco Greeff 467ccc5681 Westend known upgrade (#2584) 2020-09-06 09:51:16 +02:00
Github Actions 59922eee8f [CI Skip] release/beta 1.32.0-beta.22
skip-checks: true
2020-09-05 12:44:02 +00:00
Jaco Greeff 5af98cc89e Retry WS on initial connection failures (#2585) 2020-09-05 14:30:55 +02:00
Github Actions 1b7265048d [CI Skip] release/beta 1.32.0-beta.21
skip-checks: true
2020-09-05 06:33:47 +00:00
Jaco Greeff 3151c08aca Bump deps (#2583) 2020-09-05 08:22:29 +02:00
Github Actions 71332fde1b [CI Skip] release/beta 1.32.0-beta.20
skip-checks: true
2020-09-04 16:08:24 +00:00
Jaco Greeff 00bc441f0e Add connected() to API interface (#2580)
* Add connected() to API interface

* Slight doc update

* Align ApiRx

* isConnected() usage

* Updates

* Retrieve isConnected for API via observable

* Remove (now) useless Rx test
2020-09-04 17:57:02 +02:00
Github Actions 4f4833da74 [CI Skip] release/beta 1.32.0-beta.19
skip-checks: true
2020-09-04 08:47:58 +00:00
qiuhao 825365bb13 update DeriveCustom type (#2581) 2020-09-04 10:37:16 +02:00
Github Actions 48a3a976f9 [CI Skip] release/beta 1.32.0-beta.18
skip-checks: true
2020-09-04 06:06:45 +00:00
Jaco Greeff b579b18fad Adjust toHuman display (#2579)
* Adjust toHuman display

* revert args breakdown
2020-09-04 07:55:13 +02:00
Github Actions 27f5547bbf [CI Skip] release/beta 1.32.0-beta.17
skip-checks: true
2020-09-03 15:22:39 +00:00
Shawn Tabrizi 4654d15097 Add isReadyOrError when connecting to API (#2577)
* Add `isReadyOrError`

* lint
2020-09-03 17:10:07 +02:00
Github Actions 10574ecc33 [CI Skip] release/beta 1.32.0-beta.16
skip-checks: true
2020-09-03 14:00:02 +00:00
Jaco Greeff 6ae75ba92e Bump dev (#2576)
* Bump dev

* type linting

* linting

* linting

* missed
2020-09-03 15:47:29 +02:00
Github Actions 5a48a2a3f7 [CI Skip] release/beta 1.32.0-beta.15
skip-checks: true
2020-09-03 12:02:17 +00:00
Jaco Greeff 40899adf82 Optiona nominators (#2575) 2020-09-03 13:50:19 +02:00
Github Actions 020effecc8 [CI Skip] release/beta 1.32.0-beta.14
skip-checks: true
2020-09-03 10:58:35 +00:00
Jaco Greeff 430beb9f25 staking.currentEra returns Option (#2574)
* staking.currentEra returns Option

* Flatten

* Cleanups.

* Option<EraIndex> or EraIndex

* Test unwrapOrDefault
2020-09-03 12:45:50 +02:00
Github Actions 533d6dd441 [CI Skip] release/beta 1.32.0-beta.13
skip-checks: true
2020-09-03 06:54:48 +00:00
Jaco Greeff 95dd13e218 Dedup class creation (#2573) 2020-09-03 08:41:15 +02:00
Github Actions c8cb441a82 [CI Skip] release/beta 1.32.0-beta.12
skip-checks: true
2020-09-02 15:27:23 +00:00
Jaco Greeff b6d1be6ee5 Only memomize via instanceId (#2572)
* Add memoizee instanceId

* Gotcha.

* linitng
2020-09-02 17:13:38 +02:00
Github Actions e13514cd94 [CI Skip] release/beta 1.32.0-beta.11
skip-checks: true
2020-09-02 13:26:45 +00:00
Jaco Greeff 5a90da5df8 accountId-only lookups on paymentInfo (#2569) 2020-09-02 15:13:45 +02:00
Github Actions 8fdc518651 [CI Skip] release/beta 1.32.0-beta.10
skip-checks: true
2020-09-02 10:31:41 +00:00
Jaco Greeff eb6b3c5bd4 Align costs typing with queries (#2564)
* Align costs typing with queries

* better...

* ... and better

* ... progress

* better, down to 8

* ... down to 3

* ... 2

* Down to 1

* It builds.

* ... it really builds
2020-09-02 12:19:09 +02:00
Github Actions 1214572f02 [CI Skip] release/beta 1.32.0-beta.9
skip-checks: true
2020-09-02 07:37:22 +00:00
Jaco Greeff df229ffb8a Known Kusama update (slight upgrades rework) (#2567)
* Known Kusama update (slight upgrades rework)

* linting
2020-09-02 09:23:48 +02:00
Github Actions 334e0bb730 [CI Skip] release/beta 1.32.0-beta.8
skip-checks: true
2020-09-01 11:22:21 +00:00
Nikhil Ranjan f43bc32573 add vestingPerBlock and vestingEndBlock in DeriveBalancesAll when doing calcBalances (#2563)
* add vesting perBlock and vestingEndBlock in DeriveBalancesAll when doing calcBalances

* perBlock renamed to vestingPerBlock
2020-09-01 13:09:29 +02:00
Github Actions bf4a8e28a3 [CI Skip] release/beta 1.32.0-beta.7
skip-checks: true
2020-09-01 11:06:46 +00:00
Jaco Greeff 9188e29dcc Add grandpa_subscribeJustifications (#2562) 2020-09-01 12:54:32 +02:00
Github Actions 7ea89950fe [CI Skip] release/beta 1.32.0-beta.6
skip-checks: true
2020-09-01 10:04:40 +00:00
Jaco Greeff 7a1089df79 Cater for nested aliassed types (#2560)
* Cater for nested aliassed types

* linting
2020-09-01 11:52:11 +02:00
Github Actions f1ca28adcb [CI Skip] release/beta 1.32.0-beta.5
skip-checks: true
2020-09-01 09:26:04 +00:00
Jaco Greeff 8f675053a4 Add toHuman() & toBigInt() to type basics (#2558) 2020-09-01 11:13:46 +02:00
Github Actions 64de91a96b [CI Skip] release/beta 1.32.0-beta.4
skip-checks: true
2020-08-31 21:19:25 +00:00
Jaco Greeff 6bd10daf43 Bump static metadata (#2557) 2020-08-31 23:06:18 +02:00
Github Actions 57c54c860a [CI Skip] release/beta 1.32.0-beta.3
skip-checks: true
2020-08-31 21:03:09 +00:00
Jaco Greeff 0e9a50e020 Make metadata available on registry swap (#2556)
* Make metadata available on registry swap

* Return full VersionedRegistry
2020-08-31 22:52:33 +02:00
Github Actions 15c35900ac [CI Skip] release/beta 1.32.0-beta.2
skip-checks: true
2020-08-31 19:25:29 +00:00
Jaco Greeff 6f092a1818 api.derive.chain.getBlock(<hash>) with author getter (#2555)
* api.derive.chain.getBlock<hash>) with author getter

* Update CHANGELOG.md
2020-08-31 21:12:14 +02:00
Github Actions c0c6928394 [CI Skip] release/beta 1.32.0-beta.1
skip-checks: true
2020-08-31 17:48:54 +00:00
Jaco Greeff 391c98c845 Next beta 2020-08-31 19:34:37 +02:00
Github Actions 2e125c5542 [CI Skip] release/stable 1.31.2
skip-checks: true
2020-08-31 17:30:12 +00:00
Jaco Greeff 3d67b75059 Proxy Announcement override (#2553) 2020-08-31 19:17:48 +02:00
618 changed files with 16155 additions and 4118 deletions
+1
View File
@@ -4,3 +4,4 @@
1.11.2
1.12.2
1.17.2
1.31.2
+3
View File
@@ -1 +1,4 @@
// Copyright 2017-2020 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
module.exports = require('./babel.config.js');
+3
View File
@@ -1,3 +1,6 @@
// Copyright 2017-2020 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
const base = require('@polkadot/dev/config/eslint');
module.exports = {
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-86
View File
File diff suppressed because one or more lines are too long
+55
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -5,7 +5,7 @@ enableProgressBars: false
nodeLinker: node-modules
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.js
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
yarnPath: .yarn/releases/yarn-2.1.1.cjs
yarnPath: .yarn/releases/yarn-2.2.2.cjs
+272 -3
View File
@@ -1,5 +1,71 @@
# CHANGELOG
## 1.34.1 Sep 21, 2020
Upgrade priority: High. Metadata v12 is the next major version containing structural data exchange changes and will start rolling out to test and live networks in due course.
- **Breaking change** The `Decorated` (from `@polkadot/metadata`) class signature has changed. It now always expects a valid `Metadata` object to be passed-in, instead of raw data. It is recommended to create a `Metadata` object, set it on the registry with `.setMetadata` and then only create a `Decorated` instance. (Only affects metadata-only users of the API)
Contributed:
- Added support for POW block author extraction (Thanks to https://github.com/sorpaas)
Changes:
- Ensure Metadata retrieval does not pollute the default registry
- When passing `{ nonce: -1 }` to `signAndSend` the API will use `system.accountNextIndex` to determine the nonce
- Ensure that upgrades override old registry types (non-specified in current)
- Support for Metadata v12 with fixed indices
- Cleanups for WebSocket class detection and creation
- Ensure that ignored map params yield an error on `iterKey`
- Cater for older chains in derive democracy locks (availability detection)
## 1.33.1 Sep 14, 2020
Upgrade priority: Low. Recommended when using clones instances.
Changes:
- Allow `paymentInfo` on any extrinsic with `tx.paymentInfo(<address>, <at>)` (hash specified)
- When cloning an API instance the runtimeChain is now properly set from source
- When cloning an API instance the registry is shared with the source
- Optimize derive `receivedHeartbeats` to not re-create the full object
- Add `staking.stakerPrefs` derive to retrieve validatorPrefs over a range of eras
- Basic map of Websocket error codes to short descriptions (where none available)
## 1.32.1 Sep 7, 2020
Upgrade priority: Low. Recommended when manually using provider connect/disconnect or using multiple instances in a single process.
- **Breaking change** Previously `.isReady` could throw an error, now it will always succeed on connection. For trapping errors, use the `.isReadyOrError` variant on the API
- **Breaking change** The `isConnected` provider interface is now a getter, replacing previous calls to `provider.isConnected()`. Additionally the `provider.disconnect()` is now async, aligning with `.connect()`.
Contributed:
- Expand vesting information via derive balances (Thanks to https://github.com/niklabh)
- Add `isReadyOrError` to API, `isReady` always succeeds (Thanks to https://github.com/shawntabrizi)
Changes:
- Adjust memoization to work on a per-instance basis, with no contamination between multiple api/provider instances
- Added `derive.chain.getBlock(hash)` to retrieve a `SignedBlock` extended with an `.author` (same as `derive.chain.getHeader(...)`)
- Added `api.{connect, disconnect}()` as well as `isConnected` interfaces. The first functions async returning `Promise<void>`
- Error on provider connections will now emit all (as expected) via the event emitter
- Ensure that initial connection failures always retry (when using auto-connection management)
- The `api.derive.staking.query/queryMulti` no longer retrieves session keys (can be done via `.keys/keysMulti`)
- Add `api.derive.accounts.accountId` to perform AccountId lookups (from indices or actual AccountId)
- Lessen load of `paymentInfo` queries to only use accounId mappings as available
- Adjust staking derives to cater for early Substrate 2.0 chains (optional/non-optional EraIndexes)
- Cater for the handling of nested aliased types, e.g. wrapped inside Vec or Tuple
- Add the support for the `grandpa_subscribeJustifications` RPC
- Adjust `Call.toHuman()` to remove decoding-related technical internal details
- Static metadata & tests updated for the latest substrate master
- `toHuman()` & `.toBigInt()` has been explicitly added to the API documentation
- Adjust known types for latest Kusama network state
## 1.31.1 Aug 31, 2020
Upgrade priority: Medium, especially for staking users on Polkadot, Kusama & Westend (type updates applied for v23 onwards) or if transparent `.at(hash)` queries are required/used
@@ -7,10 +73,14 @@ Upgrade priority: Medium, especially for staking users on Polkadot, Kusama & Wes
- **Important** Substrate changed the `RewardDestination` enum with an extra field for payout-to-any account for staking preferences. If on an older chain consider adding `RewardDestination: 'RewardDestinationTo257'`
- **Important** Substrate changed the `CompactAssignment` type enhanced types for session solution submissions. If on an older chain consider adding `CompactAssignments: 'CompactAssignmentsTo257'`
Contributed:
- Fix documentation language and typos (Thanks to https://github.com/Meuko)
- Add missing `TransactionPriority` type (Thanks to https://github.com/aniiantt)
- Update definitions for new `CompactAssignments`, including tests (Thanks to https://github.com/kianenigma)
Changes:
- Add transparent support for types/metadata, i.e. hash queries such as `rpc.chain.getBlock(<hash>)` & `query.system.events.at(<hash>)` now works out-of-the-box injecting the correct metadata & types.
- Optimize RPC-layer calls with detection of short-term cacheable calls (in the same way subscriptions are done)
- Additional checks on `AccountId` for valid sizes
@@ -30,6 +100,8 @@ Upgrade priority: Medium, especially for staking users on Polkadot, Kusama & Wes
Upgrade priority: Low, unless using the `proposeParachain` module.
Changes:
- Adjust balance retrievals to check for `system.account` for new/old determination
- Add types for the new `proposeParachain` module (as per Rococo)
- Adjust `Address` <-> `LookupSource` definitions (no external impact, both in existence)
@@ -44,8 +116,12 @@ Upgrade priority: Low, unless on bleeding-edge chain with new compact `CompactAs
- **Important** The Substrate `CompactAssignments` type has changed for better space utilization. On older chains, supply `CompactAssignments: 'CompactAssignmentsTo257'`
Contributed:
- Clean tx cookbook param expansion (Thanks to https://github.com/swswsw)
Changes:
- Add additional `Fixed{I,U}{64,128}` and `{I,U}32F32` types
- Add `desiredRunnersUp` to council derives
- Cleanup indices/AccountId combination derive lookups
@@ -56,8 +132,12 @@ Upgrade priority: Low, unless on bleeding-edge chain with new compact `CompactAs
Upgrade priority: Low, unless using Centrifuge or parachains
Contributed:
- Update Centrifuge types to latest (Thanks to https://github.com/mikiquantum)
Changes:
- Add cookbook entry for viewing block extrinsics
- Support types for time-delay proxies
- Update types for parachains
@@ -69,8 +149,12 @@ Upgrade priority: Low, unless using Centrifuge or parachains
Upgrade priority: Low, unless using the Rococo chain
Contributed:
- Remove outdated example poc-3 RPC reference (Thanks to https://github.com/swswsw)
Changes:
- Raw/Bytes `toHuman` detects ASCII sequence for text output
- Add know types for the Rococo chain
@@ -79,9 +163,13 @@ Upgrade priority: Low, unless using the Rococo chain
Upgrade priority: Low
Contributed:
- Update docs for the new `system.accountNextIndex` (Thanks to https://github.com/shawntabrizi)
- Update contracts call parameter typing (Thanks to https://github.com/kwingram25)
Changes:
- Adjust votingBalance to only return `freeBalance` (only council voting is free + reserved)
- Additional checks for referenced Vec sub-type deconstruction in typegen
- Allow for API `typesBundle` option to inject a group of chain versions types
@@ -95,10 +183,14 @@ Upgrade priority: Medium, especially if using contracts.
- **Important** Contract RPC result updated on Substrate, on older chains supply `ContractExecResult: 'ContractExecResultTo255'`
Contributed:
- Support for custom HTTP headers in providers (Thanks to https://github.com/brad-larson)
- Update known types for Centrifuge (Thanks to https://github.com/philipstanislaus)
- Update API users with Registrar #1 (Thanks to https://github.com/chevdor)
Changes:
- Raw/Bytes `toHuman()` displays utf-8 as available
- Add fallback for `setImmediate` when not polyfilled
- Update `NetworkState` reputation type for `system_networkState` RPC
@@ -109,6 +201,8 @@ Upgrade priority: Medium, especially if using contracts.
## 1.24.1 Jul 13, 2020
Changes:
- Added `isAscii` & `isUtf8` getters to `Bytes` & `Raw` types
- Added `toUtf8()` helper to `Bytes` & `Raw` types
- `@polkadot/util` 2.18
@@ -116,8 +210,12 @@ Upgrade priority: Medium, especially if using contracts.
## 1.23.1 Jul 6, 2020
Contributed:
- Small README typo fix (Thanks to https://github.com/woss)
Changes:
- Add latest Substrate master types
- Adjust `<Codec>.toRawType()` to use registry name as available
- Update `ProxyType` for Kusama, Polkadot & Westend with `IdentityJudgement`
@@ -130,8 +228,12 @@ Upgrade priority: Medium, especially if using contracts.
- **Important** Substrate changed the treasury tip structure, on older chains supply `OpenTip: 'OpenTipTo225'`
Contributed:
- Allow for `[u8; 33]` in U8aFixed (Thanks to https://github.com/akru)
Changes:
- Improve derive accountId -> accountIndex lookups (optimize entries queries)
- Vesting balance calculations via `derive.balances.all` has been updated for locks
- Add derive for multi staking rewards with specified eras
@@ -140,8 +242,12 @@ Upgrade priority: Medium, especially if using contracts.
## 1.21.1 Jun 23, 2020
Contributed:
- Fix subscriptions never unsubscribing after the id swap in 1.18.1 (Thanks to https://github.com/dillu24 for testing iterations)
Changes:
- Add support for `CheckMortality` signed extension (old `CheckEra` is now an alias)
- Promise API will default to using `getStorage` on non-subscription calls, reducing RPC overhead
- Optimize derive BN allocations, using in-place operators as applicable
@@ -153,6 +259,8 @@ Upgrade priority: Medium, especially if using contracts.
- **Important** RPC for `account_nextIndex` has been moved to `system_accountNextIndex` (Aligning with Substrate as a primary alias)
Changes:
- Cleanup map entries support with only Substrate 2.0-era RPCs (when introduced)
- Add `system_dryRun` RPC
- Optimize `derive.staking.queryMulti` retrievals with additional per-type batching
@@ -163,8 +271,12 @@ Upgrade priority: Medium, especially if using contracts.
## 1.19.1 Jun 16, 2020
Contributed:
- Improve typing on `.entries()` queries (Thanks to https://github.com/monitz87)
Changes:
- Align metadata and types with latest Substrate
- Update Polkadot types for current evolution of parachains
- Allow for type aliasing on events (aligning with calls & queries)
@@ -173,11 +285,15 @@ Upgrade priority: Medium, especially if using contracts.
## 1.18.1 Jun 8, 2020
Contributed:
- Expand docs on node-template types (Thanks to https://github.com/g2udevelopment)
- Update contract fees to current impl. (Thanks to https://github.com/djuanit0x)
- Allow `Option` types in enum/Result type generation (Thanks to http://github.com/xlc)
- Add `.entriesPaged` and `.keysPaged` methods for state maps (https://github.com/monitz87)
Changes:
- Add types for new Substrate proxy module
- Adjust types for new Substrate (renamed) npos-elections module
- `Call` now exposes `method` & `section` fields (aligned with `toHuman()` representation)
@@ -187,13 +303,19 @@ Upgrade priority: Medium, especially if using contracts.
## 1.17.2 Jun 2, 2020
Changes:
- Ensure subscription promise resolves before first result
## 1.17.1 Jun 2, 2020
Contributed:
- Fix `ElectionSize` type (Thanks to https://github.com/arjanz)
Changes:
- Allow `BTreeSet` decoding from Array/JSON inputs
- Adjust Call-only metadata output to trim documentation to first full line
- Safeguard against divide-by-zero for total era points (expired reward eras)
@@ -204,6 +326,8 @@ Upgrade priority: Medium, especially if using contracts.
## 1.16.1 May 26, 2020
Changes:
- Support for Polkadot CC1 types & signed extensions
- Add support for Babe VRF secondary digests (author extraction)
- Adjust `Perbill/Permill` `toHuman()` formatting to output percentage
@@ -214,12 +338,16 @@ Upgrade priority: Medium, especially if using contracts.
## 1.15.1 May 23, 2020
Contributed:
- Adjust `keyPrefix()` with DoubleMap args (Thanks to https://github.com/KiChjang)
- Added `WeightToFeeCoefficient` type (Thanks to https://github.com/danforbes)
- Spelling fixes for console logs (Thanks to https://github.com/JoshOrndorff)
- Spelling fixes in cookbook (Thanks to https://github.com/pawelnguyen)
- Add `transactionVersion` getter in payloads (Thanks to https://github.com/amaurymartiny)
Changes:
- Adjust `stakerRewards` derive ordering for improved on-payout refreshes
- Baseline implementation for derive caching infrastructure
- Adjust `Multiplier` type to `Fixed128` (as per latest Substrate)
@@ -230,9 +358,13 @@ Upgrade priority: Medium, especially if using contracts.
- **Important** `DispatchInfo` changed `paysFee` to an enum, if using an older version use, `DispatchInfo: 'DispatchInfoTo244'`
Contributed:
- Align imOnline `Heartbeat` with Substrate (Thanks to https://github.com/arjanz)
- Adust EVM types to include `Vicinity` (Thanks to https://github.com/drewstone)
Changes:
- Ensure metadata is only requested once upon startup (bypass on upgrade subscriptions)
- Expand testing around `ExtrinsicEra` construction
- Expand `Registry` to direct access to available signed extensions (in addition to exposed types)
@@ -247,12 +379,16 @@ Upgrade priority: Medium, especially if using contracts.
## 1.13.1 May 6, 2020
Contributed:
- Add support for ECDSA keypairs in extrinsic signers (Thanks to https://github.com/akru)
- Rework type generation to use templating for better maintenance (Thanks to https://github.com/xlc)
- Adjust extrinsic `sign/signAsync` signature to optional options (Thanks to https://github.com/KiChjang)
- Support round-robin endpoints in the `WsProvider` with array of urls (Thanks to https://github.com/hoani)
- Remove static test-only metadata for Polkadot dev chains (not updated regularly, Substrate dev to remain)
Changes:
- Revert error swallow for wrong preimage data (temp. override for Kusama upgrade with no migration)
- Fix `.encodedLength` calculation on `[Type; N]` types
- Add new `rpc.grandpa.roundState` RPC
@@ -262,16 +398,22 @@ Upgrade priority: Medium, especially if using contracts.
## 1.12.2 Apr 30, 2020
Changes:
- Update `@polkadot/util` to stable 2.9.1 (sadly missed in the previous version, stable should match to stable)
## 1.12.1 Apr 29, 2020
Contributed:
- Fix `CompactAssignments` types (Thanks to https://github.com/arjanz)
- Provider ayo-connect now allows for interval config (Thanks to https://github.com/jnaviask)
- Cleanup generation for c-like enums (Thanks to https://github.com/monitz87)
- Allow subscription to all storage keys, alignment with Substrate (Thanks to https://github.com/xlc)
Changes:
- Cater for vote delegations in democracy derives
- Cleanup account derive flags where to allow for optional council modules
- Allow generic types in ApiPromise.combineLatest
@@ -280,6 +422,8 @@ Upgrade priority: Medium, especially if using contracts.
## 1.11.2 Apr 22, 2020
Changes:
- Small patch to add missing Polkadot master types (will be in next Kusama update)
@@ -287,11 +431,15 @@ Upgrade priority: Medium, especially if using contracts.
- **Important** Substrate master has an updated `Weight` (to `u64`), on older chains apply `Weight: 'u32'` (This does affect event decoding if wrongly set)
Contributed:
- Allow user type augmentation to work with different versions of rxjs (Thanks to https://github.com/monitz87)
- Align augmented generation with camelCase (Thanks to https://github.com/monitz87)
- Fix bitfield endian encoding (Thanks to investigation by https://github.com/xlc)
- Add account flag derives via `accounts.flags(accountId)` (Thanks to https://github.com/kwingram25)
Changes:
- Fix entries decoding for `Option<Number>` (& simplify, decoding correctly on rpc layer)
- Add `system.{localPeerId, localListenAddresses}` & `state.getReadProof` RPCs
- Ensure proper propagation of `api.runtimeVersion` (used for signing) after upgrade
@@ -309,6 +457,8 @@ Upgrade priority: Medium, especially if using contracts.
- **Important** Substrate master has updated staking, on older chains apply `StakingLedger: 'StakingLedgerTo240'`
Changes:
- Add `rpc.system.chainType` to retrieve the chain type (Development. Local, Live & Custom)
- Adjust types for Westend after the reset
- Adjust democracy derives, including the support of the frame-scheduler for scheduled deployments
@@ -325,6 +475,8 @@ Upgrade priority: Medium, especially if using contracts.
- **Breaking change** (TypeScript with derives only) The return type names for `api.derive.*` have been adjusted for consistency, all starting with `Derive*` (previously a mixture of `Derived*` and `Derive*`)
- **Breaking change** (derives only) Additional cleanups of democracy proposal & referenda derives, including support for new Polkadot/Substrate vote retrievals
Changes:
- Tx signing via `signAndSend` & `signAsync` now tries to use the last finalized block (depending on finalized drift)
- Add support for `api.rpc.childstate.*` Substrate RPCs, older nodes with still populate `api.rpc.state.*` with the child methods
- Adjust `Error.message` on RPC failures to not include the (already known) method signature
@@ -343,6 +495,8 @@ Upgrade priority: Medium, especially if using contracts.
- **Breaking change** Alongside API RPC changes, the `@polkadot/jsonrpc` package has been removed. Since it was never documented and only used internally, this should not have adverse impacts. All RPC definitions itself has now been moved to the relevant modules inside `@polkadot/types/interfaces`
- **Important** Substrate has an updated democracy module. If using an older chain add the `ReferendumInfo: 'ReferendumInfoTo239'` type when using referendums
Changes:
- The `isRetracted` Extrinsic status is now a warning, not a fatal error, correctly aligning with Polkadot/Substrate
- The Substrate extrinsic phase definitions has been expanded with `Initialization` to align with the latest versions
- Add support for all known substrate RPC methods
@@ -355,6 +509,8 @@ Upgrade priority: Medium, especially if using contracts.
- **Important** Current versions of Polkadot/Substrate have dropped support for linked maps on storage entries. If you are using these queries to retrieve all entries, for instance `staking.{nominators,validators}()` and using an upgraded chain, you need to swap to retrieving entries via `.entries()` or `.keys()` for the keys.
Changes:
- Pull in support and types for latest Polkadot/Substrate
- Add support for the new Substrate `state_getKeysPaged` RPC, including use in storage keys
- Move `derive.staking.controllers` to `derive.staking.stashes`, reflecting actual content
@@ -365,6 +521,8 @@ Upgrade priority: Medium, especially if using contracts.
## 1.6.2 Mar 12, 2020
Changes:
- Revert checks for query args, not working on `.at()` queries (proper fix in next version)
@@ -372,6 +530,8 @@ Upgrade priority: Medium, especially if using contracts.
- **Breaking change** `api.rpc.state.queryStorage(...)` now fully decodes the `Vec<StorageChangeSet>` and returns a decoded `[Hash, Codec[]][]` when using this RPC.
Changes:
- `StorageKey` now has an `.args` property, decoded from meta where `twox64_concat` or `blake128_concat` are used on maps
- Fix `api.query.*.*.entries` type conversions to return exact types (not `Option` in some cases)
- Add `api.query.*.*.keys` to retrieve only the storage keys, similar to `.entries`
@@ -389,10 +549,14 @@ Upgrade priority: Medium, especially if using contracts.
- **Important** Substrate master has updated staking, on older chains supply `StakingLedger: 'StakingLedgerTo223'`
- **Important** Substrate master has updated collective, on older chains supply `Votes: 'VotesTo230'`
Contributed:
- Add proper support for type generation with an Enum containing an Tuple (Thanks to https://github.com/monitz87)
- Fix storage parsing not resulting in rejected Promises (Fix from https://github.com/aniiantt applied)
- Remove use of deprecated `Observable.create` (Thanks to https://github.com/Himself65)
Changes:
- Add types & metadata for the latest Polkadot/Substrate runtime versions (master branches)
- Type extraction will now allow the same sub-module name across packages, i.e. `@polkadot/types/interfaces/runtime` & `@mine/interfaces/runtime` will be valid
- Add `.range([from, to]: [Hash, Hash?], ...args: any[]): [Hash, Codec][]` on all storage entries
@@ -409,6 +573,8 @@ Upgrade priority: Medium, especially if using contracts.
## 1.4.2 Feb 27, 2020
Changes:
- Fix `api.tx(<extrinsic>): Submittable` decoration (non-working in 1.4.1, now with proper test)
@@ -417,10 +583,14 @@ Upgrade priority: Medium, especially if using contracts.
- **Breaking change** (TypeScript only) The `*.d.ts` files now contain TypeScript 3.8 features (specifically `#private`), which is not usable in TS versions < 3.8
- **Breaking change** - `api.derive.staking.*` has updated result types and detects support for lazy payouts queries
Contributed:
- Rework type generation for `api.{query, tx}` to properly handle complex type inputs (Thanks to https://github.com/monitz87)
- Rework metadata `--strict` mode to effectively decorate chain metadata (Thanks to https://github.com/monitz87)
- Add `api.rpc.chain.subscribeAllHeads` (not just best) (Thanks to https://github.com/jak-pan)
Changes:
- Add `api.rpc.engine.*` for manual seal support
- Add `api.injectMetadata(metadata)` to initialize API with a specific metadata version
- The api now checks for runtime upgrades, augmenting the interfaces with new metadata when found
@@ -443,8 +613,12 @@ Upgrade priority: Medium, especially if using contracts.
## 1.3.1 Feb 18, 2020
Contributed:
- Add `@types/bn.js` as a normal dependency, exposed in `*.d.ts` (Thanks to https://github.com/monitz87)
Changes:
- Type generation scripts (including `polkadot-types-from-{chain,defs}`) has been moved to the `@polkadot/typegen` package
- The `@polkadot/types/codec/create` has been moved to `@polkadot/types/create`, imports from `@polkadot/types` are unaffected
- Expose chain properties on registry (and use for API type formatting)
@@ -455,8 +629,12 @@ Upgrade priority: Medium, especially if using contracts.
- **Important** Update RPC status codes (latest Substrate 2), with the `isInBlock` (`isFinalized` now indicates finality)
Contributed:
- Storage `.entries(arg?: any)` now has the correct argument type for DoubleMap (Thanks to https://github.com/monitz87)
Changes:
- Swap Kusama and Polkadot aliases for `Address` to `AccountId` (future update)
- Add `LookupSource` and `LookupTarget` types instead of mapping these directly for aliasing
- Add `BitVec` type primitive
@@ -476,6 +654,8 @@ Upgrade priority: Medium, especially if using contracts.
- **Important** Chains without `balances.account` or `system.account` should supply `"BalanceLock": "BalanceLockTo212"` to their types to use the previous-generation `BalanceLock` (when querying locks)
Changes:
- Add support for `balances.account` in all applicable derives (incl. `vesting` module)
- Inject and use SignedExtensions by name from V11 metadata (V4 extrinsics only)
- Add typings for `api.tx.*.*` - the `polkadot-types-from-chain` now also generates these
@@ -492,9 +672,13 @@ Upgrade priority: Medium, especially if using contracts.
- **Breaking change** Drop support for Substrate v1 chain in all derives
Contributed:
- Return unsub functions from provider .on emitters (Thanks to https://github.com/jak-pan)
- `ApiPromise.isReady` now rejects on unrecoverable errors (Thanks to https://github.com/laec)
Changes:
- Add `polkadot-types-from-chain` & `polkadot-types-from-defs` TypeScript generators to `@polkadot/types`
- Only decorate derives where relevant parent `api.query.*` is available
- Support `.entries(arg?: any)` lookups on DoubleMaps (in addition to previously supported maps)
@@ -514,10 +698,15 @@ Upgrade priority: Medium, especially if using contracts.
- **Important** This will the the last API version with Substrate 1.x support. Although you will still be able to use subsequent versions with older chains, dependent libraries such as sr25519 may not be compatible.
Contributed:
- Add support for `BTreeSet` (Thanks to https://github.com/satellitex)
Changes:
- Add support for the Substrate identity module
- Remove the `codec/Data` type, to remove a conflict with Substrate. This type is now named `Raw`
- Fix for linked maps using `Option`
- Add support for `BTreeSet` (Thanks to https://github.com/satellitex)
- Add support for Metadata v10
- Add support for latest Polkadot/Substrate types
- Add `paymentInfo` to submittables to calculate fees
@@ -528,6 +717,8 @@ Upgrade priority: Medium, especially if using contracts.
- **Breaking change** The `Data` and `U8a` type has been renamed and just replaced with the `Raw` type
- **Breaking change** The `api.derive.staking.info` has been split into 2 - `staking.query` for non-balance related information (more effective) and `staking.account` that enhances query for all the information previously found `.info`
Changes:
- Cleanup `DoubleMap` hashing to always hash over the full value (in the case of `Vec<T>`, this includes the length)
- Update democracy derives to take care of nextTally and lowestUnbaked
- Add additional derives for both council & treasury
@@ -536,10 +727,14 @@ Upgrade priority: Medium, especially if using contracts.
## 0.98.1 Dec 04, 2019
Contributed:
- Make the TypeScript generation script mor re-usable (Thanks to https://github.com/xlc)
- Add `.entries()` for all map-types, returning storage keys and values
- Add `.signAsync` to submittable extrinsics (Thanks to https://github.com/c410-f3r)
Changes:
- Cleanup circular references between internal dependencies
- Support for new Substrate democracy with preimages in derive
- Alignment of types with Substrate/Polkadot master branches
@@ -552,6 +747,8 @@ Upgrade priority: Medium, especially if using contracts.
- **Breaking change** Session `Keys` defaults to 4 keys now (Substrate master), depending on your node config, you would want to override with e.g. `Keys: 'SessionKeys3'` (1, 2, 3, 4, 5 & 6)
- **Breaking change** `ValidatorPrefs` now default to the new percentage commission model, to use the previous `validatorPayment`, you can override with `ValidatorPrefs: 'ValidatorPrefsTo196'`
Changes:
- `api.derive.*` now has built-in memomization
- Various fixes and cleanups to `api.derive.*` including era length progress and vesting calculations
- Aligned all types with the latest Polkadot & Substrate, including Kusama CC3
@@ -561,6 +758,8 @@ Upgrade priority: Medium, especially if using contracts.
## 0.96.1 Nov 09, 2019
Changes:
- Updated types for latest Kusama
- Add `filterRecords` (in addition to `findRecord`) on submittable results
- Various ABI v2 contract fixes
@@ -572,22 +771,28 @@ Upgrade priority: Medium, especially if using contracts.
## 0.95.2 Oct 25, 2019
Changes:
- Temporary removal of `account_nextIndex` use, will be re-added in a future release
## 0.95.1 Oct 25, 2019
- **Breaking change** `Call.injectMethods` is moved to `Call.injectMetadata` to align with `Events` (This _should_ not be used externally, however mentioned as breaking here)
Changes:
- Support Extrinsic V4 with additional signature indicator (Latest Polkadot/Substrate/Kusama)
- Adjust subscription update checks to avoid duplicated data updates
- Support Metadata V8 (exposes per-module `decl_error` definitions)
- Support next generation contracts ABI (with additional type definitions)
- Support for `BTreeMap<K, V>` types and definitions
- All latest Polkadot & Substrate types (as per master branches)
- **Breaking change** `Call.injectMethods` is moved to `Call.injectMetadata` to align with `Events` (This _should_ not be used externally, however mentioned as breaking here)
## 0.94.1 Oct 07, 2019
Changes:
- Add handling of `Result<Ok, Error>` definitions
- Adjust API cloning now takes RPC filters from source into account
- Simplification of isPedantic checks and less overhead on StorageData types
@@ -601,6 +806,8 @@ Upgrade priority: Medium, especially if using contracts.
## 0.93.1 Sep 26, 2019
Changes:
- Support for Kusama CC2
- In extrinsic submission, use `rpc.account.nextIndex` to retrieve the nonce when available
- For TypeScript users `api.query.*.*` is now properly typed for default Substrate calls, i.e. `api.query.balances.freeBalance(...)` will return a `Balance` type. Additionally the `api.queryMulti` and `.multi` on queries not allow generic type params.
@@ -612,6 +819,8 @@ Upgrade priority: Medium, especially if using contracts.
## 0.92.1 Sep 12, 2019
Changes:
- The API now correctly sets the ss58 prefix as retrieved from the chain properties via `ss58Format`
- Bump to `@polkadot/util` 1.4.1, removing use of `ExtError`
- The `Keyring` from `@polkadot/keyring` is now exposed on the API as well. You can do `import { Keyring } from '@polkadot/api'` - this alleviates the need for extra dependencies (apart from `@polkadot/api`), and since the keyring is critical for signing operations, aligns everything in one bundle
@@ -621,6 +830,8 @@ Upgrade priority: Medium, especially if using contracts.
## 0.91.1 Sep 09, 2019
Changes:
- This release was focussed on stability, with a number of cleanups and bug-fixes
- Adjustments for Substrate 1.x chain detection (with auto-types) and Substrate 2.x support has been extended with all latest types
- The `getRuntimeVersion` and `subscribeRuntimeVersion` RPCs are now only available on the `rpc.state.*` endpoints. This aligns with the Substrate implementation.
@@ -648,6 +859,8 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
- For moved types, a previous import would have been from `@polkadot/types`, i.e. `import { SetIndex } from '@polkadot/types`, now just the interfaces (TypeScript) are available via `import { SetIndex } from '@polkadot/types/interfaces`
- `usize` is now a blacklisted type that will throw on construction. Since it is platform-specific, it creates incompatibilities between native (generally `u64`) and WASM (always `u32`) code. Use one of the `u32` or `u64` types explicitly.
Changes:
- Support substrate v7 metadata
- The `Method.findFunction(callIndex)` (allowing decoding of raw data), is now available on `api.findCall(callIndex)`. To keep backwards compatibility, it is still available on `GenericCall.findMethod` but the `api.findCall` is recommended and suggested.
- The `types/codec/createType` has been moved to `types/codec/create` with the same exports. If you explicitly imported from here (and not doing the suggested `import { createType } from '@polkadot/types`), the reference needs to be updated
@@ -655,6 +868,8 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
## 0.82.0-beta.x Jul 28, 2019
Changes:
- Support for substrate 2.x (master) has been extended,
- Additional types have been addedd for the modules
- `api.derive.contract` is now `api.derive.contracts` to align with the substrate 2.x rename. (Feature detection is used so it supports both 1.x and 2.x chains)
@@ -674,6 +889,8 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
## 0.81.1 Jun 14, 2019
Changes:
- The dependency on `@polkadot/keyring` has been removed - if you relied on the API to provide this, you would now need to manually add it
- `createType` allows for the creation of `[u8; <length>]` types (opening the door for contract support)
- `api.derive.staking.info` now returns the `rewardDestination`
@@ -694,6 +911,8 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
## 0.80.1 Jun 04, 2019
Changes:
- Support for mortal transactions
- Better DoubleMap storage support
- api-derive cleanups, including additional info for balances.all and taking.info returning redeemable and locked balances
@@ -704,6 +923,8 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
## 0.79.1 May 22, 2019
Changes:
- DoubleMap query support
- Support latest EventRecord metadata (substrate master)
- Introduce RuntimeVersion type overrides in api/nodeCompat.ts
@@ -716,6 +937,8 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
## 0.78.1 May 08, 2019
Changes:
- Fix linked-maps (not working since 0.77.1)
- Convert Usize to U32 (as found in WASM environments)
- Allow pre-bundled metadata in API create & constructor
@@ -727,12 +950,16 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
## 0.77.1 Apr 25, 2019
Changes:
- Support Metadata v4, which introduces the use of a custom hasher to hash storage map keys.
- Add TreasuryProposal (not the same as democracy, type aliased)
## 0.76.1 Apr 03, 2019
Changes:
- Caching improvements (duplicate queries, no duplicate subscriptions)
- Experimental contract API
- Update @polkadot/keyring to enable Alice's stash account on dev chains
@@ -741,11 +968,15 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
## 0.75.1 Mar 29, 2019
Changes:
- Start journey to 1.0
## 0.53.1 Mar 29, 2019
Changes:
- Change spelling to US English as per substrate master (1.0-rc1). Breaking changes as a result:
- For extrinsic status results, if you have checked the type returns, i.e. `result.type === 'Finalised'` now check on the status for `result.status.isFinalized` or `result.status.isBroadcast`, ... (the `type` property is now accessible only on `result.status.type`)
- If using `subscribeFinalisedHeads` update this to `subscribeFinalizedHeads` (likewise `getFinalisedHead` should be updated to `getFinalizedHead` and `derive.bestNumberFinalized`)
@@ -756,6 +987,8 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
## 0.52.1 Mar 28, 2019
Changes:
- Support queries to linked mapped storage (found in new staking interfaces)
- Add `derive.staking.controllers` to retrieve all active staking controllers
- Align types as per latest substrate master
@@ -766,34 +999,46 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
## 0.51.1 Mar 25, 2019
Changes:
- Support metadata V2 as per latest substrate master
- Update metadata with new types as per latest substrate master
## 0.50.1 Mar 23, 2019
Changes:
- Latest util-crypto (usage of WASM with JS fallbacks if not available)
- Update upstream @polkadot dependencies (for new crypto)
## 0.49.1 Mar 20, 2019
Changes:
- Fix large message signing on non-known nodes (default is now hashing, there has been enough time between upgrades)
## 0.48.1 Mar 18, 2019
Changes:
- Pull in new sr25519 capable keyring for dev nodes
- When using dev mode, it assumes that the node is the latest with derived sr25519 keys
## 0.47.1 Mar 14, 2019
Changes:
- Swap to publishing -beta.x on merge (non-breaking testing)
## 0.46.1 Mar 01, 2019
Changes:
- Extended type registration to now handle internal types as well. Additionally the built-in Extrinsic type can now we overridden with a custom version.
- Where `Extrinsic` and `Method` is used as types, consider importing `{ IMethod, IExtrinsic }` from `@polkadot/types/types`, especially in the cases where this is used from a `SubmittableExtrinsic`
- The `typeRegistry` constant is now `getTypeRegistry()` as a function
@@ -801,6 +1046,8 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
## 0.45.1 Feb 19, 2019
Changes:
- Storage with option values now correctly return `Option<Type>` and is indicated as such in the documentation
```js
@@ -818,6 +1065,8 @@ console.log('llo', llo.unwrapOr('not set') /* Option<BlockNumber> */)
## 0.44.1 Feb 19, 2019
Changes:
- Split primitives and types into separate folders. This should not affect external use since the exports remain the same, however does have an impact where classes are referenced directly. e.g.
```js
@@ -836,37 +1085,51 @@ import { Method, Signature } from '@polkadot/types';
## 0.43.1 Feb 14, 2019
Changes:
- Introduces support for the new keyring with sr25519 support in addition to ed25519. While this does not change the exposed API, it is considered breaking since @polkadot/keyring has interface changes. (Unless needed, don't rush the upgrade)
## 0.42.1 Jan 31, 2019
Changes:
- Support for substrate hash signing with implVersion >= 18
- Changed signatures for Extrinsic signing, this should not have (much) of an impact since it is generally not used directly. SubmittableExtrinsic (as exposed by the API), supports the old-style use.
## 0.41.1 Jan 26, 2019
Changes:
- Support the V1 metadata specification from Substrate in addition to the currently testnet active V0 version
## 0.40.1 Jan 16, 2019
Changes:
- The API interfaces now require a WS-compatible provider, e.g. subscription support is a must. Previously the HTTPProvider could be use (although it was very limited in the interactions).
## 0.39.1 Jan 11, 2019
Changes:
- The Promise API now returns a `Promise<UnsubFunction>` instead of `UnsubFunction` when making subscriptions.
## 0.38.1 Jan 08, 2019
Changes:
Substrate has been updated with a breaking new transaction format where the Index/Nonce is now encoded as a Compact. This change is being rolled out to both Alexander (Polkadot testnet) as well as Charred Cherry (Substrate testnet) - transactions between old and new are not compatible.
## 0.37.1 Jan 04, 2019
Changes:
api-observable has been removed. This was only used in /apps and inconsistent with the api/rx and api/promise APIs. Future work will include derives like was included in api-observable into the base.
Tuples now return single types when only one type is available, i.e. `(AccountId)` would now resolve as `AccountId`. The extra type wrapper adds no benefit to users here.
@@ -874,6 +1137,8 @@ Tuples now return single types when only one type is available, i.e. `(AccountId
## 0.36.1 Jan 03, 2019
Changes:
Api Promise has been updated in the way we deal with subscriptions. Previously a subscription returned `Promise<number>` where the caller was to keep track of the id and use it in subsequent unsubscribes. Now any subscriptions return an unsubscribe/destroy function `(): void`, that is use for removing the subscriptions, e.g.
```js
@@ -885,11 +1150,15 @@ unsubscribe(); // here we destroy the subscription
## 0.35.1 Dec 20, 2018
Changes:
Swapped to new metadata structures from Substrate. If the API is not working with your node, update Substrate to latest master branch. (Or 0.9.1 for Charred Cherry). Dropped support for old metadata as found as far back as BBQ Birch.
## 0.34.1 Dec 18, 2018
Changes:
Changed the send signature (for future expansion of eg. events) to return `result: { status: ExtrinsicStatus }` instead of `status: ExtrinsicStatus`. For most cases where only status `type` checks are used, i.e. `status.type === 'Finalised'` this should not be a breaking change. Deep inspection of the status object however will need to adapt.
## 0.33.1 Dec 06, 2018
+1 -2
View File
@@ -1,5 +1,4 @@
// Copyright 2017-2020 @polkadot/api authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
module.exports = require('@polkadot/dev/config/babel');
+2
View File
@@ -1,4 +1,6 @@
#!/usr/bin/env bash
# Copyright 2017-2020 @polkadot/api authors & contributors
# SPDX-License-Identifier: Apache-2.0
function copy_folder () {
SRC="packages/$1/build"
+2
View File
@@ -1,4 +1,6 @@
#!/usr/bin/env bash
# Copyright 2017-2020 @polkadot/api authors & contributors
# SPDX-License-Identifier: Apache-2.0
function copy_folder () {
SRC="packages/$1/build"
+12 -1
View File
@@ -53,8 +53,19 @@ const signedBlock = await this.api.rpc.chain.getBlock();
// the information for each of the contained extrinsics
signedBlock.block.extrinsics.forEach((ex, index) => {
// the extrinsics are decoded by the API
// the extrinsics are decoded by the API, human-like view
console.log(index, ex.toHuman());
const { isSigned, meta, method: { args, method, section } } = ex;
// explicit display of name, args & documentation
console.log(`${section}.${method}(${args.map((a) => a.toString()).join(', ')})`);
console.log(meta.documentation.map((d) => d.toString()).join('\n'));
// signer/nonce info
if (isSigned) {
console.log(`signer=${ex.signer.toString()}, nonce=${ex.nonce.toString()}`);
}
});
```
+2 -2
View File
@@ -49,7 +49,7 @@ The API creation is done via the `ApiPromise.create` interface which is a shortc
```js
ApiPromise
.create({ provider: wsProvider })
.create({ provider: wsProvider }).isReady
.then((api) =>
console.log(api.genesisHash.toHex())
);
@@ -70,7 +70,7 @@ console.log(api.genesisHash.toHex());
## Failures
In all cases the API will handle reconnections automatically. This means that when you connect and the endpoint is not (yet) ready, the promise will not resolve immediately, but rather when connected. The same applies to when connection is lost, the API will manage re-connections.
In all cases the API will handle reconnecting automatically. This means that when you connect and the endpoint is not (yet) ready, the promise will not resolve immediately, but rather when connected. The same applies to when connection is lost, the API will manage re-connections.
In cases where the API does not support the chain being connected to, such as it using an unknown metadata version, the ready promise will fail to resolve and instead reject.
+2
View File
@@ -10,6 +10,7 @@ As a minimum, anything returned by the API, be it a `Vec<...>`, `Option<...>`, `
- `.eq(<other value>)` - checks for equality against the other value. In all cases, it will accept "like" values, i.e. in the case of a number you can pass a primitive (such as `1`), a hex value (such as `0x01`) or even an `Unit8Array`
- `toHex()` - returns a hex-base representation of the value, always prefixed by `0x`
- `toHuman()` - returns Human-parsable JSON structure with values formatted as per the settings
- `toJSON()` - returns a JSON-like representation of the value, this is generally used when calling `JSON.stringify(...)` on the value
- `toString()` - returns a string representation, in some cases this performs additional encoding, i.e. for `Address`, `AccountId` and `AccountIndex` it will encode to the ss58 address
- `.toU8a()` - returns a `Uint8Array` representation of the encoded value (generally exactly as passed to the node, where values are SCALE encoded)
@@ -41,6 +42,7 @@ const system = modules.find(m => m.name.eq('system'));
All numbers wrap and extend an instance of [bn.js](https://github.com/indutny/bn.js/). This means that in addition to the interfaces defined above, they have some additional methods -
- `.toNumber()` - a JS number (limited to 2^53 - 1). This does mean that for large values, e.g. `Balance` (a `u128` extension), this can cause overflows
- `.toBigInt()` - a JS `BigInt` object (on supported platforms)
- `.add(...)`, `.sub(...)`, ... - all the base methods available on the `BN` object
In cases where a `Compact` is returned, i.e. `Compact<Balance>`, the value is wrapped. This object should be `.unwrap()`-ed first to gain access to the underlying `Balance` object.
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
const config = require('@polkadot/dev/config/jest');
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
const path = require('path');
+1 -1
View File
@@ -9,5 +9,5 @@
"packages": [
"packages/*"
],
"version": "1.31.1"
"version": "1.34.1"
}
+10 -9
View File
@@ -7,7 +7,8 @@
"packages/*"
],
"resolutions": {
"babel-core": "^7.0.0-bridge.0"
"babel-core": "^7.0.0-bridge.0",
"typescript": "^4.0.2"
},
"scripts": {
"build": "yarn build:interfaces && polkadot-dev-build-ts && (cd packages/typegen && copyfiles scripts/* build)",
@@ -24,18 +25,18 @@
"test:watch": "polkadot-dev-run-test --watch"
},
"devDependencies": {
"@babel/core": "^7.11.4",
"@babel/register": "^7.10.5",
"@babel/core": "^7.11.6",
"@babel/register": "^7.11.5",
"@babel/runtime": "^7.11.2",
"@polkadot/dev": "^0.55.43",
"@polkadot/ts": "^0.3.40",
"@polkadot/dev": "^0.55.53",
"@polkadot/ts": "^0.3.47",
"@polkadot/typegen": "workspace:packages/typegen",
"@types/jest": "^26.0.10",
"@types/jest": "^26.0.13",
"@vuepress/plugin-search": "^1.5.4",
"copyfiles": "^2.3.0",
"typedoc": "^0.18.0",
"typedoc": "^0.19.1",
"typedoc-plugin-markdown": "^2.4.2",
"typedoc-plugin-no-inherit": "^1.1.10"
"typedoc-plugin-no-inherit": "^1.2.0"
},
"version": "1.31.1"
"version": "1.34.1"
}
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-contract",
"version": "1.31.1",
"version": "1.34.1",
"description": "Interfaces for interacting with contracts and contract ABIs",
"main": "index.js",
"keywords": [
@@ -27,11 +27,11 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
"dependencies": {
"@babel/runtime": "^7.11.2",
"@polkadot/api": "1.31.1",
"@polkadot/rpc-core": "1.31.1",
"@polkadot/types": "1.31.1",
"@polkadot/api": "1.34.1",
"@polkadot/rpc-core": "1.34.1",
"@polkadot/types": "1.34.1",
"@polkadot/util": "^3.4.1",
"bn.js": "^5.1.3",
"rxjs": "^6.6.2"
"rxjs": "^6.6.3"
}
}
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { TypeRegistry } from '@polkadot/types';
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { Registry } from '@polkadot/types/types';
import { AbiConstructors, AbiMessages, ContractABI, ContractABIPre, ContractABIFn, InterfaceAbi } from './types';
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { CodecArg, Constructor, Registry, TypeDef } from '@polkadot/types/types';
import { ContractABIArgBasePre, ContractABIContract, ContractABIContractPre, ContractABIEvent, ContractABIEventPre, ContractABIFn, ContractABIFnArg, ContractABIMessage, ContractABIMessageBase, ContractABIMessagePre, ContractABI, ContractABIMessageCommon, ContractABIPre, ContractABIRange, ContractABIRangePre, ContractABIStorage, ContractABIStorageLayout, ContractABIStorageLayoutPre, ContractABIStoragePre, ContractABIStorageStruct, ContractABIStorageStructPre, ContractABITypePre } from './types';
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/types authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { TypeRegistry } from '@polkadot/types';
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { MetaRegistryItem, MetaRegistryJson, MetaTypeDefClikeEnum, MetaType, MetaTypeDefEnum, MetaTypeDefEnumVariant, MetaTypeDefEnumVariantStruct, MetaTypeDefEnumVariantTupleStruct, MetaTypeDefEnumVariantUnit, MetaTypeDefStruct, MetaTypeDefStructField, MetaTypeDefTupleStruct, MetaTypeDefUnion, MetaTypeIdCustom, MetaTypeIdVec, MetaTypeIdVecFixed, MetaTypeInfo, Registry, StringIndex, TypeDef, TypeDefInfo, TypeIndex } from '@polkadot/types/types';
+2 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import { AccountId, Address, Hash } from '@polkadot/types/interfaces';
@@ -17,6 +16,7 @@ import Abi from '../Abi';
import Contract from './Contract';
import { BaseWithTx } from './util';
// eslint-disable-next-line no-use-before-define
type BlueprintCreateResultSubscription<ApiType extends ApiTypes> = Observable<BlueprintCreateResult<ApiType>>;
export interface BlueprintCreate<ApiType extends ApiTypes> {
+2 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import { AccountId, Address, Hash } from '@polkadot/types/interfaces';
@@ -17,6 +16,7 @@ import Abi from '../Abi';
import Blueprint from './Blueprint';
import { BaseWithTx } from './util';
// eslint-disable-next-line no-use-before-define
type CodePutCodeResultSubscription<ApiType extends ApiTypes> = Observable<CodePutCodeResult<ApiType>>;
export interface CodePutCode<ApiType extends ApiTypes> {
+3 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ApiTypes, DecorateMethod, ObsInnerType } from '@polkadot/api/types';
import { AccountId, Address, ContractExecResult } from '@polkadot/types/interfaces';
@@ -18,7 +17,9 @@ import { BaseWithTxAndRpcCall } from './util';
type ContractCallTypes = 'tx' | 'rpc';
type ContractCallResultSubscription<ApiType extends ApiTypes, CallType extends ContractCallTypes> = ApiType extends 'rxjs'
// eslint-disable-next-line no-use-before-define
? Observable<ContractCallResult<CallType>>
// eslint-disable-next-line no-use-before-define
: Promise<ObsInnerType<ContractCallResult<CallType>>>;
export interface ContractCall<ApiType extends ApiTypes, CallType extends ContractCallTypes> {
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
export { default as Blueprint } from './Blueprint';
export { default as Code } from './Code';
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ApiTypes, DecorateMethod, DecoratedRpc, SubmittableModuleExtrinsics } from '@polkadot/api/types';
import { RpcInterface } from '@polkadot/rpc-core/types';
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
export { default as Abi } from './Abi';
export * from './rx';
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { Hash } from '@polkadot/types/interfaces';
import { ContractABIPre } from '../types';
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ContractABIPre } from '../types';
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { AccountId } from '@polkadot/types/interfaces';
import { ContractABIPre } from '../types';
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
export { default as PromiseBlueprint } from './PromiseBlueprint';
export { default as PromiseCode } from './PromiseCode';
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { Hash } from '@polkadot/types/interfaces';
import { ContractABIPre } from '../types';
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ContractABIPre } from '../types';
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { AccountId } from '@polkadot/types/interfaces';
import { ContractABIPre } from '../types';
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
export { default as RxBlueprint } from './RxBlueprint';
export { default as RxCode } from './RxCode';
+5 -2
View File
@@ -1,14 +1,17 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import { AccountId, Address, ContractExecResult } from '@polkadot/types/interfaces';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Codec, CodecArg } from '@polkadot/types/types';
import { MetaRegistryJson, StringIndex, TypeIndex, TypeDef } from '@polkadot/types/create/types';
import { ApiPromise, ApiRx } from '@polkadot/api';
// I give up, too hard to untangle atm... and is basically deprecated
/* eslint-disable no-use-before-define */
export type ApiObject<ApiType extends ApiTypes> = ApiType extends 'rxjs'
? ApiRx
: ApiPromise;
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/rpc-core authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { Codec, Registry, TypeDef, TypeDefInfo } from '@polkadot/types/types';
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-derive",
"version": "1.31.1",
"version": "1.34.1",
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
"main": "index.js",
"keywords": [
@@ -28,15 +28,15 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"dependencies": {
"@babel/runtime": "^7.11.2",
"@polkadot/api": "1.31.1",
"@polkadot/rpc-core": "1.31.1",
"@polkadot/rpc-provider": "1.31.1",
"@polkadot/types": "1.31.1",
"@polkadot/api": "1.34.1",
"@polkadot/rpc-core": "1.34.1",
"@polkadot/rpc-provider": "1.34.1",
"@polkadot/types": "1.34.1",
"@polkadot/util": "^3.4.1",
"@polkadot/util-crypto": "^3.4.1",
"bn.js": "^5.1.3",
"memoizee": "^0.4.14",
"rxjs": "^6.6.2"
"rxjs": "^6.6.3"
},
"devDependencies": {
"@polkadot/keyring": "^3.4.1"
@@ -0,0 +1,42 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { isU8a, assert } from '@polkadot/util';
import { decodeAddress } from '@polkadot/util-crypto';
import { memo } from '../util';
function retrieve (api: ApiInterfaceRx, address: Address | AccountId | AccountIndex | string | null | undefined): Observable<AccountId> {
const decoded = isU8a(address)
? address
: decodeAddress((address || '').toString());
if (decoded.length === 32) {
return of(api.registry.createType('AccountId', decoded));
}
const accountIndex = api.registry.createType('AccountIndex', decoded);
return api.derive.accounts.indexToId(accountIndex.toString()).pipe(
map((accountId) => {
assert(accountId, 'Unable to retrieve accountId');
return accountId;
})
);
}
/**
* @name accountId
* @param {(Address | AccountId | AccountIndex | string | null)} address - An accounts address in various formats.
* @description An [[AccountId]]
*/
export function accountId (instanceId: string, api: ApiInterfaceRx): (address?: Address | AccountId | AccountIndex | string | null) => Observable<AccountId> {
return memo(instanceId, (address?: Address | AccountId | AccountIndex | string | null): Observable<AccountId> =>
retrieve(api, address));
}
+3 -4
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { AccountId, Address, Balance } from '@polkadot/types/interfaces';
@@ -31,8 +30,8 @@ function isIncludedFn (accountId: AccountId | Address | string): (_: AccountId |
* @name info
* @description Returns account membership flags
*/
export function flags (api: ApiInterfaceRx): (address?: AccountId | Address | string | null) => Observable<DeriveAccountFlags> {
return memo((address?: AccountId | Address | string | null): Observable<DeriveAccountFlags> => {
export function flags (instanceId: string, api: ApiInterfaceRx): (address?: AccountId | Address | string | null) => Observable<DeriveAccountFlags> {
return memo(instanceId, (address?: AccountId | Address | string | null): Observable<DeriveAccountFlags> => {
const councilSection = api.query.electionsPhragmen ? 'electionsPhragmen' : 'elections';
return (
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
import { AccountIdAndIndex } from '../types';
@@ -51,7 +50,7 @@ function retrieve (api: ApiInterfaceRx, address: Address | AccountId | AccountIn
* });
* ```
*/
export function idAndIndex (api: ApiInterfaceRx): (address?: Address | AccountId | AccountIndex | string | null) => Observable<AccountIdAndIndex> {
return memo((address?: Address | AccountId | AccountIndex | string | null): Observable<AccountIdAndIndex> =>
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> =>
retrieve(api, address));
}
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { AccountId, AccountIndex } from '@polkadot/types/interfaces';
import { AccountIndexes } from '../types';
@@ -25,8 +24,8 @@ import { memo } from '../util';
* });
* ```
*/
export function idToIndex (api: ApiInterfaceRx): (accountId: AccountId | string) => Observable<AccountIndex | undefined> {
return memo((accountId: AccountId | string): Observable<AccountIndex | undefined> =>
export function idToIndex (instanceId: string, api: ApiInterfaceRx): (accountId: AccountId | string) => Observable<AccountIndex | undefined> {
return memo(instanceId, (accountId: AccountId | string): Observable<AccountIndex | undefined> =>
api.derive.accounts.indexes().pipe(
map((indexes: AccountIndexes): AccountIndex | undefined =>
(indexes || {})[accountId.toString()]
+2 -2
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
export * from './accountId';
export * from './flags';
export * from './idAndIndex';
export * from './idToIndex';
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { AccountId, AccountIndex, BalanceOf } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
@@ -49,8 +48,8 @@ function query (api: ApiInterfaceRx, accountIndex: AccountIndex | string): Obser
* });
* ```
*/
export function indexToId (api: ApiInterfaceRx): (accountIndex: AccountIndex | string) => Observable<AccountId | undefined> {
return memo((accountIndex: AccountIndex | string): Observable<AccountId | undefined> =>
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)
+3 -4
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { AccountId, AccountIndex } from '@polkadot/types/interfaces';
@@ -72,8 +71,8 @@ function queryAccounts (api: ApiInterfaceRx): Observable<AccountIndexes> {
* });
* ```
*/
export function indexes (api: ApiInterfaceRx): () => Observable<AccountIndexes> {
return memo((): Observable<AccountIndexes> =>
export function indexes (instanceId: string, api: ApiInterfaceRx): () => Observable<AccountIndexes> {
return memo(instanceId, (): Observable<AccountIndexes> =>
indicesCache
? of(indicesCache)
: (
+3 -4
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { AccountId, AccountIndex, Address, Balance, Registration } from '@polkadot/types/interfaces';
@@ -113,8 +112,8 @@ function retrieveIdentity (api: ApiInterfaceRx, accountId?: AccountId): Observab
* @name info
* @description Returns aux. info with regards to an account, current that includes the accountId, accountIndex and nickname
*/
export function info (api: ApiInterfaceRx): (address?: AccountIndex | AccountId | Address | string | null) => Observable<DeriveAccountInfo> {
return memo((address?: AccountIndex | AccountId | Address | string | null): Observable<DeriveAccountInfo> =>
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> =>
api.derive.accounts.idAndIndex(address).pipe(
switchMap(([accountId, accountIndex]): Observable<[Partial<DeriveAccountInfo>, DeriveAccountRegistration, string?]> =>
combineLatest([
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { AccountId, AccountIndex, RegistrationJudgement } from '@polkadot/types/interfaces';
+5 -6
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { AccountId, AccountData, AccountIndex, AccountInfo, Address, Balance, Index } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
@@ -80,10 +79,10 @@ function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Re
* });
* ```
*/
export function account (api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAccount> {
return memo((address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAccount> =>
api.derive.accounts.info(address).pipe(
switchMap(({ accountId }): Observable<[AccountId, Result]> =>
export function account (instanceId: string, api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAccount> {
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),
+6 -4
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// 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';
@@ -50,6 +49,7 @@ function calcBalances (api: ApiInterfaceRx, [{ accountId, accountNonce, freeBala
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 vestingEndBlock = api.registry.createType('BlockNumber', isVesting ? vestingTotal.div(perBlock).add(startingBlock) : 0);
return {
accountId,
@@ -64,7 +64,9 @@ function calcBalances (api: ApiInterfaceRx, [{ accountId, accountNonce, freeBala
reservedBalance,
vestedBalance,
vestedClaimable,
vestingEndBlock,
vestingLocked,
vestingPerBlock: perBlock,
vestingTotal,
votingBalance
};
@@ -125,8 +127,8 @@ function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Re
* });
* ```
*/
export function all (api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAll> {
return memo((address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAll> =>
export function all (instanceId: string, api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAll> {
return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAll> =>
api.derive.balances.account(address).pipe(
switchMap((account): Observable<Result> =>
(!account.accountId.isEmpty
+3 -4
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Balance } from '@polkadot/types/interfaces';
@@ -24,8 +23,8 @@ import { memo } from '../util';
* });
* ```
*/
export function fees (api: ApiInterfaceRx): () => Observable<DeriveFees> {
return memo((): Observable<DeriveFees> =>
export function fees (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveFees> {
return memo(instanceId, (): Observable<DeriveFees> =>
of([
// deprecated - remove
(api.consts.balances?.creationFee as unknown as Balance) || api.registry.createType('Balance'),
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { all } from './all';
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
import { DeriveBalancesAccount } from '../types';
@@ -10,8 +9,8 @@ import { ApiInterfaceRx } from '@polkadot/api/types';
import { memo } from '../util';
export function votingBalances (api: ApiInterfaceRx): (addresses?: (AccountId | AccountIndex | Address | string)[]) => Observable<DeriveBalancesAccount[]> {
return memo((addresses?: (AccountId | AccountIndex | Address | string)[]): Observable<DeriveBalancesAccount[]> =>
export function votingBalances (instanceId: string, api: ApiInterfaceRx): (addresses?: (AccountId | AccountIndex | Address | string)[]) => Observable<DeriveBalancesAccount[]> {
return memo(instanceId, (addresses?: (AccountId | AccountIndex | Address | string)[]): Observable<DeriveBalancesAccount[]> =>
!addresses || !addresses.length
? of([] as DeriveBalancesAccount[])
: combineLatest(
+3 -4
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { BlockNumber } from '@polkadot/types/interfaces';
@@ -22,8 +21,8 @@ import { memo } from '../util';
* });
* ```
*/
export function bestNumber (api: ApiInterfaceRx): () => Observable<BlockNumber> {
return memo((): Observable<BlockNumber> =>
export function bestNumber (instanceId: string, api: ApiInterfaceRx): () => Observable<BlockNumber> {
return memo(instanceId, (): Observable<BlockNumber> =>
api.derive.chain.subscribeNewHeads().pipe(
map((header) => header.number.unwrap())
));
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { BlockNumber } from '@polkadot/types/interfaces';
@@ -23,8 +22,8 @@ import { memo } from '../util';
* });
* ```
*/
export function bestNumberFinalized (api: ApiInterfaceRx): () => Observable<BlockNumber> {
return memo((): Observable<BlockNumber> =>
export function bestNumberFinalized (instanceId: string, api: ApiInterfaceRx): () => Observable<BlockNumber> {
return memo(instanceId, (): Observable<BlockNumber> =>
api.rpc.chain.subscribeFinalizedHeads().pipe(
map((header) => header.number.unwrap())
));
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { BlockNumber } from '@polkadot/types/interfaces';
@@ -23,8 +22,8 @@ import { memo } from '../util';
* });
* ```
*/
export function bestNumberLag (api: ApiInterfaceRx): () => Observable<BlockNumber> {
return memo((): Observable<BlockNumber> =>
export function bestNumberLag (instanceId: string, api: ApiInterfaceRx): () => Observable<BlockNumber> {
return memo(instanceId, (): Observable<BlockNumber> =>
combineLatest([
api.derive.chain.bestNumber(),
api.derive.chain.bestNumberFinalized()
+43
View File
@@ -0,0 +1,43 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Observable, combineLatest, of } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
import { SignedBlockExtended } from '../type';
import { memo } from '../util';
/**
* @name getBlock
* @param {( Uint8Array | string )} hash - A block hash as U8 array or string.
* @description Get a specific block (e.g. rpc.chain.getBlock) and extend it with the author
* @example
* <BR>
*
* ```javascript
* const { author, number } = await api.derive.chain.getHeader('0x123...456');
*
* console.log(`block #${number} was authored by ${author}`);
* ```
*/
export function getHeader (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.session
? api.query.session.validators.at(hash)
: of([])
]).pipe(
map(([signedBlock, validators]): SignedBlockExtended =>
new SignedBlockExtended(api.registry, signedBlock, validators)
),
catchError((): Observable<undefined> =>
// where rpc.chain.getHeader throws, we will land here - it can happen that
// we supplied an invalid hash. (Due to defaults, storeage will have an
// empty value, so only the RPC is affected). So return undefined
of()
)
));
}
+3 -4
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
@@ -24,8 +23,8 @@ import { memo } from '../util';
* console.log(`block #${number} was authored by ${author}`);
* ```
*/
export function getHeader (api: ApiInterfaceRx): (hash: Uint8Array | string) => Observable<HeaderExtended | undefined> {
return memo((hash: Uint8Array | string): Observable<HeaderExtended | undefined> =>
export function getHeader (instanceId: string, api: ApiInterfaceRx): (hash: Uint8Array | string) => Observable<HeaderExtended | undefined> {
return memo(instanceId, (hash: Uint8Array | string): Observable<HeaderExtended | undefined> =>
combineLatest([
api.rpc.chain.getHeader(hash),
api.query.session
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
export * from './bestNumber';
export * from './bestNumberFinalized';
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
@@ -23,8 +22,8 @@ import { memo } from '../util';
* });
* ```
*/
export function subscribeNewHeads (api: ApiInterfaceRx): () => Observable<HeaderExtended> {
return memo((): Observable<HeaderExtended> =>
export function subscribeNewHeads (instanceId: string, api: ApiInterfaceRx): () => Observable<HeaderExtended> {
return memo(instanceId, (): Observable<HeaderExtended> =>
combineLatest([
api.rpc.chain.subscribeNewHeads(),
api.query.session
+1 -2
View File
@@ -1,5 +1,4 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
export * from './proposals';
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Hash, Proposal, Votes } from '@polkadot/types/interfaces';
@@ -29,8 +28,8 @@ function parse ([hashes, proposals, votes]: Result): DeriveCollectiveProposal[]
.filter((proposal): proposal is DeriveCollectiveProposal => !!proposal);
}
export function proposals (api: ApiInterfaceRx, section: 'council' | 'technicalCommittee'): () => Observable<DeriveCollectiveProposal[]> {
return memo((): Observable<DeriveCollectiveProposal[]> =>
export function proposals (instanceId: string, api: ApiInterfaceRx, section: 'council' | 'technicalCommittee'): () => Observable<DeriveCollectiveProposal[]> {
return memo(instanceId, (): Observable<DeriveCollectiveProposal[]> =>
isFunction(api.query[section]?.proposals)
? api.query[section].proposals().pipe(
switchMap((hashes: Hash[]): Observable<Result> =>
+3 -4
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { DeriveContractFees } from '../types';
@@ -45,8 +44,8 @@ function queryConstants (api: ApiInterfaceRx): Observable<ResultV2> {
* });
* ```
*/
export function fees (api: ApiInterfaceRx): () => Observable<DeriveContractFees> {
return memo((): Observable<DeriveContractFees> => {
export function fees (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveContractFees> {
return memo(instanceId, (): Observable<DeriveContractFees> => {
return queryConstants(api).pipe(
map(([callBaseFee, contractFee, creationFee, transactionBaseFee, transactionByteFee, transferFee, rentByteFee, rentDepositOffset, surchargeReward, tombstoneDeposit]): DeriveContractFees => ({
callBaseFee,
+1 -2
View File
@@ -1,5 +1,4 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
export * from './fees';
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
export * from './proposals';
export * from './votes';
+3 -4
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { DeriveCollectiveProposals } from '../types';
@@ -9,6 +8,6 @@ import { Observable } from 'rxjs';
import { proposals as collectiveProposals } from '../collective';
import { memo } from '../util';
export function proposals (api: ApiInterfaceRx): () => Observable<DeriveCollectiveProposals> {
return memo(collectiveProposals(api, 'council'));
export function proposals (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveCollectiveProposals> {
return memo(instanceId, collectiveProposals(instanceId, api, 'council'));
}
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { AccountId, Balance } from '@polkadot/types/interfaces';
+3 -4
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { AccountId, Balance } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
@@ -81,8 +80,8 @@ function retrieveCurrent (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
);
}
export function votes (api: ApiInterfaceRx): () => Observable<DeriveCouncilVotes> {
return memo((): Observable<DeriveCouncilVotes> =>
export function votes (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveCouncilVotes> {
return memo(instanceId, (): Observable<DeriveCouncilVotes> =>
(api.query.electionsPhragmen || api.query.elections).stakeOf
? retrievePrev(api)
: retrieveCurrent(api)
+3 -4
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { AccountId } from '@polkadot/types/interfaces';
import { ApiInterfaceRx } from '@polkadot/api/types';
@@ -10,8 +9,8 @@ import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { memo } from '../util';
export function votesOf (api: ApiInterfaceRx): (accountId: string | Uint8Array | AccountId) => Observable<DeriveCouncilVote> {
return memo((accountId: string | Uint8Array | AccountId): Observable<DeriveCouncilVote> =>
export function votesOf (instanceId: string, api: ApiInterfaceRx): (accountId: string | Uint8Array | AccountId) => Observable<DeriveCouncilVote> {
return memo(instanceId, (accountId: string | Uint8Array | AccountId): Observable<DeriveCouncilVote> =>
api.derive.council.votes().pipe(
map((votes): DeriveCouncilVote =>
(
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { BlockNumber, Hash, ReferendumIndex, Scheduled } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
@@ -94,8 +93,8 @@ function queryScheduler (api: ApiInterfaceRx): Observable<DeriveDispatch[]> {
);
}
export function dispatchQueue (api: ApiInterfaceRx): () => Observable<DeriveDispatch[]> {
return memo((): Observable<DeriveDispatch[]> =>
export function dispatchQueue (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveDispatch[]> {
return memo(instanceId, (): Observable<DeriveDispatch[]> =>
isFunction(api.query.scheduler?.agenda)
? queryScheduler(api)
: api.query.democracy.dispatchQueue
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
export * from './dispatchQueue';
export * from './locks';
+13 -12
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { AccountId, ReferendumInfo, ReferendumInfoTo239, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces';
import { ApiInterfaceRx } from '@polkadot/api/types';
@@ -74,16 +73,18 @@ function directLocks (api: ApiInterfaceRx, { votes }: VotingDirect): Observable<
);
}
export function locks (api: ApiInterfaceRx): (accountId: string | AccountId) => Observable<DeriveDemocracyLock[]> {
return memo((accountId: string | AccountId): Observable<DeriveDemocracyLock[]> =>
api.query.democracy.votingOf(accountId).pipe(
switchMap((voting): Observable<DeriveDemocracyLock[]> =>
voting.isDirect
? directLocks(api, voting.asDirect)
: voting.isDelegating
? delegateLocks(api, voting.asDelegating)
: of([])
export function locks (instanceId: string, api: ApiInterfaceRx): (accountId: string | AccountId) => Observable<DeriveDemocracyLock[]> {
return memo(instanceId, (accountId: string | AccountId): Observable<DeriveDemocracyLock[]> =>
api.query.democracy.votingOf
? api.query.democracy.votingOf(accountId).pipe(
switchMap((voting): Observable<DeriveDemocracyLock[]> =>
voting.isDirect
? directLocks(api, voting.asDirect)
: voting.isDelegating
? delegateLocks(api, voting.asDelegating)
: of([])
)
)
)
: of([])
);
}
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { Hash, VoteThreshold } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
@@ -29,8 +28,8 @@ function withImage (api: ApiInterfaceRx, nextOpt: Option<ITuple<[Hash, VoteThres
);
}
export function nextExternal (api: ApiInterfaceRx): () => Observable<DeriveProposalExternal | null> {
return memo((): Observable<DeriveProposalExternal | null> =>
export function nextExternal (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveProposalExternal | null> {
return memo(instanceId, (): Observable<DeriveProposalExternal | null> =>
api.query.democracy?.nextExternal
? api.query.democracy.nextExternal<Option<ITuple<[Hash, VoteThreshold]>>>().pipe(
switchMap((nextOpt) => withImage(api, nextOpt))
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { AccountId, Balance, BlockNumber, Hash } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
@@ -16,8 +15,8 @@ import { parseImage } from './util';
type PreImage = Option<ITuple<[Bytes, AccountId, Balance, BlockNumber]>>;
export function preimage (api: ApiInterfaceRx): (hash: Hash) => Observable<DeriveProposalImage | undefined> {
return memo((hash: Hash): Observable<DeriveProposalImage | undefined> =>
export function preimage (instanceId: string, api: ApiInterfaceRx): (hash: Hash) => Observable<DeriveProposalImage | undefined> {
return memo(instanceId, (hash: Hash): Observable<DeriveProposalImage | undefined> =>
api.query.democracy.preimages<PreImage>(hash).pipe(
map((imageOpt) => parseImage(api, imageOpt))
)
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { AccountId, Balance, BlockNumber, Hash } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
@@ -16,8 +15,8 @@ import { parseImage } from './util';
type PreImage = Option<ITuple<[Bytes, AccountId, Balance, BlockNumber]>>;
export function preimages (api: ApiInterfaceRx): (hashes: Hash[]) => Observable<(DeriveProposalImage | undefined)[]> {
return memo((hashes: Hash[]): Observable<(DeriveProposalImage | undefined)[]> =>
export function preimages (instanceId: string, api: ApiInterfaceRx): (hashes: Hash[]) => Observable<(DeriveProposalImage | undefined)[]> {
return memo(instanceId, (hashes: Hash[]): Observable<(DeriveProposalImage | undefined)[]> =>
api.query.democracy.preimages.multi<PreImage>(hashes).pipe(
map((images): (DeriveProposalImage | undefined)[] =>
images.map((imageOpt) => parseImage(api, imageOpt))
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { AccountId, Balance, Hash, PropIndex } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
@@ -49,8 +48,8 @@ function parse ([proposals, images, optDepositors]: Result): DeriveProposal[] {
});
}
export function proposals (api: ApiInterfaceRx): () => Observable<DeriveProposal[]> {
return memo((): Observable<DeriveProposal[]> =>
export function proposals (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveProposal[]> {
return memo(instanceId, (): Observable<DeriveProposal[]> =>
api.query.democracy?.publicProps && api.query.democracy?.preimages
? api.query.democracy.publicProps<Proposals>().pipe(
switchMap((proposals) =>
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { ReferendumIndex } from '@polkadot/types/interfaces';
@@ -11,8 +10,8 @@ import { map } from 'rxjs/operators';
import { memo } from '../util';
export function referendumIds (api: ApiInterfaceRx): () => Observable<BN[]> {
return memo((): Observable<BN[]> =>
export function referendumIds (instanceId: string, api: ApiInterfaceRx): () => Observable<BN[]> {
return memo(instanceId, (): Observable<BN[]> =>
api.query.democracy?.lowestUnbaked
? api.queryMulti<[ReferendumIndex, ReferendumIndex]>([
api.query.democracy.lowestUnbaked,
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { DeriveReferendumExt } from '../types';
@@ -10,8 +9,8 @@ import { map, switchMap } from 'rxjs/operators';
import { memo } from '../util';
export function referendums (api: ApiInterfaceRx): () => Observable<DeriveReferendumExt[]> {
return memo((): Observable<DeriveReferendumExt[]> =>
export function referendums (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveReferendumExt[]> {
return memo(instanceId, (): Observable<DeriveReferendumExt[]> =>
api.derive.democracy.referendumsActive().pipe(
switchMap((referendums) =>
combineLatest([
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { DeriveReferendum } from '../types';
@@ -10,8 +9,8 @@ import { switchMap } from 'rxjs/operators';
import { memo } from '../util';
export function referendumsActive (api: ApiInterfaceRx): () => Observable<DeriveReferendum[]> {
return memo((): Observable<DeriveReferendum[]> =>
export function referendumsActive (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveReferendum[]> {
return memo(instanceId, (): Observable<DeriveReferendum[]> =>
api.derive.democracy.referendumIds().pipe(
switchMap((ids): Observable<DeriveReferendum[]> =>
ids.length
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { ReferendumInfo, ReferendumInfoFinished } from '@polkadot/types/interfaces';
@@ -11,8 +10,8 @@ import { Option } from '@polkadot/types';
import { memo } from '../util';
export function referendumsFinished (api: ApiInterfaceRx): () => Observable<ReferendumInfoFinished[]> {
return memo((): Observable<ReferendumInfoFinished[]> =>
export function referendumsFinished (instanceId: string, api: ApiInterfaceRx): () => Observable<ReferendumInfoFinished[]> {
return memo(instanceId, (): Observable<ReferendumInfoFinished[]> =>
api.derive.democracy.referendumIds().pipe(
switchMap((ids) => api.query.democracy.referendumInfoOf.multi<Option<ReferendumInfo>>(ids)),
map((infos): ReferendumInfoFinished[] =>
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { AccountId, ReferendumInfo, ReferendumInfoTo239, Vote, Voting, VotingDirectVote, VotingDelegating } from '@polkadot/types/interfaces';
@@ -92,8 +91,8 @@ function votesCurr (api: ApiInterfaceRx, referendumId: BN): Observable<DeriveRef
);
}
export function _referendumVotes (api: ApiInterfaceRx): (referendum: DeriveReferendum) => Observable<DeriveReferendumVotes> {
return memo((referendum: DeriveReferendum): Observable<DeriveReferendumVotes> =>
export function _referendumVotes (instanceId: string, api: ApiInterfaceRx): (referendum: DeriveReferendum) => Observable<DeriveReferendumVotes> {
return memo(instanceId, (referendum: DeriveReferendum): Observable<DeriveReferendumVotes> =>
combineLatest([
api.derive.democracy.sqrtElectorate(),
isFunction(api.query.democracy.votingOf)
@@ -107,8 +106,8 @@ export function _referendumVotes (api: ApiInterfaceRx): (referendum: DeriveRefer
);
}
export function _referendumsVotes (api: ApiInterfaceRx): (referendums: DeriveReferendum[]) => Observable<DeriveReferendumVotes[]> {
return memo((referendums: DeriveReferendum[]): Observable<DeriveReferendumVotes[]> =>
export function _referendumsVotes (instanceId: string, api: ApiInterfaceRx): (referendums: DeriveReferendum[]) => Observable<DeriveReferendumVotes[]> {
return memo(instanceId, (referendums: DeriveReferendum[]): Observable<DeriveReferendumVotes[]> =>
referendums.length
? combineLatest(
referendums.map((referendum): Observable<DeriveReferendumVotes> =>
@@ -119,8 +118,8 @@ export function _referendumsVotes (api: ApiInterfaceRx): (referendums: DeriveRef
);
}
export function _referendumInfo (api: ApiInterfaceRx): (index: BN, info: Option<ReferendumInfo | ReferendumInfoTo239>) => Observable<DeriveReferendum | null> {
return memo((index: BN, info: Option<ReferendumInfo | ReferendumInfoTo239>): Observable<DeriveReferendum | null> => {
export function _referendumInfo (instanceId: string, api: ApiInterfaceRx): (index: BN, info: Option<ReferendumInfo | ReferendumInfoTo239>) => Observable<DeriveReferendum | null> {
return memo(instanceId, (index: BN, info: Option<ReferendumInfo | ReferendumInfoTo239>): Observable<DeriveReferendum | null> => {
const status = getStatus(info);
return status
@@ -136,8 +135,8 @@ export function _referendumInfo (api: ApiInterfaceRx): (index: BN, info: Option<
});
}
export function referendumsInfo (api: ApiInterfaceRx): (ids: BN[]) => Observable<DeriveReferendum[]> {
return memo((ids: BN[]): Observable<DeriveReferendum[]> =>
export function referendumsInfo (instanceId: string, api: ApiInterfaceRx): (ids: BN[]) => Observable<DeriveReferendum[]> {
return memo(instanceId, (ids: BN[]): Observable<DeriveReferendum[]> =>
ids.length
? api.query.democracy.referendumInfoOf.multi<Option<ReferendumInfo>>(ids).pipe(
switchMap((infos): Observable<(DeriveReferendum | null)[]> =>
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
@@ -11,8 +10,8 @@ import { bnSqrt } from '@polkadot/util';
import { memo } from '../util';
export function sqrtElectorate (api: ApiInterfaceRx): () => Observable<BN> {
return memo((): Observable<BN> =>
export function sqrtElectorate (instanceId: string, api: ApiInterfaceRx): () => Observable<BN> {
return memo(instanceId, (): Observable<BN> =>
api.query.balances.totalIssuance().pipe(
map((totalIssuance) =>
bnSqrt(totalIssuance)
+8 -9
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import type BN from 'bn.js';
import { AccountId, Balance, BlockNumber, Hash, Proposal, PropIndex, ReferendumInfoTo239, ReferendumStatus, Vote, ReferendumIndex, VoteThreshold } from '@polkadot/types/interfaces';
@@ -17,13 +16,6 @@ export interface DeriveDemocracyLock {
vote: Vote;
}
export interface DeriveDispatch {
at: BlockNumber;
index: ReferendumIndex;
imageHash: Hash;
image?: DeriveProposalImage;
}
export interface DeriveProposalImage {
at: BlockNumber;
balance: Balance;
@@ -31,6 +23,13 @@ export interface DeriveProposalImage {
proposer: AccountId;
}
export interface DeriveDispatch {
at: BlockNumber;
index: ReferendumIndex;
imageHash: Hash;
image?: DeriveProposalImage;
}
export interface DeriveProposal {
balance?: Balance;
index: PropIndex;
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { AccountId, Balance, BlockNumber, PreimageStatus, Proposal, ReferendumInfo, ReferendumInfoTo239, ReferendumStatus, Tally, VoteThreshold } from '@polkadot/types/interfaces';
+1 -2
View File
@@ -1,5 +1,4 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
export * from './info';
+3 -4
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { AccountId, Balance, BlockNumber } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
@@ -55,6 +54,6 @@ function queryElections (api: ApiInterfaceRx): Observable<DeriveElectionsInfo> {
* });
* ```
*/
export function info (api: ApiInterfaceRx): () => Observable<DeriveElectionsInfo> {
return memo((): Observable<DeriveElectionsInfo> => queryElections(api));
export function info (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveElectionsInfo> {
return memo(instanceId, (): Observable<DeriveElectionsInfo> => queryElections(api));
}
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { AccountId, Balance, BlockNumber, SetIndex, VoteIndex } from '@polkadot/types/interfaces';
+1 -2
View File
@@ -1,5 +1,4 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
export * from './receivedHeartbeats';
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { AccountId } from '@polkadot/types/interfaces';
import { DeriveHeartbeats } from '../types';
@@ -13,15 +12,35 @@ import { BN_ZERO } from '@polkadot/util';
import { memo } from '../util';
function mapResult ([result, validators, heartbeats, numBlocks]: [DeriveHeartbeats, AccountId[], Option<Bytes>[], u32[]]): DeriveHeartbeats {
validators.forEach((validator, index): void => {
const validatorId = validator.toString();
const blockCount = numBlocks[index];
const hasMessage = !heartbeats[index].isEmpty;
const prev = result[validatorId];
if (!prev || prev.hasMessage !== hasMessage || !prev.blockCount.eq(blockCount)) {
result[validatorId] = {
blockCount,
hasMessage,
isOnline: hasMessage || blockCount.gt(BN_ZERO)
};
}
});
return result;
}
/**
* @description Return a boolean array indicating whether the passed accounts had received heartbeats in the current session
*/
export function receivedHeartbeats (api: ApiInterfaceRx): () => Observable<DeriveHeartbeats> {
return memo((): Observable<DeriveHeartbeats> =>
export function receivedHeartbeats (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveHeartbeats> {
return memo(instanceId, (): Observable<DeriveHeartbeats> =>
api.query.imOnline?.receivedHeartbeats
? api.derive.staking.overview().pipe(
switchMap(({ currentIndex, validators }): Observable<[AccountId[], Option<Bytes>[], u32[]]> =>
switchMap(({ currentIndex, validators }): Observable<[DeriveHeartbeats, AccountId[], Option<Bytes>[], u32[]]> =>
combineLatest([
of({}),
of(validators),
api.query.imOnline.receivedHeartbeats.multi<Option<Bytes>>(
validators.map((_address, index) => [currentIndex, index])),
@@ -29,16 +48,8 @@ export function receivedHeartbeats (api: ApiInterfaceRx): () => Observable<Deriv
validators.map((address) => [currentIndex, address]))
])
),
map(([validators, heartbeats, numBlocks]): DeriveHeartbeats =>
validators.reduce((result: DeriveHeartbeats, validator, index): DeriveHeartbeats => ({
...result,
[validator.toString()]: {
blockCount: numBlocks[index],
hasMessage: !heartbeats[index].isEmpty,
isOnline: !heartbeats[index].isEmpty || numBlocks[index].gt(BN_ZERO)
}
}), {})
)
map(mapResult)
)
: of({}));
: of({})
);
}
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-call */
+7 -8
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { AnyFunction } from '@polkadot/types/types';
@@ -36,7 +35,7 @@ type DeriveAllSections<AllSections> = {
[Section in keyof AllSections]: DeriveSection<AllSections[Section]>
};
export type DeriveCustom = Record<string, Record<string, (api: ApiInterfaceRx) => (...args: any[]) => Observable<any>>>;
export type DeriveCustom = Record<string, Record<string, (instanceId: string, api: ApiInterfaceRx) => (...args: any[]) => Observable<any>>>;
export type ExactDerive = DeriveAllSections<typeof derive>;
@@ -60,7 +59,7 @@ const deriveAvail: Record<string, string[]> = {
* `allSections`, and keep the object architecture of `allSections`.
*/
/** @internal */
function injectFunctions<AllSections> (api: ApiInterfaceRx, allSections: AllSections): DeriveAllSections<AllSections> {
function injectFunctions<AllSections> (instanceId: string, api: ApiInterfaceRx, allSections: AllSections): DeriveAllSections<AllSections> {
const queryKeys = Object.keys(api.query);
return Object
@@ -77,7 +76,7 @@ function injectFunctions<AllSections> (api: ApiInterfaceRx, allSections: AllSect
const methodName = _methodName as keyof typeof section;
// Not sure what to do here, casting as any. Though the final types are good
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call
const method = (section[methodName] as any)(api);
const method = (section[methodName] as any)(instanceId, api);
// idem
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access
@@ -93,9 +92,9 @@ function injectFunctions<AllSections> (api: ApiInterfaceRx, allSections: AllSect
// FIXME The return type of this function should be {...ExactDerive, ...DeriveCustom}
// For now we just drop the custom derive typings
/** @internal */
export default function decorateDerive (api: ApiInterfaceRx, custom: DeriveCustom = {}): ExactDerive {
export default function decorateDerive (instanceId: string, api: ApiInterfaceRx, custom: DeriveCustom = {}): ExactDerive {
return {
...injectFunctions(api, derive),
...injectFunctions(api, custom)
...injectFunctions(instanceId, api, derive),
...injectFunctions(instanceId, api, custom)
};
}
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
export * from './info';
export * from './overview';
+3 -4
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { CollatorId, ParaId } from '@polkadot/types/interfaces';
import { DeriveParachainInfo, DeriveParachainFull, DeriveParachainActive } from '../types';
@@ -77,8 +76,8 @@ function parse (id: ParaId, [active, retryQueue, selectedThreads, didUpdate, inf
};
}
export function info (api: ApiInterfaceRx): (id: ParaId | number) => Observable<DeriveParachainFull | null> {
return memo((id: ParaId | number): Observable<DeriveParachainFull | null> =>
export function info (instanceId: string, api: ApiInterfaceRx): (id: ParaId | number) => Observable<DeriveParachainFull | null> {
return memo(instanceId, (id: ParaId | number): Observable<DeriveParachainFull | null> =>
api.query.registrar && api.query.parachains
? api.queryMulti<Result>([
api.query.registrar.active,
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { ParaId } from '@polkadot/types/interfaces';
import { DeriveParachain, DeriveParachainInfo } from '../types';
@@ -34,8 +33,8 @@ function parse ([ids, didUpdate, infos, pendingSwaps, relayDispatchQueueSizes]:
});
}
export function overview (api: ApiInterfaceRx): () => Observable<DeriveParachain[]> {
return memo((): Observable<DeriveParachain[]> =>
export function overview (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveParachain[]> {
return memo(instanceId, (): Observable<DeriveParachain[]> =>
api.query.registrar?.parachains && api.query.parachains
? api.query.registrar.parachains<ParaId[]>().pipe(
switchMap((paraIds) =>
+1 -2
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { CollatorId, ParaId, ParaInfo, Retriable, UpwardMessage } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
+3 -4
View File
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { BlockNumber } from '@polkadot/types/interfaces';
@@ -10,8 +9,8 @@ import { ApiInterfaceRx } from '@polkadot/api/types';
import { memo } from '../util';
export function eraLength (api: ApiInterfaceRx): () => Observable<BlockNumber> {
return memo((): Observable<BlockNumber> =>
export function eraLength (instanceId: string, api: ApiInterfaceRx): () => Observable<BlockNumber> {
return memo(instanceId, (): Observable<BlockNumber> =>
api.derive.session.info().pipe(
map((info) => info.eraLength)
));
@@ -1,6 +1,5 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// SPDX-License-Identifier: Apache-2.0
import { BlockNumber } from '@polkadot/types/interfaces';
@@ -10,8 +9,8 @@ import { ApiInterfaceRx } from '@polkadot/api/types';
import { memo } from '../util';
export function eraProgress (api: ApiInterfaceRx): () => Observable<BlockNumber> {
return memo((): Observable<BlockNumber> =>
export function eraProgress (instanceId: string, api: ApiInterfaceRx): () => Observable<BlockNumber> {
return memo(instanceId, (): Observable<BlockNumber> =>
api.derive.session.progress().pipe(
map((info) => info.eraProgress)
));

Some files were not shown because too many files have changed in this diff Show More