Compare commits

..
444 Commits
Author SHA1 Message Date
Github Actions e3a57e14bc [CI Skip] release/stable 2.1.1
skip-checks: true
2020-10-05 08:35:08 +00:00
Jaco Greeff cc926596e5 2.1 (#2681) 2020-10-05 10:24:25 +02:00
Github Actions 5193e9c6d5 [CI Skip] release/beta 2.1.0-beta.9
skip-checks: true
2020-10-04 17:53:29 +00:00
Jaco Greeff d3703c072b Revert additional catch (#2679)
* Revert additional catch

* Cleanup immediate/timeout checks
2020-10-04 19:43:15 +02:00
Github Actions 4dbcf310f3 [CI Skip] release/beta 2.1.0-beta.8
skip-checks: true
2020-10-04 13:39:32 +00:00
Jaco Greeff f778bf32e5 Dump dev (without lerna publish) (#2678)
* Dump dev (without lerna publish)

* Drop lerna.json
2020-10-04 15:30:26 +02:00
Github Actions 7027e9f982 [CI Skip] release/beta 2.1.0-beta.7
skip-checks: true
2020-10-04 09:15:39 +00:00
Jaco Greeff d13e58fb32 Bubble processing errors (#2677) 2020-10-04 11:07:07 +02:00
Github Actions 8f8e6d542f [CI Skip] release/beta 2.1.0-beta.6
skip-checks: true
2020-10-04 08:35:28 +00:00
Jaco Greeff 95c4f03bc3 s/TRANSACTION_/EXTRINSIC_/ (#2676)
* s/TRANSACTION_/EXTRINSIC_/

* Bump deps
2020-10-04 10:26:14 +02:00
Github Actions 45bba3a897 [CI Skip] release/beta 2.1.0-beta.5
skip-checks: true
2020-10-02 12:36:02 +00:00
Jaco Greeff d202287889 Remove all class summary links (#2674) 2020-10-02 14:27:08 +02:00
Github Actions 0c338dfbce [CI Skip] release/beta 2.1.0-beta.4
skip-checks: true
2020-10-02 11:57:43 +00:00
Jaco Greeff 33c161f874 Derive validators from stashes & nominations (#2672) 2020-10-02 13:48:25 +02:00
Github Actions 34d951d63e [CI Skip] release/beta 2.1.0-beta.3
skip-checks: true
2020-10-02 11:46:18 +00:00
Jaco Greeff 27c58b930b Reformat RPC errors (with less trimming) (#2668)
* Reformat RPC errors (with less trimming)

* Adjust decoding
2020-10-02 13:38:48 +02:00
Github Actions 6d2f2affe8 [CI Skip] release/beta 2.1.0-beta.2
skip-checks: true
2020-10-02 11:34:48 +00:00
Rocco Musolino e055438c59 remove broken link (#2671) 2020-10-02 13:26:21 +02:00
Github Actions 19bf1a1b59 [CI Skip] release/beta 2.1.0-beta.1
skip-checks: true
2020-10-02 11:20:05 +00:00
Jaco Greeff 5577723b73 Add limit protection for Bytes & Text (#2670)
* Add limit protection for Bytes & Text

* Limites as K

* Adjust limits upwards
2020-10-02 13:11:25 +02:00
Github Actions ba5f9d1d01 [CI Skip] release/beta 2.1.0-beta.0
skip-checks: true
2020-09-30 06:35:05 +00:00
Jaco Greeff 9d548f787f Bump deps (#2662) 2020-09-30 08:27:37 +02:00
Github Actions 98c8240457 [CI Skip] release/stable 2.0.1
skip-checks: true
2020-09-28 07:05:01 +00:00
Jaco Greeff ff59962c56 2.0 (#2657) 2020-09-28 08:56:50 +02:00
Jaco Greeff 929a2854bd Bump metadata (#2658) 2020-09-28 08:00:23 +02:00
Github Actions d90c0e82b1 [CI Skip] release/beta 1.35.0-beta.19
skip-checks: true
2020-09-27 18:21:49 +00:00
André Silva 73ffb034d0 add secondary_vrf field to babe EpochAuthorship (#2656) 2020-09-27 20:13:25 +02:00
Github Actions bd41406a34 [CI Skip] release/beta 1.35.0-beta.18
skip-checks: true
2020-09-27 09:10:14 +00:00
Jaco Greeff 8631f68ba7 Bump common (#2655)
* Bump common

* Update tests
2020-09-27 11:01:33 +02:00
Github Actions ad9d4d50f5 [CI Skip] release/beta 1.35.0-beta.17
skip-checks: true
2020-09-26 10:11:34 +00:00
Jaco Greeff cb93cb34b7 Drop support for Extrinsic V1, V2 & V3 (#2638)
* Drop support for Extrinsic V1 & V2

* Update interfaces

* Swap default to V4

* Remove V1/V2 extrinsic tests

* Fix v3 toU8a

* Fix Decorated tests for v4

* V3 payload extends v4 payload

* Revert "V3 payload extends v4 payload"

This reverts commit b1e546aa08fe1027aa77a235fd3b98441c426812.

* Drop extrinsic v3

* Update CHANGELOG.md
2020-09-26 12:02:27 +02:00
Github Actions f2fbedb407 [CI Skip] release/beta 1.35.0-beta.16
skip-checks: true
2020-09-26 08:53:52 +00:00
Jaco Greeff c27e41be3f RefCount known upgrades (#2654) 2020-09-26 10:44:47 +02:00
Github Actions ae17338520 [CI Skip] release/beta 1.35.0-beta.15
skip-checks: true
2020-09-25 17:41:01 +00:00
Jaco Greeff 19d6165bda Add PalletVersion struct (#2652) 2020-09-25 19:32:33 +02:00
Github Actions 9a02e0695b [CI Skip] release/beta 1.35.0-beta.14
skip-checks: true
2020-09-25 14:41:45 +00:00
Jaco Greeff 5ce3524ccd Drop Metadata V0-V8 (#2634)
* Drop MetadatV0

* Apply suggestions from code review

* Restore asV1

* Remove V0 comment

* Handle DoNotConstruct in enum

* No imports from DoNotConstruct

* Merge & re-generate

* Attempt empty construction

* Drop Metadata from 0-4

* CHANGELOG

* assert(5)

* BE vs LE

* Metadataall to no-construction

* Empty U8a create

* Remove old comment

* Santize handling

* Update CHANGELOG.md

* Drop support for Metadata < 9

* Remove old pre-9 definitions

* Update CHANGELOG.md

* CHANGELOG

* Remove v8-era tests

* v8 tests
2020-09-25 16:32:48 +02:00
Github Actions dff7243aad [CI Skip] release/beta 1.35.0-beta.13
skip-checks: true
2020-09-25 11:42:24 +00:00
Jaco Greeff ee6b6da02b Bump deps (#2651) 2020-09-25 13:31:57 +02:00
Github Actions dc936cfed4 [CI Skip] release/beta 1.35.0-beta.12
skip-checks: true
2020-09-25 10:32:00 +00:00
Jaco Greeff 7af9151854 Support .entries() with no queryStorageAt (#2650) 2020-09-25 12:23:14 +02:00
Github Actions 10497ddef2 [CI Skip] release/beta 1.35.0-beta.11
skip-checks: true
2020-09-25 08:29:50 +00:00
Jaco Greeff 7fd45f63df Drop support for linked lists (#2643)
* Drop support for linked lists

* CHANGELOG

* Remove all .linked. checks
2020-09-25 10:19:28 +02:00
Github Actions 82afd93bf6 [CI Skip] release/beta 1.35.0-beta.10
skip-checks: true
2020-09-24 17:23:32 +00:00
Jeremías Díaz 05c0379f43 fix(typegen): format vecfixed correctly (#2647)
* fix(typegen): add support for VecFixed in enums

* fix(typegen): format vecfixed correctly
2020-09-24 19:12:05 +02:00
Github Actions 10c7da75d8 [CI Skip] release/beta 1.35.0-beta.9
skip-checks: true
2020-09-24 17:00:05 +00:00
Jaco Greeff 0c4cc51f74 Perbill formatting with rawType equality (#2646)
* Perbill formatting with rawType equality

* Balance toHuman() check

* Formatter lookup

* typing

* Merge

* Better Compact detection
2020-09-24 18:48:24 +02:00
Github Actions 1ba58e3d04 [CI Skip] release/beta 1.35.0-beta.8
skip-checks: true
2020-09-24 15:20:09 +00:00
Jeremías Díaz c6bc664f80 fix(typegen): add support for VecFixed in enums (#2645) 2020-09-24 17:10:24 +02:00
Github Actions eb9ab67651 [CI Skip] release/beta 1.35.0-beta.7
skip-checks: true
2020-09-24 11:44:21 +00:00
Jaco Greeff 7070f757c4 Bump deps (#2644)
* Bump deps

* 24 on Polkadot
2020-09-24 13:35:10 +02:00
Github Actions 0d88095cb2 [CI Skip] release/beta 1.35.0-beta.6
skip-checks: true
2020-09-24 07:59:06 +00:00
Jaco Greeff 6faea13a28 Filter on null keys (wrong encoding) (#2642) 2020-09-24 09:48:28 +02:00
Github Actions 4f59866528 [CI Skip] release/beta 1.35.0-beta.5
skip-checks: true
2020-09-23 14:49:37 +00:00
Jaco Greeff 41f1d8f367 Centrifuge range update (#2640)
* Cetrifuge range update

* Move RefCount

* Remove Weight (u64 is default)
2020-09-23 16:39:20 +02:00
Github Actions a32a1162ff [CI Skip] release/beta 1.35.0-beta.4
skip-checks: true
2020-09-23 13:42:27 +00:00
Jaco Greeff 0c99064b19 Update know upgrade map (#2639) 2020-09-23 15:32:20 +02:00
Github Actions 77f37f387a [CI Skip] release/beta 1.35.0-beta.3
skip-checks: true
2020-09-23 13:27:55 +00:00
Jaco Greeff 9f4007bd4b RefCount change to u32 (#2635) 2020-09-23 15:17:12 +02:00
Github Actions ad20decbbc [CI Skip] release/beta 1.35.0-beta.2
skip-checks: true
2020-09-22 21:07:19 +00:00
Miguel Hervas 820dd3d0fb Centrifuge update RC6 (#2637)
* update to rc6 types

* prep rc6

* fix lint
2020-09-22 22:57:59 +02:00
Github Actions 004f9153ab [CI Skip] release/beta 1.35.0-beta.1
skip-checks: true
2020-09-22 10:28:49 +00:00
Jaco Greeff 3de336fdff Add support for grandpa_proveFinality RPC (#2633)
* Add support for grandpa_proveFinality RPC

* CHANGELOG
2020-09-22 12:18:41 +02:00
Github Actions 67e1e07714 [CI Skip] release/beta 1.35.0-beta.0
skip-checks: true
2020-09-22 10:09:16 +00:00
Jaco Greeff b4cae14836 Add Bounty type definitions (#2632)
* Add Bounty type definitions

* CHANGELOG
2020-09-22 11:58:58 +02:00
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
Github Actions d958ef8f15 [CI Skip] release/stable 1.31.1
skip-checks: true
2020-08-31 15:44:17 +00:00
Jaco Greeff 97527871d6 1.31 (#2551) 2020-08-31 17:32:20 +02:00
Github Actions 0317f28e5a [CI Skip] release/beta 1.31.0-beta.26
skip-checks: true
2020-08-31 15:06:05 +00:00
Jaco Greeff ebe6d03762 Update types for Polkadot runtime 23 (#2550)
* Update types for Polkadot runtime 23

* Expand change info

* version upgrades

* Linting
2020-08-31 16:50:56 +02:00
Github Actions 59e92fa344 [CI Skip] release/beta 1.31.0-beta.25
skip-checks: true
2020-08-31 14:24:05 +00:00
Jaco Greeff cab338e26d CHANGELOG (#2549) 2020-08-31 16:11:17 +02:00
Github Actions 743ea431b4 [CI Skip] release/beta 1.31.0-beta.24
skip-checks: true
2020-08-31 13:32:50 +00:00
Jaco Greeff 533f9ce249 Explicit delay for per-hash single queries (#2548)
* Explicit delay for per-hash single queries

* Expand delay

* Update packages/rpc-core/src/index.ts
2020-08-31 15:20:06 +02:00
Github Actions 797ee9c24a [CI Skip] release/beta 1.31.0-beta.23
skip-checks: true
2020-08-31 12:44:38 +00:00
Jaco Greeff 2f5e2537a3 Align single-shot memoization (#2546)
* Align single-shot memoization

* Small tweaks

* Test for delayed creates

* With actual sub

* Expand delay test

* Bump delay
2020-08-31 14:31:44 +02:00
Github Actions dd52ea4b32 [CI Skip] release/beta 1.31.0-beta.22
skip-checks: true
2020-08-31 12:27:52 +00:00
Jaco Greeff 5e8ae793c3 Westend known upgrades (#2547) 2020-08-31 14:16:45 +02:00
Github Actions 8713a1f2b6 [CI Skip] release/beta 1.31.0-beta.21
skip-checks: true
2020-08-31 11:22:44 +00:00
Jaco Greeff 6e6fa4a97c Known upgrade points for on-chain version skip (#2545)
* Known upgrade points for on-chain version skip

* Update packages/types-known/src/index.ts

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

* Actual known upgrade blocks for Polkadot & Kusama

* Update with known Kusama upgrade history

* linting
2020-08-31 13:09:52 +02:00
Github Actions ac2a0a34ca [CI Skip] release/beta 1.31.0-beta.20
skip-checks: true
2020-08-31 07:51:33 +00:00
Jaco Greeff 45fb6d44ad Bump deps (#2544) 2020-08-31 09:38:21 +02:00
Github Actions 6d2265d4ff [CI Skip] release/beta 1.31.0-beta.19
skip-checks: true
2020-08-31 07:11:57 +00:00
Jaco Greeff 4ec42f1750 Ensure non-destructive registry swap (#2543)
* Ensure non-destructive registry swap

* Update packages/api/src/base/Init.ts
2020-08-31 08:59:20 +02:00
Github Actions 01166b9684 [CI Skip] release/beta 1.31.0-beta.18
skip-checks: true
2020-08-30 19:24:47 +00:00
Jaco Greeff 0075dce720 Remove outdated historic query FAQ (#2540) 2020-08-30 21:11:15 +02:00
Github Actions 7fbb30066e [CI Skip] release/beta 1.31.0-beta.17
skip-checks: true
2020-08-30 18:41:28 +00:00
Jaco Greeff 637069d723 Shortcut registry for subsequent same-hash queries (#2539) 2020-08-30 20:28:37 +02:00
Github Actions d639a7ee8c [CI Skip] release/beta 1.31.0-beta.16
skip-checks: true
2020-08-30 18:17:47 +00:00
Jaco Greeff 28ef291c40 Mark submittable .sign as deprecated (#2538) 2020-08-30 20:06:42 +02:00
Github Actions 48ddd0b0d4 [CI Skip] release/beta 1.31.0-beta.15
skip-checks: true
2020-08-30 10:52:55 +00:00
Jaco Greeff e88ebf7b2e Support Vec .concat (#2537)
* Support Vec .concat

* CHANGELOG
2020-08-30 12:40:20 +02:00
Github Actions 72700e6baf [CI Skip] release/beta 1.31.0-beta.14
skip-checks: true
2020-08-30 10:36:12 +00:00
Hamza Tokuchi f748fcd46d more typos (#2532) 2020-08-30 12:24:50 +02:00
Jaco Greeff 7876bb9ced Add isHistoric flags to RPC with hash params (#2535)
* Add isHistoric flags to RPC with hash params

* Update packages/types/src/interfaces/chain/definitions.ts

* Apply suggestions from code review

* Transparently swap registry on RPC layer

* Simplify (& linting fixes)

* Cleanups

* CHANGELOG
2020-08-30 12:12:18 +02:00
Github Actions a83980b213 [CI Skip] release/beta 1.31.0-beta.13
skip-checks: true
2020-08-29 13:59:29 +00:00
Jaco Greeff c4323d5e94 Add swapRegistry(hash?) to initlize clean registry (#2534)
* Add swapRegistry(hash?) to initlize clean registry

* Cater for genesisHash queries
2020-08-29 15:46:42 +02:00
Github Actions 11694f1393 [CI Skip] release/beta 1.31.0-beta.12
skip-checks: true
2020-08-29 12:31:27 +00:00
Jaco Greeff 3989ae67b2 Bump deps (#2533) 2020-08-29 14:19:56 +02:00
Github Actions b78df57907 [CI Skip] release/beta 1.31.0-beta.11
skip-checks: true
2020-08-28 12:35:54 +00:00
Jaco Greeff 2f78329738 Return democracy locks for delegations (#2531) 2020-08-28 14:23:05 +02:00
Github Actions 6063054712 [CI Skip] release/beta 1.31.0-beta.10
skip-checks: true
2020-08-28 10:15:36 +00:00
Jaco Greeff e42af97928 Bump deps (#2530) 2020-08-28 12:03:49 +02:00
Hamza Tokuchi d05ccdb5d7 small typos (#2529) 2020-08-28 12:03:13 +02:00
Github Actions c33334b72b [CI Skip] release/beta 1.31.0-beta.9
skip-checks: true
2020-08-28 08:50:51 +00:00
Jaco Greeff 94e9fd2b17 Fix for in-place unlocking (#2528) 2020-08-28 10:40:53 +02:00
Github Actions 9c1327ea22 [CI Skip] release/beta 1.31.0-beta.8
skip-checks: true
2020-08-26 16:56:17 +00:00
Jaco Greeff 9f195e9402 Update RewardDesitination enum (any payout) (#2474) 2020-08-26 18:43:51 +02:00
Github Actions 3e5e089c68 [CI Skip] release/beta 1.31.0-beta.7
skip-checks: true
2020-08-26 11:00:13 +00:00
Jaco Greeff 35c37aa66c Allow AccountId null in constructor 2020-08-26 12:47:15 +02:00
Github Actions f1aeb564e3 [CI Skip] release/beta 1.31.0-beta.6
skip-checks: true
2020-08-26 10:41:27 +00:00
Kian Paimani c2ff1b32ae Update definitions.ts (#2514)
* Update definitions.ts

Will fix the decoding of these types. Sadly cannot provide a compact test case.

* Add more tests.

* Make the tests work.

* Fix linting as well.
2020-08-26 12:29:27 +02:00
Github Actions 288427cbb8 [CI Skip] release/beta 1.31.0-beta.5
skip-checks: true
2020-08-26 09:40:00 +00:00
Jaco Greeff d099ccedad Additional AccountId length check (protect users against themselves) (#2520)
* Additional AccountId length check

* Allow all-0

* Spaceing.
2020-08-26 11:27:57 +02:00
Github Actions 79c7983199 [CI Skip] release/beta 1.31.0-beta.4
skip-checks: true
2020-08-26 09:26:32 +00:00
Jaco Greeff 80c578fe76 Bump deps (#2521)
* Bump deps

* Rewrite yarn.lock

* Debump markdown plugin

* Explicit add of typedoc plugins

* Bump dev typedoc exec

* Bump md

* Common bump
2020-08-26 11:15:23 +02:00
Github Actions de90c048bf [CI Skip] release/beta 1.31.0-beta.3
skip-checks: true
2020-08-26 05:12:55 +00:00
aniiantt 01a36a994d add TransactionPriority def (#2519) 2020-08-26 07:03:20 +02:00
Github Actions b1ce22d51d [CI Skip] release/beta 1.31.0-beta.2
skip-checks: true
2020-08-25 22:01:24 +00:00
Jaco Greeff fe951c2645 Support bare flag on enums (#2518)
* Support bare flag on enums

* Remove extra var allocation
2020-08-25 23:50:30 +02:00
Github Actions 5a17c542a7 [CI Skip] release/beta 1.31.0-beta.1
skip-checks: true
2020-08-25 21:35:20 +00:00
Jaco Greeff 59bb5f864f Add toBigInt to number types (#2517)
* Add toBigInt to number types

* Update packages/types/src/codec/UInt.spec.ts

* Update packages/types/src/codec/Compact.spec.ts

* Update packages/types/src/codec/Compact.ts
2020-08-25 23:24:02 +02:00
Github Actions abcba20f90 [CI Skip] release/beta 1.31.0-beta.0
skip-checks: true
2020-08-25 13:48:28 +00:00
Hamza Tokuchi 014f08c7cc Small typo (#2515)
teh -> the
2020-08-25 15:36:59 +02:00
Github Actions 7ecd00a4e6 [CI Skip] release/stable 1.30.1
skip-checks: true
2020-08-24 09:27:18 +00:00
Jaco Greeff 6239818c26 1.30 (#2511) 2020-08-24 11:14:32 +02:00
Github Actions 6af22f41c7 [CI Skip] release/beta 1.30.0-beta.8
skip-checks: true
2020-08-24 07:40:12 +00:00
Jaco Greeff 77c3a701d0 Bump deps (#2510) 2020-08-24 09:27:49 +02:00
Github Actions 46b17a466c [CI Skip] release/beta 1.30.0-beta.7
skip-checks: true
2020-08-24 05:35:43 +00:00
Jaco Greeff e592c6c878 Fix circular know-type refs (#2509) 2020-08-24 07:23:06 +02:00
Github Actions ef37586dfc [CI Skip] release/beta 1.30.0-beta.6
skip-checks: true
2020-08-22 12:13:04 +00:00
Jaco Greeff 5856ce24cc User pair addressRaw for signing (#2504)
* User pair addressRaw for signing

* Bump common

* Bump common after merge
2020-08-22 14:02:28 +02:00
Github Actions 8b79056bf9 [CI Skip] release/beta 1.30.0-beta.5
skip-checks: true
2020-08-22 11:20:28 +00:00
Jaco Greeff 70e0f19ade Allow for configurable hashers (#2503) 2020-08-22 13:09:04 +02:00
Github Actions cf1e242c17 [CI Skip] release/beta 1.30.0-beta.4
skip-checks: true
2020-08-22 10:41:32 +00:00
Jaco Greeff 68856e9692 Ethereum-compatible AccountId/Address (#2501)
* Ethereum-compatible AccountId/Address

* With tests

* Adjust definitions

* Update packages/types/src/ethereum/LookupSource.ts

* Renames
2020-08-22 12:30:24 +02:00
Github Actions e0626c3dad [CI Skip] release/beta 1.30.0-beta.3
skip-checks: true
2020-08-22 09:53:13 +00:00
Jaco Greeff 277ea92fda Adjust Address <-> LookupSource definitions (#2502) 2020-08-22 11:43:19 +02:00
Github Actions aec6694028 [CI Skip] release/beta 1.30.0-beta.2
skip-checks: true
2020-08-22 08:31:53 +00:00
Jaco Greeff 533abb76f7 Bump deps (#2500)
* Bump deps

* Rewrite
2020-08-22 10:20:40 +02:00
Github Actions 7660bab86b [CI Skip] release/beta 1.30.0-beta.1
skip-checks: true
2020-08-20 08:45:46 +00:00
Jaco Greeff f7c1b6e81b Check system.account (& balances) for new queries (#2495) 2020-08-20 10:33:47 +02:00
Github Actions b6e9b29570 [CI Skip] release/beta 1.30.0-beta.0
skip-checks: true
2020-08-18 09:51:26 +00:00
Jaco Greeff 519d9c8fa9 Types for proposeParachain module (#2493) 2020-08-18 11:40:30 +02:00
Github Actions ad905db53b [CI Skip] release/stable 1.29.1
skip-checks: true
2020-08-17 10:56:06 +00:00
Jaco Greeff 0a0aa742b4 1.29 (#2489) 2020-08-17 12:43:56 +02:00
Github Actions dfbb06a4d6 [CI Skip] release/beta 1.29.0-beta.5
skip-checks: true
2020-08-13 09:05:15 +00:00
Jaco Greeff 82e71fd51e Bump deps (#2486) 2020-08-13 10:54:45 +02:00
Github Actions a8b88af97a [CI Skip] release/beta 1.29.0-beta.4
skip-checks: true
2020-08-13 07:59:11 +00:00
sung wu eee36537de Update tx.md (#2485)
fix sample code
2020-08-13 09:47:22 +02:00
Github Actions 20a75eafb6 [CI Skip] release/beta 1.29.0-beta.3
skip-checks: true
2020-08-11 15:33:01 +00:00
Jaco Greeff 00d3a1174b Add desiredRunnersUp (#2484) 2020-08-11 17:21:30 +02:00
Github Actions e293c7c1cf [CI Skip] release/beta 1.29.0-beta.2
skip-checks: true
2020-08-11 11:54:13 +00:00
Jaco Greeff 3c8cd499c4 Introduce compact version of CompactAssignments (#2483)
* Introduce compact version of CompactAssignments

* Rebuild interfaces, update tests
2020-08-11 13:43:24 +02:00
Github Actions cb3816df78 [CI Skip] release/beta 1.29.0-beta.1
skip-checks: true
2020-08-11 08:01:38 +00:00
Jaco Greeff fcfcbb2d97 Additional Fixed* types (#2481) 2020-08-11 09:50:28 +02:00
Github Actions 321b80ed63 [CI Skip] release/beta 1.29.0-beta.0
skip-checks: true
2020-08-10 14:55:58 +00:00
Jaco Greeff 73eaa9fe17 Cleanup id from index lookups (#2479) 2020-08-10 16:42:27 +02:00
Github Actions 4d8910f3da [CI Skip] release/stable 1.28.1
skip-checks: true
2020-08-10 06:20:15 +00:00
Jaco Greeff e6806ed7f9 jg-1.28 (#2478) 2020-08-10 08:10:21 +02:00
Github Actions 218abf9568 [CI Skip] release/beta 1.28.0-beta.6
skip-checks: true
2020-08-08 07:21:20 +00:00
Jaco Greeff a1df864681 Nump deps (#2477) 2020-08-08 09:09:30 +02:00
Github Actions 45640edcff [CI Skip] release/beta 1.28.0-beta.5
skip-checks: true
2020-08-07 09:29:23 +00:00
Jaco Greeff 53655019b5 Cookbook for viewing block extrinsics (#2476) 2020-08-07 11:16:33 +02:00
Github Actions a1f8bedb6d [CI Skip] release/beta 1.28.0-beta.4
skip-checks: true
2020-08-06 19:08:46 +00:00
Miguel Hervas 9d1af1eaeb Add Centrifuge missing types (#2475)
* Add missing types

* sort attempt

* sort attempt 1

* sort attempt 2
2020-08-06 20:57:07 +02:00
Github Actions 38bfd26511 [CI Skip] release/beta 1.28.0-beta.3
skip-checks: true
2020-08-06 13:07:18 +00:00
Jaco Greeff 1beaf9f208 Bump berry (#2473)
* Bump berry

* Rewrite
2020-08-06 14:56:43 +02:00
Github Actions 29c29978dd [CI Skip] release/beta 1.28.0-beta.2
skip-checks: true
2020-08-05 15:06:31 +00:00
Jaco Greeff a8d1dd0637 Bump deps (#2472) 2020-08-05 16:53:11 +02:00
Github Actions 74571dcd26 [CI Skip] release/beta 1.28.0-beta.1
skip-checks: true
2020-08-04 20:51:40 +00:00
Jaco Greeff 54b4c2620a Types for time-delay proxies (#2468)
* Types for time-delay proxies

* Remove duplicated CallHash (& generate output)
2020-08-04 22:38:56 +02:00
Github Actions da05828e74 [CI Skip] release/beta 1.28.0-beta.0
skip-checks: true
2020-08-04 11:07:26 +00:00
Jaco Greeff fa935156e1 Add ValidationFunctionParams type (#2467) 2020-08-04 12:56:55 +02:00
Github Actions 19510c1ede [CI Skip] release/stable 1.27.1
skip-checks: true
2020-08-03 07:18:56 +00:00
Jaco Greeff 97b5c699b1 1.27 (#2462) 2020-08-03 09:08:09 +02:00
Github Actions d2befda86e [CI Skip] release/beta 1.27.0-beta.3
skip-checks: true
2020-07-31 09:46:53 +00:00
Jaco Greeff 740348b48f Bump deps (#2460) 2020-07-31 11:34:00 +02:00
Github Actions 9e2a5cf532 [CI Skip] release/beta 1.27.0-beta.2
skip-checks: true
2020-07-30 16:28:52 +00:00
Jaco Greeff 6df466d9ea Known types for Rococo (#2459)
* Known types for Rococo

* Update rococo.ts
2020-07-30 18:17:32 +02:00
Github Actions e2a2ac2842 [CI Skip] release/beta 1.27.0-beta.1
skip-checks: true
2020-07-28 11:11:30 +00:00
sung wu 5adc846e45 update doc - "create instance" page (#2456)
poc-3.polkadot.io is not available right now. use rpc.polkadot.io instead.
2020-07-28 12:59:27 +02:00
Github Actions 75aa310837 [CI Skip] release/beta 1.27.0-beta.0
skip-checks: true
2020-07-28 10:27:07 +00:00
Jaco Greeff ce0523eb1c Raw toHuman Ascii detection (#2455) 2020-07-28 12:17:26 +02:00
Github Actions eb0370bb66 [CI Skip] release/stable 1.26.1
skip-checks: true
2020-07-27 11:21:29 +00:00
Jaco Greeff 5eb491dc67 1.26 (#2453) 2020-07-27 13:10:07 +02:00
Github Actions b50294ab0f [CI Skip] release/beta 1.26.0-beta.6
skip-checks: true
2020-07-27 10:56:53 +00:00
Keith Ingram e1cb62d2d2 Type for contract call params (#2452) 2020-07-27 12:43:54 +02:00
Github Actions 8ed0ef2295 [CI Skip] release/beta 1.26.0-beta.5
skip-checks: true
2020-07-27 10:18:11 +00:00
Jaco Greeff 956e173323 Metadata bump (#2451) 2020-07-27 12:06:28 +02:00
Github Actions b8a37ba438 [CI Skip] release/beta 1.26.0-beta.4
skip-checks: true
2020-07-27 07:22:38 +00:00
Jaco Greeff e7669c2b00 Add api typesBundle (#2422)
* Add api typesBundle

* Inject user-defined RPC from spec/chain

* Linting cleanups

* Invert check fro non-existing

* Extract bundle injection

* Ignore RPC for the first round

* CHANGELOG

* Merge master
2020-07-27 09:12:04 +02:00
Github Actions 6c309a503d [CI Skip] release/beta 1.26.0-beta.3
skip-checks: true
2020-07-27 07:02:12 +00:00
Jaco Greeff 3cf67c975a Bump deps (#2450) 2020-07-27 08:49:52 +02:00
Github Actions 077914364c [CI Skip] release/beta 1.26.0-beta.2
skip-checks: true
2020-07-25 12:15:51 +00:00
Jaco Greeff 56e4cbdb27 Update .123trigger 2020-07-25 14:03:36 +02:00
nsso 60bfdae734 support rpc import definitions (#2438)
* support import definitions

* fix lint
2020-07-25 13:53:04 +02:00
Jaco Greeff 1cf4d6b9b8 Additional typegen asserts (#2448)
* Additional typegen asserts

* typo

* Revert tuple assert

* Free-standing Vec is valid
2020-07-25 13:47:34 +02:00
Github Actions 40cd9ff51f [CI Skip] release/beta 1.26.0-beta.1
skip-checks: true
2020-07-20 18:13:14 +00:00
Jaco Greeff c7e6e40030 Voting is only free balance (#2444) 2020-07-20 20:03:26 +02:00
Github Actions 97d0bcbfd4 [CI Skip] release/beta 1.26.0-beta.0
skip-checks: true
2020-07-20 10:55:27 +00:00
Shawn Tabrizi 6ca84425d1 Update docs for accountNextIndex (#2443) 2020-07-20 12:45:01 +02:00
Github Actions 8481647d2c [CI Skip] release/stable 1.25.1
skip-checks: true
2020-07-20 07:35:42 +00:00
Jaco Greeff 658dda66a4 1.25 (#2440)
* 1.25

* Bump metadata
2020-07-20 09:25:04 +02:00
Github Actions 87f18efe72 [CI Skip] release/beta 1.25.0-beta.12
skip-checks: true
2020-07-17 12:38:05 +00:00
Jaco Greeff bcdfcce89c Bump dev 2020-07-17 14:26:19 +02:00
Github Actions 9418f1de56 [CI Skip] release/beta 1.25.0-beta.11
skip-checks: true
2020-07-17 12:15:43 +00:00
Jaco Greeff 37c8b8e592 Dev bumpd 2020-07-17 14:03:45 +02:00
Github Actions 4f8db79a40 [CI Skip] release/beta 1.25.0-beta.10
skip-checks: true
2020-07-17 10:28:46 +00:00
Jaco Greeff 54cf086a89 Update ContractExecResult (#2437) 2020-07-17 12:17:35 +02:00
Github Actions 37ddcaa32d [CI Skip] release/beta 1.25.0-beta.9
skip-checks: true
2020-07-17 09:38:57 +00:00
Jaco Greeff 6a2baf8352 Types for Polkadot purchase (#2436) 2020-07-17 11:27:21 +02:00
Github Actions ecca91dffd [CI Skip] release/beta 1.25.0-beta.8
skip-checks: true
2020-07-17 06:59:19 +00:00
Jaco Greeff 42576d74ac Bump deps (#2435) 2020-07-17 08:47:57 +02:00
Github Actions 26a6f20dbf [CI Skip] release/beta 1.25.0-beta.7
skip-checks: true
2020-07-17 06:33:03 +00:00
Chevdor c3ee8393b2 Add 'Registrar #1' as user (#2433) 2020-07-17 08:20:08 +02:00
Github Actions b6f0b9f262 [CI Skip] release/beta 1.25.0-beta.6
skip-checks: true
2020-07-15 17:25:30 +00:00
Jaco Greeff 991dc48020 Raw/Bytes toHuman() uses utf8 as available (#2431)
* Raw/Bytes toHuman() uses utf8 as available

* Rewrite yarn.lock

* Bump babel
2020-07-15 18:55:50 +02:00
Github Actions e4a82f9a1d [CI Skip] release/beta 1.25.0-beta.5
skip-checks: true
2020-07-15 08:58:08 +00:00
Jaco Greeff c8b6012553 networkstate reputation i32 (#2430) 2020-07-15 10:48:18 +02:00
Github Actions d0fe862605 [CI Skip] release/beta 1.25.0-beta.4
skip-checks: true
2020-07-14 17:14:55 +00:00
Jaco Greeff 61a0198695 Fallback for setImmediate (#2428) 2020-07-14 19:04:16 +02:00
Github Actions 345a97dc9f [CI Skip] release/beta 1.25.0-beta.3
skip-checks: true
2020-07-14 13:02:42 +00:00
Brad LarsonandBrad Larson f821ab8ecd [NEW] Support for custom headers with providers (#2423)
* [NEW] Support for custom headers with providers

This allows the user to supply arbitrary headers when constructing the
providers.

* [FIX] null -> undefined, use isChildClass

Co-authored-by: Brad Larson <brad@polychain.capital>
2020-07-14 14:49:42 +02:00
Github Actions f9e2bf332d [CI Skip] release/beta 1.25.0-beta.2
skip-checks: true
2020-07-14 08:40:25 +00:00
Jaco Greeff ad69430980 Clazz prototype fix for Linkage (#2426)
* Cleanup progress calcs for Aura

* Clazz prototype
2020-07-14 10:28:38 +02:00
Github Actions d25743016c [CI Skip] release/beta 1.25.0-beta.1
skip-checks: true
2020-07-14 08:15:18 +00:00
Jaco Greeff ee0a46adc4 Cleanup progress calcs for Aura (#2425) 2020-07-14 10:02:44 +02:00
Github Actions f516abfc3f [CI Skip] release/beta 1.25.0-beta.0
skip-checks: true
2020-07-13 18:53:28 +00:00
philipstanislaus 1a96ca5c0e Update types for centrifuge chain v1.2.0 (#2424)
* Update types for centrifuge chain v1.2.0

* Make linter happy
2020-07-13 20:41:15 +02:00
Github Actions 8c73cd7d6e [CI Skip] release/stable 1.24.1
skip-checks: true
2020-07-13 09:49:07 +00:00
Jaco Greeff 36232c0289 1.24 (#2421) 2020-07-13 11:38:47 +02:00
Github Actions 50d4e0397f [CI Skip] release/beta 1.24.0-beta.2
skip-checks: true
2020-07-10 13:28:14 +00:00
Jaco Greeff 539a8c4cb5 Types for poll module (#2418) 2020-07-10 15:17:03 +02:00
Github Actions b849976b3b [CI Skip] release/beta 1.24.0-beta.1
skip-checks: true
2020-07-08 14:35:48 +00:00
Jaco Greeff 2395401a2b Raw/Bytes isUtf8 & assert in toUtf8 (#2414) 2020-07-08 16:24:13 +02:00
Github Actions 0e1bbd5cac [CI Skip] release/beta 1.24.0-beta.0
skip-checks: true
2020-07-08 12:57:36 +00:00
Jaco Greeff e9489d41cb Raw isAscii & toUtf8 (#2413)
* Raw isAscii & toUtf8

* Tests for isAscii & toUtf8

* Cleanup return types
2020-07-08 14:46:12 +02:00
Github Actions 63483b9db7 [CI Skip] release/stable 1.23.1
skip-checks: true
2020-07-06 05:45:32 +00:00
Jaco Greeff b26c7f9f0a 1.23.1 (ith version bump) 2020-07-06 07:31:36 +02:00
Github Actions a165c9375c [CI Skip] release/beta 1.23.0-beta.7
skip-checks: true
2020-07-06 05:27:04 +00:00
Jaco Greeff 28631f7180 1.23 (#2411) 2020-07-06 07:15:07 +02:00
Github Actions 6489251b47 [CI Skip] release/beta 1.23.0-beta.6
skip-checks: true
2020-07-03 15:34:13 +00:00
Jaco Greeff 66884febea Add OpaqueCall type (#2408) 2020-07-03 17:22:02 +02:00
Github Actions 8058dc350f [CI Skip] release/beta 1.23.0-beta.5
skip-checks: true
2020-07-03 10:05:48 +00:00
Jaco Greeff 63096cc238 Remove unneeded base extends (#2407)
* Remove unneeded base extends

* CHANGELOG

* Result with value on enum
2020-07-03 11:55:39 +02:00
Github Actions 05600c0cd0 [CI Skip] release/beta 1.23.0-beta.4
skip-checks: true
2020-07-03 09:46:07 +00:00
Jaco Greeff eed5e23e65 Validate number sign in AbstractInt (#2406) 2020-07-03 11:33:30 +02:00
Github Actions cdf5b15673 [CI Skip] release/beta 1.23.0-beta.3
skip-checks: true
2020-07-02 05:27:15 +00:00
Jaco Greeff 1922676bd7 Bump deps (#2404) 2020-07-02 07:14:08 +02:00
Github Actions b6c427e985 [CI Skip] release/beta 1.23.0-beta.2
skip-checks: true
2020-07-01 15:55:54 +00:00
Jaco Greeff 0327aedf8e Update ProxyType for Kusama, Polkadot & Westend (#2403)
* Update ProxyType fro Kusama, Polkadot & Westend

* CHANGELOG
2020-07-01 17:42:22 +02:00
Github Actions d7035cebb1 [CI Skip] release/beta 1.23.0-beta.1
skip-checks: true
2020-07-01 11:51:42 +00:00
Daniel Maricic 8b492021af Fixed typo in README (#2402) 2020-07-01 13:39:07 +02:00
Github Actions 6a01fc7c8c [CI Skip] release/beta 1.23.0-beta.0
skip-checks: true
2020-07-01 05:58:34 +00:00
Jaco Greeff bbc30ec9dc Cross-referencing type failure (#2400)
* Cross-referencing type failure

* typo

* Adjust toRawType() with name from registry

* Rewrite yarn.lock

* Adjustments

* Test adjustments
2020-07-01 07:47:21 +02:00
Github Actions f07c0628bc [CI Skip] release/stable 1.22.1
skip-checks: true
2020-06-30 08:04:08 +00:00
Jaco Greeff 023c7588e5 1.22 (#2399)
* 1.22

* CHANGELOG for OpenTip
2020-06-30 09:52:42 +02:00
Jaco Greeff 7dfc8625cc New OpenTip structure (#2394)
* New OpenTip structure

* Kusama update
2020-06-29 16:20:43 +02:00
Github Actions 8643b5da87 [CI Skip] release/beta 1.22.0-beta.5
skip-checks: true
2020-06-29 07:03:10 +00:00
Jaco Greeff afa0e63ae8 CHANGELOG & Bumps (#2397)
* CHANGELOG & Bumps

* Rewrite yarn.lock
2020-06-29 08:52:12 +02:00
Github Actions 534303ff45 [CI Skip] release/beta 1.22.0-beta.4
skip-checks: true
2020-06-28 14:18:29 +00:00
Jaco Greeff f1ebcddec6 Adjust for vesting via locks (#2396) 2020-06-28 16:08:02 +02:00
Github Actions 657a2006dd [CI Skip] release/beta 1.22.0-beta.3
skip-checks: true
2020-06-24 19:02:00 +00:00
Jaco Greeff 219e928c01 Retried staker rewards for specified eras (#2392) 2020-06-24 20:52:21 +02:00
Github Actions 43183118d5 [CI Skip] release/beta 1.22.0-beta.2
skip-checks: true
2020-06-24 10:43:10 +00:00
Alexander Krupenkin 76e15d465d Add [u8; 33] type width for U8aFixed type (#2391)
ECDSA compressed public key has 33-byte length, this is required for encoding public key as a parameter.
2020-06-24 12:31:55 +02:00
Github Actions 4c0387e1a3 [CI Skip] release/beta 1.22.0-beta.1
skip-checks: true
2020-06-23 20:31:15 +00:00
Jaco Greeff bbbd82eb4a Move indices cache to indices list (#2390) 2020-06-23 22:19:13 +02:00
Github Actions a34a7450aa [CI Skip] release/beta 1.22.0-beta.0
skip-checks: true
2020-06-23 18:38:54 +00:00
Jaco Greeff bf472fdcf4 Optimize accountId -> accountIndex lookups (#2389) 2020-06-23 20:25:58 +02:00
Github Actions f428a58006 [CI Skip] release/stable 1.21.1
skip-checks: true
2020-06-23 16:12:18 +00:00
Jaco Greeff fcce2ab340 1.21 (#2384)
* 1.21

* CHANGELOG

* Babe EquivocationProof

* Update CHANGELOG.md
2020-06-23 18:01:47 +02:00
Jaco Greeff 877eb11717 Swap releases type to shared enum (#2388)
* Swap releases type to u8

* Shared enum for releases

* Update metadata for new names
2020-06-23 17:40:15 +02:00
Jaco Greeff 4b55f1be93 Babe Equivocation (#2374)
* Babe Equivocation

* metadata field rename to GrandpaEquivocationProof
2020-06-23 16:46:26 +02:00
Github Actions f2a677634e [CI Skip] release/beta 1.21.0-beta.4
skip-checks: true
2020-06-23 13:18:12 +00:00
Jaco Greeff eea4c8775e Use setImmediate for unsubscribe (allow outer resolve) (#2385) 2020-06-23 15:06:08 +02:00
Github Actions 792bf0ec36 [CI Skip] release/beta 1.21.0-beta.3
skip-checks: true
2020-06-23 12:20:27 +00:00
Jaco Greeff e3d13107a9 Add support for CheckMortality extension (#2383) 2020-06-23 14:08:40 +02:00
Jaco Greeff e5c2c6a228 Use BN in-place operators as appropriate (#2381)
* Use BN in-place operators as appropriate

* CHANGELOG
2020-06-23 14:02:54 +02:00
Github Actions d2be79132c [CI Skip] release/beta 1.21.0-beta.2
skip-checks: true
2020-06-23 11:59:30 +00:00
Jaco Greeff 76da2638c1 Ensure subscriptions always unsubscribe as required (#2380)
* Ensure single-shot calls always unsubscribe

* memo/refCount cleanups

* Fix unsubscriptions

* Cleanup linting types

* CHANGELOG
2020-06-23 13:47:28 +02:00
Github Actions daf3912920 [CI Skip] release/beta 1.21.0-beta.1
skip-checks: true
2020-06-23 09:17:57 +00:00
Jaco Greeff 6dfebbb9fe Fixup subscriptions for promise (w/ callback) (#2379)
* Fixup subscriptions for promise (w/ callback)

* Update packages/api/src/base/Decorate.ts
2020-06-23 11:05:51 +02:00
Github Actions e55c5f77f7 [CI Skip] release/beta 1.21.0-beta.0
skip-checks: true
2020-06-23 07:41:54 +00:00
Jaco Greeff c7315ffb74 Do not use subscriptions on single subs (#2378)
* Do not use subscriptions on single subs

* Apply suggestions from code review
2020-06-23 09:29:49 +02:00
Github Actions 84eb806f07 [CI Skip] release/stable 1.20.1
skip-checks: true
2020-06-22 14:20:44 +00:00
Jaco Greeff 2493442a2e 1.20 (#2377)
* 1.20

* Indicate @polkadot/util bump
2020-06-22 16:08:22 +02:00
Github Actions 77df7907c7 [CI Skip] release/beta 1.20.0-beta.9
skip-checks: true
2020-06-22 13:42:01 +00:00
Jaco Greeff f1b6268784 Bump metadata (#2376) 2020-06-22 15:31:27 +02:00
Github Actions 9aa9380251 [CI Skip] release/beta 1.20.0-beta.8
skip-checks: true
2020-06-22 08:22:33 +00:00
Jaco Greeff b4306cb60a Bump metadata (#2373) 2020-06-22 10:12:01 +02:00
Github Actions 1e83daf797 [CI Skip] release/beta 1.20.0-beta.7
skip-checks: true
2020-06-21 11:26:27 +00:00
Jaco Greeff d46d32d9bc Optimize query/queryMulti retrievals (#2371)
* Optimize query/queryMulti retrievals

* Current retrieval on a batch basis

* Dedup staking.account/accounts internally
2020-06-21 13:13:38 +02:00
Github Actions 032a0a595c [CI Skip] release/beta 1.20.0-beta.6
skip-checks: true
2020-06-21 08:09:28 +00:00
Jaco Greeff 34101ec12b Adjust with queryMulti as applicable (#2370) 2020-06-21 09:56:02 +02:00
Github Actions 4e02b982d3 [CI Skip] release/beta 1.20.0-beta.5
skip-checks: true
2020-06-20 18:12:10 +00:00
Jaco Greeff 5b96d52fa6 Adjust for zero-length combines (#2369) 2020-06-20 20:00:01 +02:00
Github Actions 735f2b835e [CI Skip] release/beta 1.20.0-beta.4
skip-checks: true
2020-06-20 13:42:40 +00:00
Jaco Greeff 646e64c286 Add derive.staking.waitingInfo (#2367)
* Add derive.staking.waitingInfo

* Small optimizations

* Updated
2020-06-20 15:30:48 +02:00
Github Actions fc9060caa8 [CI Skip] release/beta 1.20.0-beta.3
skip-checks: true
2020-06-19 12:04:34 +00:00
Jaco Greeff 503c2b3c63 Add transactionPayment release type (#2366) 2020-06-19 13:51:40 +02:00
Github Actions 168abc130f [CI Skip] release/beta 1.20.0-beta.2
skip-checks: true
2020-06-18 08:28:13 +00:00
Jaco Greeff 5c5db2709b Add system_dryRun RPCs (#2363)
* Add system_dryRun RPCs

* CHANGELOG
2020-06-18 10:15:41 +02:00
Github Actions 5a4ff5420f [CI Skip] release/beta 1.20.0-beta.1
skip-checks: true
2020-06-18 08:04:22 +00:00
Jaco Greeff a1655508ba Cleanups in API typing (& overrides) (#2362)
* Cleanups in API typing (& overrides)

* Less magic "as" overrides
2020-06-18 09:52:39 +02:00
Github Actions 64827a6114 [CI Skip] release/beta 1.20.0-beta.0
skip-checks: true
2020-06-17 22:18:49 +00:00
Jaco Greeff 2eb09374bc Map entries/keys cleanups (#2360) 2020-06-18 00:06:19 +02:00
Github Actions ddf67d5564 [CI Skip] release/stable 1.19.1
skip-checks: true
2020-06-16 06:47:45 +00:00
Jaco Greeff ad6b8280a2 1.19 (#2354)
* Bump deps

* 1.19

* Update CHANGELOG.md

* Freshen Substrate metadata
2020-06-16 08:34:19 +02:00
Github Actions 682c6b6fb2 [CI Skip] release/beta 1.19.0-beta.3
skip-checks: true
2020-06-12 21:28:49 +00:00
Jaco Greeff 6a281211b4 Bump metadata, allow type alias on events (#2351)
* Bump metadata, allow type alias on events

* Update packages/api/src/submittable/createClass.ts

* Update packages/metadata/src/Metadata/v11/static-substrate.json

* Fresh, no config changes
2020-06-12 23:15:50 +02:00
Github Actions 6ef94b3c3b [CI Skip] release/beta 1.19.0-beta.2
skip-checks: true
2020-06-12 16:31:41 +00:00
Jeremías Díaz e900d1d657 impovement: better typing of entries related funcs (#2346)
* impovement: better typing of entries related funcs

* refactor: remove duplicate definition
2020-06-12 18:19:55 +02:00
Github Actions 7f1a3fa636 [CI Skip] release/beta 1.19.0-beta.1
skip-checks: true
2020-06-11 07:00:42 +00:00
Jaco Greeff 21802664b8 Metadata bump (#2348) 2020-06-11 08:48:52 +02:00
Github Actions 1492df11a7 [CI Skip] release/beta 1.19.0-beta.0
skip-checks: true
2020-06-10 11:13:46 +00:00
Jaco Greeff 00fed90da2 Update parachain types (#2344) 2020-06-10 13:00:10 +02:00
Github Actions e6beb6554d [CI Skip] release/stable 1.18.1
skip-checks: true
2020-06-08 15:53:39 +00:00
Jaco Greeff 099cf5a351 1.18 (#2340)
* 1.18

* Polkadot ProxyType
2020-06-08 17:39:12 +02:00
Github Actions 55e762a348 [CI Skip] release/beta 1.18.0-beta.10
skip-checks: true
2020-06-08 13:43:22 +00:00
Jaco Greeff 0ad146c607 Adjust ProxyType for Westend (#2339) 2020-06-08 15:30:51 +02:00
Github Actions 4e7f3f5268 [CI Skip] release/beta 1.18.0-beta.9
skip-checks: true
2020-06-08 08:02:24 +00:00
Jeremías DíazandJaco Greeff 6a9e3d80f1 feat: add external pagination support (#2325)
* feat: add external pagination support

* Ordering, no functionality changes

* fix: use correct assertion condition

Also moved the PaginationOptions type to the base types file

* Apply suggestions from code review

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
2020-06-08 09:49:53 +02:00
Github Actions dee98fae55 [CI Skip] release/beta 1.18.0-beta.8
skip-checks: true
2020-06-08 05:59:44 +00:00
Xiliang Chen ff52876920 allow Option in enum & Result type (#2336) 2020-06-08 07:45:22 +02:00
Github Actions 4d01a09c54 [CI Skip] release/beta 1.18.0-beta.7
skip-checks: true
2020-06-07 17:27:50 +00:00
Jaco Greeff 7310ea825e Allow for string subids (#2335) 2020-06-07 19:16:16 +02:00
Github Actions 15b80a47c3 [CI Skip] release/beta 1.18.0-beta.6
skip-checks: true
2020-06-07 13:02:15 +00:00
Jaco Greeff 622682b4ef npos-election ElectionScore type (#2334) 2020-06-07 14:50:25 +02:00
Github Actions 56415df4ab [CI Skip] release/beta 1.18.0-beta.5
skip-checks: true
2020-06-06 06:53:17 +00:00
Jaco Greeff 8bea5e5a3b Align Call section/method field names (#2332) 2020-06-06 08:40:41 +02:00
Github Actions d6372ade44 [CI Skip] release/beta 1.18.0-beta.4
skip-checks: true
2020-06-05 20:32:29 +00:00
Jaco Greeff f501994df8 Bump deps (#2333) 2020-06-05 22:20:32 +02:00
Github Actions b787a7d5a0 [CI Skip] release/beta 1.18.0-beta.3
skip-checks: true
2020-06-03 20:20:42 +00:00
Gerben van de Wiel 11d162a10d Adding some extra notes on changes in the specname (#2329) 2020-06-03 22:08:06 +02:00
Github Actions e2564dea17 [CI Skip] release/beta 1.18.0-beta.2
skip-checks: true
2020-06-03 13:40:22 +00:00
Jaco Greeff 2b9152871e Add ProxyType (#2327) 2020-06-03 15:27:11 +02:00
Github Actions 70ecb03d14 [CI Skip] release/beta 1.18.0-beta.1
skip-checks: true
2020-06-03 05:46:05 +00:00
djuanito.eth a2f179acb1 Update fees to current constants (#2320)
* Update fees to current constants

* Reorder args on map()

* Fixed incorrect order of args on map()
2020-06-03 07:34:03 +02:00
Jaco Greeff c8cb97edef beta 0 reset 2020-06-03 07:33:27 +02:00
663 changed files with 26069 additions and 49090 deletions
+4 -2
View File
@@ -1,5 +1,7 @@
24
25
1.4.2
1.6.2
1.11.2
1.12.21.17.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');
+6 -1
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 = {
@@ -13,6 +16,8 @@ module.exports = {
// add override for any (a metric ton of them, initial conversion)
'@typescript-eslint/no-explicit-any': 'off',
// these should be removed, there are 8 of them as errors
'@typescript-eslint/no-non-null-assertion': 'off'
'@typescript-eslint/no-non-null-assertion': 'off',
// this seems very broken atm, false positives
'@typescript-eslint/unbound-method': 'off'
}
};
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
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
-56
View File
File diff suppressed because one or more lines are too long
+6 -2
View File
@@ -5,7 +5,11 @@ 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"
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: "@yarnpkg/plugin-version"
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
yarnPath: .yarn/releases/yarn-rc.js
yarnPath: .yarn/releases/yarn-2.2.2.cjs
+564 -4
View File
File diff suppressed because it is too large Load Diff
+1 -2
View File
@@ -7,7 +7,7 @@
# @polkadot/api
This library provides a clean wrapper around all the methods exposed by a Polkadot/Subtrate network client and defines all the types exposed by a node. For complete documentation around the classes, interfaces and their use, visit the [documentation portal](https://polkadot.js.org/api/).
This library provides a clean wrapper around all the methods exposed by a Polkadot/Substrate network client and defines all the types exposed by a node. For complete documentation around the classes, interfaces and their use, visit the [documentation portal](https://polkadot.js.org/api/).
If you are an existing user, please be sure to track the [CHANGELOG](CHANGELOG.md) and [UPGRADING](UPGRADING.md) guides when changing versions.
@@ -27,7 +27,6 @@ The API is split up into a number of internal packages -
Type definitions for interfaces as exposed by Polkadot & Substrate clients -
- [@polkadot/jsonrpc](packages/jsonrpc/) Definitions for JSONRPC endpoints
- [@polkadot/types](packages/types/) Codecs for all Polkadot and Substrate primitives
## development
+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"
+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Copyright 2017-2020 @polkadot/api authors & contributors
# SPDX-License-Identifier: Apache-2.0
function copy_folder () {
SRC="packages/$1/build"
DST="../test/js-test/node_modules/@polkadot/$1"
echo "** Copying $SRC to $DST"
rm -rf $DST
cp -r $SRC $DST
}
yarn polkadot-dev-build-ts
copy_folder "api"
copy_folder "api-contract"
copy_folder "api-derive"
copy_folder "metadata"
copy_folder "rpc-core"
copy_folder "rpc-provider"
copy_folder "types"
copy_folder "types-known"
copy_folder "typegen"
+28
View File
@@ -42,3 +42,31 @@ const header = await api.derive.chain.getHeader();
console.log(`#${header.number}: ${header.author}`);
```
## How do I view block extrinsic information?
The transactions are included in a signed block as part of the extrinsics - some of these will be unsigned and generated by the block author and some of these may be submitted from external sources and be signed. (Some palettes do use unsigned transactions, so signed/unsigned is not an indication of origin). To retrieve the block and display the transaction information, we can do the following -
```js
// no blockHash is specified, so we retrieve the latest
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, 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()}`);
}
});
```
In the above `.toHuman()` is used to format into a human-readable representation. You can inspect/extract specific fields from the decoded extrinsic as required, for instance `ex.method.section` would return the pallete that executed this transaction.
+6 -6
View File
@@ -16,9 +16,9 @@ const info = await api.tx.balances
// log relevant info, partialFee is Balance, estimated for current
console.log(`
class=${class.toString()},
weight=${weight.toString()},
partialFee=${partialFee.toHuman()}
class=${info.class.toString()},
weight=${info.weight.toString()},
partialFee=${info.partialFee.toHuman()}
`);
```
@@ -97,12 +97,12 @@ api.tx.utility
## How do I take the pending tx pool into account in my nonce?
The `system.account` query will always contain the current state, i.e. it will reflect the nonce for the last known block. As such when sending multiple transactions in quick succession (see batching above), there may be transactions in the pool that has the same nonce that `signAndSend` would apply - this call doesn't do any magic, it simply reads the state for the nonce. Since we can specify options to the `signandSend` operation, we can override the nonce, either by manually incrementing it o querying it via `nextNonce`.
The `system.account` query will always contain the current state, i.e. it will reflect the nonce for the last known block. As such when sending multiple transactions in quick succession (see batching above), there may be transactions in the pool that has the same nonce that `signAndSend` would apply - this call doesn't do any magic, it simply reads the state for the nonce. Since we can specify options to the `signAndSend` operation, we can override the nonce, either by manually incrementing it or querying it via `rpc.system.accountNextIndex`.
```js
for (let i = 0; i < 10; i++) {
// retrieve the nextNonce, taking txs in the pool into account
const nonce = await api.rpc.account.nextNonce(sender);
// retrieve sender's next index/nonce, taking txs in the pool into account
const nonce = await api.rpc.system.accountNextIndex(sender);
// send, just retrieving the hash, not waiting on status
const txhash = await api.tx.balances
+2 -2
View File
@@ -90,7 +90,7 @@ Looking at the example in this repo, it also has `augment*`, `index.ts` and `typ
## Generating
Now that both the metadata nd types setup is completed, we just run the build command via `yarn build` and magically (assuming you didn't have the `augment*` and other generated files), these files will be added. When running this command, the console should display something like -
Now that both the metadata and types setup is completed, we just run the build command via `yarn build` and magically (assuming you didn't have the `augment*` and other generated files), these files will be added. When running this command, the console should display something like -
```
> yarn build
@@ -166,7 +166,7 @@ As mentioned earlier, here you will notice the `import { VoteStage }`, the gener
## TypeScript config
Now that we have files generated, it is time to make TypeScript aware of the types and add an explicit override into out `tsconfig.json`. After some changes, the paths in the config looks as follow (comments are in teh actual config file here) -
Now that we have files generated, it is time to make TypeScript aware of the types and add an explicit override into out `tsconfig.json`. After some changes, the paths in the config looks as follow (comments are in the actual config file here) -
```json
{
+2 -13
View File
@@ -20,6 +20,8 @@ All data transferred between the API and the Node is in a SCALE-encoded binary f
To fix this, you should look at the specific `api.tx.*` params and adjust the type definitions for those param types to match what is found on the node side. In some rare cases the cause could be extrinsic formatting related, to track these make an `api.tx.system.remark(data: Bytes)` call, if it fails, the API and node cannot agree on [an extrinsic format and adjustments are required](types.extend.md#impact-on-extrinsics).
If you are using a node-template based version of substrate and you changed the specName you need to add these typings(In addition to other custom types) `{"Address": "AccountId","LookupSource": "AccountId"}`. This is also the case when you use [polkadot-js/apps](https://github.com/polkadot-js/apps) to connect to your node. When the specName stays node-template the API is smart enough to add the custom typings.
## I would like to sign transactions offline
The API itself is independent on where the signature comes from and how it is injected. Additionally it implements a signer interface, that can be used for external signing - an example of this is the [polkadot-js/apps](https://github.com/polkadot-js/apps) support for signing via extensions and even the [polkadot-js/extension](https://github.com/polkadot-js/extension) support for tools such as the [Parity Signer](https://github.com/paritytech/parity-signer).
@@ -63,16 +65,3 @@ Due to these customizations and differences that bleed through to the transactio
Recently Substrate master updated the `Weight` type from `u32` -> `u64`. This type is used in the `DispatchInfo` struct in the `system.ExtrinsicSuccess` events, to return the applied call weights as well as the resulting fees. Since the API master branch tracks Substrate master, this means the change has been applied by default, with the default set to `u64`.
If you are on a chain that has not been upgraded yet, you need to add `Weight: 'u32'` to your types to allow for successful parsing of all events. Without this override, parsing will fail. As soon as one event in the `Vec<EventRecord>` structure from `system.events` fails to parse, all subsequent events are affected and the decoding will return an error.
## When querying older blocks & events, it fails on parsing
Upon initialization, the API is decorated with the [current on-chain metadata](basics.md#metadata) and (if [available](https://github.com/polkadot-js/api/tree/master/packages/types-known/src)) the specific types for the runtime version is added. This allows the API to decode all current (as per the on-chain info) state and extrinsics.
When the chain is upgraded, new metadata (indicating new events, storage and extrinsics) is added on-chain. Additionally this generally goes hand in-hand with changes in types, i.e. fields may be addedd or removed or state that was used could now be migrated to new locations. In most cases, this would mean that the current chain information cannot be used to parse older entries pre-upgrade. A typical consequence of this is that any `.at(...)` or `.range(...)` queries pre-upgrade may fail.
As of the current time, there is no automatic injection of older metadata (based on the runtime version at a specific block) nor decoration of older types if they are available. It can be emulated with what the API will do to handle these cases when it adds a `.historic(...)` query type -
- querying the runtime version at the parent of older block you wish to retrieve
- retrieving and injecting the metadata from the parent block (if the runtime version has changed)
- inject any specific older types for the state at that point
- finally retrieve the actual entry via an `.at(...)` query
+3 -3
View File
@@ -8,7 +8,7 @@ import { ApiPromise, WsProvider } from '@polkadot/api';
...
// Construct
const wsProvider = new WsProvider('wss://poc-3.polkadot.io');
const wsProvider = new WsProvider('wss://rpc.polkadot.io');
const api = await ApiPromise.create({ provider: wsProvider });
// Do something
@@ -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.
+1 -1
View File
@@ -42,7 +42,7 @@ Be aware that while defined, the method will only appear on the API if it is in
## Definition breakdown
While the above example should be self-explanatory, it is important to understand teh structure. The `rpc: { ... }` definitions are keyed first and foremost by the name of the module exposing the RPC. This means that when we have 2 modules `firstModule` & `testModule`, the first-level structure would follow the following pattern,
While the above example should be self-explanatory, it is important to understand the structure. The `rpc: { ... }` definitions are keyed first and foremost by the name of the module exposing the RPC. This means that when we have 2 modules `firstModule` & `testModule`, the first-level structure would follow the following pattern,
```js
...
+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 -1
View File
@@ -20,7 +20,7 @@ With the conversions done in the API, there are limited reasons to create types
import type { Balance } from '@polkadot/types/interfaces';
...
// unwrap out option into a zero Balance whn not found
// unwrap out option into a zero Balance when not found
// (This can be done via `.unwrapOrDefault()`, which does the same underlying)
const balance: Balance = balanceOpt.unwrapOr(api.createType('Balance'));
```
+3 -3
View File
@@ -6,7 +6,7 @@ Therefore to cater for all types, a mapping in done on the [@polkadot/types libr
Additionally, the API contains some logic for chain type detection, for instance in the case of Substrate 1.x based chains, it will define `BlockNumber` & `Index` (nonce) as a `u64`, while for current-generation chains, these will be defined as `u32`. Some of the work in maintaining the API for Polkadot/Substrate is the addition of types as they appear and gets used in the Rust codebase.
There is a the [recommendation](install.md#betas) to use a `@polkadot/api@beta` should you wish to track the master branches of Polkadot or Substrate, since master changes for the addition of new types do not make it into a stable release immediately.
There is the [recommendation](install.md#betas) to use a `@polkadot/api@beta` should you wish to track the master branches of Polkadot or Substrate, since master changes for the addition of new types do not make it into a stable release immediately.
## Extension
@@ -87,7 +87,7 @@ Document: {
## User-defined enum
One form of types that appear regularly is enums, these can be defined as follow -
One form of types that appear regularly is enums, these can be defined as follows -
```js
...
@@ -212,4 +212,4 @@ Always look at customization and understand the impacts, replicating these chang
## Custom RPC
In addition to customizing modules and types on your node, you can also add custom RPC definitions. Like the type definitions in ths section, [these can be defined and passed to the API](rpc.custom.md) for decoration.
In addition to customizing your node's modules and types, you can also add custom RPC definitions. Like the type definitions in this section, [these can be defined and passed to the API](rpc.custom.md) for decoration.
+3 -3
View File
@@ -1,6 +1,6 @@
# TypeScript user generated
In the previous section we looked at the TypeScript definitions that are available and is generated from both the chain and definitions. Here we will expand upon the use of the infrastructure created to define types as part of the `@polkadot/types` library and see how to use them to generate your own definitions and chain types.
In the previous section we looked at the TypeScript definitions that are available and are generated from both the chain and definitions. Here we will expand upon the use of the infrastructure created to define types as part of the `@polkadot/types` library and see how to use them to generate your own definitions and chain types.
## Definitions
@@ -17,7 +17,7 @@ In the root of your project (with the `@polkadot/typegen` package installed), yo
## Chain modules
In the same way as the type library provides defaults from a substrate-base chain, you can also, directly from chain from metadata, generate a complete `api.{consts,query}.*` definition for your specific chain. The command will create 2 files, `{consts, query}.types.ts` which you can either use to augment the TypeScript definitions, or replace those in `@polkadot/api/*` with your versions (copy, TypeScript replacement or browser/node aliasing).
In the same way as the type library provides defaults from a substrate-base chain, you can also, directly from the chain's metadata, generate a complete `api.{consts,query}.*` definition for your specific chain. The command will create 2 files, `{consts, query}.types.ts` which you can either use to augment the TypeScript definitions, or replace those in `@polkadot/api/*` with your versions (copy, TypeScript replacement or browser/node aliasing).
In the root of your project, you can run `yarn polkadot-types-from-chain --endpoint wss://<url> --output ./stuff` and it will create the required output. (Here you can specify an optional `--package @MeInc/stuff` to read definitions for the targeted output folder with the specified package name.)
@@ -27,4 +27,4 @@ The [TypeScript augmentation example](../examples/promise/90_typegen/) example p
## And that's a wrap
This brings us to the end of our overview and jump through the API. While the documentation is still very much and ever evolving item, we can encourage you to try out what you have learned with some [examples](../examples). As we [indicated right at the start of this journey](README.md#help-us-help-others), if there are areas for improvement, let us know.
This brings us to the end of our overview and jump through the API. While the documentation is still very much an ever evolving item, we can encourage you to try out what you have learned with some [examples](../examples). As we [indicated right at the start of this journey](README.md#help-us-help-others), if there are areas for improvement, let us know.
+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');
-13
View File
@@ -1,13 +0,0 @@
{
"npmClient": "yarn",
"useWorkspaces": true,
"command": {
"publish": {
"allowBranch": "master"
}
},
"packages": [
"packages/*"
],
"version": "1.17.2"
}
+14 -10
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.3"
},
"scripts": {
"build": "yarn build:interfaces && polkadot-dev-build-ts && (cd packages/typegen && copyfiles scripts/* build)",
@@ -24,15 +25,18 @@
"test:watch": "polkadot-dev-run-test --watch"
},
"devDependencies": {
"@babel/core": "^7.10.2",
"@babel/register": "^7.10.1",
"@babel/runtime": "^7.10.2",
"@polkadot/dev": "^0.55.7",
"@polkadot/ts": "^0.3.25",
"@babel/core": "^7.11.6",
"@babel/register": "^7.11.5",
"@babel/runtime": "^7.11.2",
"@polkadot/dev": "^0.57.8",
"@polkadot/ts": "^0.3.49",
"@polkadot/typegen": "workspace:packages/typegen",
"@types/jest": "^25.2.3",
"@vuepress/plugin-search": "^1.5.0",
"copyfiles": "^2.3.0"
"@types/jest": "^26.0.14",
"@vuepress/plugin-search": "^1.6.0",
"copyfiles": "^2.4.0",
"typedoc": "^0.19.2",
"typedoc-plugin-markdown": "^3.0.7",
"typedoc-plugin-no-inherit": "^1.2.0"
},
"version": "1.17.2"
"version": "2.1.1"
}
+8 -8
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-contract",
"version": "1.17.2",
"version": "2.1.1",
"description": "Interfaces for interacting with contracts and contract ABIs",
"main": "index.js",
"keywords": [
@@ -26,12 +26,12 @@
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
"dependencies": {
"@babel/runtime": "^7.10.2",
"@polkadot/api": "1.17.2",
"@polkadot/rpc-core": "1.17.2",
"@polkadot/types": "1.17.2",
"@polkadot/util": "^2.12.2",
"bn.js": "^5.1.2",
"rxjs": "^6.5.5"
"@babel/runtime": "^7.11.2",
"@polkadot/api": "2.1.1",
"@polkadot/rpc-core": "2.1.1",
"@polkadot/types": "2.1.1",
"@polkadot/util": "^3.5.1",
"bn.js": "^5.1.3",
"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> {
+8 -7
View File
@@ -1,10 +1,9 @@
// 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';
import { Codec, IKeyringPair } from '@polkadot/types/types';
import { Codec, CodecArg, IKeyringPair } from '@polkadot/types/types';
import { ApiObject, ContractABIMessage, ContractABIPre, ContractCallOutcome } from '../types';
import BN from 'bn.js';
@@ -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> {
@@ -38,9 +39,9 @@ export default class Contract<ApiType extends ApiTypes> extends BaseWithTxAndRpc
this.address = this.registry.createType('Address', address);
}
public call (as: 'rpc', message: string, value: BN | number, gasLimit: BN | number, ...params: any[]): ContractCall<ApiType, 'rpc'>;
public call (as: 'tx', message: string, value: BN | number, gasLimit: BN | number, ...params: any[]): ContractCall<ApiType, 'tx'>;
public call<CallType extends ContractCallTypes> (as: CallType, message: string, value: BN | number, gasLimit: BN | number, ...params: any[]): ContractCall<ApiType, CallType> {
public call (as: 'rpc', message: string, value: BN | number, gasLimit: BN | number, ...params: CodecArg[]): ContractCall<ApiType, 'rpc'>;
public call (as: 'tx', message: string, value: BN | number, gasLimit: BN | number, ...params: CodecArg[]): ContractCall<ApiType, 'tx'>;
public call<CallType extends ContractCallTypes> (as: CallType, message: string, value: BN | number, gasLimit: BN | number, ...params: CodecArg[]): ContractCall<ApiType, CallType> {
const { def, fn } = this.getMessage(message);
return {
@@ -67,7 +68,7 @@ export default class Contract<ApiType extends ApiTypes> extends BaseWithTxAndRpc
};
}
private _createOutcome (result: ContractExecResult, origin: AccountId, message: ContractABIMessage, params: any[]): ContractCallOutcome {
private _createOutcome (result: ContractExecResult, origin: AccountId, message: ContractABIMessage, params: CodecArg[]): ContractCallOutcome {
let output: Codec | null = null;
if (result.isSuccess) {
+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';
-4
View File
@@ -1,7 +1,3 @@
# @polkadot/api-derive
Common functions used across Polkadot, derived from RPC calls and storage queries.
## Classes
[Classes](SUMMARY.md)
+11 -11
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-derive",
"version": "1.17.2",
"version": "2.1.1",
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
"main": "index.js",
"keywords": [
@@ -27,18 +27,18 @@
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"dependencies": {
"@babel/runtime": "^7.10.2",
"@polkadot/api": "1.17.2",
"@polkadot/rpc-core": "1.17.2",
"@polkadot/rpc-provider": "1.17.2",
"@polkadot/types": "1.17.2",
"@polkadot/util": "^2.12.2",
"@polkadot/util-crypto": "^2.12.2",
"bn.js": "^5.1.2",
"@babel/runtime": "^7.11.2",
"@polkadot/api": "2.1.1",
"@polkadot/rpc-core": "2.1.1",
"@polkadot/rpc-provider": "2.1.1",
"@polkadot/types": "2.1.1",
"@polkadot/util": "^3.5.1",
"@polkadot/util-crypto": "^3.5.1",
"bn.js": "^5.1.3",
"memoizee": "^0.4.14",
"rxjs": "^6.5.5"
"rxjs": "^6.6.3"
},
"devDependencies": {
"@polkadot/keyring": "^2.12.2"
"@polkadot/keyring": "^3.5.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';
@@ -30,7 +29,7 @@ function retrieve (api: ApiInterfaceRx, address: Address | AccountId | AccountIn
const accountIndex = api.registry.createType('AccountIndex', decoded);
return api.derive.accounts.indexToId(accountIndex).pipe(
return api.derive.accounts.indexToId(accountIndex.toString()).pipe(
map((accountId): AccountIdAndIndex => [accountId, accountIndex])
);
} catch (error) {
@@ -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)
+20 -10
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';
@@ -16,6 +15,8 @@ import { memo } from '../util';
const enumsetSize = ENUMSET_SIZE.toNumber();
let indicesCache: AccountIndexes | null = null;
function queryEnumSet (api: ApiInterfaceRx): Observable<AccountIndexes> {
return api.query.indices.nextEnumSet<AccountIndex>().pipe(
// use the nextEnumSet (which is a counter of the number of sets) to construct
@@ -70,13 +71,22 @@ function queryAccounts (api: ApiInterfaceRx): Observable<AccountIndexes> {
* });
* ```
*/
export function indexes (api: ApiInterfaceRx): () => Observable<AccountIndexes> {
return memo((): Observable<AccountIndexes> =>
(api.query.indices
? isFunction(api.query.indices.accounts)
? queryAccounts(api)
: queryEnumSet(api)
: of({} as AccountIndexes)
).pipe(startWith({}))
export function indexes (instanceId: string, api: ApiInterfaceRx): () => Observable<AccountIndexes> {
return memo(instanceId, (): Observable<AccountIndexes> =>
indicesCache
? of(indicesCache)
: (
api.query.indices
? isFunction(api.query.indices.accounts)
? queryAccounts(api).pipe(startWith({}))
: queryEnumSet(api).pipe(startWith({}))
: of({} as AccountIndexes)
).pipe(
map((indices): AccountIndexes => {
indicesCache = indices;
return indices;
})
)
);
}
+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';
+6 -7
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';
@@ -23,7 +22,7 @@ function calcBalances (api: ApiInterfaceRx, [accountId, [freeBalance, reservedBa
frozenFee,
frozenMisc,
reservedBalance,
votingBalance: api.registry.createType('Balance', freeBalance.add(reservedBalance))
votingBalance: api.registry.createType('Balance', freeBalance.toBn())
};
}
@@ -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),
+20 -20
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';
@@ -17,18 +16,22 @@ import { memo } from '../util';
type ResultBalance = [VestingInfo | null, (BalanceLock | BalanceLockTo212)[]];
type Result = [DeriveBalancesAccount, BlockNumber, ResultBalance];
const VESTING_ID = '0x76657374696e6720';
function calcBalances (api: ApiInterfaceRx, [{ accountId, accountNonce, freeBalance, frozenFee, frozenMisc, reservedBalance, votingBalance }, bestNumber, [vesting, locks]]: Result): DeriveBalancesAll {
let lockedBalance = api.registry.createType('Balance');
let lockedBreakdown: (BalanceLock | BalanceLockTo212)[] = [];
let vestingLocked = api.registry.createType('Balance');
let allLocked = false;
if (Array.isArray(locks)) {
// only get the locks that are valid until passed the current block
lockedBreakdown = (locks as BalanceLockTo212[]).filter(({ until }): boolean => !until || (bestNumber && until.gt(bestNumber)));
const notAll = lockedBreakdown.filter(({ amount }): boolean => !amount.isMax());
const notAll = lockedBreakdown.filter(({ amount }) => !amount.isMax());
allLocked = lockedBreakdown.some(({ amount }): boolean => amount.isMax());
allLocked = lockedBreakdown.some(({ amount }) => amount.isMax());
vestingLocked = api.registry.createType('Balance', lockedBreakdown.filter(({ id }) => id.eq(VESTING_ID)).reduce((result: BN, { amount }) => result.iadd(amount), new BN(0)));
// get the maximum of the locks according to https://github.com/paritytech/substrate/blob/master/srml/balances/src/lib.rs#L699
if (notAll.length) {
@@ -41,19 +44,12 @@ function calcBalances (api: ApiInterfaceRx, [{ accountId, accountNonce, freeBala
// - perBlock is the unlock amount
const { locked: vestingTotal, perBlock, startingBlock } = vesting || api.registry.createType('VestingInfo');
const isStarted = bestNumber.gt(startingBlock);
const vestedBalance = api.registry.createType('Balance', isStarted ? perBlock.mul(bestNumber.sub(startingBlock)) : 0);
const isVesting = isStarted && vestedBalance.lt(vestingTotal);
// The available balance & vested has an interplay here
// "
// vesting is a guarantee that the account's balance will never go below a certain amount. so it functions in the opposite way, a bit like a lock that is monotonically decreasing rather than a liquid amount that is monotonically increasing.
// locks function as the same guarantee - that a balance will not be lower than a particular amount.
// because of this you can see that if there is a "vesting lock" that guarantees the balance cannot go below 200, and a "staking lock" that guarantees the balance cannot drop below 300, then we just have two guarantees of which the first is irrelevant.
// i.e. (balance >= 200 && balance >= 300) == (balance >= 300)
// ""
const floating = freeBalance.sub(lockedBalance);
const extraReceived = isVesting ? freeBalance.sub(vestingTotal) : new BN(0);
const availableBalance = api.registry.createType('Balance', allLocked ? 0 : bnMax(new BN(0), isVesting && floating.gt(vestedBalance) ? vestedBalance.add(extraReceived) : floating));
const vestedNow = isStarted ? perBlock.mul(bestNumber.sub(startingBlock)) : new BN(0);
const vestedBalance = vestedNow.gt(vestingTotal) ? vestingTotal : api.registry.createType('Balance', vestedNow);
const isVesting = isStarted && !vestingLocked.isZero();
const vestedClaimable = api.registry.createType('Balance', isVesting ? vestingLocked.sub(vestingTotal.sub(vestedBalance)) : 0);
const availableBalance = api.registry.createType('Balance', allLocked ? 0 : bnMax(new BN(0), freeBalance.sub(lockedBalance)));
const vestingEndBlock = api.registry.createType('BlockNumber', isVesting ? vestingTotal.div(perBlock).add(startingBlock) : 0);
return {
accountId,
@@ -67,6 +63,10 @@ function calcBalances (api: ApiInterfaceRx, [{ accountId, accountNonce, freeBala
lockedBreakdown,
reservedBalance,
vestedBalance,
vestedClaimable,
vestingEndBlock,
vestingLocked,
vestingPerBlock: perBlock,
vestingTotal,
votingBalance
};
@@ -127,15 +127,15 @@ 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
? combineLatest([
of(account),
api.derive.chain.bestNumber(),
isFunction(api.query.balances.account)
isFunction(api.query.system.account) || isFunction(api.query.balances.account)
? queryCurrent(api, account.accountId)
: queryOld(api, account.accountId)
])
+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()
)
));
}
+4 -5
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';
@@ -11,7 +10,7 @@ import { HeaderExtended } from '../type';
import { memo } from '../util';
/**
* @name bestNumberFinalized
* @name getHeader
* @param {( Uint8Array | string )} hash - A block hash as U8 array or string.
* @returns An array containing the block header and the block author
* @description Get a specific block header and extend it with the author
@@ -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> =>
+12 -11
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';
@@ -11,23 +10,24 @@ import { map } from 'rxjs/operators';
import { memo } from '../util';
type ResultV2 = [BN, BN, BN, BN, BN, BN, BN, BN, BN];
type ResultV2 = [BN, BN, BN, BN, BN, BN, BN, BN, BN, BN];
// query via constants (current applicable path)
function queryConstants (api: ApiInterfaceRx): Observable<ResultV2> {
return of([
// deprecated
api.consts.contracts.callBaseFee || api.registry.createType('Balance'),
api.consts.contracts.contractFee || api.registry.createType('Balance'),
api.consts.contracts.creationFee || api.registry.createType('Balance'),
api.consts.contracts.transactionBaseFee || api.registry.createType('Balance'),
api.consts.contracts.transactionByteFee || api.registry.createType('Balance'),
api.consts.contracts.transferFee || api.registry.createType('Balance'),
// current
api.consts.contracts.callBaseFee,
api.consts.contracts.contractFee,
api.consts.contracts.rentByteFee,
api.consts.contracts.rentDepositOffset,
api.consts.contracts.tombstoneDeposit,
api.consts.contracts.transactionBaseFee,
api.consts.contracts.transactionByteFee
api.consts.contracts.surchargeReward,
api.consts.contracts.tombstoneDeposit
]) as unknown as Observable<ResultV2>;
}
@@ -44,15 +44,16 @@ 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(([creationFee, transferFee, callBaseFee, contractFee, rentByteFee, rentDepositOffset, tombstoneDeposit, transactionBaseFee, transactionByteFee]): DeriveContractFees => ({
map(([callBaseFee, contractFee, creationFee, transactionBaseFee, transactionByteFee, transferFee, rentByteFee, rentDepositOffset, surchargeReward, tombstoneDeposit]): DeriveContractFees => ({
callBaseFee,
contractFee,
creationFee,
rentByteFee,
rentDepositOffset,
surchargeReward,
tombstoneDeposit,
transactionBaseFee,
transactionByteFee,
+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';
+11 -28
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';
@@ -14,35 +13,19 @@ import { Vec } from '@polkadot/types';
import { memo } from '../util';
function retrieveStakeOf (api: ApiInterfaceRx): Observable<[AccountId, Balance][]> {
const elections = (api.query.electionsPhragmen || api.query.elections);
return elections.stakeOf.creator.meta.type.asMap.linked.isTrue
? elections.stakeOf<ITuple<[Vec<AccountId>, Vec<Balance>]>>().pipe(
map(([voters, stake]) =>
voters.map((voter, index): [AccountId, Balance] => [voter, stake[index]])
)
return (api.query.electionsPhragmen || api.query.elections).stakeOf.entries<Balance>().pipe(
map((entries) =>
entries.map(([key, stake]) => [key.args[0] as AccountId, stake])
)
: elections.stakeOf.entries<Balance>().pipe(
map((entries) =>
entries.map(([key, stake]) => [key.args[0] as AccountId, stake])
)
);
);
}
function retrieveVoteOf (api: ApiInterfaceRx): Observable<[AccountId, AccountId[]][]> {
const elections = (api.query.electionsPhragmen || api.query.elections);
return elections.votesOf.creator.meta.type.asMap.linked.isTrue
? elections.votesOf<ITuple<[Vec<AccountId>, Vec<Vec<AccountId>>]>>().pipe(
map(([voters, votes]) =>
voters.map((voter, index) => [voter, votes[index]])
)
return (api.query.electionsPhragmen || api.query.elections).votesOf.entries<Vec<AccountId>>().pipe(
map((entries) =>
entries.map(([key, votes]) => [key.args[0] as AccountId, votes])
)
: elections.votesOf.entries<Vec<AccountId>>().pipe(
map((entries) =>
entries.map(([key, votes]) => [key.args[0] as AccountId, votes])
)
);
);
}
function retrievePrev (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
@@ -81,8 +64,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';
+36 -12
View File
@@ -1,8 +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
import { AccountId, ReferendumInfo, ReferendumInfoTo239, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces';
import { AccountId, ReferendumInfo, ReferendumInfoTo239, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { DeriveDemocracyLock } from '../types';
@@ -20,16 +19,37 @@ const ZERO = new BN(0);
function parseLock (api: ApiInterfaceRx, [referendumId, accountVote]: VotingDirectVote, referendum: ReferendumInfo): DeriveDemocracyLock {
const { balance, vote } = accountVote.asStandard;
let unlockAt = ZERO;
let referendumEnd = ZERO;
if (referendum.isFinished) {
const { approved, end } = referendum.asFinished;
referendumEnd = end;
if ((approved.isTrue && vote.isAye) || (approved.isFalse && vote.isNay)) {
unlockAt = end.add(api.consts.democracy.enactmentPeriod.muln(LOCKUPS[vote.conviction.index]));
}
}
return { balance, isFinished: referendum.isFinished, referendumId, unlockAt, vote };
return { balance, isDelegated: false, isFinished: referendum.isFinished, referendumEnd, referendumId, unlockAt, vote };
}
function delegateLocks (api: ApiInterfaceRx, { balance, conviction, target }: VotingDelegating): Observable<DeriveDemocracyLock[]> {
return api.derive.democracy.locks(target).pipe(
map((available): DeriveDemocracyLock[] =>
available.map(({ isFinished, referendumEnd, referendumId, unlockAt, vote }): DeriveDemocracyLock => ({
balance,
isDelegated: true,
isFinished,
referendumEnd,
referendumId,
unlockAt: unlockAt.isZero()
? unlockAt
: referendumEnd.add(api.consts.democracy.enactmentPeriod.muln(LOCKUPS[conviction.index])),
vote: api.registry.createType('Vote', { aye: vote.isAye, conviction })
}))
)
);
}
function directLocks (api: ApiInterfaceRx, { votes }: VotingDirect): Observable<DeriveDemocracyLock[]> {
@@ -53,14 +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)
: 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)
+10 -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';
@@ -9,19 +8,14 @@ import { Vec } from '@polkadot/types';
export interface DeriveDemocracyLock {
balance: Balance;
isDelegated: boolean;
isFinished: boolean;
referendumEnd: BN;
referendumId: ReferendumIndex;
unlockAt: BN;
vote: Vote;
}
export interface DeriveDispatch {
at: BlockNumber;
index: ReferendumIndex;
imageHash: Hash;
image?: DeriveProposalImage;
}
export interface DeriveProposalImage {
at: BlockNumber;
balance: Balance;
@@ -29,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;
+4 -5
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';
@@ -82,15 +81,15 @@ function calcVotesPrev (votesFor: DeriveReferendumVote[]): DeriveReferendumVoteS
if (vote.isAye) {
state.allAye.push(derived);
state.voteCountAye++;
state.votedAye = state.votedAye.add(counted);
state.votedAye.iadd(counted);
} else {
state.allNay.push(derived);
state.voteCountNay++;
state.votedNay = state.votedNay.add(counted);
state.votedNay.iadd(counted);
}
state.voteCount++;
state.votedTotal = state.votedTotal.add(counted);
state.votedTotal.iadd(counted);
return state;
}, {
+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';
+5 -5
View File
@@ -1,16 +1,15 @@
// 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';
import { DeriveElectionsInfo } from './types';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Vec, u32 } from '@polkadot/types';
import { DeriveElectionsInfo } from '../types';
import { memo } from '../util';
function sortAccounts ([, balanceA]: ITuple<[AccountId, Balance]>, [, balanceB]: ITuple<[AccountId, Balance]>): number {
@@ -30,6 +29,7 @@ function queryElections (api: ApiInterfaceRx): Observable<DeriveElectionsInfo> {
candidacyBond: api.consts[section].candidacyBond as Balance,
candidateCount: api.registry.createType('u32', candidates.length),
candidates,
desiredRunnersUp: api.consts[section].desiredRunnersUp as u32,
desiredSeats: api.consts[section].desiredMembers as u32,
members: members.length
? members.sort(sortAccounts)
@@ -54,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));
}

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