Compare commits

...
621 Commits
Author SHA1 Message Date
Github Actions 4195833d6f [CI Skip] release/stable 5.8.2
skip-checks: true
2021-09-06 09:21:36 +00:00
Jaco 8f4e62c278 5.8.2 (#3934) 2021-09-06 11:10:32 +02:00
Jaco 2c294af116 Kusama MultiLocation to v0 (#3933) 2021-09-06 10:57:53 +02:00
Github Actions 0f1f3b88b2 [CI Skip] release/beta 5.8.2-0
skip-checks: true
2021-09-06 08:52:15 +00:00
Alexander Popiak 56b7697dda Version Junction and MultiLocation Types (#3932)
* version Junction and MultiLocation types

* single quotes
2021-09-06 10:39:47 +02:00
Github Actions 86d7471c76 [CI Skip] release/stable 5.8.1
skip-checks: true
2021-09-06 08:09:49 +00:00
Jaco cb7400710b 5.8.1 (#3931) 2021-09-06 09:59:33 +02:00
Github Actions 59796067e2 [CI Skip] release/beta 5.7.2-8
skip-checks: true
2021-09-05 09:10:53 +00:00
Jaco 7920565b97 Bump deps (#3929)
* Bump deps

* linting
2021-09-05 10:59:03 +02:00
Github Actions 4f0069cac8 [CI Skip] release/beta 5.7.2-7
skip-checks: true
2021-09-04 14:57:50 +00:00
Jaco 835070c44f Cleanup Xcm versioned types (with xcm v2) (#3916)
* Cleanup Xcm versioned types

* Rebuild
2021-09-04 16:49:16 +02:00
Github Actions 5368733353 [CI Skip] release/beta 5.7.2-6
skip-checks: true
2021-09-04 14:08:33 +00:00
Jaco efda09f279 Add Auction to Kusama proxies (#3928) 2021-09-04 15:58:57 +02:00
Github Actions af48f19dfa [CI Skip] release/beta 5.7.2-5
skip-checks: true
2021-09-04 13:48:04 +00:00
Jaco a0dd50b3ba Bump all static metadata (#3927)
* Bump all static metadata

* Build defs
2021-09-04 15:38:36 +02:00
Github Actions 3e159891c0 [CI Skip] release/beta 5.7.2-4
skip-checks: true
2021-09-04 09:27:34 +00:00
Jaco 4b36fa68a5 Doc for extraction chains (#3926)
* Doc for extraction chains

* Update packages/types-support/src/metadata/README.md
2021-09-04 11:16:04 +02:00
Github Actions 70c9cfa0f0 [CI Skip] release/beta 5.7.2-3
skip-checks: true
2021-09-01 16:48:31 +00:00
Jaco 3ce67375e3 Jest config cleanup (#3921) 2021-09-01 18:36:07 +02:00
Github Actions 10d611ba17 [CI Skip] release/beta 5.7.2-2
skip-checks: true
2021-09-01 15:53:20 +00:00
Jaco 00acff5956 Support for new Range mapping (#3920) 2021-09-01 17:42:22 +02:00
Github Actions 9857abd061 [CI Skip] release/beta 5.7.2-1
skip-checks: true
2021-08-30 15:52:36 +00:00
Jaco e87c830990 Re-organize xcm types (#3914) 2021-08-30 17:39:50 +02:00
Github Actions 71063c93d1 [CI Skip] release/beta 5.7.2-0
skip-checks: true
2021-08-30 13:43:35 +00:00
Jaco e037df89e3 Bump static metadata (#3913) 2021-08-30 15:32:25 +02:00
Github Actions 564d63ce28 [CI Skip] release/stable 5.7.1
skip-checks: true
2021-08-29 17:31:35 +00:00
Jaco 69db63b6f9 5.7.1 (#3912) 2021-08-29 19:21:47 +02:00
Github Actions 2bd81e9d05 [CI Skip] release/beta 5.6.2-10
skip-checks: true
2021-08-28 06:57:45 +00:00
Jaco d267895dd5 Bump common (#3911)
* Bump common

* Bump other deps
2021-08-28 08:45:30 +02:00
Github Actions 190e0fcdb1 [CI Skip] release/beta 5.6.2-9
skip-checks: true
2021-08-28 06:23:35 +00:00
Jaco 5e83837c5b Remove unneeded Vec copy operations (#3909)
* Remove unneeded Vec copy operations

* a-e

* Tuple adjust
2021-08-28 08:12:17 +02:00
Github Actions 7f949874e6 [CI Skip] release/beta 5.6.2-8
skip-checks: true
2021-08-28 06:09:31 +00:00
Jaco b024d7f63c Don't fail when specified balances instances are non-existent (#3910) 2021-08-28 08:00:29 +02:00
Github Actions 4bc76bb3e5 [CI Skip] release/beta 5.6.2-7
skip-checks: true
2021-08-26 06:05:29 +00:00
Jaco 212b43dda2 Add Kusama 9090 ugrade block (#3905) 2021-08-26 07:54:11 +02:00
Github Actions 0ba1b318a7 [CI Skip] release/beta 5.6.2-6
skip-checks: true
2021-08-25 09:42:37 +00:00
Jaco 2e8e5a93ca Rang now correctly specified (#3902) 2021-08-25 11:32:54 +02:00
Github Actions 6101f82000 [CI Skip] release/beta 5.6.2-5
skip-checks: true
2021-08-24 15:09:48 +00:00
Jaco 662aef2033 Handle scale-info Range (#3899)
* Handle scale-info Range

* Handle Range in PortableRegistry

* Cleanups

* Rebuild, fix tests (Range to be moved)
2021-08-24 16:57:30 +02:00
Github Actions 0859c470be [CI Skip] release/beta 5.6.2-4
skip-checks: true
2021-08-24 10:21:28 +00:00
Jaco 29fe22da43 Tie statemint to v0 xcm (#3897) 2021-08-24 12:10:35 +02:00
Github Actions 7eef825b38 [CI Skip] release/beta 5.6.2-3
skip-checks: true
2021-08-24 09:32:20 +00:00
Jaco 24808fb55d Adjust enum toHuman output (#3896) 2021-08-24 12:20:22 +03:00
Github Actions 9c06ed7a1c [CI Skip] release/beta 5.6.2-2
skip-checks: true
2021-08-24 07:50:11 +00:00
Jaco 9560259f55 Versioned Xcm (#3892) 2021-08-24 09:37:53 +02:00
Github Actions 6236838fc8 [CI Skip] release/beta 5.6.2-1
skip-checks: true
2021-08-24 07:27:16 +00:00
Jaco e14eddfee3 Bump deps (#3895) 2021-08-24 09:14:56 +02:00
Github Actions 0927f9ba8c [CI Skip] release/beta 5.6.2-0
skip-checks: true
2021-08-23 20:20:11 +00:00
Jaco a8775fd69d Allow aliasses for para (#3894)
* Allow aliasses for para

* Adjust indexes
2021-08-23 22:08:53 +02:00
Github Actions 363c502ae8 [CI Skip] release/stable 5.6.1
skip-checks: true
2021-08-23 08:06:34 +00:00
Jaco d6cc0c30b4 5.6.1 (#3889) 2021-08-23 09:51:19 +02:00
Github Actions 5e312973f3 [CI Skip] release/beta 5.5.3-1
skip-checks: true
2021-08-23 07:35:02 +00:00
Jaco 17c6262a5e Update Xcm types to latest (#3888)
* Update Xcm types to latest

* Updated hex & json
2021-08-23 09:22:52 +02:00
Github Actions 0932a9aa7b [CI Skip] release/beta 5.5.3-0
skip-checks: true
2021-08-21 05:41:53 +00:00
hamidra 88b44befdf add support for n key entries for NMaps (#3886) 2021-08-21 07:31:52 +02:00
Github Actions e4fb971bec [CI Skip] release/stable 5.5.2
skip-checks: true
2021-08-19 09:01:31 +00:00
Jaco 5c7c406676 Adjust ValidDisputeStatementKind enum (#3884) 2021-08-19 10:49:32 +02:00
Github Actions 709e89b801 [CI Skip] release/beta 5.5.2-1
skip-checks: true
2021-08-17 07:49:30 +00:00
Jaco fd96255d05 Bump dev (#3880) 2021-08-17 09:38:16 +02:00
Github Actions c212db26b6 [CI Skip] release/beta 5.5.2-0
skip-checks: true
2021-08-16 08:52:32 +00:00
Jaco 817aaccbb1 API health only with providers with subscriptions (#3879) 2021-08-16 10:40:10 +02:00
Github Actions bfd5642d64 [CI Skip] release/stable 5.5.1
skip-checks: true
2021-08-15 10:04:17 +00:00
Jaco 126871bd46 5.5.1 (#3877)
* 5.5.1

* CHANGELOG
2021-08-15 11:54:51 +02:00
Jaco 714234b7af TypeDefInfo alphabetical (adjust ABI compares) (#3878) 2021-08-15 11:34:27 +02:00
Jaco a7a0965d73 9080 Upgrade block (#3876)
* 9080 Upgrade block

* Update CHANGELOG.md
2021-08-15 10:54:25 +02:00
Github Actions 9b1f9c214b [CI Skip] release/beta 5.4.2-8
skip-checks: true
2021-08-14 07:23:58 +00:00
Jaco ca17955d83 Range as primitive (#3874)
* Range as primitive

* Result/Range

* INumber as Range inner

* Update

* .with on Range

* Basic range decoding

* With

* RangeName

* TypeDefInfo for Range
2021-08-14 09:14:53 +02:00
Github Actions 9b0d260b33 [CI Skip] release/beta 5.4.2-7
skip-checks: true
2021-08-13 12:01:16 +00:00
Jaco Greeff fed2913684 bump berry 2021-08-13 14:48:57 +03:00
Github Actions fc777377ef [CI Skip] release/beta 5.4.2-6
skip-checks: true
2021-08-13 11:25:41 +00:00
Jaco ce7968f870 Loosen pedantic check for fully-empty compares (#3873)
* Loosen pedantic check for fully-empty compares

* Bump dev

* Update CHANGELOG

* Bump common
2021-08-13 13:16:17 +02:00
Jaco 07594a33b5 Extends createType decoration with missing (#3872)
* Extends createType decoration with missing

* Simplify

* Correct __IntType

* Uint mismatch
2021-08-13 12:58:17 +02:00
Github Actions 48620ea7a3 [CI Skip] release/beta 5.4.2-5
skip-checks: true
2021-08-13 06:23:57 +00:00
Caio f86ace2680 Add Range and RangeInclusive types (#3791)
* Add Range and RangeInclusive types

* Lint

* Typo
2021-08-13 08:13:14 +02:00
Github Actions 0e22308954 [CI Skip] release/beta 5.4.2-4
skip-checks: true
2021-08-12 15:41:53 +00:00
Jaco ae21d13b23 Use base interfaces for base Codec (#3870) 2021-08-12 17:32:25 +02:00
Github Actions b594158275 [CI Skip] release/beta 5.4.2-3
skip-checks: true
2021-08-12 12:16:10 +00:00
Jaco 76da6a6af5 Adjust createType with inference parser (#3866)
* Adjust createType with inference parser

* Santize fixed vecs

* __Tokenize

* Shortcut ending sequences

* Update tests & checks

* greedy matching

* Additional linting

* s/extends Codec/extends Codec | undefined/

* Adjust

* Shortcut interfacetypes

* Cleanups

* set & enum

* Adjust getTypeClass fallback set

* CC

* Adjust

* Adjust createTypeUnsafe
2021-08-12 14:07:09 +02:00
Github Actions e1f510f5e9 [CI Skip] release/beta 5.4.2-2
skip-checks: true
2021-08-12 08:11:31 +00:00
Nantian db6c44615f fix bigint type (#3869) 2021-08-12 10:02:15 +02:00
Github Actions 4ce01fe16f [CI Skip] release/beta 5.4.2-1
skip-checks: true
2021-08-10 09:42:35 +00:00
Jaco c52576149a Bump deps (#3861) 2021-08-10 11:32:00 +02:00
Github Actions 0b5e4fe1cc [CI Skip] release/beta 5.4.2-0
skip-checks: true
2021-08-10 08:40:26 +00:00
Jaco 8404170240 createType with single trim (#3859)
* createType with single trim

* Adjust

* Template struct extraction

* Adjust

* Additional

* Additional checks
2021-08-10 10:28:43 +02:00
Github Actions 2b6e66b906 [CI Skip] release/stable 5.4.1
skip-checks: true
2021-08-09 08:54:48 +00:00
Jaco b165c0fe8d 5.4.1 (#3857)
* 5.4.1

* CHANGELOG

* CHANGELOG
2021-08-09 10:44:27 +02:00
hamidra c0751f1a67 enable keys(), entries() for NMaps (#3858) 2021-08-09 08:44:56 +02:00
Github Actions 2a95046fb2 [CI Skip] release/beta 5.3.3-9
skip-checks: true
2021-08-07 11:21:27 +00:00
Jaco e1828af4c4 createType TS tuple definitions (#3854) 2021-08-07 13:12:02 +02:00
Github Actions a133fec533 [CI Skip] release/beta 5.3.3-8
skip-checks: true
2021-08-06 12:08:30 +00:00
Jaco Greeff c51f3d5d2a Remove extra params to type detection 2021-08-06 14:56:03 +03:00
Jaco 54bb965537 Cater for higher-order tuples (#3851)
* Cater for higher-order tuples

* IEnum
2021-08-06 13:42:50 +02:00
Github Actions 9ab662881f [CI Skip] release/beta 5.3.3-7
skip-checks: true
2021-08-06 11:01:01 +00:00
Jaco 697781fb52 Type detection with trimming (#3850)
* Type detection with trimming

* Additional interface check
2021-08-06 12:48:45 +02:00
Github Actions a60d80953b [CI Skip] release/beta 5.3.3-6
skip-checks: true
2021-08-06 09:37:29 +00:00
Jaco a7edf81279 Detect resulting types from createType (#3849)
* Detect resulting types from createType

* Additional detect overrides

* additional

* Empy (), never for invalids
2021-08-06 11:28:32 +02:00
Github Actions 3423fb1717 [CI Skip] release/beta 5.3.3-5
skip-checks: true
2021-08-05 15:02:48 +00:00
Jaco 4ae4e4298c Ensure flags are set before connect/disconnect events (#3846) 2021-08-05 16:46:33 +02:00
Github Actions 90a84baa52 [CI Skip] release/beta 5.3.3-4
skip-checks: true
2021-08-05 10:41:02 +00:00
Jaco a80df7d846 Swap CodecArg usage to unknown (#3845)
* Swap CodecArg usage to unknown

* Adjust Constructor defintion
2021-08-05 12:27:51 +02:00
Github Actions 9961595634 [CI Skip] release/beta 5.3.3-3
skip-checks: true
2021-08-05 07:24:40 +00:00
Jaco e0ecaccb09 Adjust Registry createType return detection (#3844)
* Adjust Registry createType return detection

* type as 'OtherType' cast removal

* Use createClass via registry
2021-08-05 09:15:06 +02:00
Github Actions fd7c80bd8a [CI Skip] release/beta 5.3.3-2
skip-checks: true
2021-08-04 14:43:15 +00:00
Jaco 44a81bc00c Metadata v14 only has combined Map (#3843)
* Metadata v14 only has combined Map

* v14 Map conversion de-duped

* Substrate Map conversion

* v13 tests

* Apply suggestions from code review

* Housekeeping

* v14 bump
2021-08-04 16:31:16 +02:00
Github Actions 7d71726024 [CI Skip] release/beta 5.3.3-1
skip-checks: true
2021-08-04 08:52:18 +00:00
Jaco f603100b8b Add @polkadot/types-support (#3842)
* Add @polkadot/types-support

* jest config fix

* typegen lookups

* Build fixes

* Explicit kusama naming

* testMeta for v14 (local)

* CI test failure

* CI test failure v14

* Update with corrected data after test

* types-support json imports
2021-08-04 10:39:21 +02:00
Github Actions 70ac38cfd2 [CI Skip] release/beta 5.3.3-0
skip-checks: true
2021-08-03 11:40:44 +00:00
Jaco 0bf0d27a39 Handle BitSequence in PortableRegistry (#3838)
* Handle BitSequence in PortableRegistry

* Use Kusama-dev v14 metadata
2021-08-03 13:27:52 +02:00
Github Actions b51988193a [CI Skip] release/stable 5.3.2
skip-checks: true
2021-08-03 08:36:43 +00:00
Jaco fd31e5a6e5 5.3.2 (#3837) 2021-08-03 10:26:46 +02:00
Github Actions 074663cdb7 [CI Skip] release/beta 5.3.2-1
skip-checks: true
2021-08-03 08:07:30 +00:00
Jaco 5f5be13c08 Add missing bridges ChainId (#3836)
* Add missing bridges ChainId

* CHANGELOG
2021-08-03 09:56:35 +02:00
Jaco d60b1818d0 Update bridges types (#3835)
* Update bridges types

* BitVec

* BitVec
2021-08-03 09:39:32 +02:00
Github Actions 9c611e9414 [CI Skip] release/beta 5.3.2-0
skip-checks: true
2021-08-03 05:44:26 +00:00
Jaco da14679b65 v14 metadata bump (#3834) 2021-08-03 07:32:47 +02:00
Github Actions c88bb99b19 [CI Skip] release/stable 5.3.1
skip-checks: true
2021-08-02 09:11:40 +00:00
Jaco fc174738ec 5.3.1 (#3831) 2021-08-02 10:59:03 +02:00
Github Actions b43f1a747d [CI Skip] release/beta 5.2.2-12
skip-checks: true
2021-08-01 07:46:30 +00:00
Jaco 555b2fb5fe Flatten metadata tests & imports (#3830) 2021-08-01 09:35:01 +02:00
Github Actions 1e1ee6eb49 [CI Skip] release/beta 5.2.2-11
skip-checks: true
2021-07-30 14:58:58 +00:00
Jaco 7c4c346389 Hex/JSON metadata split (#3829)
* Hex/JSON metadata split

* revert import change

* Adjust imports

* Update tests
2021-07-30 16:45:57 +02:00
Github Actions beff353b4e [CI Skip] release/beta 5.2.2-10
skip-checks: true
2021-07-30 12:09:20 +00:00
Jaco 3172cb55f8 Add Polkadot static metadata (#3827)
* Add Polkadot static metadata

* v13 static polkadot

* v14 static polkadot

* CHANGELOG
2021-07-30 13:56:39 +02:00
Github Actions ba74ad0be9 [CI Skip] release/beta 5.2.2-9
skip-checks: true
2021-07-30 08:44:08 +00:00
Jaco 6ec7687f33 Bump static metadata (#3826) 2021-07-30 10:34:15 +02:00
Github Actions bd70b1e6ce [CI Skip] release/beta 5.2.2-8
skip-checks: true
2021-07-30 07:06:25 +00:00
Jaco 8744b95c83 Adjust PortableRegistry name matches (#3825)
* Adjust PortableRegistry name matches

* Update packages/types/src/generic/PortableRegistry.ts

* Update packages/types/src/generic/PortableRegistry.ts

* Opt

* Adjust set matching

* Extra includes check
2021-07-30 08:57:13 +02:00
Github Actions 94e6d8455d [CI Skip] release/beta 5.2.2-7
skip-checks: true
2021-07-30 06:26:56 +00:00
Jaco 70d19fcebb Kusama 9080 upgrade block (#3821) 2021-07-30 08:17:22 +02:00
Github Actions 174ba867d7 [CI Skip] release/beta 5.2.2-6
skip-checks: true
2021-07-29 11:10:28 +00:00
Jaco 36b217463a (some) Bridges types (#3823) 2021-07-29 13:00:05 +02:00
Github Actions 412c7525c0 [CI Skip] release/beta 5.2.2-5
skip-checks: true
2021-07-29 09:26:01 +00:00
Jaco 172c6f655f Update v14 metadata & PortableRegistry (#3822)
* Alin PortableRegistry with latest v14 changes

* Bump latest v14
2021-07-29 11:16:16 +02:00
Github Actions 1e3240c669 [CI Skip] release/beta 5.2.2-4
skip-checks: true
2021-07-28 10:54:16 +00:00
Jaco 43e1bf2d4a Check and match both specName/specVersion for registries (#3820) 2021-07-28 12:43:18 +02:00
Github Actions 839b2bc342 [CI Skip] release/beta 5.2.2-3
skip-checks: true
2021-07-28 05:50:31 +00:00
Jaco a281e0dc2d Adjust sorting (#3819)
* Adjust sorting

* typo
2021-07-28 07:40:46 +02:00
Github Actions 9a4893130d [CI Skip] release/beta 5.2.2-2
skip-checks: true
2021-07-28 05:34:40 +00:00
Jaco 77c45cf4c0 Fix sorting circular dependencies (#3818) 2021-07-28 07:22:42 +02:00
Github Actions ca0969b1eb [CI Skip] release/beta 5.2.2-1
skip-checks: true
2021-07-27 13:18:35 +00:00
Jaco 1df8cf9857 Bump v14 static (#3816) 2021-07-27 15:05:43 +02:00
Github Actions b7f095bcbd [CI Skip] release/beta 5.2.2-0
skip-checks: true
2021-07-27 10:34:47 +00:00
Jaco 6cc7242bdf Fix at(...) decoration (#3815)
* Fix at(...) decoration

* Add decoratedMeta/decoratedApi

* Remove intermediate
2021-07-27 12:24:49 +02:00
Jaco 48f91ae0da Adjust PortableRegistry (#3811)
* Adjust PortableRegistry

* Adjust formatting

* Additional formatting picks

* Readability

* Replacement comment
2021-07-26 09:33:15 +02:00
Github Actions 4a63026b14 [CI Skip] release/stable 5.2.1
skip-checks: true
2021-07-26 06:19:38 +00:00
Jaco a40ce72298 5.2.1 (#3810) 2021-07-26 08:07:12 +02:00
Github Actions f302d8de69 [CI Skip] release/beta 5.1.2-13
skip-checks: true
2021-07-26 05:51:34 +00:00
Lezek123 fcaebbdbb2 BTreeSet and BTreeMap - encoding and serialization fixes (#3789)
* BTreeSet and BTreeMap - encoding and serialization fixes

* Fix linter issues

* BTreeSet/BTreeMap: Support for Struct and Enum sorting

* Cleanup sorting function
2021-07-26 07:41:25 +02:00
Github Actions 9e7037af04 [CI Skip] release/beta 5.1.2-12
skip-checks: true
2021-07-25 05:41:15 +00:00
Jaco 68efac60df Allow struct alias on PortableRegistry (#3808)
* Allow struct aliasses on PortableRegistry

* Add resrved alias

* Naing adjustment

* No name for flattenned Tuple

* Add docs
2021-07-25 07:30:57 +02:00
Github Actions d763f49e8b [CI Skip] release/beta 5.1.2-11
skip-checks: true
2021-07-24 13:59:55 +00:00
Jaco 77ffd7c153 Metadata v13 to v14 conversion (#3807) 2021-07-24 15:50:06 +02:00
Jaco d1506154bd PortableRegistry support for BTreeMap (#3806)
* PortableRegistry support for BTreeMap

* Update packages/types/src/generic/PortableRegistry.ts
2021-07-24 15:49:39 +02:00
Github Actions b1254685da [CI Skip] release/beta 5.1.2-10
skip-checks: true
2021-07-24 06:43:27 +00:00
Jaco 81a2a2c688 Adjust type encoding (#3805)
* Adjust type encoding

* Adjust

* displayName adjustments
2021-07-24 08:32:36 +02:00
Github Actions 1fed997080 [CI Skip] release/beta 5.1.2-9
skip-checks: true
2021-07-23 16:13:24 +00:00
Jaco 6e620e3bb3 Short-circuit full type (with lookupIndex) (#3804)
* Short-circuit full type (with lookupIndex)

* Defaults for type expansion

* Tuple with extra spaces removed

* Fill in generated types

* Adjust generation

* Adjust tests

* Adjust
2021-07-23 18:04:14 +02:00
Github Actions 6e4c62ea99 [CI Skip] release/beta 5.1.2-8
skip-checks: true
2021-07-23 10:02:58 +00:00
Jaco 8972d2ffe9 Add type string generation to PortableRegistry (#3802)
* Add type string generation to PortableRegistry

* createClass updates

* Add missing field
2021-07-23 11:51:40 +02:00
Github Actions 091d2d30e0 [CI Skip] release/beta 5.1.2-7
skip-checks: true
2021-07-22 18:26:01 +00:00
Jaco ae7ded1767 Extensive formatting for TypeDef -> string (#3800)
* Extensive formatting for TypeDef -> string

* Remove helpers
2021-07-22 20:15:44 +02:00
Github Actions 8aa3550354 [CI Skip] release/beta 5.1.2-6
skip-checks: true
2021-07-22 17:48:31 +00:00
Jaco 196d3c5995 Pass registry to formatters (#3799) 2021-07-22 19:39:40 +02:00
Github Actions 592407d691 [CI Skip] release/beta 5.1.2-5
skip-checks: true
2021-07-22 11:28:43 +00:00
Jaco 1e3a1bb51c Allow for type overrides via path (#3797) 2021-07-22 13:18:31 +02:00
Github Actions 2ca23a85d0 [CI Skip] release/beta 5.1.2-4
skip-checks: true
2021-07-22 09:52:22 +00:00
Jaco 1a04b4a72e Fix lookup type expansion (#3796) 2021-07-22 11:43:08 +02:00
Github Actions 6dfe7c4f56 [CI Skip] release/beta 5.1.2-3
skip-checks: true
2021-07-22 09:01:44 +00:00
Jaco 3f9f7bd649 Flatten PortableRegistry type creation (#3795) 2021-07-22 10:51:56 +02:00
Github Actions e02e1302b2 [CI Skip] release/beta 5.1.2-2
skip-checks: true
2021-07-21 12:33:19 +00:00
Jaco a64dec3487 v14 static bump (w/ call param names) (#3788) 2021-07-21 14:22:16 +02:00
Github Actions 3415fbd121 [CI Skip] release/beta 5.1.2-1
skip-checks: true
2021-07-21 09:47:32 +00:00
Jaco 0be1d46be9 RPC-core createType swap (#3786)
* RPC-core createType swap

* CHANGELOG

* createType complexity
2021-07-21 11:36:10 +02:00
Github Actions 9309e9f3a1 [CI Skip] release/beta 5.1.2-0
skip-checks: true
2021-07-20 12:27:49 +00:00
Jaco 6dd019343d Adjust generation sorting (#3785) 2021-07-20 14:14:14 +02:00
Github Actions 20f18c72e5 [CI Skip] release/stable 5.1.1
skip-checks: true
2021-07-19 13:14:57 +00:00
Jaco 6a31cbe1a2 5.1.1 (#3783)
* 5.1.1

* Bump common
2021-07-19 15:01:07 +02:00
Jaco acba636d16 Latest v14 metadata (#3782) 2021-07-19 14:27:10 +02:00
Github Actions 6356fe0571 [CI Skip] release/beta 5.0.2-12
skip-checks: true
2021-07-19 08:27:44 +00:00
Jaco 3e17824539 Move Lookup check to registry (#3780) 2021-07-19 10:17:26 +02:00
Github Actions db9e580f82 [CI Skip] release/beta 5.0.2-11
skip-checks: true
2021-07-17 09:47:49 +00:00
Jaco 5ffcba6dd5 Adjust with current scale-info outputs (#3779)
* Adjust with current scale-info outputs

* Linting

* Exhaustive check for encoders
2021-07-17 11:36:19 +02:00
Github Actions 731846088c [CI Skip] release/beta 5.0.2-10
skip-checks: true
2021-07-16 14:50:41 +00:00
Jaco 8b87689489 Add PortableRegistry for v14 lookups (#3778) 2021-07-16 16:39:38 +02:00
Github Actions 5a299adddc [CI Skip] release/beta 5.0.2-9
skip-checks: true
2021-07-16 13:42:49 +00:00
Jaco 99bb6cfe71 Additional AccountId{20, 32} mappings (#3777) 2021-07-16 15:31:18 +02:00
Github Actions ad9a8605d7 [CI Skip] release/beta 5.0.2-8
skip-checks: true
2021-07-16 12:07:44 +00:00
Jaco d62bfc55ac Adjust scale-info types (updated v14, contracts rename) (#3776)
* Adjust scale-info types (updated v14, contracts rename)

* Adjust v14 metadata

* PortableRegistry -> lookup

* Rewrite json
2021-07-16 13:57:44 +02:00
Github Actions 311740a1a2 [CI Skip] release/beta 5.0.2-7
skip-checks: true
2021-07-15 08:45:19 +00:00
Jaco 3285f1f122 v14 Type changes (#3774)
* v14 Type changes

* Registry
2021-07-15 10:34:41 +02:00
Github Actions 2a9711a3cb [CI Skip] release/beta 5.0.2-6
skip-checks: true
2021-07-14 05:53:10 +00:00
Jaco 3ea7cb47ce Update v14 types (#3771) 2021-07-14 07:42:30 +02:00
Github Actions 82fc46881a [CI Skip] release/beta 5.0.2-5
skip-checks: true
2021-07-13 20:55:31 +00:00
Denis Tsai e7758ad54c realign AccountKey20Junction to polkadot xcm's Junction enum (#3770) 2021-07-13 22:43:08 +02:00
Github Actions 7d3ab4c5c1 [CI Skip] release/beta 5.0.2-4
skip-checks: true
2021-07-13 10:01:59 +00:00
Jaco 6c87a6f0af Partial latest to v14 mapping (#3767) 2021-07-13 11:52:10 +02:00
Github Actions fc5e4afe44 [CI Skip] release/beta 5.0.2-3
skip-checks: true
2021-07-13 09:38:21 +00:00
Jaco 48ef04b8ca Metadata v14 types (#3765)
* Metadata v14 types

* Linting w/ CHANGELOG

* Previous-gen SiType as SiType0
2021-07-13 11:28:44 +02:00
Github Actions 1b526fe618 [CI Skip] release/beta 5.0.2-2
skip-checks: true
2021-07-13 06:45:10 +00:00
Ian He 8d6bd931f3 add user additional rpcs during api.clone() (#3764) 2021-07-13 08:35:46 +02:00
Github Actions b317a8eb9b [CI Skip] release/beta 5.0.2-1
skip-checks: true
2021-07-12 10:14:40 +00:00
Jaco 8e65545a3c Allow nested struct generation (#3760)
* Allow nested struct generation

* CHANGELOG

* Update packages/typegen/src/util/formatting.ts

* Rebuild
2021-07-12 12:04:41 +02:00
Github Actions 4ded189697 [CI Skip] release/beta 5.0.2-0
skip-checks: true
2021-07-12 09:51:43 +00:00
Jaco b503441341 Update ParaPastCodeMeta with ReplacementTimes (#3758) 2021-07-12 11:39:46 +02:00
Github Actions f27076c8dc [CI Skip] release/stable 5.0.1
skip-checks: true
2021-07-11 10:36:42 +00:00
Jaco 7fd9c1c8b1 5.0.1 (#3757)
* 5.0.1

* version bump

* Bump common
2021-07-11 12:26:03 +02:00
Github Actions 4aafeed026 [CI Skip] release/beta 4.17.2-20
skip-checks: true
2021-07-11 05:44:10 +00:00
Jaco f7f81b2b99 Align static metadata with latest Substrate (#3756) 2021-07-11 07:32:17 +02:00
Github Actions 0a501c6a3f [CI Skip] release/beta 4.17.2-19
skip-checks: true
2021-07-10 05:25:02 +00:00
Jaco 9ad95d91a0 Adjust scheduler derive (empty results) (#3755) 2021-07-10 07:11:29 +02:00
Github Actions abb4170577 [CI Skip] release/beta 4.17.2-18
skip-checks: true
2021-07-09 12:42:33 +00:00
Jaco 081f223bb2 Adjust bundles (no @polkadot/networks) (#3754) 2021-07-09 14:33:23 +02:00
Github Actions f0778b613f [CI Skip] release/beta 4.17.2-17
skip-checks: true
2021-07-09 09:02:15 +00:00
Jaco 27c6423b28 Adjust bundle creation (#3752) 2021-07-09 10:51:01 +02:00
Github Actions 8803bdd55e [CI Skip] release/beta 4.17.2-16
skip-checks: true
2021-07-09 04:25:51 +00:00
Jaco 445a080f7d Adjust Ws .disconnect() logic to always clear auto-connect (#3749) 2021-07-09 06:14:30 +02:00
Github Actions e13a7ff5a1 [CI Skip] release/beta 4.17.2-15
skip-checks: true
2021-07-08 12:51:54 +00:00
Jaco 18cbfe4a56 Bump deps (#3745) 2021-07-08 14:42:49 +02:00
Github Actions 3397e680e2 [CI Skip] release/beta 4.17.2-14
skip-checks: true
2021-07-08 08:39:39 +00:00
Jaco e2fa996df4 Crowdloan contributions derive (#3704)
* Crwodloan contributions derive

* Handle deltas

* Opt

* Expand childKey

* Keep all previous changes

* Rework

* Adjust

* Cleanups

* Cleanups

* Pass through childKey

* deltas

* CHANGELOG

* ownContributions

* cleanups

* watch events
2021-07-08 10:30:27 +02:00
Github Actions 76d23c54a6 [CI Skip] release/beta 4.17.2-13
skip-checks: true
2021-07-08 04:44:13 +00:00
Jaco bd58f11c92 Westend 9080 (#3744) 2021-07-08 06:33:24 +02:00
Github Actions 2a3b685fb1 [CI Skip] release/beta 4.17.2-12
skip-checks: true
2021-07-07 18:51:37 +00:00
Jaco 3c59a4d417 Single module bundle via rollup (#3731)
* Single module bundle via rollup

* use createBundle

* override all

* Update rollup.config.mjs

* Add bundle import

* Remove x-* packages

* Adjust

* Adjust

* Rebuild

* Internal helpers

* Adjust locations

* Bump common

* CHANGELOG

* Update rollup.config.mjs
2021-07-07 20:39:49 +02:00
Github Actions 8d7b18526c [CI Skip] release/beta 4.17.2-11
skip-checks: true
2021-07-07 12:09:20 +00:00
Jaco 92a1f603d9 Move metadata into types (circular deps hell) (#3743)
* Move metadata into types (circular deps hells)

* Adjust

* Additional

* Additional

* Last round?

* Adjust imports

* Adjust

* packages

* Bump common
2021-07-07 14:00:30 +02:00
Github Actions 968d9078b1 [CI Skip] release/beta 4.17.2-10
skip-checks: true
2021-07-07 09:46:11 +00:00
Jaco 81be70e15b Introduce bundle exports (#3742)
* Introduce bundle exports

* Move memo

* Cleanup imports

* Move DoNotConstruct
2021-07-07 11:35:30 +02:00
Jaco Greeff 33ee38dc7a Bump common 2021-07-07 10:37:46 +03:00
Github Actions 90dd0656e2 [CI Skip] release/beta 4.17.2-9
skip-checks: true
2021-07-07 07:34:50 +00:00
Jaco ff3882f5f7 Bump common (w/ rxjs 7) (#3736)
* Bump common (w/ rxjs 7)

* Adjust

* pre bump

* Cleanup imports

* Add missing switchMap

* CHANGELOG

* Remove duplicate imports

* Bump common

* Direct rxjs import
2021-07-07 09:26:30 +02:00
Github Actions 852daebfd8 [CI Skip] release/beta 4.17.2-7
skip-checks: true
2021-07-07 05:32:26 +00:00
Jaco bde3c61f74 Small referendum optimization (#3741) 2021-07-07 07:22:50 +02:00
Github Actions 883b1aa5c2 [CI Skip] release/beta 4.17.2-6
skip-checks: true
2021-07-07 05:11:23 +00:00
Jaco 716b09737c Allow for non-decodable scheduler entries (#3740) 2021-07-07 07:02:19 +02:00
Github Actions 7d3bc36ef7 [CI Skip] release/beta 4.17.2-5
skip-checks: true
2021-07-07 04:41:58 +00:00
Jaco a3c283cdf3 combineLatest type fixes (remove deprecated) (#3739) 2021-07-07 06:30:56 +02:00
Github Actions 2d634a5b00 [CI Skip] release/beta 4.17.2-4
skip-checks: true
2021-07-07 04:20:20 +00:00
Jaco 113e514b45 Add BlockNumberFor (#3738) 2021-07-07 06:11:44 +02:00
Github Actions ae7edc2111 [CI Skip] release/beta 4.17.2-3
skip-checks: true
2021-07-06 08:47:54 +00:00
Jaco 9ac8a23b20 Update .123trigger 2021-07-06 10:39:15 +02:00
Jaco Greeff a97938a80c Bump deps 2021-07-06 10:08:16 +03:00
Jaco Greeff 4b34d6cdf7 Bump dev 2021-07-06 09:57:25 +03:00
Jaco 89c7d73951 Expose gasRequired (as available) (#3732) 2021-07-06 08:53:23 +02:00
Github Actions 0990359968 [CI Skip] release/beta 4.17.2-2
skip-checks: true
2021-07-06 05:57:29 +00:00
Jaco Greeff 7f28af2029 Bump dev 2021-07-06 08:46:43 +03:00
Github Actions 896247320c [CI Skip] release/beta 4.17.2-1
skip-checks: true
2021-07-06 04:40:52 +00:00
Jaco a635c64910 Add Westend historic HeartbeatTo244 (#3730) 2021-07-06 06:30:17 +02:00
Github Actions 398461163f [CI Skip] release/beta 4.17.2-0
skip-checks: true
2021-07-05 15:48:15 +00:00
Jaco 4d25c2a363 Bump dev (#3726) 2021-07-05 17:37:00 +02:00
Github Actions cbe2dfbd82 [CI Skip] release/stable 4.17.1
skip-checks: true
2021-07-05 08:02:45 +00:00
Jaco 5442a2e5fe 4.17 (#3724) 2021-07-05 09:53:56 +02:00
Github Actions 58b4d8c84f [CI Skip] release/beta 4.16.3-5
skip-checks: true
2021-07-05 06:42:55 +00:00
Jaco f5c6c8a072 Attach constructed registry to metadata (#3723)
* Attach constructed registry to metadata

* Remove return

* CHANGELOG
2021-07-05 08:31:06 +02:00
Github Actions 9d5ab4a2d6 [CI Skip] release/beta 4.16.3-4
skip-checks: true
2021-07-02 07:42:19 +00:00
Jaco 32f704459f api.at(blockHash).{consts, errors, events, query} (#3710)
* api.at(blockHash).{consts, errors, events, query}

* Manual tests for apiAt

* Adjust helpers... not perfect, but best for now

* Expand decorated return

* Re-add compable injectMetadata

* CHANGELOG

* Bump jest global timeout
2021-07-02 09:30:25 +02:00
Jaco e4795182ca Align static metadata with latest Substrate (#3717) 2021-07-02 09:30:01 +02:00
Github Actions 3297dbdaab [CI Skip] release/beta 4.16.3-3
skip-checks: true
2021-07-02 07:23:16 +00:00
Jaco a65a5985e6 Bump TS (#3718) 2021-07-02 09:14:50 +02:00
Github Actions 77eac494ad [CI Skip] release/beta 4.16.3-2
skip-checks: true
2021-07-02 04:58:49 +00:00
Jaco 4498f59607 Detect on elections (#3716) 2021-07-02 06:47:43 +02:00
Jaco 6322913310 Allow for fallback types (struct-only as a start) (#3714)
* Allow for fallback types (struct-only as a start)

* Filter fallback & alias from structs

* Don't clobber existing fallbackType
2021-07-01 12:54:02 +02:00
Github Actions be2f34a045 [CI Skip] release/beta 4.16.3-1
skip-checks: true
2021-07-01 08:26:48 +00:00
Jaco cce0c89168 Adjust collective with instances (#3712)
* Adjust collective with instances

* Update CHANGELOG

* Add prime & proposalaHashes to all

* Export members collective

* prime

* Optional constants

* Move constant expansion

* proposalCount derive

* candidateCount is non-optional
2021-07-01 10:17:48 +02:00
Github Actions 58cc197c89 [CI Skip] release/beta 4.16.3-0
skip-checks: true
2021-06-28 12:12:50 +00:00
Arjan Zijderveld bbb6d0eda9 Added Emergency to ElectionPhase (#3707)
Link to new field:

https://github.com/paritytech/substrate/blob/6242d37f43ec5aa9b6131a8e61b8d4e71b063907/frame/election-provider-multi-phase/src/lib.rs#L337
2021-06-28 14:03:57 +02:00
Github Actions c03068f0ec [CI Skip] release/stable 4.16.2
skip-checks: true
2021-06-27 04:03:48 +00:00
Jaco e8f352930d Correct CompactAssignments & RawSolution types for Polkadot (#3705)
* Correct `CompactAssignments` & `RawSolution` types for Polkadot

* Default to Solution 16
2021-06-27 05:55:11 +02:00
Github Actions bf2c560db5 [CI Skip] release/stable 4.16.1
skip-checks: true
2021-06-26 08:48:42 +00:00
Jaco 63189a6196 4.16 (#3701) 2021-06-26 10:37:06 +02:00
Jaco 9990690332 Bump common (#3700) 2021-06-26 10:10:46 +02:00
Github Actions ee163cc342 [CI Skip] release/beta 4.15.2-10
skip-checks: true
2021-06-26 05:54:47 +00:00
Jaco cf27f7e11b Add Kusama & Westend 9070 upgrade blocks (#3699) 2021-06-26 08:43:58 +03:00
Github Actions 12986865c8 [CI Skip] release/beta 4.15.2-9
skip-checks: true
2021-06-25 15:14:24 +00:00
Jaco aac0fc741a Add polkadot 9050 upgrade block (#3698)
* Add polkadot 9050 upgrade block

* CHANGELOG expansion

* CHAGELOG wording
2021-06-25 17:04:07 +02:00
Github Actions c33f95d64b [CI Skip] release/beta 4.15.2-8
skip-checks: true
2021-06-25 11:14:03 +00:00
Jaco eb7255b34f Bump util (#3695) 2021-06-25 13:04:35 +02:00
Github Actions 3982798d5e [CI Skip] release/beta 4.15.2-7
skip-checks: true
2021-06-25 09:39:35 +00:00
Yuri ded1ebd4e7 fixes #3693 Fix uniques return types (#3694) 2021-06-25 11:30:44 +02:00
Github Actions c261d4e333 [CI Skip] release/beta 4.15.2-6
skip-checks: true
2021-06-23 14:27:46 +00:00
Jaco 7b1400e238 Bump common (#3690) 2021-06-23 16:18:49 +02:00
Github Actions 7c2048bc6b [CI Skip] release/beta 4.15.2-5
skip-checks: true
2021-06-23 13:00:32 +00:00
Jaco 2b1d5664fe Adjust contract registry (#3689) 2021-06-23 14:49:51 +02:00
Github Actions 5403686e20 [CI Skip] release/beta 4.15.2-4
skip-checks: true
2021-06-23 12:39:41 +00:00
Jaco e90c72fc8b ABI indexes are 0-based from 0.7+ (#3688) 2021-06-23 14:31:18 +02:00
Github Actions 1910ef54a4 [CI Skip] release/beta 4.15.2-3
skip-checks: true
2021-06-23 09:18:59 +00:00
Jaco 45686f9482 Bump deps (#3686)
* Bump deps

* Add override (as applicable)
2021-06-23 11:10:12 +02:00
Github Actions a6b0d214af [CI Skip] release/beta 4.15.2-2
skip-checks: true
2021-06-22 08:36:05 +00:00
Jaco 2a1a2a936b Update .123trigger 2021-06-22 10:24:33 +02:00
Jaco 060275d1ae Event lazy create classes (#3685)
* Event lazy create classes

* head fallback
2021-06-22 09:49:45 +02:00
Github Actions abb54d2538 [CI Skip] release/beta 4.15.2-1
skip-checks: true
2021-06-21 12:16:05 +00:00
Jaco 98fc472a40 Add 9050 upgrade blocks (#3683)
* Add 9050 upgrade blocks

* CHANGELOG
2021-06-21 14:06:09 +02:00
Github Actions 4034429042 [CI Skip] release/beta 4.15.2-0
skip-checks: true
2021-06-21 09:16:45 +00:00
Jaco ca212b8736 Bump static metadata (#3682) 2021-06-21 11:06:38 +02:00
Github Actions 4c2593629d [CI Skip] release/stable 4.15.1
skip-checks: true
2021-06-19 09:34:55 +00:00
Jaco 612d85ca2a 4.15 (#3679)
* 4.15

* CHANGELOG
2021-06-19 11:24:31 +02:00
Jaco Greeff b25b92dddc Metadata generation has spaces between lines 2021-06-19 11:48:49 +03:00
Github Actions f01376ebe1 [CI Skip] release/beta 4.14.2-11
skip-checks: true
2021-06-19 08:38:55 +00:00
Jaco 03acde19b8 Expand nested getTypeDef tests (#3678)
* Expand nested getTypeDef tests

* Rename to fallback

* Remove --detectOpenHandles
2021-06-19 10:27:01 +02:00
Alexander Popiak 1de533ca9c add ChargeAssetTxPayment to SignedExtensions (#3668) 2021-06-19 09:50:30 +02:00
Jaco ce2037400c Bump common (#3677) 2021-06-19 09:18:04 +02:00
Github Actions 379fe12979 [CI Skip] release/beta 4.14.2-10
skip-checks: true
2021-06-19 06:21:43 +00:00
Jaco a285f53753 Add compatibility export for GenericAddress (#3676)
* Add compatibility export for GenericAddress

* GenericAddress -> GenericMultiAddress (new form)
2021-06-19 08:10:36 +02:00
Github Actions ed36eed112 [CI Skip] release/beta 4.14.2-9
skip-checks: true
2021-06-18 13:48:37 +00:00
Jaco ddf6f574f6 XcmOrigin definition (#3675)
* XcmOrigin definition

* CHANGELOG
2021-06-18 15:39:48 +02:00
Github Actions 4f7c4e8b4e [CI Skip] release/beta 4.14.2-8
skip-checks: true
2021-06-18 13:35:09 +00:00
Jaco f2a82ddd0f Allow for nested fixed vec defintions (#3673)
* Allow for nested fixed vec defintions

* struct with nested struct & tuple

* extract conversion to type string

* Include < & > in split iteration

* Allow for nested ( & )

* CHANGELOG
2021-06-18 15:23:54 +02:00
Github Actions 3cec316683 [CI Skip] release/beta 4.14.2-7
skip-checks: true
2021-06-18 13:08:49 +00:00
Jaco c23b5e674b Adjust module checks (& allow for nonce-only) (#3672) 2021-06-18 15:00:20 +02:00
Github Actions 8bf8222c31 [CI Skip] release/beta 4.14.2-6
skip-checks: true
2021-06-18 06:28:17 +00:00
Jaco 0c19e966cc Add BeefyId (#3671)
* Add BeefyId

* Alias
2021-06-18 08:19:00 +02:00
Github Actions 9fbda5a6e0 [CI Skip] release/beta 4.14.2-5
skip-checks: true
2021-06-17 07:38:18 +00:00
Jaco 3d7d39073f Remove isStakerPayout flag (#3665) 2021-06-17 09:26:50 +02:00
Github Actions ae26aebdf8 [CI Skip] release/beta 4.14.2-4
skip-checks: true
2021-06-16 11:52:28 +00:00
Alexander PopiakandJaco c43f442fb9 handle empty account data/missing balance gracefully (#3658)
* handle empty account data/missing balance gracefully

* check whether data is empty

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

* pull out zero balance function

Co-authored-by: Jaco <jacogr@gmail.com>
2021-06-16 13:41:23 +02:00
Github Actions f97a6d0418 [CI Skip] release/beta 4.14.2-3
skip-checks: true
2021-06-15 09:19:27 +00:00
Jaco 7cd2fa5f6a Additional check for API connection & decoration in contracts (#3654)
* Additional check for API connection & decoration in contracts

* Remove snuck-in-file
2021-06-15 11:08:47 +02:00
Github Actions 6015552aab [CI Skip] release/beta 4.14.2-2
skip-checks: true
2021-06-15 07:05:21 +00:00
Jaco 8748c02b20 Adjust error message for contracts V3 (#3653)
* Adjust error message for contracts V3

* Adjust mock API
2021-06-15 08:54:43 +02:00
Github Actions 6e04d4aa93 [CI Skip] release/beta 4.14.2-1
skip-checks: true
2021-06-15 06:33:15 +00:00
Jaco 4a955f7b77 Add support for childstate_getKeysPaged RPC (#3652)
* Add support for childstate_getKeysPaged RPC

* Optional last
2021-06-15 08:22:51 +02:00
Github Actions 227143728d [CI Skip] release/beta 4.14.2-0
skip-checks: true
2021-06-15 06:19:06 +00:00
Jaco 7330555c37 Latest metadata (#3647) 2021-06-15 08:08:16 +02:00
Github Actions 09831fe325 [CI Skip] release/stable 4.14.1
skip-checks: true
2021-06-14 09:19:12 +00:00
Jaco c7dda6fe85 4.14 (#3646) 2021-06-14 11:08:27 +02:00
Github Actions 285bbab055 [CI Skip] release/beta 4.13.2-12
skip-checks: true
2021-06-14 08:35:39 +00:00
Xiliang Chen b73010a506 add Authority origin (#3645) 2021-06-14 10:25:33 +02:00
Github Actions 9c951fe1cb [CI Skip] release/beta 4.13.2-11
skip-checks: true
2021-06-14 06:18:55 +00:00
Jaco f7dfb633d6 Bump deps (#3644)
* Bump deps

* Adjust base test timeouts
2021-06-14 08:07:54 +02:00
Github Actions e32286b610 [CI Skip] release/beta 4.13.2-10
skip-checks: true
2021-06-14 05:08:25 +00:00
Jaco fe2687b514 Add GeneralCouncil as origin until solution is available (#3643) 2021-06-14 06:59:11 +02:00
Github Actions 1adde99e1b [CI Skip] release/beta 4.13.2-9
skip-checks: true
2021-06-12 15:01:26 +00:00
André Silva 33dcc9c8aa add support for ValidationCodeHash (#3640) 2021-06-12 17:52:20 +03:00
Github Actions db563bc131 [CI Skip] release/beta 4.13.2-8
skip-checks: true
2021-06-12 08:40:26 +00:00
hamidra 35d2fa31e0 Fix typo and add missing type (#3639)
fixing a typo and also seems the 'attribute': 'u32' is missing from ClassDetails struct.
https://github.com/paritytech/substrate/blob/41ab01a8cb2a43f7d743778c066ad91453e0c883/frame/uniques/src/types.rs#L54
2021-06-12 10:29:10 +02:00
Github Actions 399637280c [CI Skip] release/beta 4.13.2-7
skip-checks: true
2021-06-11 16:22:23 +00:00
Jaco f46916b215 djust keys/entries retrieval batch sizes (#3638) 2021-06-11 18:09:47 +02:00
Github Actions 94aa79d1e5 [CI Skip] release/beta 4.13.2-6
skip-checks: true
2021-06-11 11:04:45 +00:00
Jaco 10dacf1d16 Correct dangling (old-style) HttpProvider docs (#3635) 2021-06-11 12:54:10 +02:00
Jaco bdaacfdd56 BN import from util (#3637)
* BN import from util

* Update packages/api-derive/src/staking/stakerRewards.ts
2021-06-11 12:52:21 +02:00
Github Actions 4fa77b3654 [CI Skip] release/beta 4.13.2-5
skip-checks: true
2021-06-09 13:28:42 +00:00
Jaco 400e14d6c9 Explicit length checks for u8aFixed (#3630)
* Explicit length checks for u8aFixed

* Adjust tests
2021-06-09 15:19:48 +02:00
Github Actions 09f247432f [CI Skip] release/beta 4.13.2-4
skip-checks: true
2021-06-09 05:34:53 +00:00
Jaco fd195dd4f0 Add Kusama 9040 upgrade block (#3625) 2021-06-09 07:23:01 +02:00
Github Actions 0038227680 [CI Skip] release/beta 4.13.2-3
skip-checks: true
2021-06-08 15:16:16 +00:00
Jaco Greeff 89dec0bc0b .prettierignore 2021-06-08 18:05:18 +03:00
Github Actions a55a835504 [CI Skip] release/beta 4.13.2-2
skip-checks: true
2021-06-07 14:10:52 +00:00
Jaco Greeff c1266a6657 Merge branch 'master' of github.com:polkadot-js/api 2021-06-07 17:00:30 +03:00
Jaco Greeff b78f08e2e6 Adjust cron locks 2021-06-07 17:00:25 +03:00
Github Actions 298ef03787 [CI Skip] release/beta 4.13.2-1
skip-checks: true
2021-06-07 13:59:20 +00:00
Jaco Greeff dd80b1873c lock cron 2021-06-07 16:48:23 +03:00
Github Actions f7672e053b [CI Skip] release/beta 4.13.2-0
skip-checks: true
2021-06-07 05:48:23 +00:00
Jaco 281e9d2dee Adjust semgrep check (#3624) 2021-06-07 07:37:28 +02:00
Github Actions 3f0d11b026 [CI Skip] release/stable 4.13.1
skip-checks: true
2021-06-06 19:30:05 +00:00
Jaco 0c997d2850 4.13 (#3623) 2021-06-06 21:18:30 +02:00
Github Actions cb0beea7cd [CI Skip] release/beta 4.12.2-20
skip-checks: true
2021-06-05 11:19:19 +00:00
Jaco Greeff 4ed783878d No semgrep.yml on forks 2021-06-05 14:07:41 +03:00
Github Actions 3846b5cc18 [CI Skip] release/beta 4.12.2-19
skip-checks: true
2021-06-05 06:49:48 +00:00
Jaco Greeff 57b8915101 push-master.yml adjust skip 2021-06-05 09:38:02 +03:00
Github Actions 4f3f7e8dff [CI Skip] release/beta 4.12.2-18
skip-checks: true
2021-06-05 06:30:54 +00:00
Jaco Greeff a42c266a35 semgrep.yml on PR 2021-06-05 09:20:00 +03:00
Github Actions b03b2db3f8 [CI Skip] release/beta 4.12.2-17
skip-checks: true
2021-06-04 14:50:06 +00:00
Jaco 5347db445d Split page sizes for keys & values on maps (#3620)
* Ssplit page sizes for keys & values on maps

* Adjust semgrep
2021-06-04 16:39:23 +02:00
Github Actions 2a15b65385 [CI Skip] release/beta 4.12.2-16
skip-checks: true
2021-06-04 10:49:58 +00:00
Jaco 7f1952acfc Bump deps (#3618) 2021-06-04 13:40:32 +03:00
Github Actions d8920b4bac [CI Skip] release/beta 4.12.2-15
skip-checks: true
2021-06-04 09:25:48 +00:00
Jaco 3b46505027 Bump static Substrate metadata (#3616)
* Bump static Substrate metadata

* Add size alias
2021-06-04 11:15:11 +02:00
Github Actions ba3ac3f73d [CI Skip] release/beta 4.12.2-14
skip-checks: true
2021-06-04 08:49:45 +00:00
Jaco Greeff 81d460ccc8 Merge branch 'master' of github.com:polkadot-js/api 2021-06-04 11:38:49 +03:00
Jaco Greeff e6bb6c49b3 semgrep on master only 2021-06-04 11:38:45 +03:00
Jaco 82ffa8a6e2 Bump deps (#3617) 2021-06-04 10:37:55 +02:00
Github Actions adc1af1f21 [CI Skip] release/beta 4.12.2-13
skip-checks: true
2021-06-04 05:45:25 +00:00
Jaco Greeff a05d6ad7dc semgrep only for non-forked 2021-06-04 08:36:01 +03:00
Github Actions be592f53b8 [CI Skip] release/beta 4.12.2-12
skip-checks: true
2021-06-03 15:24:02 +00:00
Jaco Greeff 8e74eca435 lock.yml cron 2021-06-03 18:14:53 +03:00
Github Actions 8a28d2cf46 [CI Skip] release/beta 4.12.2-11
skip-checks: true
2021-06-02 16:15:00 +00:00
Jaco Greeff d36886fcbf fix stale.yml 2021-06-02 19:03:46 +03:00
Github Actions 3bbc9fbf6e [CI Skip] release/beta 4.12.2-10
skip-checks: true
2021-06-02 14:36:16 +00:00
Jaco Greeff 1d4539f3ef lock.yml interval 2021-06-02 17:24:17 +03:00
Github Actions 215b20f7db [CI Skip] release/beta 4.12.2-9
skip-checks: true
2021-06-02 07:48:17 +00:00
Jaco c034b54822 Add CandidateInfo type (#3609)
* Add CandidateInfo type

* Adjust lock time
2021-06-02 09:37:47 +02:00
Jaco Greeff 261ca2149d Merge branch 'master' of github.com:polkadot-js/api 2021-06-02 10:07:17 +03:00
Jaco Greeff eaa67c8ea6 cron workflows 2021-06-02 10:07:12 +03:00
Github Actions db287d6997 [CI Skip] release/beta 4.12.2-8
skip-checks: true
2021-06-02 07:07:06 +00:00
Jaco b85bf7e41c setKeys accepts string/Uint8Array (#3608)
* setKeys accepts string/Uint8Array

* CHANGELOG

* Update CHANGELOG

* Westend upgrade block

* --forceExit for jest
2021-06-02 08:56:22 +02:00
Github Actions 84b82dd9b5 [CI Skip] release/beta 4.12.2-7
skip-checks: true
2021-06-02 06:50:02 +00:00
Jaco 3df5b01375 Bump metadata (#3607)
* Bump metadata

* Generate

* s/removeBounded/removeExtensions/
2021-06-02 08:38:17 +02:00
Github Actions 2e6a59e2a0 [CI Skip] release/beta 4.12.2-6
skip-checks: true
2021-06-01 18:04:18 +00:00
Jaco 2f91561166 Westmint spec types (#3602) 2021-06-01 19:54:02 +02:00
Github Actions b307772be2 [CI Skip] release/beta 4.12.2-5
skip-checks: true
2021-06-01 10:09:09 +00:00
Jaco Greeff d14d2ccc86 semgrep.yml 2021-06-01 12:58:25 +03:00
Github Actions 0f26ec47e2 [CI Skip] release/beta 4.12.2-4
skip-checks: true
2021-06-01 06:15:01 +00:00
Jaco Greeff 40065e300b cron daily only 2021-06-01 09:03:59 +03:00
Github Actions bbdb8a317f [CI Skip] release/beta 4.12.2-3
skip-checks: true
2021-05-31 20:27:45 +00:00
Jaco Greeff 668085262c cron locks 2021-05-31 23:15:48 +03:00
Github Actions 508400684a [CI Skip] release/beta 4.12.2-2
skip-checks: true
2021-05-31 12:42:37 +00:00
Jaco 3273556f7b Convert stragging BN type imports (#3595) 2021-05-31 14:32:33 +02:00
Github Actions d36144bf36 [CI Skip] release/beta 4.12.2-1
skip-checks: true
2021-05-31 08:11:04 +00:00
Jaco 444479011e Update .123trigger 2021-05-31 10:00:35 +02:00
Github Actions 8ac713abcf [CI Skip] release/beta 4.12.2-0
skip-checks: true
2021-05-31 07:58:00 +00:00
Jaco Greeff 728bc5294f Bump dev 2021-05-31 10:47:09 +03:00
Jaco fd2f331bdf Bump dev (#3594) 2021-05-31 09:19:54 +02:00
Jaco Greeff 2aebbb89cb lock.yml 2021-05-30 22:23:25 +03:00
Github Actions 532c011495 [CI Skip] release/beta 4.12.2-0
skip-checks: true
2021-05-30 10:52:28 +00:00
Jaco e2802df9ce Bump berry (#3592) 2021-05-30 12:41:59 +02:00
Github Actions cc181e2cc3 [CI Skip] release/stable 4.12.1
skip-checks: true
2021-05-30 06:36:49 +00:00
Jaco 1b8ba41715 4.12 (#3590)
* 4.12

* Bump dev
2021-05-30 08:25:51 +02:00
Github Actions 648be9aecb [CI Skip] release/beta 4.11.3-9
skip-checks: true
2021-05-30 05:52:02 +00:00
Jaco 292af97dc9 Eth RPC def cleanups (#3589) 2021-05-30 07:40:26 +02:00
Github Actions bcdd537214 [CI Skip] release/beta 4.11.3-8
skip-checks: true
2021-05-29 08:29:57 +00:00
Jaco Greeff 514c5e4825 Update stale.yml 2021-05-29 11:19:23 +03:00
Github Actions 9b9581487d [CI Skip] release/beta 4.11.3-7
skip-checks: true
2021-05-28 14:39:22 +00:00
Jaco d443f31a9a Kusama 9030 upgrade block (#3584) 2021-05-28 16:30:14 +02:00
Github Actions 3951da5df3 [CI Skip] release/beta 4.11.3-6
skip-checks: true
2021-05-28 08:50:52 +00:00
Jaco Greeff 5f3a1e5b24 Update stale.yml 2021-05-28 11:39:43 +03:00
Github Actions b1a6ccd425 [CI Skip] release/beta 4.11.3-5
skip-checks: true
2021-05-28 08:26:21 +00:00
Jaco adc40e581f Add stale.yml (#3582) 2021-05-28 10:14:47 +02:00
Jaco c6b0b0c161 Remove confusing external-use rpc-core README (#3581)
Closes https://github.com/polkadot-js/api/issues/3580
2021-05-28 10:14:24 +02:00
Github Actions bf5b14580b [CI Skip] release/beta 4.11.3-4
skip-checks: true
2021-05-28 07:08:13 +00:00
Jaco 088c02862b Added 9030 upgrade block for Westend (#3579) 2021-05-28 08:59:04 +02:00
Github Actions a05980900e [CI Skip] release/beta 4.11.3-3
skip-checks: true
2021-05-28 06:47:44 +00:00
Jaco 77019def08 Allow storage queries with default keys values (#3578)
* Allow storage queries with default keys values

* Cleanups

* Adjust

* Tuple test
2021-05-28 08:37:08 +02:00
Github Actions ae6a3307b1 [CI Skip] release/beta 4.11.3-2
skip-checks: true
2021-05-27 15:25:37 +00:00
Jaco 8cb15c6a87 Update Substrate static metadata (#3576) 2021-05-27 17:13:57 +02:00
Github Actions 389dbb58a9 [CI Skip] release/beta 4.11.3-1
skip-checks: true
2021-05-27 08:30:51 +00:00
Jaco 2d02f61fa7 Align Data.Raw decoding with Substrate (32-bytes) (#3573)
* Align Data.Raw decoding with Substrate (32-bytes)

* CHANGELOG

* Encoding test updates

* provider.disconnect

* Adjust provider tests

* Unique connection URLs

* Dangling tests

* detectOpenHandles

* Additional

* Remove rx test (catered for by Promise wrap)

* Additional cleanups to tests
2021-05-27 10:18:56 +02:00
Github Actions 7497ac723f [CI Skip] release/beta 4.11.3-0
skip-checks: true
2021-05-26 06:47:13 +00:00
Arjan Zijderveld 711a145e1e Changed firstSlot and lastSlot to firstPeriod and lastPeriod. Reference: [Polkadot definition source](https://github.com/paritytech/polkadot/blob/master/runtime/common/src/crowdloan.rs#L141) (#3568) 2021-05-26 08:38:22 +02:00
Github Actions 05e3db01ba [CI Skip] release/stable 4.11.2
skip-checks: true
2021-05-24 06:51:49 +00:00
Jaco 6158c07e0a 4.11.2 (#3565) 2021-05-24 08:42:06 +02:00
Github Actions ce505aaf62 [CI Skip] release/stable 4.11.1
skip-checks: true
2021-05-23 16:47:01 +00:00
Jaco 09f9a48037 4.11 (#3564) 2021-05-23 18:37:27 +02:00
Github Actions 700c1cfcd4 [CI Skip] release/beta 4.10.2-10
skip-checks: true
2021-05-23 16:18:10 +00:00
Jaco 7d2463e53f Update entries/keys for max of 256 items per call (#3563) 2021-05-23 18:08:30 +02:00
Github Actions a2ecd9bd3b [CI Skip] release/beta 4.10.2-9
skip-checks: true
2021-05-23 15:50:40 +00:00
Jaco b0de692147 Under Node.js allow for WS receiving up to 16MB messages (#3562) 2021-05-23 17:40:13 +02:00
Github Actions dcd53c76d7 [CI Skip] release/beta 4.10.2-8
skip-checks: true
2021-05-23 15:11:24 +00:00
Jaco 6ed90c6111 Augment NMap entries (#3556)
* Augment NMap entries

* CHANGELOG

* DropLast generic helper

* Keys checkType

* Signular argument

* Adjust augmentation

* Adjust

* restore key types

* NMap iterKey

* NMap keys/entries

* Adjust creation

* Simplify

* Update

* CHANGELOG
2021-05-23 17:00:58 +02:00
Github Actions babef6d7bc [CI Skip] release/beta 4.10.2-7
skip-checks: true
2021-05-23 12:47:52 +00:00
Jaco e2205a65e9 Bump deps (#3560)
* Bump deps

* yargs typing
2021-05-23 14:39:32 +02:00
Github Actions 32d55dfb18 [CI Skip] release/beta 4.10.2-6
skip-checks: true
2021-05-21 05:40:12 +00:00
Jaco 60e0d0eae4 Cleanup Rococo known types (#3555)
* Clenup Rococo known types

* CHANGELOG
2021-05-21 07:28:35 +02:00
Github Actions 9cef1febe1 [CI Skip] release/beta 4.10.2-5
skip-checks: true
2021-05-21 05:07:42 +00:00
Jaco 4c9032fedc Add state_getChildReadProof RPC (#3554)
* Add state_getChildReadProof RPC

* CHANGELOG
2021-05-21 06:58:36 +02:00
Github Actions 5b6f222e5e [CI Skip] release/beta 4.10.2-4
skip-checks: true
2021-05-20 13:28:08 +00:00
Jaco 47235d01bf Add types for Bridges (#3552)
* Add types for Bridges

* Bump deps
2021-05-20 15:17:42 +02:00
Github Actions 32efe83136 [CI Skip] release/beta 4.10.2-3
skip-checks: true
2021-05-20 12:13:02 +00:00
Jaco c4c099e693 Add types for uniques (#3551) 2021-05-20 14:02:10 +02:00
Github Actions f26ca0e624 [CI Skip] release/beta 4.10.2-2
skip-checks: true
2021-05-20 08:50:31 +00:00
Jaco 5f496f1809 Fix metadata V13 decoding (on NMap) (#3548) 2021-05-20 10:39:26 +02:00
Github Actions f1cbf8cc70 [CI Skip] release/beta 4.10.2-1
skip-checks: true
2021-05-19 15:11:05 +00:00
Jaco 8b7fccb744 DisallowSigned extension (#3547) 2021-05-19 16:59:57 +02:00
Github Actions 66d3486674 [CI Skip] release/beta 4.10.2-0
skip-checks: true
2021-05-18 19:01:54 +00:00
Jaco 2dbd217f6d Alias &'static[u8] -> Text (#3545)
* Alias &'static[u8] -> Text

* Bytes
2021-05-18 20:53:34 +02:00
Jaco fea9ae8f97 Westend has 16 nominator slots (#3544)
* Westend has 16 nominator slots

* CHANGELOG
2021-05-18 20:53:06 +02:00
Jaco 4e81bbc43c Return additional error information from decodeU8a (#3540) 2021-05-18 12:57:48 +02:00
Github Actions 83650b8f28 [CI Skip] release/stable 4.10.1
skip-checks: true
2021-05-17 05:00:09 +00:00
Jaco 50a3501dd2 4.10 (#3539) 2021-05-17 06:49:57 +02:00
Github Actions 526a3fd139 [CI Skip] release/beta 4.9.3-24
skip-checks: true
2021-05-16 18:33:15 +00:00
Jaco 3b996b3444 CompactSolution for 24 nominees (#3537)
* CompactSolution for 24 nominees

* Westend & Rococo

* CompactAssignments: 'CompactAssignmentsTo265'

* With{16, 24}

* CompactAssignmentsWith16 in test

* With16 in historic types

* RawSolution alias

* Types

* Bump common
2021-05-16 20:22:54 +02:00
Github Actions c72c9e4a5e [CI Skip] release/beta 4.9.3-23
skip-checks: true
2021-05-15 05:50:42 +00:00
Jaco 60a71a5ac9 Bump static Substrate metadata (#3532) 2021-05-15 07:39:22 +02:00
Jaco 26c3ccccc3 Additional phragmenElection check (#3531) 2021-05-15 07:32:32 +02:00
Github Actions 963e25934d [CI Skip] release/beta 4.9.3-22
skip-checks: true
2021-05-15 04:54:15 +00:00
Jaco 55d9f8a062 Fix 9010 upgrade blocks (#3530)
* Fix 9010 upgrade blocks

* CHANGELOG
2021-05-15 06:43:51 +02:00
Github Actions 700c8ba21f [CI Skip] release/beta 4.9.3-21
skip-checks: true
2021-05-14 16:16:15 +00:00
Jaco cbc255b4e7 Cater for new phragmenElection module (#3528) 2021-05-14 19:07:47 +03:00
Jaco 2fe1e5031e Add Westend & Kusama blocks for 9100 (#3527) 2021-05-14 18:01:07 +02:00
Github Actions f2cdac7875 [CI Skip] release/beta 4.9.3-20
skip-checks: true
2021-05-13 19:29:42 +00:00
Jaco 165405bdc3 Contracts read for variable-length bytes (#3526) 2021-05-13 21:19:11 +02:00
Github Actions f86d71524d [CI Skip] release/beta 4.9.3-19
skip-checks: true
2021-05-13 15:34:14 +00:00
Jaco 4d6d59f1c5 Adjust Compact toBigInt() (#3525) 2021-05-13 17:23:46 +02:00
Github Actions 7a709898e5 [CI Skip] release/beta 4.9.3-18
skip-checks: true
2021-05-13 07:17:24 +00:00
Jaco 121bfc7913 VecFixed with hex inputs (& adjust isPedantic) (#3522)
* VecFixed with hex inputs (& adjust isPedantic)

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

* Cleanups
2021-05-13 09:08:52 +02:00
Github Actions a04ccec445 [CI Skip] release/beta 4.9.3-17
skip-checks: true
2021-05-13 05:21:42 +00:00
Jaco 2611fc5e1a Handle Text is same way as Bytes (isPedantic mode) (#3521)
* Handle Text is same was as Bytes (isPedantic mode)

* Length on input

* tests

* raw decoding test
2021-05-13 07:10:44 +02:00
Github Actions cd5c306b22 [CI Skip] release/beta 4.9.3-16
skip-checks: true
2021-05-12 16:55:21 +00:00
Branan Riley ca6a7819f6 Update centrifuge-chain types for updated substrate used in parachain (#3520) 2021-05-12 18:44:35 +02:00
Github Actions 29c0ea9856 [CI Skip] release/beta 4.9.3-15
skip-checks: true
2021-05-12 13:21:30 +00:00
Jaco c82ed58d68 Bump common (#3519) 2021-05-12 15:11:14 +02:00
Github Actions 59a3867c50 [CI Skip] release/beta 4.9.3-14
skip-checks: true
2021-05-11 10:35:32 +00:00
Jaco 0fca4e6866 Raw getHeader value for metadata determination (#3490)
* Raw getHeader value for metadata determination

* Don't cache raw/json RPC calls

* getRuntimeVersion via .json RPC

* Minimal RuntimeVersion type

* getMetadata with isHistoric

* User .raw for Metadata

* Adjust types

* Updates

* Remove (now-unused) isCached

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

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

* Apply suggestions from code review

* Only decorate registry on scale

* tidy typings

* typing

* Linting updates

* CHANGELOG

* V2 contracts
2021-05-11 12:25:27 +02:00
Github Actions 3f9e65a179 [CI Skip] release/beta 4.9.3-13
skip-checks: true
2021-05-11 09:08:46 +00:00
Jaco 92bde9de6f Adjust ABI registry (#3516)
* Adjust ABI registry

* Remove V2 support

* instantiateWithCode mock
2021-05-11 10:58:20 +02:00
Github Actions 9b3158599c [CI Skip] release/beta 4.9.3-12
skip-checks: true
2021-05-11 08:12:16 +00:00
Jaco 206fb49df5 Cater for Abi type offsets in 1+ (#3514)
* Cater for Abi type offsets in 1+

* Update packages/api-contract/src/MetaRegistry.ts
2021-05-11 10:01:27 +02:00
Github Actions cc0ad9b04b [CI Skip] release/beta 4.9.3-11
skip-checks: true
2021-05-10 08:32:30 +00:00
Jaco 39902dd8ac Adjust DispatchError (#3513)
* Adjust DisptachError

* Merge master, rebuild generation
2021-05-10 11:23:15 +03:00
Github Actions 324e4ab89b [CI Skip] release/beta 4.9.3-10
skip-checks: true
2021-05-10 05:06:07 +00:00
KarishmaBothara 68bf0a487f Backward compatibility thing (#3511) 2021-05-10 06:56:04 +02:00
Github Actions 3acf7e0fd7 [CI Skip] release/beta 4.9.3-9
skip-checks: true
2021-05-10 04:45:08 +00:00
Jaco edaf13abe1 Updata cumulus types (#3512)
* Updata cumulus types

* yarn .lock
2021-05-10 06:33:20 +02:00
Github Actions b3649a70ce [CI Skip] release/beta 4.9.3-8
skip-checks: true
2021-05-09 07:58:08 +00:00
Jaco 80ab628643 Adjust contract call result decoding (#3510)
* Adjust types for node/node-template

* Adjust contract call result

* Adjust

* Raw directly

* CHANGELOG
2021-05-09 09:46:21 +02:00
Github Actions 76363c0142 [CI Skip] release/beta 4.9.3-7
skip-checks: true
2021-05-09 07:37:35 +00:00
Jaco 80c18c2201 Adjust types for node/node-template (#3509) 2021-05-09 09:27:23 +02:00
Github Actions fcf9b86b87 [CI Skip] release/beta 4.9.3-6
skip-checks: true
2021-05-07 12:52:17 +00:00
Jaco 1113a3d2f8 Use BN_* constants in contract default params (#3507) 2021-05-07 14:41:08 +02:00
Github Actions c899dbf893 [CI Skip] release/beta 4.9.3-5
skip-checks: true
2021-05-07 11:28:49 +00:00
Jaco be137b2a03 Fix ContractRx query result definitions (#3506) 2021-05-07 13:19:23 +02:00
Github Actions 122d780fe8 [CI Skip] release/beta 4.9.3-4
skip-checks: true
2021-05-07 08:57:49 +00:00
Jaco 12be027b18 Allow for Bounded* type usage (#3504)
* Allow for `Bounded*` type usage

* Adjust start index after found

* Adjust

* Add tests for bounded

* Bounded with length value

* adjust
2021-05-07 10:47:09 +02:00
Github Actions dfeef40037 [CI Skip] release/beta 4.9.3-3
skip-checks: true
2021-05-07 07:26:32 +00:00
Jaco a7b4fe4dd0 Adjust internal TS definitions for providers (#3503) 2021-05-07 09:16:10 +02:00
Github Actions f4ec64d6f5 [CI Skip] release/beta 4.9.3-2
skip-checks: true
2021-05-07 06:15:35 +00:00
JQQQ 9a0d39199e Allow rpc expose definition/ metadata (#3488)
* Expose rpc defination(meta)

* Fix lint

* Change def to meta
2021-05-07 08:04:55 +02:00
Github Actions 77d82d9511 [CI Skip] release/beta 4.9.3-1
skip-checks: true
2021-05-07 06:00:57 +00:00
Jaco 5464b91cc6 Bump dev (#3502) 2021-05-07 07:52:31 +02:00
Github Actions 64ff87952a [CI Skip] release/beta 4.9.3-0
skip-checks: true
2021-05-06 11:12:47 +00:00
WoeOm 0de39e4c52 adapt Darwinia, Crab Network types (#3498) 2021-05-06 13:03:16 +02:00
Github Actions 60bc384d22 [CI Skip] release/stable 4.9.2
skip-checks: true
2021-05-06 10:37:05 +00:00
Jaco Greeff ca7ea0e143 4.9.2 (publish failure on .1) 2021-05-06 13:26:36 +03:00
Github Actions 23d50248de [CI Skip] release/stable 4.9.1
skip-checks: true
2021-05-06 10:07:39 +00:00
Jaco ad4e54a2f6 4.9 (#3497) 2021-05-06 11:57:51 +02:00
Github Actions e659df27ae [CI Skip] release/beta 4.8.2-17
skip-checks: true
2021-05-06 09:09:11 +00:00
Jaco 6dc3c06fe8 Metadata bump for latest Substrate (#3496) 2021-05-06 11:01:00 +02:00
Github Actions 776956f166 [CI Skip] release/beta 4.8.2-16
skip-checks: true
2021-05-06 09:00:25 +00:00
Jaco 4c5203acba Optimize historic metadata retrieval from rpc core (#3495)
* Optimize historic metadata retrieval from rpc core

* Bump deps
2021-05-06 10:50:46 +02:00
Github Actions d80070a041 [CI Skip] release/beta 4.8.2-15
skip-checks: true
2021-05-05 19:44:34 +00:00
Jaco 1c00cb4c4e Align RPCs with Substrate master (#3493)
* Align RPCs with Substrate master

* Build interfaces, apply fixes

* Metadata v13 changes
2021-05-05 21:35:28 +02:00
Github Actions 736505603e [CI Skip] release/beta 4.8.2-14
skip-checks: true
2021-05-05 19:23:44 +00:00
Jaco c243da79e1 Prepare for auto-capability detection for historic queries (#3474)
* Add auto-capability detection for historic queries

* Detect

* Detection via storage length

* Capabilities via storage sizes

* Update CHANGELOG.md

* Explicit

* CHANGELOG

* Westend upgrade block

* Pass registry explcitly

* Updates

* Adjust

* .at remove capabilities call
2021-05-05 21:12:50 +02:00
Github Actions 2677f38090 [CI Skip] release/beta 4.8.2-13
skip-checks: true
2021-05-05 18:45:37 +00:00
Jaco 41d05d2402 Westend 9000 upgrade block (#3491)
* Westend 9000 upgrade block

* Upgrade block for Westend 9000

* Correct block
2021-05-05 20:37:13 +02:00
Github Actions 0f38584566 [CI Skip] release/beta 4.8.2-12
skip-checks: true
2021-05-05 16:38:02 +00:00
André Silva 2b7fb8667e parachains: update HostConfiguration type (#3492) 2021-05-05 19:27:39 +03:00
Github Actions ca18846bfb [CI Skip] release/beta 4.8.2-11
skip-checks: true
2021-05-05 10:04:57 +00:00
Jaco 4ba372d29b Remove deprecated api-contract methods (#3486)
* Remove deprectaed api-contract methods

* Remove deprecated read/exec from checkTypes
2021-05-05 11:54:25 +02:00
Github Actions bdc2d24366 [CI Skip] release/beta 4.8.2-10
skip-checks: true
2021-05-05 07:06:39 +00:00
Jaco 3de06c1d4c Support for metadata v13 (#3465)
* Support for metadata v13

* Lint fixes

* Lastest tag as string

* Documentation

* MagicNumber opt

* NMap enum entry

* NMapTypeLatest

* Adjust for NMap type overrides

* Static from v13

* Basic NMap support

* lint

* Test expectations
2021-05-05 08:55:49 +02:00
Github Actions b51149d895 [CI Skip] release/beta 4.8.2-9
skip-checks: true
2021-05-04 15:09:01 +00:00
Jaco Greeff e0fef55366 Adjust aliasses for paras* 2021-05-04 17:59:18 +03:00
Github Actions e2aac5f94a [CI Skip] release/beta 4.8.2-8
skip-checks: true
2021-05-04 09:45:59 +00:00
Jaco 8f44f84c7f Update ChangesTrieSignal (#3485) 2021-05-04 11:36:02 +02:00
Jaco d53a61ec86 ConsensusEngineId implements [u8; 4] (#3482)
* ConsensusEngineId implements [u8; 4]

* Adjust tests

* isLE
2021-05-04 11:27:01 +02:00
Github Actions cf18f79c14 [CI Skip] release/beta 4.8.2-7
skip-checks: true
2021-05-04 09:26:08 +00:00
Jaco beb8011b4c Adjust ContractInfo types (#3484) 2021-05-04 11:15:38 +02:00
Github Actions 38a601b665 [CI Skip] release/beta 4.8.2-6
skip-checks: true
2021-05-04 08:18:36 +00:00
Jaco 11a3483ce5 Adjust error logs on create (#3480) 2021-05-04 10:08:44 +02:00
Github Actions 1db133b741 [CI Skip] release/beta 4.8.2-5
skip-checks: true
2021-05-03 19:40:32 +00:00
Jaco 716dce0093 Westend 900 upgrade block (#3478) 2021-05-03 21:30:49 +02:00
Github Actions 3b53442172 [CI Skip] release/beta 4.8.2-4
skip-checks: true
2021-05-03 18:21:51 +00:00
Jaco 253d94a47d Adjust re-encoding of BitVec based on decoded length (#3476) 2021-05-03 20:12:37 +02:00
Github Actions fb1129a49b [CI Skip] release/beta 4.8.2-3
skip-checks: true
2021-05-03 17:23:51 +00:00
Jaco 1cc56d6e44 Adjust para types (#3475) 2021-05-03 19:14:15 +02:00
Github Actions 9e2983a735 [CI Skip] release/beta 4.8.2-2
skip-checks: true
2021-05-03 13:33:19 +00:00
Jaco a6fcba95de Adjust capability detection (#3473)
* Adjust capability detection

* Adjust types

* Fully known isU32
2021-05-03 15:24:31 +02:00
Github Actions c8c535834e [CI Skip] release/beta 4.8.2-1
skip-checks: true
2021-05-03 11:55:00 +00:00
Jaco b8d7c2e3e3 Re-add isPedantic check on storage decoding (#3471)
* Re-add isPedantic check on storage decoding

* Additional length log

* Check for existing system

* Adjust output length
2021-05-03 13:45:37 +02:00
Github Actions 0283d4727b [CI Skip] release/beta 4.8.2-0
skip-checks: true
2021-05-03 11:25:48 +00:00
Jaco a4ab732478 Additional Xcm types (#3472) 2021-05-03 13:16:18 +02:00
Github Actions 0dc121a796 [CI Skip] release/stable 4.8.1
skip-checks: true
2021-05-02 18:21:16 +00:00
Jaco a827131457 4.8 (#3470) 2021-05-02 20:11:35 +02:00
Github Actions 2174537f76 [CI Skip] release/beta 4.7.3-12
skip-checks: true
2021-05-02 07:32:19 +00:00
Jaco 53fca2406a Cleanup WebSocket handlers when close event has been received (#3469) 2021-05-02 09:24:10 +02:00
Github Actions 0eaba284ae [CI Skip] release/beta 4.7.3-11
skip-checks: true
2021-05-02 07:14:56 +00:00
Jaco 378f359a76 add known upgrade block for Polkadot v30 (#3468) 2021-05-02 09:04:48 +02:00
Github Actions 5460d96b5d [CI Skip] release/beta 4.7.3-10
skip-checks: true
2021-05-01 06:40:35 +00:00
Jaco b1353edc84 Expose additional camelCase method on AbiMessage (maps to decorated name) (#3466) 2021-05-01 08:31:16 +02:00
Github Actions 9129fed6e5 [CI Skip] release/beta 4.7.3-9
skip-checks: true
2021-04-30 12:56:27 +00:00
Jaco 7c4abacaca Cater for N-key hashing (#3451)
* Cater for N-key hashing

* Adjust

* Cleanups

* Update packages/types/src/primitive/types.ts

* Update packages/metadata/src/decorate/storage/createFunction.ts

* Update packages/metadata/src/decorate/storage/createFunction.ts

* Adjust

* Adjust

* DoubleMap arg check test

* On-demand create

* Rework
2021-04-30 14:48:19 +02:00
Github Actions 3664c7d81b [CI Skip] release/beta 4.7.3-8
skip-checks: true
2021-04-30 06:58:09 +00:00
Jaco f75b87c5a5 Verification test for 2-byte ss58 (#3464)
* Verification test for 2-byte ss58

* CHANGELOG
2021-04-30 08:50:11 +02:00
Github Actions 1c228216cd [CI Skip] release/beta 4.7.3-7
skip-checks: true
2021-04-30 06:21:25 +00:00
Jaco cec3c12795 Bump metadata (#3463) 2021-04-30 08:13:24 +02:00
Github Actions 0d0d12e85b [CI Skip] release/beta 4.7.3-6
skip-checks: true
2021-04-30 06:05:49 +00:00
Jaco 3a16e69be5 Bump deps (#3462) 2021-04-30 07:56:39 +02:00
Github Actions 4ae8e3909f [CI Skip] release/beta 4.7.3-5
skip-checks: true
2021-04-29 12:15:38 +00:00
Jaco 6e18bb3b1d Allow Metadata instances from JSON or Map (#3459)
* assert isU8a & isHex inputs on Metadata

* Remove _ in param

* Allow hex parsing

* CHANGELOG
2021-04-29 14:07:32 +02:00
Github Actions be153e13a6 [CI Skip] release/beta 4.7.3-4
skip-checks: true
2021-04-29 12:05:39 +00:00
Chevdor 4c01dfd0ab Fix metadata package link (#3458) 2021-04-29 13:55:23 +02:00
Github Actions b57c7a1343 [CI Skip] release/beta 4.7.3-3
skip-checks: true
2021-04-28 16:47:22 +00:00
Jaco da62acdf50 Adjust XcmError with updated WeightLimitReached (#3455) 2021-04-28 18:37:56 +02:00
Github Actions cc95e4fc0a [CI Skip] release/beta 4.7.3-2
skip-checks: true
2021-04-28 08:26:17 +00:00
Jaco 7f5647c6e1 Optimize metadata unknown type validation (#3453) 2021-04-28 10:16:38 +02:00
Github Actions c636d63bc0 [CI Skip] release/beta 4.7.3-1
skip-checks: true
2021-04-27 12:15:39 +00:00
Jaco 30c98ef857 Fix generation of well-known keys (#3452)
* Fix generation of well-known keys

* CHANGELOG

* Linting, unfiy decorate params

* Adjust
2021-04-27 14:05:59 +02:00
Github Actions debecde50f [CI Skip] release/beta 4.7.3-0
skip-checks: true
2021-04-27 05:03:10 +00:00
Jaco cd2cdd1184 De-alias XcmOutcome (#3449) 2021-04-27 06:53:40 +02:00
Github Actions f5c25d75ff [CI Skip] release/stable 4.7.2
skip-checks: true
2021-04-26 18:20:50 +00:00
Jaco 780cc62942 4.7.2 (#3448)
* 4.7.2

* XcmError update
2021-04-26 20:11:39 +02:00
Github Actions 165568c905 [CI Skip] release/beta 4.7.2-5
skip-checks: true
2021-04-26 16:34:59 +00:00
Jaco 976a48d8f9 Update .nvmrc (#3447)
As per https://github.com/polkadot-js/api/issues/3446 (also need one on common before bumping to a patch)
2021-04-26 19:24:44 +03:00
Github Actions 35cbbbe0ed [CI Skip] release/beta 4.7.2-4
skip-checks: true
2021-04-26 12:06:50 +00:00
Jaco 772769c981 Add membership derives (#3442) 2021-04-26 13:57:30 +02:00
Github Actions 1ba2bd1766 [CI Skip] release/beta 4.7.2-3
skip-checks: true
2021-04-26 10:43:48 +00:00
Jaco 4afa345a7d Cleanup encodedLength calculations (#3441)
* Cleanup encodedLength calculations

* Remove array santize

* Test adjustments
2021-04-26 12:33:16 +02:00
Github Actions 5c03359f32 [CI Skip] release/beta 4.7.2-2
skip-checks: true
2021-04-25 15:16:21 +00:00
Jaco Greeff 04120505f0 Fix H32 definition 2021-04-25 18:08:02 +03:00
Github Actions 7bd9dd65f8 [CI Skip] release/beta 4.7.2-1
skip-checks: true
2021-04-25 14:44:02 +00:00
Jaco 5f57ecb2e1 Update ETH types (#3439)
* Update ETH types

* Build
2021-04-25 16:34:42 +02:00
Github Actions 9123f1d805 [CI Skip] release/beta 4.7.2-0
skip-checks: true
2021-04-25 11:28:54 +00:00
Jaco 7050c4a554 Updated Xcm OriginKind enum (#3438) 2021-04-25 13:18:47 +02:00
Github Actions 62afb0b534 [CI Skip] release/stable 4.7.1
skip-checks: true
2021-04-25 05:18:10 +00:00
Jaco Greeff 5157ca5608 CHANGELOG bump 2021-04-25 08:08:28 +03:00
Jaco 315617c027 4.7 (#3435)
* 4.7

* Update CHANGELOG.md
2021-04-25 06:31:42 +02:00
Github Actions 7d33b4dec6 [CI Skip] release/beta 4.6.3-11
skip-checks: true
2021-04-24 08:06:21 +00:00
Jaco 2345f69c71 Add engines field to package.json (#3433) 2021-04-24 09:56:50 +02:00
Github Actions 3cef2fb4d5 [CI Skip] release/beta 4.6.3-10
skip-checks: true
2021-04-23 15:50:43 +00:00
Jaco 2bbf5513b2 Expand DispatchError (#3431) 2021-04-23 17:43:32 +02:00
Github Actions c146f06178 [CI Skip] release/beta 4.6.3-9
skip-checks: true
2021-04-23 05:44:16 +00:00
Jaco 5903704b61 Expand Data (from identity) with all is/as getters (#3429) 2021-04-23 07:34:01 +02:00
Github Actions 90d8db651b [CI Skip] release/beta 4.6.3-8
skip-checks: true
2021-04-22 13:10:53 +00:00
Jaco 557283a3d1 Struct decoding error messaging (#3425)
* Struct decoding error messaging

* Error adjust

* Tests

* Bump common, use stringify

* Linting

* Adjust

* Bumps

* Rebump

* Assert cleanups

* Don't modify original value on encoding

* util bump, fixe compact encoding
2021-04-22 15:02:54 +02:00
Github Actions 88b84dcf75 [CI Skip] release/beta 4.6.3-7
skip-checks: true
2021-04-21 17:13:17 +00:00
Jaco 45d190eaca Revery Westend beefy keys (#3423) 2021-04-21 20:03:43 +03:00
Github Actions 6d32328509 [CI Skip] release/beta 4.6.3-6
skip-checks: true
2021-04-21 10:37:47 +00:00
Jaco ba470e7417 Bump WS reconnect delay from 1s -> 2.5s (#3420) 2021-04-21 12:27:16 +02:00
Github Actions 4a16e46f88 [CI Skip] release/beta 4.6.3-5
skip-checks: true
2021-04-21 09:39:02 +00:00
Jaco Greeff ada0d99a84 Sorting 2021-04-21 12:28:51 +03:00
Github Actions e486fc4316 [CI Skip] release/beta 4.6.3-4
skip-checks: true
2021-04-21 08:58:57 +00:00
Jaco 6e5c6f4e0b Bump deps (#3418)
* Bump deps

* Sorting md
2021-04-21 10:48:52 +02:00
Github Actions 21ddcaf173 [CI Skip] release/beta 4.6.3-3
skip-checks: true
2021-04-21 07:17:45 +00:00
Jaco 6085b994f6 Remove well-known json dependency (#3417) 2021-04-21 09:09:30 +02:00
Github Actions 7c3bf05868 [CI Skip] release/beta 4.6.3-2
skip-checks: true
2021-04-21 07:03:45 +00:00
Jaco 8bce5b4a09 Add support for BoundedVec (#3415)
* Add support for BoundedVec

* Update packages/types/src/create/sanitize.ts

* Cleanup sanitize duplication

* Additional cleanups

* Update packages/types/src/create/sanitize.ts

* Box wrap
2021-04-21 08:52:56 +02:00
Github Actions 7a6077301f [CI Skip] release/beta 4.6.3-1
skip-checks: true
2021-04-20 09:05:25 +00:00
Jaco 3f2767462f Adjust statemint proxy type (#3412) 2021-04-20 10:55:28 +02:00
Github Actions ecc37d11df [CI Skip] release/beta 4.6.3-0
skip-checks: true
2021-04-20 06:02:39 +00:00
Jaco 0589d151da Add Xcm Plurality types (#3411) 2021-04-20 07:53:24 +02:00
Jaco 47cd6c6410 RewardDestination: None types (#3231) 2021-04-20 07:44:42 +02:00
612 changed files with 183428 additions and 14455 deletions
+9 -2
View File
@@ -1,4 +1,4 @@
29
32
1.4.2
1.6.2
1.11.2
@@ -19,5 +19,12 @@
3.10.2
4.0.2
4.0.3
4.6.2
4.7.2
4.9.2
4.11.2
4.16.2
4.6.2
5.3.2
5.5.2
5.8.2
+23
View File
@@ -0,0 +1,23 @@
name: 'Lock Threads'
on:
schedule:
- cron: '30 1/2 * * *'
jobs:
lock:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v2
with:
github-token: ${{ secrets.GH_PAT_BOT }}
issue-lock-inactive-days: '7'
issue-lock-comment: >
This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue
if you think you have a related problem or query.
pr-lock-inactive-days: '2'
pr-lock-comment: >
This pull request has been automatically locked since there
has not been any recent activity after it was closed.
Please open a new issue for related bugs.
+1 -8
View File
@@ -6,11 +6,11 @@ on:
jobs:
master:
if: "! startsWith(github.event.head_commit.message, '[CI Skip]')"
strategy:
matrix:
step: ['build:release']
name: ${{ matrix.step }}
if: "! startsWith(github.event.head_commit.message, '[CI Skip]') && github.repository == 'polkadot-js/api'"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@@ -25,10 +25,3 @@ jobs:
run: |
yarn install --immutable | grep -v 'YN0013'
yarn ${{ matrix.step }}
dummy:
runs-on: ubuntu-latest
steps:
- name: dummy
run: |
echo "Dummy skip step"
+18
View File
@@ -0,0 +1,18 @@
name: Semgrep
on:
pull_request: {}
push:
branches:
- master
jobs:
check:
if: "! startsWith(github.event.head_commit.message, '[CI Skip]') && (!github.event.pull_request || github.event.pull_request.head.repo.full_name == github.repository)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: returntocorp/semgrep-action@v1
with:
auditOn: push
publishToken: ${{ secrets.SEMGREP_APP_TOKEN }}
publishDeployment: 1395
+17
View File
@@ -0,0 +1,17 @@
name: 'Close stale issues and PRs'
on:
schedule:
- cron: '30 2/2 * * *'
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GH_PAT_BOT }}
stale-issue-message: 'This issue has been open for 21 days with no activity and is not labelled as an enhancement. It will be closed in 7 days.'
stale-issue-label: 'stale'
exempt-issue-labels: '-size-l,-size-m,-size-s,-size-xl,-size-xs,[bug]'
days-before-stale: 21
days-before-close: 7
+1 -1
View File
@@ -1 +1 @@
12
14
+3
View File
@@ -0,0 +1,3 @@
build
coverage
packages
+4
View File
@@ -0,0 +1,4 @@
// Copyright 2017-2021 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
module.exports = require('@polkadot/dev/config/prettier.cjs');
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-55
View File
File diff suppressed because one or more lines are too long
+631
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -10,4 +10,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: "@yarnpkg/plugin-version"
yarnPath: .yarn/releases/yarn-2.4.1.cjs
yarnPath: .yarn/releases/yarn-3.0.1.cjs
+444 -2
View File
@@ -1,8 +1,450 @@
# CHANGELOG
## 5.8.2 Sep 6, 2021
Contributed:
- Correct Xcm V1 `MultiLocation` definitions (Thanks to https://github.com/apopiak)
Changes:
- Adjust Kusama Xcm overrides
## 5.8.1 Sep 6, 2021
Upgrade priority: Low.
Changes:
- Add `Auction` to Kusama `ProxyType` definition
- Adjust Xcm definitions with latest v1 & v2 types
- Support for `scale-info` 1.0 `Range` mapping
- Bump static metadata for latest Substrate, Polkadot & Kusama
## 5.7.1 Aug 29, 2021
Upgrade priority: Low.
Changes:
- Optimize `Vec` construction (no re-create on new arrays)
- Adjust output for enums in `toHuman`
- Adjust aliases for new parachain module locations
- Support for versioned xcm types (Polkadot master)
- Add support for `Range` in `PortableRegistry` (used in Metadata 14)
- Adjust balances derive for non-existent instances
- Ensure Statemint (current) defaults to xcm v0
- Add Kusama 9090 upgrade block
## 5.6.1 Aug 23, 2021
Upgrade priority: Low. Recommended for users of Xcm, preparing for Kusama/Westend 9100
Contributed:
- Support 0...N-1 args on `keys/entries` (Thanks to https://github.com/hamidra)
Changes:
- Updated XCM types, `AssetId`, `MultiAssets`, `MultiAssetV1`, `AssetInstanceV1`, `XcmOrderV1`
- Rename `Null` entry in `MultiLocation` to `Here` (Xcm V1)
- Westend 9090 upgrade block
- Bump static Substrate, Kusama & Polkadot metadata
## 5.5.2 Aug 19, 2021
Upgrade priority: Medium. Contains fixes for parachain types, affecting historic block retrieval on Kusama.
Changes:
- Adjust `ValidDisputeStatementKind` enum to latest version
- Only enable API health keepalive on connections supporting subscriptions
## 5.5.1 Aug 15, 2021
Upgrade priority: Low. Recommended for users of TS (`createType` and `bigint` adjustments)
Contributed:
- Add `Range` & `RangeInclusive` types (Thanks to https://github.com/c410-f3r)
- Always use TS `bigint` type (Thanks to https://github.com/ntduan)
Changes:
- Loosen pedantic check not to fail on all-empty values
- Extend `createType` auto-TS decoration for `BreeMap`, `BTreeSet`, `HashMap`, `Range`
- Add Polkadot 9080 upgrade block
## 5.4.1 Aug 9, 2021
Upgrade priority: Low. Recommended for potential users of NMap.
- **Important** The `ClassOf` alias for `createClass` has been removed, use `createClass` (with new generics) directly
Contributed:
- Enable `.keys()/.entries()` on NMap (Thanks to https://github.com/hamidra)
Changes:
- `createType<T = Codec>('...': K)` now returns `Codec` when `K` is not known
- `createType` does basic TypeScript type matching on the input type
- Handle `BitSequence` in `PortableRegistry`
- Ensure API `isConnected` is set before connect/disconnect events are fired
- Move all static test support files into `@polkadot/types-support`
- Align static Metadata with latest Substrate, Polkadot & Kusama
- Adjust v14 Metadata definitions to latest version
## 5.3.2 Aug 3, 2021
Upgrade priority: Low. Recommended for users of bridges.
Contributed:
- Add missing bridges types (Thanks to https://github.com/tomusdrw)
Changes:
- Align static metadata with latest Substrate
## 5.3.1 Aug 2, 2021
Upgrade priority: Low. Recommended for users of `api.at(...)` interfaces
Changes:
- Check specName & specVersion for historic registries (caters for runtime renames)
- Fix circular dependencies in codec utils
- Fix `api.at(<blockHash>)` to decorate with the correct storage hash
- Adjustments for upcoming metadata v14 in type creation & `PortableRegistry`
- Add Kusama 9080 upgrade block
- Add v13/v14 static metadata for Polkadot
- Align static metadata with latest Substrate
## 5.2.1 Jul 26, 2021
Upgrade priority: Low. Recommended for users of `BTreeMap` and `BTreeSet`
Contributed:
- Perform sorting on `BTree{Map, Set}`, aligning with Substrate (Thanks to https://github.com/Lezek123)
Changes:
- Adjust RPC to use `registry.createType` with optionality (required for metadata v14)
- Adjust alphabetical sorting for TS type generation
- Adjustments for upcoming metadata v14 in type creation & `PortableRegistry`
- Provide the capability to convert v13 Metadata to upcoming v14
## 5.1.1 Jul 19, 2021
Upgrade priority: Low. Recommended for users of XCM with type fixes.
- **Breaking changes** With the support for v14 metadata parsing, the `documentation` fields on metadata was renamed to `docs` for consistency, aligning with the SCALE type generators.
Contributed:
- Don't clear rpc decoration on Api clone (Thanks to https://github.com/ianhe8x)
- Align Xcm Junction type with Substrate (Thanks to https://github.com/dt665m)
Changes:
- Update `ParaPastCodeMeta` with `ReplacementTimes`
- Add mappings for `AccountId20` & `AccountId32` types
- Adjust scale-info types with Substrate (mapping for api-contracts to old)
- Allow nested structs in enum definitions & generation
- Allow for parsing of v14 metadata (not enabled by default, not merged into Substrate as of yet)
## 5.0.1 Jul 11, 2021
Upgrade priority: Low. Recommended for users of current-generation Substrate chains.
- **Breaking change** The `@polkadot/metadata` package has been removed, adjust imports to `@polkadot/types`
- **Important** Internally rxjs has been upgraded to the 7.0 version, affecting users of the `ApiRx` interface
Changes:
- Remove the `@polkadot/metadata` package, consolidate into `@polkadot/types`
- Contract reads will now expose an additional `gasRequired` (total estimated)
- Allow schedule derives to handle scheduler entries that cannot decode
- Add missing historic `Heartbeat: HeartbeatTo244` mapping to Westend
- Adjust Ws `.disconnect()` logic to always clear auto-connect
- Add `BlockNumberFor` type mapping
- Add Westend 9080 upgrade block
- Add `derive.crowdloan.contributions(paraId)`
- Allow building as a completely stand-alone browser bundle (experimental)
- Update to latest `@polkadot/x-rxjs` with RxJs 7.2
- Align static metadata with latest Substrate
## 4.17.1 Jul 5, 2021
Upgrade priority: Low. Allows cleaner access to multiple `.at` queries via new API.
Contributed:
- Added `Emergency` to `ElectionPhase` (Thanks to https://github.com/arjanz)
Changes:
- Added `await api.at(<blockHash>)` to retrieve API instances at a point
- Added `fallbackType` for type classes (only struct, as defined)
- Allow `instances` API config to drive derive collective locations
- Ensure correct registry is attached to historic metadata
- Align static metadata with latest Substrate
## 4.16.2 Jun 27, 2021
Upgrade priority: Low. Recommended for Polkadot with runtime >= 9050.
Changes:
- Correct `CompactAssignments` & `RawSolution` types for Polkadot
## 4.16.1 Jun 26, 2021
Upgrade priority: Low. Recommended for full from-genesis queries on Kusama.
Contributed:
- Adjust types for uniques (Thanks to https://github.com/Yuripetusko)
Changes:
- Add Kusama, Polkadot & Westend 9050 upgrade blocks
- Add Kusama & Westend 9070 upgrade blocks
- Adjust API decoration to lazy-create event and storage types
- Use TS `override` as applicable (with `--noImplicitOverrides` option)
- Add missing historic `Heartbeat: HeartbeatTo244` mapping to Kusama
- Remove duplication from contracts registry
- Add explicit check for scale-info 0.7+ (contracts index lookups)
- Align static metadata with latest Substrate
## 4.15.1 Jun 19, 2021
Upgrade priority: Medium. Recommended for all chains where Xcm is used (addition of new `XcmOrigin`)
Contributed:
- Added `ChargeAssetTxPayment` extension (Thanks to https://github.com/apopiak)
Changes:
- Allow for type decoding of nested fixed vectors, tuples and structs
- Added `childstate_getKeysPaged` RPC
- Add `XcmOrigin` mapping for `OriginCaller` generation
- Align static metadata with latest Substrate
- Adjust error message for contracts V3 (extrinsic from runtime)
- Correct module optionality in `api.derive.balances.account`
- Add alias for `GenericAddress` -> `GenericMultiAddress`
- Adjust metadata doc generation (keep spaces between subsequent lines)
## 4.14.1 Jun 14, 2021
Upgrade priority: Low. Internal adjustment only, no major external usage changes.
Contributed:
- Adjust types for uniques (Thanks to https://github.com/hamidra)
- Add `ValidationCodeHash` type (Thanks to https://github.com/andresilva)
- Extend `OriginCaller` type creation (Thanks to https://github.com/xlc)
Changes:
- Do strict length checking on `[u8; <length>]` type inputs
- Adjust keys/entries retrieval batch sizes
- Add upgrade block for Kusama 9040
- Use `BN` imports from `@polkadot/util`
## 4.13.1 Jun 6, 2021
Upgrade priority: Medium. Required for users connecting to Statemine and future Kusama upgrades.
Changes:
- Overrides for `westmint` spec (same as `statemint`)
- Adjust `tx.session.setKeys` TS augmentation to allow `string` & `Uint8Array` keys
- Add & adjust types for latest Cumulus code
- Added 9031-9033 upgrade block for Westend
- Update static metadata to latest Substrate
- Optimize map retrieval with split page sizes for keys & values
- Sanitizing `BN` imports to `type`-only as required
## 4.12.1 May 30, 2021
Upgrade priority: Low. Internal adjustment only, no major external usage changes.
Changelog:
- Update `FundInfo` type with Polkadot (Thanks to https://github.com/arjanz)
Changes:
- Allow storage queries with default keys values
- Align identity `Data` to limit to 32 bytes in the `Raw` enum (as per Substrate)
- Align static (test & docs-only) metadata with latest Substrate master
- Added 9030 upgrade blocks for Kusama & Westend
- Cleanup of Eth pallet RPC definitions
- Cleanup README for `@polkadot/rpc-core` (recommended for internal-usage only)
- Cleanup internal tests (no dangling handles, cater for Jest 27)
## 4.11.2 May 24, 2021
Upgrade priority: Low. Recommended where users are having TS mismatches with type definitions created on older versions.
Changes:
- Add backwards-compatible TS-only `AugmentedQueryDoubleMap` type (unused now in type generation)
## 4.11.1 May 23, 2021
Upgrade priority: Low. Recommended for users using staking entries on Polkadot and users of Substrate master.
Changes:
- Fix metadata v13 storage decoding on `NMap`
- Add augmentation & keys/entries for NMap types
- Return additional error information from internal u8a decoding failures
- Adjust Westend types for 16 nominators-only
- Add support for `DisallowSigned` (as per shell runtime) extension
- Display small hex-slice with u8a decoding failures
- Add `state_getChildReadProof` RPC
- Cleanup Rococo known types (only as used)
- Under Node.js allow for WS receiving up to 16MB messages
- Update entries/keys for max of 256 items per call
## 4.10.1 May 17, 2021
Upgrade priority: Medium. Recommended for uses of Polkadot/Kusama 9010 runtimes.
- **Breaking change** Support for the contracts V2 compatibility has been dropped in `@polkadot/api-contract`
Contributed:
- Expose RPC definitions via `.meta` (Thanks to https://github.com/jiqiang90)
- Adjust staking derives for chain-specific optional fields (https://github.com/WoeOm)
- Update base Centrifuge types (Thanks to https://github.com/branan)
Changes:
- Allow for `Bounded*` type usage (as per latest Substrate)
- Adjust internal TS definitions for providers
- Fix `ContractRx` query result definitions (no extra Observable)
- Handle contract call RPC result directly as `Raw` (returned as hex)
- Use `BN_*` constants as non-specified defaults in contract interfaces
- Remove all type overrides for node/node-template (API tracks latest)
- Contracts ABI now supports metadata version where indexes are 0-based
- Remove support for the old-style V2 contracts from `@polkadot/api-contract`
- Adjust historic decoration, return as-at registry via `getHeader`, `getMetadata` & `getRuntimeVersion`
- Adjust `VecFixed` to allow for the handling of hex inputs
- Adjust `Compact<*>` to allow for wrapped `toBigInt()` conversions
- Fix `isPedantic` decoding to correctly handle `Text`
- Cater for new `phragmenElection` module naming
- Add Kusama & Westend 9010 upgrade blocks
- Adjust `CompactSolution` for 24 nominators
- Bump static metadata to latest Substrate
## 4.9.1 May 6, 2021
Upgrade priority: Medium. Required for the next v0.9.0 Polkadot/Kusama chain upgrades where parachains are used.
- **Breaking change** The previously deprecated contracts interfaces, has been removed. Update to `<myContract>.query.*`, `<myContract>.tx.*` and `<myCode>.tx.*` interfaces as per the previous code usage hints.
- **Important** By default the `isPedantic` mode is now switched on for storage queries. This means that the API will fail on any types where the input/output decoding doesn't match 100%
Changes:
- Re-add isPedantic check on storage decoding
- `ConsensusEngineId` now implements `[u8;4]` (mapping closer to Rust source)
- Additional Xcm types
- Adjust parachain types
- Remove error logging on createType (details passed in error)
- Adjust `ContractInfo` type as per latest Substrate
- Adjust `DigestItem` type as per latest Substrate
- Adjust re-encoding of `BitVec` based on decoded length
- Added `contracts_instantiate`, `state_traceBlock` & `system_reservedPeers` RPCs
- Prepare for auto-capability detection with historic `.at` queries
- Add known upgrade block for Westend 900 & 9000
- Remove all deprecated interfaces inside `@polkadot/api-contracts`
- Initial support for NMap storage keys
- Support metadata v13 from Substrate (upcoming upgrade)
- Optimize historic metadata retrieval from rpc core
## 4.8.1 May 2, 2021
Upgrade priority: Low. Recommended when using or developing for parachains.
Changes:
- De-alias xcm `Outcome` (used in multiple pallettes)
- Adjust xcm types as per latest, e.g. `XcmError`
- Fix generate of well-known storage keys (e.g. `:code`)
- Optimize metadata unknown type validation
- Allow metadata creation for `Map` or `Record`
- Expose additional camelCase `method` on `AbiMessage` (maps to decorated name)
- Added explicit double-byte ss58 `AccountId` encoding test
- Add known upgrade block for Polkadot v30
- Cleanup WebSocket handlers when close event has been received
- Update to latest Substrate metadata
## 4.7.2 Apr 26, 2021
Upgrade priority: Low. Recommended for users of 4.7.1 using nvm
Changes:
- Update `EthBlock`/`EthHeader` types (as per Rust origin)
- Updated Xcm `OriginKind` enum
- Add derives for `membership`
- Cleanups on encodedLength calculations
- Update `.nvmrc` to reflect engines changes
## 4.7.1 Apr 25, 2021
Upgrade priority: Low. Recommended for users following Substrate master.
Changes:
- Adjust Struct decoding with better error messages on invalid input objects
- Add support for new `BoundedVec` type
- Expand `Data` type (as used in identity), with all is/as getters
- Updated `Xcm` types (with Plularity)
- Adjust `DispatchError` type as per current Substrate master
- Adjusted Statemint `Proxy` type
- Remove metadata generation dependency on well-known.json (dedupe)
- Adjust WebSocket reconnection delay from 1s to 2.5s
- Revert Beefy keys addition for Westend
- Add explicit `engines` config to `package.json`
- Support for `None` in `RewardDestination`
- Align with latest substrate metadata
## 4.6.2 Apr 19, 2021
Upgrade priority: Low.
Upgrade priority: Low. Recommended for users of Kusama/Polkadot.
Changes:
@@ -18,7 +460,7 @@ Changes:
- Assert keypair validity in signing operations
- Expose `internalError` on submittable results (e.g. event decoding errors)
- Simplify session derives for old/new
- Add statemint to known types
- Add Statemint to known types
- Add support for `rpc.beefy.subscribeJustifications`
- Update Xcm types
- Explicitly handle `isReadyOrError` with `Api.create`
+1 -1
View File
@@ -21,7 +21,7 @@ The API is split up into a number of internal packages -
- [@polkadot/api](packages/api/) The API library, providing both Promise and RxJS Observable-based interfaces. This is the main user-facing entry point.
- [@polkadot/api-derive](packages/api-derive/) Derived results that are injected into the API, allowing for combinations of various query results (only used internally and exposed on the Api instances via `api.derive.*`)
- [@polkadot/api-metadata](packages/api-metadata/) Base extrinsic, storage and constant injectors for injection
- [@polkadot/metadata](packages/metadata/) Base extrinsic, storage and constant injectors for injection
- [@polkadot/rpc-core](packages/rpc-core/) Wrapper around all [JSON-RPC methods](https://polkadot.js.org/docs/substrate/rpc) exposed by a Polkadot network client
- [@polkadot/rpc-provider](packages/rpc-provider/) Providers for connecting to nodes, including WebSockets and Http
+2 -13
View File
@@ -12,20 +12,9 @@ module.exports = {
'@polkadot/metadata(.*)$': '<rootDir>/packages/metadata/src/$1',
'@polkadot/rpc-(core|provider)(.*)$': '<rootDir>/packages/rpc-$1/src/$2',
'@polkadot/typegen(.*)$': '<rootDir>/packages/typegen/src/$1',
'@polkadot/types-known(.*)$': '<rootDir>/packages/types-known/src/$1',
'@polkadot/types-(known|support)(.*)$': '<rootDir>/packages/types-$1/src/$2',
// eslint-disable-next-line sort-keys
'@polkadot/types(.*)$': '<rootDir>/packages/types/src/$1'
},
modulePathIgnorePatterns: [
'<rootDir>/packages/api/build',
'<rootDir>/packages/api-contract/build',
'<rootDir>/packages/api-derive/build',
'<rootDir>/packages/metadata/build',
'<rootDir>/packages/rpc-core/build',
'<rootDir>/packages/rpc-provider/build',
'<rootDir>/packages/typegen/build',
'<rootDir>/packages/types/build',
'<rootDir>/packages/types-known/build'
],
transformIgnorePatterns: ['/node_modules/(?!@polkadot|@babel/runtime/helpers/esm/)']
testTimeout: 30000
};
+12 -10
View File
@@ -8,31 +8,33 @@
"packages/*"
],
"resolutions": {
"typescript": "^4.2.4"
"typescript": "^4.4.2"
},
"scripts": {
"build": "yarn build:interfaces && polkadot-dev-build-ts",
"build:extra": "(cd packages/typegen && copyfiles scripts/* build)",
"build:interfaces": "polkadot-types-internal-interfaces",
"build:release": "polkadot-ci-ghact-build",
"build:rollup": "polkadot-exec-rollup --config",
"docs:metadata": "polkadot-types-internal-metadata",
"chain:info": "polkadot-types-chain-info",
"lint": "polkadot-dev-run-lint",
"clean": "polkadot-dev-clean-build",
"postinstall": "polkadot-dev-yarn-only",
"test": "polkadot-dev-run-test --coverage --runInBand --testPathIgnorePatterns e2e",
"test:one": "polkadot-dev-run-test",
"test": "polkadot-dev-run-test --coverage --forceExit --runInBand --testPathIgnorePatterns e2e",
"test:one": "polkadot-dev-run-test --detectOpenHandles --forceExit",
"test:watch": "polkadot-dev-run-test --watch"
},
"devDependencies": {
"@babel/core": "^7.13.15",
"@babel/register": "^7.13.14",
"@babel/runtime": "^7.13.10",
"@polkadot/dev": "^0.62.8",
"@polkadot/ts": "^0.3.62",
"@babel/core": "^7.15.5",
"@babel/register": "^7.15.3",
"@babel/runtime": "^7.15.4",
"@polkadot/dev": "^0.62.66",
"@polkadot/ts": "^0.4.7",
"@polkadot/typegen": "workspace:packages/typegen",
"@types/jest": "^26.0.22",
"@types/jest": "^27.0.1",
"copyfiles": "^2.4.1"
},
"version": "4.6.2"
"version": "5.8.2",
"packageManager": "yarn@3.0.1"
}
+9 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-contract",
"version": "4.6.2",
"version": "5.8.2",
"type": "module",
"description": "Interfaces for interacting with contracts and contract ABIs",
"main": "index.js",
@@ -8,6 +8,9 @@
"./detectPackage.js",
"./detectPackage.cjs"
],
"engines": {
"node": ">=14.0.0"
},
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
"contributors": [],
@@ -16,11 +19,10 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
"dependencies": {
"@babel/runtime": "^7.13.10",
"@polkadot/api": "4.6.2",
"@polkadot/types": "4.6.2",
"@polkadot/util": "^6.2.1",
"@polkadot/x-rxjs": "^6.2.1",
"bn.js": "^4.11.9"
"@babel/runtime": "^7.15.4",
"@polkadot/api": "5.8.2",
"@polkadot/types": "5.8.2",
"@polkadot/util": "^7.3.1",
"rxjs": "^7.3.0"
}
}
+17 -18
View File
@@ -3,15 +3,13 @@
import type { Bytes } from '@polkadot/types';
import type { ChainProperties, ContractConstructorSpec, ContractEventSpec, ContractMessageParamSpec, ContractMessageSpec, ContractProject } from '@polkadot/types/interfaces';
import type { AnyJson, Codec, CodecArg } from '@polkadot/types/types';
import type { AnyJson, Codec } from '@polkadot/types/types';
import type { AbiConstructor, AbiEvent, AbiMessage, AbiParam, DecodedEvent, DecodedMessage } from './types';
import { assert, assertReturn, compactAddLength, compactStripLength, isNumber, isObject, isString, logger, stringCamelCase, u8aConcat, u8aToHex } from '@polkadot/util';
import { assert, assertReturn, compactAddLength, compactStripLength, isNumber, isObject, isString, logger, stringCamelCase, stringify, u8aConcat, u8aToHex } from '@polkadot/util';
import { MetaRegistry } from './MetaRegistry';
const EMPTY_U8A = new Uint8Array();
const l = logger('Abi');
function findMessage <T extends AbiMessage> (list: T[], messageOrId: T | string | number): T {
@@ -21,7 +19,7 @@ function findMessage <T extends AbiMessage> (list: T[], messageOrId: T | string
? list.find(({ identifier }) => [identifier, stringCamelCase(identifier)].includes(messageOrId.toString()))
: messageOrId;
return assertReturn(message, `Attempted to call an invalid contract interface, ${JSON.stringify(messageOrId)}`);
return assertReturn(message, () => `Attempted to call an invalid contract interface, ${stringify(messageOrId)}`);
}
export class Abi {
@@ -45,13 +43,13 @@ export class Abi {
assert(isObject(json) && !Array.isArray(json) && json.metadataVersion && isObject(json.spec) && !Array.isArray(json.spec) && Array.isArray(json.spec.constructors) && Array.isArray(json.spec.messages), 'Invalid JSON ABI structure supplied, expected a recent metadata version');
this.json = json;
this.registry = new MetaRegistry(chainProperties);
this.registry = new MetaRegistry(json.metadataVersion as string, chainProperties);
this.project = this.registry.createType('ContractProject', json);
this.registry.setMetaTypes(this.project.types);
this.project.types.forEach((_, index) =>
this.registry.getMetaTypeDef({ type: this.registry.createType('SiLookupTypeId', index + 1) })
this.registry.getMetaTypeDef({ type: this.registry.createType('Si0LookupTypeId', index + this.registry.typeOffset) })
);
this.constructors = this.project.spec.constructors.map((spec: ContractConstructorSpec, index) =>
this.#createMessage(spec, index, {
@@ -81,7 +79,7 @@ export class Abi {
const index = data[0];
const event = this.#events[index];
assert(event, `Unable to find event with index ${index}`);
assert(event, () => `Unable to find event with index ${index}`);
return event.fromU8a(data.subarray(1));
}
@@ -118,7 +116,7 @@ export class Abi {
type: this.registry.getMetaTypeDef(arg.type)
};
} catch (error) {
l.error(`Error expanding argument ${index} in ${JSON.stringify(spec)}`);
l.error(`Error expanding argument ${index} in ${stringify(spec)}`);
throw error;
}
@@ -129,7 +127,7 @@ export class Abi {
const args = this.#createArgs(spec.args, spec);
const event = {
args,
docs: spec.docs.map((doc) => doc.toString()),
docs: spec.docs.map((d) => d.toString()),
fromU8a: (data: Uint8Array): DecodedEvent => ({
args: this.#decodeArgs(args, data),
event
@@ -143,19 +141,21 @@ export class Abi {
#createMessage = (spec: ContractMessageSpec | ContractConstructorSpec, index: number, add: Partial<AbiMessage> = {}): AbiMessage => {
const args = this.#createArgs(spec.args, spec);
const identifier = spec.name.toString();
const message = {
...add,
args,
docs: spec.docs.map((doc) => doc.toString()),
docs: spec.docs.map((d) => d.toString()),
fromU8a: (data: Uint8Array): DecodedMessage => ({
args: this.#decodeArgs(args, data),
message
}),
identifier: spec.name.toString(),
identifier,
index,
method: stringCamelCase(identifier),
selector: spec.selector,
toU8a: (params: CodecArg[], additional?: Uint8Array) =>
this.#encodeArgs(spec, args, params, additional)
toU8a: (params: unknown[]) =>
this.#encodeArgs(spec, args, params)
};
return message;
@@ -185,14 +185,13 @@ export class Abi {
return message.fromU8a(trimmed.subarray(4));
}
#encodeArgs = ({ name, selector }: ContractMessageSpec | ContractConstructorSpec, args: AbiParam[], data: CodecArg[], additional = EMPTY_U8A): Uint8Array => {
assert(data.length === args.length, `Expected ${args.length} arguments to contract message '${name.toString()}', found ${data.length}`);
#encodeArgs = ({ name, selector }: ContractMessageSpec | ContractConstructorSpec, args: AbiParam[], data: unknown[]): Uint8Array => {
assert(data.length === args.length, () => `Expected ${args.length} arguments to contract message '${name.toString()}', found ${data.length}`);
return compactAddLength(
u8aConcat(
this.registry.createType('ContractSelector', selector).toU8a(),
...args.map(({ type }, index) => this.registry.createType(type.type as 'Text', data[index]).toU8a()),
additional
...args.map(({ type }, index) => this.registry.createType(type.type as 'Text', data[index]).toU8a())
)
);
}
+17 -9
View File
@@ -4,27 +4,35 @@
import fs from 'fs';
import path from 'path';
import { TypeDefInfo } from '@polkadot/types/types';
import abis from '../test/contracts';
import { Abi } from '.';
function stringifyInfo (key: string, value: unknown): unknown {
return key === 'info'
? TypeDefInfo[value as number]
: value;
}
describe('MetaRegistry', (): void => {
Object.keys(abis).forEach((abiName) => {
it(`initializes from a contract ABI (${abiName})`, (): void => {
const abi = new Abi(abis[abiName]);
const json = JSON.stringify(abi.registry.metaTypeDefs, stringifyInfo, 2);
const cmpPath = path.join(__dirname, `../test/compare/${abiName}.test.json`);
try {
const cmpPath = path.join(__dirname, `../test/compare/${abiName}.test.json`);
// eslint-disable-next-line @typescript-eslint/no-var-requires
expect(JSON.parse(json)).toEqual(require(cmpPath));
} catch (error) {
if (process.env.GITHUB_REPOSITORY) {
console.error(JSON.stringify(abi.registry.metaTypeDefs, stringifyInfo));
if (!fs.existsSync(cmpPath)) {
fs.writeFileSync(cmpPath, JSON.stringify(abi.registry.metaTypeDefs, null, 2), { flag: 'w' });
throw error;
}
// eslint-disable-next-line @typescript-eslint/no-var-requires
expect(abi.registry.metaTypeDefs).toEqual(require(cmpPath));
} catch (error) {
console.error(JSON.stringify(abi.registry.metaTypeDefs));
throw error;
fs.writeFileSync(cmpPath, json, { flag: 'w' });
}
});
});
+74 -74
View File
@@ -1,21 +1,20 @@
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ChainProperties, ContractDisplayName, SiField, SiLookupTypeId, SiType, SiTypeDefArray, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiVariant } from '@polkadot/types/interfaces';
import type { ChainProperties, ContractDisplayName, Si0Field, Si0LookupTypeId, Si0Type, Si0TypeDefArray, Si0TypeDefSequence, Si0TypeDefTuple, Si0TypeDefVariant, Si0Variant } from '@polkadot/types/interfaces';
import type { InterfaceTypes, TypeDef } from '@polkadot/types/types';
import { TypeRegistry, withTypeString } from '@polkadot/types/create';
import { TypeDefInfo } from '@polkadot/types/types';
import { TypeDefInfo, TypeRegistry, withTypeString } from '@polkadot/types';
import { assert, isUndefined } from '@polkadot/util';
interface PartialTypeSpec {
readonly type: SiLookupTypeId;
readonly type: Si0LookupTypeId;
readonly displayName?: ContractDisplayName;
}
// convert the offset into project-specific, index-1
export function getRegistryOffset (id: SiLookupTypeId): number {
return id.toNumber() - 1;
export function getRegistryOffset (id: Si0LookupTypeId, typeOffset: number): number {
return id.toNumber() - typeOffset;
}
const PRIMITIVE_ALIAS: Record<string, keyof InterfaceTypes> = {
@@ -25,25 +24,33 @@ const PRIMITIVE_ALIAS: Record<string, keyof InterfaceTypes> = {
const PRIMITIVE_ALWAYS = ['AccountId', 'AccountIndex', 'Address', 'Balance'];
// TODO Replace usages with PortableRegistry
export class MetaRegistry extends TypeRegistry {
public readonly metaTypeDefs: TypeDef[] = [];
#siTypes: SiType[] = [];
public readonly typeOffset;
constructor (chainProperties?: ChainProperties) {
#siTypes: Si0Type[] = [];
constructor (metadataVersion: string, chainProperties?: ChainProperties) {
super();
const [major, minor] = metadataVersion.split('.').map((n) => parseInt(n, 10));
// type indexes are 1-based pre 0.7 and 0-based post
this.typeOffset = (major === 0 && minor < 7) ? 1 : 0;
if (chainProperties) {
this.setChainProperties(chainProperties);
}
}
public setMetaTypes (metaTypes: SiType[]): void {
public setMetaTypes (metaTypes: Si0Type[]): void {
this.#siTypes = metaTypes;
}
public getMetaTypeDef (typeSpec: PartialTypeSpec): TypeDef {
const offset = getRegistryOffset(typeSpec.type);
const offset = getRegistryOffset(typeSpec.type, this.typeOffset);
let typeDef = this.metaTypeDefs[offset];
if (!typeDef) {
@@ -77,20 +84,23 @@ export class MetaRegistry extends TypeRegistry {
return typeDef;
}
#getMetaType = (id: SiLookupTypeId): SiType => {
const type = this.#siTypes[getRegistryOffset(id)];
#getMetaType = (id: Si0LookupTypeId): Si0Type => {
const type = this.#siTypes[getRegistryOffset(id, this.typeOffset)];
assert(!isUndefined(type), `getMetaType:: Unable to find ${id.toNumber()} in type values`);
assert(!isUndefined(type), () => `getMetaType:: Unable to find ${id.toNumber()} in type values`);
return this.createType('SiType', type);
return this.createType('Si0Type', type);
}
#extract = (type: SiType, id: SiLookupTypeId): TypeDef => {
#extract = (type: Si0Type, id: Si0LookupTypeId): TypeDef => {
const path = [...type.path];
const pathFinal = path.length ? path[path.length - 1].toString() : '';
const isPrimitivePath = !!path.length && (
(path.length > 2 && path[0].eq('ink_env') && path[1].eq('types')) ||
PRIMITIVE_ALWAYS.includes(path[path.length - 1].toString())
);
let typeDef: Omit<TypeDef, 'type'>;
if (type.path.join('::').startsWith('ink_env::types::') || PRIMITIVE_ALWAYS.includes(pathFinal)) {
if (isPrimitivePath) {
typeDef = this.#extractPrimitivePath(type);
} else if (type.def.isPrimitive) {
typeDef = this.#extractPrimitive(type);
@@ -110,13 +120,13 @@ export class MetaRegistry extends TypeRegistry {
const displayName = path.pop()?.toString();
return withTypeString({
return withTypeString(this, {
...(displayName
? { displayName }
: {}
),
...(path.length > 1
? { namespace: path.map((segment) => segment.toString()).join('::') }
? { namespace: path.map((s) => s.toString()).join('::') }
: {}
),
...(type.params.length > 0
@@ -127,8 +137,8 @@ export class MetaRegistry extends TypeRegistry {
});
}
#extractArray = ({ len: length, type }: SiTypeDefArray): Omit<TypeDef, 'type'> => {
assert(!length || length.toNumber() <= 256, 'MetaRegistry: Only support for [Type; <length>], where length > 256');
#extractArray = ({ len: length, type }: Si0TypeDefArray): Omit<TypeDef, 'type'> => {
assert(!length || length.toNumber() <= 256, 'MetaRegistry: Only support for [Type; <length>], where length <= 256');
return {
info: TypeDefInfo.VecFixed,
@@ -137,37 +147,35 @@ export class MetaRegistry extends TypeRegistry {
};
}
#extractFields = (fields: SiField[]): Omit<TypeDef, 'type'> => {
#extractFields = (fields: Si0Field[]): Omit<TypeDef, 'type'> => {
const [isStruct, isTuple] = fields.reduce(([isAllNamed, isAllUnnamed], { name }) => ([
isAllNamed && name.isSome,
isAllUnnamed && name.isNone
]),
[true, true]);
let info;
assert(isTuple || isStruct, 'Invalid fields type detected, expected either Tuple or Struct');
// check for tuple first (no fields may be available)
if (isTuple) {
info = TypeDefInfo.Tuple;
} else if (isStruct) {
info = TypeDefInfo.Struct;
} else {
throw new Error('Invalid fields type detected, expected either Tuple or Struct');
}
const sub = fields.map(({ name, type }) => {
return {
...this.getMetaTypeDef({ type }),
...(name.isSome ? { name: name.unwrap().toString() } : {})
};
});
const sub = fields.map(({ name, type }) => ({
...this.getMetaTypeDef({ type }),
...(name.isSome
? { name: name.unwrap().toString() }
: {}
)
}));
return isTuple && sub.length === 1
? sub[0]
: { info, sub };
: {
// check for tuple first (no fields may be available)
info: isTuple
? TypeDefInfo.Tuple
: TypeDefInfo.Struct,
sub
};
}
#extractPrimitive = (type: SiType): TypeDef => {
#extractPrimitive = (type: Si0Type): TypeDef => {
const typeStr = type.def.asPrimitive.type.toString();
return {
@@ -176,15 +184,15 @@ export class MetaRegistry extends TypeRegistry {
};
}
#extractPrimitivePath = (type: SiType): TypeDef => {
#extractPrimitivePath = (type: Si0Type): TypeDef => {
return {
info: TypeDefInfo.Plain,
type: type.path[type.path.length - 1].toString()
};
}
#extractSequence = ({ type }: SiTypeDefSequence, id: SiLookupTypeId): Omit<TypeDef, 'type'> => {
assert(!!type, `ContractRegistry: Invalid sequence type found at id ${id.toString()}`);
#extractSequence = ({ type }: Si0TypeDefSequence, id: Si0LookupTypeId): Omit<TypeDef, 'type'> => {
assert(!!type, () => `ContractRegistry: Invalid sequence type found at id ${id.toString()}`);
return {
info: TypeDefInfo.Vec,
@@ -192,7 +200,7 @@ export class MetaRegistry extends TypeRegistry {
};
}
#extractTuple = (ids: SiTypeDefTuple): Omit<TypeDef, 'type'> => {
#extractTuple = (ids: Si0TypeDefTuple): Omit<TypeDef, 'type'> => {
return ids.length === 1
? this.getMetaTypeDef({ type: ids[0] })
: {
@@ -201,36 +209,32 @@ export class MetaRegistry extends TypeRegistry {
};
}
#extractVariant = ({ variants }: SiTypeDefVariant, id: SiLookupTypeId): Omit<TypeDef, 'type'> => {
#extractVariant = ({ variants }: Si0TypeDefVariant, id: Si0LookupTypeId): Omit<TypeDef, 'type'> => {
const { params, path } = this.#getMetaType(id);
const specialVariant = path[0].toString();
if (specialVariant === 'Option') {
return {
return specialVariant === 'Option'
? {
info: TypeDefInfo.Option,
sub: this.getMetaTypeDef({ type: params[0] })
};
} else if (specialVariant === 'Result') {
return {
info: TypeDefInfo.Result,
sub: params.map((type, index) => ({
name: ['Ok', 'Error'][index],
...this.getMetaTypeDef({ type })
}))
};
}
return {
info: TypeDefInfo.Enum,
sub: this.#extractVariantSub(variants)
};
}
: specialVariant === 'Result'
? {
info: TypeDefInfo.Result,
sub: params.map((type, index) => ({
name: ['Ok', 'Error'][index],
...this.getMetaTypeDef({ type })
}))
}
: {
info: TypeDefInfo.Enum,
sub: this.#extractVariantSub(variants)
};
}
#extractVariantSub = (variants: SiVariant[]): TypeDef[] => {
const isAllUnitVariants = variants.every(({ fields }) => fields.length === 0);
if (isAllUnitVariants) {
return variants.map(({ discriminant, name }) => ({
#extractVariantSub = (variants: Si0Variant[]): TypeDef[] => {
return variants.every(({ fields }) => fields.length === 0)
? variants.map(({ discriminant, name }) => ({
...(
discriminant.isSome
? { ext: { discriminant: discriminant.unwrap().toNumber() } }
@@ -239,14 +243,10 @@ export class MetaRegistry extends TypeRegistry {
info: TypeDefInfo.Plain,
name: name.toString(),
type: 'Null'
}));
}
return variants.map(({ fields, name }) =>
withTypeString({
}))
: variants.map(({ fields, name }) => withTypeString(this, {
...this.#extractFields(fields),
name: name.toString()
})
);
}));
}
}
+3 -2
View File
@@ -5,7 +5,7 @@ import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import type { AnyJson, Registry } from '@polkadot/types/types';
import { ApiBase } from '@polkadot/api/base';
import { assert } from '@polkadot/util';
import { assert, isFunction } from '@polkadot/util';
import { Abi } from '../Abi';
@@ -26,6 +26,7 @@ export abstract class Base<ApiType extends ApiTypes> {
this.registry = this.abi.registry;
this._decorateMethod = decorateMethod;
assert(api.rx.tx.contracts?.instantiate, 'You need to connect to a node with the contracts module, the metadata does not enable api.tx.contracts on this instance');
assert(!!(api && api.isConnected && api.tx && api.tx.contracts && Object.keys(api.tx.contracts).length), 'Your API has not been initialized correctly and it not decorated with the runtime interfaces for contracts as retrieved from the on-chain runtime');
assert(isFunction(api.tx.contracts.instantiateWithCode), 'You need to connect to a chain with a runtime with a V3 contracts module. The runtime does not expose api.tx.contracts.instantiateWithCode');
}
}
+20 -30
View File
@@ -4,19 +4,19 @@
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import type { AccountId, EventRecord, Hash } from '@polkadot/types/interfaces';
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
import type { AnyJson, ISubmittableResult } from '@polkadot/types/types';
import type { AbiConstructor, BlueprintOptions } from '../types';
import type { ContractGeneric, MapConstructorExec } from './types';
import type { MapConstructorExec } from './types';
import { SubmittableResult } from '@polkadot/api';
import { ApiBase } from '@polkadot/api/base';
import { isUndefined, stringCamelCase } from '@polkadot/util';
import { BN_ZERO, isUndefined } from '@polkadot/util';
import { Abi } from '../Abi';
import { applyOnEvent } from '../util';
import { Base } from './Base';
import { Contract } from './Contract';
import { createBluePrintTx, createBluePrintWithId, EMPTY_SALT, encodeSalt } from './util';
import { createBluePrintTx, encodeSalt } from './util';
export class BlueprintSubmittableResult<ApiType extends ApiTypes> extends SubmittableResult {
public readonly contract?: Contract<ApiType>;
@@ -34,25 +34,16 @@ export class Blueprint<ApiType extends ApiTypes> extends Base<ApiType> {
*/
public readonly codeHash: Hash;
/**
* @deprecated
* @description Deprecated. Use `.tx.<constructorName>`. Creates a contract in a non-deterministic way.
*/
public readonly createContract: ContractGeneric<BlueprintOptions, SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>>>;
readonly #tx: MapConstructorExec<ApiType> = {};
constructor (api: ApiBase<ApiType>, abi: AnyJson | Abi, codeHash: string | Hash | Uint8Array, decorateMethod: DecorateMethod<ApiType>) {
super(api, abi, decorateMethod);
this.codeHash = this.registry.createType('Hash', codeHash);
this.createContract = createBluePrintWithId(this.#deploy);
this.abi.constructors.forEach((c): void => {
const messageName = stringCamelCase(c.identifier);
if (isUndefined(this.#tx[messageName])) {
this.#tx[messageName] = createBluePrintTx((o, p) => this.#deploy(c, o, p));
if (isUndefined(this.#tx[c.method])) {
this.#tx[c.method] = createBluePrintTx((o, p) => this.#deploy(c, o, p));
}
});
}
@@ -61,20 +52,19 @@ export class Blueprint<ApiType extends ApiTypes> extends Base<ApiType> {
return this.#tx;
}
#deploy = (constructorOrId: AbiConstructor | string | number, { gasLimit = 0, salt, value = 0 }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> => {
const encodedSalt = encodeSalt(salt);
const withSalt = this.api.tx.contracts.instantiate.meta.args.length === 5;
const encoded = this.abi.findConstructor(constructorOrId).toU8a(params, withSalt ? EMPTY_SALT : encodedSalt);
const tx = withSalt
? this.api.tx.contracts.instantiate(value, gasLimit, this.codeHash, encoded, encodedSalt)
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore old style with salt included
: this.api.tx.contracts.instantiate(value, gasLimit, this.codeHash, encoded);
return tx.withResultTransform((result: ISubmittableResult) =>
new BlueprintSubmittableResult(result, applyOnEvent(result, ['Instantiated'], ([record]: EventRecord[]) =>
new Contract<ApiType>(this.api, this.abi, record.event.data[1] as AccountId, this._decorateMethod)
))
);
#deploy = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, value = BN_ZERO }: BlueprintOptions, params: unknown[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> => {
return this.api.tx.contracts
.instantiate(
value,
gasLimit,
this.codeHash,
this.abi.findConstructor(constructorOrId).toU8a(params),
encodeSalt(salt)
)
.withResultTransform((result: ISubmittableResult) =>
new BlueprintSubmittableResult(result, applyOnEvent(result, ['Instantiated'], ([record]: EventRecord[]) =>
new Contract<ApiType>(this.api, this.abi, record.event.data[1] as AccountId, this._decorateMethod)
))
);
}
}
+3 -3
View File
@@ -4,7 +4,7 @@
import fs from 'fs';
import path from 'path';
import { decorateMethod } from '@polkadot/api/promise';
import { decorateMethodPromise } from '@polkadot/api';
import contractFlipper from '../../test/contracts/ink/flipper.contract.json';
import abiFlipper from '../../test/contracts/ink/flipper.json';
@@ -16,13 +16,13 @@ const wasmFlipper = fs.readFileSync(path.join(__dirname, '../../test/contracts/i
describe('Code', (): void => {
it('can construct with an individual ABI/WASM combo', (): void => {
expect(
() => new Code(mockApi, abiFlipper, wasmFlipper, decorateMethod)
() => new Code(mockApi, abiFlipper, wasmFlipper, decorateMethodPromise)
).not.toThrow();
});
it('can construct with an .contract ABI', (): void => {
expect(
() => new Code(mockApi, contractFlipper, null, decorateMethod)
() => new Code(mockApi, contractFlipper, null, decorateMethodPromise)
).not.toThrow();
});
});
+24 -59
View File
@@ -4,23 +4,20 @@
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import type { EventRecord } from '@polkadot/types/interfaces';
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
import type { AnyJson, ISubmittableResult } from '@polkadot/types/types';
import type { AbiConstructor, BlueprintOptions } from '../types';
import type { MapConstructorExec } from './types';
import { SubmittableResult } from '@polkadot/api';
import { ApiBase } from '@polkadot/api/base';
import { assert, compactAddLength, isFunction, isUndefined, isWasm, logger, stringCamelCase, u8aToU8a } from '@polkadot/util';
import { blake2AsU8a } from '@polkadot/util-crypto';
import { assert, BN_ZERO, compactAddLength, isUndefined, isWasm, u8aToU8a } from '@polkadot/util';
import { Abi } from '../Abi';
import { applyOnEvent } from '../util';
import { Base } from './Base';
import { Blueprint } from './Blueprint';
import { Contract } from './Contract';
import { createBluePrintTx, EMPTY_SALT, encodeSalt } from './util';
const l = logger('Code');
import { createBluePrintTx, encodeSalt } from './util';
export class CodeSubmittableResult<ApiType extends ApiTypes> extends SubmittableResult {
public readonly blueprint?: Blueprint<ApiType>;
@@ -49,10 +46,8 @@ export class Code<ApiType extends ApiTypes> extends Base<ApiType> {
assert(isWasm(this.code), 'No WASM code provided');
this.abi.constructors.forEach((c): void => {
const messageName = stringCamelCase(c.identifier);
if (isUndefined(this.#tx[messageName])) {
this.#tx[messageName] = createBluePrintTx((o, p) => this.#instantiate(c, o, p));
if (isUndefined(this.#tx[c.method])) {
this.#tx[c.method] = createBluePrintTx((o, p) => this.#instantiate(c, o, p));
}
});
}
@@ -61,55 +56,25 @@ export class Code<ApiType extends ApiTypes> extends Base<ApiType> {
return this.#tx;
}
/**
* @description Deploy the code bundle and the contract, creating a Blueprint.
* @deprecated Use the `code.tx.<constructor>(...) format to put code and deploy
*/
public createContract (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> {
l.warn('.createContract is deprecated, use code.tx.<constructorName>(...) instead (where code refers to this instance)');
return this.#instantiate(constructorOrId, options, params);
}
#instantiate = (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
return isFunction(this.api.tx.contracts.instantiateWithCode)
? this.#instantiateCurrent(constructorOrId, options, params)
: this.#instantiatePrev(constructorOrId, options, params);
}
#instantiateCurrent = (constructorOrId: AbiConstructor | string | number, { gasLimit = 0, salt, value = 0 }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
#instantiate = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, value = BN_ZERO }: BlueprintOptions, params: unknown[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
return this.api.tx.contracts
.instantiateWithCode(value, gasLimit, compactAddLength(this.code), this.abi.findConstructor(constructorOrId).toU8a(params), encodeSalt(salt))
.withResultTransform(this.#transformEvents);
}
#instantiatePrev = (constructorOrId: AbiConstructor | string | number, { gasLimit = 0, salt, value = 0 }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
assert(isFunction(this.api.tx.utility?.batch), 'Your chain does not include the utility pallet, for contracts v2 deployment, this is required');
const encodedSalt = encodeSalt(salt);
const withSalt = this.api.tx.contracts.instantiate.meta.args.length === 5;
const encoded = this.abi.findConstructor(constructorOrId).toU8a(params, withSalt ? EMPTY_SALT : encodedSalt);
const codeHash = blake2AsU8a(this.code);
return this.api.tx.utility.batch([
this.api.tx.contracts.putCode(compactAddLength(this.code)),
withSalt
? this.api.tx.contracts.instantiate(value, gasLimit, codeHash, encoded, encodedSalt)
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore old style with salt included in the params itself
: this.api.tx.contracts.instantiate(value, gasLimit, codeHash, encoded)
]).withResultTransform(this.#transformEvents);
}
#transformEvents = (result: ISubmittableResult): CodeSubmittableResult<ApiType> => {
return new CodeSubmittableResult(result, ...(applyOnEvent(result, ['CodeStored', 'Instantiated'], (records: EventRecord[]) =>
records.reduce(([blueprint, contract], { event }): [Blueprint<ApiType>?, Contract<ApiType>?] =>
this.api.events.contracts.Instantiated.is(event)
? [blueprint, new Contract<ApiType>(this.api, this.abi, event.data[1], this._decorateMethod)]
: this.api.events.contracts.CodeStored.is(event)
? [new Blueprint<ApiType>(this.api, this.abi, event.data[0], this._decorateMethod), contract]
: [blueprint, contract],
[] as [Blueprint<ApiType>?, Contract<ApiType>?])
) || []));
.instantiateWithCode(
value,
gasLimit,
compactAddLength(this.code),
this.abi.findConstructor(constructorOrId).toU8a(params),
encodeSalt(salt)
)
.withResultTransform((result: ISubmittableResult) =>
new CodeSubmittableResult(result, ...(applyOnEvent(result, ['CodeStored', 'Instantiated'], (records: EventRecord[]) =>
records.reduce<[Blueprint<ApiType>?, Contract<ApiType>?]>(([blueprint, contract], { event }) =>
this.api.events.contracts.Instantiated.is(event)
? [blueprint, new Contract<ApiType>(this.api, this.abi, event.data[1], this._decorateMethod)]
: this.api.events.contracts.CodeStored.is(event)
? [new Blueprint<ApiType>(this.api, this.abi, event.data[0], this._decorateMethod), contract]
: [blueprint, contract],
[])
) || []))
);
}
}
+48 -93
View File
@@ -4,52 +4,42 @@
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import type { Bytes } from '@polkadot/types';
import type { AccountId, ContractExecResult, EventRecord, Weight } from '@polkadot/types/interfaces';
import type { AnyJson, CodecArg, ISubmittableResult, Registry } from '@polkadot/types/types';
import type { AccountId, EventRecord, Weight } from '@polkadot/types/interfaces';
import type { AnyJson, ISubmittableResult } from '@polkadot/types/types';
import type { AbiMessage, ContractCallOutcome, ContractOptions, DecodedEvent } from '../types';
import type { ContractCallResult, ContractCallSend, ContractGeneric, ContractQuery, ContractTx, MapMessageQuery, MapMessageTx } from './types';
import type { ContractCallResult, ContractCallSend, ContractQuery, ContractTx, MapMessageQuery, MapMessageTx } from './types';
import BN from 'bn.js';
import { map } from 'rxjs';
import { SubmittableResult } from '@polkadot/api';
import { ApiBase } from '@polkadot/api/base';
import { assert, bnToBn, isFunction, isUndefined, logger, stringCamelCase } from '@polkadot/util';
import { map } from '@polkadot/x-rxjs/operators';
import { createTypeUnsafe } from '@polkadot/types';
import { assert, BN, BN_HUNDRED, BN_ONE, BN_ZERO, bnToBn, isFunction, isUndefined, logger } from '@polkadot/util';
import { Abi } from '../Abi';
import { applyOnEvent, extractOptions, formatData, isOptions } from '../util';
import { applyOnEvent, extractOptions, isOptions } from '../util';
import { Base } from './Base';
// As per Rust, 5 * GAS_PER_SEC
const MAX_CALL_GAS = new BN(5_000_000_000_000).subn(1);
const MAX_CALL_GAS = new BN(5_000_000_000_000).isub(BN_ONE);
const ERROR_NO_CALL = 'Your node does not expose the contracts.call RPC. This is most probably due to a runtime configuration.';
const l = logger('Contract');
function createQuery <ApiType extends ApiTypes> (fn: (origin: string | AccountId | Uint8Array, options: ContractOptions, params: CodecArg[]) => ContractCallResult<ApiType, ContractCallOutcome>): ContractQuery<ApiType> {
return (origin: string | AccountId | Uint8Array, options: BigInt | string | number | BN | ContractOptions, ...params: CodecArg[]): ContractCallResult<ApiType, ContractCallOutcome> =>
function createQuery <ApiType extends ApiTypes> (fn: (origin: string | AccountId | Uint8Array, options: ContractOptions, params: unknown[]) => ContractCallResult<ApiType, ContractCallOutcome>): ContractQuery<ApiType> {
return (origin: string | AccountId | Uint8Array, options: bigint | string | number | BN | ContractOptions, ...params: unknown[]): ContractCallResult<ApiType, ContractCallOutcome> =>
isOptions(options)
? fn(origin, options, params)
: fn(origin, ...extractOptions(options, params));
}
function createTx <ApiType extends ApiTypes> (fn: (options: ContractOptions, params: CodecArg[]) => SubmittableExtrinsic<ApiType>): ContractTx<ApiType> {
return (options: BigInt | string | number | BN | ContractOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType> =>
function createTx <ApiType extends ApiTypes> (fn: (options: ContractOptions, params: unknown[]) => SubmittableExtrinsic<ApiType>): ContractTx<ApiType> {
return (options: bigint | string | number | BN | ContractOptions, ...params: unknown[]): SubmittableExtrinsic<ApiType> =>
isOptions(options)
? fn(options, params)
: fn(...extractOptions(options, params));
}
function createWithId <T> (fn: (messageOrId: AbiMessage | string | number, options: ContractOptions, params: CodecArg[]) => T, warn?: string): ContractGeneric<ContractOptions, T> {
return (messageOrId: AbiMessage | string | number, options: BigInt | string | number | BN | ContractOptions, ...params: CodecArg[]): T => {
warn && l.warn(warn);
return isOptions(options)
? fn(messageOrId, options, params)
: fn(messageOrId, ...extractOptions(options, params));
};
}
export class ContractSubmittableResult extends SubmittableResult {
public readonly contractEvents?: DecodedEvent[];
@@ -60,51 +50,12 @@ export class ContractSubmittableResult extends SubmittableResult {
}
}
// map from a JSON result to current-style ContractExecResult
function mapExecResult (registry: Registry, json: Record<string, AnyJson>): ContractExecResult {
if (!Object.keys(json).some((key) => ['error', 'success'].includes(key))) {
return registry.createType('ContractExecResult', json);
}
const from = registry.createType('ContractExecResultTo260', json);
if (from.isSuccess) {
const s = from.asSuccess;
return registry.createType('ContractExecResult', {
gasConsumed: s.gasConsumed,
result: {
ok: {
data: s.data,
flags: s.flags
}
}
});
}
// in the old format error has no additional information,
// map it as-is with an "unknown" error
return registry.createType('ContractExecResult', { result: { err: { other: 'unknown' } } });
}
export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
/**
* @description The on-chain address for this contract
*/
public readonly address: AccountId;
/**
* @deprecated
* @description Deprecated. Use `.tx.<messageName>` to send a transaction.
*/
public readonly exec: ContractGeneric<ContractOptions, SubmittableExtrinsic<ApiType>>;
/**
* @deprecated
* @description Deprecated. Use `.tx.<messageName>` to send a transaction.
*/
public readonly read: ContractGeneric<ContractOptions, ContractCallSend<ApiType>>;
readonly #query: MapMessageQuery<ApiType> = {};
readonly #tx: MapMessageTx<ApiType> = {};
@@ -113,18 +64,14 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
super(api, abi, decorateMethod);
this.address = this.registry.createType('AccountId', address);
this.exec = createWithId(this.#exec, '.exec is deprecated, use contract.tx.<messageName>(...) instead (where contract refers to this instance)');
this.read = createWithId(this.#read, '.read is deprecated, use contract.query.<messageName>(...) instead (where contract refers to this instance)');
this.abi.messages.forEach((m): void => {
const messageName = stringCamelCase(m.identifier);
if (isUndefined(this.#tx[messageName])) {
this.#tx[messageName] = createTx((o, p) => this.#exec(m, o, p));
if (isUndefined(this.#tx[m.method])) {
this.#tx[m.method] = createTx((o, p) => this.#exec(m, o, p));
}
if (isUndefined(this.#query[messageName])) {
this.#query[messageName] = createQuery((f, o, p) => this.#read(m, o, p).send(f));
if (isUndefined(this.#query[m.method])) {
this.#query[m.method] = createQuery((f, o, p) => this.#read(m, o, p).send(f));
}
});
}
@@ -143,22 +90,27 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
return this.#tx;
}
#getGas = (_gasLimit: BigInt | BN | string | number, isCall = false): BN => {
#getGas = (_gasLimit: bigint | BN | string | number, isCall = false): BN => {
const gasLimit = bnToBn(_gasLimit);
return gasLimit.lten(0)
return gasLimit.lte(BN_ZERO)
? isCall
? MAX_CALL_GAS
: (this.api.consts.system.blockWeights
? this.api.consts.system.blockWeights.maxBlock
: this.api.consts.system.maximumBlockWeight as Weight
).muln(64).divn(100)
).muln(64).div(BN_HUNDRED)
: gasLimit;
}
#exec = (messageOrId: AbiMessage | string | number, { gasLimit = 0, value = 0 }: ContractOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType> => {
#exec = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, value = BN_ZERO }: ContractOptions, params: unknown[]): SubmittableExtrinsic<ApiType> => {
return this.api.tx.contracts
.call(this.address, value, this.#getGas(gasLimit), this.abi.findMessage(messageOrId).toU8a(params))
.call(
this.address,
value,
this.#getGas(gasLimit),
this.abi.findMessage(messageOrId).toU8a(params)
)
.withResultTransform((result: ISubmittableResult) =>
// ContractEmitted is the current generation, ContractExecution is the previous generation
new ContractSubmittableResult(result, applyOnEvent(result, ['ContractEmitted', 'ContractExecution'], (records: EventRecord[]) =>
@@ -177,7 +129,7 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
);
}
#read = (messageOrId: AbiMessage | string | number, { gasLimit = 0, value = 0 }: ContractOptions, params: CodecArg[]): ContractCallSend<ApiType> => {
#read = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, value = BN_ZERO }: ContractOptions, params: unknown[]): ContractCallSend<ApiType> => {
assert(this.hasRpcContractsCall, ERROR_NO_CALL);
const message = this.abi.findMessage(messageOrId);
@@ -185,24 +137,27 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
return {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
send: this._decorateMethod((origin: string | AccountId | Uint8Array) =>
this.api.rx.rpc.contracts.call.json({
dest: this.address,
gasLimit: this.#getGas(gasLimit, true),
inputData: message.toU8a(params),
origin,
value
}).pipe(map((json): ContractCallOutcome => {
const { debugMessage, gasConsumed, result } = mapExecResult(this.registry, json.toJSON());
return {
debugMessage,
gasConsumed,
output: result.isOk && message.returnType
? formatData(this.registry, result.asOk.data, message.returnType)
: null,
result
};
}))
this.api.rx.rpc.contracts
.call({
dest: this.address,
gasLimit: this.#getGas(gasLimit, true),
inputData: message.toU8a(params),
origin,
value
})
.pipe(
map(({ debugMessage, gasConsumed, gasRequired, result }): ContractCallOutcome => ({
debugMessage,
gasConsumed,
gasRequired: gasRequired && !gasRequired.isZero()
? gasRequired
: gasConsumed,
output: result.isOk && message.returnType
? createTypeUnsafe(this.registry, message.returnType.type, [result.asOk.data.toU8a(true)], { isPedantic: true })
: null,
result
}))
)
)
};
}
+5 -9
View File
@@ -7,16 +7,12 @@ import { TypeRegistry } from '@polkadot/types';
const registry = new TypeRegistry();
export const mockApi = {
isConnected: true,
registry,
rx: {
tx: {
contracts: {
instantiate: (): never => {
throw new Error('mock');
},
putCode: (): never => {
throw new Error('mock');
}
tx: {
contracts: {
instantiateWithCode: (): never => {
throw new Error('mock');
}
}
}
+11 -12
View File
@@ -1,36 +1,35 @@
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type BN from 'bn.js';
import type { Observable } from 'rxjs';
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import type { ApiTypes, ObsInnerType } from '@polkadot/api/types';
import type { AccountId } from '@polkadot/types/interfaces';
import type { CodecArg } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { BN } from '@polkadot/util';
import type { AbiMessage, BlueprintOptions, ContractCallOutcome, ContractOptions } from '../types';
export interface BlueprintDeploy<ApiType extends ApiTypes> {
(options: BlueprintOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
(value: BigInt | string | number | BN, gasLimit: BigInt | string | number | BN, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
(options: BlueprintOptions, ...params: unknown[]): SubmittableExtrinsic<ApiType>;
(value: bigint | string | number | BN, gasLimit: bigint | string | number | BN, ...params: unknown[]): SubmittableExtrinsic<ApiType>;
}
export interface ContractQuery<ApiType extends ApiTypes> {
(origin: AccountId | string | Uint8Array, options: ContractOptions, ...params: CodecArg[]): ContractCallResult<ApiType, ContractCallOutcome>;
(origin: AccountId | string | Uint8Array, value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]): ContractCallResult<ApiType, ContractCallOutcome>;
(origin: AccountId | string | Uint8Array, options: ContractOptions, ...params: unknown[]): ContractCallResult<ApiType, ContractCallOutcome>;
(origin: AccountId | string | Uint8Array, value: bigint | BN | string | number, gasLimit: bigint | BN | string | number, ...params: unknown[]): ContractCallResult<ApiType, ContractCallOutcome>;
}
export interface ContractTx<ApiType extends ApiTypes> {
(options: ContractOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
(value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
(options: ContractOptions, ...params: unknown[]): SubmittableExtrinsic<ApiType>;
(value: bigint | BN | string | number, gasLimit: bigint | BN | string | number, ...params: unknown[]): SubmittableExtrinsic<ApiType>;
}
export interface ContractGeneric<O, T> {
(messageOrId: AbiMessage | string | number, options: O, ...params: CodecArg[]): T;
(messageOrId: AbiMessage | string | number, value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]): T;
(messageOrId: AbiMessage | string | number, options: O, ...params: unknown[]): T;
(messageOrId: AbiMessage | string | number, value: bigint | BN | string | number, gasLimit: bigint | BN | string | number, ...params: unknown[]): T;
}
export type ContractCallResult<ApiType extends ApiTypes, T> = ApiType extends 'rxjs'
? Observable<Observable<T>>
? Observable<T>
: Promise<ObsInnerType<Observable<T>>>;
export interface ContractCallSend<ApiType extends ApiTypes> {
+5 -7
View File
@@ -4,12 +4,10 @@
import type { SubmittableResult } from '@polkadot/api';
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import type { ApiTypes } from '@polkadot/api/types';
import type { CodecArg } from '@polkadot/types/types';
import type { BN } from '@polkadot/util';
import type { AbiConstructor, BlueprintOptions } from '../types';
import type { BlueprintDeploy, ContractGeneric } from './types';
import BN from 'bn.js';
import { Bytes } from '@polkadot/types';
import { compactAddLength, u8aToU8a } from '@polkadot/util';
import { randomAsU8a } from '@polkadot/util-crypto';
@@ -18,15 +16,15 @@ import { extractOptions, isOptions } from '../util';
export const EMPTY_SALT = new Uint8Array();
export function createBluePrintTx <ApiType extends ApiTypes, R extends SubmittableResult> (fn: (options: BlueprintOptions, params: CodecArg[]) => SubmittableExtrinsic<ApiType, R>): BlueprintDeploy<ApiType> {
return (options: BigInt | string | number | BN | BlueprintOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType, R> =>
export function createBluePrintTx <ApiType extends ApiTypes, R extends SubmittableResult> (fn: (options: BlueprintOptions, params: unknown[]) => SubmittableExtrinsic<ApiType, R>): BlueprintDeploy<ApiType> {
return (options: bigint | string | number | BN | BlueprintOptions, ...params: unknown[]): SubmittableExtrinsic<ApiType, R> =>
isOptions(options)
? fn(options, params)
: fn(...extractOptions(options, params));
}
export function createBluePrintWithId <T> (fn: (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: CodecArg[]) => T): ContractGeneric<BlueprintOptions, T> {
return (constructorOrId: AbiConstructor | string | number, options: BigInt | string | number | BN | BlueprintOptions, ...params: CodecArg[]): T =>
export function createBluePrintWithId <T> (fn: (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: unknown[]) => T): ContractGeneric<BlueprintOptions, T> {
return (constructorOrId: AbiConstructor | string | number, options: bigint | string | number | BN | BlueprintOptions, ...params: unknown[]): T =>
isOptions(options)
? fn(constructorOrId, options, params)
: fn(constructorOrId, ...extractOptions(options, params));
+7
View File
@@ -0,0 +1,7 @@
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
export { Abi } from './Abi';
export { packageInfo } from './packageInfo';
export { Blueprint as BlueprintPromise, Code as CodePromise, Contract as ContractPromise } from './promise';
export { Blueprint as BlueprintRx, Code as CodeRx, Contract as ContractRx } from './rx';
@@ -30,10 +30,6 @@ async function checkContract (api: ApiPromise, pairs: TestKeyringMap): Promise<v
// execute
await contract.tx.inc({ gasLimit: 1234 }, 123).signAndSend(pairs.eve);
await contract.tx.inc(123, 456, 69).signAndSend(pairs.eve);
// deprecated
await contract.read('get', {}).send(pairs.eve.address);
await contract.exec('inc', {}, 123).signAndSend(pairs.dave);
}
async function main (): Promise<void> {
+1 -4
View File
@@ -3,7 +3,4 @@
import './detectPackage';
export { Abi } from './Abi';
export { packageInfo } from './packageInfo';
export { Blueprint as BlueprintPromise, Code as CodePromise, Contract as ContractPromise } from './promise';
export { Blueprint as BlueprintRx, Code as CodeRx, Contract as ContractRx } from './rx';
export * from './bundle';
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api-contract', version: '4.6.2' };
export const packageInfo = { name: '@polkadot/api-contract', version: '5.8.2' };
@@ -4,14 +4,13 @@
import type { Hash } from '@polkadot/types/interfaces';
import type { AnyJson } from '@polkadot/types/types';
import { ApiPromise } from '@polkadot/api';
import { decorateMethod } from '@polkadot/api/promise';
import { ApiPromise, decorateMethodPromise } from '@polkadot/api';
import { Abi } from '../Abi';
import { Blueprint as BaseBlueprint } from '../base';
export class Blueprint extends BaseBlueprint<'promise'> {
constructor (api: ApiPromise, abi: AnyJson | Abi, codeHash: string | Hash) {
super(api, abi, codeHash, decorateMethod);
super(api, abi, codeHash, decorateMethodPromise);
}
}
+2 -2
View File
@@ -4,13 +4,13 @@
import type { ApiPromise } from '@polkadot/api';
import type { AnyJson } from '@polkadot/types/types';
import { decorateMethod } from '@polkadot/api/promise';
import { decorateMethodPromise } from '@polkadot/api';
import { Abi } from '../Abi';
import { Code as BaseCode } from '../base';
export class Code extends BaseCode<'promise'> {
constructor (api: ApiPromise, abi: AnyJson | Abi, wasm: Uint8Array | string | Buffer | null | undefined) {
super(api, abi, wasm, decorateMethod);
super(api, abi, wasm, decorateMethodPromise);
}
}
@@ -4,14 +4,13 @@
import type { AccountId } from '@polkadot/types/interfaces';
import type { AnyJson } from '@polkadot/types/types';
import { ApiPromise } from '@polkadot/api';
import { decorateMethod } from '@polkadot/api/promise';
import { ApiPromise, decorateMethodPromise } from '@polkadot/api';
import { Abi } from '../Abi';
import { Contract as BaseContract } from '../base';
export class Contract extends BaseContract<'promise'> {
constructor (api: ApiPromise, abi: AnyJson | Abi, address: string | AccountId) {
super(api, abi, address, decorateMethod);
super(api, abi, address, decorateMethodPromise);
}
}
+2 -3
View File
@@ -4,14 +4,13 @@
import type { Hash } from '@polkadot/types/interfaces';
import type { AnyJson } from '@polkadot/types/types';
import { ApiRx } from '@polkadot/api';
import { decorateMethod } from '@polkadot/api/rx';
import { ApiRx, decorateMethodRx } from '@polkadot/api';
import { Abi } from '../Abi';
import { Blueprint as BaseBlueprint } from '../base';
export class Blueprint extends BaseBlueprint<'rxjs'> {
constructor (api: ApiRx, abi: AnyJson | Abi, codeHash: string | Hash) {
super(api, abi, codeHash, decorateMethod);
super(api, abi, codeHash, decorateMethodRx);
}
}
+2 -2
View File
@@ -4,13 +4,13 @@
import type { ApiRx } from '@polkadot/api';
import type { AnyJson } from '@polkadot/types/types';
import { decorateMethod } from '@polkadot/api/rx';
import { decorateMethodRx } from '@polkadot/api';
import { Abi } from '../Abi';
import { Code as BaseCode } from '../base';
export class Code extends BaseCode<'rxjs'> {
constructor (api: ApiRx, abi: AnyJson | Abi, wasm: Uint8Array | string | Buffer | null | undefined) {
super(api, abi, wasm, decorateMethod);
super(api, abi, wasm, decorateMethodRx);
}
}
+2 -3
View File
@@ -4,14 +4,13 @@
import type { AccountId } from '@polkadot/types/interfaces';
import type { AnyJson } from '@polkadot/types/types';
import { ApiRx } from '@polkadot/api';
import { decorateMethod } from '@polkadot/api/rx';
import { ApiRx, decorateMethodRx } from '@polkadot/api';
import { Abi } from '../Abi';
import { Contract as BaseContract } from '../base';
export class Contract extends BaseContract<'rxjs'> {
constructor (api: ApiRx, abi: AnyJson | Abi, address: string | AccountId) {
super(api, abi, address, decorateMethod);
super(api, abi, address, decorateMethodRx);
}
}
+9 -7
View File
@@ -1,12 +1,12 @@
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type BN from 'bn.js';
import type { ApiBase } from '@polkadot/api/base';
import type { ApiTypes } from '@polkadot/api/types';
import type { Text, u64 } from '@polkadot/types';
import type { ContractExecResultResult, ContractSelector } from '@polkadot/types/interfaces';
import type { Codec, CodecArg, TypeDef } from '@polkadot/types/types';
import type { Codec, TypeDef } from '@polkadot/types/types';
import type { BN } from '@polkadot/util';
import type { Abi } from '.';
export interface ContractBase<ApiType extends ApiTypes> {
@@ -39,9 +39,10 @@ export interface AbiMessage {
isConstructor?: boolean;
isMutating?: boolean;
isPayable?: boolean;
method: string;
returnType?: TypeDef | null;
selector: ContractSelector;
toU8a: (params: CodecArg[], additional?: Uint8Array) => Uint8Array;
toU8a: (params: unknown[]) => Uint8Array;
}
export type AbiConstructor = AbiMessage;
@@ -54,6 +55,7 @@ export interface InterfaceContractCalls {
export interface ContractCallOutcome {
debugMessage: Text;
gasConsumed: u64;
gasRequired: u64;
output: Codec | null;
result: ContractExecResultResult;
}
@@ -69,12 +71,12 @@ export interface DecodedMessage {
}
export interface BlueprintOptions {
gasLimit?: BigInt | string | number | BN;
gasLimit?: bigint | string | number | BN;
salt?: Uint8Array | string | null;
value?: BigInt | string | number | BN;
value?: bigint | string | number | BN;
}
export interface ContractOptions {
gasLimit?: BigInt | BN | string | number;
value?: BigInt | BN | string | number;
gasLimit?: bigint | BN | string | number;
value?: bigint | BN | string | number;
}
+3 -11
View File
@@ -2,24 +2,16 @@
// SPDX-License-Identifier: Apache-2.0
import type { SubmittableResult } from '@polkadot/api';
import type { Raw } from '@polkadot/types';
import type { EventRecord } from '@polkadot/types/interfaces';
import type { Codec, CodecArg, Registry, TypeDef } from '@polkadot/types/types';
import type { BN } from '@polkadot/util';
import type { BlueprintOptions, ContractOptions } from './types';
import BN from 'bn.js';
import { createTypeUnsafe } from '@polkadot/types/create';
import { isBigInt, isBn, isNumber, isString } from '@polkadot/util';
type ContractEvents = 'CodeStored' | 'ContractEmitted' | 'ContractExecution' | 'Instantiated';
type TOptions = BlueprintOptions | ContractOptions;
export function formatData (registry: Registry, data: Raw, { type }: TypeDef): Codec {
return createTypeUnsafe(registry, type, [data], { isPedantic: true });
}
export function applyOnEvent <T> (result: SubmittableResult, types: ContractEvents[], fn: (records: EventRecord[]) => T): T | undefined {
if (result.isInBlock || result.isFinalized) {
const records = result.filterRecords('contracts', types);
@@ -32,11 +24,11 @@ export function applyOnEvent <T> (result: SubmittableResult, types: ContractEven
return undefined;
}
export function isOptions <T> (options: BigInt | string | number | BN | T): options is T {
export function isOptions <T> (options: bigint | string | number | BN | T): options is T {
return !(isBn(options) || isBigInt(options) || isNumber(options) || isString(options));
}
export function extractOptions <T extends TOptions> (value: BigInt | string | number | BN, params: CodecArg[]): [T, CodecArg[]] {
export function extractOptions <T extends TOptions> (value: bigint | string | number | BN, params: unknown[]): [T, unknown[]] {
const gasLimit = params.shift() as BN;
return [{ gasLimit, value } as T, params];
@@ -2,30 +2,30 @@
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
"info": 12,
"info": "VecFixed",
"length": 32,
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "[u8;32]"
},
{
"info": 6,
"info": "Plain",
"type": "u8"
},
{
"info": 6,
"info": "Plain",
"type": "i32"
},
{
"displayName": "Hash",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "Hash"
}
]
@@ -2,20 +2,20 @@
{
"displayName": "Header",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "last_vacant"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "len"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "len_entries"
}
@@ -23,7 +23,7 @@
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
},
{
"info": 6,
"info": "Plain",
"type": "u32"
},
{
@@ -33,15 +33,15 @@
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -52,45 +52,45 @@
{
"displayName": "Hash",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "Hash",
"name": "Occupied"
}
],
"info": 3,
"info": "Enum",
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"Hash\"}}"
},
{
"displayName": "Hash",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "Hash"
},
{
"info": 12,
"info": "VecFixed",
"length": 32,
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "[u8;32]"
},
{
"info": 6,
"info": "Plain",
"type": "u8"
},
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -104,23 +104,23 @@
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId",
"name": "value"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "key_index"
}
],
"info": 9,
"info": "Struct",
"type": "{\"value\":\"AccountId\",\"key_index\":\"u32\"}"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
@@ -128,7 +128,7 @@
"sub": [
{
"name": "Ok",
"info": 10,
"info": "Tuple",
"sub": [],
"type": "()"
},
@@ -136,13 +136,13 @@
"name": "Error",
"displayName": "Error",
"namespace": "dns::dns",
"info": 3,
"info": "Enum",
"sub": [
{
"ext": {
"discriminant": 0
},
"info": 6,
"info": "Plain",
"name": "NameAlreadyExists",
"type": "Null"
},
@@ -150,7 +150,7 @@
"ext": {
"discriminant": 1
},
"info": 6,
"info": "Plain",
"name": "CallerIsNotOwner",
"type": "Null"
}
@@ -158,24 +158,24 @@
"type": "{\"_enum\":[\"NameAlreadyExists\",\"CallerIsNotOwner\"]}"
}
],
"info": 7,
"info": "Result",
"type": "Result<(), Error>"
},
{
"info": 10,
"info": "Tuple",
"sub": [],
"type": "()"
},
{
"displayName": "Error",
"namespace": "dns::dns",
"info": 3,
"info": "Enum",
"sub": [
{
"ext": {
"discriminant": 0
},
"info": 6,
"info": "Plain",
"name": "NameAlreadyExists",
"type": "Null"
},
@@ -183,7 +183,7 @@
"ext": {
"discriminant": 1
},
"info": 6,
"info": "Plain",
"name": "CallerIsNotOwner",
"type": "Null"
}
@@ -195,10 +195,10 @@
"sub": {
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
"info": 5,
"info": "Option",
"type": "Option<AccountId>"
}
]
@@ -1,25 +1,25 @@
[
{
"info": 6,
"info": "Plain",
"type": "u128"
},
{
"displayName": "Header",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "last_vacant"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "len"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "len_entries"
}
@@ -27,7 +27,7 @@
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
},
{
"info": 6,
"info": "Plain",
"type": "u32"
},
{
@@ -37,15 +37,15 @@
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -56,45 +56,45 @@
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId",
"name": "Occupied"
}
],
"info": 3,
"info": "Enum",
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
"info": 12,
"info": "VecFixed",
"length": 32,
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "[u8;32]"
},
{
"info": 6,
"info": "Plain",
"type": "u8"
},
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -106,17 +106,17 @@
"namespace": "ink_storage::collections::hashmap",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u128",
"name": "value"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "key_index"
}
],
"info": 9,
"info": "Struct",
"type": "{\"value\":\"u128\",\"key_index\":\"u32\"}"
},
{
@@ -126,15 +126,15 @@
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -143,48 +143,48 @@
"name": "Vacant"
},
{
"info": 10,
"info": "Tuple",
"sub": [
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
}
],
"type": "(AccountId, AccountId)",
"type": "(AccountId,AccountId)",
"name": "Occupied"
}
],
"info": 3,
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId, AccountId)\"}}"
"info": "Enum",
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId,AccountId)\"}}"
},
{
"info": 10,
"info": "Tuple",
"sub": [
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
}
],
"type": "(AccountId, AccountId)"
"type": "(AccountId,AccountId)"
},
{
"info": 6,
"info": "Plain",
"type": "bool"
},
{
@@ -192,10 +192,10 @@
"sub": {
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
"info": 5,
"info": "Option",
"type": "Option<AccountId>"
}
]
@@ -2,20 +2,20 @@
{
"displayName": "Header",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "last_vacant"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "len"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "len_entries"
}
@@ -23,7 +23,7 @@
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
},
{
"info": 6,
"info": "Plain",
"type": "u32"
},
{
@@ -33,15 +33,15 @@
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -50,26 +50,26 @@
"name": "Vacant"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "Occupied"
}
],
"info": 3,
"info": "Enum",
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"u32\"}}"
},
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -83,36 +83,36 @@
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId",
"name": "value"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "key_index"
}
],
"info": 9,
"info": "Struct",
"type": "{\"value\":\"AccountId\",\"key_index\":\"u32\"}"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
"info": 12,
"info": "VecFixed",
"length": 32,
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "[u8;32]"
},
{
"info": 6,
"info": "Plain",
"type": "u8"
},
{
@@ -122,15 +122,15 @@
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -141,12 +141,12 @@
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId",
"name": "Occupied"
}
],
"info": 3,
"info": "Enum",
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
},
{
@@ -154,17 +154,17 @@
"namespace": "ink_storage::collections::hashmap",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "value"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "key_index"
}
],
"info": 9,
"info": "Struct",
"type": "{\"value\":\"u32\",\"key_index\":\"u32\"}"
},
{
@@ -174,15 +174,15 @@
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -191,66 +191,66 @@
"name": "Vacant"
},
{
"info": 10,
"info": "Tuple",
"sub": [
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
}
],
"type": "(AccountId, AccountId)",
"type": "(AccountId,AccountId)",
"name": "Occupied"
}
],
"info": 3,
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId, AccountId)\"}}"
"info": "Enum",
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId,AccountId)\"}}"
},
{
"info": 10,
"info": "Tuple",
"sub": [
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
}
],
"type": "(AccountId, AccountId)"
"type": "(AccountId,AccountId)"
},
{
"displayName": "ValueEntry",
"namespace": "ink_storage::collections::hashmap",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "bool",
"name": "value"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "key_index"
}
],
"info": 9,
"info": "Struct",
"type": "{\"value\":\"bool\",\"key_index\":\"u32\"}"
},
{
"info": 6,
"info": "Plain",
"type": "bool"
},
{
@@ -258,10 +258,10 @@
"sub": {
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
"info": 5,
"info": "Option",
"type": "Option<AccountId>"
},
{
@@ -269,7 +269,7 @@
"sub": [
{
"name": "Ok",
"info": 10,
"info": "Tuple",
"sub": [],
"type": "()"
},
@@ -277,13 +277,13 @@
"name": "Error",
"displayName": "Error",
"namespace": "erc721::erc721",
"info": 3,
"info": "Enum",
"sub": [
{
"ext": {
"discriminant": 0
},
"info": 6,
"info": "Plain",
"name": "NotOwner",
"type": "Null"
},
@@ -291,7 +291,7 @@
"ext": {
"discriminant": 1
},
"info": 6,
"info": "Plain",
"name": "NotApproved",
"type": "Null"
},
@@ -299,7 +299,7 @@
"ext": {
"discriminant": 2
},
"info": 6,
"info": "Plain",
"name": "TokenExists",
"type": "Null"
},
@@ -307,7 +307,7 @@
"ext": {
"discriminant": 3
},
"info": 6,
"info": "Plain",
"name": "TokenNotFound",
"type": "Null"
},
@@ -315,7 +315,7 @@
"ext": {
"discriminant": 4
},
"info": 6,
"info": "Plain",
"name": "CannotInsert",
"type": "Null"
},
@@ -323,7 +323,7 @@
"ext": {
"discriminant": 5
},
"info": 6,
"info": "Plain",
"name": "CannotRemove",
"type": "Null"
},
@@ -331,7 +331,7 @@
"ext": {
"discriminant": 6
},
"info": 6,
"info": "Plain",
"name": "CannotFetchValue",
"type": "Null"
},
@@ -339,7 +339,7 @@
"ext": {
"discriminant": 7
},
"info": 6,
"info": "Plain",
"name": "NotAllowed",
"type": "Null"
}
@@ -347,24 +347,24 @@
"type": "{\"_enum\":[\"NotOwner\",\"NotApproved\",\"TokenExists\",\"TokenNotFound\",\"CannotInsert\",\"CannotRemove\",\"CannotFetchValue\",\"NotAllowed\"]}"
}
],
"info": 7,
"info": "Result",
"type": "Result<(), Error>"
},
{
"info": 10,
"info": "Tuple",
"sub": [],
"type": "()"
},
{
"displayName": "Error",
"namespace": "erc721::erc721",
"info": 3,
"info": "Enum",
"sub": [
{
"ext": {
"discriminant": 0
},
"info": 6,
"info": "Plain",
"name": "NotOwner",
"type": "Null"
},
@@ -372,7 +372,7 @@
"ext": {
"discriminant": 1
},
"info": 6,
"info": "Plain",
"name": "NotApproved",
"type": "Null"
},
@@ -380,7 +380,7 @@
"ext": {
"discriminant": 2
},
"info": 6,
"info": "Plain",
"name": "TokenExists",
"type": "Null"
},
@@ -388,7 +388,7 @@
"ext": {
"discriminant": 3
},
"info": 6,
"info": "Plain",
"name": "TokenNotFound",
"type": "Null"
},
@@ -396,7 +396,7 @@
"ext": {
"discriminant": 4
},
"info": 6,
"info": "Plain",
"name": "CannotInsert",
"type": "Null"
},
@@ -404,7 +404,7 @@
"ext": {
"discriminant": 5
},
"info": 6,
"info": "Plain",
"name": "CannotRemove",
"type": "Null"
},
@@ -412,7 +412,7 @@
"ext": {
"discriminant": 6
},
"info": 6,
"info": "Plain",
"name": "CannotFetchValue",
"type": "Null"
},
@@ -420,7 +420,7 @@
"ext": {
"discriminant": 7
},
"info": 6,
"info": "Plain",
"name": "NotAllowed",
"type": "Null"
}
@@ -1,6 +1,6 @@
[
{
"info": 6,
"info": "Plain",
"type": "bool"
}
]
@@ -1,6 +1,6 @@
[
{
"info": 6,
"info": "Plain",
"type": "bool"
}
]
@@ -1,6 +1,6 @@
[
{
"info": 6,
"info": "Plain",
"type": "i32"
}
]
@@ -2,20 +2,20 @@
{
"displayName": "Header",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "last_vacant"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "len"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "len_entries"
}
@@ -23,7 +23,7 @@
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
},
{
"info": 6,
"info": "Plain",
"type": "u32"
},
{
@@ -33,15 +33,15 @@
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -50,73 +50,73 @@
"name": "Vacant"
},
{
"info": 10,
"info": "Tuple",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
}
],
"type": "(u32, AccountId)",
"type": "(u32,AccountId)",
"name": "Occupied"
}
],
"info": 3,
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(u32, AccountId)\"}}"
"info": "Enum",
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(u32,AccountId)\"}}"
},
{
"info": 10,
"info": "Tuple",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
}
],
"type": "(u32, AccountId)"
"type": "(u32,AccountId)"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
"info": 12,
"info": "VecFixed",
"length": 32,
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "[u8;32]"
},
{
"info": 6,
"info": "Plain",
"type": "u8"
},
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -128,22 +128,22 @@
"namespace": "ink_storage::collections::hashmap",
"sub": [
{
"info": 10,
"info": "Tuple",
"sub": [],
"type": "()",
"name": "value"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "key_index"
}
],
"info": 9,
"info": "Struct",
"type": "{\"value\":\"()\",\"key_index\":\"u32\"}"
},
{
"info": 10,
"info": "Tuple",
"sub": [],
"type": "()"
},
@@ -154,15 +154,15 @@
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -171,12 +171,12 @@
"name": "Vacant"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "Occupied"
}
],
"info": 3,
"info": "Enum",
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"u32\"}}"
},
{
@@ -184,17 +184,17 @@
"namespace": "ink_storage::collections::hashmap",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "value"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "key_index"
}
],
"info": 9,
"info": "Struct",
"type": "{\"value\":\"u32\",\"key_index\":\"u32\"}"
},
{
@@ -204,15 +204,15 @@
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -223,41 +223,41 @@
{
"displayName": "Transaction",
"namespace": "multisig_plain::multisig_plain",
"info": 9,
"info": "Struct",
"sub": [
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId",
"name": "callee"
},
{
"info": 12,
"info": "VecFixed",
"length": 4,
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "[u8;4]",
"name": "selector"
},
{
"info": 11,
"info": "Vec",
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "Vec<u8>",
"name": "input"
},
{
"info": 6,
"info": "Plain",
"type": "u128",
"name": "transferred_value"
},
{
"info": 6,
"info": "Plain",
"type": "u64",
"name": "gas_limit"
}
@@ -266,47 +266,47 @@
"name": "Occupied"
}
],
"info": 3,
"info": "Enum",
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"Transaction\"}}"
},
{
"displayName": "Transaction",
"namespace": "multisig_plain::multisig_plain",
"info": 9,
"info": "Struct",
"sub": [
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId",
"name": "callee"
},
{
"info": 12,
"info": "VecFixed",
"length": 4,
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "[u8;4]",
"name": "selector"
},
{
"info": 11,
"info": "Vec",
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "Vec<u8>",
"name": "input"
},
{
"info": 6,
"info": "Plain",
"type": "u128",
"name": "transferred_value"
},
{
"info": 6,
"info": "Plain",
"type": "u64",
"name": "gas_limit"
}
@@ -314,28 +314,28 @@
"type": "{\"callee\":\"AccountId\",\"selector\":\"[u8;4]\",\"input\":\"Vec<u8>\",\"transferred_value\":\"u128\",\"gas_limit\":\"u64\"}"
},
{
"info": 12,
"info": "VecFixed",
"length": 4,
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "[u8;4]"
},
{
"info": 11,
"info": "Vec",
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "Vec<u8>"
},
{
"info": 6,
"info": "Plain",
"type": "u128"
},
{
"info": 6,
"info": "Plain",
"type": "u64"
},
{
@@ -345,15 +345,15 @@
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -364,44 +364,44 @@
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId",
"name": "Occupied"
}
],
"info": 3,
"info": "Enum",
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
},
{
"info": 11,
"info": "Vec",
"sub": {
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
"type": "Vec<AccountId>"
},
{
"info": 10,
"info": "Tuple",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32"
},
{
"displayName": "ConfirmationStatus",
"namespace": "multisig_plain::multisig_plain",
"info": 3,
"info": "Enum",
"sub": [
{
"info": 10,
"info": "Tuple",
"sub": [],
"name": "Confirmed",
"type": "()"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "ConfirmationsNeeded"
}
@@ -409,21 +409,21 @@
"type": "{\"_enum\":{\"Confirmed\":\"()\",\"ConfirmationsNeeded\":\"u32\"}}"
}
],
"type": "(u32, ConfirmationStatus)"
"type": "(u32,ConfirmationStatus)"
},
{
"displayName": "ConfirmationStatus",
"namespace": "multisig_plain::multisig_plain",
"info": 3,
"info": "Enum",
"sub": [
{
"info": 10,
"info": "Tuple",
"sub": [],
"name": "Confirmed",
"type": "()"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "ConfirmationsNeeded"
}
@@ -435,18 +435,18 @@
"sub": [
{
"name": "Ok",
"info": 10,
"info": "Tuple",
"sub": [],
"type": "()"
},
{
"name": "Error",
"info": 10,
"info": "Tuple",
"sub": [],
"type": "()"
}
],
"info": 7,
"info": "Result",
"type": "Result<(), ()>"
},
{
@@ -454,21 +454,21 @@
"sub": [
{
"name": "Ok",
"info": 11,
"info": "Vec",
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "Vec<u8>"
},
{
"name": "Error",
"info": 10,
"info": "Tuple",
"sub": [],
"type": "()"
}
],
"info": 7,
"info": "Result",
"type": "Result<Vec<u8>, ()>"
},
{
@@ -478,37 +478,37 @@
"name": "Ok",
"displayName": "Option",
"sub": {
"info": 11,
"info": "Vec",
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "Vec<u8>"
},
"info": 5,
"info": "Option",
"type": "Option<Vec<u8>>"
},
{
"name": "Error",
"info": 10,
"info": "Tuple",
"sub": [],
"type": "()"
}
],
"info": 7,
"info": "Result",
"type": "Result<Option<Vec<u8>>, ()>"
},
{
"displayName": "Option",
"sub": {
"info": 11,
"info": "Vec",
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "Vec<u8>"
},
"info": 5,
"info": "Option",
"type": "Option<Vec<u8>>"
}
]
@@ -1,6 +1,6 @@
[
{
"info": 6,
"info": "Plain",
"type": "u256"
}
]
@@ -1,28 +1,28 @@
[
{
"info": 6,
"info": "Plain",
"type": "u256"
},
{
"info": 6,
"info": "Plain",
"type": "u8"
},
{
"info": 12,
"info": "VecFixed",
"length": 32,
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "[u8;32]"
},
{
"displayName": "AccountId",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
"info": 6,
"info": "Plain",
"type": "Text"
}
]
@@ -1,23 +1,23 @@
[
{
"info": 6,
"info": "Plain",
"type": "i32"
},
{
"info": 6,
"info": "Plain",
"type": "u32"
},
{
"info": 6,
"info": "Plain",
"type": "u8"
},
{
"displayName": "Variant",
"namespace": "enum_example::enum_example",
"info": 3,
"info": "Enum",
"sub": [
{
"info": 10,
"info": "Tuple",
"sub": [],
"name": "None",
"type": "()"
@@ -25,13 +25,13 @@
{
"displayName": "Weekday",
"namespace": "enum_example::enum_example",
"info": 3,
"info": "Enum",
"sub": [
{
"ext": {
"discriminant": 0
},
"info": 6,
"info": "Plain",
"name": "Monday",
"type": "Null"
},
@@ -39,7 +39,7 @@
"ext": {
"discriminant": 1
},
"info": 6,
"info": "Plain",
"name": "Tuesday",
"type": "Null"
},
@@ -47,7 +47,7 @@
"ext": {
"discriminant": 2
},
"info": 6,
"info": "Plain",
"name": "Wednesday",
"type": "Null"
},
@@ -55,7 +55,7 @@
"ext": {
"discriminant": 3
},
"info": 6,
"info": "Plain",
"name": "Thursday",
"type": "Null"
},
@@ -63,7 +63,7 @@
"ext": {
"discriminant": 4
},
"info": 6,
"info": "Plain",
"name": "Friday",
"type": "Null"
},
@@ -71,7 +71,7 @@
"ext": {
"discriminant": 5
},
"info": 6,
"info": "Plain",
"name": "Saturday",
"type": "Null"
},
@@ -79,7 +79,7 @@
"ext": {
"discriminant": 6
},
"info": 6,
"info": "Plain",
"name": "Sunday",
"type": "Null"
}
@@ -90,15 +90,15 @@
{
"displayName": "TupleMaybeSigned",
"namespace": "enum_example::enum_example",
"info": 3,
"info": "Enum",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "i32",
"name": "Signed"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "Unsigned"
}
@@ -109,13 +109,13 @@
{
"displayName": "NamedMaybeSigned",
"namespace": "enum_example::enum_example",
"info": 3,
"info": "Enum",
"sub": [
{
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "i32",
"name": "value"
}
@@ -124,10 +124,10 @@
"type": "{\"value\":\"i32\"}"
},
{
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "value"
}
@@ -142,47 +142,47 @@
{
"displayName": "Color",
"namespace": "enum_example::enum_example",
"info": 3,
"info": "Enum",
"sub": [
{
"info": 10,
"info": "Tuple",
"sub": [],
"name": "Red",
"type": "()"
},
{
"info": 10,
"info": "Tuple",
"sub": [],
"name": "Blue",
"type": "()"
},
{
"info": 10,
"info": "Tuple",
"sub": [],
"name": "Green",
"type": "()"
},
{
"info": 10,
"info": "Tuple",
"sub": [],
"name": "Yellow",
"type": "()"
},
{
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "r"
},
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "g"
},
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "b"
}
@@ -191,25 +191,25 @@
"type": "{\"r\":\"u8\",\"g\":\"u8\",\"b\":\"u8\"}"
},
{
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "r"
},
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "g"
},
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "b"
},
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "a"
}
@@ -227,13 +227,13 @@
{
"displayName": "Weekday",
"namespace": "enum_example::enum_example",
"info": 3,
"info": "Enum",
"sub": [
{
"ext": {
"discriminant": 0
},
"info": 6,
"info": "Plain",
"name": "Monday",
"type": "Null"
},
@@ -241,7 +241,7 @@
"ext": {
"discriminant": 1
},
"info": 6,
"info": "Plain",
"name": "Tuesday",
"type": "Null"
},
@@ -249,7 +249,7 @@
"ext": {
"discriminant": 2
},
"info": 6,
"info": "Plain",
"name": "Wednesday",
"type": "Null"
},
@@ -257,7 +257,7 @@
"ext": {
"discriminant": 3
},
"info": 6,
"info": "Plain",
"name": "Thursday",
"type": "Null"
},
@@ -265,7 +265,7 @@
"ext": {
"discriminant": 4
},
"info": 6,
"info": "Plain",
"name": "Friday",
"type": "Null"
},
@@ -273,7 +273,7 @@
"ext": {
"discriminant": 5
},
"info": 6,
"info": "Plain",
"name": "Saturday",
"type": "Null"
},
@@ -281,7 +281,7 @@
"ext": {
"discriminant": 6
},
"info": 6,
"info": "Plain",
"name": "Sunday",
"type": "Null"
}
@@ -291,15 +291,15 @@
{
"displayName": "TupleMaybeSigned",
"namespace": "enum_example::enum_example",
"info": 3,
"info": "Enum",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "i32",
"name": "Signed"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "Unsigned"
}
@@ -309,13 +309,13 @@
{
"displayName": "NamedMaybeSigned",
"namespace": "enum_example::enum_example",
"info": 3,
"info": "Enum",
"sub": [
{
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "i32",
"name": "value"
}
@@ -324,10 +324,10 @@
"type": "{\"value\":\"i32\"}"
},
{
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "value"
}
@@ -341,47 +341,47 @@
{
"displayName": "Color",
"namespace": "enum_example::enum_example",
"info": 3,
"info": "Enum",
"sub": [
{
"info": 10,
"info": "Tuple",
"sub": [],
"name": "Red",
"type": "()"
},
{
"info": 10,
"info": "Tuple",
"sub": [],
"name": "Blue",
"type": "()"
},
{
"info": 10,
"info": "Tuple",
"sub": [],
"name": "Green",
"type": "()"
},
{
"info": 10,
"info": "Tuple",
"sub": [],
"name": "Yellow",
"type": "()"
},
{
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "r"
},
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "g"
},
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "b"
}
@@ -390,25 +390,25 @@
"type": "{\"r\":\"u8\",\"g\":\"u8\",\"b\":\"u8\"}"
},
{
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "r"
},
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "g"
},
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "b"
},
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "a"
}
@@ -1,25 +1,25 @@
[
{
"info": 6,
"info": "Plain",
"type": "u128"
},
{
"displayName": "Header",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "last_vacant"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "len"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "len_entries"
}
@@ -27,7 +27,7 @@
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
},
{
"info": 6,
"info": "Plain",
"type": "u32"
},
{
@@ -37,15 +37,15 @@
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -56,45 +56,45 @@
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId",
"name": "Occupied"
}
],
"info": 3,
"info": "Enum",
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
"info": 12,
"info": "VecFixed",
"length": 32,
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "[u8;32]"
},
{
"info": 6,
"info": "Plain",
"type": "u8"
},
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -106,17 +106,17 @@
"namespace": "ink_storage::collections::hashmap",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u128",
"name": "value"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "key_index"
}
],
"info": 9,
"info": "Struct",
"type": "{\"value\":\"u128\",\"key_index\":\"u32\"}"
},
{
@@ -126,15 +126,15 @@
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -143,52 +143,52 @@
"name": "Vacant"
},
{
"info": 10,
"info": "Tuple",
"sub": [
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
}
],
"type": "(AccountId, AccountId)",
"type": "(AccountId,AccountId)",
"name": "Occupied"
}
],
"info": 3,
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId, AccountId)\"}}"
"info": "Enum",
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId,AccountId)\"}}"
},
{
"info": 10,
"info": "Tuple",
"sub": [
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
}
],
"type": "(AccountId, AccountId)"
"type": "(AccountId,AccountId)"
},
{
"info": 6,
"info": "Plain",
"type": "Text"
},
{
"info": 6,
"info": "Plain",
"type": "bool"
},
{
@@ -196,10 +196,10 @@
"sub": {
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
"info": 5,
"info": "Option",
"type": "Option<AccountId>"
}
]
+13 -11
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-derive",
"version": "4.6.2",
"version": "5.8.2",
"type": "module",
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
"main": "index.js",
@@ -8,6 +8,9 @@
"./detectPackage.js",
"./detectPackage.cjs"
],
"engines": {
"node": ">=14.0.0"
},
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
"contributors": [],
@@ -16,17 +19,16 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"dependencies": {
"@babel/runtime": "^7.13.10",
"@polkadot/api": "4.6.2",
"@polkadot/rpc-core": "4.6.2",
"@polkadot/types": "4.6.2",
"@polkadot/util": "^6.2.1",
"@polkadot/util-crypto": "^6.2.1",
"@polkadot/x-rxjs": "^6.2.1",
"bn.js": "^4.11.9"
"@babel/runtime": "^7.15.4",
"@polkadot/api": "5.8.2",
"@polkadot/rpc-core": "5.8.2",
"@polkadot/types": "5.8.2",
"@polkadot/util": "^7.3.1",
"@polkadot/util-crypto": "^7.3.1",
"rxjs": "^7.3.0"
},
"devDependencies": {
"@polkadot/keyring": "^6.2.1",
"@polkadot/rpc-provider": "4.6.2"
"@polkadot/keyring": "^7.3.1",
"@polkadot/rpc-provider": "5.8.2"
}
}
@@ -1,14 +1,14 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import { map, of } from 'rxjs';
import { assertReturn, isU8a } from '@polkadot/util';
import { decodeAddress } from '@polkadot/util-crypto';
import { of } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
+9 -6
View File
@@ -1,15 +1,14 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Vec } from '@polkadot/types';
import type { AccountId, Address, Balance } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveAccountFlags } from '../types';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
import { combineLatest, map, of } from 'rxjs';
import { memo } from '../util';
@@ -41,11 +40,15 @@ function parseFlags (address: AccountId | Address | string | null | undefined, [
*/
export function flags (instanceId: string, api: ApiInterfaceRx): (address?: AccountId | Address | string | null) => Observable<DeriveAccountFlags> {
return memo(instanceId, (address?: AccountId | Address | string | null): Observable<DeriveAccountFlags> => {
const councilSection = api.query.electionsPhragmen ? 'electionsPhragmen' : 'elections';
const councilSection = api.query.phragmenElection
? 'phragmenElection'
: api.query.electionsPhragmen
? 'electionsPhragmen'
: 'elections';
return combineLatest<FlagsIntermediate>([
return combineLatest([
address && api.query[councilSection]?.members
? api.query[councilSection].members()
? api.query[councilSection].members<Vec<ITuple<[AccountId, Balance]>>>()
: of(undefined),
address && api.query.council?.members
? api.query.council.members()
@@ -1,15 +1,15 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import type { AccountIdAndIndex } from '../types';
import { map, of } from 'rxjs';
import { isU8a } from '@polkadot/util';
import { decodeAddress } from '@polkadot/util-crypto';
import { of } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
@@ -1,12 +1,12 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AccountId, AccountIndex } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import type { AccountIndexes } from '../types';
import { map } from '@polkadot/x-rxjs/operators';
import { map } from 'rxjs';
import { memo } from '../util';
+3 -3
View File
@@ -1,16 +1,16 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Data, Option } from '@polkadot/types';
import type { AccountId, IdentityInfoAdditional, Registration } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveAccountRegistration, DeriveHasIdentity } from '../types';
import { combineLatest, map, of, switchMap } from 'rxjs';
import { isHex, u8aToString } from '@polkadot/util';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
@@ -1,14 +1,13 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option } from '@polkadot/types';
import type { AccountId, AccountIndex, BalanceOf } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import { of } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
import { map, of } from 'rxjs';
import { memo } from '../util';
+2 -3
View File
@@ -1,12 +1,11 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { AccountIndexes } from '../types';
import { of } from '@polkadot/x-rxjs';
import { map, startWith } from '@polkadot/x-rxjs/operators';
import { map, of, startWith } from 'rxjs';
import { memo } from '../util';
+3 -3
View File
@@ -1,16 +1,16 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Bytes, Option, u32 } from '@polkadot/types';
import type { AccountId, AccountIndex, Address, Balance } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveAccountInfo, DeriveAccountRegistration } from '../types';
import { combineLatest, map, of, switchMap } from 'rxjs';
import { u8aToString } from '@polkadot/util';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
+74 -42
View File
@@ -1,15 +1,15 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx, QueryableStorageEntry } from '@polkadot/api/types';
import type { AccountData, AccountId, AccountIndex, AccountInfo, Address, Balance, Index } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveBalancesAccount, DeriveBalancesAccountData } from '../types';
import { assert, isFunction } from '@polkadot/util';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { combineLatest, map, of, switchMap } from 'rxjs';
import { isFunction } from '@polkadot/util';
import { memo } from '../util';
@@ -23,25 +23,27 @@ type DeriveCustomAccount = ApiInterfaceRx['derive'] & {
}
}
function zeroBalance (api: ApiInterfaceRx) {
return api.registry.createType('Balance');
}
function getBalance (api: ApiInterfaceRx, [freeBalance, reservedBalance, frozenFee, frozenMisc]: BalanceResult): DeriveBalancesAccountData {
const votingBalance = api.registry.createType('Balance', freeBalance.toBn());
return {
freeBalance,
frozenFee,
frozenMisc,
reservedBalance,
votingBalance: api.registry.createType('Balance', freeBalance.toBn())
votingBalance
};
}
function calcBalances (api: ApiInterfaceRx, [accountId, [accountNonce, balances]]: [AccountId, Result]): DeriveBalancesAccount {
const primary = balances[0];
assert(primary, 'No balances retrieved for account');
function calcBalances (api: ApiInterfaceRx, [accountId, [accountNonce, [primary, ...additional]]]: [AccountId, Result]): DeriveBalancesAccount {
return {
accountId,
accountNonce,
additional: balances.filter((_, index) => index !== 0).map((b) => getBalance(api, b)),
additional: additional.map((b) => getBalance(api, b)),
...getBalance(api, primary)
};
}
@@ -55,41 +57,72 @@ function queryBalancesFree (api: ApiInterfaceRx, accountId: AccountId): Observab
]).pipe(
map(([freeBalance, reservedBalance, accountNonce]): Result => [
accountNonce,
[[freeBalance, reservedBalance, api.registry.createType('Balance'), api.registry.createType('Balance')]]
[[freeBalance, reservedBalance, zeroBalance(api), zeroBalance(api)]]
])
);
}
function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId, modules: string[] = ['balances']): Observable<Result> {
const balances = modules.map(
(m): QueryableStorageMultiArg<'rxjs'> => [
(api.derive as DeriveCustomAccount)[m]?.customAccount || api.query[m].account,
accountId
]
);
const extract = (data: AccountData[]) =>
data.map(({ feeFrozen, free, miscFrozen, reserved }): BalanceResult => [free, reserved, feeFrozen, miscFrozen]);
function queryNonceOnly (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
const fill = (nonce: Index): Result => [
nonce,
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
];
return isFunction(api.query.system.account)
? api.queryMulti<[AccountInfo, ...(AccountData[])]>([[api.query.system.account, accountId], ...balances]).pipe(
map(([{ nonce }, ...balances]): Result => [nonce, extract(balances)])
? api.query.system.account(accountId).pipe(
map(({ nonce }) => fill(nonce))
)
: api.queryMulti<[Index, ...(AccountData[])]>([[api.query.system.accountNonce, accountId], ...balances]).pipe(
map(([nonce, ...balances]): Result => [nonce, extract(balances)])
);
: isFunction(api.query.system.accountNonce)
? api.query.system.accountNonce<Index>(accountId).pipe(
map((nonce) => fill(nonce))
)
: of(fill(api.registry.createType('Index')));
}
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId, modules: string[] = ['balances']): Observable<Result> {
const balances = modules
.map((m): QueryableStorageEntry<'rxjs'> => (api.derive as DeriveCustomAccount)[m]?.customAccount || api.query[m]?.account)
.filter((q) => isFunction(q))
.map((q): [QueryableStorageEntry<'rxjs'>, AccountId] => [q, accountId]);
const extract = (nonce: Index, data: AccountData[]): Result => [
nonce,
data.map(({ feeFrozen, free, miscFrozen, reserved }): BalanceResult => [free, reserved, feeFrozen, miscFrozen])
];
// NOTE this is for the first case where we do have instances specified
return balances.length
? isFunction(api.query.system.account)
? api.queryMulti<[AccountInfo, ...(AccountData[])]>([[api.query.system.account, accountId], ...balances]).pipe(
map(([{ nonce }, ...balances]) => extract(nonce, balances))
)
: api.queryMulti<[Index, ...(AccountData[])]>([[api.query.system.accountNonce, accountId], ...balances]).pipe(
map(([nonce, ...balances]) => extract(nonce, balances))
)
: queryNonceOnly(api, accountId);
}
function querySystemAccount (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
// AccountInfo is current, support old, eg. Edgeware
return api.query.system.account<AccountInfo | ITuple<[Index, AccountData]>>(accountId).pipe(
map((infoOrTuple): Result => {
const { feeFrozen, free, miscFrozen, reserved } = (infoOrTuple as AccountInfo).nonce
const data = (infoOrTuple as AccountInfo).nonce
? (infoOrTuple as AccountInfo).data
: (infoOrTuple as [Index, AccountData])[1];
const nonce = (infoOrTuple as AccountInfo).nonce || (infoOrTuple as [Index, AccountData])[0];
if (!data || data.isEmpty) {
return [
nonce,
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
];
}
const { feeFrozen, free, miscFrozen, reserved } = data;
return [
(infoOrTuple as AccountInfo).nonce || (infoOrTuple as [Index, AccountData])[0],
nonce,
[[free, reserved, feeFrozen, miscFrozen]]
];
})
@@ -122,19 +155,18 @@ export function account (instanceId: string, api: ApiInterfaceRx): (address: Acc
of(accountId),
balanceInstances
? queryBalancesAccount(api, accountId, balanceInstances)
: isFunction(api.query.system.account)
? queryCurrent(api, accountId)
: isFunction(api.query.balances.account)
: isFunction(api.query.system?.account)
? querySystemAccount(api, accountId)
: isFunction(api.query.balances?.account)
? queryBalancesAccount(api, accountId)
: queryBalancesFree(api, accountId)
])
: of([
api.registry.createType('AccountId'),
[
api.registry.createType('Index'),
[[api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Balance')]]
]
: isFunction(api.query.balances?.freeBalance)
? queryBalancesFree(api, accountId)
: queryNonceOnly(api, accountId)
])
: of([api.registry.createType('AccountId'), [
api.registry.createType('Index'),
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
]])
)
),
map((result): DeriveBalancesAccount => calcBalances(api, result))
+20 -25
View File
@@ -1,17 +1,15 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
import type { Option, Vec } from '@polkadot/types';
import type { AccountId, AccountIndex, Address, Balance, BalanceLock, BalanceLockTo212, BlockNumber, VestingInfo, VestingSchedule } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveBalancesAccount, DeriveBalancesAccountData, DeriveBalancesAll, DeriveBalancesAllAccountData } from '../types';
import BN from 'bn.js';
import { combineLatest, map, of, switchMap } from 'rxjs';
import { bnMax, isFunction } from '@polkadot/util';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { BN, bnMax, isFunction } from '@polkadot/util';
import { memo } from '../util';
@@ -44,11 +42,11 @@ function calcLocked (api: ApiInterfaceRx, bestNumber: BlockNumber, locks: (Balan
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)));
allLocked = lockedBreakdown.some(({ amount }) => amount.isMax());
allLocked = lockedBreakdown.some(({ amount }) => 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
const notAll = lockedBreakdown.filter(({ amount }) => !amount.isMax());
const notAll = lockedBreakdown.filter(({ amount }) => amount && !amount.isMax());
if (notAll.length) {
lockedBalance = api.registry.createType('Balance', bnMax(...notAll.map(({ amount }): Balance => amount)));
@@ -75,7 +73,8 @@ function calcBalances (api: ApiInterfaceRx, [data, bestNumber, [vesting, allLock
// Calculate the vesting balances,
// - offset = balance locked at startingBlock
// - perBlock is the unlock amount
const { locked: vestingTotal, perBlock, startingBlock } = vesting || api.registry.createType('VestingInfo');
const emptyVest = api.registry.createType('VestingInfo');
const { locked: vestingTotal, perBlock, startingBlock } = vesting || emptyVest;
const isStarted = bestNumber.gt(startingBlock);
const vestedNow = isStarted ? perBlock.mul(bestNumber.sub(startingBlock)) : new BN(0);
const vestedBalance = vestedNow.gt(vestingTotal) ? vestingTotal : api.registry.createType('Balance', vestedNow);
@@ -119,33 +118,29 @@ const isNonNullable = <T>(nullable: T): nullable is NonNullable<T> => !!nullable
// current (balances, vesting)
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId, balanceInstances: string[] = ['balances']): Observable<ResultBalance> {
const lockCalls = balanceInstances.map(
(m): ApiInterfaceRx['query']['balances']['locks'] | undefined =>
(api.derive as DeriveCustomLocks)[m]?.customLocks || api.query[m as 'balances']?.locks
const calls = balanceInstances.map((m): ApiInterfaceRx['query']['balances']['locks'] | undefined =>
(api.derive as DeriveCustomLocks)[m]?.customLocks || api.query[m as 'balances']?.locks
);
const lockEmpty = lockCalls.map((c) => !c);
const lockQueries = lockCalls.filter(isNonNullable).map((c): QueryableStorageMultiArg<'rxjs'> => [c, accountId]);
const lockEmpty = calls.map((c) => !c);
const queries = calls.filter(isNonNullable).map((c): QueryableStorageMultiArg<'rxjs'> => [c, accountId]);
return (
api.query.vesting?.vesting
? api.queryMulti<[Option<VestingInfo>, ...BalanceLocks]>([
[api.query.vesting.vesting, accountId],
...lockQueries
])
? api.queryMulti<[Option<VestingInfo>, ...BalanceLocks]>([[api.query.vesting.vesting, accountId], ...queries])
// TODO We need to check module instances here as well, not only the balances module
: lockQueries.length
? api.queryMulti<[...(Vec<BalanceLock>)[]]>(lockQueries).pipe(
map((locks): [Option<VestingInfo>, ...BalanceLocks] =>
[api.registry.createType('Option<VestingInfo>'), ...locks]
)
: queries.length
? api.queryMulti<[...(Vec<BalanceLock>)[]]>(queries).pipe(
map((r): [Option<VestingInfo>, ...BalanceLocks] => [api.registry.createType('Option<VestingInfo>'), ...r])
)
: of([api.registry.createType('Option<VestingInfo>')] as [Option<VestingInfo>])
).pipe(
map(([optVesting, ...locks]): ResultBalance => {
map(([opt, ...locks]): ResultBalance => {
let offset = -1;
return [optVesting.unwrapOr(null), lockEmpty.map((e) => e ? api.registry.createType('Vec<BalanceLock>') : locks[++offset])];
return [
opt.unwrapOr(null),
lockEmpty.map((e) => e ? api.registry.createType('Vec<BalanceLock>') : locks[++offset])
];
})
);
}
+2 -3
View File
@@ -1,13 +1,12 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Balance } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveFees } from '../types';
import { of } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
import { map, of } from 'rxjs';
import { memo } from '../util';
@@ -1,12 +1,12 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveBalancesAccount } from '../types';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { combineLatest, of } from 'rxjs';
import { memo } from '../util';
@@ -6,10 +6,11 @@ import type { Bytes, Option, StorageKey } from '@polkadot/types';
import type { Bounty, BountyIndex, ProposalIndex } from '@polkadot/types/interfaces';
import type { Codec, InterfaceTypes } from '@polkadot/types/types';
import { firstValueFrom, of } from 'rxjs';
import { ApiPromise } from '@polkadot/api';
import { DeriveCollectiveProposal } from '@polkadot/api-derive/types';
import { Proposal } from '@polkadot/types/interfaces';
import { of } from '@polkadot/x-rxjs';
import { BountyFactory } from '../../test/bountyFactory';
import { BytesFactory } from '../../test/bytesFactory';
@@ -98,7 +99,7 @@ describe('bounties derive', () => {
}
} as unknown as ApiInterfaceRx;
const result = await bounties('', mockApi)().toPromise();
const result = await firstValueFrom(bounties('', mockApi)());
expect(result).toHaveLength(2);
expect(result[0].bounty.proposer.toString()).toEqual(DEFAULT_PROPOSER);
@@ -110,7 +111,7 @@ describe('bounties derive', () => {
});
it('returns motions', async () => {
const result = await bounties('', defaultMockApi)().toPromise();
const result = await firstValueFrom(bounties('', defaultMockApi)());
expect(result).toHaveLength(2);
expect(result[0].proposals).toHaveLength(0);
@@ -126,7 +127,7 @@ describe('bounties derive', () => {
}
} as unknown as ApiInterfaceRx;
const result = await bounties('', mockApi)().toPromise();
const result = await firstValueFrom(bounties('', mockApi)());
expect(result).toHaveLength(2);
expect(result[0].bounty.proposer.toString()).toEqual(DEFAULT_PROPOSER);
@@ -151,7 +152,7 @@ describe('bounties derive', () => {
}
} as unknown as ApiInterfaceRx;
const result = await bounties('', mockApi)().toPromise();
const result = await firstValueFrom(bounties('', mockApi)());
expect(result).toHaveLength(2);
expect(result[0].proposals).toHaveLength(0);
+4 -4
View File
@@ -1,15 +1,15 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { DeriveBounties, DeriveCollectiveProposal } from '@polkadot/api-derive/types';
import type { Bytes, Option } from '@polkadot/types';
import type { Bounty, BountyIndex, ProposalIndex } from '@polkadot/types/interfaces';
import type { DeriveBounties, DeriveCollectiveProposal } from '../types';
import { memo } from '@polkadot/api-derive/util';
import { combineLatest, Observable, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { combineLatest, map, of, switchMap } from 'rxjs';
import { memo } from '../util';
import { filterBountiesProposals } from './helpers/filterBountyProposals';
type Result = [Option<Bounty>[], Option<Bytes>[], BountyIndex[], DeriveCollectiveProposal[]];
+114
View File
@@ -0,0 +1,114 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AnyFunction } from '@polkadot/types/types';
import * as accounts from './accounts';
import * as balances from './balances';
import * as bounties from './bounties';
import * as chain from './chain';
import * as contracts from './contracts';
import * as council from './council';
import * as crowdloan from './crowdloan';
import * as democracy from './democracy';
import * as elections from './elections';
import * as imOnline from './imOnline';
import * as membership from './membership';
import * as parachains from './parachains';
import * as session from './session';
import * as society from './society';
import * as staking from './staking';
import * as technicalCommittee from './technicalCommittee';
import * as treasury from './treasury';
import * as tx from './tx';
export { packageInfo } from './packageInfo';
export * from './type';
interface Avail {
instances: string[];
withDetect?: boolean;
}
export const derive = { accounts, balances, bounties, chain, contracts, council, crowdloan, democracy, elections, imOnline, membership, parachains, session, society, staking, technicalCommittee, treasury, tx };
type DeriveSection<Section> = {
[Method in keyof Section]: Section[Method] extends AnyFunction
? ReturnType<Section[Method]> // ReturnType<Section[Method]> will be the inner function, i.e. without (api) argument
: never;
};
type DeriveAllSections<AllSections> = {
[Section in keyof AllSections]: DeriveSection<AllSections[Section]>
};
type DeriveCreator = (instanceId: string, api: ApiInterfaceRx) => (...args: unknown[]) => Observable<any>;
export type DeriveCustom = Record<string, Record<string, DeriveCreator>>;
export type ExactDerive = DeriveAllSections<typeof derive>;
// Enable derive only if some of these modules are available
const checks: Record<string, Avail> = {
contracts: { instances: ['contracts'] },
council: { instances: ['council'], withDetect: true },
crowdloan: { instances: ['crowdloan'] },
democracy: { instances: ['democracy'] },
elections: { instances: ['phragmenElection', 'electionsPhragmen', 'elections', 'council'], withDetect: true },
imOnline: { instances: ['imOnline'] },
membership: { instances: ['membership'] },
parachains: { instances: ['parachains', 'registrar'] },
session: { instances: ['session'] },
society: { instances: ['society'] },
staking: { instances: ['staking'] },
technicalCommittee: { instances: ['technicalCommittee'], withDetect: true },
treasury: { instances: ['treasury'] }
};
/**
* Returns an object that will inject `api` into all the functions inside
* `allSections`, and keep the object architecture of `allSections`.
*/
/** @internal */
function injectFunctions<AllSections> (instanceId: string, api: ApiInterfaceRx, allSections: AllSections): DeriveAllSections<AllSections> {
const queryKeys = Object.keys(api.query);
const specName = api.runtimeVersion.specName.toString();
return Object
.keys(allSections)
.filter((sectionName) =>
!checks[sectionName] ||
checks[sectionName].instances.some((q) => queryKeys.includes(q)) ||
(
checks[sectionName].withDetect &&
checks[sectionName].instances.some((q) =>
(api.registry.getModuleInstances(specName, q) || []).some((q) => queryKeys.includes(q))
)
)
)
.reduce((derives, sectionName): DeriveAllSections<AllSections> => {
const section = allSections[sectionName as keyof AllSections];
derives[sectionName as keyof AllSections] = Object
.entries(section)
.reduce((methods, [methodName, creator]): DeriveSection<typeof section> => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call
methods[methodName as keyof typeof section] = creator(instanceId, api);
return methods;
}, {} as DeriveSection<typeof section>);
return derives;
}, {} as DeriveAllSections<AllSections>);
}
// FIXME The return type of this function should be {...ExactDerive, ...DeriveCustom}
// For now we just drop the custom derive typings
/** @internal */
export function decorateDerive (instanceId: string, api: ApiInterfaceRx, custom: DeriveCustom = {}): ExactDerive {
return {
...injectFunctions(instanceId, api, derive),
...injectFunctions(instanceId, api, custom)
};
}
+2 -2
View File
@@ -1,11 +1,11 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { BlockNumber } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
import { map } from 'rxjs';
import { memo } from '../util';
@@ -1,11 +1,11 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { BlockNumber } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
import { map } from 'rxjs';
import { memo } from '../util';
@@ -1,12 +1,11 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { BlockNumber } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import { combineLatest } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
import { combineLatest, map } from 'rxjs';
import { memo } from '../util';
+2 -3
View File
@@ -1,12 +1,11 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { SignedBlockExtended } from '../type/types';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { catchError, map } from '@polkadot/x-rxjs/operators';
import { catchError, combineLatest, map, of } from 'rxjs';
import { createSignedBlockExtended } from '../type';
import { memo } from '../util';
+2 -3
View File
@@ -1,12 +1,11 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { HeaderExtended } from '../type/types';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { catchError, map } from '@polkadot/x-rxjs/operators';
import { catchError, combineLatest, map, of } from 'rxjs';
import { createHeaderExtended } from '../type';
import { memo } from '../util';
@@ -1,14 +1,13 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Vec } from '@polkadot/types';
import type { EventRecord, SignedBlock } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import type { HeaderExtended, SignedBlockExtended } from '../type/types';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { combineLatest, map, of, switchMap } from 'rxjs';
import { createSignedBlockExtended } from '../type';
import { memo } from '../util';
@@ -1,12 +1,11 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { HeaderExtended } from '../type/types';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
import { combineLatest, map, of } from 'rxjs';
import { createHeaderExtended } from '../type';
import { memo } from '../util';
@@ -0,0 +1,12 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx } from '@polkadot/api/types';
export function getInstance (api: ApiInterfaceRx, section: string): string {
const instances = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), section);
return instances && instances.length
? instances[0]
: section;
}
@@ -1,4 +1,6 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './members';
export * from './prime';
export * from './proposals';
@@ -0,0 +1,24 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AccountId } from '@polkadot/types/interfaces';
import type { Collective } from './types';
import { of } from 'rxjs';
import { isFunction } from '@polkadot/util';
import { memo } from '../util';
import { getInstance } from './getInstance';
export function members (instanceId: string, api: ApiInterfaceRx, _section: Collective): () => Observable<AccountId[]> {
const section = getInstance(api, _section);
return memo(instanceId, (): Observable<AccountId[]> =>
isFunction(api.query[section]?.members)
? api.query[section as 'council'].members()
: of([])
);
}
@@ -0,0 +1,28 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option } from '@polkadot/types';
import type { AccountId } from '@polkadot/types/interfaces';
import { map, of } from 'rxjs';
import { isFunction } from '@polkadot/util';
import { memo } from '../util';
import { getInstance } from './getInstance';
export function prime (instanceId: string, api: ApiInterfaceRx, _section: string): () => Observable<AccountId | null> {
const section = getInstance(api, _section);
return memo(instanceId, (): Observable<AccountId | null> =>
isFunction(api.query[section as 'council']?.prime)
? api.query[section as 'council'].prime<Option<AccountId>>().pipe(
map((optPrime): AccountId | null =>
optPrime.unwrapOr(null)
)
)
: of(null)
);
}
+53 -17
View File
@@ -1,17 +1,19 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option } from '@polkadot/types';
import type { Option, u32 } from '@polkadot/types';
import type { Hash, Proposal, Votes } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveCollectiveProposal } from '../types';
import type { Collective } from './types';
import { catchError, combineLatest, map, of, switchMap } from 'rxjs';
import { isFunction } from '@polkadot/util';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { catchError, map, switchMap } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
import { getInstance } from './getInstance';
type Result = [(Hash | Uint8Array | string)[], (Option<Proposal> | null)[], Option<Votes>[]];
@@ -29,39 +31,73 @@ function parse (api: ApiInterfaceRx, [hashes, proposals, votes]: Result): Derive
.filter((proposal): proposal is DeriveCollectiveProposal => !!proposal);
}
function _proposalsFrom (instanceId: string, api: ApiInterfaceRx, section: 'council' | 'technicalCommittee' = 'council'): (hashes: (Hash | Uint8Array | string)[]) => Observable<DeriveCollectiveProposal[]> {
function _proposalsFrom (instanceId: string, api: ApiInterfaceRx, section: string): (hashes: (Hash | Uint8Array | string)[]) => Observable<DeriveCollectiveProposal[]> {
return memo(instanceId, (hashes: (Hash | Uint8Array | string)[]): Observable<DeriveCollectiveProposal[]> =>
(isFunction(api.query[section]?.proposals) && hashes.length
? combineLatest<Result>([
? combineLatest([
of(hashes),
// this should simply be api.query[section].proposalOf.multi<Option<Proposal>>(hashes),
// however we have had cases on Edgeware where the indices have moved around after an
// upgrade, which results in invalid on-chain data
combineLatest(hashes.map((hash) =>
// this should simply be api.query[section].proposalOf.multi<Option<Proposal>>(hashes),
// however we have had cases on Edgeware where the indices have moved around after an
// upgrade, which results in invalid on-chain data
api.query[section].proposalOf(hash).pipe(catchError(() => of(null)))
api.query[section].proposalOf<Option<Proposal>>(hash).pipe(
catchError(() => of(null))
)
)),
api.query[section].voting.multi<Option<Votes>>(hashes)
])
: of([[], [], []] as Result)
: of<Result>([[], [], []])
).pipe(
map((result) => parse(api, result))
)
);
}
export function proposals (instanceId: string, api: ApiInterfaceRx, section: 'council' | 'technicalCommittee' = 'council'): () => Observable<DeriveCollectiveProposal[]> {
const proposalsFrom = _proposalsFrom(instanceId, api, section);
export function hasProposals (instanceId: string, api: ApiInterfaceRx, _section: Collective): () => Observable<boolean> {
const section = getInstance(api, _section);
return memo(instanceId, (): Observable<DeriveCollectiveProposal[]> =>
isFunction(api.query[section]?.proposals)
? api.query[section].proposals().pipe(
switchMap(proposalsFrom)
)
: of([] as DeriveCollectiveProposal[])
return memo(instanceId, (): Observable<boolean> =>
of(isFunction(api.query[section]?.proposals))
);
}
export function proposal (instanceId: string, api: ApiInterfaceRx, section: 'council' | 'technicalCommittee' = 'council'): (hash: Hash | Uint8Array | string) => Observable<DeriveCollectiveProposal | null> {
export function proposalCount (instanceId: string, api: ApiInterfaceRx, _section: Collective): () => Observable<u32 | null> {
const section = getInstance(api, _section);
return memo(instanceId, (): Observable<u32 | null> =>
isFunction(api.query[section].proposalCount)
? api.query[section as 'council'].proposalCount()
: of(null)
);
}
export function proposalHashes (instanceId: string, api: ApiInterfaceRx, _section: Collective): () => Observable<Hash[]> {
const section = getInstance(api, _section);
return memo(instanceId, (): Observable<Hash[]> =>
isFunction(api.query[section]?.proposals)
? api.query[section as 'council'].proposals()
: of([])
);
}
export function proposals (instanceId: string, api: ApiInterfaceRx, _section: Collective): () => Observable<DeriveCollectiveProposal[]> {
const section = getInstance(api, _section);
const proposalsFrom = _proposalsFrom(instanceId, api, section);
const getHashes = proposalHashes(instanceId, api, _section);
return memo(instanceId, (): Observable<DeriveCollectiveProposal[]> =>
getHashes().pipe(
switchMap(proposalsFrom)
)
);
}
export function proposal (instanceId: string, api: ApiInterfaceRx, _section: Collective): (hash: Hash | Uint8Array | string) => Observable<DeriveCollectiveProposal | null> {
const section = getInstance(api, _section);
const proposalsFrom = _proposalsFrom(instanceId, api, section);
return memo(instanceId, (hash: Hash | Uint8Array | string): Observable<DeriveCollectiveProposal | null> =>
@@ -0,0 +1,4 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
export type Collective = 'council' | 'membership' | 'technicalCommittee';
+3 -5
View File
@@ -1,14 +1,12 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { BN } from '@polkadot/util';
import type { DeriveContractFees } from '../types';
import BN from 'bn.js';
import { of } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
import { map, of } from 'rxjs';
import { memo } from '../util';
+2
View File
@@ -1,6 +1,8 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './members';
export * from './prime';
export * from './proposals';
export * from './votes';
export * from './votesOf';
@@ -0,0 +1,13 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AccountId } from '@polkadot/types/interfaces';
import { members as collectiveMembers } from '../collective';
import { memo } from '../util';
export function members (instanceId: string, api: ApiInterfaceRx): () => Observable<AccountId[]> {
return memo(instanceId, collectiveMembers(instanceId, api, 'council'));
}
+13
View File
@@ -0,0 +1,13 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AccountId } from '@polkadot/types/interfaces';
import { prime as collectivePrime } from '../collective';
import { memo } from '../util';
export function prime (instanceId: string, api: ApiInterfaceRx): () => Observable<AccountId | null> {
return memo(instanceId, collectivePrime(instanceId, api, 'council'));
}
+17 -4
View File
@@ -1,18 +1,31 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { u32 } from '@polkadot/types';
import type { Hash } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveCollectiveProposal } from '../types';
import { proposal as collectiveProposal, proposals as collectiveProposals } from '../collective';
import { hasProposals as collectiveHasProposals, proposal as collectiveProposal, proposalCount as collectiveProposalCount, proposalHashes as collectiveProposalHashes, proposals as collectiveProposals } from '../collective';
import { memo } from '../util';
export function hasProposals (instanceId: string, api: ApiInterfaceRx): () => Observable<boolean> {
return memo(instanceId, collectiveHasProposals(instanceId, api, 'council'));
}
export function proposal (instanceId: string, api: ApiInterfaceRx): (hash: Hash | Uint8Array | string) => Observable<DeriveCollectiveProposal | null> {
return memo(instanceId, collectiveProposal(instanceId, api));
return memo(instanceId, collectiveProposal(instanceId, api, 'council'));
}
export function proposalCount (instanceId: string, api: ApiInterfaceRx): () => Observable<u32 | null> {
return memo(instanceId, collectiveProposalCount(instanceId, api, 'council'));
}
export function proposalHashes (instanceId: string, api: ApiInterfaceRx): () => Observable<Hash[]> {
return memo(instanceId, collectiveProposalHashes(instanceId, api, 'council'));
}
export function proposals (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveCollectiveProposal[]> {
return memo(instanceId, collectiveProposals(instanceId, api));
return memo(instanceId, collectiveProposals(instanceId, api, 'council'));
}
+20 -16
View File
@@ -1,15 +1,14 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx, QueryableModuleStorage } from '@polkadot/api/types';
import type { Vec } from '@polkadot/types';
import type { AccountId, Balance, Voter } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveCouncilVote, DeriveCouncilVotes } from '../types';
import { combineLatest } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
import { combineLatest, map, of } from 'rxjs';
import { memo } from '../util';
@@ -20,24 +19,27 @@ function isVoter (value: VoteEntry): value is Voter {
return !Array.isArray(value);
}
function retrieveStakeOf (api: ApiInterfaceRx): Observable<[AccountId, Balance][]> {
return (api.query.electionsPhragmen || api.query.elections).stakeOf.entries<Balance, [AccountId]>().pipe(
function retrieveStakeOf (elections: QueryableModuleStorage<'rxjs'>): Observable<[AccountId, Balance][]> {
return elections.stakeOf.entries<Balance, [AccountId]>().pipe(
map((entries) =>
entries.map(([{ args: [accountId] }, stake]) => [accountId, stake])
)
);
}
function retrieveVoteOf (api: ApiInterfaceRx): Observable<[AccountId, AccountId[]][]> {
return (api.query.electionsPhragmen || api.query.elections).votesOf.entries<Vec<AccountId>, [AccountId]>().pipe(
function retrieveVoteOf (elections: QueryableModuleStorage<'rxjs'>): Observable<[AccountId, AccountId[]][]> {
return elections.votesOf.entries<Vec<AccountId>, [AccountId]>().pipe(
map((entries) =>
entries.map(([{ args: [accountId] }, votes]) => [accountId, votes])
)
);
}
function retrievePrev (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
return combineLatest([retrieveStakeOf(api), retrieveVoteOf(api)]).pipe(
function retrievePrev (api: ApiInterfaceRx, elections: QueryableModuleStorage<'rxjs'>): Observable<DeriveCouncilVotes> {
return combineLatest([
retrieveStakeOf(elections),
retrieveVoteOf(elections)
]).pipe(
map(([stakes, votes]): DeriveCouncilVotes => {
const result: DeriveCouncilVotes = [];
@@ -60,9 +62,7 @@ function retrievePrev (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
);
}
function retrieveCurrent (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
const elections = (api.query.electionsPhragmen || api.query.elections);
function retrieveCurrent (elections: QueryableModuleStorage<'rxjs'>): Observable<DeriveCouncilVotes> {
return elections.voting.entries<VoteEntry, [AccountId]>().pipe(
map((entries): DeriveCouncilVotes =>
entries.map(([{ args: [accountId] }, value]): [AccountId, DeriveCouncilVote] => [
@@ -76,9 +76,13 @@ function retrieveCurrent (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
}
export function votes (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveCouncilVotes> {
const elections = api.query.phragmenElection || api.query.electionsPhragmen || api.query.elections;
return memo(instanceId, (): Observable<DeriveCouncilVotes> =>
(api.query.electionsPhragmen || api.query.elections).stakeOf
? retrievePrev(api)
: retrieveCurrent(api)
elections
? elections.stakeOf
? retrievePrev(api, elections)
: retrieveCurrent(elections)
: of([])
);
}
+2 -2
View File
@@ -1,12 +1,12 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AccountId } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveCouncilVote } from '../types';
import { map } from '@polkadot/x-rxjs/operators';
import { map } from 'rxjs';
import { memo } from '../util';
@@ -0,0 +1,37 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option } from '@polkadot/types';
import type { FundInfo, ParaId } from '@polkadot/types/interfaces';
import { map } from 'rxjs';
import { u8aConcat, u8aToHex } from '@polkadot/util';
import { blake2AsU8a } from '@polkadot/util-crypto';
import { memo } from '../util';
function createChildKey ({ trieIndex }: FundInfo): string {
return u8aToHex(
u8aConcat(
':child_storage:default:',
blake2AsU8a(
u8aConcat('crowdloan', trieIndex.toU8a())
)
)
);
}
export function childKey (instanceId: string, api: ApiInterfaceRx): (paraId: string | number | ParaId) => Observable<string | null> {
return memo(instanceId, (paraId: string | number | ParaId): Observable<string | null> =>
api.query.crowdloan.funds<Option<FundInfo>>(paraId).pipe(
map((optInfo) =>
optInfo.isSome
? createChildKey(optInfo.unwrap())
: null
)
)
);
}
@@ -0,0 +1,135 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { StorageKey } from '@polkadot/types';
import type { ParaId } from '@polkadot/types/interfaces';
import type { DeriveContributions } from '../types';
import { BehaviorSubject, combineLatest, EMPTY, map, of, startWith, switchMap, tap, toArray } from 'rxjs';
import { arrayFlatten, isFunction } from '@polkadot/util';
import { memo } from '../util';
import { extractContributed } from './util';
interface Changes {
added: string[];
blockHash: string;
removed: string[];
}
const PAGE_SIZE_K = 1000; // limit aligned with the 1k on the node (trie lookups are heavy)
function _getUpdates (api: ApiInterfaceRx, paraId: string | number | ParaId): Observable<Changes> {
let added: string[] = [];
let removed: string[] = [];
return api.query.system.events().pipe(
switchMap((events): Observable<Changes> => {
const changes = extractContributed(paraId, events);
if (changes.added.length || changes.removed.length) {
added = added.concat(...changes.added);
removed = removed.concat(...changes.removed);
return of({ added, addedDelta: changes.added, blockHash: events.createdAtHash?.toHex() || '-', removed, removedDelta: changes.removed });
}
return EMPTY;
}),
startWith({ added, addedDelta: [], blockHash: '-', removed, removedDelta: [] })
);
}
function _eventTriggerAll (api: ApiInterfaceRx, paraId: string | number | ParaId): Observable<string> {
return api.query.system.events().pipe(
switchMap((events): Observable<string> => {
const items = events.filter(({ event: { data: [eventParaId], method, section } }) =>
section === 'crowdloan' &&
['AllRefunded', 'Dissolved', 'PartiallyRefunded'].includes(method) &&
eventParaId.eq(paraId)
);
return items.length
? of(events.createdAtHash?.toHex() || '-')
: EMPTY;
}),
startWith('-')
);
}
function _getKeysPaged (api: ApiInterfaceRx, childKey: string): Observable<StorageKey[]> {
const startSubject = new BehaviorSubject<string | undefined>(undefined);
return startSubject.pipe(
switchMap((startKey) =>
api.rpc.childstate.getKeysPaged(childKey, '0x', PAGE_SIZE_K, startKey)
),
tap((keys): void => {
setTimeout((): void => {
keys.length === PAGE_SIZE_K
? startSubject.next(keys[PAGE_SIZE_K - 1].toHex())
: startSubject.complete();
}, 0);
}),
toArray(), // toArray since we want to startSubject to be completed
map((keyArr: StorageKey[][]) => arrayFlatten(keyArr))
);
}
function _getAll (api: ApiInterfaceRx, paraId: string | number | ParaId, childKey: string): Observable<string[]> {
return _eventTriggerAll(api, paraId).pipe(
switchMap(() =>
// FIXME Needs testing and being enabled
// eslint-disable-next-line no-constant-condition
isFunction(api.rpc.childstate.getKeysPaged) && false
? _getKeysPaged(api, childKey)
: api.rpc.childstate.getKeys(childKey, '0x')
),
map((keys) =>
keys.map((k) => k.toHex())
)
);
}
function _contributions (api: ApiInterfaceRx, paraId: string | number | ParaId, childKey: string): Observable<DeriveContributions> {
return combineLatest([
_getAll(api, paraId, childKey),
_getUpdates(api, paraId)
]).pipe(
map(([keys, { added, blockHash, removed }]): DeriveContributions => {
const contributorsMap: Record<string, boolean> = {};
keys.forEach((k): void => {
contributorsMap[k] = true;
});
added.forEach((k): void => {
contributorsMap[k] = true;
});
removed.forEach((k): void => {
delete contributorsMap[k];
});
return {
blockHash,
contributorsHex: Object.keys(contributorsMap)
};
})
);
}
export function contributions (instanceId: string, api: ApiInterfaceRx): (paraId: string | number | ParaId) => Observable<DeriveContributions> {
return memo(instanceId, (paraId: string | number | ParaId): Observable<DeriveContributions> =>
api.derive.crowdloan.childKey(paraId).pipe(
switchMap((childKey) =>
childKey
? _contributions(api, paraId, childKey)
: of({ blockHash: '-', contributorsHex: [] })
)
)
);
}
@@ -0,0 +1,6 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './childKey';
export * from './contributions';
export * from './onwContributions';
@@ -0,0 +1,72 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { ParaId } from '@polkadot/types/interfaces';
import type { DeriveOwnContributions } from '../types';
import { combineLatest, EMPTY, map, of, startWith, switchMap } from 'rxjs';
import { memo } from '../util';
import { extractContributed } from './util';
function _getValues (api: ApiInterfaceRx, childKey: string, keys: string[]): Observable<DeriveOwnContributions> {
// We actually would love to use multi-keys https://github.com/paritytech/substrate/issues/9203
return combineLatest(keys.map((k) => api.rpc.childstate.getStorage(childKey, k))).pipe(
map((values) =>
values
.map((v) => api.registry.createType('Option<StorageData>', v))
.map((o) =>
o.isSome
? api.registry.createType('Balance', o.unwrap())
: api.registry.createType('Balance')
)
.reduce((all: DeriveOwnContributions, b, index): DeriveOwnContributions => ({
...all,
[keys[index]]: b
}), {})
)
);
}
function _watchOwnChanges (api: ApiInterfaceRx, paraId: string | number | ParaId, childkey: string, keys: string[]): Observable<DeriveOwnContributions> {
return api.query.system.events().pipe(
switchMap((events): Observable<DeriveOwnContributions> => {
const changes = extractContributed(paraId, events);
const filtered = keys.filter((k) =>
changes.added.includes(k) ||
changes.removed.includes(k)
);
return filtered.length
? _getValues(api, childkey, filtered)
: EMPTY;
}),
startWith({})
);
}
function _contributions (api: ApiInterfaceRx, paraId: string | number | ParaId, childKey: string, keys: string[]): Observable<DeriveOwnContributions> {
return combineLatest([
_getValues(api, childKey, keys),
_watchOwnChanges(api, paraId, childKey, keys)
]).pipe(
map(([all, latest]) => ({
...all,
...latest
}))
);
}
export function ownContributions (instanceId: string, api: ApiInterfaceRx): (paraId: string | number | ParaId, keys: string[]) => Observable<DeriveOwnContributions> {
return memo(instanceId, (paraId: string | number | ParaId, keys: string[]): Observable<DeriveOwnContributions> =>
api.derive.crowdloan.childKey(paraId).pipe(
switchMap((childKey) =>
childKey && keys.length
? _contributions(api, paraId, childKey, keys)
: of({})
)
)
);
}
@@ -0,0 +1,11 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Balance } from '@polkadot/types/interfaces';
export interface DeriveContributions {
blockHash: string;
contributorsHex: string[];
}
export type DeriveOwnContributions = Record<string, Balance>;
+32
View File
@@ -0,0 +1,32 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Vec } from '@polkadot/types';
import type { EventRecord, ParaId } from '@polkadot/types/interfaces';
interface Changes {
added: string[];
blockHash: string;
removed: string[];
}
export function extractContributed (paraId: string | number | ParaId, events: Vec<EventRecord>): Changes {
const added: string[] = [];
const removed: string[] = [];
return events
.filter(({ event: { data: [, eventParaId], method, section } }) =>
section === 'crowdloan' &&
['Contributed', 'Withdrew'].includes(method) &&
eventParaId.eq(paraId)
)
.reduce((result: Changes, { event: { data: [accountId], method } }): Changes => {
if (method === 'Contributed') {
result.added.push(accountId.toHex());
} else {
result.removed.push(accountId.toHex());
}
return result;
}, { added, blockHash: events.createdAtHash?.toHex() || '-', removed });
}
@@ -1,16 +1,16 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option, u64, Vec } from '@polkadot/types';
import type { BlockNumber, Hash, ReferendumIndex, Scheduled } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveDispatch, DeriveProposalImage } from '../types';
import { catchError, combineLatest, map, of, switchMap } from 'rxjs';
import { isFunction, stringToHex } from '@polkadot/util';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
@@ -42,7 +42,7 @@ function queryQueue (api: ApiInterfaceRx): Observable<DeriveDispatch[]> {
);
}
function schedulerEntries (api: ApiInterfaceRx): Observable<[BlockNumber[], Option<Scheduled>[][]]> {
function schedulerEntries (api: ApiInterfaceRx): Observable<[BlockNumber[], (Option<Scheduled>[] | null)[]]> {
// 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
@@ -53,10 +53,20 @@ function schedulerEntries (api: ApiInterfaceRx): Observable<[BlockNumber[], Opti
switchMap((keys) => {
const blockNumbers = keys.map(({ args: [blockNumber] }) => blockNumber);
return combineLatest([
of(blockNumbers),
api.query.scheduler.agenda.multi<Vec<Option<Scheduled>>>(blockNumbers)
]);
return blockNumbers.length
? combineLatest([
of(blockNumbers),
// this should simply be api.query.scheduler.agenda.multi<Vec<Option<Scheduled>>>,
// however we have had cases on Darwinia where the indices have moved around after an
// upgrade, which results in invalid on-chain data
combineLatest(blockNumbers.map((blockNumber) =>
api.query.scheduler.agenda<Vec<Option<Scheduled>>>(blockNumber).pipe(
// this does create an issue since it discards all at that block
catchError(() => of(null))
)
))
])
: of<[BlockNumber[], null[]]>([[], []]);
})
);
}
@@ -67,26 +77,30 @@ function queryScheduler (api: ApiInterfaceRx): Observable<DeriveDispatch[]> {
const result: SchedulerInfo[] = [];
blockNumbers.forEach((at, index): void => {
agendas[index].filter((optScheduled) => optScheduled.isSome).forEach((optScheduled): void => {
const scheduled = optScheduled.unwrap();
(agendas[index] || [])
.filter((opt) => opt.isSome)
.forEach((optScheduled): void => {
const scheduled = optScheduled.unwrap();
if (scheduled.maybeId.isSome) {
const id = scheduled.maybeId.unwrap().toHex();
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;
if (id.startsWith(DEMOCRACY_ID)) {
const [, index] = api.registry.createType<ITuple<[u64, ReferendumIndex]>>('(u64, ReferendumIndex)', id);
const imageHash = scheduled.call.args[0] as Hash;
result.push({ at, imageHash, index });
result.push({ at, imageHash, index });
}
}
}
});
});
});
return combineLatest([
of(result),
api.derive.democracy.preimages(result.map(({ imageHash }) => imageHash))
]);
return result.length
? combineLatest([
of(result),
api.derive.democracy.preimages(result.map(({ imageHash }) => imageHash))
])
: of([[], []]);
}),
map(([infos, images]): DeriveDispatch[] =>
infos.map((info, index) => ({ ...info, image: images[index] }))
+3 -4
View File
@@ -1,17 +1,16 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option } from '@polkadot/types';
import type { AccountId, ReferendumInfo, ReferendumInfoFinished, ReferendumInfoTo239, Vote, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import type { BN } from '@polkadot/util';
import type { DeriveDemocracyLock } from '../types';
import BN from 'bn.js';
import { map, of, switchMap } from 'rxjs';
import { BN_ZERO, isUndefined } from '@polkadot/util';
import { of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
@@ -1,15 +1,14 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option } from '@polkadot/types';
import type { Hash, VoteThreshold } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveProposalExternal } from '../types';
import { of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { map, of, switchMap } from 'rxjs';
import { memo } from '../util';
@@ -1,14 +1,14 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Bytes, Option } from '@polkadot/types';
import type { AccountId, Balance, BlockNumber, Hash } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveProposalImage } from '../types';
import { map } from '@polkadot/x-rxjs/operators';
import { map } from 'rxjs';
import { memo } from '../util';
import { parseImage } from './util';
@@ -1,14 +1,14 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Bytes, Option } from '@polkadot/types';
import type { AccountId, Balance, BlockNumber, Hash } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveProposalImage } from '../types';
import { map } from '@polkadot/x-rxjs/operators';
import { map, of } from 'rxjs';
import { memo } from '../util';
import { parseImage } from './util';
@@ -17,10 +17,12 @@ type PreImage = Option<ITuple<[Bytes, AccountId, Balance, BlockNumber]>>;
export function preimages (instanceId: string, api: ApiInterfaceRx): (hashes: Hash[]) => Observable<(DeriveProposalImage | undefined)[]> {
return memo(instanceId, (hashes: Hash[]): Observable<(DeriveProposalImage | undefined)[]> =>
api.query.democracy.preimages.multi<PreImage>(hashes).pipe(
map((images): (DeriveProposalImage | undefined)[] =>
images.map((imageOpt) => parseImage(api, imageOpt))
hashes.length
? api.query.democracy.preimages.multi<PreImage>(hashes).pipe(
map((images): (DeriveProposalImage | undefined)[] =>
images.map((imageOpt) => parseImage(api, imageOpt))
)
)
)
: of([])
);
}

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