Compare commits

..
600 Commits
Author SHA1 Message Date
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
Github Actions 69d344c6c3 [CI Skip] release/stable 1.17.2
skip-checks: true
2020-06-02 15:26:46 +00:00
Jaco Greeff 44cdf49b2c Resolve first result after unsub promise (via setImmediate) (#2324) 2020-06-02 17:14:29 +02:00
Github Actions daaf4654a1 [CI Skip] release/stable 1.17.1
skip-checks: true
2020-06-02 12:26:21 +00:00
Jaco Greeff f8d4fcaf04 1.17 (#2323) 2020-06-02 14:15:27 +02:00
Github Actions eb19a39d82 [CI Skip] release/beta 1.17.0-beta.8
skip-checks: true
2020-06-02 10:50:47 +00:00
Jaco Greeff 7ed958fb2d Metadata bump (#2322)
* Metadata bump

* yarn.lock

* var requires
2020-06-02 12:39:48 +02:00
Github Actions bbe9b94f26 [CI Skip] release/beta 1.17.0-beta.7
skip-checks: true
2020-06-02 09:17:06 +00:00
Jaco Greeff 6e83e6aaef Adjust call-only metadata output (#2321) 2020-06-02 11:03:34 +02:00
Github Actions 1545bbf7c5 [CI Skip] release/beta 1.17.0-beta.6
skip-checks: true
2020-05-31 11:18:45 +00:00
Jaco Greeff 5bfc2cd534 Protect against div-by-zero (#2319)
* Protect against div-by-zero

* Rewrite
2020-05-31 13:07:42 +02:00
Github Actions b22d0a196f [CI Skip] 1.17.0-beta.5
skip-checks: true
2020-05-28 11:23:47 +00:00
Jaco Greeff b174864804 Adjust own cache key (per accountId) (#2317) 2020-05-28 13:12:27 +02:00
Github Actions e6834d60c5 [CI Skip] 1.17.0-beta.4
skip-checks: true
2020-05-28 10:54:39 +00:00
Jaco Greeff 97438bb2e8 Small combineLatest -> queryMulti opts (#2316)
* Small combineLatest -> queryMulti opts

* Update packages/api-derive/src/staking/ownSlashes.ts
2020-05-28 12:43:02 +02:00
Github Actions f630d43a25 [CI Skip] 1.17.0-beta.3
skip-checks: true
2020-05-28 10:19:44 +00:00
Jaco Greeff 0187f1ff19 Extend deriveCache around ownExposure/ownSlash (#2315) 2020-05-28 12:07:02 +02:00
Github Actions d8db866316 [CI Skip] 1.17.0-beta.2
skip-checks: true
2020-05-28 09:55:46 +00:00
Jaco Greeff 28aa9e18a7 Bump deps (#2314) 2020-05-28 11:43:45 +02:00
Github Actions 3eaea97b8f [CI Skip] 1.17.0-beta.1
skip-checks: true
2020-05-28 08:55:06 +00:00
Jaco Greeff ea0e5e4547 BTreeSet decoding from Array (#2313) 2020-05-28 10:42:46 +02:00
Github Actions 1256317b65 [CI Skip] 1.17.0-beta.0
skip-checks: true
2020-05-27 17:42:13 +00:00
Jaco Greeff e0c3ed1b96 Fix ElectionSize type (#2312) 2020-05-27 19:29:13 +02:00
Github Actions 9f2c3016d7 [CI Skip] 1.16.1
skip-checks: true
2020-05-26 15:03:50 +00:00
Jaco Greeff 938ace2342 1.16 (#2310) 2020-05-26 16:51:10 +02:00
Github Actions e5d2607dff [CI Skip] 1.16.0-beta.6
skip-checks: true
2020-05-26 12:58:13 +00:00
Jaco Greeff 50b8db2263 Update with new Babe digests (#2309)
* Update with new Babe digests

* Naming cleanups
2020-05-26 14:46:06 +02:00
Github Actions 91766a6885 [CI Skip] 1.16.0-beta.5
skip-checks: true
2020-05-26 12:02:14 +00:00
Jaco Greeff 4b1a9ab9e1 Perbill/Permill toHuman as percentage (#2307)
* Perbill/Permill toHuman as percentage

* Expectation to percentage
2020-05-26 13:51:05 +02:00
Github Actions 9a14c65336 [CI Skip] 1.16.0-beta.4
skip-checks: true
2020-05-26 07:30:37 +00:00
Jaco Greeff 4aa66fd4c6 Adjust Polkadot spec version/types (#2306)
* Adjust Polkadot spec version/types

* CHANGELOG
2020-05-26 09:20:15 +02:00
Github Actions 3d9c62d538 [CI Skip] 1.16.0-beta.3
skip-checks: true
2020-05-25 06:31:48 +00:00
Jaco Greeff 4156eb44ab Bump metadata (#2305)
* Bump metadata

* Rewrite yarn.lock
2020-05-25 08:20:45 +02:00
Github Actions 4b2d33693c [CI Skip] 1.16.0-beta.2
skip-checks: true
2020-05-24 16:49:59 +00:00
Jaco Greeff e8b127e177 Adjust sign options (#2304) 2020-05-24 18:40:39 +02:00
Github Actions b052b03f31 [CI Skip] 1.16.0-beta.1
skip-checks: true
2020-05-24 14:41:32 +00:00
Amaury Martiny 6727e12468 StatementKind: Regular and Saft (#2303) 2020-05-24 16:30:12 +02:00
Github Actions c130285651 [CI Skip] 1.16.0-beta.0
skip-checks: true
2020-05-24 07:36:17 +00:00
Jaco Greeff 47fc4a2b3c Bump deps w/ eslint (#2302)
* Bump deps w/ eslint

* Additional cleanups

* Additional

* @polkadot/types done

* Additional

* @polkadot/typegen done

* Additional

* @polkadot/rpc-core done

* Additional

* Additional

* Additional

* docs

* @polkadot/api-derive done

* @polkadot/api done

* @polkadot/api-contracts done

* Update tests
2020-05-24 09:24:45 +02:00
Github Actions 97cb408f36 [CI Skip] 1.15.1
skip-checks: true
2020-05-23 09:35:31 +00:00
Jaco Greeff dde7c8085a 1.15 (#2301) 2020-05-23 11:26:05 +02:00
Github Actions 8b02fafb99 [CI Skip] 1.15.0-beta.9
skip-checks: true
2020-05-23 09:05:12 +00:00
Jaco Greeff 393f46ba4a Bump metadata (#2300) 2020-05-23 10:54:28 +02:00
455f5ad834 Allow keyPrefix to accept an additional argument for double maps (#2230)
* Allow keyPrefix to accept an additional argument for double maps

* Make key creators accept an optional parameter for key construction

* Remove .only from a test case

Co-authored-by: Xiliang Chen <xlchen1291@gmail.com>

* Cache prefix key when no arguments are supplied

* Address review comments

* Update packages/metadata/src/Decorated/storage/fromMetadata/createFunction.spec.ts

Co-authored-by: Xiliang Chen <xlchen1291@gmail.com>
Co-authored-by: Jaco Greeff <jacogr@gmail.com>
2020-05-23 10:51:38 +02:00
Github Actions 674324e7f9 [CI Skip] 1.15.0-beta.8
skip-checks: true
2020-05-21 09:08:13 +00:00
Jaco Greeff b0dc7cf451 Bump metadata (#2297)
* Bump metadata

* Deps

* Regen

* Update sig for new signed extensions
2020-05-21 10:56:56 +02:00
Github Actions cbe1b2b1ce [CI Skip] 1.15.0-beta.7
skip-checks: true
2020-05-20 22:08:39 +00:00
Dan Forbes 4bd2f2fc32 Add WeightToFeeCoefficient type (#2296)
Added to support paritytech/substrate#6076
2020-05-20 23:56:04 +02:00
Github Actions 053112470d [CI Skip] 1.15.0-beta.6
skip-checks: true
2020-05-19 14:38:35 +00:00
Joshy Orndorff acdf27a272 spelling; efect -> effect (#2295) 2020-05-19 16:15:58 +02:00
Github Actions f70b32ba76 [CI Skip] 1.15.0-beta.5
skip-checks: true
2020-05-19 08:41:46 +00:00
Jaco Greeff 67a3376ef8 POC for a rough derive cache (#2293)
* POC for a rough derive cache

* With expiry

* Cache cleanups

* Memory cache

* Small cleanups
2020-05-19 10:29:40 +02:00
Github Actions eb06bb6e93 [CI Skip] 1.15.0-beta.4
skip-checks: true
2020-05-19 05:42:16 +00:00
Paweł Nguyen f8f7e92da4 Fix a minor typo in cookbook blocks docs (#2294) 2020-05-19 07:29:27 +02:00
Github Actions d0fd3eca25 [CI Skip] 1.15.0-beta.3
skip-checks: true
2020-05-18 08:32:29 +00:00
Jaco Greeff dac1df35de stakerRewards filters, re-org (#2292) 2020-05-18 10:20:09 +02:00
Github Actions 597563d2bb [CI Skip] 1.15.0-beta.2
skip-checks: true
2020-05-16 12:04:58 +00:00
Jaco Greeff f825c7f187 Fixed128 -> Fixed64 in old versions 2020-05-16 13:54:36 +02:00
Jaco Greeff 2e71a6160e Multiplier -> Fixed128 (#2290) 2020-05-16 13:52:56 +02:00
Github Actions c076c37119 [CI Skip] 1.15.0-beta.1
skip-checks: true
2020-05-16 06:49:21 +00:00
Amaury Martiny 0e18fdbccc Add transactionVersion to ExtrinsicPayload (#2287) 2020-05-16 08:37:29 +02:00
Github Actions c3eebd8fbe [CI Skip] 1.15.0-beta.0
skip-checks: true
2020-05-15 11:46:27 +00:00
Jaco Greeff 45786b31da Bump deps (#2286)
* Bump deps

* Linting cleanups
2020-05-15 13:35:15 +02:00
Github Actions f348e34de7 [CI Skip] 1.14.1
skip-checks: true
2020-05-14 14:02:15 +00:00
Jaco Greeff 337de79bef 1.14 (#2281) 2020-05-14 15:51:48 +02:00
Github Actions a13b51b985 [CI Skip] 1.14.0-beta.20
skip-checks: true
2020-05-14 06:17:01 +00:00
Jaco Greeff c5c77c9b52 Bump deps (#2280) 2020-05-14 08:05:15 +02:00
Drew StoneandJaco Greeff 2a033e5634 Update evm definitions to include vicinity (#2279)
* Update definitions.ts

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

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
2020-05-14 07:51:29 +02:00
Github Actions 00ffb358cb [CI Skip] 1.14.0-beta.19
skip-checks: true
2020-05-13 16:07:57 +00:00
Jaco Greeff 66d1bbe4cb Don't re-calculate extinsic hash (status updates) (#2277) 2020-05-13 17:56:26 +02:00
Github Actions 3baf36e9e6 [CI Skip] 1.14.0-beta.18
skip-checks: true
2020-05-13 07:44:25 +00:00
Jaco Greeff e3abb95111 Bump metadata (#2276) 2020-05-13 09:32:26 +02:00
Github Actions da281c9531 [CI Skip] 1.14.0-beta.17
skip-checks: true
2020-05-13 06:59:03 +00:00
Jaco Greeff c0e3026772 Add signedExtensions to SignerPayload (#2275) 2020-05-13 08:49:31 +02:00
Github Actions 757da68675 [CI Skip] 1.14.0-beta.16
skip-checks: true
2020-05-12 21:27:47 +00:00
Jaco Greeff f145488314 Add StatementKind & PrevalidateAttests for Polkadot claims (#2273)
* Add StatementKind for Polkadot claims

* PrevalidateAttests extension
2020-05-12 23:14:32 +02:00
Github Actions 0ce10d2938 [CI Skip] 1.14.0-beta.15
skip-checks: true
2020-05-12 20:58:34 +00:00
Jaco Greeff 6f2d62bb3b Cater for old/new style DepositOf tuples (#2272)
* Cater for old/new style DepositOf tuples

* Remove unused api on parse
2020-05-12 22:45:53 +02:00
Github Actions fc7c8310ae [CI Skip] 1.14.0-beta.14
skip-checks: true
2020-05-12 20:16:47 +00:00
Jaco Greeff c9921f002f Cater for Check{Spec, Tx}Version extensions (#2270)
* Cater for Check{Spec, Tx}Version extensions

* Fix tests
2020-05-12 22:03:20 +02:00
Github Actions 6b8a65eb31 [CI Skip] 1.14.0-beta.13
skip-checks: true
2020-05-12 19:09:51 +00:00
Jaco Greeff 0cf29719b3 Fix ProxyState type (#2269)
* Fix ProxyState type

* Generate
2020-05-12 20:58:40 +02:00
Github Actions abecabdaed [CI Skip] 1.14.0-beta.12
skip-checks: true
2020-05-12 18:31:46 +00:00
Jaco Greeff 0c5b69bea1 Extra signedExtensions retrieved via specVersion (#2268)
* Extra signedExtensions retrieved via  specVersion

* Fix tests
2020-05-12 20:20:24 +02:00
Github Actions 7b3f24b1f5 [CI Skip] 1.14.0-beta.11
skip-checks: true
2020-05-12 16:43:19 +00:00
Jaco Greeff d1f8f8b5e8 Extend SignerPayload with extra tx/extensions (#2267)
* Extend SignerPayload with extra tx/extensions

* Update registry.ts

* Update extrinsic.ts

* Linting options
2020-05-12 18:32:18 +02:00
Github Actions 3f060b9e0d [CI Skip] 1.14.0-beta.10
skip-checks: true
2020-05-12 15:00:09 +00:00
Jaco Greeff fe69f70539 DispatchInfo paysFee to Pays enum (#2266)
* DispatchInfo paysFee to Pays enum

* Update Kusama types
2020-05-12 16:46:07 +02:00
Github Actions 578c4ffb69 [CI Skip] 1.14.0-beta.9
skip-checks: true
2020-05-12 09:56:51 +00:00
Jaco Greeff 66aa38000b Derive for democracy locks (#2264)
* Derive for democracy locks

* Cater for old referendums

* Split lock parsing
2020-05-12 11:44:54 +02:00
Github Actions 50ddff6907 [CI Skip] 1.14.0-beta.8
skip-checks: true
2020-05-11 16:16:49 +00:00
Paweł Nguyen 14874f41f7 Fix a typo in Query docs - freee -> free (#2263)
This fixes a typo in Query Subscriptions with params docs. `freee` -> `free`
2020-05-11 18:05:43 +02:00
Github Actions 5a11b0c701 [CI Skip] 1.14.0-beta.7
skip-checks: true
2020-05-11 12:56:11 +00:00
Jaco Greeff 8491ab8ca6 import type BN (as applicable) (#2262) 2020-05-11 14:45:14 +02:00
Github Actions 4f5cb0f35e [CI Skip] 1.14.0-beta.6
skip-checks: true
2020-05-11 10:14:17 +00:00
Jaco Greeff 53d081df65 Bump berry (#2261) 2020-05-11 12:02:05 +02:00
Github Actions 6b5dbb6948 [CI Skip] 1.14.0-beta.5
skip-checks: true
2020-05-11 08:29:29 +00:00
Jaco Greeff 3879986a75 Bump common (#2260) 2020-05-11 10:20:21 +02:00
Github Actions 378ca10580 [CI Skip] 1.14.0-beta.4
skip-checks: true
2020-05-11 07:05:13 +00:00
Jaco Greeff d75d8bec0e Additional mortal era tests (#2259)
* Additional moratl era tests

* birth !== current (output the same)
2020-05-11 08:53:05 +02:00
Github Actions 6f6a32a7a2 [CI Skip] 1.14.0-beta.3
skip-checks: true
2020-05-08 09:59:57 +00:00
Jaco Greeff 226426e67e Add older heartbeats struct (#2255) 2020-05-08 11:50:18 +02:00
Github Actions 66e2a4d298 [CI Skip] 1.14.0-beta.2
skip-checks: true
2020-05-08 08:41:41 +00:00
Arjan Zijderveld 664151f829 Added validatorsLen to Heartbeat struct (#2254) 2020-05-08 10:31:04 +02:00
Github Actions 49b00524b1 [CI Skip] 1.14.0-beta.1
skip-checks: true
2020-05-07 07:17:07 +00:00
Jaco Greeff 401784b7e6 Historic queries FAQ (#2253) 2020-05-07 09:05:51 +02:00
Github Actions 99873e901a [CI Skip] 1.14.0-beta.0
skip-checks: true
2020-05-07 07:02:00 +00:00
Jaco Greeff 72d131f62f Ensure metadata is only retrieved once on startup (#2252)
* Ensure metadata is only retrieved once on startup

* Ensure we set rx.runtimeVersion
2020-05-07 08:50:36 +02:00
Github Actions c412f7fa11 [CI Skip] 1.13.1
skip-checks: true
2020-05-06 18:33:13 +00:00
Jaco Greeff a1ad90c2b4 1.13 (#2248)
* 1.13

* Add grandpa_roundState RPC

* RPC interfaces
2020-05-06 20:22:18 +02:00
Github Actions 92f62bfa15 [CI Skip] 1.13.0-beta.19
skip-checks: true
2020-05-06 16:48:28 +00:00
Jaco Greeff fa9c5778be Adjust Centrifuge versions (#2247) 2020-05-06 18:37:44 +02:00
Github Actions e6f877621a [CI Skip] 1.13.0-beta.18
skip-checks: true
2020-05-06 15:22:36 +00:00
Jaco Greeff 5c35a70e9d Centrifuge Chain Node (#2246) 2020-05-06 17:11:33 +02:00
Github Actions a287096cc3 [CI Skip] 1.13.0-beta.17
skip-checks: true
2020-05-06 13:47:59 +00:00
Jaco Greeff c35f31bfbd Adjust mock timeouts (#2244)
* Adjust mock timeouts

* Play with timeouts some more...

* Ooops, overzealous search-and-replace
2020-05-06 15:36:20 +02:00
Jaco Greeff 718afa91e3 Multiple endpoints CHANGELOG (#2243) 2020-05-06 15:10:37 +02:00
Hoani BrysonandJaco Greeff 102a06b0f2 Multiple Endpoint support for WsProvider (#2234)
* Fix incorrect ws connect test cases

* Make endpoint an array of endpoints

* Add requirement that WsProvider endpoint arrays must not be empty

* Simple endpoint increment

* Add multi-endpoint test for endpoint closing its connection

* Implement endpoint round robin

* Revert change to mock's TEST_WS_URL

* Address Lint errors

* Change endpoint variable to plural in WsProvider

Co-authored-by: Jaco Greeff <jacogr@gmail.com>

* Review corrections to WsProvider

* Grouping improvement in WsProvider connect

* Correct endpoint logging to only show the specific endpoint involved

* Correct ordering of endpoint increment on connect

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
2020-05-06 14:42:30 +02:00
Github Actions 58f0df1ef0 [CI Skip] 1.13.0-beta.16
skip-checks: true
2020-05-06 12:08:40 +00:00
Jaco Greeff a458589222 Fix CompactAssignment decoding (#2242)
* Fix CompactAssignment decoding

* CHANGELOG
2020-05-06 13:56:17 +02:00
Github Actions deef4ce4c7 [CI Skip] 1.13.0-beta.15
skip-checks: true
2020-05-06 08:36:29 +00:00
Jaco Greeff f5d2449407 Grandpa Equivocation types (#2239)
* Grandpa Equivocation types

* typo
2020-05-06 10:25:37 +02:00
Github Actions 8bb1d1259e [CI Skip] 1.13.0-beta.14
skip-checks: true
2020-05-06 08:23:10 +00:00
Jaco Greeff abd860d548 Bump deps (#2240)
* Bump deps

* Jest revert
2020-05-06 10:11:58 +02:00
Github Actions 25936d882f [CI Skip] 1.13.0-beta.13
skip-checks: true
2020-05-06 06:29:54 +00:00
Keith YeungandJaco Greeff 9deaff54e4 Make the 2nd argument to SubmittableExtrinsic.sign/signAsync optional (#2238)
* Make the 2nd argument to SubmittableExtrinsic.sign/signAsync optional

* Use default argument for optionsOrNonce

Co-authored-by: Jaco Greeff <jacogr@gmail.com>

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
2020-05-06 08:17:51 +02:00
Github Actions bc479a995b [CI Skip] 1.13.0-beta.12
skip-checks: true
2020-05-05 09:44:03 +00:00
Jaco Greeff 458b7fa7e4 Update with latest Substrate metadata (#2233) 2020-05-05 11:33:04 +02:00
Github Actions 2fc17a66e1 [CI Skip] 1.13.0-beta.11
skip-checks: true
2020-05-05 05:26:31 +00:00
codingsh 94f81db568 #2182 - add: search for docs (#2232) 2020-05-05 07:16:39 +02:00
Github Actions e83d97c849 [CI Skip] 1.13.0-beta.10
skip-checks: true
2020-05-05 05:09:33 +00:00
Joshy Orndorff 4a497fa970 minor typo: RC -> RPC (#2229) 2020-05-05 06:58:52 +02:00
Github Actions cb40d459b5 [CI Skip] 1.13.0-beta.9
skip-checks: true
2020-05-04 18:40:00 +00:00
Jaco Greeff c70cdb351f Additional modules/methods in RPC samples 2020-05-04 20:29:02 +02:00
Github Actions 001aa0d011 [CI Skip] 1.13.0-beta.8
skip-checks: true
2020-05-04 15:58:01 +00:00
Jaco Greeff 961d27ad46 Update CHANGELOG.md 2020-05-04 17:47:09 +02:00
Github Actions 1c09bb69dd [CI Skip] 1.13.0-beta.7
skip-checks: true
2020-05-04 13:32:30 +00:00
Xiliang ChenandJaco Greeff 174510a928 use handlebars for code generation (#2228)
* use handlebars for code generation

* update docs

* fix isStrict

* fix lint

* Apply suggestions from code review

Co-authored-by: Jaco Greeff <jacogr@gmail.com>

* convert consts

* keep empty lines in doc comments

* update rpc

* update tx

* update interfaceRegistry

* update tsDef

* remove no longer used code

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
2020-05-04 15:21:09 +02:00
Github Actions 39ed76f2de [CI Skip] 1.13.0-beta.6
skip-checks: true
2020-05-04 12:20:51 +00:00
Jaco Greeff 7d1c93db59 Update CHANGELOG.md 2020-05-04 14:08:18 +02:00
Github Actions e9b1b4ee77 [CI Skip] 1.13.0-beta.5
skip-checks: true
2020-05-01 19:11:49 +00:00
Jaco Greeff 2367978f6e Remove polkadot metadata (not mainatained, outdated) (#2227) 2020-05-01 21:01:08 +02:00
Github Actions e77050b9f5 [CI Skip] 1.13.0-beta.4
skip-checks: true
2020-04-30 13:24:43 +00:00
Jaco Greeff 844d1a2928 Allow failures on preimage (instead of swallow) (#2225) 2020-04-30 15:14:56 +02:00
Github Actions 6a70beda0f [CI Skip] 1.13.0-beta.3
skip-checks: true
2020-04-30 09:16:39 +00:00
Alexander Krupenkin 05a834b822 Fix extrinsic ECDSA signatures (#2222)
* Fix extrinsic ECDSA signatures

* Fix lint
2020-04-30 11:04:55 +02:00
Github Actions 6a3af506a4 [CI Skip] 1.13.0-beta.2
skip-checks: true
2020-04-30 07:37:46 +00:00
Jaco Greeff c82b85ef79 Bump deps (#2224) 2020-04-30 09:27:04 +02:00
Github Actions 91ab81ef60 [CI Skip] 1.13.0-beta.1
skip-checks: true
2020-04-30 05:47:17 +00:00
Jaco Greeff 3665690444 Beta bump (#2223) 2020-04-30 07:37:12 +02:00
Github Actions 03dcefceb5 [CI Skip] 1.12.2
skip-checks: true
2020-04-29 22:56:16 +00:00
Jaco Greeff e84be032f4 1.12.2 (stable util) 2020-04-30 00:46:45 +02:00
Github Actions 033ff7a28c [CI Skip] 1.12.1
skip-checks: true
2020-04-29 22:23:45 +00:00
Jaco Greeff 7c8b2abf92 1.12 (#2221) 2020-04-30 00:13:27 +02:00
Github Actions 5312ec1f3a [CI Skip] 1.12.0-beta.15
skip-checks: true
2020-04-29 16:13:00 +00:00
Matej Nemček cdfbf91ee6 added Kodadot to @polkadot/api users section (#2220) 2020-04-29 18:00:50 +02:00
Github Actions 14f2abdc37 [CI Skip] 1.12.0-beta.14
skip-checks: true
2020-04-29 15:50:05 +00:00
Jake Naviasky 04c8d49e9d Add configurable provider auto-reconnect time. (#2215) 2020-04-29 17:39:31 +02:00
Github Actions 722929d0d4 [CI Skip] 1.12.0-beta.13
skip-checks: true
2020-04-29 14:57:15 +00:00
Jaco Greeff d1fae523ac Fix CompactAssignments types (#2219)
* Fix CompactAssignments types

* Cleanup mistaken type adjustments
2020-04-29 16:45:59 +02:00
Github Actions ce9a92cdc0 [CI Skip] 1.12.0-beta.12
skip-checks: true
2020-04-27 17:09:59 +00:00
Jaco Greeff 3de09a2e27 Hack around preimage failures (#2217) 2020-04-27 18:59:18 +02:00
Github Actions f28479180f [CI Skip] 1.12.0-beta.11
skip-checks: true
2020-04-27 14:04:29 +00:00
Jaco Greeff 0d1d42f6c2 Update promise combineLatest with generics (#2214) 2020-04-27 15:53:17 +02:00
Github Actions c93dad0bc5 [CI Skip] 1.12.0-beta.10
skip-checks: true
2020-04-27 07:04:47 +00:00
Jaco Greeff e3d3a1ff71 Handle no keysReturn StorageChangeSet with no keys (#2212) 2020-04-27 08:54:02 +02:00
Github Actions 1c8bd896e1 [CI Skip] 1.12.0-beta.9
skip-checks: true
2020-04-26 11:56:32 +00:00
Jaco Greeff e0119c1873 Bump metadata to current Substrate master (incl. types) (#2210) 2020-04-26 13:46:36 +02:00
Github Actions defe81e560 [CI Skip] 1.12.0-beta.8
skip-checks: true
2020-04-26 11:42:47 +00:00
Xiliang Chen 932122cd21 subscribeStorage parameter should be optional (#2208) 2020-04-26 13:32:43 +02:00
Github Actions 40d035eca7 [CI Skip] 1.12.0-beta.7
skip-checks: true
2020-04-25 07:58:44 +00:00
Jaco Greeff a135abaea2 Fix flags (council may not exist) (#2207) 2020-04-25 09:47:46 +02:00
Github Actions 00b8c10881 [CI Skip] 1.12.0-beta.6
skip-checks: true
2020-04-24 14:34:08 +00:00
Jaco Greeff 11e7b90918 Bump deps (#2206) 2020-04-24 16:22:18 +02:00
Github Actions ae74467e6a [CI Skip] 1.12.0-beta.5
skip-checks: true
2020-04-24 13:40:02 +00:00
Jeremías Díaz 5a929d3810 remove unnecessary parentheses and duplicate types (#2204)
* remove unnecessary parentheses and duplicate types

* fix: remove test code
2020-04-24 15:28:47 +02:00
Github Actions 63732f1456 [CI Skip] 1.12.0-beta.4
skip-checks: true
2020-04-24 08:54:04 +00:00
Jaco Greeff ea6bb83c01 Voting delegations (#2205) 2020-04-24 10:41:30 +02:00
Github Actions d6a443ca2a [CI Skip] 1.12.0-beta.3
skip-checks: true
2020-04-23 09:50:46 +00:00
Jaco Greeff d983ee106c migrateEra is first stakerPayouts era (#2202) 2020-04-23 11:39:39 +02:00
Github Actions beed1df5bd [CI Skip] 1.12.0-beta.2
skip-checks: true
2020-04-22 09:04:55 +00:00
Jaco Greeff 426aef6088 Update .123trigger 2020-04-22 10:55:01 +02:00
Github Actions 9be9b3fb83 [CI Skip] 1.12.0-beta.1
skip-checks: true
2020-04-22 07:56:01 +00:00
Jaco Greeff 8676f30cbf Reset to beta 2020-04-22 09:44:59 +02:00
Github Actions 154561c34c [CI Skip] 1.11.2
skip-checks: true
2020-04-22 07:40:26 +00:00
Jaco Greeff 714b242ec0 0.11.2 (#2200) 2020-04-22 09:30:02 +02:00
Github Actions 32ce650ee1 [CI Skip] 1.12.0-beta.0
skip-checks: true
2020-04-21 17:05:00 +00:00
Jaco Greeff 3715df2f5b Additional parachains types (#2199)
* Additional parachains types

* missing extensions listing

* trigger
2020-04-21 18:53:00 +02:00
Github Actions dd6e6ddfc1 [CI Skip] 1.11.1
skip-checks: true
2020-04-21 07:47:25 +00:00
Jaco Greeff 9975f58cfb 1.11 (#2198)
* 1.11

* isOptional is custom RPC sample

* Names is one-liner for custom RPCs
2020-04-21 09:38:09 +02:00
Github Actions 536369261f [CI Skip] 1.11.0-beta.35
skip-checks: true
2020-04-21 07:10:16 +00:00
Jaco Greeff 33165e93dc Add state_getReadProof (#2196) 2020-04-21 09:00:03 +02:00
Github Actions 39a38a6c44 [CI Skip] 1.11.0-beta.34
skip-checks: true
2020-04-21 05:41:16 +00:00
Keith Ingram b18bdc37f9 Add api.derive.accounts.flags (#2195)
* account flags in new call

* Fix
2020-04-21 07:31:00 +02:00
Github Actions 79847aabf7 [CI Skip] 1.11.0-beta.33
skip-checks: true
2020-04-20 09:22:55 +00:00
Jaco Greeff ab75863d94 Fix derive.democracy.preimage signature (#2194) 2020-04-20 11:12:03 +02:00
Github Actions c908a27b7d [CI Skip] 1.11.0-beta.32
skip-checks: true
2020-04-18 07:31:19 +00:00
Jaco Greeff 98c7e5d5ea Optimize entries retrieval (#2193) 2020-04-18 09:21:06 +02:00
Github Actions fd4587a0bc [CI Skip] 1.11.0-beta.31
skip-checks: true
2020-04-17 13:41:21 +00:00
Jaco Greeff e211ae1667 Added types for DoubleVoteReport (parachains) (#2192) 2020-04-17 15:32:51 +02:00
Github Actions af735176fe [CI Skip] 1.11.0-beta.30
skip-checks: true
2020-04-17 10:34:48 +00:00
Jaco Greeff 9eb44d6e89 console warnings on the use of node-template (#2191)
* console warnings on the use of node-template

* Message formatting
2020-04-17 12:23:44 +02:00
Github Actions 379e841808 [CI Skip] 1.11.0-beta.29
skip-checks: true
2020-04-17 06:07:08 +00:00
Jaco Greeff 5c16b8e8a1 Adjust spec types (starting versions) (#2189) 2020-04-17 07:55:53 +02:00
Github Actions 96d7d9ff5a [CI Skip] 1.11.0-beta.28
skip-checks: true
2020-04-16 19:55:16 +00:00
Jaco Greeff e9fbbbbd42 Typos 2020-04-16 21:44:04 +02:00
Github Actions 73750ddb7d [CI Skip] 1.11.0-beta.27
skip-checks: true
2020-04-16 19:39:17 +00:00
Jaco Greeff 4e1145c66f FAQ entry for Weight adjustment (#2188)
* FAQ entry for Weight adjustment

* CHANGELOG entry for rxjs Observable exposure

* Event decoding
2020-04-16 21:29:22 +02:00
Github Actions 7f35fa22d5 [CI Skip] 1.11.0-beta.26
skip-checks: true
2020-04-16 17:14:23 +00:00
Jeremías Díaz da1daf5bd9 fix: ensure consistent Observable version (#2187) 2020-04-16 19:03:00 +02:00
Github Actions 5afc87ce47 [CI Skip] 1.11.0-beta.25
skip-checks: true
2020-04-16 16:21:36 +00:00
Jaco Greeff a2269cd999 Explain where args come from and their types (#2186)
* Explain where args come from and their types

* Update api.query.other.md
2020-04-16 18:11:12 +02:00
Github Actions 201308c259 [CI Skip] 1.11.0-beta.24
skip-checks: true
2020-04-16 14:32:15 +00:00
Jaco Greeff 00490116dd Add system_{localPeerId, localListenAddresses} RPCs (#2185)
* Add system_{localPeerId, localListenAddresses} RPCs

* CHANGELOG
2020-04-16 16:21:40 +02:00
Github Actions 1968c878f5 [CI Skip] 1.11.0-beta.23
skip-checks: true
2020-04-16 13:52:16 +00:00
Jaco Greeff 52ccb9fbbf Linkage fixes (#2184)
* Fix linkage decoding

* Actually fix linkage

* CHANGELOG
2020-04-16 15:41:42 +02:00
Github Actions 03e21ea64b [CI Skip] 1.11.0-beta.22
skip-checks: true
2020-04-16 13:39:19 +00:00
Jaco Greeff 8c949bb3df StorageKey toHuman returns decoded key (#2183) 2020-04-16 15:28:15 +02:00
Github Actions e484e7cf35 [CI Skip] 1.11.0-beta.21
skip-checks: true
2020-04-16 11:32:18 +00:00
Jaco Greeff 7aac4c7936 Add missing cookbook .keys 2020-04-16 13:21:04 +02:00
Github Actions 933c8d48e2 [CI Skip] 1.11.0-beta.20
skip-checks: true
2020-04-16 11:18:25 +00:00
Jaco Greeff d3d3bb9b5a Adjust Weight to u64 (#2181)
* Adjust Weight to u64

* Adjust copy (really should be reading folders...)

* build:interfaces

* EventRecord test expectation update
2020-04-16 13:08:46 +02:00
Github Actions f4d976c337 [CI Skip] 1.11.0-beta.19
skip-checks: true
2020-04-16 10:17:47 +00:00
Jaco Greeff 07c4037fcf On subscriptions, ensure rx.runtimeVersion is set (#2180) 2020-04-16 12:05:35 +02:00
Github Actions 52d73d8698 [CI Skip] 1.11.0-beta.18
skip-checks: true
2020-04-16 09:02:05 +00:00
Jeremías Díaz ccfab75f41 fix: use camelCase for storage module names (#2176) 2020-04-16 10:51:19 +02:00
Github Actions b8204b138d [CI Skip] 1.11.0-beta.17
skip-checks: true
2020-04-16 08:46:32 +00:00
Jaco Greeff a97cb6e25d Return all identity hashes (not just as subset) (#2179) 2020-04-16 10:36:37 +02:00
Github Actions 11534a1153 [CI Skip] 1.11.0-beta.16
skip-checks: true
2020-04-16 07:21:00 +00:00
Jaco Greeff dd1fab5366 Adjust set bitfileds to LE (#2178) 2020-04-16 09:09:17 +02:00
Github Actions dbb3a5ccc2 [CI Skip] 1.11.0-beta.15
skip-checks: true
2020-04-15 16:26:29 +00:00
Jaco Greeff fb08215e0d Add Fixed128 type (#2175) 2020-04-15 18:15:11 +02:00
Github Actions d7d7ab2f89 [CI Skip] 1.11.0-beta.14
skip-checks: true
2020-04-15 08:54:43 +00:00
Jaco Greeff 25393cd982 Add note on field ordering (#2173)
* Add note on field ordering

* Field ordering additional links
2020-04-15 10:43:15 +02:00
Github Actions d6a6089e2d [CI Skip] 1.11.0-beta.13
skip-checks: true
2020-04-15 06:55:53 +00:00
Jaco Greeff a3eaca0270 Small doc cleanups (#2172) 2020-04-15 08:44:15 +02:00
Github Actions f9d1b4d653 [CI Skip] 1.11.0-beta.12
skip-checks: true
2020-04-14 20:22:21 +00:00
Jaco Greeff f81712343a Transaction batching (#2171) 2020-04-14 22:10:25 +02:00
Github Actions 33e414be12 [CI Skip] 1.11.0-beta.11
skip-checks: true
2020-04-14 16:27:55 +00:00
Jaco Greeff 9387103558 cookbook link 2020-04-14 18:15:28 +02:00
Github Actions 3b7c1afa95 [CI Skip] 1.11.0-beta.10
skip-checks: true
2020-04-14 15:28:01 +00:00
Jaco Greeff 7e1fa8954b Extend storage cookbook (#2169)
* Extend storage cookbook

* Update storage.md

* Update storage.md
2020-04-14 17:16:46 +02:00
Github Actions 53c62f1542 [CI Skip] 1.11.0-beta.9
skip-checks: true
2020-04-14 14:56:23 +00:00
Jaco Greeff 5ed94a50e1 Update .123trigger 2020-04-14 16:45:30 +02:00
Github Actions b1c047149b [CI Skip] 1.11.0-beta.8
skip-checks: true
2020-04-14 14:35:37 +00:00
Jaco Greeff 7a0efaf58c Kusama 1057 known types (#2168) 2020-04-14 16:24:19 +02:00
Github Actions 5acce98346 [CI Skip] 1.11.0-beta.7
skip-checks: true
2020-04-14 11:52:00 +00:00
Jaco Greeff 165179ebf2 Remove flags on derive.accounts.info (#2167)
* Remove flags from derive.account.info

* adjust types
2020-04-14 13:40:12 +02:00
Github Actions def60dce9e [CI Skip] 1.11.0-beta.6
skip-checks: true
2020-04-14 10:49:12 +00:00
Jaco Greeff c8f91fcf7a Parameterize DoNotConstruct (#2165)
* Parameterize DoNotConstruct

* Update DoNotConstruct list

* typo fix
2020-04-14 12:37:30 +02:00
Github Actions 70a160cca0 [CI Skip] 1.11.0-beta.5
skip-checks: true
2020-04-14 10:31:23 +00:00
Jaco Greeff 9691fd5ba7 don't subscribe to runtime updates with no subs (#2166) 2020-04-14 12:20:07 +02:00
Jaco Greeff 475cb4fa69 Move Digest to interfaces (#2164)
* Move Digest to interfaces

* Unconstructable typos
2020-04-14 12:09:36 +02:00
Github Actions 5c54b3cc92 [CI Skip] 1.11.0-beta.4
skip-checks: true
2020-04-14 10:05:31 +00:00
Jaco Greeff 55d8c58d95 Add transactionVerions to RuntimeVersion struct (#2163) 2020-04-14 11:54:42 +02:00
Github Actions edf8adaa88 [CI Skip] 1.11.0-beta.3
skip-checks: true
2020-04-14 08:49:43 +00:00
Jaco Greeff 1f8f6e54bd Add unsigned sending to cookbook (#2162)
* Add unsigned sending to cookbook

* Block author extraction example
2020-04-14 10:36:15 +02:00
Github Actions f6ca7b9a9d [CI Skip] 1.11.0-beta.2
skip-checks: true
2020-04-14 07:52:33 +00:00
Jaco Greeff 7732339fc0 Line lengths 2020-04-14 09:41:04 +02:00
Jaco Greeff 5a8a8c7ecb Fix cookbook links 2020-04-14 09:34:39 +02:00
Github Actions 05df087e73 [CI Skip] 1.11.0-beta.1
skip-checks: true
2020-04-14 06:58:37 +00:00
Jaco Greeff 5b71abfe80 Make a start at a cookbook... still loads to go (#2160) 2020-04-14 08:48:14 +02:00
Github Actions 1d6c33060a [CI Skip] 1.11.0-beta.0
skip-checks: true
2020-04-13 10:45:21 +00:00
Jaco Greeff eae573e6a2 Simplify entries() decoding (#2159) 2020-04-13 12:33:24 +02:00
Github Actions 0f08031792 [CI Skip] 1.10.1
skip-checks: true
2020-04-13 05:28:25 +00:00
Jaco Greeff e0bde927d1 1.10 (#2158)
* 1.10

* CHANGELOG

* key extract example
2020-04-13 07:16:43 +02:00
Github Actions e569de520a [CI Skip] 1.10.0-beta.29
skip-checks: true
2020-04-11 20:32:39 +00:00
Jaco Greeff a833dccdaf All private prefixed with _ (#2157)
* All private prefixed with _

* Fix test
2020-04-11 22:21:55 +02:00
Github Actions b58d772156 [CI Skip] 1.10.0-beta.28
skip-checks: true
2020-04-10 16:17:30 +00:00
Jaco Greeff e5d9bbc264 Filter old rewards with stakingLedger (ledger can update) (#2155)
* Filter old rewards with stakingLedger (ledger can update)

* Cleanup internal functions
2020-04-10 18:06:14 +02:00
Github Actions 3089529405 [CI Skip] 1.10.0-beta.27
skip-checks: true
2020-04-10 12:41:15 +00:00
Jaco Greeff 5ab24390c5 Indicate all protected members and variables (#2154)
* Indicate all protected members and variables

* Added dropped protected
2020-04-10 14:29:58 +02:00
Github Actions 245047a41f [CI Skip] 1.10.0-beta.26
skip-checks: true
2020-04-10 12:04:49 +00:00
Jaco Greeff 8aa1bd5bd0 Indicate protected raw with _raw in Base codec (#2153) 2020-04-10 13:54:15 +02:00
Github Actions e0dde35621 [CI Skip] 1.10.0-beta.25
skip-checks: true
2020-04-10 10:23:42 +00:00
Jaco Greeff 9ba91a3851 Use forkJoin for entries() retrieval (#2152)
* Use forkJoin for entries() retrieval

* Some current and validator retrieval opts

* Remove duplicate filtering
2020-04-10 12:12:10 +02:00
Github Actions 351cb97667 [CI Skip] 1.10.0-beta.24
skip-checks: true
2020-04-09 16:44:08 +00:00
Jaco Greeff afdb476796 Small cleanups & consistency (#2151)
* Small cleanups & consistency

* Fixes
2020-04-09 18:32:30 +02:00
Github Actions 3b67b65091 [CI Skip] 1.10.0-beta.23
skip-checks: true
2020-04-09 13:55:22 +00:00
Jaco Greeff 25580b2026 Update CHANGELOG, bump deps (#2150) 2020-04-09 15:44:07 +02:00
Github Actions 2db16e94b7 [CI Skip] 1.10.0-beta.22
skip-checks: true
2020-04-09 12:57:00 +00:00
Jaco Greeff 9184268c3d Bump metadata (#2148)
* Bump metadata

* Adjust to non-customized democracy params
2020-04-09 14:46:48 +02:00
Github Actions 83a762af1e [CI Skip] 1.10.0-beta.21
skip-checks: true
2020-04-09 12:39:49 +00:00
Jaco Greeff 6a8e5370b6 Add system_chainType RPC (#2149) 2020-04-09 14:28:43 +02:00
Github Actions 9cd4bf7cf7 [CI Skip] 1.10.0-beta.20
skip-checks: true
2020-04-09 07:31:24 +00:00
Jaco Greeff c4708dcfca Cleanup isPassing (#2147) 2020-04-09 09:19:56 +02:00
Github Actions 041d06a6c8 [CI Skip] 1.10.0-beta.19
skip-checks: true
2020-04-08 19:58:30 +00:00
Jaco Greeff 2b4bd75499 Adjust calc with turnout add/sub 2020-04-08 21:47:22 +02:00
Github Actions c4c47a84e1 [CI Skip] 1.10.0-beta.18
skip-checks: true
2020-04-08 15:36:45 +00:00
Jaco Greeff a241bd1c38 Adjust change calc (#2145) 2020-04-08 17:23:59 +02:00
Github Actions d420cede82 [CI Skip] 1.10.0-beta.17
skip-checks: true
2020-04-08 14:04:37 +00:00
Jaco Greeff b869695e40 Bump util (#2144) 2020-04-08 15:55:04 +02:00
Github Actions 37caf4e710 [CI Skip] 1.10.0-beta.16
skip-checks: true
2020-04-07 19:23:34 +00:00
Jaco Greeff 134bc22463 Westend (spec) 2020-04-07 21:11:37 +02:00
Github Actions 39d142876e [CI Skip] 1.10.0-beta.15
skip-checks: true
2020-04-07 18:42:57 +00:00
Jaco Greeff 6d95eb418d Westend (again) 2020-04-07 20:31:16 +02:00
Github Actions e26a6a28ff [CI Skip] 1.10.0-beta.14
skip-checks: true
2020-04-07 18:10:26 +00:00
Jaco Greeff d80d6f2a06 Westend update (#2143) 2020-04-07 19:59:08 +02:00
Github Actions ff8dabb249 [CI Skip] 1.10.0-beta.13
skip-checks: true
2020-04-07 09:30:13 +00:00
Jaco Greeff e7a01f9780 Dump dev (incl. eslint header checks) (#2142) 2020-04-07 11:20:07 +02:00
Github Actions 94938c7075 [CI Skip] 1.10.0-beta.12
skip-checks: true
2020-04-06 10:43:28 +00:00
Jaco Greeff f37e729605 Use bumbled node (#2141) 2020-04-06 12:32:05 +02:00
Github Actions 9cfde73ff8 [CI Skip] 1.10.0-beta.11
skip-checks: true
2020-04-05 10:23:01 +00:00
Jaco Greeff f5c140d1c2 Split derive.staking.currentPoints from overview (#2140) 2020-04-05 12:12:03 +02:00
Github Actions 472e1022d3 [CI Skip] 1.10.0-beta.10
skip-checks: true
2020-04-05 08:15:44 +00:00
Jaco Greeff f71211f5dc Bump deps (#2139) 2020-04-05 10:05:50 +02:00
Github Actions 7e06974f1b [CI Skip] 1.10.0-beta.9
skip-checks: true
2020-04-04 17:16:19 +00:00
Jaco Greeff f95384d9ff Bump deps (#2138)
* Bump deps

* Add lockfile :)
2020-04-04 19:04:42 +02:00
Github Actions baedd5b689 [CI Skip] 1.10.0-beta.8
skip-checks: true
2020-04-04 16:36:28 +00:00
Jaco Greeff 9ec1cb194a Update StakingLedger (simpl payouts) (#2102)
* Update StakingLedger (simpl payouts)

* Chain defs

* Allow stakers queries with exclude filter

* Generate interfaces

* Return all exposures

* Rework exposures

* Cleanups
2020-04-04 18:25:32 +02:00
Github Actions d730310ea5 [CI Skip] 1.10.0-beta.7
skip-checks: true
2020-04-03 12:58:06 +00:00
Jaco Greeff 641fe5c380 Refresh on scheduler entries (#2135)
* Refresh on scheduler entries

* Cleanups
2020-04-03 14:47:39 +02:00
Github Actions c5a8d5e018 [CI Skip] 1.10.0-beta.6
skip-checks: true
2020-04-03 11:40:23 +00:00
Jaco Greeff 02d130f0a0 Add Mandatory to DispatchClass (#2134) 2020-04-03 13:29:07 +02:00
Github Actions 5554f17f05 [CI Skip] 1.10.0-beta.5
skip-checks: true
2020-04-02 18:55:29 +00:00
Jaco Greeff 69351ceb9e Cater for new dispatch scheduler (#2130)
* Cater for new dispatch scheduler

* Updated

* debug logs

* Update types.ts
2020-04-02 20:44:27 +02:00
Github Actions 0cf9fa7405 [CI Skip] 1.10.0-beta.4
skip-checks: true
2020-04-02 14:27:07 +00:00
Jaco Greeff 8213fa7cb9 Add validator total to staker rewards (#2129)
* Add validator total to staker rewards

* yarn rewrite
2020-04-02 16:16:10 +02:00
Github Actions 8ef983169f [CI Skip] 1.10.0-beta.3
skip-checks: true
2020-04-02 09:24:58 +00:00
Jaco Greeff e392dd745e Base centrifuge types (#2125) 2020-04-02 11:15:28 +02:00
Github Actions 6b07a9c2a5 [CI Skip] 1.10.0-beta.2
skip-checks: true
2020-04-02 07:46:55 +00:00
Jaco Greeff 114ac59707 Reword FAQ 2020-04-02 09:35:16 +02:00
Github Actions 3c95bfe56e [CI Skip] 1.10.0-beta.1
skip-checks: true
2020-04-01 22:00:58 +00:00
Jaco Greeff 58de0b8b9c Rewrite yarn.lock (#2127) 2020-04-01 23:49:56 +02:00
Github Actions 1f97c5e9e3 [CI Skip] 1.10.0-beta.0
skip-checks: true
2020-04-01 20:54:58 +00:00
Jaco Greeff 0dc46445bc Bump dev (incl. lint fixes) (#2126)
* Bump dev (incl. lint fixes)

* Fix call encoding (stepped into that one)

* Event struct order

* Update with missing tuple type (getTypeDef type)
2020-04-01 22:44:34 +02:00
495 changed files with 20547 additions and 16928 deletions
+5 -2
View File
@@ -1,3 +1,6 @@
21
1.4.2
25
1.4.2
1.6.2
1.11.2
1.12.2
1.17.2
+1
View File
@@ -1,3 +1,4 @@
.eslintrc.js
**/build/*
**/coverage/*
**/node_modules/*
+3 -1
View File
@@ -13,6 +13,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'
}
};
-3
View File
@@ -10,9 +10,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: ${{ matrix.step }}
run: |
yarn install --immutable | grep -v 'YN0013'
+2 -8
View File
@@ -10,30 +10,24 @@ jobs:
matrix:
step: ['build:release', 'docs:release']
name: ${{ matrix.step }}
if: "! contains(github.event.head_commit.message, '[CI Skip]') && github.repository == 'polkadot-js/api'"
if: "! startsWith(github.event.head_commit.message, '[CI Skip]') && github.repository == 'polkadot-js/api'"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
token: ${{ secrets.GH_PAT }}
- uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: ${{ matrix.step }}
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
GH_PAGES_SRC: build-docs
GH_PAT: ${{ secrets.GH_PAT }}
GH_TOKEN: ${{ secrets.GH_PAT }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_RELEASE_GITHUB_API_TOKEN: ${{ secrets.GH_PAT }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
yarn install --immutable | grep -v 'YN0013'
yarn ${{ matrix.step }}
dummy:
name: Dummy
if: "contains(github.event.head_commit.message, '[CI Skip]')"
runs-on: ubuntu-latest
steps:
- name: dummy
+86
View File
File diff suppressed because one or more lines are too long
-50
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -8,4 +8,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.js
spec: "@yarnpkg/plugin-interactive-tools"
yarnPath: .yarn/releases/yarn-rc.js
yarnPath: .yarn/releases/yarn-2.1.1.cjs
+438 -75
View File
@@ -1,7 +1,330 @@
# 1.9.1 Apr 1, 2020
# CHANGELOG
## 1.31.1 Aug 31, 2020
Upgrade priority: Medium, especially for staking users on Polkadot, Kusama & Westend (type updates applied for v23 onwards) or if transparent `.at(hash)` queries are required/used
- **Important** Substrate changed the `RewardDestination` enum with an extra field for payout-to-any account for staking preferences. If on an older chain consider adding `RewardDestination: 'RewardDestinationTo257'`
- **Important** Substrate changed the `CompactAssignment` type enhanced types for session solution submissions. If on an older chain consider adding `CompactAssignments: 'CompactAssignmentsTo257'`
- Fix documentation language and typos (Thanks to https://github.com/Meuko)
- Add missing `TransactionPriority` type (Thanks to https://github.com/aniiantt)
- Update definitions for new `CompactAssignments`, including tests (Thanks to https://github.com/kianenigma)
- Add transparent support for types/metadata, i.e. hash queries such as `rpc.chain.getBlock(<hash>)` & `query.system.events.at(<hash>)` now works out-of-the-box injecting the correct metadata & types.
- Optimize RPC-layer calls with detection of short-term cacheable calls (in the same way subscriptions are done)
- Additional checks on `AccountId` for valid sizes
- Add `toBigInt()` (JS built-in `BigInt`) on `Int/Uint`, & `Compact<*>` types
- Support for `.concat` on Codec arrays
- Support for serialization with `isBare` flag on enums
- Add `api.getBlockRegistry(blockHash?)` to create registry/types for a specific block
- `derive.democracy.locks` now returns delegated locks for an account as well
- Adjust unlocking derives with appropriate in-place additions (less object allocations)
- `.sign` on submittables is marked deprecated (not due for removal, but rather use `.signAsync` for consistency with `.signAndSend`)
- Adjust types for `CompactAssignments` & `RewardDestination` for Polkadot, Kusama & Westend
- `@polkadot/util` 3.4
- `@polkadot/wasm-crypto` 1.4
## 1.30.1 Aug 24, 2020
Upgrade priority: Low, unless using the `proposeParachain` module.
- Adjust balance retrievals to check for `system.account` for new/old determination
- Add types for the new `proposeParachain` module (as per Rococo)
- Adjust `Address` <-> `LookupSource` definitions (no external impact, both in existence)
- Add Ethereum-compatible `Ethereum{AccountId, LookupSource}` types, underlying `H160`
- Allow for configurable hashers via `registry.setHasher(...)` (defaults to `blake2AsU8a`)
- `@polkadot/util` 3.3
## 1.29.1 Aug 17, 2020
Upgrade priority: Low, unless on bleeding-edge chain with new compact `CompactAssignments`.
- **Important** The Substrate `CompactAssignments` type has changed for better space utilization. On older chains, supply `CompactAssignments: 'CompactAssignmentsTo257'`
- Clean tx cookbook param expansion (Thanks to https://github.com/swswsw)
- Add additional `Fixed{I,U}{64,128}` and `{I,U}32F32` types
- Add `desiredRunnersUp` to council derives
- Cleanup indices/AccountId combination derive lookups
- `@polkadot/util` 3.2
## 1.28.1 Aug 10, 2020
Upgrade priority: Low, unless using Centrifuge or parachains
- Update Centrifuge types to latest (Thanks to https://github.com/mikiquantum)
- Add cookbook entry for viewing block extrinsics
- Support types for time-delay proxies
- Update types for parachains
- `@polkadot/util` 3.1
- `@polkadot/wasm-crypto` 1.3
## 1.27.1 Aug 3, 2020
Upgrade priority: Low, unless using the Rococo chain
- Remove outdated example poc-3 RPC reference (Thanks to https://github.com/swswsw)
- Raw/Bytes `toHuman` detects ASCII sequence for text output
- Add know types for the Rococo chain
## 1.26.1 Jul 27, 2020
Upgrade priority: Low
- Update docs for the new `system.accountNextIndex` (Thanks to https://github.com/shawntabrizi)
- Update contracts call parameter typing (Thanks to https://github.com/kwingram25)
- Adjust votingBalance to only return `freeBalance` (only council voting is free + reserved)
- Additional checks for referenced Vec sub-type deconstruction in typegen
- Allow for API `typesBundle` option to inject a group of chain versions types
- Update metadata static tests for latest Substrate
- `@polkadot/util` 3.0
## 1.25.1 Jul 20, 2020
Upgrade priority: Medium, especially if using contracts.
- **Important** Contract RPC result updated on Substrate, on older chains supply `ContractExecResult: 'ContractExecResultTo255'`
- Support for custom HTTP headers in providers (Thanks to https://github.com/brad-larson)
- Update known types for Centrifuge (Thanks to https://github.com/philipstanislaus)
- Update API users with Registrar #1 (Thanks to https://github.com/chevdor)
- Raw/Bytes `toHuman()` displays utf-8 as available
- Add fallback for `setImmediate` when not polyfilled
- Update `NetworkState` reputation type for `system_networkState` RPC
- Update session progress calcs for Aura (cater for negative)
- Fix class prototype for (basically-deprecated) Linkage type
- Add Polkadot types for `purchase` pallet
## 1.24.1 Jul 13, 2020
- Added `isAscii` & `isUtf8` getters to `Bytes` & `Raw` types
- Added `toUtf8()` helper to `Bytes` & `Raw` types
- `@polkadot/util` 2.18
## 1.23.1 Jul 6, 2020
- Small README typo fix (Thanks to https://github.com/woss)
- Add latest Substrate master types
- Adjust `<Codec>.toRawType()` to use registry name as available
- Update `ProxyType` for Kusama, Polkadot & Westend with `IdentityJudgement`
- Validate number format (signed/unsigned) for number types
- Remove core codec dependencies on Base class (with proper TS encapsulation)
- `@polkadot/util` 2.17
## 1.22.1 Jun 30, 2020
- **Important** Substrate changed the treasury tip structure, on older chains supply `OpenTip: 'OpenTipTo225'`
- Allow for `[u8; 33]` in U8aFixed (Thanks to https://github.com/akru)
- Improve derive accountId -> accountIndex lookups (optimize entries queries)
- Vesting balance calculations via `derive.balances.all` has been updated for locks
- Add derive for multi staking rewards with specified eras
- `@polkadot/util` 2.16
## 1.21.1 Jun 23, 2020
- Fix subscriptions never unsubscribing after the id swap in 1.18.1 (Thanks to https://github.com/dillu24 for testing iterations)
- Add support for `CheckMortality` signed extension (old `CheckEra` is now an alias)
- Promise API will default to using `getStorage` on non-subscription calls, reducing RPC overhead
- Optimize derive BN allocations, using in-place operators as applicable
- Add new Substrate types for Babe `EquivocationProof`
- Adjust `Releases` enum to use a shared instance
## 1.20.1 Jun 22, 2020
- **Important** RPC for `account_nextIndex` has been moved to `system_accountNextIndex` (Aligning with Substrate as a primary alias)
- Cleanup map entries support with only Substrate 2.0-era RPCs (when introduced)
- Add `system_dryRun` RPC
- Optimize `derive.staking.queryMulti` retrievals with additional per-type batching
- Add `derive.staking.waitingInfo` (same as `electedInfo` for waiting validators)
- Adjust types & metadata for latest Substrate
- `@polkadot/util` 2.15
## 1.19.1 Jun 16, 2020
- Improve typing on `.entries()` queries (Thanks to https://github.com/monitz87)
- Align metadata and types with latest Substrate
- Update Polkadot types for current evolution of parachains
- Allow for type aliasing on events (aligning with calls & queries)
- `@polkadot/util` 2.14
## 1.18.1 Jun 8, 2020
- Expand docs on node-template types (Thanks to https://github.com/g2udevelopment)
- Update contract fees to current impl. (Thanks to https://github.com/djuanit0x)
- Allow `Option` types in enum/Result type generation (Thanks to http://github.com/xlc)
- Add `.entriesPaged` and `.keysPaged` methods for state maps (https://github.com/monitz87)
- Add types for new Substrate proxy module
- Adjust types for new Substrate (renamed) npos-elections module
- `Call` now exposes `method` & `section` fields (aligned with `toHuman()` representation)
- Cater for new Substrate string subscription ids (with backwards compatibility)
- `@polkadot/util` 2.13
## 1.17.2 Jun 2, 2020
- Ensure subscription promise resolves before first result
## 1.17.1 Jun 2, 2020
- Fix `ElectionSize` type (Thanks to https://github.com/arjanz)
- Allow `BTreeSet` decoding from Array/JSON inputs
- Adjust Call-only metadata output to trim documentation to first full line
- Safeguard against divide-by-zero for total era points (expired reward eras)
- Internal derive optimizations with combining calls
- Support for latest Substrate types & metadata
- `@polkadot/util` 2.12
## 1.16.1 May 26, 2020
- Support for Polkadot CC1 types & signed extensions
- Add support for Babe VRF secondary digests (author extraction)
- Adjust `Perbill/Permill` `toHuman()` formatting to output percentage
- Support for latest Substrate types & metadata
- Update to latest TypeScript, eslint & typescript-eslint
- `@polkadot/util` 2.11
## 1.15.1 May 23, 2020
- Adjust `keyPrefix()` with DoubleMap args (Thanks to https://github.com/KiChjang)
- Added `WeightToFeeCoefficient` type (Thanks to https://github.com/danforbes)
- Spelling fixes for console logs (Thanks to https://github.com/JoshOrndorff)
- Spelling fixes in cookbook (Thanks to https://github.com/pawelnguyen)
- Add `transactionVersion` getter in payloads (Thanks to https://github.com/amaurymartiny)
- Adjust `stakerRewards` derive ordering for improved on-payout refreshes
- Baseline implementation for derive caching infrastructure
- Adjust `Multiplier` type to `Fixed128` (as per latest Substrate)
- Updated to latest Substrate metadata & add new types
## 1.14.1 May 14, 2020
- **Important** `DispatchInfo` changed `paysFee` to an enum, if using an older version use, `DispatchInfo: 'DispatchInfoTo244'`
- Align imOnline `Heartbeat` with Substrate (Thanks to https://github.com/arjanz)
- Adust EVM types to include `Vicinity` (Thanks to https://github.com/drewstone)
- Ensure metadata is only requested once upon startup (bypass on upgrade subscriptions)
- Expand testing around `ExtrinsicEra` construction
- Expand `Registry` to direct access to available signed extensions (in addition to exposed types)
- Cater for new `CheckSpecVersion` and `CheckTxVersion` signed extensions (with `SignerPayload` adjustments)
- Cater for new `PrevalidateAttests` signed extensions (Polkadot claims)
- Don't re-calculate submittable extrinsic hash on status checks (optimization)
- Support for both old/new Tuples in `democracy.depositOf` in derives
- Fix democracy `ProxyState` types
- Extends types for Polkadot claims
- Update `@polkadot/util` to 2.10
## 1.13.1 May 6, 2020
- Add support for ECDSA keypairs in extrinsic signers (Thanks to https://github.com/akru)
- Rework type generation to use templating for better maintenance (Thanks to https://github.com/xlc)
- Adjust extrinsic `sign/signAsync` signature to optional options (Thanks to https://github.com/KiChjang)
- Support round-robin endpoints in the `WsProvider` with array of urls (Thanks to https://github.com/hoani)
- Remove static test-only metadata for Polkadot dev chains (not updated regularly, Substrate dev to remain)
- Revert error swallow for wrong preimage data (temp. override for Kusama upgrade with no migration)
- Fix `.encodedLength` calculation on `[Type; N]` types
- Add new `rpc.grandpa.roundState` RPC
- Update types & metadata as per latest Substrate master
- Adjust Centrifuge starting version
## 1.12.2 Apr 30, 2020
- Update `@polkadot/util` to stable 2.9.1 (sadly missed in the previous version, stable should match to stable)
## 1.12.1 Apr 29, 2020
- Fix `CompactAssignments` types (Thanks to https://github.com/arjanz)
- Provider ayo-connect now allows for interval config (Thanks to https://github.com/jnaviask)
- Cleanup generation for c-like enums (Thanks to https://github.com/monitz87)
- Allow subscription to all storage keys, alignment with Substrate (Thanks to https://github.com/xlc)
- Cater for vote delegations in democracy derives
- Cleanup account derive flags where to allow for optional council modules
- Allow generic types in ApiPromise.combineLatest
- Update to latest substrate metadata
## 1.11.2 Apr 22, 2020
- Small patch to add missing Polkadot master types (will be in next Kusama update)
## 1.11.1 Apr 21, 2020
- **Important** Substrate master has an updated `Weight` (to `u64`), on older chains apply `Weight: 'u32'` (This does affect event decoding if wrongly set)
- Allow user type augmentation to work with different versions of rxjs (Thanks to https://github.com/monitz87)
- Align augmented generation with camelCase (Thanks to https://github.com/monitz87)
- Fix bitfield endian encoding (Thanks to investigation by https://github.com/xlc)
- Add account flag derives via `accounts.flags(accountId)` (Thanks to https://github.com/kwingram25)
- Fix entries decoding for `Option<Number>` (& simplify, decoding correctly on rpc layer)
- Add `system.{localPeerId, localListenAddresses}` & `state.getReadProof` RPCs
- Ensure proper propagation of `api.runtimeVersion` (used for signing) after upgrade
- Field ordering fix for deprecated `Linkage` (used in linked maps)
- `derive.account.info` now returns all field enum types decoded (not only raw)
- Add banner with FAQ entries for node-template to aid with common issues
- `Digest` has been moved to definitions, removal of `GenericDigest` type
- Support `Fixed128` type
- Add `transactionVersion` to `RuntimeVersion` struct
- Enhance API support for non-subscription providers (skip subscription to runtimeVersion)
- Adjust types for Kusama 1057 (notably the new `StakingLedger`)
## 1.10.1 Apr 13, 2020
- **Important** Substrate master has updated staking, on older chains apply `StakingLedger: 'StakingLedgerTo240'`
- Add `rpc.system.chainType` to retrieve the chain type (Development. Local, Live & Custom)
- Adjust types for Westend after the reset
- Adjust democracy derives, including the support of the frame-scheduler for scheduled deployments
- Allow staking derives to work with new staking payouts, specifically `tx.staking.payoutStakers`
- Cleanups to derives for democracy & staking to be more performant
- Add Centrifuge base types to `@polkadot/types-known`
- Adjust with all the latest substrate master types
- Internally all private/protected methods/variables are now `_` prefixed (Aligning with the `private/protected` indicators in the TS definitions)
- Update metadata/docs-from-metadata to the latest Substrate
## 1.9.1 Apr 1, 2020
- **Breaking change** (TypeScript with derives only) The return type names for `api.derive.*` have been adjusted for consistency, all starting with `Derive*` (previously a mixture of `Derived*` and `Derive*`)
- **Breaking change** (derives only) Additional cleanups of democracy proposal & referenda derives, including support for new Polkadot/Substrate vote retrievals
**Breaking change** (TypeScript with derives only) The return type names for `api.derive.*` have been adjusted for consistency, all starting with `Derive*` (previously a mixture of `Derived*` and `Derive*`)
**Breaking change** (derives only) Additional cleanups of democracy proposal & referenda derives, including support for new Polkadot/Substrate vote retrievals
- Tx signing via `signAndSend` & `signAsync` now tries to use the last finalized block (depending on finalized drift)
- Add support for `api.rpc.childstate.*` Substrate RPCs, older nodes with still populate `api.rpc.state.*` with the child methods
- Adjust `Error.message` on RPC failures to not include the (already known) method signature
@@ -13,11 +336,13 @@
- Fix encoding for `Vec<u8>`-related types as part of constants
- Internal adjustment of interface type locations (no impact on imports via `@polkadot/types/interfaces`)
# 1.8.1 Mar 22, 2020
## 1.8.1 Mar 22, 2020
- **Breaking change** The format for any custom RPCs have been changed (alongside API-internal changes) to allow for better RPC management. If you are currently using custom RPCs (or planning to do so), look at the [updated documentation](https://polkadot.js.org/api/start/rpc.custom.html)
- **Breaking change** Alongside API RPC changes, the `@polkadot/jsonrpc` package has been removed. Since it was never documented and only used internally, this should not have adverse impacts. All RPC definitions itself has now been moved to the relevant modules inside `@polkadot/types/interfaces`
- **Important** Substrate has an updated democracy module. If using an older chain add the `ReferendumInfo: 'ReferendumInfoTo239'` type when using referendums
- The `isRetracted` Extrinsic status is now a warning, not a fatal error, correctly aligning with Polkadot/Substrate
- The Substrate extrinsic phase definitions has been expanded with `Initialization` to align with the latest versions
- Add support for all known substrate RPC methods
@@ -25,9 +350,11 @@
- Adjusted referendum derives to cater for bot new/old democracy. Derived `referendumInfo` now includes `status` field, not `info`
- Add `initWasm` flag to API options. When set to `false` does not init the WASM portion (leaving it to the user elsewhere)
# 1.7.1 Mar 17, 2020
## 1.7.1 Mar 17, 2020
- **Important** Current versions of Polkadot/Substrate have dropped support for linked maps on storage entries. If you are using these queries to retrieve all entries, for instance `staking.{nominators,validators}()` and using an upgraded chain, you need to swap to retrieving entries via `.entries()` or `.keys()` for the keys.
- Pull in support and types for latest Polkadot/Substrate
- Add support for the new Substrate `state_getKeysPaged` RPC, including use in storage keys
- Move `derive.staking.controllers` to `derive.staking.stashes`, reflecting actual content
@@ -35,13 +362,16 @@
- Expanded `derive.staking.*` derives, including addition of `derive.staking.own*`
- Re-add fixed (with tests) checks for query args, previously disabled in 1.6.2
# 1.6.2 Mar 12, 2020
## 1.6.2 Mar 12, 2020
- Revert checks for query args, not working on `.at()` queries (proper fix in next version)
# 1.6.1 Mar 12, 2020
## 1.6.1 Mar 12, 2020
- **Breaking change** `api.rpc.state.queryStorage(...)` now fully decodes the `Vec<StorageChangeSet>` and returns a decoded `[Hash, Codec[]][]` when using this RPC.
- `StorageKey` now has an `.args` property, decoded from meta where `twox64_concat` or `blake128_concat` are used on maps
- Fix `api.query.*.*.entries` type conversions to return exact types (not `Option` in some cases)
- Add `api.query.*.*.keys` to retrieve only the storage keys, similar to `.entries`
@@ -53,13 +383,16 @@
- Add runtime validation for map arguments to `api.query.*`
- TypeScript interfaces for linked maps now correctly generates as `[Type, Linkage<Next>]`
# 1.5.1 Mar 06, 2020
## 1.5.1 Mar 06, 2020
- **Important** Substrate master has updated staking, on older chains supply `StakingLedger: 'StakingLedgerTo223'`
- **Important** Substrate master has updated collective, on older chains supply `Votes: 'VotesTo230'`
- Add proper support for type generation with an Enum containing an Tuple (Thanks to https://github.com/monitz87)
- Fix storage parsing not resulting in rejected Promises (Fix from https://github.com/aniiantt applied)
- Remove use of deprecated `Observable.create` (Thanks to https://github.com/Himself65)
- Add types & metadata for the latest Polkadot/Substrate runtime versions (master branches)
- Type extraction will now allow the same sub-module name across packages, i.e. `@polkadot/types/interfaces/runtime` & `@mine/interfaces/runtime` will be valid
- Add `.range([from, to]: [Hash, Hash?], ...args: any[]): [Hash, Codec][]` on all storage entries
@@ -73,17 +406,21 @@
- Add additional derives to `api.derive.staking` to handle lazy-payout retrievals
- Update `@polkadot/{util, util-crypto, keyring}` to 1.6.1 & `@polkadot/wasm` to 1.2.1
# 1.4.2 Feb 27, 2020
## 1.4.2 Feb 27, 2020
- Fix `api.tx(<extrinsic>): Submittable` decoration (non-working in 1.4.1, now with proper test)
# 1.4.1 Feb 26, 2020
## 1.4.1 Feb 26, 2020
- **Breaking change** (TypeScript only) The `*.d.ts` files now contain TypeScript 3.8 features (specifically `#private`), which is not usable in TS versions < 3.8
- **Breaking change** - `api.derive.staking.*` has updated result types and detects support for lazy payouts queries
- Rework type generation for `api.{query, tx}` to properly handle complex type inputs (Thanks to https://github.com/monitz87)
- Rework metadata `--strict` mode to effectively decorate chain metadata (Thanks to https://github.com/monitz87)
- Add `api.rpc.chain.subscribeAllHeads` (not just best) (Thanks to https://github.com/jak-pan)
- Add `api.rpc.engine.*` for manual seal support
- Add `api.injectMetadata(metadata)` to initialize API with a specific metadata version
- The api now checks for runtime upgrades, augmenting the interfaces with new metadata when found
@@ -103,18 +440,23 @@
- Cleanup augmentation and generation scripts for type definitions, aligning with api augmentation
- Bump to `@polkadot/{util, util-crypto, keyring}` 2.5.1
# 1.3.1 Feb 18, 2020
## 1.3.1 Feb 18, 2020
- Add `@types/bn.js` as a normal dependency, exposed in `*.d.ts` (Thanks to https://github.com/monitz87)
- Type generation scripts (including `polkadot-types-from-{chain,defs}`) has been moved to the `@polkadot/typegen` package
- The `@polkadot/types/codec/create` has been moved to `@polkadot/types/create`, imports from `@polkadot/types` are unaffected
- Expose chain properties on registry (and use for API type formatting)
- Add `toHuman(isExtended?: boolean)` to all codec types, formatting into a human-readable structure
# 1.2.1 Feb 16, 2020
## 1.2.1 Feb 16, 2020
- **Important** Update RPC status codes (latest Substrate 2), with the `isInBlock` (`isFinalized` now indicates finality)
- Storage `.entries(arg?: any)` now has the correct argument type for DoubleMap (Thanks to https://github.com/monitz87)
- Swap Kusama and Polkadot aliases for `Address` to `AccountId` (future update)
- Add `LookupSource` and `LookupTarget` types instead of mapping these directly for aliasing
- Add `BitVec` type primitive
@@ -129,9 +471,11 @@
- Cleanup `codec/Date` tests to make it run properly on all timezones
- Add explicit dependencies to all packages and move TypeScript `@types/*` to dev deps
# 1.1.1 Feb 06, 2020
## 1.1.1 Feb 06, 2020
- **Important** Chains without `balances.account` or `system.account` should supply `"BalanceLock": "BalanceLockTo212"` to their types to use the previous-generation `BalanceLock` (when querying locks)
- Add support for `balances.account` in all applicable derives (incl. `vesting` module)
- Inject and use SignedExtensions by name from V11 metadata (V4 extrinsics only)
- Add typings for `api.tx.*.*` - the `polkadot-types-from-chain` now also generates these
@@ -143,11 +487,14 @@
- Adjust balances fees derivation with optional transfer and creation fees (removed in Substrate)
- Adjust enum `.toJSON()` to return type name as specified
# 1.0.1 Jan 30, 2020
## 1.0.1 Jan 30, 2020
- **Breaking change** Drop support for Substrate v1 chain in all derives
- Return unsub functions from provider .on emitters (Thanks to https://github.com/jak-pan)
- `ApiPromise.isReady` now rejects on unrecoverable errors (Thanks to https://github.com/laec)
- Add `polkadot-types-from-chain` & `polkadot-types-from-defs` TypeScript generators to `@polkadot/types`
- Only decorate derives where relevant parent `api.query.*` is available
- Support `.entries(arg?: any)` lookups on DoubleMaps (in addition to previously supported maps)
@@ -162,9 +509,11 @@
- Remove support for un-deployed metadata
- Remove old known types for Substrate V1
# 0.100.1 Jan 13, 2020
## 0.100.1 Jan 13, 2020
- **Important** This will the the last API version with Substrate 1.x support. Although you will still be able to use subsequent versions with older chains, dependent libraries such as sr25519 may not be compatible.
- Add support for the Substrate identity module
- Remove the `codec/Data` type, to remove a conflict with Substrate. This type is now named `Raw`
- Fix for linked maps using `Option`
@@ -173,37 +522,44 @@
- Add support for latest Polkadot/Substrate types
- Add `paymentInfo` to submittables to calculate fees
# 0.99.1 Dec 13, 2019
## 0.99.1 Dec 13, 2019
- **Breaking change** The `Data` and `U8a` type has been renamed and just replaced with the `Raw` type
- **Breaking change** The `api.derive.staking.info` has been split into 2 - `staking.query` for non-balance related information (more effective) and `staking.account` that enhances query for all the information previously found `.info`
- Cleanup `DoubleMap` hashing to always hash over the full value (in the case of `Vec<T>`, this includes the length)
- Update democracy derives to take care of nextTally and lowestUnbaked
- Add additional derives for both council & treasury
- Alignment with latest Polkadot/Substrate master branch types
# 0.98.1 Dec 04, 2019
## 0.98.1 Dec 04, 2019
- Make the TypeScript generation script mor re-usable (Thanks to https://github.com/xlc)
- Add `.entries()` for all map-types, returning storage keys and values
- Add `.signAsync` to submittable extrinsics (Thanks to https://github.com/c410-f3r)
- Cleanup circular references between internal dependencies
- Support for new Substrate democracy with preimages in derive
- Alignment of types with Substrate/Polkadot master branches
# 0.97.1 Nov 29, 2019
## 0.97.1 Nov 29, 2019
- **Breaking change** Add the passing on an explicit `Registry` to all calls to `createType` as well as all codec classes. If you are upgrading form an older version, use the [migration guide](UPGRADING.md) to walk through the changes required.
- **Breaking change** The metadata classes have been moved from `@polkadot/types` into `@polkadot/metadata`. If you explicitly create `Metadata` classes, you now would need to do so with the `import Metadata from '@polkadot/metadata';` This is a decorated class, where the previous metadata is now available on `Metadata.metadata`, alongside decorated `consts.*`', `tx.*` and `query.*`.
- **Breaking change** Session `Keys` defaults to 4 keys now (Substrate master), depending on your node config, you would want to override with e.g. `Keys: 'SessionKeys3'` (1, 2, 3, 4, 5 & 6)
- **Breaking change** `ValidatorPrefs` now default to the new percentage commission model, to use the previous `validatorPayment`, you can override with `ValidatorPrefs: 'ValidatorPrefsTo196'`
- `api.derive.*` now has built-in memomization
- Various fixes and cleanups to `api.derive.*` including era length progress and vesting calculations
- Aligned all types with the latest Polkadot & Substrate, including Kusama CC3
- Support for Metadata V9, which adjusts the hashing methods of storage entries
- Support for Metadata V10 (still un-released), which includes prefixed map support
# 0.96.1 Nov 09, 2019
## 0.96.1 Nov 09, 2019
- Updated types for latest Kusama
- Add `filterRecords` (in addition to `findRecord`) on submittable results
@@ -213,11 +569,13 @@
- Update council derives for the latest Substrate master support (with constants)
- Derive cleanups, including sharing of instances between the API and internal to derives
# 0.95.2 Oct 25, 2019
## 0.95.2 Oct 25, 2019
- Temporary removal of `account_nextIndex` use, will be re-added in a future release
# 0.95.1 Oct 25, 2019
## 0.95.1 Oct 25, 2019
- Support Extrinsic V4 with additional signature indicator (Latest Polkadot/Substrate/Kusama)
- Adjust subscription update checks to avoid duplicated data updates
@@ -227,7 +585,8 @@
- All latest Polkadot & Substrate types (as per master branches)
- **Breaking change** `Call.injectMethods` is moved to `Call.injectMetadata` to align with `Events` (This _should_ not be used externally, however mentioned as breaking here)
# 0.94.1 Oct 07, 2019
## 0.94.1 Oct 07, 2019
- Add handling of `Result<Ok, Error>` definitions
- Adjust API cloning now takes RPC filters from source into account
@@ -239,7 +598,8 @@
- Add documentation for custom extrinsic formats (advanced chains)
- Update to latest substrate master metadata
# 0.93.1 Sep 26, 2019
## 0.93.1 Sep 26, 2019
- Support for Kusama CC2
- In extrinsic submission, use `rpc.account.nextIndex` to retrieve the nonce when available
@@ -249,7 +609,8 @@
- Support recursive type registration (self-referencing via `Box`) in addition to better sanitation of user-defined-types
- Documentation and example updates (thanks mostly to contributions)
# 0.92.1 Sep 12, 2019
## 0.92.1 Sep 12, 2019
- The API now correctly sets the ss58 prefix as retrieved from the chain properties via `ss58Format`
- Bump to `@polkadot/util` 1.4.1, removing use of `ExtError`
@@ -257,7 +618,8 @@
- Support the latest Polkadot & Substrate master branches (incl. metadata updates)
- Getting started documentation has been made available
# 0.91.1 Sep 09, 2019
## 0.91.1 Sep 09, 2019
- This release was focussed on stability, with a number of cleanups and bug-fixes
- Adjustments for Substrate 1.x chain detection (with auto-types) and Substrate 2.x support has been extended with all latest types
@@ -271,7 +633,8 @@
- **Breaking change** `SignerPayload` is renamed to `SignerPayloadJSON`
- **Breaking change** `SignerPayloadJSON`, `SignerPayloadRawBase` and `SignerPayloadRaw` are all moved to `@polkadot/types`
# 0.90.1 Aug 24, 2019
## 0.90.1 Aug 24, 2019
If you are upgrading form an older version, use the CHANGELOG hand-in-hand with the [migration guide](UPGRADING.md).
@@ -284,12 +647,13 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
- For creation of types, it is recommended to use `createType(<TypeName>, <value>)` instead of e.g. `new Proposal(...)`. When passing these to methods/queries, construction should not be needed, the raw value can be passed.
- For moved types, a previous import would have been from `@polkadot/types`, i.e. `import { SetIndex } from '@polkadot/types`, now just the interfaces (TypeScript) are available via `import { SetIndex } from '@polkadot/types/interfaces`
- `usize` is now a blacklisted type that will throw on construction. Since it is platform-specific, it creates incompatibilities between native (generally `u64`) and WASM (always `u32`) code. Use one of the `u32` or `u64` types explicitly.
- Support substrate v7 metadata
- The `Method.findFunction(callIndex)` (allowing decoding of raw data), is now available on `api.findCall(callIndex)`. To keep backwards compatibility, it is still available on `GenericCall.findMethod` but the `api.findCall` is recommended and suggested.
- The `types/codec/createType` has been moved to `types/codec/create` with the same exports. If you explicitly imported from here (and not doing the suggested `import { createType } from '@polkadot/types`), the reference needs to be updated
# 0.82.0-beta.x Jul 28, 2019
## 0.82.0-beta.x Jul 28, 2019
- Support for substrate 2.x (master) has been extended,
- Additional types have been addedd for the modules
@@ -308,7 +672,7 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
- The `ContractsAbi` type has been moved from `@polkadot/types` to `import { Abi } from '@polkadot/api-contract`. This paves the way for an enhanced contracts interface, instead of dealing with low-level API calls.
# 0.81.1 Jun 14, 2019
## 0.81.1 Jun 14, 2019
- The dependency on `@polkadot/keyring` has been removed - if you relied on the API to provide this, you would now need to manually add it
- `createType` allows for the creation of `[u8; <length>]` types (opening the door for contract support)
@@ -328,7 +692,7 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
- Add `off` method to `Api` (Base, for both `ApiPromise` & `ApiRx`) to remove an event listener
# 0.80.1 Jun 04, 2019
## 0.80.1 Jun 04, 2019
- Support for mortal transactions
- Better DoubleMap storage support
@@ -338,7 +702,7 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
- Misc. cleanups and fixes
# 0.79.1 May 22, 2019
## 0.79.1 May 22, 2019
- DoubleMap query support
- Support latest EventRecord metadata (substrate master)
@@ -350,7 +714,7 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
- Add `toRawType` on all type classes (breakdown into primitive types)
# 0.78.1 May 08, 2019
## 0.78.1 May 08, 2019
- Fix linked-maps (not working since 0.77.1)
- Convert Usize to U32 (as found in WASM environments)
@@ -361,13 +725,13 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
- Metadata updates for substrate (WithdrawReasons, ContractInfo)
# 0.77.1 Apr 25, 2019
## 0.77.1 Apr 25, 2019
- Support Metadata v4, which introduces the use of a custom hasher to hash storage map keys.
- Add TreasuryProposal (not the same as democracy, type aliased)
# 0.76.1 Apr 03, 2019
## 0.76.1 Apr 03, 2019
- Caching improvements (duplicate queries, no duplicate subscriptions)
- Experimental contract API
@@ -375,23 +739,22 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
- Update @polkadot/util-crypto with smaller footprint
# 0.75.1 Mar 29, 2019
## 0.75.1 Mar 29, 2019
- Start journey to 1.0
# 0.53.1 Mar 29, 2019
## 0.53.1 Mar 29, 2019
- Change spelling to US English as per substrate master (1.0-rc1). Breaking changes as a result:
- For extrinsic status results, if you have checked the type returns, i.e. `result.type === 'Finalised'` now check on the status for `result.status.isFinalized` or `result.status.isBroadcast`, ... (the `type` property is now accessible only on `result.status.type`)
- If using `subscribeFinalisedHeads` update this to `subscribeFinalizedHeads` (likewise `getFinalisedHead` should be updated to `getFinalizedHead` and `derive.bestNumberFinalized`)
- The underlying ss58 address checksums have changed
- The updated keyring with support for this has been made available
- All examples have been updated with sr25519 addresses (with the new checksums)
# 0.52.1 Mar 28, 2019
## 0.52.1 Mar 28, 2019
- Support queries to linked mapped storage (found in new staking interfaces)
- Add `derive.staking.controllers` to retrieve all active staking controllers
@@ -401,42 +764,42 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
- Check for single instances for api and types as they are loaded (assertSingletonPackage)
# 0.51.1 Mar 25, 2019
## 0.51.1 Mar 25, 2019
- Support metadata V2 as per latest substrate master
- Update metadata with new types as per latest substrate master
# 0.50.1 Mar 23, 2019
## 0.50.1 Mar 23, 2019
- Latest util-crypto (usage of WASM with JS fallbacks if not available)
- Update upstream @polkadot dependencies (for new crypto)
# 0.49.1 Mar 20, 2019
## 0.49.1 Mar 20, 2019
- Fix large message signing on non-known nodes (default is now hashing, there has been enough time between upgrades)
# 0.48.1 Mar 18, 2019
## 0.48.1 Mar 18, 2019
- Pull in new sr25519 capable keyring for dev nodes
- When using dev mode, it assumes that the node is the latest with derived sr25519 keys
# 0.47.1 Mar 14, 2019
## 0.47.1 Mar 14, 2019
- Swap to publishing -beta.x on merge (non-breaking testing)
# 0.46.1 Mar 01, 2019
## 0.46.1 Mar 01, 2019
- Extended type registration to now handle internal types as well. Additionally the built-in Extrinsic type can now we overridden with a custom version.
- Where `Extrinsic` and `Method` is used as types, consider importing `{ IMethod, IExtrinsic }` from `@polkadot/types/types`, especially in the cases where this is used from a `SubmittableExtrinsic`
- The `typeRegistry` constant is now `getTypeRegistry()` as a function
# 0.45.1 Feb 19, 2019
## 0.45.1 Feb 19, 2019
- Storage with option values now correctly return `Option<Type>` and is indicated as such in the documentation
@@ -453,7 +816,7 @@ console.log('llo', llo.unwrapOr('not set') /* Option<BlockNumber> */)
```
# 0.44.1 Feb 19, 2019
## 0.44.1 Feb 19, 2019
- Split primitives and types into separate folders. This should not affect external use since the exports remain the same, however does have an impact where classes are referenced directly. e.g.
@@ -471,45 +834,45 @@ import { Method, Signature } from '@polkadot/types';
```
# 0.43.1 Feb 14, 2019
## 0.43.1 Feb 14, 2019
- Introduces support for the new keyring with sr25519 support in addition to ed25519. While this does not change the exposed API, it is considered breaking since @polkadot/keyring has interface changes. (Unless needed, don't rush the upgrade)
# 0.42.1 Jan 31, 2019
## 0.42.1 Jan 31, 2019
- Support for substrate hash signing with implVersion >= 18
- Changed signatures for Extrinsic signing, this should not have (much) of an impact since it is generally not used directly. SubmittableExtrinsic (as exposed by the API), supports the old-style use.
# 0.41.1 Jan 26, 2019
## 0.41.1 Jan 26, 2019
- Support the V1 metadata specification from Substrate in addition to the currently testnet active V0 version
# 0.40.1 Jan 16, 2019
## 0.40.1 Jan 16, 2019
- The API interfaces now require a WS-compatible provider, e.g. subscription support is a must. Previously the HTTPProvider could be use (although it was very limited in the interactions).
# 0.39.1 Jan 11, 2019
## 0.39.1 Jan 11, 2019
- The Promise API now returns a `Promise<UnsubFunction>` instead of `UnsubFunction` when making subscriptions.
# 0.38.1 Jan 08, 2019
## 0.38.1 Jan 08, 2019
Substrate has been updated with a breaking new transaction format where the Index/Nonce is now encoded as a Compact. This change is being rolled out to both Alexander (Polkadot testnet) as well as Charred Cherry (Substrate testnet) - transactions between old and new are not compatible.
# 0.37.1 Jan 04, 2019
## 0.37.1 Jan 04, 2019
api-observable has been removed. This was only used in /apps and inconsistent with the api/rx and api/promise APIs. Future work will include derives like was included in api-observable into the base.
Tuples now return single types when only one type is available, i.e. `(AccountId)` would now resolve as `AccountId`. The extra type wrapper adds no benefit to users here.
# 0.36.1 Jan 03, 2019
## 0.36.1 Jan 03, 2019
Api Promise has been updated in the way we deal with subscriptions. Previously a subscription returned `Promise<number>` where the caller was to keep track of the id and use it in subsequent unsubscribes. Now any subscriptions return an unsubscribe/destroy function `(): void`, that is use for removing the subscriptions, e.g.
@@ -520,51 +883,51 @@ unsubscribe(); // here we destroy the subscription
```
# 0.35.1 Dec 20, 2018
## 0.35.1 Dec 20, 2018
Swapped to new metadata structures from Substrate. If the API is not working with your node, update Substrate to latest master branch. (Or 0.9.1 for Charred Cherry). Dropped support for old metadata as found as far back as BBQ Birch.
# 0.34.1 Dec 18, 2018
## 0.34.1 Dec 18, 2018
Changed the send signature (for future expansion of eg. events) to return `result: { status: ExtrinsicStatus }` instead of `status: ExtrinsicStatus`. For most cases where only status `type` checks are used, i.e. `status.type === 'Finalised'` this should not be a breaking change. Deep inspection of the status object however will need to adapt.
# 0.33.1 Dec 06, 2018
## 0.33.1 Dec 06, 2018
# 0.32.1 Nov 21, 2018
## 0.32.1 Nov 21, 2018
# 0.31.1 Oct 10, 2018
## 0.31.1 Oct 10, 2018
# 0.30.1 Sep 27, 2018
## 0.30.1 Sep 27, 2018
# 0.29.1 Sep 14, 2018
## 0.29.1 Sep 14, 2018
# 0.28.1 Aug 11, 2018
## 0.28.1 Aug 11, 2018
# 0.15.1 Aug 07, 2018
## 0.15.1 Aug 07, 2018
# 0.14.1 Jun 23, 2018
## 0.14.1 Jun 23, 2018
# 0.13.1 May 29, 2018
## 0.13.1 May 29, 2018
# 0.12.1 May 18, 2018
## 0.12.1 May 18, 2018
# 0.11.1 May 16, 2018
## 0.11.1 May 16, 2018
# 0.10.1 May 07, 2018
## 0.10.1 May 07, 2018
# 0.9.1 Apr 24, 2018
## 0.9.1 Apr 24, 2018
# 0.8.1 Mar 15, 2018
## 0.8.1 Mar 15, 2018
# 0.7.1 Jan 25, 2018
## 0.7.1 Jan 25, 2018
# 0.6.1 Dec 03, 2017
## 0.6.1 Dec 03, 2017
# 0.5.1 Nov 28, 2017
## 0.5.1 Nov 28, 2017
# 0.4.1 Nov 19, 2017
## 0.4.1 Nov 19, 2017
# 0.3.1 Nov 19, 2017
## 0.3.1 Nov 19, 2017
# 0.2.1 Nov 18, 2017
## 0.2.1 Nov 18, 2017
+1 -1
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.
+4
View File
@@ -1 +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.
module.exports = require('@polkadot/dev/config/babel');
+1
View File
@@ -19,4 +19,5 @@ copy_folder "metadata"
copy_folder "rpc-core"
copy_folder "rpc-provider"
copy_folder "types"
copy_folder "types-known"
copy_folder "typegen"
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
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"
+19 -2
View File
@@ -20,7 +20,8 @@ module.exports = {
},
{ text: 'GitHub', link: 'https://github.com/polkadot-js/api' }
],
search: false,
search: true,
searchMaxSuggestions: 10,
sidebar: [
{
title: 'Getting started',
@@ -50,6 +51,17 @@ module.exports = {
['start/FAQ.md', 'FAQ']
]
},
{
title: 'Cookbook',
path: '/cookbook/',
collapsable: false,
sidebarDepth: 0,
children: [
['cookbook/blocks.md', 'Blocks'],
['cookbook/storage.md', 'Storage'],
['cookbook/tx.md', 'Transactions']
]
},
{
title: 'Examples (Promise API)',
path: '/examples/promise/',
@@ -86,5 +98,10 @@ module.exports = {
['/types/', '@polkadot/types'],
'/CONTRIBUTING.md'
]
}
},
plugins: [
['@vuepress/search', {
searchMaxSuggestions: 10
}]
]
};
+3
View File
@@ -1,5 +1,8 @@
$accentColor = #fd8824
$textColor = #2c3e50
$borderColor = #eaecef
$codeBgColor = #282c34
$arrowBgColor = #ccc
.home .hero .description,
.home .feature h2,
+2 -9
View File
@@ -13,7 +13,7 @@ features:
- title: Types
details: Various type interfaces to make using returned values from API calls transparent in your code.
footer: Apache-2 Licensed | Copyright © 2017-2019 polkadot-js authors and contributors
footer: Apache-2 Licensed | Copyright © 2017-2020 polkadot-js authors and contributors
---
## Welcome
@@ -21,16 +21,9 @@ footer: Apache-2 Licensed | Copyright © 2017-2019 polkadot-js authors and contr
The API provides application developers the ability to query a node and interact with the Polkadot or Substrate chains using Javascript. Here you will find documentation and examples to get you started.
::: tip Getting started & Examples
[Jump right in](/start/) and get an overview on using the API in your projects, from installation all the way through to making it do magic. Already understand how things work and just want the examples? [The ApiPromise examples](/examples/promise/) provide some basic recipies.
[Jump right in](/start/) and get an overview on using the API in your projects, from installation all the way through to making it do magic. Have things working and want tips? The [cookbook](/cookbook/) provides some tips and tricks. Getting started and want some full examples? [The ApiPromise examples](/examples/promise/) provide some basic examples.
:::
## Available packages
This repository split up into a number of internal packages, namely -
- [api](api/README.md) Promise and RxJS-based APIs
- [types](types/README.md) Type encoding and decoding wrappers
## The Polkadot Project
You can read more about the Polkadot Network at [https://polkadot.network/](https://polkadot.network/) and more about the polkadot-js projects at [https://polkadot.js.org](https://polkadot.js.org)
+19
View File
@@ -0,0 +1,19 @@
# Cookbook
The cookbook hosts small code snippets in a question-answer format. It does not walk you through the whole setup, like the [basic examples](../examples/), but rather aims to answer some questions around specific uses. It also does not replace the [getting started FAQ](../start/FAQ.md), rather this is focussed explicitly on code samples, instead of general trouble-shooting for common mishaps.
These questions are added as they do come up and the hope is that the snippets here is will be useful to others, instead of just the original person who asked on a specific use-case. As of today, it is only making a start and not fully comprehensive yet - check back early, check back often.
## Sections
The following cookbook sections are available -
- [Blocks](blocks.md) - Snippets around working with blocks and headers
- [Storage](storage.md) - Snippets for working with storage
- [Transactions](tx.md) - Snippets for working with transactions
... more to come.
## Contribute
And as always, if you have an addition to make, or a question to ask any [any PRs](https://github.com/polkadot-js/api/tree/master/docs) or [issues](https://github.com/polkadot-js/api/issues) are appreciated. The initial content was generate from exactly such questions, either in Riot chat or as submitted as issues.
+61
View File
@@ -0,0 +1,61 @@
# Blocks
The building blocks for each blockchain. As such there are a number of examples for working with blocks and headers, that could be useful.
## How do I retrieve the header/extrinsic hash from blocks?
A block hash refers to the hash over the header, the extrinsic hash refers to the hash of the encoded extrinsic. Since all objects returned by the API implements the `.hash => Hash` getter, we can simply use this to view the actual hash.
```js
// returns Hash
const blockHash = await this.api.rpc.chain.getBlockHash(blockNumber);
// returns SignedBlock
const signedBlock = await this.api.rpc.chain.getBlock(blockHash);
// the hash for the block, always via header (Hash -> toHex()) - will be
// the same as blockHash above (also available on any header retrieved,
// subscription or once-off)
console.log(signedBlock.header.hash.toHex());
// the hash for each extrinsic in the block
signedBlock.block.extrinsics.forEach((ex, index) => {
console.log(index, ex.hash.toHex());
});
```
## How do I extract the block author?
The block author is encoded inside the consensus logs for the block. To extract, you need to decode the log (which the API does do) and then map the index of the validator to the list of session validators. This extraction is however available on the api derive for new head subscriptions, which returns an extended header with the author populated (assuming that the digest logs are known).
```js
// subscribe to all new headers (with extended info)
api.derive.chain.subscribeNewHeads((header) => {
console.log(`#${header.number}: ${header.author}`);
});
```
For a single header only, the derives also contain a `getHeader`, which once again returns a header extended with the author -
```js
// retrieve the last header (hash optional)
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
console.log(index, ex.toHuman());
});
```
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.
+55
View File
@@ -0,0 +1,55 @@
# Storage
Here you will find snippets for working with storage.
## How do I check for storage existence?
In the metadata, for each storage item a fallback is provided. This means that when an entry does not exist, the fallback (which is the default value for the type) will be provided. This means, that querying for a non-existent key (unless an option), will yield a value -
```js
// retrieve Option<StakingLedger>
const ledger = await api.query.staking.ledger('EoukLS2Rzh6dZvMQSkqFy4zGvqeo14ron28Ue3yopVc8e3Q');
// retrieve ValidatorPrefs (will yield the default value)
const prefs = await api.query.staking.validators('EoukLS2Rzh6dZvMQSkqFy4zGvqeo14ron28Ue3yopVc8e3Q');
console.log(ledger.isNone, ledger.isSome); // true, false
console.log(JSON.stringify(prefs.toHuman())); // {"commission":"0"}
```
In the second case, the non-existent prefs returns the default/fallback value for the storage item. So in this case we don't know if the value is set to 0 or unset. Existence can be checked by using the storage size, which would be zero if nothing is stored.
```js
// exists
const sizeY = await api.query.staking.validators.size('DB2mp5nNhbFN86J9hxoAog8JALMhDXgwvWMxrRMLNUFMEY4');
// non existent
const sizeN = await api.query.staking.validators.size('EoukLS2Rzh6dZvMQSkqFy4zGvqeo14ron28Ue3yopVc8e3Q');
console.log(sizeY.isZero(), sizeY.toNumber()); // false 4
console.log(sizeN.isZero(), sizeY.toNumber()); // true 0
```
## How do I use .entries()/.keys() on double maps?
As [explained elsewhere](../start/api.query.other.md#map-keys-entries) each map-type storage entry exposes the entries/keys helpers to retrieve the whole list. In the case of double maps, with the addition of a single argument, you can retrieve either all entries or a subset based on the first map key.
In both these cases, entries/keys operate the same way, `.entries()` retrieving `(StorageKey, Codec)[]` and `.keys()` retrieving `StorageKey[]`
```js
// Retrieves the entries for all slashes, in all eras (no arg)
const allEntries = await api.query.staking.nominatorSlashInEra.entries();
// nominatorSlashInEra(EraIndex, AccountId) for the types of the key args
allEntries.forEach(([{ args: [era, nominatorId] }, value]) => {
console.log(`${era}: ${nominatorId} slashed ${value.toHuman()}`);
});
```
While we can retrieve only the keys for a specific era, using a argument for the first part of the doublemap (as defined here, an `EraIndex`) -
```js
// Retrieves the keys for the slashed validators in era 652
const slashedKeys = await api.query.staking.nominatorSlashInEra.keys(652);
// key args still contains [EraIndex, AccountId] decoded
console.log(`slashed: ${slashedKeys.map(({ args: [era, nominatorId] }) => nominatorId)`);
```
+112
View File
@@ -0,0 +1,112 @@
# Transactions
A blockchain is no fun if you are not submitting transactions. Or at least if somebody is not submitting any. Here you will find some snippets for dealing with some common issues.
## How do I estimate the transaction fees?
In addition to the `signAndSend` helper on transactions, `.paymentInfo` (with the exact same parameters) are also exposed. Using the same sender, it applies a dummy signature to the transaction and then gets the fee estimation via RPC.
```js
// estimate the fees as RuntimeDispatchInfo, using the signer (either
// address or locked/unlocked keypair) (When overrides are applied, e.g
// nonce, the format would be `paymentInfo(sender, { nonce })`)
const info = await api.tx.balances
.transfer(recipient, 123)
.paymentInfo(sender);
// log relevant info, partialFee is Balance, estimated for current
console.log(`
class=${info.class.toString()},
weight=${info.weight.toString()},
partialFee=${info.partialFee.toHuman()}
`);
```
## How do I get the decoded enum for an ExtrinsicFailed event?
Assuming you are sending a tx via `.signAndSend`, the callback yields information around the tx pool status as well as any events when `isInBlock` or `isFinalized`. If an extrinsic fails via `system.ExtrinsicFailed` event, you can retrieve the error, if defined as an enum on a module.
```js
api.tx.balances
.transfer(recipient, 123)
.signAndSend(sender, ({ status, events }) => {
if (status.isInBlock || status.isFinalized) {
events
// find/filter for failed events
.filter(({ section, method }) =>
section === 'system' &&
method === 'ExtrinsicFailed'
)
// we know that data for system.ExtrinsicFailed is
// (DispatchError, DispatchInfo)
.forEach(({ data: [error, info] }) => {
if (error.isModule) {
// for module errors, we have the section indexed, lookup
const decoded = api.registry.findMetaError(error.asModule);
const { documentation, method, section } = decoded;
console.log(`${section}.${method}: ${documentation.join(' ')}`);
} else {
// Other, CannotLookup, BadOrigin, no extra info
console.log(error.toString());
}
});
}
});
```
## How do I send an unsigned extrinsic?
For most runtime modules, transactions need to be signed and validation for this happens node-side. There are however modules that accepts unsigned extrinsics, an example would be the Polkadot/Kusama token claims (which is here used as an example).
```js
// construct the transaction, exactly as per normal
const utx = api.tx.claims.claim(beneficiary, ethSignature);
// send it without calling sign, pass callback with status/events
tx.send(({ status }) => {
if (status.isInBlock) {
console.log(`included in ${status.asInBlock}`);
}
});
```
The signing is indicated by the first byte in the transaction, so in this case we have called `.send` on it (no `.sign` or `.signAndSend`), so it will be sent using the unsigned state, without signature attached.
## How can I batch transactions?
Polkadot/Substrate provides a `utility.batch` method that can be used to send a number of transactions at once. These are then executed from a single sender (single nonce specified) in sequence. This is very useful in a number of cases, for instance if you wish to create a payout for a validator for multiple eras, you can use this method. Likewise, you can send a number of transfers at once. Or even batch different types of transactions.
```js
// construct a list of transactions we want to batch
const txs = [
api.tx.balances.transfer(addrBob, 12345),
api.tx.balances.transfer(addrEve, 12345),
api.tx.staking.unbond(12345)
];
// construct the batch and send the transactions
api.tx.utility
.batch(txs)
.signAndSend(sender, ({ status }) => {
if (status.isInBlock) {
console.log(`included in ${status.asInBlock}`);
}
});
```
## 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 or querying it via `rpc.system.accountNextIndex`.
```js
for (let i = 0; i < 10; i++) {
// 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
.transfer(recipient, 123)
.signAndSend(sender, { nonce });
}
```
@@ -1,6 +1,7 @@
/* eslint-disable header/header */
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Required imports
const { ApiPromise, WsProvider } = require('@polkadot/api');
@@ -1,6 +1,7 @@
/* eslint-disable header/header */
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API
const { ApiPromise } = require('@polkadot/api');
@@ -1,6 +1,8 @@
/* eslint-disable header/header */
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/no-floating-promises */
// Import the API
const { ApiPromise } = require('@polkadot/api');
@@ -13,13 +15,13 @@ async function main () {
// Retrieve the initial balance. Since the call has no callback, it is simply a promise
// that resolves to the current on-chain value
let { nonce: previousNonce, data: { free: previousFree } } = await api.query.system.account(Alice);
let { data: { free: previousFree }, nonce: previousNonce } = await api.query.system.account(Alice);
console.log(`${Alice} has a balance of ${previousFree}, nonce ${previousNonce}`);
console.log(`You may leave this example running and start example 06 or transfer any value to ${Alice}`);
// Here we subscribe to any balance changes and update the on-screen value
api.query.system.account(Alice, ({ nonce: currentNonce, data: { free: currentFree } }) => {
api.query.system.account(Alice, ({ data: { free: currentFree }, nonce: currentNonce }) => {
// Calculate the delta
const change = currentFree.sub(previousFree);
@@ -1,6 +1,8 @@
/* eslint-disable header/header */
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/no-floating-promises */
// Import the API
const { ApiPromise } = require('@polkadot/api');
@@ -1,6 +1,7 @@
/* eslint-disable header/header */
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API
const { ApiPromise } = require('@polkadot/api');
@@ -1,6 +1,7 @@
/* eslint-disable header/header */
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API
const { ApiPromise } = require('@polkadot/api');
@@ -1,6 +1,7 @@
/* eslint-disable header/header */
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API
const { ApiPromise } = require('@polkadot/api');
@@ -1,6 +1,7 @@
/* eslint-disable header/header */
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API, Keyring and some utility functions
const { ApiPromise } = require('@polkadot/api');
const { Keyring } = require('@polkadot/keyring');
@@ -1,6 +1,7 @@
/* eslint-disable header/header */
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API, Keyring and some utility functions
const { ApiPromise } = require('@polkadot/api');
const { Keyring } = require('@polkadot/keyring');
@@ -1,6 +1,8 @@
/* eslint-disable header/header */
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/no-floating-promises */
// Import the API
const { ApiPromise } = require('@polkadot/api');
@@ -1,6 +1,8 @@
/* eslint-disable header/header */
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/no-floating-promises */
// Import the API & Provider and some utility functions
const { ApiPromise } = require('@polkadot/api');
@@ -44,7 +46,7 @@ async function main () {
console.log('Included at block hash', status.asInBlock.toHex());
console.log('Events:');
events.forEach(({ phase, event: { data, method, section } }) => {
events.forEach(({ event: { data, method, section }, phase }) => {
console.log('\t', phase.toString(), `: ${section}.${method}`, data.toString());
});
} else if (status.isFinalized) {
@@ -1,6 +1,8 @@
/* eslint-disable header/header */
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/no-floating-promises */
// Import the API & Provider and some utility functions
const { ApiPromise, WsProvider } = require('@polkadot/api');
+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 -1
View File
@@ -1,6 +1,7 @@
/* eslint-disable header/header */
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Required imports
const { zip } = require('rxjs');
const { ApiRx } = require('@polkadot/api');
@@ -1,6 +1,7 @@
/* eslint-disable header/header */
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API
const { ApiRx } = require('@polkadot/api');
const { switchMap } = require('rxjs/operators');
@@ -1,6 +1,7 @@
/* eslint-disable header/header */
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API and operators from RxJs
const { ApiRx } = require('@polkadot/api');
const { pairwise, startWith } = require('rxjs/operators');
@@ -27,6 +28,7 @@ async function main () {
// then balance[1] is the initial value of Alice account.
console.log(`Alice ${Alice} has a balance of ${balance[1].data.free}`);
console.log('You may leave this example running and start the "Make a transfer" example or transfer any value to Alice address');
return;
}
+2 -1
View File
@@ -1,6 +1,7 @@
/* eslint-disable header/header */
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API
const { ApiRx } = require('@polkadot/api');
const { switchMap } = require('rxjs/operators');
+2 -1
View File
@@ -1,6 +1,7 @@
/* eslint-disable header/header */
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API
const { ApiRx } = require('@polkadot/api');
const { combineLatest, of } = require('rxjs');
+3 -1
View File
@@ -1,6 +1,8 @@
/* eslint-disable header/header */
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API, Keyring and some utility functions
const { ApiRx } = require('@polkadot/api');
const { Keyring } = require('@polkadot/keyring');
+2 -1
View File
@@ -1,6 +1,7 @@
/* eslint-disable header/header */
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API and selected RxJs operators
const { switchMap } = require('rxjs/operators');
const { ApiRx } = require('@polkadot/api');
+3 -2
View File
@@ -1,6 +1,7 @@
/* eslint-disable header/header */
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API and some utility functions
const { ApiRx } = require('@polkadot/api');
@@ -48,7 +49,7 @@ async function main () {
console.log('Included at block hash', status.asInBlock.toHex());
console.log('Events:');
events.forEach(({ phase, event: { data, method, section } }) => {
events.forEach(({ event: { data, method, section }, phase }) => {
console.log('\t', phase.toString(), `: ${section}.${method}`, data.toString());
});
} else if (status.isFinalized) {
+2 -1
View File
@@ -1,6 +1,7 @@
/* eslint-disable header/header */
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API & Provider and some utility functions
const { ApiRx, WsProvider } = require('@polkadot/api');
// Import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
+11 -3
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).
@@ -52,8 +54,14 @@ Likewise, if your chain has been upgraded recently and you are still using the o
## I cannot send transactions from my node-template-based chain
For the API defaults, the API always the type definitions as specified by the Substrate master fully-featured node. This means that any customizations needs to be applied as types should there be differences in specific user-implementations.
The API always injects the default type definitions as specified by the Substrate master fully-featured node. This means that any customizations to chains needs needs to be applied as types, should there be differences in specific user-implementations.
The Substrate node-template has added customizations for some types in the default template, specifically around the `Address` and `Lookup` types, removing indices lookups from addresses. This means that the transaction payload saves 2 bytes for a transfer and is an approach followed by other chains as well, notably Polkadot & Kusama.
The Substrate node-template has added customizations for some types in the default template, specifically around the `Address` and `Lookup` types, removing any lookups based on indices. This means that the transaction payload saves 2 bytes for a transfer and is an approach followed by other chains as well, notably Polkadot & Kusama.
Due to these customizations and differences that bleed through to the transaction formats, out-of-the-box the node-template will have issues when sending transactions. To fix this, you would need to add [the customized Address types into your API](types.extend.md#impact-on-extrinsics) instances (or UIs), allowing the API to have the information required to adjust the encoding.
Due to these customizations and differences that bleed through to the transaction formats, out-of-the-box chains based on the node-template will have issues when sending transactions. To fix this, you would need to add [the customized Address types into your API](types.extend.md#impact-on-extrinsics) instances (or UIs), allowing the API to have the information required to adjust the encoding.
## Using a non-current-master node, I have issues parsing events
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.
+1 -1
View File
@@ -23,7 +23,7 @@ A couple of items to note in the example above: we don't call `account` directly
...
// Retrieve a snapshot of the validators
const validators = await api.query.session.validators();
const validatorKeys = await api.query.session.validators.keys();
// Subscribe to the balances for these accounts
const unsub = await api.query.balances.account.multi(validators, (balances) => {
+18 -3
View File
@@ -62,7 +62,7 @@ When working maps and double-maps, it is possible to retrieve a list of all the
// Retrieve the active era
const activeEra = await api.query.staking.activeEra();
// retrieve all exposures int the active era
// retrieve all exposures for the active era
const exposures = await api.query.staking.erasStakers.entries(activeEra.index);
exposures.forEach(([key, exposure]) => {
@@ -71,9 +71,24 @@ exposures.forEach(([key, exposure]) => {
});
```
Here we are querying a double-map, so we supply 1 argument. No arguments on double-maps will be very costly, retrieving all the eras and associated entries. Additionally when `twox64_concat` & `blake2_concat` is used, the key `.args` will contain decoded values of the params, in this case it will contain the actual `AccountId` of the staker. (Since that was not supplied)
To understand the usage of the `key.args`, you need to understand that map/doublemap keys are stored alongside their lookups. This means that the raw key has hashed parts as well as the raw data. The API will decode the keys and provide the raw key arguments in args. This would mean -
In the same way as above we can simply do `.keys(activeEra.index): StorageKey[]` to retrieve all the keys here, including the individual keys args decoding, as available on maps with decodable hashing functions.
- if we are querying `api.query.staking.validators(validatorId: AccountId)` via `entries`, the `key.args` would be `[AccountId]`
- if we are querying `api.query.staking.erasStakers(era: EraIndex, validatorId: AccountId)` via `entries`, the `key.args` would be `[EraIndex, AccountId]`
the same applies to `.keys()` - here the list of keys also have the decoded args, as specified. You can think of `.args` as a tuple with the same types as the types required to retrieve a single entry in the map.
In the first example we are querying a double-map, so we supply 1 argument. No arguments on double-maps will be very costly, retrieving all the eras and associated entries. In the same way as above we can simply do `.keys(activeEra.index): StorageKey[]` to retrieve all the keys here, including the individual keys args (available on maps with decodable hashing functions) -
```js
// retrieve all the nominator keys
const keys = await api.query.staking.nominators.keys();
// extract the first key argument [AccountId] as string
const nominatorIds = keys.map(({ args: [nominatorId] }) => nominatorId);
console.log('all nominators:', nominatorIds.join(', '));
```
## State entries
+1 -1
View File
@@ -26,7 +26,7 @@ If we had a query with parameters, i.e. where we wish to perform a query for a s
// Subscribe to balance changes for our account
const unsub = await api.query.system.account(ADDR, ({ nonce, data: balance }) => {
console.log(`free balance is ${balance.freee} with ${balance.reserved} reserved and a nonce of ${nonce}`);
console.log(`free balance is ${balance.free} with ${balance.reserved} reserved and a nonce of ${nonce}`);
});
```
+1 -1
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
+18 -6
View File
@@ -1,6 +1,6 @@
# Custom RPC
In previous sections we looked at the injection of types, as in use and defined in modules from the node. Another area that can be customized is RC definitions, and like with the types, the API provides the capability to add user-defined RPCs (in addition to the Polkadot/Substrate base) to allow use of these RPCs via the API.
In previous sections we looked at the injection of types, as in use and defined in modules from the node. Another area that can be customized is RPC definitions, and like with the types, the API provides the capability to add user-defined RPCs (in addition to the Polkadot/Substrate base) to allow use of these RPCs via the API.
## Custom definitions
@@ -17,20 +17,32 @@ const api = await ApiPromise.create({
{
name: 'index',
type: 'u64'
},
{
name: 'at',
type: 'Hash',
isOptional: true
}
],
type: 'Balance'
}
}
}
},
anotherMethod: { ... },
...
},
anotherModule: { ... },
...
},
...
});
```
In the above example we have defined a new method, which is now available on the RPCs as `api.rpc.firstModule.testMethod(u64) => Promise<Balance>`. Do be aware that while defined, the method will only appear if it is in the list as returned by `api.rpc.rpc.methods()`, which is the list of known RPCs the node exposes. When making changes to the node, always ensure that it does expose the RPC method correctly, otherwise it will not be decorated.
In the above example we have defined a new method, which is now available on the RPCs as `api.rpc.firstModule.testMethod(index: u64, at?: Hash) => Promise<Balance>`. In the case of optional params, we have added the `isOptional: true` flag alongside the `name` & `type` in the param definition.
Be aware that while defined, the method will only appear on the API if it is in the list as returned by `api.rpc.rpc.methods()`, which is the list of known RPCs the node exposes. When making changes to the node, always ensure that it does expose the RPC method correctly, otherwise it will not be decorated.
## 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 -1
View File
@@ -57,7 +57,7 @@ Be aware that in the JS version naming defaults to `camelCase` where names of fi
Each enum has additional getters which are injected based on the fields wrapped. These take the form of `.is<Name>` and `.as<Name>` to allow you to check is the enum is a certain value or to retrieve the underlying value as a specific type.
As a real-world example, when an extrinsic is applied, the `Phase` enum has one of two states, `ApplyExtrinsic(u32)` or `Finalization`. In this case `.isApplyExtrinsic` would be `true` when an extrinsic is being applied, and `.asApplyExtrinsic` would return the value as a `u32` (which is the index of the extrinsic in the block, as it is being applied). When `isisApplyExtrinsic` is `false` and `asApplyExtrinsic` is called, the getter will throw.
As a real-world example, when an extrinsic is applied, the `Phase` enum has one of two states, `ApplyExtrinsic(u32)` or `Finalization`. In this case `.isApplyExtrinsic` would be `true` when an extrinsic is being applied, and `.asApplyExtrinsic` would return the value as a `u32` (which is the index of the extrinsic in the block, as it is being applied). When `isApplyExtrinsic` is `false` and `asApplyExtrinsic` is called, the getter will throw.
## Working with Option&lt;Type&gt;
@@ -67,6 +67,7 @@ An `Option<Type>` attempts to mimic the Rust approach of having `None` and `Some
- `.isSome` - this is `true` is a value is wrapped, i.e. if a `Option<u32>` has an actual underlying `u32`
- `.unwrap()` - when `isSome`, this will return the wrapped value, i.e. for `Option<u32>`, this would return the `u32`. When the value is `isNone`, this call will throw an exception.
- `.unwrapOr(<default value>)` - this extends `unwrap()`, returning the wrapped value when `isSome` and in the case of `isNone` it will return the `<default value>` passed.
- `.unwrapOrDefault()` - returns either the rapped value when `isSome`, or the default for the type when `isNone`
## Working with Tuples
+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'));
```
+12 -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
@@ -26,6 +26,15 @@ const api = await ApiPromise.create({
The above introduces the `types` registry, effectively allowing overrides and the definition of new types. The override above would mean that immediately the API will treat all occurrences of `Balance` not as the default, but rather as the defined size.
## Field ordering
When defining any custom structures or types, it is critical that the following rules are applied -
- Map exactly to what is defined in the Rust code, i.e. defining a `SaleType` cannot be `u16` on the one end and `u32` on the other end. If mismatches occur, the serialization will fail.
- Ensure that the field order is maintained in all definitions. The SCALE serialization is binary and contains no field names in the serialization, only the encoded values. Any decoding is therefore done based on the size of the type and the order thereof in the definitions.
These rules apply everywhere. Always ensure that the types match exactly between the environments and that the ordering is maintained, be it for structs, tuples or enums.
## User-defined structs
Registration also applies to any type that can be found on a specific chain, i.e. we can add any types that is available on a specific node -
@@ -78,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
...
@@ -203,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.
+4 -4
View File
@@ -1,10 +1,10 @@
# 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
A large part of the type definitions are defined not as classes, but rather as structures from which type definitions are extracted and that can be used as-is to let the API know how to decode a type. By now you should be familiar with [type extensions](types.extend.md), but effectively the [types library does exactly the same](https://github.com/polkadot-js/api/tree/master/packages/types/src/interfaces).
A large part of the type definitions are defined not as classes, but rather as structures from which type definitions are extracted and that can be used as-is to let the API know how to decode a type. By now you should be familiar with [type extensions](types.extend.md) and the [rules around fields](types.extend.md#field-ordering), but effectively the [types library does exactly the same](https://github.com/polkadot-js/api/tree/master/packages/types/src/interfaces).
To create TypeScript-aware definitions and keep your files in a single place, you can follow the same approach. Assuming you have a package named `@MeInc/stuff` where you have the definitions in an `stuff/interfaces` folder. Each sub-folder would indicate a runtime module, e.g.
@@ -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.
+6 -2
View File
@@ -1,15 +1,19 @@
/* eslint-disable @typescript-eslint/camelcase */
/* eslint-disable @typescript-eslint/no-var-requires */
// 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.
const config = require('@polkadot/dev/config/jest');
module.exports = Object.assign({}, config, {
moduleNameMapper: {
'@polkadot/api-contract(.*)$': '<rootDir>/packages/api-contract/src/$1',
'@polkadot/api-derive(.*)$': '<rootDir>/packages/api-derive/src/$1',
// eslint-disable-next-line sort-keys
'@polkadot/api(.*)$': '<rootDir>/packages/api/src/$1',
'@polkadot/metadata(.*)$': '<rootDir>/packages/metadata/src/$1',
'@polkadot/rpc-(core|provider)(.*)$': '<rootDir>/packages/rpc-$1/src/$2',
'@polkadot/types-known(.*)$': '<rootDir>/packages/types-known/src/$1',
// eslint-disable-next-line sort-keys
'@polkadot/types(.*)$': '<rootDir>/packages/types/src/$1'
},
modulePathIgnorePatterns: [
+1 -2
View File
@@ -1,8 +1,7 @@
// Copyright 2017-2020 @polkadot/util authors & contributors
// Copyright 2017-2020 @polkadot/api authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path');
module.exports = function resolver (file, config) {
+1 -1
View File
@@ -9,5 +9,5 @@
"packages": [
"packages/*"
],
"version": "1.9.1"
"version": "1.31.1"
}
+14 -9
View File
@@ -7,7 +7,7 @@
"packages/*"
],
"resolutions": {
"typescript": "^3.8.3"
"babel-core": "^7.0.0-bridge.0"
},
"scripts": {
"build": "yarn build:interfaces && polkadot-dev-build-ts && (cd packages/typegen && copyfiles scripts/* build)",
@@ -24,13 +24,18 @@
"test:watch": "polkadot-dev-run-test --watch"
},
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/register": "^7.9.0",
"@babel/runtime": "^7.9.2",
"@polkadot/dev": "^0.51.9",
"@polkadot/ts": "^0.3.14",
"@babel/core": "^7.11.4",
"@babel/register": "^7.10.5",
"@babel/runtime": "^7.11.2",
"@polkadot/dev": "^0.55.43",
"@polkadot/ts": "^0.3.40",
"@polkadot/typegen": "workspace:packages/typegen",
"@types/jest": "^25.1.4",
"copyfiles": "^2.2.0"
}
"@types/jest": "^26.0.10",
"@vuepress/plugin-search": "^1.5.4",
"copyfiles": "^2.3.0",
"typedoc": "^0.18.0",
"typedoc-plugin-markdown": "^2.4.2",
"typedoc-plugin-no-inherit": "^1.1.10"
},
"version": "1.31.1"
}
+8 -8
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-contract",
"version": "1.9.1",
"version": "1.31.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.9.2",
"@polkadot/api": "1.9.1",
"@polkadot/rpc-core": "1.9.1",
"@polkadot/types": "1.9.1",
"@polkadot/util": "^2.7.1",
"bn.js": "^5.1.1",
"rxjs": "^6.5.4"
"@babel/runtime": "^7.11.2",
"@polkadot/api": "1.31.1",
"@polkadot/rpc-core": "1.31.1",
"@polkadot/types": "1.31.1",
"@polkadot/util": "^3.4.1",
"bn.js": "^5.1.3",
"rxjs": "^6.6.2"
}
}
+2 -2
View File
@@ -18,10 +18,10 @@ export default class ContractAbi extends ContractRegistry implements InterfaceAb
constructor (registry: Registry, abi: ContractABIPre) {
super(registry, abi);
[this.abi, this.constructors, this.messages] = this.decodeAbi(abi);
[this.abi, this.constructors, this.messages] = this._decodeAbi(abi);
}
private decodeAbi (abiPre: ContractABIPre): [ContractABI, ContractABIFn[], AbiMessages] {
private _decodeAbi (abiPre: ContractABIPre): [ContractABI, ContractABIFn[], AbiMessages] {
this.validateAbi(abiPre);
const abi = this.convertAbi(abiPre);
+24 -17
View File
@@ -19,7 +19,7 @@ function parseSelector (registry: Registry, fnname: string, input: ContractABIMe
return registry.createType('u32', hexToU8a(input));
} else if (typeof input === 'string') {
try {
const array = JSON.parse(input);
const array = JSON.parse(input) as unknown[];
assert(array.length === 4, `${fnname}: Invalid selector length`);
@@ -61,7 +61,7 @@ export default class ContractRegistry extends MetaRegistry {
const unknownKeys = Object.keys(arg).filter((key): boolean => !['name', 'type'].includes(key));
assert(unknownKeys.length === 0, `Unknown keys ${unknownKeys.join(', ')} found in ABI args for ${name}`);
assert(isNumber(arg.name) && isString(this.stringAt(arg.name)), `${name} args should have valid name `);
assert(isNumber(arg.name) && isString(this._stringAt(arg.name)), `${name} args should have valid name `);
assert(isNumber(arg.type.ty) && isObject(this.typeDefAt(arg.type.ty)), `${name} args should have valid type`);
});
}
@@ -83,9 +83,9 @@ export default class ContractRegistry extends MetaRegistry {
assert(unknownKeys.length === 0, `Unknown keys ${unknownKeys.join(', ')} found in ABI args for messages.${message.name}`);
const { name, selector, return_type: returnType } = message;
const { name, return_type: returnType, selector } = message;
assert(isNumber(name) && isString(this.stringAt(name)), `Expected name for ${fnname}`);
assert(isNumber(name) && isString(this._stringAt(name)), `Expected name for ${fnname}`);
assert(isNull(returnType) || (isNumber(returnType.ty) && isObject(this.typeDefAt(returnType.ty))), `Expected return_type for ${fnname}`);
parseSelector(this.registry, fnname, selector);
@@ -100,7 +100,7 @@ export default class ContractRegistry extends MetaRegistry {
const { contract: { constructors, messages, name } } = abi;
assert(constructors && messages && isString(this.stringAt(name)), 'ABI should have constructors, messages & name sections');
assert(constructors && messages && isString(this._stringAt(name)), 'ABI should have constructors, messages & name sections');
this.validateConstructors(abi);
this.validateMessages(abi);
@@ -108,14 +108,17 @@ export default class ContractRegistry extends MetaRegistry {
public createMessage (name: string, message: Partial<ContractABIMessage> & ContractABIMessageBase): ContractABIFn {
const args = message.args.map(({ name, type }): ContractABIFnArg => {
assert(isObject(type), `Invalid type at index ${type}`);
assert(isObject(type), `Invalid type at index ${type.toString()}`);
return {
name: stringCamelCase(name),
type
};
});
const Clazz = createArgClass(this.registry, args, isUndefined(message.selector) ? {} : { __selector: 'u32' });
const baseStruct: { [index: string]: any } = { __selector: isUndefined(message.selector) ? undefined : parseSelector(this.registry, name, message.selector) };
const encoder = (...params: CodecArg[]): Uint8Array => {
assert(params.length === args.length, `Expected ${args.length} arguments to contract ${name}, found ${params.length}`);
@@ -136,6 +139,7 @@ export default class ContractRegistry extends MetaRegistry {
fn.args = args;
fn.isConstant = !(message.mutates || false);
fn.type = message.returnType || null;
return fn;
}
@@ -147,19 +151,20 @@ export default class ContractRegistry extends MetaRegistry {
}
public convertArgs (args: ContractABIArgBasePre[]): any[] {
return args.map(({ name, type, ...arg }) => ({ ...arg, name: this.stringAt(name), type: this.convertType(type) }));
return args.map(({ name, type, ...arg }) => ({ ...arg, name: this._stringAt(name), type: this.convertType(type) }));
}
public convertType ({ ty, display_name: displayNameIndices }: ContractABITypePre): TypeDef {
public convertType ({ display_name: displayNameIndices, ty }: ContractABITypePre): TypeDef {
const displayName = this.stringsAt(displayNameIndices).join('::');
return this.typeDefAt(ty, { displayName });
}
public convertContract ({ constructors, messages, name, events, ...contract }: ContractABIContractPre): ContractABIContract {
public convertContract ({ constructors, events, messages, name, ...contract }: ContractABIContractPre): ContractABIContract {
return {
constructors: this.convertConstructors(constructors),
messages: messages.map((message) => this.convertMessage(message)),
name: this.stringAt(name),
name: this._stringAt(name),
...(events
? { events: events.map((event) => this.convertEvent(event)) }
: {}),
@@ -178,14 +183,16 @@ export default class ContractRegistry extends MetaRegistry {
public convertMessage ({ args, name, return_type: returnType, ...message }: ContractABIMessagePre): ContractABIMessage {
return {
...message,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
args: this.convertArgs(args),
name: this.stringAt(name),
name: this._stringAt(name),
returnType: returnType ? this.convertType(returnType) : null
};
}
public convertEvent ({ args }: ContractABIEventPre): ContractABIEvent {
return {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
args: this.convertArgs(args)
};
}
@@ -202,13 +209,13 @@ export default class ContractRegistry extends MetaRegistry {
}
}
public convertStorageStruct ({ 'struct.type': structType, 'struct.fields': structFields }: ContractABIStorageStructPre): ContractABIStorageStruct {
public convertStorageStruct ({ 'struct.fields': structFields, 'struct.type': structType }: ContractABIStorageStructPre): ContractABIStorageStruct {
return {
'struct.type': this.typeDefAt(structType),
'struct.fields': structFields.map(({ name, layout }) => ({
name: this.stringAt(name),
layout: this.convertStorageLayout(layout)
}))
'struct.fields': structFields.map(({ layout, name }) => ({
layout: this.convertStorageLayout(layout),
name: this._stringAt(name)
})),
'struct.type': this.typeDefAt(structType)
};
}
+59 -55
View File
@@ -7,11 +7,11 @@ import { MetaRegistryItem, MetaRegistryJson, MetaTypeDefClikeEnum, MetaType, Met
import { assert } from '@polkadot/util';
import { displayType, withTypeString } from '@polkadot/types';
const builtinMap: [(id: any) => boolean, MetaTypeInfo][] = [
[(id: any): boolean => typeof id === 'string', MetaTypeInfo.BuiltinPlain],
[(id: any): boolean => Array.isArray(id), MetaTypeInfo.BuiltinTuple],
[(id: any): boolean => !!(id['array.type']), MetaTypeInfo.BuiltinVecFixed],
[(id: any): boolean => !!(id['slice.type']), MetaTypeInfo.BuiltinVec]
const builtinMap: [(id: unknown | unknown[] | { 'array.type': unknown } | { 'slice.type': unknown }) => boolean, MetaTypeInfo][] = [
[(id: any) => typeof id === 'string', MetaTypeInfo.BuiltinPlain],
[(id: any) => Array.isArray(id), MetaTypeInfo.BuiltinTuple],
[(id: any) => !!((id as { 'array.type': unknown })['array.type']), MetaTypeInfo.BuiltinVecFixed],
[(id: any) => !!((id as { 'slice.type': unknown })['slice.type']), MetaTypeInfo.BuiltinVec]
];
const typeMap: [string, MetaTypeInfo][] = [
@@ -25,8 +25,8 @@ function detectedType ({ def, id }: MetaType): MetaTypeInfo {
assert(!(def as MetaTypeDefUnion)['union.fields'], 'Invalid union type definition found');
const lookup = def === 'builtin'
? builtinMap.find(([test]): boolean => test(id))
: typeMap.find(([test]): boolean => !!(def as any)[test]);
? builtinMap.find(([test]) => test(id))
: typeMap.find(([test]) => !!(def as unknown as Record<string, unknown>)[test]);
return lookup
? lookup[1]
@@ -48,7 +48,7 @@ class MetadataRegistryLookup {
this._types = types;
}
protected hasItemAt (index: number, variant: MetaRegistryItem): boolean {
protected _hasItemAt (index: number, variant: MetaRegistryItem): boolean {
switch (variant) {
case MetaRegistryItem.String:
return this._strings && !!this._strings[index - 1];
@@ -59,8 +59,8 @@ class MetadataRegistryLookup {
}
}
protected itemAt (index: number, variant: MetaRegistryItem): any {
assert(this.hasItemAt(index, variant), `MetaRegistry: Invalid ${variant} index ${index} found in metadata`);
protected _itemAt (index: number, variant: MetaRegistryItem): string | MetaType | TypeDef {
assert(this._hasItemAt(index, variant), `MetaRegistry: Invalid ${variant} index ${index} found in metadata`);
switch (variant) {
case MetaRegistryItem.String:
@@ -72,33 +72,33 @@ class MetadataRegistryLookup {
}
}
protected itemsAt (indices: number[], variant: MetaRegistryItem): any[] {
return indices.map((index: number): string => this.itemAt(index, variant));
protected _itemsAt (indices: number[], variant: MetaRegistryItem): (string | MetaType | TypeDef)[] {
return indices.map((index: number) => this._itemAt(index, variant));
}
protected stringAt (index: StringIndex): string {
return this.itemAt(index, MetaRegistryItem.String);
protected _stringAt (index: StringIndex): string {
return this._itemAt(index, MetaRegistryItem.String) as string;
}
public stringsAt (indices: StringIndex[]): string[] {
return this.itemsAt(indices, MetaRegistryItem.String);
return this._itemsAt(indices, MetaRegistryItem.String) as string[];
}
public typeAt (index: TypeIndex): MetaType {
return this.itemAt(index, MetaRegistryItem.Type);
return this._itemAt(index, MetaRegistryItem.Type) as MetaType;
}
public typesAt (indices: TypeIndex[]): MetaType[] {
return this.itemsAt(indices, MetaRegistryItem.Type);
return this._itemsAt(indices, MetaRegistryItem.Type) as MetaType[];
}
public hasTypeDefAt (index: TypeIndex): boolean {
return this.hasItemAt(index, MetaRegistryItem.TypeDef);
return this._hasItemAt(index, MetaRegistryItem.TypeDef);
}
public typeDefAt (index: TypeIndex, extra: Pick<TypeDef, never> = {}): TypeDef {
return {
...this.itemAt(index, MetaRegistryItem.TypeDef),
...this._itemAt(index, MetaRegistryItem.TypeDef) as TypeDef,
...extra
};
}
@@ -116,7 +116,7 @@ export default class MetaRegistry extends MetadataRegistryLookup {
this.typeDefs[typeIndex - 1] = this.typeDefFromMetaType(this.typeAt(typeIndex), typeIndex);
}
private typeDefIdFields ({ id }: MetaType): Pick<TypeDef, never> {
private _typeDefIdFields ({ id }: MetaType): Pick<TypeDef, never> {
const { 'custom.name': nameIndex, 'custom.namespace': namespaceIndices, 'custom.params': paramsIndices } = id as MetaTypeIdCustom;
if (!nameIndex) {
@@ -124,7 +124,7 @@ export default class MetaRegistry extends MetadataRegistryLookup {
}
return {
name: this.stringAt(nameIndex),
name: this._stringAt(nameIndex),
...(namespaceIndices && namespaceIndices.length
? { namespace: this.stringsAt(namespaceIndices).join('::') }
: {}
@@ -136,33 +136,33 @@ export default class MetaRegistry extends MetadataRegistryLookup {
};
}
private typeDefDefFields (metaType: MetaType, typeIndex?: TypeIndex): Pick<TypeDef, never> {
private _typeDefDefFields (metaType: MetaType, typeIndex: TypeIndex = -1): Pick<TypeDef, never> {
let typeDef;
switch (detectedType(metaType)) {
case MetaTypeInfo.BuiltinPlain:
typeDef = this.typeDefForBuiltinPlain(metaType.id as string);
typeDef = this._typeDefForBuiltinPlain(metaType.id as string);
break;
case MetaTypeInfo.BuiltinTuple:
typeDef = this.typeDefForBuiltinTuple(metaType.id as TypeIndex[]);
typeDef = this._typeDefForBuiltinTuple(metaType.id as TypeIndex[]);
break;
case MetaTypeInfo.BuiltinVec:
typeDef = this.typeDefForBuiltinVec(metaType.id as MetaTypeIdVec, typeIndex);
typeDef = this._typeDefForBuiltinVec(metaType.id as MetaTypeIdVec, typeIndex);
break;
case MetaTypeInfo.BuiltinVecFixed:
typeDef = this.typeDefForBuiltinVecFixed(metaType.id as MetaTypeIdVecFixed, typeIndex);
typeDef = this._typeDefForBuiltinVecFixed(metaType.id as MetaTypeIdVecFixed, typeIndex);
break;
case MetaTypeInfo.Enum:
typeDef = this.typeDefForEnum(metaType.def as MetaTypeDefEnum, metaType.id as MetaTypeIdCustom, typeIndex);
typeDef = this._typeDefForEnum(metaType.def as MetaTypeDefEnum, metaType.id as MetaTypeIdCustom, typeIndex);
break;
case MetaTypeInfo.ClikeEnum:
typeDef = this.typeDefForClikeEnum(metaType.def as MetaTypeDefClikeEnum);
typeDef = this._typeDefForClikeEnum(metaType.def as MetaTypeDefClikeEnum);
break;
case MetaTypeInfo.Struct:
typeDef = this.typeDefForStruct(metaType.def as MetaTypeDefStruct);
break;
case MetaTypeInfo.TupleStruct:
typeDef = this.typeDefForTupleStruct(metaType.def as MetaTypeDefTupleStruct);
typeDef = this._typeDefForTupleStruct(metaType.def as MetaTypeDefTupleStruct);
break;
case MetaTypeInfo.Null:
default:
@@ -176,8 +176,8 @@ export default class MetaRegistry extends MetadataRegistryLookup {
return withTypeString({
info: TypeDefInfo.Null,
type: '',
...this.typeDefDefFields(metaType, typeIndex),
...this.typeDefIdFields(metaType)
...this._typeDefDefFields(metaType, typeIndex),
...this._typeDefIdFields(metaType)
}) as TypeDef;
}
@@ -189,13 +189,13 @@ export default class MetaRegistry extends MetadataRegistryLookup {
return this.typeDefAt(typeIndex);
}
private typeDefForEnumVariant (variant: MetaTypeDefEnumVariant): Pick<TypeDef, any> {
private _typeDefForEnumVariant (variant: MetaTypeDefEnumVariant): Pick<TypeDef, any> {
const { 'unit_variant.name': unitNameIndex } = variant as MetaTypeDefEnumVariantUnit;
if (unitNameIndex) {
return {
info: TypeDefInfo.Plain,
name: this.stringAt(unitNameIndex),
name: this._stringAt(unitNameIndex),
type: 'Null'
};
}
@@ -203,7 +203,7 @@ export default class MetaRegistry extends MetadataRegistryLookup {
const { 'tuple_struct_variant.name': tupleStructVariantNameIndex } = variant as MetaTypeDefEnumVariantTupleStruct;
if (tupleStructVariantNameIndex) {
return this.typeDefForTupleStruct(variant as MetaTypeDefEnumVariantTupleStruct);
return this._typeDefForTupleStruct(variant as MetaTypeDefEnumVariantTupleStruct);
}
const { 'struct_variant.name': structVariantNameIndex } = variant as MetaTypeDefEnumVariantStruct;
@@ -218,14 +218,14 @@ export default class MetaRegistry extends MetadataRegistryLookup {
};
}
private typeDefForBuiltinPlain (id: string): Pick<TypeDef, never> {
private _typeDefForBuiltinPlain (id: string): Pick<TypeDef, never> {
return {
info: TypeDefInfo.Plain,
type: id
};
}
private typeDefForBuiltinTuple (id: TypeIndex[]): Pick<TypeDef, never> {
private _typeDefForBuiltinTuple (id: TypeIndex[]): Pick<TypeDef, never> {
const sub = id.map((tupleTypeIndex: number): TypeDef => this.typeDefFromMetaTypeAt(tupleTypeIndex));
return {
@@ -234,48 +234,52 @@ export default class MetaRegistry extends MetadataRegistryLookup {
};
}
private typeDefForBuiltinVec (id: MetaTypeIdVec, typeIndex?: TypeIndex): Pick<TypeDef, never> {
private _typeDefForBuiltinVec (id: MetaTypeIdVec, typeIndex: TypeIndex = -1): Pick<TypeDef, never> {
const { 'slice.type': vecTypeIndex } = id;
assert(!typeIndex || vecTypeIndex !== typeIndex, `MetaRegistry: self-referencing registry type at index ${typeIndex}`);
const type = displayType(this.typeDefFromMetaTypeAt(vecTypeIndex));
assert(type && type.length > 0, `MetaRegistry: Invalid builtin Vec type found at index ${typeIndex}`);
return {
info: TypeDefInfo.Vec,
type: `Vec<${type}>`,
sub: this.typeDefFromMetaTypeAt(vecTypeIndex)
sub: this.typeDefFromMetaTypeAt(vecTypeIndex),
type: `Vec<${type}>`
};
}
private typeDefForBuiltinVecFixed (id: MetaTypeIdVecFixed, typeIndex?: TypeIndex): Pick<TypeDef, never> {
const { 'array.type': vecTypeIndex, 'array.len': vecLength } = id;
private _typeDefForBuiltinVecFixed (id: MetaTypeIdVecFixed, typeIndex: TypeIndex = -1): Pick<TypeDef, never> {
const { 'array.len': vecLength, 'array.type': vecTypeIndex } = id;
assert(!vecLength || vecLength <= 256, 'MetaRegistry: Only support for [Type; <length>], where length <= 256');
assert(!typeIndex || vecTypeIndex !== typeIndex, `MetaRegistry: self-referencing registry type at index ${typeIndex}`);
const type = displayType(this.typeDefFromMetaTypeAt(vecTypeIndex));
assert(type && type.length > 0, `MetaRegistry: Invalid vector type found at index ${typeIndex}`);
return {
info: TypeDefInfo.VecFixed,
length: vecLength, // ex: { type: type }
type: `[${type};${vecLength}]`,
sub: this.typeDefFromMetaTypeAt(vecTypeIndex)
sub: this.typeDefFromMetaTypeAt(vecTypeIndex),
type: `[${type};${vecLength}]`
};
}
private typeDefForEnum (def: MetaTypeDefEnum, id: MetaTypeIdCustom, typeIndex?: TypeIndex): Pick<TypeDef, any> {
const name = id && this.stringAt(id['custom.name']);
private _typeDefForEnum (def: MetaTypeDefEnum, id: MetaTypeIdCustom, typeIndex?: TypeIndex): Pick<TypeDef, any> {
const name = id && this._stringAt(id['custom.name']);
switch (name) {
case 'Option':
return this.typeDefForOption(id, typeIndex);
case 'Result':
return this.typeDefForResult(id, typeIndex);
default: {
const sub = def['enum.variants'].map((variant) => this.typeDefForEnumVariant(variant));
const sub = def['enum.variants'].map((variant) => this._typeDefForEnumVariant(variant));
return {
info: TypeDefInfo.Enum,
@@ -285,19 +289,19 @@ export default class MetaRegistry extends MetadataRegistryLookup {
}
}
private typeDefForClikeEnum (def: MetaTypeDefClikeEnum): Pick<TypeDef, never> {
private _typeDefForClikeEnum (def: MetaTypeDefClikeEnum): Pick<TypeDef, never> {
return {
info: TypeDefInfo.Enum,
sub: def['clike_enum.variants'].map(({ name: nameIndex, discriminant }): TypeDef => ({
sub: def['clike_enum.variants'].map(({ discriminant, name: nameIndex }): TypeDef => ({
ext: { discriminant },
info: TypeDefInfo.Plain,
name: this.stringAt(nameIndex),
name: this._stringAt(nameIndex),
type: 'Null'
}))
};
}
public typeDefForOption (id: MetaTypeIdCustom, typeIndex?: TypeIndex): Pick<TypeDef, any> {
public typeDefForOption (id: MetaTypeIdCustom, typeIndex: TypeIndex = -1): Pick<TypeDef, any> {
assert(id['custom.params'] && id['custom.params'][0], `Invalid Option type defined at index ${typeIndex}`);
return {
@@ -306,7 +310,7 @@ export default class MetaRegistry extends MetadataRegistryLookup {
};
}
public typeDefForResult (id: MetaTypeIdCustom, typeIndex?: TypeIndex): Pick<TypeDef, any> {
public typeDefForResult (id: MetaTypeIdCustom, typeIndex: TypeIndex = -1): Pick<TypeDef, any> {
assert(id['custom.params'] && id['custom.params'][0] && id['custom.params'][1], `Invalid Result type defined at index ${typeIndex}`);
return {
@@ -322,24 +326,24 @@ export default class MetaRegistry extends MetadataRegistryLookup {
return withTypeString({
info: TypeDefInfo.Struct,
...(structNameIndex
? { name: this.stringAt(structNameIndex) }
? { name: this._stringAt(structNameIndex) }
: {}
),
sub: structFields.map((field: MetaTypeDefStructField): TypeDef => ({
...this.typeDefFromMetaTypeAt(field.type),
name: this.stringAt(field.name)
name: this._stringAt(field.name)
}))
});
}
private typeDefForTupleStruct (def: MetaTypeDefTupleStruct | MetaTypeDefEnumVariantTupleStruct): Pick<TypeDef, any> {
private _typeDefForTupleStruct (def: MetaTypeDefTupleStruct | MetaTypeDefEnumVariantTupleStruct): Pick<TypeDef, any> {
const tupleStructTypes = (def as MetaTypeDefTupleStruct)['tuple_struct.types'] || (def as MetaTypeDefEnumVariantTupleStruct)['tuple_struct_variant.types'];
const tupleStructNameIndex = (def as MetaTypeDefEnumVariantTupleStruct)['tuple_struct_variant.name'];
return withTypeString({
info: TypeDefInfo.Tuple,
...(tupleStructNameIndex
? { name: this.stringAt(tupleStructNameIndex) }
? { name: this._stringAt(tupleStructNameIndex) }
: {}
),
sub: tupleStructTypes.map((fieldIndex: number, index: number): TypeDef => ({
+4 -3
View File
@@ -47,18 +47,19 @@ export default class Blueprint<ApiType extends ApiTypes> extends BaseWithTx<ApiT
assert(!!this.abi.constructors[constructorIndex], `Specified constructor index ${constructorIndex} does not exist`);
return {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
signAndSend: this.decorateMethod(
(account: IKeyringPair | string | AccountId | Address): BlueprintCreateResultSubscription<ApiType> => {
return this.apiContracts
return this._apiContracts
.create(endowment, maxGas, this.codeHash, this.abi.constructors[constructorIndex](...params))
.signAndSend(account)
.pipe(map(this.createResult));
.pipe(map(this._createResult));
}
)
};
}
private createResult = (result: SubmittableResult): BlueprintCreateResult<ApiType> => {
private _createResult = (result: SubmittableResult): BlueprintCreateResult<ApiType> => {
let contract: Contract<ApiType> | undefined;
if (result.isInBlock) {
+4 -4
View File
@@ -19,7 +19,6 @@ import { BaseWithTx } from './util';
type CodePutCodeResultSubscription<ApiType extends ApiTypes> = Observable<CodePutCodeResult<ApiType>>;
// eslint-disable-next-line @typescript-eslint/interface-name-prefix
export interface CodePutCode<ApiType extends ApiTypes> {
signAndSend (account: IKeyringPair | string | AccountId | Address): CodePutCodeResultSubscription<ApiType>;
}
@@ -46,17 +45,18 @@ export default class Code<ApiType extends ApiTypes> extends BaseWithTx<ApiType>
public createBlueprint = (maxGas: number | BN): CodePutCode<ApiType> => {
return {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
signAndSend: this.decorateMethod(
(account: IKeyringPair | string | AccountId | Address): CodePutCodeResultSubscription<ApiType> =>
this.apiContracts
this._apiContracts
.putCode(maxGas, compactAddLength(this.code))
.signAndSend(account)
.pipe(map(this.createResult))
.pipe(map(this._createResult))
)
};
}
private createResult = (result: ISubmittableResult): CodePutCodeResult<ApiType> => {
private _createResult = (result: ISubmittableResult): CodePutCodeResult<ApiType> => {
let blueprint: Blueprint<ApiType> | undefined;
if (result.isInBlock) {
+22 -22
View File
@@ -4,7 +4,7 @@
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';
@@ -21,7 +21,6 @@ type ContractCallResultSubscription<ApiType extends ApiTypes, CallType extends C
? Observable<ContractCallResult<CallType>>
: Promise<ObsInnerType<ContractCallResult<CallType>>>;
// eslint-disable-next-line @typescript-eslint/interface-name-prefix
export interface ContractCall<ApiType extends ApiTypes, CallType extends ContractCallTypes> {
send (account: IKeyringPair | string | AccountId | Address): ContractCallResultSubscription<ApiType, CallType>;
}
@@ -33,35 +32,42 @@ export type ContractCallResult<CallType extends ContractCallTypes> = CallType ex
export default class Contract<ApiType extends ApiTypes> extends BaseWithTxAndRpcCall<ApiType> {
public readonly 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> {
const { fn, def } = this.getMessage(message);
constructor (api: ApiObject<ApiType>, abi: ContractABIPre | Abi, decorateMethod: DecorateMethod<ApiType>, address: string | AccountId | Address) {
super(api, abi, decorateMethod);
this.address = this.registry.createType('Address', address);
}
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 {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
send: this.decorateMethod(
as === 'rpc' && this.hasRpcContractsCall
? (account: IKeyringPair | string | AccountId | Address): ContractCallResult<'rpc'> =>
this.rpcContractsCall(
this._rpcContractsCall(
this.registry.createType('ContractCallRequest', {
origin: account,
dest: this.address.toString(),
value,
gasLimit,
inputData: fn(...params)
inputData: fn(...params),
origin: account,
value
})
).pipe(map((result: ContractExecResult): ContractCallOutcome =>
this.createOutcome(result, this.registry.createType('AccountId', account), def, params)
this._createOutcome(result, this.registry.createType('AccountId', account), def, params)
))
: (account: IKeyringPair | string | AccountId | Address): ContractCallResult<'tx'> =>
this.apiContracts
this._apiContracts
.call(this.address, value, gasLimit, fn(...params))
.signAndSend(account)
)
};
}
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) {
@@ -73,19 +79,13 @@ export default class Contract<ApiType extends ApiTypes> extends BaseWithTxAndRpc
}
return {
time: Date.now(),
isSuccess: result.isSuccess,
message,
origin,
output,
params,
result,
isSuccess: result.isSuccess,
output
time: Date.now()
};
}
constructor (api: ApiObject<ApiType>, abi: ContractABIPre | Abi, decorateMethod: DecorateMethod<ApiType>, address: string | AccountId | Address) {
super(api, abi, decorateMethod);
this.address = this.registry.createType('Address', address);
}
}
+7 -6
View File
@@ -31,9 +31,9 @@ export abstract class Base<ApiType extends ApiTypes> implements ContractBase<Api
public get messages (): ContractMessage[] {
return this.abi.abi.contract.messages.map(
(def: ContractABIMessage, index): ContractMessage => ({
index,
def,
fn: this.abi.messages[def.name] || this.abi.messages[stringCamelCase(name)]
fn: this.abi.messages[def.name] || this.abi.messages[stringCamelCase(name)],
index
})
);
}
@@ -46,15 +46,16 @@ export abstract class Base<ApiType extends ApiTypes> implements ContractBase<Api
: 0;
const def = this.abi.abi.contract.messages[index];
assert(!!def, `Attempted to access a contract message that does not exist: ${typeof nameOrIndex === 'number' ? `index ${nameOrIndex}` : nameOrIndex}`);
assert(!!def, `Attempted to access a contract message that does not exist: ${typeof nameOrIndex === 'number' ? `index ${nameOrIndex}` : (nameOrIndex || 'unknown')}`);
const fn = this.abi.messages[def.name] || this.abi.messages[stringCamelCase(def.name)];
return { index, def, fn };
return { def, fn, index };
}
}
export abstract class BaseWithTx<ApiType extends ApiTypes> extends Base<ApiType> {
protected get apiContracts (): SubmittableModuleExtrinsics<'rxjs'> {
protected get _apiContracts (): SubmittableModuleExtrinsics<'rxjs'> {
return this.api.rx.tx.contracts;
}
@@ -70,7 +71,7 @@ export abstract class BaseWithTxAndRpcCall<ApiType extends ApiTypes> extends Bas
return isFunction(this.api.rx.rpc.contracts?.call);
}
protected get rpcContractsCall (): DecoratedRpc<'rxjs', RpcInterface>['contracts']['call'] {
protected get _rpcContractsCall (): DecoratedRpc<'rxjs', RpcInterface>['contracts']['call'] {
assert(this.hasRpcContractsCall, 'You need to connect to a node with the contracts.call RPC method.');
return this.api.rx.rpc.contracts.call;
+3
View File
@@ -23,6 +23,7 @@ export interface ContractBase<ApiType extends ApiTypes> {
export interface ContractABITypePre {
ty: TypeIndex;
// eslint-disable-next-line camelcase
display_name: StringIndex[];
}
@@ -56,6 +57,7 @@ export interface ContractABIMessageCommon {
export interface ContractABIMessagePre extends ContractABIMessageCommon, ContractABIMessageBasePre {
name: StringIndex;
// eslint-disable-next-line camelcase
return_type: ContractABITypePre | null;
}
@@ -187,6 +189,7 @@ export interface InterfaceAbi {
}
export interface InterfaceContractCalls {
// eslint-disable-next-line @typescript-eslint/ban-types
[index: string]: Function;
}
+11 -11
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-derive",
"version": "1.9.1",
"version": "1.31.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.9.2",
"@polkadot/api": "1.9.1",
"@polkadot/rpc-core": "1.9.1",
"@polkadot/rpc-provider": "1.9.1",
"@polkadot/types": "1.9.1",
"@polkadot/util": "^2.7.1",
"@polkadot/util-crypto": "^2.7.1",
"bn.js": "^5.1.1",
"@babel/runtime": "^7.11.2",
"@polkadot/api": "1.31.1",
"@polkadot/rpc-core": "1.31.1",
"@polkadot/rpc-provider": "1.31.1",
"@polkadot/types": "1.31.1",
"@polkadot/util": "^3.4.1",
"@polkadot/util-crypto": "^3.4.1",
"bn.js": "^5.1.3",
"memoizee": "^0.4.14",
"rxjs": "^6.5.4"
"rxjs": "^6.6.2"
},
"devDependencies": {
"@polkadot/keyring": "^2.7.1"
"@polkadot/keyring": "^3.4.1"
}
}
+69
View File
@@ -0,0 +1,69 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { ApiInterfaceRx } from '@polkadot/api/types';
import { AccountId, Address, Balance } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
import { DeriveAccountFlags } from '../types';
import { Observable, combineLatest, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { Vec } from '@polkadot/types';
import { memo } from '../util';
type FlagsIntermediate = [
Vec<ITuple<[AccountId, Balance]>> | undefined,
AccountId[],
AccountId[],
AccountId[],
AccountId | undefined
];
function isIncludedFn (accountId: AccountId | Address | string): (_: AccountId | Address |string) => boolean {
return function (id: AccountId | Address | string): boolean {
return id.toString() === accountId.toString();
};
}
/**
* @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> => {
const councilSection = api.query.electionsPhragmen ? 'electionsPhragmen' : 'elections';
return (
combineLatest([
address && api.query[councilSection]?.members
? api.query[councilSection].members()
: of(undefined),
address && api.query.council?.members
? api.query.council.members()
: of([]),
address && api.query.technicalCommittee?.members
? api.query.technicalCommittee.members()
: of([]),
address && api.query.society?.members
? api.query.society.members()
: of([]),
address && api.query.sudo?.key
? api.query.sudo.key()
: of(undefined)
]) as Observable<FlagsIntermediate>
).pipe(
map(([electionsMembers, councilMembers, technicalCommitteeMembers, societyMembers, sudoKey]): DeriveAccountFlags => {
const isIncluded = address ? isIncludedFn(address) : (): boolean => false;
return {
isCouncil: (electionsMembers?.map(([id]: ITuple<[AccountId, Balance]>) => id) || councilMembers || []).some(isIncluded),
isSociety: (societyMembers || []).some(isIncluded),
isSudo: sudoKey?.toString() === address?.toString(),
isTechCommittee: (technicalCommitteeMembers || []).some(isIncluded)
};
})
);
});
}
@@ -3,6 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
import { AccountIdAndIndex } from '../types';
import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
@@ -12,8 +13,6 @@ import { decodeAddress } from '@polkadot/util-crypto';
import { memo } from '../util';
export type AccountIdAndIndex = [AccountId?, AccountIndex?];
function retrieve (api: ApiInterfaceRx, address: Address | AccountId | AccountIndex | string | null | undefined): Observable<AccountIdAndIndex> {
try {
// yes, this can fail, don't care too much, catch will catch it
@@ -31,7 +30,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) {
@@ -2,6 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
export * from './flags';
export * from './idAndIndex';
export * from './idToIndex';
export * from './indexToId';
@@ -10,6 +10,7 @@ import { map, startWith } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { ENUMSET_SIZE } from '@polkadot/types/generic/AccountIndex';
import { Option, Vec } from '@polkadot/types';
import { isFunction } from '@polkadot/util';
import { memo } from '../util';
@@ -51,7 +52,7 @@ 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> =>
api.query.indices
? api.query.indices.accounts
? isFunction(api.query.indices.accounts)
? query(api, accountIndex)
: queryEnumSet(api, accountIndex)
: of(undefined)
+18 -6
View File
@@ -10,11 +10,14 @@ import { Observable, of } from 'rxjs';
import { map, startWith, switchMap } from 'rxjs/operators';
import { ENUMSET_SIZE } from '@polkadot/types/generic/AccountIndex';
import { Vec } from '@polkadot/types';
import { isFunction } from '@polkadot/util';
import { 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
@@ -71,11 +74,20 @@ function queryAccounts (api: ApiInterfaceRx): Observable<AccountIndexes> {
*/
export function indexes (api: ApiInterfaceRx): () => Observable<AccountIndexes> {
return memo((): Observable<AccountIndexes> =>
(api.query.indices
? api.query.indices.accounts
? queryAccounts(api)
: queryEnumSet(api)
: of({} as AccountIndexes)
).pipe(startWith({}))
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;
})
)
);
}
+10 -50
View File
@@ -5,11 +5,11 @@
import { ApiInterfaceRx } from '@polkadot/api/types';
import { AccountId, AccountIndex, Address, Balance, Registration } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
import { DeriveAccountFlags, DeriveAccountInfo, DeriveAccountRegistration } from '../types';
import { DeriveAccountInfo, DeriveAccountRegistration } from '../types';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { Bytes, Data, Option, u32, Vec } from '@polkadot/types';
import { Bytes, Data, Option, u32 } from '@polkadot/types';
import { u8aToString } from '@polkadot/util';
import { memo } from '../util';
@@ -17,15 +17,9 @@ import { memo } from '../util';
function dataAsString (data: Data): string | undefined {
return data.isRaw
? u8aToString(data.asRaw.toU8a(true))
: data.isSha256
? data.asSha256.toHex()
: undefined;
}
function includedWrapper (accountId?: AccountId): (_: AccountId) => boolean {
return function (id: AccountId): boolean {
return id.eq(accountId);
};
: data.isNone
? undefined
: data.toHex();
}
function retrieveNick (api: ApiInterfaceRx, accountId?: AccountId): Observable<string | undefined> {
@@ -59,6 +53,7 @@ function extractIdentity (identityOfOpt?: Option<Registration>, superOf?: [Accou
: undefined,
email: dataAsString(info.email),
image: dataAsString(info.image),
judgements,
legal: dataAsString(info.legal),
other: info.additional.reduce((other: Record<string, string>, [_key, _value]): Record<string, string> => {
const key = dataAsString(_key);
@@ -78,8 +73,7 @@ function extractIdentity (identityOfOpt?: Option<Registration>, superOf?: [Accou
: undefined,
riot: dataAsString(info.riot),
twitter: dataAsString(info.twitter),
web: dataAsString(info.web),
judgements
web: dataAsString(info.web)
};
}
@@ -115,39 +109,6 @@ function retrieveIdentity (api: ApiInterfaceRx, accountId?: AccountId): Observab
);
}
function retrieveFlags (api: ApiInterfaceRx, accountId?: AccountId): Observable<DeriveAccountFlags> {
const councilSection = api.query.electionsPhragmen ? 'electionsPhragmen' : 'elections';
return combineLatest([
api.query[councilSection]?.members
? api.query[councilSection].members<Vec<ITuple<[AccountId, Balance]>>>()
: of(undefined),
api.query.council?.members
? api.query.council.members()
: of([]),
api.query.technicalCommittee?.members
? api.query.technicalCommittee.members()
: of([]),
api.query.society?.members
? api.query.society.members()
: of([]),
api.query.sudo?.key
? api.query.sudo.key()
: of(undefined)
]).pipe(
map(([electionsMembers, councilMembers, technicalCommitteeMembers, societyMembers, sudoKey]): DeriveAccountFlags => {
const checkIncluded = includedWrapper(accountId);
return {
isCouncil: (electionsMembers?.map(([id]) => id) || councilMembers || []).some(checkIncluded),
isTechCommittee: technicalCommitteeMembers.some(checkIncluded),
isSociety: societyMembers.some(checkIncluded),
isSudo: !!sudoKey && sudoKey.eq(accountId)
};
})
);
}
/**
* @name info
* @description Returns aux. info with regards to an account, current that includes the accountId, accountIndex and nickname
@@ -155,16 +116,15 @@ function retrieveFlags (api: ApiInterfaceRx, accountId?: AccountId): Observable<
export function info (api: ApiInterfaceRx): (address?: AccountIndex | AccountId | Address | string | null) => Observable<DeriveAccountInfo> {
return memo((address?: AccountIndex | AccountId | Address | string | null): Observable<DeriveAccountInfo> =>
api.derive.accounts.idAndIndex(address).pipe(
switchMap(([accountId, accountIndex]): Observable<[Partial<DeriveAccountInfo>, DeriveAccountFlags, DeriveAccountRegistration, string?]> =>
switchMap(([accountId, accountIndex]): Observable<[Partial<DeriveAccountInfo>, DeriveAccountRegistration, string?]> =>
combineLatest([
of({ accountId, accountIndex }),
retrieveFlags(api, accountId),
retrieveIdentity(api, accountId),
retrieveNick(api, accountId)
])
),
map(([{ accountId, accountIndex }, flags, identity, nickname]): DeriveAccountInfo => ({
accountId, accountIndex, ...flags, identity, nickname
map(([{ accountId, accountIndex }, identity, nickname]): DeriveAccountInfo => ({
accountId, accountIndex, identity, nickname
}))
));
}
+38
View File
@@ -0,0 +1,38 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, AccountIndex, RegistrationJudgement } from '@polkadot/types/interfaces';
export type AccountIdAndIndex = [AccountId?, AccountIndex?];
export type AccountIndexes = Record<string, AccountIndex>;
export interface DeriveAccountRegistration {
display?: string;
displayParent?: string;
email?: string;
image?: string;
legal?: string;
other?: Record<string, string>;
parent?: AccountId;
pgp?: string;
riot?: string;
twitter?: string;
web?: string;
judgements: RegistrationJudgement[];
}
export interface DeriveAccountFlags {
isCouncil: boolean;
isSociety: boolean;
isSudo: boolean;
isTechCommittee: boolean;
}
export interface DeriveAccountInfo {
accountId?: AccountId;
accountIndex?: AccountIndex;
identity: DeriveAccountRegistration;
nickname?: string;
}
+6 -5
View File
@@ -9,6 +9,7 @@ import { DeriveBalancesAccount } from '../types';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { isFunction } from '@polkadot/util';
import { memo } from '../util';
@@ -22,7 +23,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())
};
}
@@ -44,7 +45,7 @@ function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId): Obser
[api.query.balances.account, accountId],
[api.query.system.accountNonce, accountId]
]).pipe(
map(([{ free, reserved, miscFrozen, feeFrozen }, accountNonce]): Result =>
map(([{ feeFrozen, free, miscFrozen, reserved }, accountNonce]): Result =>
[free, reserved, feeFrozen, miscFrozen, accountNonce]
)
);
@@ -54,7 +55,7 @@ function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Re
// AccountInfo is current, support old, eg. Edgeware
return api.query.system.account<AccountInfo | ITuple<[Index, AccountData]>>(accountId).pipe(
map((infoOrTuple): Result => {
const { free, reserved, miscFrozen, feeFrozen } = (infoOrTuple as AccountInfo).nonce
const { feeFrozen, free, miscFrozen, reserved } = (infoOrTuple as AccountInfo).nonce
? (infoOrTuple as AccountInfo).data
: (infoOrTuple as [Index, AccountData])[1];
const accountNonce = (infoOrTuple as AccountInfo).nonce || (infoOrTuple as [Index, AccountData])[0];
@@ -86,9 +87,9 @@ export function account (api: ApiInterfaceRx): (address: AccountIndex | AccountI
(accountId
? combineLatest([
of(accountId),
api.query.system.account
isFunction(api.query.system.account)
? queryCurrent(api, accountId)
: api.query.balances.account
: isFunction(api.query.balances.account)
? queryBalancesAccount(api, accountId)
: queryBalancesFree(api, accountId)
])
+15 -17
View File
@@ -10,25 +10,29 @@ import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Option, Vec } from '@polkadot/types';
import { bnMax } from '@polkadot/util';
import { bnMax, isFunction } from '@polkadot/util';
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 +45,11 @@ 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)));
return {
accountId,
@@ -67,6 +63,8 @@ function calcBalances (api: ApiInterfaceRx, [{ accountId, accountNonce, freeBala
lockedBreakdown,
reservedBalance,
vestedBalance,
vestedClaimable,
vestingLocked,
vestingTotal,
votingBalance
};
@@ -135,7 +133,7 @@ export function all (api: ApiInterfaceRx): (address: AccountIndex | AccountId |
? combineLatest([
of(account),
api.derive.chain.bestNumber(),
api.query.balances.account
isFunction(api.query.system.account) || isFunction(api.query.balances.account)
? queryCurrent(api, account.accountId)
: queryOld(api, account.accountId)
])
+3 -3
View File
@@ -28,12 +28,12 @@ export function fees (api: ApiInterfaceRx): () => Observable<DeriveFees> {
return memo((): Observable<DeriveFees> =>
of([
// deprecated - remove
(api.consts.balances?.creationFee as Balance) || api.registry.createType('Balance'),
(api.consts.balances?.transferFee as Balance) || api.registry.createType('Balance'),
(api.consts.balances?.creationFee as unknown as Balance) || api.registry.createType('Balance'),
(api.consts.balances?.transferFee as unknown as Balance) || api.registry.createType('Balance'),
// current
(api.consts.balances?.existentialDeposit as Balance) || api.registry.createType('Balance'),
(api.consts.transactionPayment?.transactionBaseFee as Balance) || api.registry.createType('Balance'),
(api.consts.transactionPayment?.transactionBaseFee as unknown as Balance) || api.registry.createType('Balance'),
(api.consts.transactionPayment?.transactionByteFee as Balance) || api.registry.createType('Balance')
]).pipe(
map(([creationFee, transferFee, existentialDeposit, transactionBaseFee, transactionByteFee]): DeriveFees => ({
+1 -1
View File
@@ -11,7 +11,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
@@ -9,6 +9,9 @@ import { DeriveCollectiveProposal } from '../types';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { Option } from '@polkadot/types';
import { isFunction } from '@polkadot/util';
import { memo } from '../util';
type Result = [Hash[], Option<Proposal>[], Option<Votes>[]];
@@ -27,8 +30,8 @@ function parse ([hashes, proposals, votes]: Result): DeriveCollectiveProposal[]
}
export function proposals (api: ApiInterfaceRx, section: 'council' | 'technicalCommittee'): () => Observable<DeriveCollectiveProposal[]> {
return (): Observable<DeriveCollectiveProposal[]> =>
api.query[section]?.proposals
return memo((): Observable<DeriveCollectiveProposal[]> =>
isFunction(api.query[section]?.proposals)
? api.query[section].proposals().pipe(
switchMap((hashes: Hash[]): Observable<Result> =>
hashes.length
@@ -41,5 +44,6 @@ export function proposals (api: ApiInterfaceRx, section: 'council' | 'technicalC
),
map(parse)
)
: of([] as DeriveCollectiveProposal[]);
: of([] as DeriveCollectiveProposal[])
);
}
+9 -7
View File
@@ -11,23 +11,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>;
}
@@ -47,12 +48,13 @@ function queryConstants (api: ApiInterfaceRx): Observable<ResultV2> {
export function fees (api: ApiInterfaceRx): () => Observable<DeriveContractFees> {
return memo((): 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,
+5 -3
View File
@@ -11,6 +11,8 @@ import { Observable, combineLatest } from 'rxjs';
import { map } from 'rxjs/operators';
import { Vec } from '@polkadot/types';
import { memo } from '../util';
function retrieveStakeOf (api: ApiInterfaceRx): Observable<[AccountId, Balance][]> {
const elections = (api.query.electionsPhragmen || api.query.elections);
@@ -80,9 +82,9 @@ function retrieveCurrent (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
}
export function votes (api: ApiInterfaceRx): () => Observable<DeriveCouncilVotes> {
// since we are using entries, we are not adding a memo
return (): Observable<DeriveCouncilVotes> =>
return memo((): Observable<DeriveCouncilVotes> =>
(api.query.electionsPhragmen || api.query.elections).stakeOf
? retrievePrev(api)
: retrieveCurrent(api);
: retrieveCurrent(api)
);
}
+4 -3
View File
@@ -8,10 +8,10 @@ import { DeriveCouncilVote } from '../types';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { memo } from '../util';
export function votesOf (api: ApiInterfaceRx): (accountId: string | Uint8Array | AccountId) => Observable<DeriveCouncilVote> {
// no memo, votes actually pulls the entries without a memo (using entries)
return (accountId: string | Uint8Array | AccountId): Observable<DeriveCouncilVote> =>
return memo((accountId: string | Uint8Array | AccountId): Observable<DeriveCouncilVote> =>
api.derive.council.votes().pipe(
map((votes): DeriveCouncilVote =>
(
@@ -19,5 +19,6 @@ export function votesOf (api: ApiInterfaceRx): (accountId: string | Uint8Array |
[null, { stake: api.registry.createType('Balance'), votes: [] as AccountId[] }]
)[1]
)
);
)
);
}
@@ -1,32 +0,0 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { ApiInterfaceRx } from '@polkadot/api/types';
import { ReferendumInfo, ReferendumInfoTo239 } from '@polkadot/types/interfaces';
import { DeriveReferendum } from '../types';
import BN from 'bn.js';
import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { Option } from '@polkadot/types';
import { memo } from '../util';
import { getStatus, parseImage } from './util';
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> => {
const status = getStatus(info);
return status
? api.query.democracy.preimages(status.proposalHash).pipe(
map((preimage): DeriveReferendum => ({
index: api.registry.createType('ReferendumIndex', index),
image: parseImage(api, preimage),
imageHash: status.proposalHash,
status
}))
)
: of(null);
});
}
@@ -1,84 +0,0 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { ApiInterfaceRx } from '@polkadot/api/types';
import { AccountId, Vote, Voting, VotingDirectVote } from '@polkadot/types/interfaces';
import { DeriveBalancesAccount, DeriveReferendum, DeriveReferendumVote, DeriveReferendumVotes } from '../types';
import BN from 'bn.js';
import { Observable, of, combineLatest } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { Vec } from '@polkadot/types';
import { memo } from '../util';
import { calcVotes } from './util';
function votesPrev (api: ApiInterfaceRx, referendumId: BN): Observable<DeriveReferendumVote[]> {
return api.query.democracy.votersFor<Vec<AccountId>>(referendumId).pipe(
switchMap((votersFor): Observable<[Vec<AccountId>, Vote[], DeriveBalancesAccount[]]> =>
combineLatest([
of(votersFor),
votersFor.length
? api.query.democracy.voteOf.multi<Vote>(
votersFor.map((accountId): [BN | number, AccountId] =>
[referendumId, accountId]
)
)
: of([]),
api.derive.balances.votingBalances(votersFor)
])
),
map(([votersFor, votes, balances]): DeriveReferendumVote[] =>
votersFor.map((accountId, index): DeriveReferendumVote => ({
accountId,
balance: balances[index].votingBalance || api.registry.createType('Balance'),
vote: votes[index] || api.registry.createType('Vote')
}))
)
);
}
function votesCurr (api: ApiInterfaceRx, referendumId: BN): Observable<DeriveReferendumVote[]> {
return api.query.democracy.votingOf.entries<Voting>().pipe(
map((allVoting): DeriveReferendumVote[] =>
allVoting
.map(([key, voting]): [AccountId, Voting] => [key.args[0] as AccountId, voting])
// FIXME We are ignoring delegated votes
.filter(([, voting]) => voting.isDirect)
.map(([accountId, voting]): [AccountId, VotingDirectVote[]] => [
accountId,
voting.asDirect.votes.filter(([idx]) => idx.eq(referendumId))
])
.filter(([, directVotes]) => !!directVotes.length)
.reduce((result: DeriveReferendumVote[], [accountId, votes]) =>
// FIXME We are ignoring split votes
votes.reduce((result: DeriveReferendumVote[], [, vote]): DeriveReferendumVote[] => {
if (vote.isStandard) {
result.push({
accountId,
...vote.asStandard
});
}
return result;
}, result), []
)
)
);
}
export function _referendumVotes (api: ApiInterfaceRx): (referendum: DeriveReferendum) => Observable<DeriveReferendumVotes> {
return memo((referendum: DeriveReferendum): Observable<DeriveReferendumVotes> =>
combineLatest([
api.derive.democracy.sqrtElectorate(),
api.query.democracy.votingOf
? votesCurr(api, referendum.index)
: votesPrev(api, referendum.index)
]).pipe(
map(([sqrtElectorate, votes]) =>
calcVotes(sqrtElectorate, referendum, votes)
)
)
);
}
@@ -1,22 +0,0 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { ApiInterfaceRx } from '@polkadot/api/types';
import { DeriveReferendum, DeriveReferendumVotes } from '../types';
import { Observable, of, combineLatest } from 'rxjs';
import { memo } from '../util';
export function _referendumsVotes (api: ApiInterfaceRx): (referendums: DeriveReferendum[]) => Observable<DeriveReferendumVotes[]> {
return memo((referendums: DeriveReferendum[]): Observable<DeriveReferendumVotes[]> =>
referendums.length
? combineLatest(
referendums.map((referendum): Observable<DeriveReferendumVotes> =>
api.derive.democracy._referendumVotes(referendum)
)
)
: of([])
);
}
@@ -2,37 +2,104 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { BlockNumber, Hash, ReferendumIndex } from '@polkadot/types/interfaces';
import { BlockNumber, Hash, ReferendumIndex, Scheduled } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
import { DeriveDispatch } from '../types';
import { DeriveDispatch, DeriveProposalImage } from '../types';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Vec } from '@polkadot/types';
import { Option, Vec, u64 } from '@polkadot/types';
import { isFunction, stringToHex } from '@polkadot/util';
import { memo } from '../util';
export function dispatchQueue (api: ApiInterfaceRx): () => Observable<DeriveDispatch[]> {
return memo((): Observable<DeriveDispatch[]> =>
api.query.democracy?.dispatchQueue
? api.query.democracy.dispatchQueue<Vec<ITuple<[BlockNumber, Hash, ReferendumIndex]>>>().pipe(
switchMap((dispatches) =>
combineLatest([
of(dispatches),
api.derive.democracy.preimages(
dispatches.map(([, hash]) => hash))
])
),
map(([dispatches, images]) =>
dispatches.map(([at, imageHash, index], dispatchIndex): DeriveDispatch => ({
at,
index,
image: images[dispatchIndex],
imageHash
}))
)
)
: of([])
const DEMOCRACY_ID = stringToHex('democrac');
interface SchedulerInfo {
at: BlockNumber;
imageHash: Hash;
index: ReferendumIndex;
}
function queryQueue (api: ApiInterfaceRx): Observable<DeriveDispatch[]> {
return api.query.democracy.dispatchQueue<Vec<ITuple<[BlockNumber, Hash, ReferendumIndex]>>>().pipe(
switchMap((dispatches) =>
combineLatest([
of(dispatches),
api.derive.democracy.preimages(
dispatches.map(([, hash]) => hash))
])
),
map(([dispatches, images]) =>
dispatches.map(([at, imageHash, index], dispatchIndex): DeriveDispatch => ({
at,
image: images[dispatchIndex],
imageHash,
index
}))
)
);
}
function schedulerEntries (api: ApiInterfaceRx): Observable<[BlockNumber[], Option<Scheduled>[][]]> {
// We don't get entries, but rather we get the keys (triggered via finished referendums) and
// the subscribe to those keys - this means we pickup when the schedulers actually executes
// at a block, the entry for that block will become empty
return api.derive.democracy.referendumsFinished().pipe(
switchMap(() =>
api.query.scheduler.agenda.keys()
),
switchMap((keys) => {
const blockNumbers = keys.map((key) => key.args[0] as BlockNumber);
return combineLatest([
of(blockNumbers),
api.query.scheduler.agenda.multi<Vec<Option<Scheduled>>>(blockNumbers)
]);
})
);
}
function queryScheduler (api: ApiInterfaceRx): Observable<DeriveDispatch[]> {
return schedulerEntries(api).pipe(
switchMap(([blockNumbers, agendas]): Observable<[SchedulerInfo[], (DeriveProposalImage | undefined)[]]> => {
const result: SchedulerInfo[] = [];
blockNumbers.forEach((at, index): void => {
agendas[index].filter((optScheduled) => optScheduled.isSome).forEach((optScheduled): void => {
const scheduled = optScheduled.unwrap();
if (scheduled.maybeId.isSome) {
const id = scheduled.maybeId.unwrap().toHex();
if (id.startsWith(DEMOCRACY_ID)) {
const [, index] = api.registry.createType('(u64, ReferendumIndex)' as any, id) as ITuple<[u64, ReferendumIndex]>;
const imageHash = scheduled.call.args[0] as Hash;
result.push({ at, imageHash, index });
}
}
});
});
return combineLatest([
of(result),
api.derive.democracy.preimages(result.map(({ imageHash }) => imageHash))
]);
}),
map(([infos, images]): DeriveDispatch[] =>
infos.map((info, index) => ({ ...info, image: images[index] }))
)
);
}
export function dispatchQueue (api: ApiInterfaceRx): () => Observable<DeriveDispatch[]> {
return memo((): Observable<DeriveDispatch[]> =>
isFunction(api.query.scheduler?.agenda)
? queryScheduler(api)
: api.query.democracy.dispatchQueue
? queryQueue(api)
: of([])
);
}
+3 -3
View File
@@ -2,15 +2,15 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
export * from './_referendumsVotes';
export * from './_referendumVotes';
export * from './_referendumInfo';
export * from './dispatchQueue';
export * from './locks';
export * from './nextExternal';
export * from './preimage';
export * from './preimages';
export * from './proposals';
export * from './referendumIds';
export * from './referendums';
export * from './referendumsActive';
export * from './referendumsFinished';
export * from './referendumsInfo';
export * from './sqrtElectorate';
@@ -0,0 +1,89 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, ReferendumInfo, ReferendumInfoTo239, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { DeriveDemocracyLock } from '../types';
import BN from 'bn.js';
import { Observable, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { Option } from '@polkadot/types';
import { isUndefined } from '@polkadot/util';
import { memo } from '../util';
const LOCKUPS = [0, 1, 2, 4, 8, 16, 32];
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, 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[]> {
if (!votes.length) {
return of([]);
}
return api.query.democracy.referendumInfoOf.multi<Option<ReferendumInfo | ReferendumInfoTo239>>(votes.map(([referendumId]) => referendumId)).pipe(
map((referendums) =>
votes
.map((vote, index): [VotingDirectVote, ReferendumInfo | ReferendumInfoTo239 | null] =>
[vote, referendums[index].unwrapOr(null)]
)
.filter((item): item is [VotingDirectVote, ReferendumInfo] =>
!!item[1] && isUndefined((item[1] as ReferendumInfoTo239).end) && item[0][1].isStandard
)
.map(([directVote, referendum]) =>
parseLock(api, directVote, referendum)
)
)
);
}
export function locks (api: ApiInterfaceRx): (accountId: string | AccountId) => Observable<DeriveDemocracyLock[]> {
return memo((accountId: string | AccountId): Observable<DeriveDemocracyLock[]> =>
api.query.democracy.votingOf(accountId).pipe(
switchMap((voting): Observable<DeriveDemocracyLock[]> =>
voting.isDirect
? directLocks(api, voting.asDirect)
: voting.isDelegating
? delegateLocks(api, voting.asDelegating)
: of([])
)
)
);
}
@@ -17,8 +17,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((hashes: Hash[]): Observable<DeriveProposalImage | undefined> =>
api.query.democracy.preimages<PreImage>(hashes).pipe(
return memo((hash: Hash): Observable<DeriveProposalImage | undefined> =>
api.query.democracy.preimages<PreImage>(hash).pipe(
map((imageOpt) => parseImage(api, imageOpt))
)
);
@@ -20,9 +20,7 @@ export function preimages (api: ApiInterfaceRx): (hashes: Hash[]) => Observable<
return memo((hashes: Hash[]): Observable<(DeriveProposalImage | undefined)[]> =>
api.query.democracy.preimages.multi<PreImage>(hashes).pipe(
map((images): (DeriveProposalImage | undefined)[] =>
images.map((imageOpt) =>
parseImage(api, imageOpt)
)
images.map((imageOpt) => parseImage(api, imageOpt))
)
)
);
+22 -8
View File
@@ -10,27 +10,41 @@ import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Option, Vec } from '@polkadot/types';
import { isFunction } from '@polkadot/util';
import { memo } from '../util';
type Depositors = Option<ITuple<[Balance, Vec<AccountId>]>>;
type DepositorsNew = Option<ITuple<[Vec<AccountId>, Balance]>>;
type DepositorsOld = Option<ITuple<[Balance, Vec<AccountId>]>>;
type Depositors = DepositorsNew | DepositorsOld;
type Proposals = Vec<ITuple<[PropIndex, Hash, AccountId]>>;
type Result = [Proposals, (DeriveProposalImage | undefined)[], Depositors[]];
function parse ([proposals, images, depositors]: [Proposals, (DeriveProposalImage | undefined)[], Depositors[]]): DeriveProposal[] {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function isNewDepositors (depositors: ITuple<[Vec<AccountId>, Balance]> | ITuple<[Balance, Vec<AccountId>]>): depositors is ITuple<[Vec<AccountId>, Balance]> {
// Detect balance...
// eslint-disable-next-line @typescript-eslint/unbound-method
return isFunction((depositors[1] as Balance).mul);
}
function parse ([proposals, images, optDepositors]: Result): DeriveProposal[] {
return proposals
.filter(([, , proposer], index): boolean =>
!!(depositors[index]?.isSome) && !proposer.isEmpty
!!(optDepositors[index]?.isSome) && !proposer.isEmpty
)
.map(([index, imageHash, proposer], proposalIndex): DeriveProposal => {
const [balance, seconds] = depositors[proposalIndex].unwrap();
const depositors = optDepositors[proposalIndex].unwrap();
return {
balance,
index,
...(
isNewDepositors(depositors)
? { balance: depositors[1], seconds: depositors[0] }
: { balance: depositors[0], seconds: depositors[1] }
),
image: images[proposalIndex],
imageHash,
proposer,
seconds
index,
proposer
};
});
}
@@ -0,0 +1,30 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { ApiInterfaceRx } from '@polkadot/api/types';
import { ReferendumIndex } from '@polkadot/types/interfaces';
import BN from 'bn.js';
import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { memo } from '../util';
export function referendumIds (api: ApiInterfaceRx): () => Observable<BN[]> {
return memo((): Observable<BN[]> =>
api.query.democracy?.lowestUnbaked
? api.queryMulti<[ReferendumIndex, ReferendumIndex]>([
api.query.democracy.lowestUnbaked,
api.query.democracy.referendumCount
]).pipe(
map(([first, total]): BN[] =>
total.gt(first)
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
? [...Array(total.sub(first).toNumber())].map((_, i): BN => first.addn(i))
: []
)
)
: of([])
);
}
@@ -3,10 +3,8 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { ApiInterfaceRx } from '@polkadot/api/types';
import { ReferendumIndex } from '@polkadot/types/interfaces';
import { DeriveReferendum } from '../types';
import BN from 'bn.js';
import { Observable, of } from 'rxjs';
import { switchMap } from 'rxjs/operators';
@@ -14,19 +12,12 @@ import { memo } from '../util';
export function referendumsActive (api: ApiInterfaceRx): () => Observable<DeriveReferendum[]> {
return memo((): Observable<DeriveReferendum[]> =>
api.query.democracy?.lowestUnbaked
? api.queryMulti<[ReferendumIndex, ReferendumIndex]>([
api.query.democracy.lowestUnbaked,
api.query.democracy.referendumCount
]).pipe(
switchMap(([first, total]): Observable<DeriveReferendum[]> =>
total.gt(first)
? api.derive.democracy.referendumsInfo(
[...Array(total.sub(first).toNumber())].map((_, i): BN => first.addn(i))
)
: of([])
)
api.derive.democracy.referendumIds().pipe(
switchMap((ids): Observable<DeriveReferendum[]> =>
ids.length
? api.derive.democracy.referendumsInfo(ids)
: of([])
)
: of([])
)
);
}
@@ -0,0 +1,27 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { ApiInterfaceRx } from '@polkadot/api/types';
import { ReferendumInfo, ReferendumInfoFinished } from '@polkadot/types/interfaces';
import { Observable } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { Option } from '@polkadot/types';
import { memo } from '../util';
export function referendumsFinished (api: ApiInterfaceRx): () => Observable<ReferendumInfoFinished[]> {
return memo((): Observable<ReferendumInfoFinished[]> =>
api.derive.democracy.referendumIds().pipe(
switchMap((ids) => api.query.democracy.referendumInfoOf.multi<Option<ReferendumInfo>>(ids)),
map((infos): ReferendumInfoFinished[] =>
infos
.filter((optInfo) => optInfo.isSome)
.map((optInfo) => optInfo.unwrap())
.filter((info) => info.isFinished)
.map((info) => info.asFinished)
)
)
);
}
@@ -3,15 +3,138 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { ApiInterfaceRx } from '@polkadot/api/types';
import { ReferendumInfo } from '@polkadot/types/interfaces';
import { DeriveReferendum } from '../types';
import { AccountId, ReferendumInfo, ReferendumInfoTo239, Vote, Voting, VotingDirectVote, VotingDelegating } from '@polkadot/types/interfaces';
import { DeriveBalancesAccount, DeriveReferendum, DeriveReferendumVote, DeriveReferendumVotes } from '../types';
import BN from 'bn.js';
import { Observable, of, combineLatest } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { Option } from '@polkadot/types';
import { Option, Vec } from '@polkadot/types';
import { isFunction } from '@polkadot/util';
import { memo } from '../util';
import { calcVotes, getStatus, parseImage } from './util';
function votesPrev (api: ApiInterfaceRx, referendumId: BN): Observable<DeriveReferendumVote[]> {
return api.query.democracy.votersFor<Vec<AccountId>>(referendumId).pipe(
switchMap((votersFor): Observable<[Vec<AccountId>, Vote[], DeriveBalancesAccount[]]> =>
combineLatest([
of(votersFor),
votersFor.length
? api.query.democracy.voteOf.multi<Vote>(
votersFor.map((accountId): [BN | number, AccountId] =>
[referendumId, accountId]
)
)
: of([]),
api.derive.balances.votingBalances(votersFor)
])
),
map(([votersFor, votes, balances]): DeriveReferendumVote[] =>
votersFor.map((accountId, index): DeriveReferendumVote => ({
accountId,
balance: balances[index].votingBalance || api.registry.createType('Balance'),
isDelegating: false,
vote: votes[index] || api.registry.createType('Vote')
}))
)
);
}
function votesCurr (api: ApiInterfaceRx, referendumId: BN): Observable<DeriveReferendumVote[]> {
return api.query.democracy.votingOf.entries<Voting>().pipe(
map((allVoting): DeriveReferendumVote[] => {
const mapped = allVoting.map(([key, voting]): [AccountId, Voting] => [key.args[0] as AccountId, voting]);
const votes = mapped
.filter(([, voting]) => voting.isDirect)
.map(([accountId, voting]): [AccountId, VotingDirectVote[]] => [
accountId,
voting.asDirect.votes.filter(([idx]) => idx.eq(referendumId))
])
.filter(([, directVotes]) => !!directVotes.length)
.reduce((result: DeriveReferendumVote[], [accountId, votes]) =>
// FIXME We are ignoring split votes
votes.reduce((result: DeriveReferendumVote[], [, vote]): DeriveReferendumVote[] => {
if (vote.isStandard) {
result.push({
accountId,
isDelegating: false,
...vote.asStandard
});
}
return result;
}, result), []
);
const delegations = mapped
.filter(([, voting]) => voting.isDelegating)
.map(([accountId, voting]): [AccountId, VotingDelegating] => [accountId, voting.asDelegating]);
// add delegations
delegations.forEach(([accountId, { balance, conviction, target }]): void => {
// Are we delegating to a delegator
const toDelegator = delegations.find(([accountId]) => accountId.eq(target));
const to = votes.find(({ accountId }) => accountId.eq(toDelegator ? toDelegator[0] : target));
// this delegation has a target
if (to) {
votes.push({
accountId,
balance,
isDelegating: true,
vote: api.registry.createType('Vote', { aye: to.vote.isAye, conviction })
});
}
});
return votes;
})
);
}
export function _referendumVotes (api: ApiInterfaceRx): (referendum: DeriveReferendum) => Observable<DeriveReferendumVotes> {
return memo((referendum: DeriveReferendum): Observable<DeriveReferendumVotes> =>
combineLatest([
api.derive.democracy.sqrtElectorate(),
isFunction(api.query.democracy.votingOf)
? votesCurr(api, referendum.index)
: votesPrev(api, referendum.index)
]).pipe(
map(([sqrtElectorate, votes]) =>
calcVotes(sqrtElectorate, referendum, votes)
)
)
);
}
export function _referendumsVotes (api: ApiInterfaceRx): (referendums: DeriveReferendum[]) => Observable<DeriveReferendumVotes[]> {
return memo((referendums: DeriveReferendum[]): Observable<DeriveReferendumVotes[]> =>
referendums.length
? combineLatest(
referendums.map((referendum): Observable<DeriveReferendumVotes> =>
api.derive.democracy._referendumVotes(referendum)
)
)
: of([])
);
}
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> => {
const status = getStatus(info);
return status
? api.query.democracy.preimages(status.proposalHash).pipe(
map((preimage): DeriveReferendum => ({
image: parseImage(api, preimage),
imageHash: status.proposalHash,
index: api.registry.createType('ReferendumIndex', index),
status
}))
)
: of(null);
});
}
export function referendumsInfo (api: ApiInterfaceRx): (ids: BN[]) => Observable<DeriveReferendum[]> {
return memo((ids: BN[]): Observable<DeriveReferendum[]> =>
+12 -1
View File
@@ -2,11 +2,21 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import type BN from 'bn.js';
import { AccountId, Balance, BlockNumber, Hash, Proposal, PropIndex, ReferendumInfoTo239, ReferendumStatus, Vote, ReferendumIndex, VoteThreshold } from '@polkadot/types/interfaces';
import BN from 'bn.js';
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;
@@ -46,6 +56,7 @@ export interface DeriveReferendum {
export interface DeriveReferendumVote {
accountId: AccountId;
balance: Balance;
isDelegating: boolean;
vote: Vote;
}
+40 -12
View File
@@ -3,7 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { ApiInterfaceRx } from '@polkadot/api/types';
import { AccountId, Balance, BlockNumber, Proposal, ReferendumInfo, ReferendumInfoTo239, ReferendumStatus, Tally, VoteThreshold } from '@polkadot/types/interfaces';
import { AccountId, Balance, BlockNumber, PreimageStatus, Proposal, ReferendumInfo, ReferendumInfoTo239, ReferendumStatus, Tally, VoteThreshold } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
import { DeriveProposalImage, DeriveReferendum, DeriveReferendumVote, DeriveReferendumVotes, DeriveReferendumVoteState } from '../types';
@@ -11,6 +11,15 @@ import BN from 'bn.js';
import { Bytes, Option } from '@polkadot/types';
import { bnSqrt } from '@polkadot/util';
type PreimageInfo = [Bytes, AccountId, Balance, BlockNumber];
type OldPreimage = ITuple<PreimageInfo>;
interface ApproxState {
votedAye: BN;
votedNay: BN;
votedTotal: BN;
}
function isOldInfo (info: ReferendumInfo | ReferendumInfoTo239): info is ReferendumInfoTo239 {
return !!(info as ReferendumInfoTo239).proposalHash;
}
@@ -19,6 +28,10 @@ function isCurrentStatus (status: ReferendumStatus | ReferendumInfoTo239): statu
return !!(status as ReferendumStatus).tally;
}
function isCurrentPreimage (api: ApiInterfaceRx, imageOpt: Option<OldPreimage> | Option<PreimageStatus>): imageOpt is Option<PreimageStatus> {
return !!imageOpt && !api.query.democracy.dispatchQueue;
}
export function compareRationals (n1: BN, d1: BN, n2: BN, d2: BN): boolean {
while (true) {
const q1 = n1.div(d1);
@@ -46,7 +59,7 @@ export function compareRationals (n1: BN, d1: BN, n2: BN, d2: BN): boolean {
}
}
function isPassing (threshold: VoteThreshold, sqrtElectorate: BN, { votedAye, votedNay, votedTotal }: DeriveReferendumVoteState): boolean {
export function calcPassing (threshold: VoteThreshold, sqrtElectorate: BN, { votedAye, votedNay, votedTotal }: ApproxState): boolean {
const sqrtVoters = bnSqrt(votedTotal);
return sqrtVoters.isZero()
@@ -69,15 +82,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;
}, {
@@ -123,7 +136,7 @@ export function calcVotes (sqrtElectorate: BN, referendum: DeriveReferendum, vot
return {
...state,
isPassing: isPassing(referendum.status.threshold, sqrtElectorate, state),
isPassing: calcPassing(referendum.status.threshold, sqrtElectorate, state),
votes
};
}
@@ -145,13 +158,8 @@ export function getStatus (info: Option<ReferendumInfo | ReferendumInfoTo239>):
return null;
}
export function parseImage (api: ApiInterfaceRx, imageOpt: Option<ITuple<[Bytes, AccountId, Balance, BlockNumber]>>): DeriveProposalImage | undefined {
if (imageOpt.isNone) {
return;
}
function constructProposal (api: ApiInterfaceRx, [bytes, proposer, balance, at]: PreimageInfo): DeriveProposalImage {
let proposal: Proposal | undefined;
const [bytes, proposer, balance, at] = imageOpt.unwrap();
try {
proposal = api.registry.createType('Proposal', bytes.toU8a(true));
@@ -161,3 +169,23 @@ export function parseImage (api: ApiInterfaceRx, imageOpt: Option<ITuple<[Bytes,
return { at, balance, proposal, proposer };
}
export function parseImage (api: ApiInterfaceRx, imageOpt: Option<OldPreimage> | Option<PreimageStatus>): DeriveProposalImage | undefined {
if (imageOpt.isNone) {
return;
}
if (isCurrentPreimage(api, imageOpt)) {
const status = imageOpt.unwrap();
if (status.isMissing) {
return;
}
const { data, deposit, provider, since } = status.asAvailable;
return constructProposal(api, [data, provider, deposit, since]);
}
return constructProposal(api, imageOpt.unwrap());
}
+4 -3
View File
@@ -4,13 +4,13 @@
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 {
@@ -27,9 +27,10 @@ function queryElections (api: ApiInterfaceRx): Observable<DeriveElectionsInfo> {
api.query[section].runnersUp
]).pipe(
map(([councilMembers, candidates, members, runnersUp]): DeriveElectionsInfo => ({
candidates,
candidateCount: api.registry.createType('u32', candidates.length),
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)
@@ -0,0 +1,22 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, Balance, BlockNumber, SetIndex, VoteIndex } from '@polkadot/types/interfaces';
import { u32 } from '@polkadot/types';
export interface DeriveElectionsInfo {
candidates: AccountId[];
candidateCount: u32;
candidacyBond?: Balance;
desiredRunnersUp: u32;
desiredSeats: u32;
members: [AccountId, Balance][];
nextVoterSet?: SetIndex;
runnersUp: [AccountId, Balance][];
termDuration: BlockNumber;
voteCount?: VoteIndex;
voterCount?: SetIndex;
votingBond?: Balance;
}
@@ -9,6 +9,7 @@ import { Observable, of, combineLatest } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Bytes, Option, u32 } from '@polkadot/types';
import { BN_ZERO } from '@polkadot/util';
import { memo } from '../util';
@@ -34,7 +35,7 @@ export function receivedHeartbeats (api: ApiInterfaceRx): () => Observable<Deriv
[validator.toString()]: {
blockCount: numBlocks[index],
hasMessage: !heartbeats[index].isEmpty,
isOnline: !heartbeats[index].isEmpty || numBlocks[index].gtn(0)
isOnline: !heartbeats[index].isEmpty || numBlocks[index].gt(BN_ZERO)
}
}), {})
)
+5 -1
View File
@@ -2,6 +2,10 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
import { Observable, from } from 'rxjs';
import ApiRx from '@polkadot/api/rx/Api';
import MockProvider from '@polkadot/rpc-provider/mock';
@@ -33,7 +37,7 @@ describe('derive', (): void => {
const api = new ApiRx({ provider: new MockProvider(registry), registry });
beforeAll((done): void => {
api.isReady.subscribe((): void => done());
api.isReady.subscribe(() => done());
});
testFunction(api)('accounts', 'idAndIndex', []);

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