Compare commits

...
476 Commits
Author SHA1 Message Date
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
Github Actions 65688f9e0e [CI Skip] release/stable 4.6.2
skip-checks: true
2021-04-19 10:47:57 +00:00
Jaco 5eb2a95ef2 Correct Kusama/Polkadot runtime 30 session key definitions (#3409)
* Correct Kusama/Polkadot runtime 30 session key definitions

* Remove duplicates
2021-04-19 12:38:48 +02:00
Github Actions 282b39d27a [CI Skip] release/stable 4.6.1
skip-checks: true
2021-04-19 06:07:35 +00:00
Jaco f21e3d317a 4.6.1 (#3407) 2021-04-19 07:56:46 +02:00
Github Actions c2af7cf8f2 [CI Skip] release/beta 4.5.2-8
skip-checks: true
2021-04-18 09:29:51 +00:00
Jaco 0958a4c693 Bump common (#3405)
* Bump common

* Bumps
2021-04-18 11:19:47 +02:00
Github Actions c687181130 [CI Skip] release/beta 4.5.2-7
skip-checks: true
2021-04-16 16:03:07 +00:00
Jaco 685f1ec0b6 Update .123trigger 2021-04-16 17:53:22 +02:00
Jaco e0069b6f7d statemint known-types (#3404) 2021-04-16 17:39:21 +02:00
Github Actions cf48762ff2 [CI Skip] release/beta 4.5.2-6
skip-checks: true
2021-04-15 12:27:19 +00:00
Jaco 31a7545a19 Bump common (#3403) 2021-04-15 14:18:06 +02:00
Github Actions 5cd8e8fb97 [CI Skip] release/beta 4.5.2-5
skip-checks: true
2021-04-14 07:15:18 +00:00
Jaco 96e4090174 Simplify/harden session derives (#3401) 2021-04-14 09:05:35 +02:00
Github Actions 0bbebab90b [CI Skip] release/beta 4.5.2-4
skip-checks: true
2021-04-14 06:26:22 +00:00
Jaco 57dac0ef47 Assert keypair validity in signing operations (#3400) 2021-04-14 08:17:10 +02:00
Github Actions 6c3d24551b [CI Skip] release/beta 4.5.2-3
skip-checks: true
2021-04-13 18:44:11 +00:00
Jaco e7dc6d7a5a Expose internalError on submittables (#3399) 2021-04-13 20:33:59 +02:00
Github Actions a63b7f611e [CI Skip] release/beta 4.5.2-2
skip-checks: true
2021-04-13 10:33:28 +00:00
Jaco 82e15dc36d Explicitly handle isReadyOrError (when only using isReady) (#3395) 2021-04-13 12:24:26 +02:00
Github Actions 6f96037cb5 [CI Skip] release/beta 4.5.2-1
skip-checks: true
2021-04-13 09:08:55 +00:00
Jaco b6da84b8b2 Beefy subscribeJustifications (#3393)
* Beefy subscribeJustifications

* Add payload info

* Update RPC description
2021-04-13 10:59:23 +02:00
Github Actions 41209f074c [CI Skip] release/beta 4.5.2-0
skip-checks: true
2021-04-12 13:17:40 +00:00
Jaco Greeff c47964c942 Updated xcm types (#3391)
* Updated xcm types

* Move NetworkId

* Update DoubleEncodedCall

* trigger

* Xcm is an enum
2021-04-12 15:09:33 +02:00
Github Actions 5f13a634e5 [CI Skip] release/stable 4.5.1
skip-checks: true
2021-04-12 06:30:52 +00:00
Jaco Greeff 40af520fe7 4.5.1 (#3390) 2021-04-12 08:21:37 +02:00
Github Actions 1e506e0f8c [CI Skip] release/beta 4.4.2-7
skip-checks: true
2021-04-11 13:29:10 +00:00
Jaco Greeff 96ea5803d4 Adjust Westend known & detection (#3386) 2021-04-11 15:19:05 +02:00
Jaco Greeff 7d99459f50 Bump deps (#3389) 2021-04-11 15:15:01 +02:00
Github Actions 8fa090f435 [CI Skip] release/beta 4.4.2-6
skip-checks: true
2021-04-09 20:11:40 +00:00
Jaco Greeff d3c60d197c PalletId type 2021-04-09 23:01:11 +03:00
Github Actions ad8550f7f5 [CI Skip] release/beta 4.4.2-5
skip-checks: true
2021-04-09 19:51:56 +00:00
Jaco Greeff a899aa439d Adjust slot types based on constants (#3385) 2021-04-09 21:40:24 +02:00
Github Actions e0e075b350 [CI Skip] release/beta 4.4.2-4
skip-checks: true
2021-04-09 04:48:56 +00:00
Jaco Greeff 34ff14547e Westend runtime 50 upgrade block (& v30 session keys) (#3382)
* Westend runtime 50 upgrade block (& v30 session keys)

* Revery beefy keys

* Defer 7B keys to 51
2021-04-09 06:39:40 +02:00
Github Actions 681a80d456 [CI Skip] release/beta 4.4.2-3
skip-checks: true
2021-04-08 12:17:03 +00:00
Jaco Greeff ed5f2673ce Detect Keys, inject SessionKeys (#3380) 2021-04-08 14:07:39 +02:00
Github Actions 43e87603e2 [CI Skip] release/beta 4.4.2-2
skip-checks: true
2021-04-08 09:02:42 +00:00
Jaco Greeff d056416b47 Bump deps (#3379) 2021-04-08 10:52:20 +02:00
Github Actions 1bcf94131d [CI Skip] release/beta 4.4.2-1
skip-checks: true
2021-04-08 05:45:13 +00:00
Jaco Greeff 17b607b6c3 Update Rococo session key (& small para type cleanups) (#3378) 2021-04-08 08:35:24 +03:00
Github Actions 5a16d1dd8b [CI Skip] release/beta 4.4.2-0
skip-checks: true
2021-04-07 14:18:01 +00:00
Jaco Greeff 144b74306a Update parachain types (#3376)
* Update parachain types

* Remove retiring flag
2021-04-07 16:09:38 +02:00
Jaco Greeff 16b9fa956d Adjust ParaInfo types (#3372) 2021-04-07 15:53:57 +02:00
Github Actions b6af4b9877 [CI Skip] release/stable 4.4.1
skip-checks: true
2021-04-05 11:30:23 +00:00
Jaco Greeff 3f368e721d 4.4 (#3371)
* 4.4

* CHANGELOG
2021-04-05 13:20:18 +02:00
Github Actions 22b4257636 [CI Skip] release/beta 4.3.2-2
skip-checks: true
2021-04-03 06:15:11 +00:00
Jaco Greeff ca7a631032 Add cumulus ServiceQuality type (#3368) 2021-04-03 08:04:42 +02:00
Github Actions da5bbd17af [CI Skip] release/beta 4.3.2-1
skip-checks: true
2021-03-30 09:52:02 +00:00
Jaco Greeff b58f3f5c3e Multilocation update (X5-X8) (#3362) 2021-03-30 11:42:27 +02:00
Github Actions 8c30194f59 [CI Skip] release/beta 4.3.2-0
skip-checks: true
2021-03-30 09:03:06 +00:00
Jaco Greeff dc9ec37490 Add Polkadot 29 upgrade block (#3361) 2021-03-30 10:53:30 +02:00
Github Actions 5175e77eec [CI Skip] release/stable 4.3.1
skip-checks: true
2021-03-29 09:40:47 +00:00
Jaco Greeff 9553c5467c 4.3 (#3359) 2021-03-29 12:30:49 +03:00
Github Actions a1f07e3274 [CI Skip] release/beta 4.2.2-4
skip-checks: true
2021-03-24 11:04:59 +00:00
Jaco Greeff 58deb2eb14 Session index without staking (#3352)
* Session index without staking

* Fix ordering
2021-03-24 11:55:36 +01:00
Github Actions 83caad7f1b [CI Skip] release/beta 4.2.2-3
skip-checks: true
2021-03-24 10:08:26 +00:00
Jaco Greeff 26c3cc9126 Make council optional with treasury proposals (#3351) 2021-03-24 10:58:03 +01:00
Github Actions 1a231dfb0d [CI Skip] release/beta 4.2.2-2
skip-checks: true
2021-03-23 09:48:48 +00:00
Jaco Greeff 712d0425d0 Update ParaInfo types (#3348) 2021-03-23 10:38:28 +01:00
Github Actions eaa5db517f [CI Skip] release/beta 4.2.2-1
skip-checks: true
2021-03-22 16:12:29 +00:00
Jaco Greeff 88c3850d1b Warn on deprecated contracts interfaces (#3346) 2021-03-22 17:03:49 +01:00
Github Actions 943df72ae9 [CI Skip] release/beta 4.2.2-0
skip-checks: true
2021-03-22 15:58:36 +00:00
Veliko 67ab11a036 Abi constructor takes different parameters (#3347)
The Abi constructor used to take the registry as a parameter, now it takes registry.getChainProperties() and this change introduced hard to debug behaviour
2021-03-22 16:48:15 +01:00
Github Actions c87ef7526b [CI Skip] release/stable 4.2.1
skip-checks: true
2021-03-22 08:39:17 +00:00
Jaco Greeff bccf2d52ad 4.2 (#3344) 2021-03-22 09:29:38 +01:00
Github Actions be6dbdd3e4 [CI Skip] release/beta 4.1.2-8
skip-checks: true
2021-03-21 16:37:49 +00:00
Jaco Greeff 3c34ee9897 Bump metadata (#3343) 2021-03-21 17:27:41 +01:00
Github Actions 9ad97813e3 [CI Skip] release/beta 4.1.2-7
skip-checks: true
2021-03-20 17:28:19 +00:00
Jaco Greeff 028f04e47f Optimize society multi-derive (#3342)
* Optimize society multi-derive

* isVoting flag

* isDefenderVoter
2021-03-20 18:18:49 +01:00
Github Actions 4974c9247f [CI Skip] release/beta 4.1.2-6
skip-checks: true
2021-03-20 10:22:42 +00:00
Jaco Greeff 1ffe6a11bf SignedBlock (justifications field) (#3340) 2021-03-20 11:13:56 +01:00
Github Actions 19699ea445 [CI Skip] release/beta 4.1.2-5
skip-checks: true
2021-03-20 09:11:02 +00:00
Jaco Greeff d98ccfb12a Ensure metadata private fields are not accessed (#3341) 2021-03-20 10:01:03 +01:00
Github Actions 41cb056b0f [CI Skip] release/beta 4.1.2-4
skip-checks: true
2021-03-20 08:10:05 +00:00
Jaco Greeff 48bda0bdea Rococo types (detected, now explicit) (#3339)
* Rococo types (detected, now explicit)

* Bumps
2021-03-20 08:59:57 +01:00
Github Actions 1b393c7b67 [CI Skip] release/beta 4.1.2-3
skip-checks: true
2021-03-18 16:17:51 +00:00
Jaco Greeff f52e518b7b Adjust extended derives with as-defined instances (#3336) 2021-03-18 17:08:18 +01:00
Github Actions 08970cff88 [CI Skip] release/beta 4.1.2-2
skip-checks: true
2021-03-17 08:06:55 +00:00
Jaco Greeff 6d38ca6453 Update .123trigger 2021-03-17 08:57:36 +01:00
Github Actions 60db4bc66b [CI Skip] release/beta 4.1.2-1
skip-checks: true
2021-03-16 13:48:13 +00:00
Jaco Greeff 0661237b28 Bump deps (#3326) 2021-03-16 14:38:17 +01:00
Github Actions 6ccac712a8 [CI Skip] release/beta 4.1.2-0
skip-checks: true
2021-03-16 07:41:09 +00:00
Jaco Greeff 3d4877940c Update .123trigger 2021-03-16 08:31:40 +01:00
VelikoandJaco Greeff 70fc95ef27 Fix contractEvents in ContractSubmittableResult (#3324)
* fix the autoaggregation of contract events 

apparently, the system event for contract emitted events has had its name changed

* fix the autoaggregation of contract events

apparently, the system event for contract emitted events has had its name changed

* Update packages/api-contract/src/base/Contract.ts

* Apply suggestions from code review

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
2021-03-15 22:16:35 +01:00
Github Actions 463f65d25c [CI Skip] release/stable 4.1.1
skip-checks: true
2021-03-15 11:51:46 +00:00
Jaco Greeff 09d176c82e 4.1 (#3321) 2021-03-15 12:42:20 +01:00
Github Actions fce96baf3d [CI Skip] release/beta 4.0.4-16
skip-checks: true
2021-03-15 11:18:57 +00:00
Jaco Greeff c6785c533f Use at-block registry/types for derive block/header (#3320)
* Use at-block registry/types for derive block/header

* Also apply to subscribe
2021-03-15 12:08:25 +01:00
Github Actions 64de021149 [CI Skip] release/beta 4.0.4-15
skip-checks: true
2021-03-15 10:13:45 +00:00
Jaco Greeff de9e17a1a0 Add Mmr RPCs (#3318)
* Add Mmr RPCs

* blockHash
2021-03-15 11:03:18 +01:00
Github Actions 987bccea2e [CI Skip] release/beta 4.0.4-14
skip-checks: true
2021-03-15 09:46:29 +00:00
Jaco GreeffandXiliang Chen 1434b86b8f Update to latest Substrate metadata (#3316)
* Update to latest Substrate metadata

* Update contract Schedule

* Update CHANGELOG.md

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

* CHANGELOG

* Updates

Co-authored-by: Xiliang Chen <xlchen1291@gmail.com>
2021-03-15 10:36:05 +01:00
Github Actions a398b2201f [CI Skip] release/beta 4.0.4-13
skip-checks: true
2021-03-15 08:44:13 +00:00
Jaco Greeff f015837c38 Allow ConsensusEngineId toString with non-ascii (#3315)
* Allow ConsensusEngineId toString with non-ascii

* Add number test
2021-03-15 09:34:16 +01:00
Github Actions 5b51588995 [CI Skip] release/beta 4.0.4-12
skip-checks: true
2021-03-12 15:31:59 +00:00
Jaco Greeff 7383e521e5 Kusama 2029 upgrade block (#3310) 2021-03-12 16:23:41 +01:00
Github Actions b10f05786c [CI Skip] release/beta 4.0.4-11
skip-checks: true
2021-03-11 13:03:32 +00:00
Jaco Greeff a212351528 Re-add old slot types (#3305) 2021-03-11 13:55:11 +01:00
Github Actions 55c01af260 [CI Skip] release/beta 4.0.4-10
skip-checks: true
2021-03-11 07:49:11 +00:00
Jaco Greeff 1cf6ffad2b Updata HostConfig for parachains (#3302) 2021-03-11 08:39:24 +01:00
Github Actions 00d0ab9de1 [CI Skip] release/beta 4.0.4-9
skip-checks: true
2021-03-10 21:27:04 +00:00
Jaco Greeff b38e60a9a7 ValidatorIndex for shared 2021-03-10 22:17:30 +01:00
Github Actions 29f7e46439 [CI Skip] release/beta 4.0.4-8
skip-checks: true
2021-03-10 21:10:51 +00:00
Jaco Greeff fa0add8564 Adjust to new auction types (#3297)
* Adjust to new auction types

* Update BitVec fields, Babe types
2021-03-10 22:00:57 +01:00
Github Actions 5bec38c404 [CI Skip] release/beta 4.0.4-7
skip-checks: true
2021-03-10 16:33:36 +00:00
Jaco Greeff 43b66b6507 Remove createBlueprint (use createContract) (#3300) 2021-03-10 17:24:59 +01:00
Github Actions 7e370b3a23 [CI Skip] release/beta 4.0.4-6
skip-checks: true
2021-03-10 16:06:13 +00:00
Jaco Greeff 2b270a3c9f Fix author extraction (both POW & BABE) (#3299)
* Fix author extaction for Babeb session-end

* Fix extraction from Seal
2021-03-10 16:55:59 +01:00
Github Actions cf0d9a2d3f [CI Skip] release/beta 4.0.4-5
skip-checks: true
2021-03-09 15:49:41 +00:00
Jaco Greeff 5d70622819 Extend signer payload with any additional extension fields (#3269)
* Extend payload with additional fields

* Extras

* Adjust
2021-03-09 16:38:33 +01:00
Github Actions fcebdb6d6f [CI Skip] release/beta 4.0.4-4
skip-checks: true
2021-03-09 15:28:51 +00:00
Jaco Greeff 3d020b5159 Check types against fallbacks (#3293)
* Check types against fallbacks

* Only enable fallback check for latest
2021-03-09 16:17:49 +01:00
Github Actions 530d1bcd03 [CI Skip] release/beta 4.0.4-3
skip-checks: true
2021-03-09 14:48:18 +00:00
Jaco Greeff a4151c2941 Adjust for latest types (#3291) 2021-03-09 15:40:06 +01:00
Github Actions a801d30fb6 [CI Skip] release/beta 4.0.4-2
skip-checks: true
2021-03-09 10:00:17 +00:00
Jaco Greeff 1fe9b605dd Bump substrate metadata (#3289) 2021-03-09 10:49:42 +01:00
Github Actions ecfd822d94 [CI Skip] release/beta 4.0.4-1
skip-checks: true
2021-03-09 09:30:33 +00:00
Jaco Greeff a5e4d68993 Remove jest confix for rxjs (#3288) 2021-03-09 10:20:26 +01:00
Github Actions ca5c002d37 [CI Skip] release/beta 4.0.4-0
skip-checks: true
2021-03-09 08:27:13 +00:00
Jaco Greeff 6e28760da4 Remove explicit RpcCore interface (apply in API itself) (#3284)
* Remove explicit RpcCore interface (apply in API itself)

* Simplify

* Adjust test linting

* casting

* Remove stray eslint

* Re-add enable
2021-03-09 09:17:30 +01:00
Github Actions a253c4edb5 [CI Skip] release/stable 4.0.3
skip-checks: true
2021-03-08 21:20:51 +00:00
Jaco Greeff 7c96525d35 4.0.3 (#3287) 2021-03-08 22:11:42 +01:00
Zeke MostovandJaco Greeff 3f0457efc2 fix: Allow sudo for polkadot indexed proxy enum (#3286)
* fix: Allow sudo for polkadot indexed proxy enum

* Update packages/types-known/src/spec/polkadot.ts

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
2021-03-08 22:00:35 +01:00
342 changed files with 29884 additions and 7659 deletions
+7 -3
View File
@@ -1,4 +1,4 @@
26
31
1.4.2
1.6.2
1.11.2
@@ -17,5 +17,9 @@
3.9.2
3.9.3
3.10.2
4.0.2
4.0.2
4.0.3
4.6.2
4.7.2
4.9.2
4.11.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
+591
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.0-rc.2.cjs
+340
View File
@@ -1,5 +1,345 @@
# CHANGELOG
## 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. Recommended for users of Kusama/Polkadot.
Changes:
- Correct Kusama/Polkadot runtime 30 session key definitions
## 4.6.1 Apr 19, 2021
Upgrade priority: Low. Recommended if used in a Node.js 15.x environment.
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 support for `rpc.beefy.subscribeJustifications`
- Update Xcm types
- Explicitly handle `isReadyOrError` with `Api.create`
- Add Kusama upgrade block for 2030
## 4.5.1 Apr 12, 2021
Upgrade priority: Low. Recommended with usage with the Rococo testnet.
Changes:
- Update parachain types as per latest Polkadot
- Cater for `Keys` with `BEEFY` session keys
- Update `Keys` injection to allow for on-chain type detection
- Add `Westend` known upgrade block for runtime 50
- Align types with latest Substrate master
- Adjust keepalive `system_health` timer
## 4.4.1 Apr 5, 2021
Upgrade priority: Low. Recommended with usage with the Rococo testnet.
Changes:
- Add `ServiceQuality` type for Cumulus
- Adjust XCM MultiLocation type (X5 to X8 junctions)
- Add Polkadot 29 upgrade block
## 4.3.1 Mar 29, 2021
Upgrade priority: Low.
Contributed:
- Fix documentation on ABI parameters (Thanks to https://github.com/vminkov)
Changes:
- Warn on usage of deprecated contract interfaces
- Update `ParaInfo` type
- Council should be optional in treasury derives
- Allow extraction of session derives indexes with no staking
## 4.2.1 Mar 22, 2021
Upgrade priority: Low. Recommended when tracking the latest updates from Substrate.
Contributed:
- Fix contract even decoding on Substrate 3 (Thanks to https://github.com/vminkov)
Changes:
- Adjust `Extender{Header, SignedBlock}` types to ensure at-block `Header` types are used
- Explicit definition for new Rococo triple refcount `AccountData` types
- Convert metadata private class fields to ES-private
- Adjust `SignedBlock` type for new `justifications` field
- Optimize society derive for multi accounts
- Bump metadata to latest substrate version
## 4.1.1 Mar 15, 2021
Upgrade priority: Low. Recommended when tracking the latest updates from Substrate.
Changes:
- Fix author extraction for last block in a session
- Expand `SignerPayload` to inject/expose custom signed extensions
- `ConsensusEngineId` formats non-Ascii engines correctly
- Allow `getBlock/Header` derives to use as-at registry (instead of latest)
- Cleanup `RpcCore` augmentation (removing TS warnings on typegen chains)
- Add upgrade block for Kusama 2029
- Ensure that type alias overrides also apply to map keys
- Check type generation against fallbacks (build-time only sanity check)
- Add `mmr_generateProof` RPC
- Align types with latest substrate master
- Apply latest Polkadot auctions/crowdloan/parachains/slots types
## 4.0.3 Mar 8, 2021
Upgrade priority: Low. Recommended if you use the API to sync the full chain, most notably Polkadot.
Contributed:
- Re-add unused historical `SudoBalances` to `ProxyType` (Thanks to https://github.com/emostov)
## 4.0.2 Mar 8, 2021
Upgrade priority: High. Required if you are using 4.0.1 in a Node.js environment.
+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
+5 -3
View File
@@ -3,7 +3,8 @@
const config = require('@polkadot/dev/config/jest.cjs');
module.exports = Object.assign({}, config, {
module.exports = {
...config,
moduleNameMapper: {
'@polkadot/api-(contract|derive)(.*)$': '<rootDir>/packages/api-$1/src/$2',
// eslint-disable-next-line sort-keys
@@ -26,5 +27,6 @@ module.exports = Object.assign({}, config, {
'<rootDir>/packages/types/build',
'<rootDir>/packages/types-known/build'
],
transformIgnorePatterns: ['/node_modules/(?!@polkadot|@babel/runtime/helpers/esm/|rxjs/_esm5)']
});
testTimeout: 10000,
transformIgnorePatterns: ['/node_modules/(?!@polkadot|@babel/runtime/helpers/esm/)']
};
+10 -10
View File
@@ -8,7 +8,7 @@
"packages/*"
],
"resolutions": {
"typescript": "^4.2.3"
"typescript": "^4.3.4"
},
"scripts": {
"build": "yarn build:interfaces && polkadot-dev-build-ts",
@@ -20,19 +20,19 @@
"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.8",
"@babel/register": "^7.13.8",
"@babel/runtime": "^7.13.9",
"@polkadot/dev": "^0.62.5",
"@polkadot/ts": "^0.3.61",
"@babel/core": "^7.14.6",
"@babel/register": "^7.14.5",
"@babel/runtime": "^7.14.6",
"@polkadot/dev": "^0.62.43",
"@polkadot/ts": "^0.4.1",
"@polkadot/typegen": "workspace:packages/typegen",
"@types/jest": "^26.0.20",
"@types/jest": "^26.0.23",
"copyfiles": "^2.4.1"
},
"version": "4.0.2"
"version": "4.16.1"
}
+1 -1
View File
@@ -8,7 +8,7 @@ import { Abi } from '@polkadot/api-contract';
const wsProvider = new WsProvider(<...Node Url...>);
const api = await ApiPromise.create({ provider: wsProvider });
const abi = new Abi(api.registry, <...JSON ABI...>);
const abi = new Abi(<...JSON ABI...>, api.registry.getChainProperties());
api.tx.contracts
.call(<contract addr>, <value>, <max gas>, abi.messages.<method name>(<...params...>))
+9 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-contract",
"version": "4.0.2",
"version": "4.16.1",
"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.9",
"@polkadot/api": "4.0.2",
"@polkadot/types": "4.0.2",
"@polkadot/util": "^6.0.5",
"@polkadot/x-rxjs": "^6.0.5",
"bn.js": "^4.11.9"
"@babel/runtime": "^7.14.6",
"@polkadot/api": "4.16.1",
"@polkadot/types": "4.16.1",
"@polkadot/util": "^6.10.1",
"@polkadot/x-rxjs": "^6.10.1"
}
}
+16 -17
View File
@@ -6,12 +6,10 @@ import type { ChainProperties, ContractConstructorSpec, ContractEventSpec, Contr
import type { AnyJson, Codec, CodecArg } from '@polkadot/types/types';
import type { AbiConstructor, AbiEvent, AbiMessage, AbiParam, DecodedEvent, DecodedMessage } from './types';
import { assert, assertReturn, compactAddLength, compactStripLength, isNumber, isObject, isString, logger, stringCamelCase, u8aConcat, u8aToHex } from '@polkadot/util';
import { 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('SiLookupTypeId', 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: CodecArg[]) =>
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: CodecArg[]): 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())
)
);
}
+56 -56
View File
@@ -14,8 +14,8 @@ interface PartialTypeSpec {
}
// convert the offset into project-specific, index-1
export function getRegistryOffset (id: SiLookupTypeId): number {
return id.toNumber() - 1;
export function getRegistryOffset (id: SiLookupTypeId, typeOffset: number): number {
return id.toNumber() - typeOffset;
}
const PRIMITIVE_ALIAS: Record<string, keyof InterfaceTypes> = {
@@ -28,11 +28,18 @@ const PRIMITIVE_ALWAYS = ['AccountId', 'AccountIndex', 'Address', 'Balance'];
export class MetaRegistry extends TypeRegistry {
public readonly metaTypeDefs: TypeDef[] = [];
public readonly typeOffset;
#siTypes: SiType[] = [];
constructor (chainProperties?: ChainProperties) {
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);
}
@@ -43,7 +50,7 @@ export class MetaRegistry extends TypeRegistry {
}
public getMetaTypeDef (typeSpec: PartialTypeSpec): TypeDef {
const offset = getRegistryOffset(typeSpec.type);
const offset = getRegistryOffset(typeSpec.type, this.typeOffset);
let typeDef = this.metaTypeDefs[offset];
if (!typeDef) {
@@ -78,19 +85,22 @@ export class MetaRegistry extends TypeRegistry {
}
#getMetaType = (id: SiLookupTypeId): SiType => {
const type = this.#siTypes[getRegistryOffset(id)];
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);
}
#extract = (type: SiType, id: SiLookupTypeId): 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);
@@ -116,7 +126,7 @@ export class MetaRegistry extends TypeRegistry {
: {}
),
...(path.length > 1
? { namespace: path.map((segment) => segment.toString()).join('::') }
? { namespace: path.map((s) => s.toString()).join('::') }
: {}
),
...(type.params.length > 0
@@ -128,7 +138,7 @@ 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');
assert(!length || length.toNumber() <= 256, 'MetaRegistry: Only support for [Type; <length>], where length <= 256');
return {
info: TypeDefInfo.VecFixed,
@@ -144,27 +154,25 @@ export class MetaRegistry extends TypeRegistry {
]),
[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 => {
@@ -184,7 +192,7 @@ export class MetaRegistry extends TypeRegistry {
}
#extractSequence = ({ type }: SiTypeDefSequence, id: SiLookupTypeId): Omit<TypeDef, 'type'> => {
assert(!!type, `ContractRegistry: Invalid sequence type found at id ${id.toString()}`);
assert(!!type, () => `ContractRegistry: Invalid sequence type found at id ${id.toString()}`);
return {
info: TypeDefInfo.Vec,
@@ -205,32 +213,28 @@ export class MetaRegistry extends TypeRegistry {
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 }) => ({
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.#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');
}
}
+19 -29
View File
@@ -6,17 +6,17 @@ import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import type { AccountId, EventRecord, Hash } from '@polkadot/types/interfaces';
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
import type { AbiConstructor, BlueprintOptions } from '../types';
import type { 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: CodecArg[]): 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)
))
);
}
}
+24 -67
View File
@@ -3,22 +3,21 @@
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import type { EventRecord, Hash } from '@polkadot/types/interfaces';
import type { EventRecord } from '@polkadot/types/interfaces';
import type { AnyJson, CodecArg, 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, 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';
import { createBluePrintTx, encodeSalt } from './util';
export class CodeSubmittableResult<ApiType extends ApiTypes> extends SubmittableResult {
public readonly blueprint?: Blueprint<ApiType>;
@@ -47,77 +46,35 @@ 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));
}
});
}
/**
* @description Deploy the code bundle, creating a Blueprint.
* @deprecated Use the `code.tx.<constructor>(...) format to put code and deploy
*/
public createBlueprint (): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> {
return this.api.tx.contracts
.putCode(compactAddLength(this.code))
.withResultTransform((result: ISubmittableResult) =>
new CodeSubmittableResult(result, applyOnEvent(result, ['CodeStored'], ([record]: EventRecord[]) =>
new Blueprint<ApiType>(this.api, this.abi, record.event.data[0] as Hash, this._decorateMethod)
))
);
}
/**
* @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>> {
return this.#instantiate(constructorOrId, options, params);
}
public get tx (): MapConstructorExec<ApiType> {
return this.#tx;
}
#instantiate = (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
return isFunction(this.api.tx.contracts.instantiateWithCode)
? this.#instantiateSingle(constructorOrId, options, params)
: this.#instantiateBatch(constructorOrId, options, params);
}
#instantiateSingle = (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: CodecArg[]): 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);
}
#instantiateBatch = (constructorOrId: AbiConstructor | string | number, { gasLimit = 0, salt, value = 0 }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<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 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],
[])
) || []))
);
}
}
+42 -86
View File
@@ -4,25 +4,25 @@
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, CodecArg, 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 BN from 'bn.js';
import type { ContractCallResult, ContractCallSend, ContractQuery, ContractTx, MapMessageQuery, MapMessageTx } from './types';
import { SubmittableResult } from '@polkadot/api';
import { ApiBase } from '@polkadot/api/base';
import { assert, bnToBn, isFunction, isUndefined, logger, stringCamelCase } from '@polkadot/util';
import { createTypeUnsafe } from '@polkadot/types';
import { assert, BN, BN_HUNDRED, BN_ONE, BN_ZERO, bnToBn, isFunction, isUndefined, logger } from '@polkadot/util';
import { map } from '@polkadot/x-rxjs/operators';
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> {
@@ -39,13 +39,6 @@ function createTx <ApiType extends ApiTypes> (fn: (options: ContractOptions, par
: fn(...extractOptions(options, params));
}
function createWithId <T> (fn: (messageOrId: AbiMessage | string | number, options: ContractOptions, params: CodecArg[]) => T): ContractGeneric<ContractOptions, T> {
return (messageOrId: AbiMessage | string | number, options: BigInt | string | number | BN | ContractOptions, ...params: CodecArg[]): T =>
isOptions(options)
? fn(messageOrId, options, params)
: fn(messageOrId, ...extractOptions(options, params));
}
export class ContractSubmittableResult extends SubmittableResult {
public readonly contractEvents?: DecodedEvent[];
@@ -56,51 +49,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> = {};
@@ -109,18 +63,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);
this.read = createWithId(this.#read);
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));
}
});
}
@@ -142,21 +92,27 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
#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: CodecArg[]): 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) =>
new ContractSubmittableResult(result, applyOnEvent(result, ['ContractExecution'], (records: EventRecord[]) =>
// ContractEmitted is the current generation, ContractExecution is the previous generation
new ContractSubmittableResult(result, applyOnEvent(result, ['ContractEmitted', 'ContractExecution'], (records: EventRecord[]) =>
records
.map(({ event: { data: [, data] } }): DecodedEvent | null => {
try {
@@ -172,7 +128,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: CodecArg[]): ContractCallSend<ApiType> => {
assert(this.hasRpcContractsCall, ERROR_NO_CALL);
const message = this.abi.findMessage(messageOrId);
@@ -180,24 +136,24 @@ 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, result }): ContractCallOutcome => ({
debugMessage,
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');
}
}
}
+2 -2
View File
@@ -1,11 +1,11 @@
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type BN from 'bn.js';
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import type { ApiTypes, ObsInnerType } from '@polkadot/api/types';
import type { AccountId } from '@polkadot/types/interfaces';
import type { CodecArg } from '@polkadot/types/types';
import type { BN } from '@polkadot/util';
import type { Observable } from '@polkadot/x-rxjs';
import type { AbiMessage, BlueprintOptions, ContractCallOutcome, ContractOptions } from '../types';
@@ -30,7 +30,7 @@ export interface ContractGeneric<O, 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> {
+1 -2
View File
@@ -5,11 +5,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';
@@ -30,14 +30,12 @@ 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> {
const api = await ApiPromise.create();
const api = await ApiPromise.create({
hasher: (data: Uint8Array): Uint8Array => data
});
const pairs = createTestPairs();
// eslint-disable-next-line @typescript-eslint/no-floating-promises
+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.0.2' };
export const packageInfo = { name: '@polkadot/api-contract', version: '4.16.1' };
+3 -2
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 { 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: CodecArg[]) => Uint8Array;
}
export type AbiConstructor = AbiMessage;
+3 -10
View File
@@ -2,24 +2,17 @@
// 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 { CodecArg } 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' | 'ContractExecution' | 'Instantiated';
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);
+13 -11
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-derive",
"version": "4.0.2",
"version": "4.16.1",
"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.9",
"@polkadot/api": "4.0.2",
"@polkadot/rpc-core": "4.0.2",
"@polkadot/types": "4.0.2",
"@polkadot/util": "^6.0.5",
"@polkadot/util-crypto": "^6.0.5",
"@polkadot/x-rxjs": "^6.0.5",
"bn.js": "^4.11.9"
"@babel/runtime": "^7.14.6",
"@polkadot/api": "4.16.1",
"@polkadot/rpc-core": "4.16.1",
"@polkadot/types": "4.16.1",
"@polkadot/util": "^6.10.1",
"@polkadot/util-crypto": "^6.10.1",
"@polkadot/x-rxjs": "^6.10.1"
},
"devDependencies": {
"@polkadot/keyring": "^6.0.5",
"@polkadot/rpc-provider": "4.0.2"
"@polkadot/keyring": "^6.10.1",
"@polkadot/rpc-provider": "4.16.1"
}
}
+5 -1
View File
@@ -41,7 +41,11 @@ 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>([
address && api.query[councilSection]?.members
+45 -16
View File
@@ -23,13 +23,19 @@ 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
};
}
@@ -55,7 +61,16 @@ 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 querySystemNonce (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
return api.query.system.accountNonce<Index>(accountId).pipe(
map((accountNonce): Result => [
accountNonce,
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
])
);
}
@@ -71,6 +86,7 @@ function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId, module
const extract = (data: AccountData[]) =>
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 isFunction(api.query.system.account)
? api.queryMulti<[AccountInfo, ...(AccountData[])]>([[api.query.system.account, accountId], ...balances]).pipe(
map(([{ nonce }, ...balances]): Result => [nonce, extract(balances)])
@@ -80,16 +96,27 @@ function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId, module
);
}
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
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]]
];
})
@@ -113,6 +140,10 @@ function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Re
*/
export function account (instanceId: string, api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAccount> {
const balanceInstances = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), 'balances');
const empty: Result = [
api.registry.createType('Index'),
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
];
return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAccount> =>
api.derive.accounts.accountId(address).pipe(
@@ -122,19 +153,17 @@ 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)
: isFunction(api.query.system?.accountNonce)
? querySystemNonce(api, accountId)
: of(empty)
])
: of([api.registry.createType('AccountId'), empty])
)
),
map((result): DeriveBalancesAccount => calcBalances(api, result))
+3 -5
View File
@@ -7,9 +7,7 @@ import type { AccountId, AccountIndex, Address, Balance, BalanceLock, BalanceLoc
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveBalancesAccount, DeriveBalancesAccountData, DeriveBalancesAll, DeriveBalancesAllAccountData } from '../types';
import BN from 'bn.js';
import { bnMax, isFunction } from '@polkadot/util';
import { BN, bnMax, isFunction } from '@polkadot/util';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
@@ -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)));
+6 -2
View File
@@ -37,12 +37,16 @@ export function bounties (instanceId: string, api: ApiInterfaceRx): () => Observ
return memo(instanceId, (): Observable<DeriveBounties> =>
combineLatest([
bountyBase.bountyCount<BountyIndex>(),
api.query.council ? api.query.council.proposalCount<ProposalIndex>() : of(0)
api.query.council
? api.query.council.proposalCount<ProposalIndex>()
: of(0)
]).pipe(
switchMap(() =>
combineLatest([
bountyBase.bounties.keys<[BountyIndex]>(),
api.derive.council ? api.derive.council.proposals() : of([])
api.derive.council
? api.derive.council.proposals()
: of([])
])
),
switchMap(([keys, proposals]): Observable<Result> => {
+3 -2
View File
@@ -3,11 +3,12 @@
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 { SignedBlockExtended } from '../type';
import { createSignedBlockExtended } from '../type';
import { memo } from '../util';
/**
@@ -33,7 +34,7 @@ export function getBlock (instanceId: string, api: ApiInterfaceRx): (hash: Uint8
: of([])
]).pipe(
map(([signedBlock, events, validators]): SignedBlockExtended =>
new SignedBlockExtended(api.registry, signedBlock, events, validators)
createSignedBlockExtended(api.registry, signedBlock, events, validators)
),
catchError((): Observable<undefined> =>
// where rpc.chain.getHeader throws, we will land here - it can happen that
+3 -2
View File
@@ -3,11 +3,12 @@
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 { HeaderExtended } from '../type';
import { createHeaderExtended } from '../type';
import { memo } from '../util';
/**
@@ -33,7 +34,7 @@ export function getHeader (instanceId: string, api: ApiInterfaceRx): (hash: Uint
: of([])
]).pipe(
map(([header, validators]): HeaderExtended =>
new HeaderExtended(api.registry, header, validators)
createHeaderExtended(header.registry, header, validators)
),
catchError((): Observable<undefined> =>
// where rpc.chain.getHeader throws, we will land here - it can happen that
@@ -5,12 +5,12 @@ 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 } from '../type';
import type { HeaderExtended, SignedBlockExtended } from '../type/types';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { SignedBlockExtended } from '../type';
import { createSignedBlockExtended } from '../type';
import { memo } from '../util';
/**
@@ -30,7 +30,7 @@ export function subscribeNewBlocks (instanceId: string, api: ApiInterfaceRx): ()
);
}),
map(([block, events, header]) =>
new SignedBlockExtended(api.registry, block, events, header.validators)
createSignedBlockExtended(block.registry, block, events, header.validators)
)
)
);
@@ -3,11 +3,12 @@
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 { HeaderExtended } from '../type';
import { createHeaderExtended } from '../type';
import { memo } from '../util';
/**
@@ -34,7 +35,7 @@ export function subscribeNewHeads (instanceId: string, api: ApiInterfaceRx): ()
map(([header, validators]): HeaderExtended => {
header.createdAtHash = header.hash;
return new HeaderExtended(api.registry, header, validators);
return createHeaderExtended(header.registry, header, validators);
})
)
);
@@ -13,6 +13,8 @@ import { catchError, map, switchMap } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
type Collective = 'council' | 'membership' | 'technicalCommittee';
type Result = [(Hash | Uint8Array | string)[], (Option<Proposal> | null)[], Option<Votes>[]];
function parse (api: ApiInterfaceRx, [hashes, proposals, votes]: Result): DeriveCollectiveProposal[] {
@@ -29,7 +31,7 @@ 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: Collective): (hashes: (Hash | Uint8Array | string)[]) => Observable<DeriveCollectiveProposal[]> {
return memo(instanceId, (hashes: (Hash | Uint8Array | string)[]): Observable<DeriveCollectiveProposal[]> =>
(isFunction(api.query[section]?.proposals) && hashes.length
? combineLatest<Result>([
@@ -49,19 +51,19 @@ function _proposalsFrom (instanceId: string, api: ApiInterfaceRx, section: 'coun
);
}
export function proposals (instanceId: string, api: ApiInterfaceRx, section: 'council' | 'technicalCommittee' = 'council'): () => Observable<DeriveCollectiveProposal[]> {
export function proposals (instanceId: string, api: ApiInterfaceRx, section: Collective): () => Observable<DeriveCollectiveProposal[]> {
const proposalsFrom = _proposalsFrom(instanceId, api, section);
return memo(instanceId, (): Observable<DeriveCollectiveProposal[]> =>
isFunction(api.query[section]?.proposals)
? api.query[section].proposals().pipe(
? api.query[section as 'council'].proposals().pipe(
switchMap(proposalsFrom)
)
: of([] as DeriveCollectiveProposal[])
);
}
export function proposal (instanceId: string, api: ApiInterfaceRx, section: 'council' | 'technicalCommittee' = 'council'): (hash: Hash | Uint8Array | string) => Observable<DeriveCollectiveProposal | null> {
export function proposal (instanceId: string, api: ApiInterfaceRx, section: Collective): (hash: Hash | Uint8Array | string) => Observable<DeriveCollectiveProposal | null> {
const proposalsFrom = _proposalsFrom(instanceId, api, section);
return memo(instanceId, (hash: Hash | Uint8Array | string): Observable<DeriveCollectiveProposal | null> =>
+1 -2
View File
@@ -2,11 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { BN } from '@polkadot/util';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveContractFees } from '../types';
import BN from 'bn.js';
import { of } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
+2 -2
View File
@@ -10,9 +10,9 @@ import { proposal as collectiveProposal, proposals as collectiveProposals } from
import { memo } from '../util';
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 proposals (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveCollectiveProposal[]> {
return memo(instanceId, collectiveProposals(instanceId, api));
return memo(instanceId, collectiveProposals(instanceId, api, 'council'));
}
+4 -4
View File
@@ -21,7 +21,7 @@ function isVoter (value: VoteEntry): value is Voter {
}
function retrieveStakeOf (api: ApiInterfaceRx): Observable<[AccountId, Balance][]> {
return (api.query.electionsPhragmen || api.query.elections).stakeOf.entries<Balance, [AccountId]>().pipe(
return (api.query.phragmenElection || api.query.electionsPhragmen || api.query.elections).stakeOf.entries<Balance, [AccountId]>().pipe(
map((entries) =>
entries.map(([{ args: [accountId] }, stake]) => [accountId, stake])
)
@@ -29,7 +29,7 @@ function retrieveStakeOf (api: ApiInterfaceRx): Observable<[AccountId, Balance][
}
function retrieveVoteOf (api: ApiInterfaceRx): Observable<[AccountId, AccountId[]][]> {
return (api.query.electionsPhragmen || api.query.elections).votesOf.entries<Vec<AccountId>, [AccountId]>().pipe(
return (api.query.phragmenElection || api.query.electionsPhragmen || api.query.elections).votesOf.entries<Vec<AccountId>, [AccountId]>().pipe(
map((entries) =>
entries.map(([{ args: [accountId] }, votes]) => [accountId, votes])
)
@@ -61,7 +61,7 @@ function retrievePrev (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
}
function retrieveCurrent (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
const elections = (api.query.electionsPhragmen || api.query.elections);
const elections = (api.query.phragmenElection || api.query.electionsPhragmen || api.query.elections);
return elections.voting.entries<VoteEntry, [AccountId]>().pipe(
map((entries): DeriveCouncilVotes =>
@@ -77,7 +77,7 @@ function retrieveCurrent (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
export function votes (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveCouncilVotes> {
return memo(instanceId, (): Observable<DeriveCouncilVotes> =>
(api.query.electionsPhragmen || api.query.elections).stakeOf
(api.query.phragmenElection || api.query.electionsPhragmen || api.query.elections).stakeOf
? retrievePrev(api)
: retrieveCurrent(api)
);
+1 -2
View File
@@ -4,11 +4,10 @@
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 { BN } from '@polkadot/util';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveDemocracyLock } from '../types';
import BN from 'bn.js';
import { BN_ZERO, isUndefined } from '@polkadot/util';
import { of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
@@ -3,10 +3,9 @@
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { ReferendumIndex } from '@polkadot/types/interfaces';
import type { BN } from '@polkadot/util';
import type { Observable } from '@polkadot/x-rxjs';
import BN from 'bn.js';
import { of } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
@@ -4,11 +4,10 @@
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option, Vec } from '@polkadot/types';
import type { AccountId, ReferendumInfo, ReferendumInfoTo239, Vote, Voting, VotingDelegating, VotingDirectVote } from '@polkadot/types/interfaces';
import type { BN } from '@polkadot/util';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveBalancesAccount, DeriveReferendum, DeriveReferendumVote, DeriveReferendumVotes } from '../types';
import BN from 'bn.js';
import { isFunction } from '@polkadot/util';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
@@ -2,10 +2,9 @@
// SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { BN } from '@polkadot/util';
import type { Observable } from '@polkadot/x-rxjs';
import BN from 'bn.js';
import { bnSqrt } from '@polkadot/util';
import { map } from '@polkadot/x-rxjs/operators';
+1 -1
View File
@@ -1,9 +1,9 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type BN from 'bn.js';
import type { Vec } from '@polkadot/types';
import type { AccountId, Balance, BlockNumber, Hash, PropIndex, Proposal, ReferendumIndex, ReferendumInfoTo239, ReferendumStatus, Vote, VoteThreshold } from '@polkadot/types/interfaces';
import type { BN } from '@polkadot/util';
export interface DeriveDemocracyLock {
balance: Balance;
+1 -3
View File
@@ -7,9 +7,7 @@ import type { AccountId, Balance, BlockNumber, PreimageStatus, Proposal, Referen
import type { ITuple } from '@polkadot/types/types';
import type { DeriveProposalImage, DeriveReferendum, DeriveReferendumVote, DeriveReferendumVotes, DeriveReferendumVoteState } from '../types';
import BN from 'bn.js';
import { bnSqrt } from '@polkadot/util';
import { BN, bnSqrt } from '@polkadot/util';
type PreimageInfo = [Bytes, AccountId, Balance, BlockNumber];
type OldPreimage = ITuple<PreimageInfo>;
+5 -1
View File
@@ -42,7 +42,11 @@ function sortAccounts ([, balanceA]: [AccountId, Balance], [, balanceB]: [Accoun
}
function queryElections (api: ApiInterfaceRx): Observable<DeriveElectionsInfo> {
const section = api.query.electionsPhragmen ? 'electionsPhragmen' : 'elections';
const section = api.query.phragmenElection
? 'phragmenElection'
: api.query.electionsPhragmen
? 'electionsPhragmen'
: 'elections';
return api.queryMulti<[Vec<AccountId>, Vec<Candidate>, Vec<Member>, Vec<Member>]>([
api.query.council.members,
+9 -1
View File
@@ -39,6 +39,10 @@ describe('derive', (): void => {
api.isReady.subscribe(() => done());
});
afterAll(async () => {
await api.disconnect();
});
testFunction(api)('accounts', 'idAndIndex', []);
testFunction(api)('accounts', 'idToIndex', []);
testFunction(api)('accounts', 'indexes', []);
@@ -80,7 +84,11 @@ describe('derive', (): void => {
});
beforeAll((done): void => {
api.isReady.subscribe((): void => done());
api.isReady.subscribe(() => done());
});
afterAll(async () => {
await api.disconnect();
});
// override
+4 -2
View File
@@ -16,6 +16,7 @@ import * as council from './council';
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';
@@ -27,7 +28,7 @@ import * as tx from './tx';
export { packageInfo } from './packageInfo';
export * from './type';
export const derive = { accounts, balances, bounties, chain, contracts, council, democracy, elections, imOnline, parachains, session, society, staking, technicalCommittee, treasury, tx };
export const derive = { accounts, balances, bounties, chain, contracts, council, democracy, elections, imOnline, membership, parachains, session, society, staking, technicalCommittee, treasury, tx };
type DeriveSection<Section> = {
[Method in keyof Section]: Section[Method] extends AnyFunction
@@ -47,8 +48,9 @@ const deriveAvail: Record<string, string[]> = {
contracts: ['contracts'],
council: ['council'],
democracy: ['democracy'],
elections: ['electionsPhragmen', 'elections'],
elections: ['phragmenElection', 'electionsPhragmen', 'elections'],
imOnline: ['imOnline'],
membership: ['membership'],
parachains: ['parachains', 'registrar'],
session: ['session'],
society: ['society'],
@@ -0,0 +1,4 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './proposals';
@@ -0,0 +1,13 @@
// 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 '@polkadot/x-rxjs';
import type { DeriveCollectiveProposal } from '../types';
import { proposals as collectiveProposals } from '../collective';
import { memo } from '../util';
export function proposals (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveCollectiveProposal[]> {
return memo(instanceId, collectiveProposals(instanceId, api, 'membership'));
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api-derive', version: '4.0.2' };
export const packageInfo = { name: '@polkadot/api-derive', version: '4.16.1' };
+24 -9
View File
@@ -13,7 +13,7 @@ import { map } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
// parse into Indexes
function parse ([activeEra, activeEraStart, currentEra, currentIndex, validatorCount]: [EraIndex, Option<Moment>, EraIndex, SessionIndex, u32]): DeriveSessionIndexes {
function parse ([currentIndex, activeEra, activeEraStart, currentEra, validatorCount]: [SessionIndex, EraIndex, Option<Moment>, EraIndex, u32]): DeriveSessionIndexes {
return {
activeEra,
activeEraStart,
@@ -24,42 +24,57 @@ function parse ([activeEra, activeEraStart, currentEra, currentIndex, validatorC
}
// query based on latest
function query (api: ApiInterfaceRx): Observable<DeriveSessionIndexes> {
return api.queryMulti<[Option<ActiveEraInfo>, Option<EraIndex>, SessionIndex, u32]>([
function queryStaking (api: ApiInterfaceRx): Observable<DeriveSessionIndexes> {
return api.queryMulti<[SessionIndex, Option<ActiveEraInfo>, Option<EraIndex>, u32]>([
api.query.session.currentIndex,
api.query.staking.activeEra,
api.query.staking.currentEra,
api.query.session.currentIndex,
api.query.staking.validatorCount
]).pipe(
map(([activeOpt, currentEra, currentIndex, validatorCount]): DeriveSessionIndexes => {
map(([currentIndex, activeOpt, currentEra, validatorCount]): DeriveSessionIndexes => {
const { index, start } = activeOpt.unwrapOrDefault();
return parse([
currentIndex,
index,
start,
currentEra.unwrapOrDefault(),
currentIndex,
validatorCount
]);
})
);
}
// query based on latest
function querySession (api: ApiInterfaceRx): Observable<DeriveSessionIndexes> {
return api.query.session.currentIndex().pipe(
map((currentIndex): DeriveSessionIndexes => parse([
currentIndex,
api.registry.createType('EraIndex'),
api.registry.createType('Option<Moment>'),
api.registry.createType('EraIndex'),
api.registry.createType('u32')
]))
);
}
// empty set when none is available
function empty (api: ApiInterfaceRx): Observable<DeriveSessionIndexes> {
return of(parse([
api.registry.createType('SessionIndex', 1),
api.registry.createType('EraIndex'),
api.registry.createType('Option<Moment>'),
api.registry.createType('EraIndex'),
api.registry.createType('SessionIndex', 1),
api.registry.createType('u32')
]));
}
export function indexes (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveSessionIndexes> {
return memo(instanceId, (): Observable<DeriveSessionIndexes> =>
api.query.session && api.query.staking
? query(api)
api.query.session
? api.query.staking
? queryStaking(api)
: querySession(api)
: empty(api)
);
}
+15 -55
View File
@@ -2,71 +2,31 @@
// SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { u64 } from '@polkadot/types';
import type { SessionIndex } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveSessionIndexes, DeriveSessionInfo } from '../types';
import type { DeriveSessionInfo } from '../types';
import { map } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
type ResultType = [boolean, u64, SessionIndex];
type Result = [ResultType, DeriveSessionIndexes];
function createDerive (api: ApiInterfaceRx, [[hasBabe, epochDuration, sessionsPerEra], { activeEra, activeEraStart, currentEra, currentIndex, validatorCount }]: Result): DeriveSessionInfo {
return {
activeEra,
activeEraStart,
currentEra,
currentIndex,
eraLength: api.registry.createType('BlockNumber', sessionsPerEra.mul(epochDuration)),
isEpoch: hasBabe,
sessionLength: epochDuration,
sessionsPerEra,
validatorCount
};
}
function queryAura (api: ApiInterfaceRx): Observable<DeriveSessionInfo> {
return api.derive.session.indexes().pipe(
map((indexes): DeriveSessionInfo =>
createDerive(api, [
[
false,
api.registry.createType('u64', 1),
// we may have aura without staking (permissioned)
api.consts.staking?.sessionsPerEra || api.registry.createType('SessionIndex', 1)
],
indexes
])
)
);
}
function queryBabe (api: ApiInterfaceRx): Observable<DeriveSessionInfo> {
return api.derive.session.indexes().pipe(
map((indexes) =>
createDerive(api, [
[
true,
api.consts.babe.epochDuration,
// we may have babe without staking (permissioned)
api.consts.staking?.sessionsPerEra || api.registry.createType('SessionIndex', 1)
],
indexes
])
)
);
}
/**
* @description Retrieves all the session and era query and calculates specific values on it as the length of the session and eras
*/
export function info (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveSessionInfo> {
return memo(instanceId, (): Observable<DeriveSessionInfo> =>
api.consts.babe
? queryBabe(api)
: queryAura(api)
api.derive.session.indexes().pipe(
map((indexes) => {
const sessionLength = api.consts?.babe?.epochDuration || api.registry.createType('u64', 1);
const sessionsPerEra = api.consts?.staking?.sessionsPerEra || api.registry.createType('SessionIndex', 1);
return {
...indexes,
eraLength: api.registry.createType('BlockNumber', sessionsPerEra.mul(sessionLength)),
isEpoch: !!api.query.babe,
sessionLength,
sessionsPerEra
};
})
)
);
}
+2 -2
View File
@@ -44,7 +44,7 @@ function queryBabe (api: ApiInterfaceRx): Observable<[DeriveSessionInfo, ResultS
combineLatest([
of(info),
// we may have no staking, but have babe (permissioned)
api.query.staking
api.query.staking?.erasStartSessionIndex
? api.queryMulti<ResultSlots>([
api.query.babe.currentSlot,
api.query.babe.epochIndex,
@@ -69,7 +69,7 @@ function queryBabe (api: ApiInterfaceRx): Observable<[DeriveSessionInfo, ResultS
*/
export function progress (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveSessionProgress> {
return memo(instanceId, (): Observable<DeriveSessionProgress> =>
api.consts.babe
api.query.babe
? queryBabe(api).pipe(
map(([info, slots]: [DeriveSessionInfo, ResultSlotsFlat]): DeriveSessionProgress =>
createDerive(api, info, slots)
+3 -20
View File
@@ -2,9 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { bool, Option, Vec } from '@polkadot/types';
import type { AccountId, Balance, BlockNumber, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { AccountId } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveSocietyMember } from '../types';
@@ -12,28 +10,13 @@ import { map } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
type Result = [Vec<ITuple<[BlockNumber, Balance]>>, StrikeCount, Option<SocietyVote>, bool, Option<VouchingStatus>];
/**
* @description Get the member info for a society
*/
export function member (instanceId: string, api: ApiInterfaceRx): (accountId: AccountId) => Observable<DeriveSocietyMember> {
return memo(instanceId, (accountId: AccountId): Observable<DeriveSocietyMember> =>
api.queryMulti<Result>([
[api.query.society.payouts, accountId],
[api.query.society.strikes, accountId],
[api.query.society.defenderVotes, accountId],
[api.query.society.suspendedMembers, accountId],
[api.query.society.vouching, accountId]
]).pipe(
map(([payouts, strikes, defenderVotes, suspended, vouching]: Result): DeriveSocietyMember => ({
accountId,
isSuspended: suspended.isTrue,
payouts,
strikes,
vote: defenderVotes.unwrapOr(undefined),
vouching: vouching.unwrapOr(undefined)
}))
api.derive.society._members([accountId]).pipe(
map(([result]) => result)
)
);
}
+33 -10
View File
@@ -2,28 +2,51 @@
// SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AccountId } from '@polkadot/types/interfaces';
import type { bool, Option, Vec } from '@polkadot/types';
import type { AccountId, Balance, BlockNumber, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveSocietyMember } from '../types';
import { combineLatest } from '@polkadot/x-rxjs';
import { switchMap } from '@polkadot/x-rxjs/operators';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
type Result = [AccountId[], Vec<ITuple<[BlockNumber, Balance]>>[], StrikeCount[], Option<SocietyVote>[], bool[], Option<VouchingStatus>[]];
export function _members (instanceId: string, api: ApiInterfaceRx): (accountIds: AccountId[]) => Observable<DeriveSocietyMember[]> {
return memo(instanceId, (accountIds: AccountId[]): Observable<DeriveSocietyMember[]> =>
combineLatest<Result>([
of(accountIds),
api.query.society.payouts.multi(accountIds),
api.query.society.strikes.multi(accountIds),
api.query.society.defenderVotes.multi(accountIds),
api.query.society.suspendedMembers.multi(accountIds),
api.query.society.vouching.multi(accountIds)
]).pipe(
map(([accountIds, payouts, strikes, defenderVotes, suspended, vouching]) =>
accountIds.map((accountId, index) => ({
accountId,
isDefenderVoter: defenderVotes[index].isSome,
isSuspended: suspended[index].isTrue,
payouts: payouts[index],
strikes: strikes[index],
vote: defenderVotes[index].unwrapOr(undefined),
vouching: vouching[index].unwrapOr(undefined)
}))
)
)
);
}
/**
* @description Get the member info for a society
*/
export function members (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveSocietyMember[]> {
return memo(instanceId, (): Observable<DeriveSocietyMember[]> =>
api.query.society.members<AccountId[]>().pipe(
switchMap((members): Observable<DeriveSocietyMember[]> =>
combineLatest(
members.map((accountId): Observable<DeriveSocietyMember> =>
api.derive.society.member(accountId)
)
)
)
switchMap((members) => api.derive.society._members(members))
)
);
}
+1 -3
View File
@@ -5,9 +5,7 @@ import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Balance, StakingLedger, UnlockChunk } from '@polkadot/types/interfaces';
import type { DeriveSessionInfo, DeriveStakingAccount, DeriveStakingKeys, DeriveStakingQuery, DeriveUnlocking } from '../types';
import BN from 'bn.js';
import { BN_ZERO } from '@polkadot/util';
import { BN, BN_ZERO } from '@polkadot/util';
import { combineLatest, Observable } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
@@ -4,10 +4,10 @@
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option, u32 } from '@polkadot/types';
import type { ActiveEraInfo, EraIndex } from '@polkadot/types/interfaces';
import type { BN } from '@polkadot/util';
import type { Observable } from '@polkadot/x-rxjs';
import BN from 'bn.js';
import { BN_ONE, BN_ZERO } from '@polkadot/util';
import { map } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
@@ -24,12 +24,12 @@ export function erasHistoric (instanceId: string, api: ApiInterfaceRx): (withAct
const activeEra: BN = activeEraOpt.unwrapOrDefault().index;
let lastEra = activeEra;
while (lastEra.gten(0) && (result.length < max)) {
while (lastEra.gte(BN_ZERO) && (result.length < max)) {
if ((lastEra !== activeEra) || (withActive === true)) {
result.push(api.registry.createType('EraIndex', lastEra));
}
lastEra = lastEra.subn(1);
lastEra = lastEra.sub(BN_ONE);
}
// go from oldest to newest
@@ -3,12 +3,11 @@
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AccountId, EraIndex, StakingLedger } from '@polkadot/types/interfaces';
import type { BN } from '@polkadot/util';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveEraPoints, DeriveEraPrefs, DeriveEraRewards, DeriveEraValPrefs, DeriveStakerExposure, DeriveStakerReward, DeriveStakerRewardValidator } from '../types';
import type { DeriveStakingQuery } from './types';
import BN from 'bn.js';
import { BN_BILLION, BN_ZERO } from '@polkadot/util';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
@@ -28,7 +27,7 @@ function parseRewards (api: ApiInterfaceRx, stashId: AccountId, [erasPoints, era
Object.entries(eraValidators).forEach(([validatorId, exposure]): void => {
const valPoints = allValPoints[validatorId] || BN_ZERO;
const valComm = allValPrefs[validatorId]?.commission.unwrap() || BN_ZERO;
const expTotal = exposure.total.unwrap();
const expTotal = exposure.total?.unwrap() || BN_ZERO;
let avail = BN_ZERO;
let value: BN | undefined;
@@ -121,8 +120,6 @@ function filterRewards (eras: EraIndex[], valInfo: [string, DeriveStakingQuery][
return false;
}
reward.isStakerPayout = true;
removeClaimed(validators, queryValidators, reward);
return true;
@@ -165,17 +162,21 @@ export function _stakerRewards (instanceId: string, api: ApiInterfaceRx): (accou
const [allValidators, stashValidators] = allUniqValidators(allRewards);
return api.derive.staking.queryMulti(allValidators, { withLedger: true }).pipe(
map((queriedVals): DeriveStakerReward[][] => {
return queries.map(({ stakingLedger }, index): DeriveStakerReward[] => {
const rewards = allRewards[index];
const ownValidators = stashValidators[index].map((validatorId): [string, DeriveStakingQuery] => [
validatorId,
queriedVals.find((q) => q.accountId.eq(validatorId)) as DeriveStakingQuery
]);
return filterRewards(eras, ownValidators, { rewards, stakingLedger });
});
})
map((queriedVals): DeriveStakerReward[][] =>
queries.map(({ stakingLedger }, index): DeriveStakerReward[] =>
filterRewards(
eras,
stashValidators[index].map((validatorId): [string, DeriveStakingQuery] => [
validatorId,
queriedVals.find((q) => q.accountId.eq(validatorId)) as DeriveStakingQuery
]),
{
rewards: allRewards[index],
stakingLedger
}
)
)
)
);
})
)
+1 -2
View File
@@ -1,8 +1,8 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type BN from 'bn.js';
import type { AccountId, Balance, EraIndex, Exposure, RewardDestination, RewardPoint, StakingLedger, ValidatorPrefs } from '@polkadot/types/interfaces';
import type { BN } from '@polkadot/util';
import type { DeriveSessionIndexes } from '../session/types';
export type DeriveEraValPoints = Record<string, RewardPoint>;
@@ -81,7 +81,6 @@ export interface DeriveStakerRewardValidator {
export interface DeriveStakerReward {
era: EraIndex;
eraReward: Balance;
isStakerPayout?: boolean;
isEmpty: boolean;
isValidator: boolean;
nominating: DeriveEraExposureNominating[];
@@ -61,7 +61,9 @@ function retrieveProposals (api: ApiInterfaceRx, proposalCount: ProposalIndex, a
return combineLatest([
api.query.treasury.proposals.multi<Option<TreasuryProposal>>(allIds),
api.derive.council.proposals()
api.derive.council
? api.derive.council.proposals()
: of([] as DeriveCollectiveProposal[])
]).pipe(
map(([allProposals, councilProposals]: [Option<TreasuryProposal>[], DeriveCollectiveProposal[]]): DeriveTreasuryProposals =>
parseResult(api, { allIds, allProposals, approvalIds, councilProposals, proposalCount })
+1 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import BN from 'bn.js';
import { BN } from '@polkadot/util';
export const FALLBACK_MAX_HASH_COUNT = 250;
+29 -32
View File
@@ -2,44 +2,41 @@
// SPDX-License-Identifier: Apache-2.0
import type { AccountId, Header } from '@polkadot/types/interfaces';
import type { Constructor, Registry } from '@polkadot/types/types';
import { Struct } from '@polkadot/types';
import runtimeTypes from '@polkadot/types/interfaces/runtime/definitions';
import type { Registry } from '@polkadot/types/types';
import type { HeaderExtended } from './types';
import { extractAuthor } from './util';
// We can ignore the properties, added via Struct.with
const _Header = Struct.with(runtimeTypes.types.Header as any) as Constructor<Header>;
export function createHeaderExtended (registry: Registry, header?: Header, validators?: AccountId[]): HeaderExtended {
// an instance of the base extrinsic for us to extend
const HeaderBase = registry.createClass('Header');
/**
* @name HeaderExtended
* @description
* A [[Block]] header with an additional `author` field that indicates the block author
*/
export class HeaderExtended extends _Header {
readonly #author?: AccountId;
readonly #validators?: AccountId[];
class Implementation extends HeaderBase implements HeaderExtended {
readonly #author?: AccountId;
readonly #validators?: AccountId[];
constructor (registry: Registry, header?: Header, validators?: AccountId[]) {
super(registry, header);
constructor (registry: Registry, header?: Header, validators?: AccountId[]) {
super(registry, header);
this.#author = extractAuthor(this.digest, validators);
this.#validators = validators;
this.createdAtHash = header?.createdAtHash;
this.#author = extractAuthor(this.digest, validators);
this.#validators = validators;
this.createdAtHash = header?.createdAtHash;
}
/**
* @description Convenience method, returns the author for the block
*/
public get author (): AccountId | undefined {
return this.#author;
}
/**
* @description Convenience method, returns the validators for the block
*/
public get validators (): AccountId[] | undefined {
return this.#validators;
}
}
/**
* @description Convenience method, returns the author for the block
*/
public get author (): AccountId | undefined {
return this.#author;
}
/**
* @description Convenience method, returns the validators for the block
*/
public get validators (): AccountId[] | undefined {
return this.#validators;
}
return new Implementation(registry, header, validators);
}
@@ -1,24 +1,12 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { AccountId, DispatchError, DispatchInfo, Event, EventRecord, Extrinsic, SignedBlock } from '@polkadot/types/interfaces';
import type { Constructor, Registry } from '@polkadot/types/types';
import { Struct } from '@polkadot/types';
import runtimeTypes from '@polkadot/types/interfaces/runtime/definitions';
import type { AccountId, DispatchError, DispatchInfo, EventRecord, Extrinsic, SignedBlock } from '@polkadot/types/interfaces';
import type { Registry } from '@polkadot/types/types';
import type { SignedBlockExtended, TxWithEvent } from './types';
import { extractAuthor } from './util';
// We can ignore the properties, added via Struct.with
const _SignedBlock = Struct.with(runtimeTypes.types.SignedBlock as any) as Constructor<SignedBlock>;
interface TxWithEvent {
dispatchError?: DispatchError;
dispatchInfo?: DispatchInfo;
events: Event[];
extrinsic: Extrinsic;
}
function mapExtrinsics (extrinsics: Extrinsic[], records: EventRecord[]): TxWithEvent[] {
return extrinsics.map((extrinsic, index): TxWithEvent => {
let dispatchError: DispatchError | undefined;
@@ -43,43 +31,45 @@ function mapExtrinsics (extrinsics: Extrinsic[], records: EventRecord[]): TxWith
});
}
/**
* @name SignedBlockExtended
* @description
* A [[Block]] header with an additional `author` field that indicates the block author
*/
export class SignedBlockExtended extends _SignedBlock {
readonly #author?: AccountId;
readonly #events: EventRecord[];
readonly #extrinsics: TxWithEvent[];
export function createSignedBlockExtended (registry: Registry, block?: SignedBlock, events?: EventRecord[], validators?: AccountId[]): SignedBlockExtended {
// an instance of the base extrinsic for us to extend
const SignedBlockBase = registry.createClass('SignedBlock');
constructor (registry: Registry, block?: SignedBlock, events?: EventRecord[], validators?: AccountId[]) {
super(registry, block);
class Implementation extends SignedBlockBase implements SignedBlockExtended {
readonly #author?: AccountId;
readonly #events: EventRecord[];
readonly #extrinsics: TxWithEvent[];
this.#author = extractAuthor(this.block.header.digest, validators);
this.#events = events || ([] as EventRecord[]);
this.#extrinsics = mapExtrinsics(this.block.extrinsics, this.#events);
this.createdAtHash = block?.createdAtHash;
constructor (registry: Registry, block?: SignedBlock, events?: EventRecord[], validators?: AccountId[]) {
super(registry, block);
this.#author = extractAuthor(this.block.header.digest, validators);
this.#events = events || ([] as EventRecord[]);
this.#extrinsics = mapExtrinsics(this.block.extrinsics, this.#events);
this.createdAtHash = block?.createdAtHash;
}
/**
* @description Convenience method, returns the author for the block
*/
public get author (): AccountId | undefined {
return this.#author;
}
/**
* @description Convenience method, returns the events associated with the block
*/
public get events (): EventRecord[] {
return this.#events;
}
/**
* @description Returns the extrinsics and their events, mapped
*/
public get extrinsics (): TxWithEvent[] {
return this.#extrinsics;
}
}
/**
* @description Convenience method, returns the author for the block
*/
public get author (): AccountId | undefined {
return this.#author;
}
/**
* @description Convenience method, returns the events associated with the block
*/
public get events (): EventRecord[] {
return this.#events;
}
/**
* @description Returns the extrinsics and their events, mapped
*/
public get extrinsics (): TxWithEvent[] {
return this.#extrinsics;
}
return new Implementation(registry, block, events, validators);
}
+2 -2
View File
@@ -1,5 +1,5 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
export { HeaderExtended } from './HeaderExtended';
export { SignedBlockExtended } from './SignedBlockExtended';
export { createHeaderExtended } from './HeaderExtended';
export { createSignedBlockExtended } from './SignedBlockExtended';
+22
View File
@@ -0,0 +1,22 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { AccountId, DispatchError, DispatchInfo, Event, EventRecord, Extrinsic, Header, SignedBlock } from '@polkadot/types/interfaces';
export interface HeaderExtended extends Header {
readonly author: AccountId | undefined;
readonly validators: AccountId[] | undefined;
}
export interface SignedBlockExtended extends SignedBlock {
readonly author: AccountId | undefined;
readonly events: EventRecord[];
readonly extrinsics: TxWithEvent[];
}
export interface TxWithEvent {
dispatchError?: DispatchError;
dispatchInfo?: DispatchInfo;
events: Event[];
extrinsic: Extrinsic;
}
+32 -9
View File
@@ -5,20 +5,43 @@ import type { AccountId, Digest } from '@polkadot/types/interfaces';
export function extractAuthor (digest: Digest, sessionValidators: AccountId[] = []): AccountId | undefined {
const [citem] = digest.logs.filter(({ type }) => type === 'Consensus');
const [pitem] = digest.logs.filter(({ type }) => type === 'PreRuntime');
const [sitem] = digest.logs.filter(({ type }) => type === 'Seal');
if (citem) {
const [engine, data] = citem.asConsensus;
let accountId: AccountId | undefined;
return engine.extractAuthor(data, sessionValidators);
} else {
const [pitem] = digest.logs.filter(({ type }) => type === 'PreRuntime');
if (pitem) {
// This is critical to be first for BABE (before Consensus)
// If not first, we end up dropping the author at session-end
if (pitem) {
try {
const [engine, data] = pitem.asPreRuntime;
return engine.extractAuthor(data, sessionValidators);
accountId = engine.extractAuthor(data, sessionValidators);
} catch {
// ignore
}
}
return undefined;
if (!accountId && citem) {
try {
const [engine, data] = citem.asConsensus;
accountId = engine.extractAuthor(data, sessionValidators);
} catch {
// ignore
}
}
// SEAL, still used in e.g. Kulupu for pow
if (!accountId && sitem) {
try {
const [engine, data] = sitem.asSeal;
accountId = engine.extractAuthor(data, sessionValidators);
} catch {
// ignore
}
}
return accountId;
}
+3 -1
View File
@@ -1,9 +1,9 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type BN from 'bn.js';
import type { u32 } from '@polkadot/types';
import type { AccountId, Balance, BalanceLock, BalanceLockTo212, BalanceOf, Bid, BidKind, BlockNumber, Bounty, BountyIndex, Hash, Index, Proposal, ProposalIndex, SetIndex, SocietyVote, StrikeCount, TreasuryProposal, Votes, VouchingStatus } from '@polkadot/types/interfaces';
import type { BN } from '@polkadot/util';
export * from './accounts/types';
export * from './council/types';
@@ -12,6 +12,7 @@ export * from './elections/types';
export * from './parachains/types';
export * from './session/types';
export * from './staking/types';
export * from './type/types';
export interface DeriveBalancesAccountData {
freeBalance: Balance;
@@ -107,6 +108,7 @@ export interface DeriveSocietyCandidate {
export interface DeriveSocietyMember {
accountId: AccountId;
isDefenderVoter: boolean;
isSuspended: boolean;
payouts: [BlockNumber, Balance][];
strikes: StrikeCount;
+15 -13
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api",
"version": "4.0.2",
"version": "4.16.1",
"type": "module",
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
"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,18 +19,17 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
"dependencies": {
"@babel/runtime": "^7.13.9",
"@polkadot/api-derive": "4.0.2",
"@polkadot/keyring": "^6.0.5",
"@polkadot/metadata": "4.0.2",
"@polkadot/rpc-core": "4.0.2",
"@polkadot/rpc-provider": "4.0.2",
"@polkadot/types": "4.0.2",
"@polkadot/types-known": "4.0.2",
"@polkadot/util": "^6.0.5",
"@polkadot/util-crypto": "^6.0.5",
"@polkadot/x-rxjs": "^6.0.5",
"bn.js": "^4.11.9",
"@babel/runtime": "^7.14.6",
"@polkadot/api-derive": "4.16.1",
"@polkadot/keyring": "^6.10.1",
"@polkadot/metadata": "4.16.1",
"@polkadot/rpc-core": "4.16.1",
"@polkadot/rpc-provider": "4.16.1",
"@polkadot/types": "4.16.1",
"@polkadot/types-known": "4.16.1",
"@polkadot/util": "^6.10.1",
"@polkadot/util-crypto": "^6.10.1",
"@polkadot/x-rxjs": "^6.10.1",
"eventemitter3": "^4.0.7"
}
}
+234 -78
View File
@@ -1,9 +1,10 @@
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
/* eslint-disable */
import type { Vec, u16, u32, u64, u8 } from '@polkadot/types';
import type { Vec, u16, u32, u64 } from '@polkadot/types';
import type { Codec } from '@polkadot/types/types';
import type { Balance, BalanceOf, BlockNumber, LockIdentifier, ModuleId, Moment, Perbill, Percent, Permill, RuntimeDbWeight, Weight } from '@polkadot/types/interfaces/runtime';
import type { Schedule } from '@polkadot/types/interfaces/contracts';
import type { Balance, BalanceOf, BlockNumber, LockIdentifier, Moment, PalletId, Perbill, Percent, Permill, RuntimeDbWeight, Weight } from '@polkadot/types/interfaces/runtime';
import type { SessionIndex } from '@polkadot/types/interfaces/session';
import type { EraIndex } from '@polkadot/types/interfaces/staking';
import type { RuntimeVersion } from '@polkadot/types/interfaces/state';
@@ -14,13 +15,10 @@ import type { ApiTypes } from '@polkadot/api/types';
declare module '@polkadot/api/types/consts' {
export interface AugmentedConsts<ApiType> {
babe: {
[key: string]: Codec;
/**
* The number of **slots** that an epoch takes. We couple sessions to
* epochs, i.e. we start a new session once the new epoch begins.
* NOTE: Currently it is not possible to change the epoch duration
* after the chain has started. Attempting to do so will brick block
* production.
* The amount of time, in slots, that each epoch should last.
* NOTE: Currently it is not possible to change the epoch duration after
* the chain has started. Attempting to do so will brick block production.
**/
epochDuration: u64 & AugmentedConst<ApiType>;
/**
@@ -31,16 +29,22 @@ declare module '@polkadot/api/types/consts' {
* the probability of a slot being empty).
**/
expectedBlockTime: Moment & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
balances: {
[key: string]: Codec;
/**
* The minimum amount required to keep an account open.
**/
existentialDeposit: Balance & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
bounties: {
[key: string]: Codec;
/**
* Percentage of the curator fee that will be reserved upfront as deposit for bounty curator.
**/
@@ -69,9 +73,12 @@ declare module '@polkadot/api/types/consts' {
* Maximum acceptable reason length.
**/
maximumReasonLength: u32 & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
contracts: {
[key: string]: Codec;
/**
* The maximum number of tries that can be queued for deletion.
**/
@@ -106,20 +113,6 @@ declare module '@polkadot/api/types/consts' {
* It works the same as [`Self::DepositPerStorageByte`] but for storage items.
**/
depositPerStorageItem: BalanceOf & AugmentedConst<ApiType>;
/**
* The maximum length of a contract code in bytes. This limit applies to the instrumented
* version of the code. Therefore `instantiate_with_code` can fail even when supplying
* a wasm binary below this maximum size.
**/
maxCodeSize: u32 & AugmentedConst<ApiType>;
/**
* The maximum nesting level of a call/instantiate stack.
**/
maxDepth: u32 & AugmentedConst<ApiType>;
/**
* The maximum size of a storage value and event payload in bytes.
**/
maxValueSize: u32 & AugmentedConst<ApiType>;
/**
* The fraction of the deposit that should be used as rent per block.
*
@@ -128,6 +121,10 @@ declare module '@polkadot/api/types/consts' {
* This determines how high this rent payment is per block as a fraction of the deposit.
**/
rentFraction: Perbill & AugmentedConst<ApiType>;
/**
* Cost schedule and limits.
**/
schedule: Schedule & AugmentedConst<ApiType>;
/**
* Number of block delay an extrinsic claim surcharge has.
*
@@ -144,9 +141,12 @@ declare module '@polkadot/api/types/consts' {
* The minimum amount required to generate a tombstone.
**/
tombstoneDeposit: BalanceOf & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
democracy: {
[key: string]: Codec;
/**
* Period in blocks where an external proposal may not be re-submitted after being vetoed.
**/
@@ -160,7 +160,7 @@ declare module '@polkadot/api/types/consts' {
**/
enactmentPeriod: BlockNumber & AugmentedConst<ApiType>;
/**
* Minimum voting period allowed for an emergency referendum.
* Minimum voting period allowed for a fast-track referendum.
**/
fastTrackVotingPeriod: BlockNumber & AugmentedConst<ApiType>;
/**
@@ -169,6 +169,9 @@ declare module '@polkadot/api/types/consts' {
launchPeriod: BlockNumber & AugmentedConst<ApiType>;
/**
* The maximum number of votes for an account.
*
* Also used to compute weight, an overly big value can
* lead to extrinsic with very big weight: see `delegate` for instance.
**/
maxVotes: u32 & AugmentedConst<ApiType>;
/**
@@ -183,9 +186,19 @@ declare module '@polkadot/api/types/consts' {
* How often (in blocks) to check for new votes.
**/
votingPeriod: BlockNumber & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
electionProviderMultiPhase: {
[key: string]: Codec;
/**
* The repeat threshold of the offchain worker.
*
* For example, if it is 5, that means that at least 5 blocks will elapse between attempts
* to submit the worker's solution.
**/
offchainRepeat: BlockNumber & AugmentedConst<ApiType>;
/**
* Duration of the signed phase.
**/
@@ -199,21 +212,102 @@ declare module '@polkadot/api/types/consts' {
* Duration of the unsigned phase.
**/
unsignedPhase: BlockNumber & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
elections: {
[key: string]: Codec;
/**
* How much should be locked up in order to submit one's candidacy.
**/
candidacyBond: BalanceOf & AugmentedConst<ApiType>;
/**
* Number of members to elect.
**/
desiredMembers: u32 & AugmentedConst<ApiType>;
/**
* Number of runners_up to keep.
**/
desiredRunnersUp: u32 & AugmentedConst<ApiType>;
moduleId: LockIdentifier & AugmentedConst<ApiType>;
/**
* Identifier for the elections-phragmen pallet's lock
**/
palletId: LockIdentifier & AugmentedConst<ApiType>;
/**
* How long each seat is kept. This defines the next block number at which an election
* round will happen. If set to zero, no elections are ever triggered and the module will
* be in passive mode.
**/
termDuration: BlockNumber & AugmentedConst<ApiType>;
/**
* Base deposit associated with voting.
*
* This should be sensibly high to economically ensure the pallet cannot be attacked by
* creating a gigantic number of votes.
**/
votingBondBase: BalanceOf & AugmentedConst<ApiType>;
/**
* The amount of bond that need to be locked for each vote (32 bytes).
**/
votingBondFactor: BalanceOf & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
gilt: {
/**
* Portion of the queue which is free from ordering and just a FIFO.
*
* Must be no greater than `MaxQueueLen`.
**/
fifoQueueLen: u32 & AugmentedConst<ApiType>;
/**
* The number of blocks between consecutive attempts to issue more gilts in an effort to
* get to the target amount to be frozen.
*
* A larger value results in fewer storage hits each block, but a slower period to get to
* the target.
**/
intakePeriod: BlockNumber & AugmentedConst<ApiType>;
/**
* The maximum amount of bids that can be turned into issued gilts each block. A larger
* value here means less of the block available for transactions should there be a glut of
* bids to make into gilts to reach the target.
**/
maxIntakeBids: u32 & AugmentedConst<ApiType>;
/**
* Maximum number of items that may be in each duration queue.
**/
maxQueueLen: u32 & AugmentedConst<ApiType>;
/**
* The minimum amount of funds that may be offered to freeze for a gilt. Note that this
* does not actually limit the amount which may be frozen in a gilt since gilts may be
* split up in order to satisfy the desired amount of funds under gilts.
*
* It should be at least big enough to ensure that there is no possible storage spam attack
* or queue-filling attack.
**/
minFreeze: BalanceOf & AugmentedConst<ApiType>;
/**
* The base period for the duration queues. This is the common multiple across all
* supported freezing durations that can be bid upon.
**/
period: BlockNumber & AugmentedConst<ApiType>;
/**
* Number of duration queues in total. This sets the maximum duration supported, which is
* this value multiplied by `Period`.
**/
queueCount: u32 & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
identity: {
[key: string]: Codec;
/**
* The amount held on deposit for a registered identity.
* The amount held on deposit for a registered identity
**/
basicDeposit: BalanceOf & AugmentedConst<ApiType>;
/**
@@ -240,70 +334,114 @@ declare module '@polkadot/api/types/consts' {
* another trie item whose value is the size of an account ID plus 32 bytes.
**/
subAccountDeposit: BalanceOf & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
indices: {
[key: string]: Codec;
/**
* The deposit needed for reserving an index.
**/
deposit: BalanceOf & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
lottery: {
[key: string]: Codec;
/**
* The max number of calls available in a single lottery.
**/
maxCalls: u32 & AugmentedConst<ApiType>;
moduleId: ModuleId & AugmentedConst<ApiType>;
/**
* The Lottery's pallet id
**/
palletId: PalletId & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
multisig: {
[key: string]: Codec;
/**
* The base amount of currency needed to reserve for creating a multisig execution or to store
* a dispatch call for later.
*
* This is held for an additional storage item whose value size is
* `4 + sizeof((BlockNumber, Balance, AccountId))` bytes and whose key size is
* `32 + sizeof(AccountId)` bytes.
**/
depositBase: BalanceOf & AugmentedConst<ApiType>;
/**
* The amount of currency needed per unit threshold when creating a multisig execution.
*
* This is held for adding 32 bytes more into a pre-existing storage value.
**/
depositFactor: BalanceOf & AugmentedConst<ApiType>;
/**
* The maximum amount of signatories allowed for a given multisig.
* The maximum amount of signatories allowed in the multisig.
**/
maxSignatories: u16 & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
proxy: {
[key: string]: Codec;
/**
* `AnnouncementDepositBase` metadata shadow.
* The base amount of currency needed to reserve for creating an announcement.
*
* This is held when a new storage item holding a `Balance` is created (typically 16 bytes).
**/
announcementDepositBase: BalanceOf & AugmentedConst<ApiType>;
/**
* `AnnouncementDepositFactor` metadata shadow.
* The amount of currency needed per announcement made.
*
* This is held for adding an `AccountId`, `Hash` and `BlockNumber` (typically 68 bytes)
* into a pre-existing storage value.
**/
announcementDepositFactor: BalanceOf & AugmentedConst<ApiType>;
/**
* `MaxPending` metadata shadow.
* The maximum amount of time-delayed announcements that are allowed to be pending.
**/
maxPending: u32 & AugmentedConst<ApiType>;
/**
* The maximum amount of proxies allowed for a single account.
**/
maxProxies: u16 & AugmentedConst<ApiType>;
maxProxies: u32 & AugmentedConst<ApiType>;
/**
* The base amount of currency needed to reserve for creating a proxy.
*
* This is held for an additional storage item whose value size is
* `sizeof(Balance)` bytes and whose key size is `sizeof(AccountId)` bytes.
**/
proxyDepositBase: BalanceOf & AugmentedConst<ApiType>;
/**
* The amount of currency needed per proxy added.
*
* This is held for adding 32 bytes plus an instance of `ProxyType` more into a pre-existing
* storage value. Thus, when configuring `ProxyDepositFactor` one should take into account
* `32 + proxy_type.encode().len()` bytes of data.
**/
proxyDepositFactor: BalanceOf & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
recovery: {
[key: string]: Codec;
/**
* The base amount of currency needed to reserve for creating a recovery configuration.
*
* This is held for an additional storage item whose value size is
* `2 + sizeof(BlockNumber, Balance)` bytes.
**/
configDepositBase: BalanceOf & AugmentedConst<ApiType>;
/**
* The amount of currency needed per additional user when creating a recovery configuration.
*
* This is held for adding `sizeof(AccountId)` bytes more into a pre-existing storage value.
**/
friendDepositFactor: BalanceOf & AugmentedConst<ApiType>;
/**
@@ -312,11 +450,20 @@ declare module '@polkadot/api/types/consts' {
maxFriends: u16 & AugmentedConst<ApiType>;
/**
* The base amount of currency needed to reserve for starting a recovery.
*
* This is primarily held for deterring malicious recovery attempts, and should
* have a value large enough that a bad actor would choose not to place this
* deposit. It also acts to fund additional storage item whose value size is
* `sizeof(BlockNumber, Balance + T * AccountId)` bytes. Where T is a configurable
* threshold.
**/
recoveryDeposit: BalanceOf & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
society: {
[key: string]: Codec;
/**
* The minimum amount of a deposit required for a bid to be made.
**/
@@ -325,6 +472,10 @@ declare module '@polkadot/api/types/consts' {
* The number of blocks between membership challenges.
**/
challengePeriod: BlockNumber & AugmentedConst<ApiType>;
/**
* Maximum candidate intake per round.
**/
maxCandidateIntake: u32 & AugmentedConst<ApiType>;
/**
* The number of times a member may vote the wrong way (or not at all, when they are a skeptic)
* before they become suspended.
@@ -333,7 +484,7 @@ declare module '@polkadot/api/types/consts' {
/**
* The societies's module id
**/
moduleId: ModuleId & AugmentedConst<ApiType>;
palletId: PalletId & AugmentedConst<ApiType>;
/**
* The amount of incentive paid within each period. Doesn't include VoterTip.
**/
@@ -347,29 +498,17 @@ declare module '@polkadot/api/types/consts' {
* doesn't vote or someone votes in the wrong way.
**/
wrongSideDeduction: BalanceOf & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
staking: {
[key: string]: Codec;
/**
* Number of eras that staked funds must remain bonded for.
**/
bondingDuration: EraIndex & AugmentedConst<ApiType>;
/**
* The number of blocks before the end of the era from which election submissions are allowed.
*
* Setting this to zero will disable the offchain compute and only on-chain seq-phragmen will
* be used.
*
* This is bounded by being within the last session. Hence, setting it to a value more than the
* length of a session will be pointless.
**/
electionLookahead: BlockNumber & AugmentedConst<ApiType>;
/**
* Maximum number of balancing iterations to run in the offchain submission.
*
* If set to 0, balance_solution will not be executed at all.
**/
maxIterations: u32 & AugmentedConst<ApiType>;
maxNominations: u32 & AugmentedConst<ApiType>;
/**
* The maximum number of nominators rewarded for each validator.
*
@@ -377,10 +516,6 @@ declare module '@polkadot/api/types/consts' {
* their reward. This used to limit the i/o cost for the nominator payout.
**/
maxNominatorRewardedPerValidator: u32 & AugmentedConst<ApiType>;
/**
* The threshold of improvement that should be provided for a new solution to be accepted.
**/
minSolutionScoreBump: Perbill & AugmentedConst<ApiType>;
/**
* Number of sessions per era.
**/
@@ -388,14 +523,16 @@ declare module '@polkadot/api/types/consts' {
/**
* Number of eras that slashes are deferred by, after computation.
*
* This should be less than the bonding duration.
* Set to 0 if slashes should be applied immediately, without opportunity for
* intervention.
* This should be less than the bonding duration. Set to 0 if slashes
* should be applied immediately, without opportunity for intervention.
**/
slashDeferDuration: EraIndex & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
system: {
[key: string]: Codec;
/**
* Maximum number of block number to block hash mappings to keep (oldest pruned first).
**/
@@ -419,14 +556,17 @@ declare module '@polkadot/api/types/consts' {
* that the runtime should know about the prefix in order to make use of it as
* an identifier of the chain.
**/
ss58Prefix: u8 & AugmentedConst<ApiType>;
ss58Prefix: u16 & AugmentedConst<ApiType>;
/**
* Get the chain's current version.
**/
version: RuntimeVersion & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
timestamp: {
[key: string]: Codec;
/**
* The minimum period between blocks. Beware that this is different to the *expected* period
* that the block production apparatus provides. Your chosen consensus system will generally
@@ -434,9 +574,12 @@ declare module '@polkadot/api/types/consts' {
* period on default settings.
**/
minimumPeriod: Moment & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
tips: {
[key: string]: Codec;
/**
* The amount held on deposit per byte within the tip report reason.
**/
@@ -457,9 +600,12 @@ declare module '@polkadot/api/types/consts' {
* The amount held on deposit for placing a tip report.
**/
tipReportDepositBase: BalanceOf & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
transactionPayment: {
[key: string]: Codec;
/**
* The fee to be paid for making a transaction; the per-byte portion.
**/
@@ -468,9 +614,12 @@ declare module '@polkadot/api/types/consts' {
* The polynomial that is applied in order to derive fee from weight.
**/
weightToFee: Vec<WeightToFeeCoefficient> & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
treasury: {
[key: string]: Codec;
/**
* Percentage of spare funds (if any) that are burnt per spend period.
**/
@@ -478,7 +627,7 @@ declare module '@polkadot/api/types/consts' {
/**
* The treasury's module id, used for deriving its sovereign account ID.
**/
moduleId: ModuleId & AugmentedConst<ApiType>;
palletId: PalletId & AugmentedConst<ApiType>;
/**
* Fraction of a proposal's value that should be bonded in order to place the proposal.
* An accepted proposal gets these back. A rejected proposal does not.
@@ -492,13 +641,20 @@ declare module '@polkadot/api/types/consts' {
* Period between successive spends.
**/
spendPeriod: BlockNumber & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
vesting: {
[key: string]: Codec;
/**
* The minimum amount to be transferred to create a new vesting schedule.
* The minimum amount transferred to call `vested_transfer`.
**/
minVestedTransfer: BalanceOf & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
}
+407 -122
View File
@@ -6,19 +6,10 @@ import type { ApiTypes } from '@polkadot/api/types';
declare module '@polkadot/api/types/errors' {
export interface AugmentedErrors<ApiType> {
assets: {
[key: string]: AugmentedError<ApiType>;
/**
* Transfer amount should be non-zero.
**/
AmountZero: AugmentedError<ApiType>;
/**
* Invalid metadata given.
**/
BadMetadata: AugmentedError<ApiType>;
/**
* Some internal state is broken.
**/
BadState: AugmentedError<ApiType>;
/**
* Invalid witness data given.
**/
@@ -48,24 +39,27 @@ declare module '@polkadot/api/types/errors' {
**/
NoPermission: AugmentedError<ApiType>;
/**
* A mint operation lead to an overflow.
* No provider reference exists to allow a non-zero balance of a non-self-sufficient asset.
**/
Overflow: AugmentedError<ApiType>;
NoProvider: AugmentedError<ApiType>;
/**
* Attempt to destroy an asset class when non-zombie, reference-bearing accounts exist.
* No approval exists that would allow the transfer.
**/
RefsLeft: AugmentedError<ApiType>;
/**
* Too many zombie accounts in use.
**/
TooManyZombies: AugmentedError<ApiType>;
Unapproved: AugmentedError<ApiType>;
/**
* The given asset ID is unknown.
**/
Unknown: AugmentedError<ApiType>;
/**
* The source account would not survive the transfer and it needs to stay alive.
**/
WouldDie: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
authorship: {
[key: string]: AugmentedError<ApiType>;
/**
* The uncle is genesis.
**/
@@ -94,9 +88,30 @@ declare module '@polkadot/api/types/errors' {
* Uncles already set in the block.
**/
UnclesAlreadySet: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
babe: {
/**
* A given equivocation report is valid but already previously reported.
**/
DuplicateOffenceReport: AugmentedError<ApiType>;
/**
* An equivocation proof provided as part of an equivocation report is invalid.
**/
InvalidEquivocationProof: AugmentedError<ApiType>;
/**
* A key ownership proof provided as part of an equivocation report is invalid.
**/
InvalidKeyOwnershipProof: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
balances: {
[key: string]: AugmentedError<ApiType>;
/**
* Beneficiary account must pre-exist
**/
@@ -122,16 +137,19 @@ declare module '@polkadot/api/types/errors' {
**/
LiquidityRestrictions: AugmentedError<ApiType>;
/**
* Got an overflow after adding
* Number of named reserves exceed MaxReserves
**/
Overflow: AugmentedError<ApiType>;
TooManyReserves: AugmentedError<ApiType>;
/**
* Vesting balance too high to send value
**/
VestingBalance: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
bounties: {
[key: string]: AugmentedError<ApiType>;
/**
* Proposer's balance is too low.
**/
@@ -169,9 +187,12 @@ declare module '@polkadot/api/types/errors' {
* The bounty status is unexpected.
**/
UnexpectedStatus: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
contracts: {
[key: string]: AugmentedError<ApiType>;
/**
* Performing the requested transfer would have brought the contract below
* the subsistence threshold. No transfer is allowed to do this in order to allow
@@ -188,6 +209,13 @@ declare module '@polkadot/api/types/errors' {
* current schedule.
**/
CodeTooLarge: AugmentedError<ApiType>;
/**
* A tombstone exist at the specified address.
*
* Tombstone cannot be called. Anyone can use `seal_restore_to` in order to revive
* the contract, though.
**/
ContractIsTombstone: AugmentedError<ApiType>;
/**
* A contract could not be evicted because it has enough balance to pay rent.
*
@@ -195,10 +223,18 @@ declare module '@polkadot/api/types/errors' {
* contract has enough balance to pay for its rent.
**/
ContractNotEvictable: AugmentedError<ApiType>;
/**
* No contract was found at the specified address.
**/
ContractNotFound: AugmentedError<ApiType>;
/**
* Contract trapped during execution.
**/
ContractTrapped: AugmentedError<ApiType>;
/**
* The debug message specified to `seal_debug_message` does contain invalid UTF-8.
**/
DebugMessageInvalidUTF8: AugmentedError<ApiType>;
/**
* Input passed to a contract API function failed to decode as expected type.
**/
@@ -220,9 +256,9 @@ declare module '@polkadot/api/types/errors' {
**/
DuplicateTopics: AugmentedError<ApiType>;
/**
* `seal_input` was called twice from the same contract execution context.
* `seal_call` forwarded this contracts input. It therefore is no longer available.
**/
InputAlreadyRead: AugmentedError<ApiType>;
InputForwarded: AugmentedError<ApiType>;
/**
* An origin TrieId written in the current block.
**/
@@ -263,11 +299,6 @@ declare module '@polkadot/api/types/errors' {
* is rejected.
**/
NoChainExtension: AugmentedError<ApiType>;
/**
* The contract that was called is either no contract at all (a plain account)
* or is a tombstone.
**/
NotCallable: AugmentedError<ApiType>;
/**
* A buffer outside of sandbox memory was passed to a contract API function.
**/
@@ -285,11 +316,18 @@ declare module '@polkadot/api/types/errors' {
**/
RandomSubjectTooLong: AugmentedError<ApiType>;
/**
* The action performed is not allowed while the contract performing it is already
* on the call stack. Those actions are contract self destruction and restoration
* of a tombstone.
* A call tried to invoke a contract that is flagged as non-reentrant.
**/
ReentranceDenied: AugmentedError<ApiType>;
/**
* The called contract does not have enough balance to pay for its storage.
*
* The contract ran out of balance and is therefore eligible for eviction into a
* tombstone. Anyone can evict the contract by submitting a `claim_surcharge`
* extrinsic. Alternatively, a plain balance transfer can be used in order to
* increase the contracts funds so that it can be called again.
**/
RentNotPaid: AugmentedError<ApiType>;
/**
* A storage modification exhausted the 32bit type that holds the storage size.
*
@@ -297,6 +335,17 @@ declare module '@polkadot/api/types/errors' {
* when number of storage items is too large.
**/
StorageExhausted: AugmentedError<ApiType>;
/**
* A contract self destructed in its constructor.
*
* This can be triggered by a call to `seal_terminate` or `seal_restore_to`.
**/
TerminatedInConstructor: AugmentedError<ApiType>;
/**
* Termination of a contract is not allowed while the contract is already
* on the call stack. Can be triggered by `seal_terminate` or `seal_restore_to.
**/
TerminatedWhileReentrant: AugmentedError<ApiType>;
/**
* The amount of topics passed to `seal_deposit_events` exceeds the limit.
**/
@@ -311,9 +360,12 @@ declare module '@polkadot/api/types/errors' {
* The size defined in `T::MaxValueSize` was exceeded.
**/
ValueTooLarge: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
council: {
[key: string]: AugmentedError<ApiType>;
/**
* Members are already initialized!
**/
@@ -354,9 +406,12 @@ declare module '@polkadot/api/types/errors' {
* The given weight bound for the proposal was too low.
**/
WrongProposalWeight: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
democracy: {
[key: string]: AugmentedError<ApiType>;
/**
* Cannot cancel the same proposal twice
**/
@@ -449,10 +504,6 @@ declare module '@polkadot/api/types/errors' {
* The given account did not vote on the referendum.
**/
NotVoter: AugmentedError<ApiType>;
/**
* An unexpected integer overflow occurred.
**/
Overflow: AugmentedError<ApiType>;
/**
* Invalid preimage
**/
@@ -481,10 +532,6 @@ declare module '@polkadot/api/types/errors' {
* Maximum number of proposals reached.
**/
TooManyProposals: AugmentedError<ApiType>;
/**
* An unexpected integer underflow occurred.
**/
Underflow: AugmentedError<ApiType>;
/**
* Value too low
**/
@@ -498,9 +545,20 @@ declare module '@polkadot/api/types/errors' {
* Invalid upper bound.
**/
WrongUpperBound: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
electionProviderMultiPhase: {
[key: string]: AugmentedError<ApiType>;
/**
* The call is not allowed at this point.
**/
CallNotAllowed: AugmentedError<ApiType>;
/**
* OCW submitted solution for wrong round
**/
OcwCallWrongEra: AugmentedError<ApiType>;
/**
* Submission was too early.
**/
@@ -513,9 +571,12 @@ declare module '@polkadot/api/types/errors' {
* Wrong number of winners presented.
**/
PreDispatchWrongWinnerCount: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
elections: {
[key: string]: AugmentedError<ApiType>;
/**
* Duplicated candidate submission.
**/
@@ -584,9 +645,51 @@ declare module '@polkadot/api/types/errors' {
* Cannot vote when no candidates or members exist.
**/
UnableToVote: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
gilt: {
/**
* The amount of the bid is less than the minimum allowed.
**/
AmountTooSmall: AugmentedError<ApiType>;
/**
* The queue for the bid's duration is full and the amount bid is too low to get in through
* replacing an existing bid.
**/
BidTooLow: AugmentedError<ApiType>;
/**
* The duration is the bid is greater than the number of queues.
**/
DurationTooBig: AugmentedError<ApiType>;
/**
* The duration of the bid is less than one.
**/
DurationTooSmall: AugmentedError<ApiType>;
/**
* Gilt not yet at expiry date.
**/
NotExpired: AugmentedError<ApiType>;
/**
* The given bid for retraction is not found.
**/
NotFound: AugmentedError<ApiType>;
/**
* Not the owner of the gilt.
**/
NotOwner: AugmentedError<ApiType>;
/**
* Gilt index is unknown.
**/
Unknown: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
grandpa: {
[key: string]: AugmentedError<ApiType>;
/**
* Attempt to signal GRANDPA change with one already pending.
**/
@@ -617,9 +720,12 @@ declare module '@polkadot/api/types/errors' {
* Cannot signal forced change so soon after last.
**/
TooSoon: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
identity: {
[key: string]: AugmentedError<ApiType>;
/**
* Account ID is already named.
**/
@@ -684,9 +790,12 @@ declare module '@polkadot/api/types/errors' {
* Too many subs-accounts.
**/
TooManySubAccounts: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
imOnline: {
[key: string]: AugmentedError<ApiType>;
/**
* Duplicated heartbeat.
**/
@@ -695,9 +804,72 @@ declare module '@polkadot/api/types/errors' {
* Non existent public key.
**/
InvalidKey: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
indices: {
/**
* The index was not available.
**/
InUse: AugmentedError<ApiType>;
/**
* The index was not already assigned.
**/
NotAssigned: AugmentedError<ApiType>;
/**
* The index is assigned to another account.
**/
NotOwner: AugmentedError<ApiType>;
/**
* The source and destination accounts are identical.
**/
NotTransfer: AugmentedError<ApiType>;
/**
* The index is permanent and may not be freed/changed.
**/
Permanent: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
lottery: {
/**
* A lottery has already ended.
**/
AlreadyEnded: AugmentedError<ApiType>;
/**
* You are already participating in the lottery with this call.
**/
AlreadyParticipating: AugmentedError<ApiType>;
/**
* Failed to encode calls
**/
EncodingFailed: AugmentedError<ApiType>;
/**
* A lottery is already in progress.
**/
InProgress: AugmentedError<ApiType>;
/**
* The call is not valid for an open lottery.
**/
InvalidCall: AugmentedError<ApiType>;
/**
* A lottery has not been configured.
**/
NotConfigured: AugmentedError<ApiType>;
/**
* Too many calls for a single lottery.
**/
TooManyCalls: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
multisig: {
[key: string]: AugmentedError<ApiType>;
/**
* Call is already approved by this signatory.
**/
@@ -754,9 +926,12 @@ declare module '@polkadot/api/types/errors' {
* A different timepoint was given to the multisig operation that is underway.
**/
WrongTimepoint: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
proxy: {
[key: string]: AugmentedError<ApiType>;
/**
* Account is already a proxy.
**/
@@ -789,9 +964,12 @@ declare module '@polkadot/api/types/errors' {
* A call which is incompatible with the proxy type's filter was attempted.
**/
Unproxyable: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
recovery: {
[key: string]: AugmentedError<ApiType>;
/**
* This account is already set up for recovery
**/
@@ -844,10 +1022,6 @@ declare module '@polkadot/api/types/errors' {
* A recovery process has not started for this rescuer
**/
NotStarted: AugmentedError<ApiType>;
/**
* There was an overflow in a calculation
**/
Overflow: AugmentedError<ApiType>;
/**
* There are still active recovery attempts that need to be closed
**/
@@ -860,9 +1034,12 @@ declare module '@polkadot/api/types/errors' {
* Threshold must be greater than zero
**/
ZeroThreshold: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
scheduler: {
[key: string]: AugmentedError<ApiType>;
/**
* Failed to schedule a call
**/
@@ -879,9 +1056,12 @@ declare module '@polkadot/api/types/errors' {
* Given target block number is in the past.
**/
TargetBlockNumberInPast: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
session: {
[key: string]: AugmentedError<ApiType>;
/**
* Registered duplicate key.
**/
@@ -902,9 +1082,12 @@ declare module '@polkadot/api/types/errors' {
* No keys are associated with this account.
**/
NoKeys: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
society: {
[key: string]: AugmentedError<ApiType>;
/**
* User has already made a bid.
**/
@@ -977,9 +1160,12 @@ declare module '@polkadot/api/types/errors' {
* User is suspended.
**/
Suspended: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
staking: {
[key: string]: AugmentedError<ApiType>;
/**
* Stash is already bonded.
**/
@@ -1001,9 +1187,9 @@ declare module '@polkadot/api/types/errors' {
**/
BadTarget: AugmentedError<ApiType>;
/**
* The call is not allowed at the given time due to restrictions of election period.
* The user has enough bond and thus cannot be chilled forcefully by an external person.
**/
CallNotAllowed: AugmentedError<ApiType>;
CannotChillOther: AugmentedError<ApiType>;
/**
* Duplicate index.
**/
@@ -1025,9 +1211,9 @@ declare module '@polkadot/api/types/errors' {
**/
IncorrectSlashingSpans: AugmentedError<ApiType>;
/**
* Can not bond with value less than minimum balance.
* Can not bond with value less than minimum required.
**/
InsufficientValue: AugmentedError<ApiType>;
InsufficientBond: AugmentedError<ApiType>;
/**
* Invalid era to reward.
**/
@@ -1061,74 +1247,35 @@ declare module '@polkadot/api/types/errors' {
**/
NoUnlockChunk: AugmentedError<ApiType>;
/**
* Error while building the assignment type from the compact. This can happen if an index
* is invalid, or if the weights _overflow_.
* There are too many nominators in the system. Governance needs to adjust the staking settings
* to keep things safe for the runtime.
**/
OffchainElectionBogusCompact: AugmentedError<ApiType>;
/**
* The submitted result has unknown edges that are not among the presented winners.
**/
OffchainElectionBogusEdge: AugmentedError<ApiType>;
/**
* The election size is invalid.
**/
OffchainElectionBogusElectionSize: AugmentedError<ApiType>;
/**
* One of the submitted nominators has an edge to which they have not voted on chain.
**/
OffchainElectionBogusNomination: AugmentedError<ApiType>;
/**
* One of the submitted nominators is not an active nominator on chain.
**/
OffchainElectionBogusNominator: AugmentedError<ApiType>;
/**
* The claimed score does not match with the one computed from the data.
**/
OffchainElectionBogusScore: AugmentedError<ApiType>;
/**
* A self vote must only be originated from a validator to ONLY themselves.
**/
OffchainElectionBogusSelfVote: AugmentedError<ApiType>;
/**
* One of the submitted winners is not an active candidate on chain (index is out of range
* in snapshot).
**/
OffchainElectionBogusWinner: AugmentedError<ApiType>;
/**
* Incorrect number of winners were presented.
**/
OffchainElectionBogusWinnerCount: AugmentedError<ApiType>;
/**
* The submitted result is received out of the open window.
**/
OffchainElectionEarlySubmission: AugmentedError<ApiType>;
/**
* One of the submitted nominators has an edge which is submitted before the last non-zero
* slash of the target.
**/
OffchainElectionSlashedNomination: AugmentedError<ApiType>;
/**
* The submitted result is not as good as the one stored on chain.
**/
OffchainElectionWeakSubmission: AugmentedError<ApiType>;
/**
* The snapshot data of the current window is missing.
**/
SnapshotUnavailable: AugmentedError<ApiType>;
TooManyNominators: AugmentedError<ApiType>;
/**
* Too many nomination targets supplied.
**/
TooManyTargets: AugmentedError<ApiType>;
/**
* There are too many validators in the system. Governance needs to adjust the staking settings
* to keep things safe for the runtime.
**/
TooManyValidators: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
sudo: {
[key: string]: AugmentedError<ApiType>;
/**
* Sender must be the Sudo account
**/
RequireSudo: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
system: {
[key: string]: AugmentedError<ApiType>;
/**
* Failed to extract the runtime version from the new runtime.
*
@@ -1153,9 +1300,12 @@ declare module '@polkadot/api/types/errors' {
* and the new runtime.
**/
SpecVersionNeedsToIncrease: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
technicalCommittee: {
[key: string]: AugmentedError<ApiType>;
/**
* Members are already initialized!
**/
@@ -1196,9 +1346,26 @@ declare module '@polkadot/api/types/errors' {
* The given weight bound for the proposal was too low.
**/
WrongProposalWeight: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
technicalMembership: {
/**
* Already a member.
**/
AlreadyMember: AugmentedError<ApiType>;
/**
* Not a member.
**/
NotMember: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
tips: {
[key: string]: AugmentedError<ApiType>;
/**
* The tip was already found/started.
**/
@@ -1223,9 +1390,70 @@ declare module '@polkadot/api/types/errors' {
* The tip hash is unknown.
**/
UnknownTip: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
transactionStorage: {
/**
* Attempted to call `store` outside of block execution.
**/
BadContext: AugmentedError<ApiType>;
/**
* Double proof check in the block.
**/
DoubleCheck: AugmentedError<ApiType>;
/**
* Attempting to store empty transaction
**/
EmptyTransaction: AugmentedError<ApiType>;
/**
* Insufficient account balance.
**/
InsufficientFunds: AugmentedError<ApiType>;
/**
* Proof failed verification.
**/
InvalidProof: AugmentedError<ApiType>;
/**
* Missing storage proof.
**/
MissingProof: AugmentedError<ApiType>;
/**
* Unable to verify proof becasue state data is missing.
**/
MissingStateData: AugmentedError<ApiType>;
/**
* Invalid configuration.
**/
NotConfigured: AugmentedError<ApiType>;
/**
* Storage proof was not checked in the block.
**/
ProofNotChecked: AugmentedError<ApiType>;
/**
* Renewed extrinsic is not found.
**/
RenewedNotFound: AugmentedError<ApiType>;
/**
* Too many transactions in the block.
**/
TooManyTransactions: AugmentedError<ApiType>;
/**
* Transaction is too large.
**/
TransactionTooLarge: AugmentedError<ApiType>;
/**
* Proof was not expected in this block.
**/
UnexpectedProof: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
treasury: {
[key: string]: AugmentedError<ApiType>;
/**
* Proposer's balance is too low.
**/
@@ -1234,9 +1462,62 @@ declare module '@polkadot/api/types/errors' {
* No proposal or bounty at that index.
**/
InvalidIndex: AugmentedError<ApiType>;
/**
* Too many approvals in the queue.
**/
TooManyApprovals: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
uniques: {
/**
* The asset instance ID has already been used for an asset.
**/
AlreadyExists: AugmentedError<ApiType>;
/**
* Invalid witness data given.
**/
BadWitness: AugmentedError<ApiType>;
/**
* The asset instance or class is frozen.
**/
Frozen: AugmentedError<ApiType>;
/**
* The asset ID is already taken.
**/
InUse: AugmentedError<ApiType>;
/**
* There is no delegate approved.
**/
NoDelegate: AugmentedError<ApiType>;
/**
* The signing account has no permission to do the operation.
**/
NoPermission: AugmentedError<ApiType>;
/**
* No approval exists that would allow the transfer.
**/
Unapproved: AugmentedError<ApiType>;
/**
* The given asset ID is unknown.
**/
Unknown: AugmentedError<ApiType>;
/**
* The delegate turned out to be different to what was expected.
**/
WrongDelegate: AugmentedError<ApiType>;
/**
* The owner turned out to be different to what was expected.
**/
WrongOwner: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
vesting: {
[key: string]: AugmentedError<ApiType>;
/**
* Amount being transferred is too low to create a vesting schedule.
**/
@@ -1249,6 +1530,10 @@ declare module '@polkadot/api/types/errors' {
* The account given is not vesting.
**/
NotVesting: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
}
+306 -50
View File
@@ -9,28 +9,44 @@ import type { MemberCount, ProposalIndex } from '@polkadot/types/interfaces/coll
import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
import type { PropIndex, ReferendumIndex } from '@polkadot/types/interfaces/democracy';
import type { VoteThreshold } from '@polkadot/types/interfaces/elections';
import type { ActiveIndex } from '@polkadot/types/interfaces/gilt';
import type { AuthorityList } from '@polkadot/types/interfaces/grandpa';
import type { RegistrarIndex } from '@polkadot/types/interfaces/identity';
import type { CallIndex } from '@polkadot/types/interfaces/lottery';
import type { Kind, OpaqueTimeSlot } from '@polkadot/types/interfaces/offences';
import type { ProxyType } from '@polkadot/types/interfaces/proxy';
import type { AccountId, AccountIndex, AssetId, Balance, BlockNumber, CallHash, Hash, PhantomData } from '@polkadot/types/interfaces/runtime';
import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber, CallHash, Hash, PhantomData } from '@polkadot/types/interfaces/runtime';
import type { TaskAddress } from '@polkadot/types/interfaces/scheduler';
import type { IdentificationTuple, SessionIndex } from '@polkadot/types/interfaces/session';
import type { ElectionCompute, EraIndex } from '@polkadot/types/interfaces/staking';
import type { DispatchError, DispatchInfo, DispatchResult } from '@polkadot/types/interfaces/system';
import type { BountyIndex } from '@polkadot/types/interfaces/treasury';
import type { ClassId, InstanceId } from '@polkadot/types/interfaces/uniques';
import type { Timepoint } from '@polkadot/types/interfaces/utility';
import type { ApiTypes } from '@polkadot/api/types';
declare module '@polkadot/api/types/events' {
export interface AugmentedEvents<ApiType> {
assets: {
[key: string]: AugmentedEvent<ApiType>;
/**
* An approval for account `delegate` was cancelled by `owner`.
* \[id, owner, delegate\]
**/
ApprovalCancelled: AugmentedEvent<ApiType, [AssetId, AccountId, AccountId]>;
/**
* (Additional) funds have been approved for transfer to a destination account.
* \[asset_id, source, delegate, amount\]
**/
ApprovedTransfer: AugmentedEvent<ApiType, [AssetId, AccountId, AccountId, TAssetBalance]>;
/**
* Some asset `asset_id` was frozen. \[asset_id\]
**/
AssetFrozen: AugmentedEvent<ApiType, [AssetId]>;
/**
* An asset has had its attributes changed by the `Force` origin.
* \[id\]
**/
AssetStatusChanged: AugmentedEvent<ApiType, [AssetId]>;
/**
* Some asset `asset_id` was thawed. \[asset_id\]
**/
@@ -51,10 +67,6 @@ declare module '@polkadot/api/types/events' {
* Some asset class was force-created. \[asset_id, owner\]
**/
ForceCreated: AugmentedEvent<ApiType, [AssetId, AccountId]>;
/**
* Some assets was transferred by an admin. \[asset_id, from, to, amount\]
**/
ForceTransferred: AugmentedEvent<ApiType, [AssetId, AccountId, AccountId, TAssetBalance]>;
/**
* Some account `who` was frozen. \[asset_id, who\]
**/
@@ -64,13 +76,13 @@ declare module '@polkadot/api/types/events' {
**/
Issued: AugmentedEvent<ApiType, [AssetId, AccountId, TAssetBalance]>;
/**
* The maximum amount of zombies allowed has changed. \[asset_id, max_zombies\]
* Metadata has been cleared for an asset. \[asset_id\]
**/
MaxZombiesChanged: AugmentedEvent<ApiType, [AssetId, u32]>;
MetadataCleared: AugmentedEvent<ApiType, [AssetId]>;
/**
* New metadata has been set for an asset. \[asset_id, name, symbol, decimals\]
* New metadata has been set for an asset. \[asset_id, name, symbol, decimals, is_frozen\]
**/
MetadataSet: AugmentedEvent<ApiType, [AssetId, Bytes, Bytes, u8]>;
MetadataSet: AugmentedEvent<ApiType, [AssetId, Bytes, Bytes, u8, bool]>;
/**
* The owner changed \[asset_id, owner\]
**/
@@ -87,9 +99,18 @@ declare module '@polkadot/api/types/events' {
* Some assets were transferred. \[asset_id, from, to, amount\]
**/
Transferred: AugmentedEvent<ApiType, [AssetId, AccountId, AccountId, TAssetBalance]>;
/**
* An `amount` was transferred in its entirety from `owner` to `destination` by
* the approved `delegate`.
* \[id, owner, delegate, destination\]
**/
TransferredApproved: AugmentedEvent<ApiType, [AssetId, AccountId, AccountId, AccountId, TAssetBalance]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
balances: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A balance was set by root. \[who, free, reserved\]
**/
@@ -125,9 +146,12 @@ declare module '@polkadot/api/types/events' {
* Some balance was unreserved (moved from reserved to free). \[who, value\]
**/
Unreserved: AugmentedEvent<ApiType, [AccountId, Balance]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
bounties: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A bounty is awarded to a beneficiary. \[index, beneficiary\]
**/
@@ -156,9 +180,12 @@ declare module '@polkadot/api/types/events' {
* A bounty proposal was rejected; funds were slashed. \[index, bond\]
**/
BountyRejected: AugmentedEvent<ApiType, [BountyIndex, Balance]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
contracts: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A code with the specified hash was removed.
* \[code_hash\]
@@ -225,9 +252,12 @@ declare module '@polkadot/api/types/events' {
* this event is by calling `seal_terminate`.
**/
Terminated: AugmentedEvent<ApiType, [AccountId, AccountId]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
council: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A motion was approved by the required threshold.
* \[proposal_hash\]
@@ -265,9 +295,12 @@ declare module '@polkadot/api/types/events' {
* \[account, proposal_hash, voted, yes, no\]
**/
Voted: AugmentedEvent<ApiType, [AccountId, Hash, bool, MemberCount, MemberCount]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
democracy: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A proposal \[hash\] has been blacklisted permanently.
**/
@@ -344,9 +377,12 @@ declare module '@polkadot/api/types/events' {
* An external proposal has been vetoed. \[who, proposal_hash, until\]
**/
Vetoed: AugmentedEvent<ApiType, [AccountId, Hash, BlockNumber]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
electionProviderMultiPhase: {
[key: string]: AugmentedEvent<ApiType>;
/**
* The election has been finalized, with `Some` of the given computation, or else if the
* election failed, `None`.
@@ -375,9 +411,12 @@ declare module '@polkadot/api/types/events' {
* The unsigned phase of the given round has started.
**/
UnsignedPhaseStarted: AugmentedEvent<ApiType, [u32]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
elections: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A \[candidate\] was slashed by \[amount\] due to failing to obtain a seat as member or
* runner-up.
@@ -400,10 +439,11 @@ declare module '@polkadot/api/types/events' {
**/
MemberKicked: AugmentedEvent<ApiType, [AccountId]>;
/**
* A new term with \[new_members\]. This indicates that enough candidates existed to run the
* election, not that enough have has been elected. The inner value must be examined for
* this purpose. A `NewTerm(\[\])` indicates that some candidates got their bond slashed and
* none were elected, whilst `EmptyTerm` means that no candidates existed to begin with.
* A new term with \[new_members\]. This indicates that enough candidates existed to run
* the election, not that enough have has been elected. The inner value must be examined
* for this purpose. A `NewTerm(\[\])` indicates that some candidates got their bond
* slashed and none were elected, whilst `EmptyTerm` means that no candidates existed to
* begin with.
**/
NewTerm: AugmentedEvent<ApiType, [Vec<ITuple<[AccountId, Balance]>>]>;
/**
@@ -414,9 +454,38 @@ declare module '@polkadot/api/types/events' {
* A \[seat holder\] was slashed by \[amount\] by being forcefully removed from the set.
**/
SeatHolderSlashed: AugmentedEvent<ApiType, [AccountId, Balance]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
gilt: {
/**
* A bid was successfully placed.
* \[ who, amount, duration \]
**/
BidPlaced: AugmentedEvent<ApiType, [AccountId, BalanceOf, u32]>;
/**
* A bid was successfully removed (before being accepted as a gilt).
* \[ who, amount, duration \]
**/
BidRetracted: AugmentedEvent<ApiType, [AccountId, BalanceOf, u32]>;
/**
* A bid was accepted as a gilt. The balance may not be released until expiry.
* \[ index, expiry, who, amount \]
**/
GiltIssued: AugmentedEvent<ApiType, [ActiveIndex, BlockNumber, AccountId, BalanceOf]>;
/**
* An expired gilt has been thawed.
* \[ index, who, original_amount, additional_amount \]
**/
GiltThawed: AugmentedEvent<ApiType, [ActiveIndex, AccountId, BalanceOf, BalanceOf]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
grandpa: {
[key: string]: AugmentedEvent<ApiType>;
/**
* New authority set has been applied. \[authority_set\]
**/
@@ -429,9 +498,12 @@ declare module '@polkadot/api/types/events' {
* Current authority set has been resumed.
**/
Resumed: AugmentedEvent<ApiType, []>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
identity: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A name was cleared, and the given balance returned. \[who, deposit\]
**/
@@ -474,9 +546,12 @@ declare module '@polkadot/api/types/events' {
* main identity account to the sub-identity account. \[sub, main, deposit\]
**/
SubIdentityRevoked: AugmentedEvent<ApiType, [AccountId, AccountId, Balance]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
imOnline: {
[key: string]: AugmentedEvent<ApiType>;
/**
* At the end of the session, no offence was committed.
**/
@@ -489,9 +564,12 @@ declare module '@polkadot/api/types/events' {
* At the end of the session, at least one validator was found to be \[offline\].
**/
SomeOffline: AugmentedEvent<ApiType, [Vec<IdentificationTuple>]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
indices: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A account index was assigned. \[index, who\]
**/
@@ -504,9 +582,12 @@ declare module '@polkadot/api/types/events' {
* A account index has been frozen to its current account ID. \[index, who\]
**/
IndexFrozen: AugmentedEvent<ApiType, [AccountIndex, AccountId]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
lottery: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A new set of calls have been set!
**/
@@ -523,9 +604,12 @@ declare module '@polkadot/api/types/events' {
* A winner has been chosen!
**/
Winner: AugmentedEvent<ApiType, [AccountId, Balance]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
multisig: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A multisig operation has been approved by someone.
* \[approving, timepoint, multisig, call_hash\]
@@ -543,19 +627,24 @@ declare module '@polkadot/api/types/events' {
* A new multisig operation has begun. \[approving, multisig, call_hash\]
**/
NewMultisig: AugmentedEvent<ApiType, [AccountId, AccountId, CallHash]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
offences: {
[key: string]: AugmentedEvent<ApiType>;
/**
* There is an offence reported of the given `kind` happened at the `session_index` and
* (kind-specific) time slot. This event is not deposited for duplicate slashes. last
* element indicates of the offence was applied (true) or queued (false)
* \[kind, timeslot, applied\].
* (kind-specific) time slot. This event is not deposited for duplicate slashes.
* \[kind, timeslot\].
**/
Offence: AugmentedEvent<ApiType, [Kind, OpaqueTimeSlot, bool]>;
Offence: AugmentedEvent<ApiType, [Kind, OpaqueTimeSlot]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
proxy: {
[key: string]: AugmentedEvent<ApiType>;
/**
* An announcement was placed to make a call in the future. \[real, proxy, call_hash\]
**/
@@ -569,9 +658,12 @@ declare module '@polkadot/api/types/events' {
* A proxy was executed correctly, with the given \[result\].
**/
ProxyExecuted: AugmentedEvent<ApiType, [DispatchResult]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
recovery: {
[key: string]: AugmentedEvent<ApiType>;
/**
* Lost account has been successfully recovered by rescuer account.
* \[lost, rescuer\]
@@ -600,9 +692,12 @@ declare module '@polkadot/api/types/events' {
* \[lost, rescuer, sender\]
**/
RecoveryVouched: AugmentedEvent<ApiType, [AccountId, AccountId, AccountId]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
scheduler: {
[key: string]: AugmentedEvent<ApiType>;
/**
* Canceled some task. \[when, index\]
**/
@@ -615,17 +710,23 @@ declare module '@polkadot/api/types/events' {
* Scheduled some task. \[when, index\]
**/
Scheduled: AugmentedEvent<ApiType, [BlockNumber, u32]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
session: {
[key: string]: AugmentedEvent<ApiType>;
/**
* New session has happened. Note that the argument is the \[session_index\], not the block
* number as the type might suggest.
**/
NewSession: AugmentedEvent<ApiType, [SessionIndex]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
society: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A \[candidate\] was dropped (due to an excess of bids in the system).
**/
@@ -693,9 +794,12 @@ declare module '@polkadot/api/types/events' {
* their offer is the second. The vouching party is the third. \[candidate_id, offer, vouching\]
**/
Vouch: AugmentedEvent<ApiType, [AccountId, Balance, AccountId]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
staking: {
[key: string]: AugmentedEvent<ApiType>;
/**
* An account has bonded this amount. \[stash, amount\]
*
@@ -728,13 +832,13 @@ declare module '@polkadot/api/types/events' {
**/
Slash: AugmentedEvent<ApiType, [AccountId, Balance]>;
/**
* A new solution for the upcoming election has been stored. \[compute\]
* A new set of stakers was elected.
**/
SolutionStored: AugmentedEvent<ApiType, [ElectionCompute]>;
StakingElection: AugmentedEvent<ApiType, []>;
/**
* A new set of stakers was elected with the given \[compute\].
* The election failed. No new era is planned.
**/
StakingElection: AugmentedEvent<ApiType, [ElectionCompute]>;
StakingElectionFailed: AugmentedEvent<ApiType, []>;
/**
* An account has unbonded this amount. \[stash, amount\]
**/
@@ -744,9 +848,12 @@ declare module '@polkadot/api/types/events' {
* from the unlocking queue. \[stash, amount\]
**/
Withdrawn: AugmentedEvent<ApiType, [AccountId, Balance]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
sudo: {
[key: string]: AugmentedEvent<ApiType>;
/**
* The \[sudoer\] just switched identity; the old key is supplied.
**/
@@ -759,9 +866,12 @@ declare module '@polkadot/api/types/events' {
* A sudo just took place. \[result\]
**/
SudoAsDone: AugmentedEvent<ApiType, [DispatchResult]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
system: {
[key: string]: AugmentedEvent<ApiType>;
/**
* `:code` was updated.
**/
@@ -782,9 +892,16 @@ declare module '@polkadot/api/types/events' {
* A new \[account\] was created.
**/
NewAccount: AugmentedEvent<ApiType, [AccountId]>;
/**
* On on-chain remark happened. \[origin, remark_hash\]
**/
Remarked: AugmentedEvent<ApiType, [AccountId, Hash]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
technicalCommittee: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A motion was approved by the required threshold.
* \[proposal_hash\]
@@ -822,9 +939,12 @@ declare module '@polkadot/api/types/events' {
* \[account, proposal_hash, voted, yes, no\]
**/
Voted: AugmentedEvent<ApiType, [AccountId, Hash, bool, MemberCount, MemberCount]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
technicalMembership: {
[key: string]: AugmentedEvent<ApiType>;
/**
* Phantom member, never used.
**/
@@ -849,9 +969,12 @@ declare module '@polkadot/api/types/events' {
* Two members were swapped; see the transaction for who.
**/
MembersSwapped: AugmentedEvent<ApiType, []>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
tips: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A new tip suggestion has been opened. \[tip_hash\]
**/
@@ -872,9 +995,30 @@ declare module '@polkadot/api/types/events' {
* A tip suggestion has been slashed. \[tip_hash, finder, deposit\]
**/
TipSlashed: AugmentedEvent<ApiType, [Hash, AccountId, Balance]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
transactionStorage: {
/**
* Storage proof was successfully checked.
**/
ProofChecked: AugmentedEvent<ApiType, []>;
/**
* Renewed data under specified index.
**/
Renewed: AugmentedEvent<ApiType, [u32]>;
/**
* Stored data under specified index.
**/
Stored: AugmentedEvent<ApiType, [u32]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
treasury: {
[key: string]: AugmentedEvent<ApiType>;
/**
* Some funds have been allocated. \[proposal_index, award, beneficiary\]
**/
@@ -904,9 +1048,114 @@ declare module '@polkadot/api/types/events' {
* We have ended a spend period and will now allocate funds. \[budget_remaining\]
**/
Spending: AugmentedEvent<ApiType, [Balance]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
uniques: {
/**
* An approval for a `delegate` account to transfer the `instance` of an asset `class` was
* cancelled by its `owner`.
* \[ class, instance, owner, delegate \]
**/
ApprovalCancelled: AugmentedEvent<ApiType, [ClassId, InstanceId, AccountId, AccountId]>;
/**
* An `instance` of an asset `class` has been approved by the `owner` for transfer by a
* `delegate`.
* \[ class, instance, owner, delegate \]
**/
ApprovedTransfer: AugmentedEvent<ApiType, [ClassId, InstanceId, AccountId, AccountId]>;
/**
* An asset `class` has had its attributes changed by the `Force` origin.
* \[ class \]
**/
AssetStatusChanged: AugmentedEvent<ApiType, [ClassId]>;
/**
* Attribute metadata has been cleared for an asset class or instance.
* \[ class, maybe_instance, key, maybe_value \]
**/
AttributeCleared: AugmentedEvent<ApiType, [ClassId, Option<InstanceId>, Bytes]>;
/**
* New attribute metadata has been set for an asset class or instance.
* \[ class, maybe_instance, key, value \]
**/
AttributeSet: AugmentedEvent<ApiType, [ClassId, Option<InstanceId>, Bytes, Bytes]>;
/**
* An asset `instance` was destroyed. \[ class, instance, owner \]
**/
Burned: AugmentedEvent<ApiType, [ClassId, InstanceId, AccountId]>;
/**
* Some asset `class` was frozen. \[ class \]
**/
ClassFrozen: AugmentedEvent<ApiType, [ClassId]>;
/**
* Metadata has been cleared for an asset class. \[ class \]
**/
ClassMetadataCleared: AugmentedEvent<ApiType, [ClassId]>;
/**
* New metadata has been set for an asset class. \[ class, data, is_frozen \]
**/
ClassMetadataSet: AugmentedEvent<ApiType, [ClassId, Bytes, bool]>;
/**
* Some asset `class` was thawed. \[ class \]
**/
ClassThawed: AugmentedEvent<ApiType, [ClassId]>;
/**
* An asset class was created. \[ class, creator, owner \]
**/
Created: AugmentedEvent<ApiType, [ClassId, AccountId, AccountId]>;
/**
* An asset `class` was destroyed. \[ class \]
**/
Destroyed: AugmentedEvent<ApiType, [ClassId]>;
/**
* An asset class was force-created. \[ class, owner \]
**/
ForceCreated: AugmentedEvent<ApiType, [ClassId, AccountId]>;
/**
* Some asset `instance` was frozen. \[ class, instance \]
**/
Frozen: AugmentedEvent<ApiType, [ClassId, InstanceId]>;
/**
* An asset `instace` was issued. \[ class, instance, owner \]
**/
Issued: AugmentedEvent<ApiType, [ClassId, InstanceId, AccountId]>;
/**
* Metadata has been cleared for an asset instance. \[ class, instance \]
**/
MetadataCleared: AugmentedEvent<ApiType, [ClassId, InstanceId]>;
/**
* New metadata has been set for an asset instance.
* \[ class, instance, data, is_frozen \]
**/
MetadataSet: AugmentedEvent<ApiType, [ClassId, InstanceId, Bytes, bool]>;
/**
* The owner changed \[ class, new_owner \]
**/
OwnerChanged: AugmentedEvent<ApiType, [ClassId, AccountId]>;
/**
* Metadata has been cleared for an asset instance. \[ class, successful_instances \]
**/
Redeposited: AugmentedEvent<ApiType, [ClassId, Vec<InstanceId>]>;
/**
* The management team changed \[ class, issuer, admin, freezer \]
**/
TeamChanged: AugmentedEvent<ApiType, [ClassId, AccountId, AccountId, AccountId]>;
/**
* Some asset `instance` was thawed. \[ class, instance \]
**/
Thawed: AugmentedEvent<ApiType, [ClassId, InstanceId]>;
/**
* An asset `instace` was transferred. \[ class, instance, from, to \]
**/
Transferred: AugmentedEvent<ApiType, [ClassId, InstanceId, AccountId, AccountId]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
utility: {
[key: string]: AugmentedEvent<ApiType>;
/**
* Batch of dispatches completed fully with no error.
**/
@@ -916,9 +1165,12 @@ declare module '@polkadot/api/types/events' {
* well as the error. \[index, error\]
**/
BatchInterrupted: AugmentedEvent<ApiType, [u32, DispatchError]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
vesting: {
[key: string]: AugmentedEvent<ApiType>;
/**
* An \[account\] has become fully vested. No further vesting can happen.
**/
@@ -929,6 +1181,10 @@ declare module '@polkadot/api/types/events' {
* \[account, unvested\]
**/
VestingUpdated: AugmentedEvent<ApiType, [AccountId, Balance]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
}
+335 -114
View File
@@ -3,30 +3,32 @@
import type { Bytes, Data, Option, U8aFixed, Vec, bool, u32, u64 } from '@polkadot/types';
import type { AnyNumber, ITuple, Observable } from '@polkadot/types/types';
import type { AssetBalance, AssetDetails, AssetMetadata } from '@polkadot/types/interfaces/assets';
import type { AssetApproval, AssetBalance, AssetDetails, AssetMetadata } from '@polkadot/types/interfaces/assets';
import type { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
import type { BabeAuthorityWeight, MaybeRandomness, NextConfigDescriptor, Randomness } from '@polkadot/types/interfaces/babe';
import type { AccountData, BalanceLock } from '@polkadot/types/interfaces/balances';
import type { BabeAuthorityWeight, BabeEpochConfiguration, MaybeRandomness, NextConfigDescriptor, Randomness } from '@polkadot/types/interfaces/babe';
import type { AccountData, BalanceLock, ReserveData } from '@polkadot/types/interfaces/balances';
import type { ProposalIndex, Votes } from '@polkadot/types/interfaces/collective';
import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
import type { CodeHash, ContractInfo, DeletedContract, PrefabWasmModule, Schedule } from '@polkadot/types/interfaces/contracts';
import type { CodeHash, ContractInfo, DeletedContract, PrefabWasmModule } from '@polkadot/types/interfaces/contracts';
import type { PreimageStatus, PropIndex, Proposal, ReferendumIndex, ReferendumInfo, Voting } from '@polkadot/types/interfaces/democracy';
import type { VoteThreshold } from '@polkadot/types/interfaces/elections';
import type { ActiveGilt, ActiveGiltsTotal, ActiveIndex, GiltBid } from '@polkadot/types/interfaces/gilt';
import type { SetId, StoredPendingChange, StoredState } from '@polkadot/types/interfaces/grandpa';
import type { RegistrarInfo, Registration } from '@polkadot/types/interfaces/identity';
import type { AuthIndex } from '@polkadot/types/interfaces/imOnline';
import type { CallIndex, LotteryConfig } from '@polkadot/types/interfaces/lottery';
import type { DeferredOffenceOf, Kind, OffenceDetails, OpaqueTimeSlot, ReportIdOf } from '@polkadot/types/interfaces/offences';
import type { Kind, OffenceDetails, OpaqueTimeSlot, ReportIdOf } from '@polkadot/types/interfaces/offences';
import type { ProxyAnnouncement, ProxyDefinition } from '@polkadot/types/interfaces/proxy';
import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber, Hash, KeyTypeId, Moment, OpaqueCall, Perbill, Releases, Slot, ValidatorId } from '@polkadot/types/interfaces/runtime';
import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber, Hash, KeyTypeId, Moment, OpaqueCall, Perbill, Releases, Slot, TransactionInfo, ValidatorId } from '@polkadot/types/interfaces/runtime';
import type { Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler';
import type { Keys, SessionIndex } from '@polkadot/types/interfaces/session';
import type { Bid, BidKind, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
import type { ActiveEraInfo, ElectionPhase, ElectionResult, ElectionScore, ElectionStatus, EraIndex, EraRewardPoints, Exposure, Forcing, Nominations, ReadySolution, RewardDestination, RoundSnapshot, SeatHolder, SlashingSpans, SolutionOrSnapshotSize, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs, Voter } from '@polkadot/types/interfaces/staking';
import type { ActiveEraInfo, ElectionPhase, ElectionScore, EraIndex, EraRewardPoints, Exposure, Forcing, Nominations, ReadySolution, RewardDestination, RoundSnapshot, SeatHolder, SlashingSpans, SolutionOrSnapshotSize, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs, Voter } from '@polkadot/types/interfaces/staking';
import type { AccountInfo, ConsumedWeight, DigestOf, EventIndex, EventRecord, LastRuntimeUpgradeInfo, Phase } from '@polkadot/types/interfaces/system';
import type { Bounty, BountyIndex, OpenTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
import type { Multiplier } from '@polkadot/types/interfaces/txpayment';
import type { ClassDetails, ClassId, ClassMetadata, DepositBalanceOf, InstanceDetails, InstanceId, InstanceMetadata } from '@polkadot/types/interfaces/uniques';
import type { Multisig } from '@polkadot/types/interfaces/utility';
import type { VestingInfo } from '@polkadot/types/interfaces/vesting';
import type { ApiTypes } from '@polkadot/api/types';
@@ -34,11 +36,16 @@ import type { ApiTypes } from '@polkadot/api/types';
declare module '@polkadot/api/types/storage' {
export interface AugmentedQueries<ApiType> {
assets: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The number of units of assets held by any given account.
**/
account: AugmentedQueryDoubleMap<ApiType, (key1: AssetId | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<AssetBalance>, [AssetId, AccountId]> & QueryableStorageEntry<ApiType, [AssetId, AccountId]>;
account: AugmentedQuery<ApiType, (arg1: AssetId | AnyNumber | Uint8Array, arg2: AccountId | string | Uint8Array) => Observable<AssetBalance>, [AssetId, AccountId]> & QueryableStorageEntry<ApiType, [AssetId, AccountId]>;
/**
* Approved balance transfers. First balance is the amount approved for transfer. Second
* is the amount of `T::Currency` reserved for storing this.
* First key is the asset ID, second key is the owner and third key is the delegate.
**/
approvals: AugmentedQuery<ApiType, (arg1: AssetId | AnyNumber | Uint8Array, arg2: AccountId | string | Uint8Array, arg3: AccountId | string | Uint8Array) => Observable<Option<AssetApproval>>, [AssetId, AccountId, AccountId]> & QueryableStorageEntry<ApiType, [AssetId, AccountId, AccountId]>;
/**
* Details of an asset.
**/
@@ -47,9 +54,12 @@ declare module '@polkadot/api/types/storage' {
* Metadata of an asset.
**/
metadata: AugmentedQuery<ApiType, (arg: AssetId | AnyNumber | Uint8Array) => Observable<AssetMetadata>, [AssetId]> & QueryableStorageEntry<ApiType, [AssetId]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
authorship: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Author of current block.
**/
@@ -62,9 +72,12 @@ declare module '@polkadot/api/types/storage' {
* Uncles
**/
uncles: AugmentedQuery<ApiType, () => Observable<Vec<UncleEntryItem>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
babe: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Current epoch authorities.
**/
@@ -79,10 +92,22 @@ declare module '@polkadot/api/types/storage' {
* Current slot number.
**/
currentSlot: AugmentedQuery<ApiType, () => Observable<Slot>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The configuration for the current epoch. Should never be `None` as it is initialized in genesis.
**/
epochConfig: AugmentedQuery<ApiType, () => Observable<Option<BabeEpochConfiguration>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Current epoch index.
**/
epochIndex: AugmentedQuery<ApiType, () => Observable<u64>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The block numbers when the last and current epoch have started, respectively `N-1` and
* `N`.
* NOTE: We track this is in order to annotate the block number when a given pool of
* entropy was fixed (i.e. it was known to chain observers). Since epochs are defined in
* slots, which may be skipped, the block numbers may not line up with the slot numbers.
**/
epochStart: AugmentedQuery<ApiType, () => Observable<ITuple<[BlockNumber, BlockNumber]>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The slot at which the first epoch actually started. This is 0
* until the first block of the chain.
@@ -106,13 +131,18 @@ declare module '@polkadot/api/types/storage' {
**/
nextAuthorities: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[AuthorityId, BabeAuthorityWeight]>>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Next epoch configuration, if changed.
* The configuration for the next epoch, `None` if the config will not change
* (you can fallback to `EpochConfig` instead in that case).
**/
nextEpochConfig: AugmentedQuery<ApiType, () => Observable<Option<NextConfigDescriptor>>, []> & QueryableStorageEntry<ApiType, []>;
nextEpochConfig: AugmentedQuery<ApiType, () => Observable<Option<BabeEpochConfiguration>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Next epoch randomness.
**/
nextRandomness: AugmentedQuery<ApiType, () => Observable<Randomness>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Pending epoch configuration change that will be applied when the next epoch is enacted.
**/
pendingEpochConfigChange: AugmentedQuery<ApiType, () => Observable<Option<NextConfigDescriptor>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The epoch randomness for the *current* epoch.
*
@@ -142,9 +172,12 @@ declare module '@polkadot/api/types/storage' {
* TWOX-NOTE: `SegmentIndex` is an increasing integer, so this is okay.
**/
underConstruction: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Vec<Randomness>>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
balances: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The balance of an account.
*
@@ -156,6 +189,10 @@ declare module '@polkadot/api/types/storage' {
* NOTE: Should only be accessed when setting, changing and freeing a lock.
**/
locks: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Vec<BalanceLock>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* Named reserves on some account balances.
**/
reserves: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Vec<ReserveData>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* Storage version of the pallet.
*
@@ -166,9 +203,12 @@ declare module '@polkadot/api/types/storage' {
* The total units issued in the system.
**/
totalIssuance: AugmentedQuery<ApiType, () => Observable<Balance>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
bounties: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Bounties that have been made.
**/
@@ -185,9 +225,12 @@ declare module '@polkadot/api/types/storage' {
* The description of each bounty.
**/
bountyDescriptions: AugmentedQuery<ApiType, (arg: BountyIndex | AnyNumber | Uint8Array) => Observable<Option<Bytes>>, [BountyIndex]> & QueryableStorageEntry<ApiType, [BountyIndex]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
contracts: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The subtrie counter.
**/
@@ -202,10 +245,6 @@ declare module '@polkadot/api/types/storage' {
* TWOX-NOTE: SAFE since `AccountId` is a secure hash.
**/
contractInfoOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<ContractInfo>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* Current cost schedule for contracts.
**/
currentSchedule: AugmentedQuery<ApiType, () => Observable<Schedule>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Evicted contracts that await child trie deletion.
*
@@ -217,9 +256,12 @@ declare module '@polkadot/api/types/storage' {
* A mapping from an original code hash to the original code, untouched by instrumentation.
**/
pristineCode: AugmentedQuery<ApiType, (arg: CodeHash | string | Uint8Array) => Observable<Option<Bytes>>, [CodeHash]> & QueryableStorageEntry<ApiType, [CodeHash]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
council: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The current members of the collective. This is stored sorted (just by value).
**/
@@ -244,9 +286,12 @@ declare module '@polkadot/api/types/storage' {
* Votes on a given proposal, if it is ongoing.
**/
voting: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Option<Votes>>, [Hash]> & QueryableStorageEntry<ApiType, [Hash]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
democracy: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* A record of who vetoed what. Maps proposal hash to a possible existent block number
* (until when it may not be resubmitted) and who vetoed it.
@@ -322,9 +367,12 @@ declare module '@polkadot/api/types/storage' {
* TWOX-NOTE: SAFE as `AccountId`s are crypto hashes anyway.
**/
votingOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Voting>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
electionProviderMultiPhase: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Current phase.
**/
@@ -335,6 +383,13 @@ declare module '@polkadot/api/types/storage' {
* Only exists when [`Snapshot`] is present.
**/
desiredTargets: AugmentedQuery<ApiType, () => Observable<Option<u32>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The minimum score that each 'untrusted' solution must attain in order to be considered
* feasible.
*
* Can be set via `set_minimum_untrusted_score`.
**/
minimumUntrustedScore: AugmentedQuery<ApiType, () => Observable<Option<ElectionScore>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Current best solution, signed or unsigned, queued to be returned upon `elect`.
**/
@@ -360,9 +415,12 @@ declare module '@polkadot/api/types/storage' {
* Only exists when [`Snapshot`] is present.
**/
snapshotMetadata: AugmentedQuery<ApiType, () => Observable<Option<SolutionOrSnapshotSize>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
elections: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The present candidate list. A current member or runner-up can never enter this vector
* and is always implicitly assumed to be a candidate.
@@ -395,9 +453,38 @@ declare module '@polkadot/api/types/storage' {
* TWOX-NOTE: SAFE as `AccountId` is a crypto hash.
**/
voting: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Voter>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
gilt: {
/**
* The currently active gilts, indexed according to the order of creation.
**/
active: AugmentedQuery<ApiType, (arg: ActiveIndex | AnyNumber | Uint8Array) => Observable<Option<ActiveGilt>>, [ActiveIndex]> & QueryableStorageEntry<ApiType, [ActiveIndex]>;
/**
* Information relating to the gilts currently active.
**/
activeTotal: AugmentedQuery<ApiType, () => Observable<ActiveGiltsTotal>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The queues of bids ready to become gilts. Indexed by duration (in `Period`s).
**/
queues: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Vec<GiltBid>>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
/**
* The totals of items and balances within each queue. Saves a lot of storage reads in the
* case of sparsely packed queues.
*
* The vector is indexed by duration in `Period`s, offset by one, so information on the queue
* whose duration is one `Period` would be storage `0`.
**/
queueTotals: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[u32, BalanceOf]>>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
grandpa: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The number of changes (both in terms of keys and underlying economic responsibilities)
* in the "set" of Grandpa validators from genesis.
@@ -426,9 +513,12 @@ declare module '@polkadot/api/types/storage' {
* State of the current authority set.
**/
state: AugmentedQuery<ApiType, () => Observable<StoredState>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
identity: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Information that is pertinent to identify the entity behind an account.
*
@@ -455,21 +545,29 @@ declare module '@polkadot/api/types/storage' {
* context. If the account is not some other account's sub-identity, then just `None`.
**/
superOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<ITuple<[AccountId, Data]>>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
imOnline: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* For each session index, we keep a mapping of `ValidatorId<T>` to the
* number of blocks authored by the given authority.
**/
authoredBlocks: AugmentedQueryDoubleMap<ApiType, (key1: SessionIndex | AnyNumber | Uint8Array, key2: ValidatorId | string | Uint8Array) => Observable<u32>, [SessionIndex, ValidatorId]> & QueryableStorageEntry<ApiType, [SessionIndex, ValidatorId]>;
authoredBlocks: AugmentedQuery<ApiType, (arg1: SessionIndex | AnyNumber | Uint8Array, arg2: ValidatorId | string | Uint8Array) => Observable<u32>, [SessionIndex, ValidatorId]> & QueryableStorageEntry<ApiType, [SessionIndex, ValidatorId]>;
/**
* The block number after which it's ok to send heartbeats in current session.
* The block number after which it's ok to send heartbeats in the current
* session.
*
* At the beginning of each session we set this to a value that should
* fall roughly in the middle of the session duration.
* The idea is to first wait for the validators to produce a block
* in the current session, so that the heartbeat later on will not be necessary.
* At the beginning of each session we set this to a value that should fall
* roughly in the middle of the session duration. The idea is to first wait for
* the validators to produce a block in the current session, so that the
* heartbeat later on will not be necessary.
*
* This value will only be used as a fallback if we fail to get a proper session
* progress estimate from `NextSessionRotation`, as those estimates should be
* more accurate then the value we calculate for `HeartbeatAfter`.
**/
heartbeatAfter: AugmentedQuery<ApiType, () => Observable<BlockNumber>, []> & QueryableStorageEntry<ApiType, []>;
/**
@@ -480,17 +578,23 @@ declare module '@polkadot/api/types/storage' {
* For each session index, we keep a mapping of `AuthIndex` to
* `offchain::OpaqueNetworkState`.
**/
receivedHeartbeats: AugmentedQueryDoubleMap<ApiType, (key1: SessionIndex | AnyNumber | Uint8Array, key2: AuthIndex | AnyNumber | Uint8Array) => Observable<Option<Bytes>>, [SessionIndex, AuthIndex]> & QueryableStorageEntry<ApiType, [SessionIndex, AuthIndex]>;
receivedHeartbeats: AugmentedQuery<ApiType, (arg1: SessionIndex | AnyNumber | Uint8Array, arg2: AuthIndex | AnyNumber | Uint8Array) => Observable<Option<Bytes>>, [SessionIndex, AuthIndex]> & QueryableStorageEntry<ApiType, [SessionIndex, AuthIndex]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
indices: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The lookup from index to account.
**/
accounts: AugmentedQuery<ApiType, (arg: AccountIndex | AnyNumber | Uint8Array) => Observable<Option<ITuple<[AccountId, BalanceOf, bool]>>>, [AccountIndex]> & QueryableStorageEntry<ApiType, [AccountIndex]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
lottery: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The calls stored in this pallet to be used in an active lottery if configured
* by `Config::ValidateCall`.
@@ -516,9 +620,12 @@ declare module '@polkadot/api/types/storage' {
* Total number of tickets sold.
**/
ticketsCount: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
mmr: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Hashes of the nodes in the MMR.
*
@@ -534,26 +641,27 @@ declare module '@polkadot/api/types/storage' {
* Latest MMR Root hash.
**/
rootHash: AugmentedQuery<ApiType, () => Observable<Hash>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
multisig: {
[key: string]: QueryableStorageEntry<ApiType>;
calls: AugmentedQuery<ApiType, (arg: U8aFixed | string | Uint8Array) => Observable<Option<ITuple<[OpaqueCall, AccountId, BalanceOf]>>>, [U8aFixed]> & QueryableStorageEntry<ApiType, [U8aFixed]>;
/**
* The set of open multisig operations.
**/
multisigs: AugmentedQueryDoubleMap<ApiType, (key1: AccountId | string | Uint8Array, key2: U8aFixed | string | Uint8Array) => Observable<Option<Multisig>>, [AccountId, U8aFixed]> & QueryableStorageEntry<ApiType, [AccountId, U8aFixed]>;
multisigs: AugmentedQuery<ApiType, (arg1: AccountId | string | Uint8Array, arg2: U8aFixed | string | Uint8Array) => Observable<Option<Multisig>>, [AccountId, U8aFixed]> & QueryableStorageEntry<ApiType, [AccountId, U8aFixed]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
offences: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* A vector of reports of the same kind that happened at the same time slot.
**/
concurrentReportsIndex: AugmentedQueryDoubleMap<ApiType, (key1: Kind | string | Uint8Array, key2: OpaqueTimeSlot | string | Uint8Array) => Observable<Vec<ReportIdOf>>, [Kind, OpaqueTimeSlot]> & QueryableStorageEntry<ApiType, [Kind, OpaqueTimeSlot]>;
/**
* Deferred reports that have been rejected by the offence handler and need to be submitted
* at a later time.
**/
deferredOffences: AugmentedQuery<ApiType, () => Observable<Vec<DeferredOffenceOf>>, []> & QueryableStorageEntry<ApiType, []>;
concurrentReportsIndex: AugmentedQuery<ApiType, (arg1: Kind | string | Uint8Array, arg2: OpaqueTimeSlot | string | Uint8Array) => Observable<Vec<ReportIdOf>>, [Kind, OpaqueTimeSlot]> & QueryableStorageEntry<ApiType, [Kind, OpaqueTimeSlot]>;
/**
* The primary structure that holds all offence records keyed by report identifiers.
**/
@@ -567,9 +675,12 @@ declare module '@polkadot/api/types/storage' {
* different types are not supported at the moment so we are doing the manual serialization.
**/
reportsByKindIndex: AugmentedQuery<ApiType, (arg: Kind | string | Uint8Array) => Observable<Bytes>, [Kind]> & QueryableStorageEntry<ApiType, [Kind]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
proxy: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The announcements made by the proxy (key).
**/
@@ -579,25 +690,31 @@ declare module '@polkadot/api/types/storage' {
* which are being delegated to, together with the amount held on deposit.
**/
proxies: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ITuple<[Vec<ProxyDefinition>, BalanceOf]>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
randomnessCollectiveFlip: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Series of block headers from the last 81 blocks that acts as random seed material. This
* is arranged as a ring buffer with `block_number % 81` being the index into the `Vec` of
* the oldest hash.
**/
randomMaterial: AugmentedQuery<ApiType, () => Observable<Vec<Hash>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
recovery: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Active recovery attempts.
*
* First account is the account to be recovered, and the second account
* is the user trying to recover the account.
**/
activeRecoveries: AugmentedQueryDoubleMap<ApiType, (key1: AccountId | string | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<Option<ActiveRecovery>>, [AccountId, AccountId]> & QueryableStorageEntry<ApiType, [AccountId, AccountId]>;
activeRecoveries: AugmentedQuery<ApiType, (arg1: AccountId | string | Uint8Array, arg2: AccountId | string | Uint8Array) => Observable<Option<ActiveRecovery>>, [AccountId, AccountId]> & QueryableStorageEntry<ApiType, [AccountId, AccountId]>;
/**
* The list of allowed proxy accounts.
*
@@ -608,9 +725,12 @@ declare module '@polkadot/api/types/storage' {
* The set of recoverable accounts and their recovery configuration.
**/
recoverable: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<RecoveryConfig>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
scheduler: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Items to be executed, indexed by the block number that they should be executed on.
**/
@@ -625,9 +745,12 @@ declare module '@polkadot/api/types/storage' {
* New networks start with last version.
**/
storageVersion: AugmentedQuery<ApiType, () => Observable<Releases>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
session: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Current index of the session.
**/
@@ -660,9 +783,12 @@ declare module '@polkadot/api/types/storage' {
* The current set of validators.
**/
validators: AugmentedQuery<ApiType, () => Observable<Vec<ValidatorId>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
society: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The current bids, stored ordered by the value of the bid.
**/
@@ -723,14 +849,17 @@ declare module '@polkadot/api/types/storage' {
/**
* Double map from Candidate -> Voter -> (Maybe) Vote.
**/
votes: AugmentedQueryDoubleMap<ApiType, (key1: AccountId | string | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<Option<SocietyVote>>, [AccountId, AccountId]> & QueryableStorageEntry<ApiType, [AccountId, AccountId]>;
votes: AugmentedQuery<ApiType, (arg1: AccountId | string | Uint8Array, arg2: AccountId | string | Uint8Array) => Observable<Option<SocietyVote>>, [AccountId, AccountId]> & QueryableStorageEntry<ApiType, [AccountId, AccountId]>;
/**
* Members currently vouching or banned from vouching again
**/
vouching: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<VouchingStatus>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
staking: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The active era information, it holds index and start.
*
@@ -754,6 +883,14 @@ declare module '@polkadot/api/types/storage' {
* canceled by extraordinary circumstances (e.g. governance).
**/
canceledSlashPayout: AugmentedQuery<ApiType, () => Observable<BalanceOf>, []> & QueryableStorageEntry<ApiType, []>;
/**
* A tracker to keep count of the number of items in the `Nominators` map.
**/
counterForNominators: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
/**
* A tracker to keep count of the number of items in the `Validators` map.
**/
counterForValidators: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The current era index.
*
@@ -771,13 +908,6 @@ declare module '@polkadot/api/types/storage' {
* The earliest era for which we have a pending, unapplied slash.
**/
earliestUnappliedSlash: AugmentedQuery<ApiType, () => Observable<Option<EraIndex>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Flag to control the execution of the offchain election. When `Open(_)`, we accept
* solutions to be submitted.
*
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
**/
eraElectionStatus: AugmentedQuery<ApiType, () => Observable<ElectionStatus>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Rewards for the last `HISTORY_DEPTH` eras.
* If reward hasn't been set or has been removed then 0 reward is returned.
@@ -791,7 +921,7 @@ declare module '@polkadot/api/types/storage' {
* Is it removed after `HISTORY_DEPTH` eras.
* If stakers hasn't been set or has been removed then empty exposure is returned.
**/
erasStakers: AugmentedQueryDoubleMap<ApiType, (key1: EraIndex | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<Exposure>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
erasStakers: AugmentedQuery<ApiType, (arg1: EraIndex | AnyNumber | Uint8Array, arg2: AccountId | string | Uint8Array) => Observable<Exposure>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
/**
* Clipped Exposure of validator at era.
*
@@ -805,7 +935,7 @@ declare module '@polkadot/api/types/storage' {
* Is it removed after `HISTORY_DEPTH` eras.
* If stakers hasn't been set or has been removed then empty exposure is returned.
**/
erasStakersClipped: AugmentedQueryDoubleMap<ApiType, (key1: EraIndex | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<Exposure>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
erasStakersClipped: AugmentedQuery<ApiType, (arg1: EraIndex | AnyNumber | Uint8Array, arg2: AccountId | string | Uint8Array) => Observable<Exposure>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
/**
* The session index at which the era start for the last `HISTORY_DEPTH` eras.
*
@@ -825,7 +955,7 @@ declare module '@polkadot/api/types/storage' {
*
* Is it removed after `HISTORY_DEPTH` eras.
**/
erasValidatorPrefs: AugmentedQueryDoubleMap<ApiType, (key1: EraIndex | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<ValidatorPrefs>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
erasValidatorPrefs: AugmentedQuery<ApiType, (arg1: EraIndex | AnyNumber | Uint8Array, arg2: AccountId | string | Uint8Array) => Observable<ValidatorPrefs>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
/**
* The total validator era payout for the last `HISTORY_DEPTH` eras.
*
@@ -852,47 +982,48 @@ declare module '@polkadot/api/types/storage' {
* invulnerables) and restricted to testnets.
**/
invulnerables: AugmentedQuery<ApiType, () => Observable<Vec<AccountId>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* True if the current **planned** session is final. Note that this does not take era
* forcing into account.
*
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
**/
isCurrentSessionFinal: AugmentedQuery<ApiType, () => Observable<bool>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Map from all (unlocked) "controller" accounts to the info regarding the staking.
**/
ledger: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<StakingLedger>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* The maximum nominator count before we stop allowing new validators to join.
*
* When this value is not set, no limits are enforced.
**/
maxNominatorsCount: AugmentedQuery<ApiType, () => Observable<Option<u32>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The maximum validator count before we stop allowing new validators to join.
*
* When this value is not set, no limits are enforced.
**/
maxValidatorsCount: AugmentedQuery<ApiType, () => Observable<Option<u32>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Minimum number of staking participants before emergency conditions are imposed.
**/
minimumValidatorCount: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The minimum active bond to become and maintain the role of a nominator.
**/
minNominatorBond: AugmentedQuery<ApiType, () => Observable<BalanceOf>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The minimum active bond to become and maintain the role of a validator.
**/
minValidatorBond: AugmentedQuery<ApiType, () => Observable<BalanceOf>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The map from nominator stash key to the set of stash keys of all validators to nominate.
*
* When updating this storage item, you must also update the `CounterForNominators`.
**/
nominators: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<Nominations>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* All slashing events on nominators, mapped by era to the highest slash value of the era.
**/
nominatorSlashInEra: AugmentedQueryDoubleMap<ApiType, (key1: EraIndex | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<Option<BalanceOf>>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
nominatorSlashInEra: AugmentedQuery<ApiType, (arg1: EraIndex | AnyNumber | Uint8Array, arg2: AccountId | string | Uint8Array) => Observable<Option<BalanceOf>>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
/**
* Where the reward payment should be made. Keyed by stash.
**/
payee: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<RewardDestination>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* The next validator set. At the end of an era, if this is available (potentially from the
* result of an offchain worker), it is immediately used. Otherwise, the on-chain election
* is executed.
*
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
**/
queuedElected: AugmentedQuery<ApiType, () => Observable<Option<ElectionResult>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The score of the current [`QueuedElected`].
*
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
**/
queuedScore: AugmentedQuery<ApiType, () => Observable<Option<ElectionScore>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Slashing spans for stash accounts.
**/
@@ -903,20 +1034,6 @@ declare module '@polkadot/api/types/storage' {
* The rest of the slashed value is handled by the `Slash`.
**/
slashRewardFraction: AugmentedQuery<ApiType, () => Observable<Perbill>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Snapshot of nominators at the beginning of the current election window. This should only
* have a value when [`EraElectionStatus`] == `ElectionStatus::Open(_)`.
*
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
**/
snapshotNominators: AugmentedQuery<ApiType, () => Observable<Option<Vec<AccountId>>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Snapshot of validators at the beginning of the current election window. This should only
* have a value when [`EraElectionStatus`] == `ElectionStatus::Open(_)`.
*
* TWO_PHASE_NOTE: should be removed once we switch to multi-phase.
**/
snapshotValidators: AugmentedQuery<ApiType, () => Observable<Option<Vec<AccountId>>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Records information about the maximum slash of a stash within a slashing span,
* as well as how much reward has been paid out.
@@ -926,7 +1043,7 @@ declare module '@polkadot/api/types/storage' {
* True if network has been upgraded to this version.
* Storage version of the pallet.
*
* This is set to v5.0.0 for new networks.
* This is set to v6.0.0 for new networks.
**/
storageVersion: AugmentedQuery<ApiType, () => Observable<Releases>, []> & QueryableStorageEntry<ApiType, []>;
/**
@@ -939,23 +1056,31 @@ declare module '@polkadot/api/types/storage' {
validatorCount: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The map from (wannabe) validator stash key to the preferences of that validator.
*
* When updating this storage item, you must also update the `CounterForValidators`.
**/
validators: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ValidatorPrefs>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* All slashing events on validators, mapped by era to the highest slash proportion
* and slash value of the era.
**/
validatorSlashInEra: AugmentedQueryDoubleMap<ApiType, (key1: EraIndex | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<Option<ITuple<[Perbill, BalanceOf]>>>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
validatorSlashInEra: AugmentedQuery<ApiType, (arg1: EraIndex | AnyNumber | Uint8Array, arg2: AccountId | string | Uint8Array) => Observable<Option<ITuple<[Perbill, BalanceOf]>>>, [EraIndex, AccountId]> & QueryableStorageEntry<ApiType, [EraIndex, AccountId]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
sudo: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The `AccountId` of the sudo key.
**/
key: AugmentedQuery<ApiType, () => Observable<AccountId>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
system: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The full account information for a particular account ID.
**/
@@ -1022,17 +1147,20 @@ declare module '@polkadot/api/types/storage' {
**/
parentHash: AugmentedQuery<ApiType, () => Observable<Hash>, []> & QueryableStorageEntry<ApiType, []>;
/**
* True if we have upgraded so that AccountInfo contains two types of `RefCount`. False
* True if we have upgraded so that AccountInfo contains three types of `RefCount`. False
* (default) if not.
**/
upgradedToDualRefCount: AugmentedQuery<ApiType, () => Observable<bool>, []> & QueryableStorageEntry<ApiType, []>;
upgradedToTripleRefCount: AugmentedQuery<ApiType, () => Observable<bool>, []> & QueryableStorageEntry<ApiType, []>;
/**
* True if we have upgraded so that `type RefCount` is `u32`. False (default) if not.
**/
upgradedToU32RefCount: AugmentedQuery<ApiType, () => Observable<bool>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
technicalCommittee: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The current members of the collective. This is stored sorted (just by value).
**/
@@ -1057,9 +1185,12 @@ declare module '@polkadot/api/types/storage' {
* Votes on a given proposal, if it is ongoing.
**/
voting: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Option<Votes>>, [Hash]> & QueryableStorageEntry<ApiType, [Hash]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
technicalMembership: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The current membership, stored as an ordered Vec.
**/
@@ -1068,9 +1199,12 @@ declare module '@polkadot/api/types/storage' {
* The current prime member, if one exists.
**/
prime: AugmentedQuery<ApiType, () => Observable<Option<AccountId>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
timestamp: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Did the timestamp get updated in this block?
**/
@@ -1079,9 +1213,12 @@ declare module '@polkadot/api/types/storage' {
* Current time for the current block.
**/
now: AugmentedQuery<ApiType, () => Observable<Moment>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
tips: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Simple preimage lookup from the reason's hash to the original data. Again, has an
* insecure enumerable hash since the key is guaranteed to be the result of a secure hash.
@@ -1093,14 +1230,60 @@ declare module '@polkadot/api/types/storage' {
* guaranteed to be a secure hash.
**/
tips: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Option<OpenTip>>, [Hash]> & QueryableStorageEntry<ApiType, [Hash]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
transactionPayment: {
[key: string]: QueryableStorageEntry<ApiType>;
nextFeeMultiplier: AugmentedQuery<ApiType, () => Observable<Multiplier>, []> & QueryableStorageEntry<ApiType, []>;
storageVersion: AugmentedQuery<ApiType, () => Observable<Releases>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
transactionStorage: {
blockTransactions: AugmentedQuery<ApiType, () => Observable<Vec<TransactionInfo>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Storage fee per byte.
**/
byteFee: AugmentedQuery<ApiType, () => Observable<Option<BalanceOf>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Count indexed chunks for each block.
**/
chunkCount: AugmentedQuery<ApiType, (arg: BlockNumber | AnyNumber | Uint8Array) => Observable<u32>, [BlockNumber]> & QueryableStorageEntry<ApiType, [BlockNumber]>;
/**
* Storage fee per transaction.
**/
entryFee: AugmentedQuery<ApiType, () => Observable<Option<BalanceOf>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Maximum number of indexed transactions in the block.
**/
maxBlockTransactions: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Maximum data set in a single transaction in bytes.
**/
maxTransactionSize: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Was the proof checked in this block?
**/
proofChecked: AugmentedQuery<ApiType, () => Observable<bool>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Storage period for data in blocks. Should match `sp_storage_proof::DEFAULT_STORAGE_PERIOD`
* for block authoring.
**/
storagePeriod: AugmentedQuery<ApiType, () => Observable<BlockNumber>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Collection of transaction metadata by block number.
**/
transactions: AugmentedQuery<ApiType, (arg: BlockNumber | AnyNumber | Uint8Array) => Observable<Option<Vec<TransactionInfo>>>, [BlockNumber]> & QueryableStorageEntry<ApiType, [BlockNumber]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
treasury: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Proposal indices that have been approved but not yet awarded.
**/
@@ -1113,13 +1296,51 @@ declare module '@polkadot/api/types/storage' {
* Proposals that have been made.
**/
proposals: AugmentedQuery<ApiType, (arg: ProposalIndex | AnyNumber | Uint8Array) => Observable<Option<TreasuryProposal>>, [ProposalIndex]> & QueryableStorageEntry<ApiType, [ProposalIndex]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
uniques: {
/**
* The assets held by any given account; set out this way so that assets owned by a single
* account can be enumerated.
**/
account: AugmentedQuery<ApiType, (arg1: AccountId | string | Uint8Array, arg2: ClassId | AnyNumber | Uint8Array, arg3: InstanceId | AnyNumber | Uint8Array) => Observable<Option<ITuple<[]>>>, [AccountId, ClassId, InstanceId]> & QueryableStorageEntry<ApiType, [AccountId, ClassId, InstanceId]>;
/**
* The assets in existence and their ownership details.
**/
asset: AugmentedQuery<ApiType, (arg1: ClassId | AnyNumber | Uint8Array, arg2: InstanceId | AnyNumber | Uint8Array) => Observable<Option<InstanceDetails>>, [ClassId, InstanceId]> & QueryableStorageEntry<ApiType, [ClassId, InstanceId]>;
/**
* Metadata of an asset class.
**/
attribute: AugmentedQuery<ApiType, (arg1: ClassId | AnyNumber | Uint8Array, arg2: Option<InstanceId> | null | object | string | Uint8Array, arg3: Bytes | string | Uint8Array) => Observable<Option<ITuple<[Bytes, DepositBalanceOf]>>>, [ClassId, Option<InstanceId>, Bytes]> & QueryableStorageEntry<ApiType, [ClassId, Option<InstanceId>, Bytes]>;
/**
* Details of an asset class.
**/
class: AugmentedQuery<ApiType, (arg: ClassId | AnyNumber | Uint8Array) => Observable<Option<ClassDetails>>, [ClassId]> & QueryableStorageEntry<ApiType, [ClassId]>;
/**
* Metadata of an asset class.
**/
classMetadataOf: AugmentedQuery<ApiType, (arg: ClassId | AnyNumber | Uint8Array) => Observable<Option<ClassMetadata>>, [ClassId]> & QueryableStorageEntry<ApiType, [ClassId]>;
/**
* Metadata of an asset instance.
**/
instanceMetadataOf: AugmentedQuery<ApiType, (arg1: ClassId | AnyNumber | Uint8Array, arg2: InstanceId | AnyNumber | Uint8Array) => Observable<Option<InstanceMetadata>>, [ClassId, InstanceId]> & QueryableStorageEntry<ApiType, [ClassId, InstanceId]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
vesting: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* Information regarding the vesting of a given account.
**/
vesting: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<VestingInfo>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
}
+38 -4
View File
@@ -6,19 +6,21 @@ import type { Bytes, HashMap, Json, Null, Option, StorageKey, Text, U256, U64, V
import type { AnyNumber, Codec, IExtrinsic, Observable } from '@polkadot/types/types';
import type { ExtrinsicOrHash, ExtrinsicStatus } from '@polkadot/types/interfaces/author';
import type { EpochAuthorship } from '@polkadot/types/interfaces/babe';
import type { BeefySignedCommitment } from '@polkadot/types/interfaces/beefy';
import type { BlockHash } from '@polkadot/types/interfaces/chain';
import type { PrefixedStorageKey } from '@polkadot/types/interfaces/childstate';
import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
import type { ContractCallRequest, ContractExecResult } from '@polkadot/types/interfaces/contracts';
import type { ContractCallRequest, ContractExecResult, ContractInstantiateResult, InstantiateRequest } from '@polkadot/types/interfaces/contracts';
import type { CreatedBlock } from '@polkadot/types/interfaces/engine';
import type { EthAccount, EthCallRequest, EthFilter, EthFilterChanges, EthLog, EthReceipt, EthRichBlock, EthSubKind, EthSubParams, EthSyncStatus, EthTransaction, EthTransactionRequest, EthWork } from '@polkadot/types/interfaces/eth';
import type { Extrinsic } from '@polkadot/types/interfaces/extrinsics';
import type { EncodedFinalityProofs, JustificationNotification, ReportedRoundStates } from '@polkadot/types/interfaces/grandpa';
import type { MmrLeafProof } from '@polkadot/types/interfaces/mmr';
import type { StorageKind } from '@polkadot/types/interfaces/offchain';
import type { FeeDetails, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
import type { RpcMethods } from '@polkadot/types/interfaces/rpc';
import type { AccountId, BlockNumber, H160, H256, H64, Hash, Header, Index, Justification, KeyValue, SignedBlock, StorageData } from '@polkadot/types/interfaces/runtime';
import type { ReadProof, RuntimeVersion } from '@polkadot/types/interfaces/state';
import type { ReadProof, RuntimeVersion, TraceBlockResponse } from '@polkadot/types/interfaces/state';
import type { ApplyExtrinsicResult, ChainProperties, ChainType, Health, NetworkState, NodeRole, PeerInfo, SyncState } from '@polkadot/types/interfaces/system';
declare module '@polkadot/rpc-core/types.jsonrpc' {
@@ -63,6 +65,12 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
**/
epochAuthorship: AugmentedRpc<() => Observable<HashMap<AuthorityId, EpochAuthorship>>>;
};
beefy: {
/**
* Returns the block most recently finalized by BEEFY, alongside side its justification.
**/
subscribeJustifications: AugmentedRpc<() => Observable<BeefySignedCommitment>>;
};
chain: {
/**
* Get header and body of a relay chain block
@@ -98,6 +106,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
* Returns the keys with prefix from a child storage, leave empty to get all the keys
**/
getKeys: AugmentedRpc<(childKey: PrefixedStorageKey | string | Uint8Array, prefix: StorageKey | string | Uint8Array | any, at?: Hash | string | Uint8Array) => Observable<Vec<StorageKey>>>;
/**
* Returns the keys with prefix from a child storage with pagination support
**/
getKeysPaged: AugmentedRpc<(childKey: PrefixedStorageKey | string | Uint8Array, prefix: StorageKey | string | Uint8Array | any, count: u32 | AnyNumber | Uint8Array, startKey?: StorageKey | string | Uint8Array | any, at?: Hash | string | Uint8Array) => Observable<Vec<StorageKey>>>;
/**
* Returns a child storage entry at a specific block state
**/
@@ -120,6 +132,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
* Returns the value under a specified storage key in a contract
**/
getStorage: AugmentedRpc<(address: AccountId | string | Uint8Array, key: H256 | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<Option<Bytes>>>;
/**
* Instantiate a new contract
**/
instantiate: AugmentedRpc<(request: InstantiateRequest | { origin?: any; endowment?: any; gasLimit?: any; code?: any; data?: any; salt?: any } | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<ContractInstantiateResult>>;
/**
* Returns the projected time a given contract will be able to sustain paying its rent
**/
@@ -133,7 +149,7 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
/**
* Instructs the manual-seal authorship task to finalize a block
**/
finalizeBlock: AugmentedRpc<(hash: BlockHash | string | Uint8Array, justification?: Justification | string | Uint8Array) => Observable<bool>>;
finalizeBlock: AugmentedRpc<(hash: BlockHash | string | Uint8Array, justification?: Justification) => Observable<bool>>;
};
eth: {
/**
@@ -141,7 +157,7 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
**/
accounts: AugmentedRpc<() => Observable<Vec<H160>>>;
/**
* Returns balance of the given account.
* Returns the blockNumber
**/
blockNumber: AugmentedRpc<() => Observable<U256>>;
/**
@@ -315,6 +331,12 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
**/
subscribeJustifications: AugmentedRpc<() => Observable<JustificationNotification>>;
};
mmr: {
/**
* Generate MMR proof for given leaf index.
**/
generateProof: AugmentedRpc<(leafIndex: u64 | AnyNumber | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<MmrLeafProof>>;
};
net: {
/**
* Returns true if client is actively listening for network connections. Otherwise false.
@@ -364,6 +386,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
* Retrieves the keys with prefix of a specific child storage
**/
getChildKeys: AugmentedRpc<(childStorageKey: StorageKey | string | Uint8Array | any, childDefinition: StorageKey | string | Uint8Array | any, childType: u32 | AnyNumber | Uint8Array, key: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array) => Observable<Vec<StorageKey>>>;
/**
* Returns proof of storage for child key entries at a specific block state.
**/
getChildReadProof: AugmentedRpc<(childStorageKey: PrefixedStorageKey | string | Uint8Array, keys: Vec<StorageKey> | (StorageKey | string | Uint8Array | any)[], at?: BlockHash | string | Uint8Array) => Observable<ReadProof>>;
/**
* Retrieves the child storage for a key
**/
@@ -428,6 +454,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
* Subscribes to storage changes for the provided keys
**/
subscribeStorage: AugmentedRpc<<T = Codec[]>(keys?: Vec<StorageKey> | (StorageKey | string | Uint8Array | any)[]) => Observable<T>>;
/**
* Provides a way to trace the re-execution of a single block
**/
traceBlock: AugmentedRpc<(block: Hash | string | Uint8Array, targets: Option<Text> | null | object | string | Uint8Array, storageKeys: Option<Text> | null | object | string | Uint8Array) => Observable<TraceBlockResponse>>;
};
syncstate: {
/**
@@ -496,6 +526,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
* Remove a reserved peer
**/
removeReservedPeer: AugmentedRpc<(peerId: Text | string) => Observable<Text>>;
/**
* Returns the list of reserved peers
**/
reservedPeers: AugmentedRpc<() => Observable<Vec<Text>>>;
/**
* Resets the log filter to Substrate defaults
**/
File diff suppressed because it is too large Load Diff
+72 -70
View File
@@ -10,8 +10,6 @@ import type { AnyFunction, AnyTuple, CallFunction, Codec, CodecArg as Arg, Defin
import type { SubmittableExtrinsic } from '../submittable/types';
import type { ApiInterfaceRx, ApiOptions, ApiTypes, DecoratedErrors, DecoratedEvents, DecoratedRpc, DecoratedRpcSection, DecorateMethod, PaginationOptions, QueryableConsts, QueryableModuleStorage, QueryableStorage, QueryableStorageEntry, QueryableStorageMulti, QueryableStorageMultiArg, SubmittableExtrinsicFunction, SubmittableExtrinsics, SubmittableModuleExtrinsics } from '../types';
import BN from 'bn.js';
import { decorateDerive, ExactDerive } from '@polkadot/api-derive';
import { memo } from '@polkadot/api-derive/util';
import { expandMetadata, Metadata } from '@polkadot/metadata';
@@ -20,7 +18,7 @@ import { WsProvider } from '@polkadot/rpc-provider';
import { TypeRegistry } from '@polkadot/types/create';
import { DEFAULT_VERSION as EXTRINSIC_DEFAULT_VERSION } from '@polkadot/types/extrinsic/constants';
import { unwrapStorageType } from '@polkadot/types/primitive/StorageKey';
import { arrayChunk, arrayFlatten, assert, compactStripLength, logger, u8aToHex } from '@polkadot/util';
import { arrayChunk, arrayFlatten, assert, BN, compactStripLength, logger, u8aToHex } from '@polkadot/util';
import { BehaviorSubject, combineLatest, Observable, of } from '@polkadot/x-rxjs';
import { map, switchMap, tap, toArray } from '@polkadot/x-rxjs/operators';
@@ -39,7 +37,8 @@ interface MetaDecoration {
}
// the max amount of keys/values that we will retrieve at once
const PAGE_SIZE = 384;
const PAGE_SIZE_K = 1000; // limit aligned with the 1k on the node (trie lookups are heavy)
const PAGE_SIZE_V = 250; // limited since the data may be very large (e.g. misfiring elections)
const l = logger('api/init');
@@ -79,7 +78,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
protected _rpc?: DecoratedRpc<ApiType, RpcInterface>;
protected _rpcCore: RpcCore;
protected _rpcCore: RpcCore & RpcInterface;
protected _runtimeChain?: Text;
@@ -136,6 +135,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
this.#instanceId = `${++instanceCounter}`;
this.#registry = options.source?.registry || options.registry || new TypeRegistry();
this._rx.registry = this.#registry;
const thisProvider = options.source
? options.source._rpcCore.provider.clone()
@@ -144,10 +144,11 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
this._decorateMethod = decorateMethod;
this._options = options;
this._type = type;
this._rpcCore = new RpcCore(this.#instanceId, this.#registry, thisProvider, this._options.rpc);
// The RPC interface decorates the known interfaces on init
this._rpcCore = new RpcCore(this.#instanceId, this.#registry, thisProvider, this._options.rpc) as (RpcCore & RpcInterface);
this._isConnected = new BehaviorSubject(this._rpcCore.provider.isConnected);
this._rx.hasSubscriptions = this._rpcCore.provider.hasSubscriptions;
this._rx.registry = this.#registry;
}
/**
@@ -260,7 +261,8 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
return allKeys;
}, []);
const unknown = exposed.filter((key) => !allKeys.includes(key));
const unknown = exposed.filter((k) => !allKeys.includes(k));
const deletion = allKnown.filter(([k]) => hasResults && !exposed.includes(k) && k !== 'rpc_methods');
if (unknown.length) {
l.warn(`RPC methods not decorated: ${unknown.join(', ')}`);
@@ -268,20 +270,13 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
// loop through all entries we have (populated in decorate) and filter as required
// only remove when we have results and method missing, or with no results if optional
allKnown
.filter(([key]): boolean => hasResults
? !exposed.includes(key) && key !== 'rpc_methods' // rpc_methods doesn't appear, v1
: key === 'rpc_methods' // we didn't find this one, remove
)
// eslint-disable-next-line @typescript-eslint/no-unused-vars
.forEach(([_, { method, section }]): void => {
delete (this._rpc as Record<string, Record<string, unknown>>)[section][method];
delete (this._rpcCore as unknown as Record<string, Record<string, unknown>>)[section][method];
delete (this._rx.rpc as Record<string, Record<string, unknown>>)[section][method];
});
deletion.forEach(([, { method, section }]): void => {
delete (this._rpc as Record<string, Record<string, unknown>>)[section][method];
delete (this._rx.rpc as Record<string, Record<string, unknown>>)[section][method];
});
}
protected _decorateRpc<ApiType extends ApiTypes> (rpc: RpcCore, decorateMethod: DecorateMethod<ApiType>, input: Partial<DecoratedRpc<ApiType, RpcInterface>> = {}): DecoratedRpc<ApiType, RpcInterface> {
protected _decorateRpc<ApiType extends ApiTypes> (rpc: RpcCore & RpcInterface, decorateMethod: DecorateMethod<ApiType>, input: Partial<DecoratedRpc<ApiType, RpcInterface>> = {}): DecoratedRpc<ApiType, RpcInterface> {
return rpc.sections.reduce((out, _sectionName): DecoratedRpc<ApiType, RpcInterface> => {
const sectionName = _sectionName as keyof DecoratedRpc<ApiType, RpcInterface>;
@@ -295,6 +290,8 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
(section as Record<string, { json: unknown }>)[methodName].json = decorateMethod(method.json, { methodName }) as unknown;
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
(section as Record<string, { raw: unknown }>)[methodName].raw = decorateMethod(method.raw, { methodName }) as unknown;
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
(section as Record<string, { meta: unknown }>)[methodName].meta = method.meta;
}
return section;
@@ -358,7 +355,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
private _decorateStorageEntry<ApiType extends ApiTypes> (creator: StorageEntry, decorateMethod: DecorateMethod<ApiType>): QueryableStorageEntry<ApiType> {
// get the storage arguments, with DoubleMap as an array entry, otherwise spread
const getArgs = (...args: unknown[]): unknown[] => extractStorageArgs(creator, args);
const getArgs = (args: unknown[]): unknown[] => extractStorageArgs(creator, args);
// Disable this where it occurs for each field we are decorating
/* eslint-disable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
@@ -367,51 +364,60 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
decorated.creator = creator;
decorated.at = decorateMethod((hash: Hash, arg1?: Arg, arg2?: Arg): Observable<Codec> =>
this._rpcCore.state.getStorage(getArgs(arg1, arg2), hash));
decorated.at = decorateMethod((hash: Hash, ...args: Arg[]): Observable<Codec> =>
this._rpcCore.state.getStorage(getArgs(args), hash));
decorated.hash = decorateMethod((arg1?: Arg, arg2?: Arg): Observable<Hash> =>
this._rpcCore.state.getStorageHash(getArgs(arg1, arg2)));
decorated.hash = decorateMethod((...args: Arg[]): Observable<Hash> =>
this._rpcCore.state.getStorageHash(getArgs(args)));
decorated.is = <A extends AnyTuple> (key: IStorageKey<AnyTuple>): key is IStorageKey<A> =>
key.section === creator.section && key.method === creator.method;
decorated.key = (arg1?: Arg, arg2?: Arg): string =>
u8aToHex(compactStripLength(creator(creator.meta.type.isDoubleMap ? [arg1, arg2] : arg1))[1]);
decorated.key = (...args: Arg[]): string =>
u8aToHex(compactStripLength(creator(
creator.meta.type.isPlain
? undefined
: creator.meta.type.isMap
? args[0]
: creator.meta.type.isDoubleMap
? [args[0], args[1]]
: args
))[1]);
decorated.keyPrefix = (key1?: Arg): string =>
u8aToHex(creator.keyPrefix(key1));
decorated.keyPrefix = (...keys: Arg[]): string =>
u8aToHex(creator.keyPrefix(...keys));
decorated.range = decorateMethod((range: [Hash, Hash?], arg1?: Arg, arg2?: Arg): Observable<[Hash, Codec][]> =>
this._decorateStorageRange(decorated, [arg1, arg2], range));
decorated.range = decorateMethod((range: [Hash, Hash?], ...args: Arg[]): Observable<[Hash, Codec][]> =>
this._decorateStorageRange(decorated, args, range));
decorated.size = decorateMethod((arg1?: Arg, arg2?: Arg): Observable<u64> =>
this._rpcCore.state.getStorageSize(getArgs(arg1, arg2)));
decorated.size = decorateMethod((...args: Arg[]): Observable<u64> =>
this._rpcCore.state.getStorageSize(getArgs(args)));
decorated.sizeAt = decorateMethod((hash: Hash | Uint8Array | string, arg1?: Arg, arg2?: Arg): Observable<u64> =>
this._rpcCore.state.getStorageSize(getArgs(arg1, arg2), hash));
decorated.sizeAt = decorateMethod((hash: Hash | Uint8Array | string, ...args: Arg[]): Observable<u64> =>
this._rpcCore.state.getStorageSize(getArgs(args), hash));
// FIXME NMap support
// .keys() & .entries() only available on map types
if (creator.iterKey && (creator.meta.type.isMap || creator.meta.type.isDoubleMap)) {
decorated.entries = decorateMethod(
memo(this.#instanceId, (doubleMapArg?: Arg): Observable<[StorageKey, Codec][]> =>
this._retrieveMapEntries(creator, null, doubleMapArg)));
memo(this.#instanceId, (...args: Arg[]): Observable<[StorageKey, Codec][]> =>
this._retrieveMapEntries(creator, null, args)));
decorated.entriesAt = decorateMethod(
memo(this.#instanceId, (hash: Hash | Uint8Array | string, doubleMapArg?: Arg): Observable<[StorageKey, Codec][]> =>
this._retrieveMapEntries(creator, hash, doubleMapArg)));
memo(this.#instanceId, (hash: Hash | Uint8Array | string, ...args: Arg[]): Observable<[StorageKey, Codec][]> =>
this._retrieveMapEntries(creator, hash, args)));
decorated.entriesPaged = decorateMethod(
memo(this.#instanceId, (opts: PaginationOptions): Observable<[StorageKey, Codec][]> =>
this._retrieveMapEntriesPaged(creator, opts)));
decorated.keys = decorateMethod(
memo(this.#instanceId, (doubleMapArg?: Arg): Observable<StorageKey[]> =>
this._retrieveMapKeys(creator, null, doubleMapArg)));
memo(this.#instanceId, (...args: Arg[]): Observable<StorageKey[]> =>
this._retrieveMapKeys(creator, null, args)));
decorated.keysAt = decorateMethod(
memo(this.#instanceId, (hash: Hash | Uint8Array | string, doubleMapArg?: Arg): Observable<StorageKey[]> =>
this._retrieveMapKeys(creator, hash, doubleMapArg)));
memo(this.#instanceId, (hash: Hash | Uint8Array | string, ...args: Arg[]): Observable<StorageKey[]> =>
this._retrieveMapKeys(creator, hash, args)));
decorated.keysPaged = decorateMethod(
memo(this.#instanceId, (opts: PaginationOptions): Observable<StorageKey[]> =>
@@ -445,7 +451,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
});
}
private _decorateStorageRange<ApiType extends ApiTypes> (decorated: QueryableStorageEntry<ApiType>, args: [Arg?, Arg?], range: [Hash, Hash?]): Observable<[Hash, Codec][]> {
private _decorateStorageRange<ApiType extends ApiTypes> (decorated: QueryableStorageEntry<ApiType>, args: Arg[], range: [Hash, Hash?]): Observable<[Hash, Codec][]> {
const outputType = unwrapStorageType(decorated.creator.meta.type, decorated.creator.meta.modifier.isOptional);
return this._rpcCore.state
@@ -464,64 +470,60 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
return of([]);
}
const queryCall = this.hasSubscriptions
? this._rpcCore.state.subscribeStorage
: this._rpcCore.state.queryStorageAt;
return combineLatest(
arrayChunk(keys, PAGE_SIZE).map((keys) =>
(this.hasSubscriptions
? this._rpcCore.state.subscribeStorage
: this._rpcCore.state.queryStorageAt
)(keys)
)
arrayChunk(keys, PAGE_SIZE_V).map((keys) => queryCall(keys))
).pipe(
map((valsArr): Codec[] => arrayFlatten(valsArr))
map(arrayFlatten)
);
}
private _retrieveMapKeys ({ iterKey, meta, method, section }: StorageEntry, at: Hash | Uint8Array | string | null, arg?: Arg): Observable<StorageKey[]> {
assert(iterKey && (meta.type.isMap || meta.type.isDoubleMap), 'keys can only be retrieved on maps, linked maps and double maps');
private _retrieveMapKeys ({ iterKey, meta, method, section }: StorageEntry, at: Hash | Uint8Array | string | null, args: Arg[]): Observable<StorageKey[]> {
assert(iterKey && (meta.type.isMap || meta.type.isDoubleMap || meta.type.isNMap), 'keys can only be retrieved on maps, linked maps and double maps');
const headKey = iterKey(arg).toHex();
const headKey = iterKey(...args).toHex();
const startSubject = new BehaviorSubject<string>(headKey);
const query = at
? (startKey: string) => this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE, startKey, at)
: (startKey: string) => this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE, startKey);
const queryCall = at
? (startKey: string) => this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE_K, startKey, at)
: (startKey: string) => this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE_K, startKey);
return startSubject.pipe(
switchMap((startKey) =>
query(startKey).pipe(
map((keys) => keys.map((key) => key.setMeta(meta, section, method)))
)
),
switchMap(queryCall),
map((keys) => keys.map((key) => key.setMeta(meta, section, method))),
tap((keys): void => {
setTimeout((): void => {
keys.length === PAGE_SIZE
? startSubject.next(keys[PAGE_SIZE - 1].toHex())
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((keysArr: StorageKey[][]) => arrayFlatten(keysArr))
map(arrayFlatten)
);
}
private _retrieveMapKeysPaged ({ iterKey, meta, method, section }: StorageEntry, opts: PaginationOptions): Observable<StorageKey[]> {
assert(iterKey && (meta.type.isMap || meta.type.isDoubleMap), 'keys can only be retrieved on maps, linked maps and double maps');
assert(iterKey && (meta.type.isMap || meta.type.isDoubleMap || meta.type.isNMap), 'keys can only be retrieved on maps, linked maps and double maps');
const headKey = iterKey(opts.arg).toHex();
const headKey = iterKey(...opts.args).toHex();
return this._rpcCore.state.getKeysPaged(headKey, opts.pageSize, opts.startKey || headKey).pipe(
map((keys) => keys.map((key) => key.setMeta(meta, section, method)))
);
}
private _retrieveMapEntries (entry: StorageEntry, at: Hash | Uint8Array | string | null, arg?: Arg): Observable<[StorageKey, Codec][]> {
private _retrieveMapEntries (entry: StorageEntry, at: Hash | Uint8Array | string | null, args: Arg[]): Observable<[StorageKey, Codec][]> {
const query = at
? (keyset: StorageKey[]) => this._rpcCore.state.queryStorageAt(keyset, at)
: (keyset: StorageKey[]) => this._rpcCore.state.queryStorageAt(keyset);
return this._retrieveMapKeys(entry, at, arg).pipe(
return this._retrieveMapKeys(entry, at, args).pipe(
switchMap((keys) =>
keys.length
? combineLatest(arrayChunk(keys, PAGE_SIZE).map(query)).pipe(
? combineLatest(arrayChunk(keys, PAGE_SIZE_V).map(query)).pipe(
map((valsArr) =>
arrayFlatten(valsArr).map((value, index): [StorageKey, Codec] => [keys[index], value])
)
-7
View File
@@ -82,13 +82,6 @@ export abstract class Getters<ApiType extends ApiTypes> extends Init<ApiType> {
return assertResult(this._genesisHash);
}
/**
* @description `true` when subscriptions are supported
*/
public get hasSubscriptions (): boolean {
return this._rpcCore.provider.hasSubscriptions;
}
/**
* @description true is the underlying provider is connected
*/
+66 -43
View File
@@ -1,28 +1,27 @@
// Copyright 2017-2021 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { RpcInterfaceMethod } from '@polkadot/rpc-core/types';
import type { Text } from '@polkadot/types';
import type { ChainProperties, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
import type { Registry } from '@polkadot/types/types';
import type { BN } from '@polkadot/util';
import type { Observable, Subscription } from '@polkadot/x-rxjs';
import type { ApiBase, ApiOptions, ApiTypes, DecorateMethod } from '../types';
import type { VersionedRegistry } from './types';
import BN from 'bn.js';
import { Metadata } from '@polkadot/metadata';
import { TypeRegistry } from '@polkadot/types/create';
import { getSpecAlias, getSpecExtensions, getSpecHasher, getSpecRpc, getSpecTypes, getUpgradeVersion } from '@polkadot/types-known';
import { assert, BN_ZERO, logger, u8aEq, u8aToHex, u8aToU8a } from '@polkadot/util';
import { assert, BN_ZERO, logger, stringify, u8aEq, u8aToHex, u8aToU8a } from '@polkadot/util';
import { cryptoWaitReady } from '@polkadot/util-crypto';
import { of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { detectedCapabilities } from './capabilities';
import { Decorate } from './Decorate';
import { detectedCapabilities } from './util';
const KEEPALIVE_INTERVAL = 15000;
const DEFAULT_BLOCKNUMBER = { unwrap: () => BN_ZERO };
const KEEPALIVE_INTERVAL = 10000;
const l = logger('api/init');
@@ -31,7 +30,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
#registries: VersionedRegistry[] = [];
#updateSub?: Subscription;
#updateSub?: Subscription | null = null;
constructor (options: ApiOptions, type: ApiTypes, decorateMethod: DecorateMethod<ApiType>) {
super(options, type, decorateMethod);
@@ -58,7 +57,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
this._rx.signer = options.signer;
this._rpcCore.setRegistrySwap((hash: string | Uint8Array) => this.getBlockRegistry(hash));
this._rpcCore.setRegistrySwap((blockHash: Uint8Array) => this.getBlockRegistry(blockHash));
if (this.hasSubscriptions) {
this._rpcCore.provider.on('disconnected', this.#onProviderDisconnect);
@@ -102,10 +101,10 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
/**
* @description Sets up a registry based on the block hash defined
*/
public async getBlockRegistry (blockHash: string | Uint8Array): Promise<VersionedRegistry> {
// shortcut in the case where we have an immediate-same request
const lastBlockHash = u8aToU8a(blockHash);
const existingViaHash = this.#registries.find((r) => r.lastBlockHash && u8aEq(lastBlockHash, r.lastBlockHash));
public async getBlockRegistry (blockHash: Uint8Array): Promise<VersionedRegistry> {
const existingViaHash = this.#registries.find(({ lastBlockHash }) =>
lastBlockHash && u8aEq(lastBlockHash, blockHash)
);
if (existingViaHash) {
return existingViaHash;
@@ -116,39 +115,45 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
// We have to assume that on the RPC layer the calls used here does not call back into
// the registry swap, so getHeader & getRuntimeVersion should not be historic
const header = this._genesisHash.eq(blockHash)
? { number: DEFAULT_BLOCKNUMBER, parentHash: this._genesisHash }
: await this._rpcCore.chain.getHeader(blockHash).toPromise();
const header = this.registry.createType('HeaderPartial',
this._genesisHash.eq(blockHash)
? { number: BN_ZERO, parentHash: this._genesisHash }
: await (this._rpcCore.chain.getHeader as RpcInterfaceMethod).json(blockHash).toPromise()
);
assert(header?.parentHash && !header.parentHash.isEmpty, 'Unable to retrieve header and parent from supplied hash');
assert(!header.parentHash.isEmpty, 'Unable to retrieve header and parent from supplied hash');
// get the runtime version, either on-chain or via an known upgrade history
const [firstVersion, lastVersion] = getUpgradeVersion(this._genesisHash, header.number.unwrap());
const version = (firstVersion && (lastVersion || firstVersion.specVersion.eq(this._runtimeVersion.specVersion)))
? { specName: this._runtimeVersion.specName, specVersion: firstVersion.specVersion }
: await this._rpcCore.state.getRuntimeVersion(header.parentHash).toPromise();
const [firstVersion, lastVersion] = getUpgradeVersion(this._genesisHash, header.number);
const version = this.registry.createType('RuntimeVersionPartial',
(firstVersion && (lastVersion || firstVersion.specVersion.eq(this._runtimeVersion.specVersion)))
? { specName: this._runtimeVersion.specName, specVersion: firstVersion.specVersion }
: await (this._rpcCore.state.getRuntimeVersion as RpcInterfaceMethod).json(header.parentHash).toPromise()
);
// check for pre-existing registries
const existingViaVersion = this.#registries.find((r) => r.specVersion.eq(version.specVersion));
const existingViaVersion = this.#registries.find(({ specVersion }) => specVersion.eq(version.specVersion));
if (existingViaVersion) {
existingViaVersion.lastBlockHash = lastBlockHash;
existingViaVersion.lastBlockHash = blockHash;
return existingViaVersion;
}
// nothing has been found, construct new
const metadata = await this._rpcCore.state.getMetadata(header.parentHash).toPromise();
const metadata = new Metadata(this.registry,
await (this._rpcCore.state.getMetadata as RpcInterfaceMethod).raw(header.parentHash).toPromise()
);
const registry = this._initRegistry(new TypeRegistry(blockHash), this._runtimeChain as Text, version, metadata);
// For now, since this is new we ignore the capability lookups (this could be useful once proven)
// this._detectCapabilities(registry, blockHash);
// add our new registry
const result = { isDefault: false, lastBlockHash, metadata, metadataConsts: null, registry, specVersion: version.specVersion };
const result = { isDefault: false, lastBlockHash: blockHash, metadata, metadataConsts: null, registry, specVersion: version.specVersion };
this.#registries.push(result);
// TODO This could be useful for historic, disabled due to cross-looping, i.e. .at queries
// this._detectCapabilities(registry, blockHash);
return result;
}
@@ -156,10 +161,10 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
// on re-connection to the same chain, we don't want to re-do everything from chain again
if (this._isReady) {
return true;
} else if (this.#updateSub) {
this.#updateSub.unsubscribe();
}
this._unsubscribeUpdates();
// only load from on-chain if we are not a clone (default path), alternatively
// just use the values from the source instance provided
[this._genesisHash, this._runtimeMetadata] = this._options.source?._isReady
@@ -190,17 +195,19 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
return [source.genesisHash, source.runtimeMetadata];
}
private _detectCapabilities (registry?: Registry, blockHash?: string | Uint8Array): void {
private _detectCapabilities (registry: Registry, blockHash?: string | Uint8Array): boolean {
detectedCapabilities(this._rx, blockHash)
.toPromise()
.then((types): void => {
if (Object.keys(types).length) {
(registry || this.registry).register(types as Record<string, string>);
registry.register(types as Record<string, string>);
l.debug(`Capabilities detected${blockHash ? ` (${u8aToHex(u8aToU8a(blockHash))})` : ''}: ${JSON.stringify(types)}`);
l.debug(() => `Capabilities detected${blockHash ? ` (${u8aToHex(u8aToU8a(blockHash))})` : ''}: ${stringify(types)}`);
}
})
.catch(l.error);
.catch(undefined);
return true;
}
// subscribe to metadata updates, inject the types on changes
@@ -235,9 +242,8 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
// clear the registry types to ensure that we override correctly
this._initRegistry(thisRegistry.registry.init(), this._runtimeChain as Text, version, metadata);
this.injectMetadata(metadata, false, thisRegistry.registry);
this._detectCapabilities(thisRegistry.registry);
return true;
return this._detectCapabilities(thisRegistry.registry);
})
)
)
@@ -280,7 +286,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
}
// get unique types & validate
metadata.getUniqTypes(false);
metadata.getUniqTypes(this._options.throwOnUnknown || false);
return [genesisHash, metadata];
}
@@ -293,15 +299,36 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
// inject metadata and adjust the types as detected
this.injectMetadata(metadata, true);
this._detectCapabilities();
// derive is last, since it uses the decorated rx
this._rx.derive = this._decorateDeriveRx(this._rxDecorateMethod);
this._derive = this._decorateDerive(this._decorateMethod);
// detect the on-chain capabilities
this._detectCapabilities(this.registry);
return true;
}
private _unsubscribeHealth (): void {
if (this.#healthTimer) {
clearInterval(this.#healthTimer);
this.#healthTimer = null;
}
}
private _unsubscribeUpdates (): void {
if (this.#updateSub) {
this.#updateSub.unsubscribe();
this.#updateSub = null;
}
}
protected _unsubscribe (): void {
this._unsubscribeHealth();
this._unsubscribeUpdates();
}
#onProviderConnect = async (): Promise<void> => {
this.emit('connected');
this._isConnected.next(true);
@@ -321,13 +348,12 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
}
this.#healthTimer = setInterval((): void => {
this._rpcCore.system.health().toPromise().catch(() => null);
this._rpcCore.system.health().toPromise().catch(() => undefined);
}, KEEPALIVE_INTERVAL);
} catch (_error) {
const error = new Error(`FATAL: Unable to initialize the API: ${(_error as Error).message}`);
l.error(error);
l.error(_error);
this.emit('error', error);
}
@@ -337,10 +363,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
this.emit('disconnected');
this._isConnected.next(false);
if (this.#healthTimer) {
clearInterval(this.#healthTimer);
this.#healthTimer = null;
}
this._unsubscribeHealth();
};
#onProviderError = (error: Error): void => {
+190
View File
@@ -0,0 +1,190 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Raw, u32 } from '@polkadot/types';
import type { Releases } from '@polkadot/types/interfaces';
import type { InterfaceTypes } from '@polkadot/types/types';
import { assert, compactFromU8a } from '@polkadot/util';
import { combineLatest, Observable, of } from '@polkadot/x-rxjs';
import { catchError, map, take } from '@polkadot/x-rxjs/operators';
// the order and types needs to map with the all array setup below
type ExtractedQ = [Releases | null];
type ExtractedR = [Raw | null, Raw | null];
type ExtractedC = [u32 | null, u32 | null];
type DetectedKeys = keyof Pick<InterfaceTypes, 'AccountInfo' | 'ValidatorPrefs'>;
type DetectedValues = keyof InterfaceTypes;
interface DetectedTypes extends Record<DetectedKeys, DetectedValues> {
AccountInfo: 'AccountInfoWithRefCount' | 'AccountInfoWithDualRefCount' | 'AccountInfoWithTripleRefCount',
Keys: 'SessionKeys1' | 'SessionKeys2' | 'SessionKeys3' | 'SessionKeys4' | 'SessionKeys5' | 'SessionKeys6' | 'SessionKeys7' | 'SessionKeys8' | 'SessionKeys9' | 'SessionKeys10';
RefCount: 'u8' | 'u32',
SlotRange: Record<string, unknown>;
ValidatorPrefs: 'ValidatorPrefsWithBlocked' | 'ValidatorPrefsWithCommission';
WinningData: string;
}
interface AvailableMap<T> {
filtered: T[];
included: boolean[];
original: T[];
}
interface Constants {
accountIdLength: number;
refcount1Length: number;
refcount2Length: number;
refcount3Length: number;
}
const NumberMap = ['Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten'];
function mapCapabilities ({ accountIdLength, refcount1Length, refcount2Length, refcount3Length }: Constants, [leasePeriodsPerSlot, slotRangeCount]: ExtractedC, [stakingVersion]: ExtractedQ, [keys, accountInfo]: ExtractedR): Partial<DetectedTypes> {
const types: Partial<DetectedTypes> = {};
// AccountInfo
if (accountInfo) {
const length = accountInfo.length;
if (length === refcount1Length) {
types.AccountInfo = 'AccountInfoWithRefCount';
} else if (length === refcount2Length) {
types.AccountInfo = 'AccountInfoWithDualRefCount';
} else if (length === refcount3Length) {
types.AccountInfo = 'AccountInfoWithTripleRefCount';
}
}
// ValidatorPrefs
if (stakingVersion) {
if (stakingVersion.index >= 4) { // v1 = index 0, V5 = index 4
types.ValidatorPrefs = 'ValidatorPrefsWithBlocked';
} else {
types.ValidatorPrefs = 'ValidatorPrefsWithCommission';
}
}
// Keys
if (keys) {
try {
const [offset, numItems] = compactFromU8a(keys);
const tupleLength = (keys.length - offset) / numItems.toNumber();
const numIds = tupleLength / accountIdLength;
const numIdsRound = Math.floor(numIds);
assert(numIds >= 2 && numIds <= 11, () => `Detected ${numIds} in Keys, should be >= 2 and <= 11`);
if (numIdsRound !== numIds) {
// Beefy?
if ((((numIdsRound - 1) * accountIdLength) + 33) === tupleLength) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
types.Keys = `SessionKeys${numIdsRound - 1}B`;
} else {
assert(false, () => `Expected integer number of keys, found ${numIds.toFixed(2)}`);
}
} else {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
types.Keys = `SessionKeys${numIds - 1}`;
}
} catch {
// ignore
}
}
// auctions
if (leasePeriodsPerSlot && slotRangeCount) {
const _enum: string[] = [];
for (let i = 0; leasePeriodsPerSlot.gtn(i); i++) {
for (let j = i; leasePeriodsPerSlot.gtn(j); j++) {
_enum.push(`${NumberMap[i]}${NumberMap[j]}`);
}
}
types.SlotRange = { _enum };
types.WinningData = `[WinningDataEntry; ${slotRangeCount.toNumber()}]`;
}
return types;
}
function filterEntries <T> (original: T[]): AvailableMap<T> {
const included = original.map((c) => !!c);
return {
filtered: original.filter((_, index) => included[index]),
included,
original
};
}
function extractResults <R, T = unknown> (results: unknown[], map: AvailableMap<T>): R {
let offset = -1;
return map.included.map((isIncluded) =>
isIncluded
? results[++offset]
: null
) as unknown as R;
}
/**
* @description Query the chain for the specific capabilities
*/
export function detectedCapabilities (api: ApiInterfaceRx, blockHash?: Uint8Array | string | undefined): Observable<Partial<DetectedTypes>> {
const emptyAccountId = api.registry.createType('AccountId');
const consts = filterEntries([
api.consts.auctions?.leasePeriodsPerSlot,
api.consts.auctions?.slotRangeCount
]);
const queries = filterEntries([
api.query.staking?.storageVersion
]);
const raws = filterEntries([
api.query.session?.queuedKeys.key(),
api.query.system?.account?.key(emptyAccountId)
]);
return combineLatest([
consts.filtered.length
? blockHash
// FIXME consts don't have .at as of yet...
? of([])
: of(consts.filtered)
: of([]),
queries.filtered.length
? blockHash
? combineLatest(queries.filtered.map((c) => c.at(blockHash)))
: api.queryMulti(queries.filtered)
: of([]),
raws.filtered.length
? blockHash
? combineLatest(raws.filtered.map((k) => api.rpc.state.getStorage.raw(k, blockHash)))
: combineLatest(raws.filtered.map((k) => api.rpc.state.getStorage.raw(k)))
: of([])
]).pipe(
map(([cResults, qResults, rResults]): Partial<DetectedTypes> =>
mapCapabilities(
{
accountIdLength: emptyAccountId.encodedLength,
refcount1Length: api.registry.createType('AccountInfoWithRefCount').encodedLength,
refcount2Length: api.registry.createType('AccountInfoWithDualRefCount').encodedLength,
refcount3Length: api.registry.createType('AccountInfoWithTripleRefCount').encodedLength
},
extractResults<ExtractedC>(cResults, consts),
extractResults<ExtractedQ>(qResults, queries),
extractResults<ExtractedR>(rResults, raws)
)
),
take(1),
catchError(() => of({}))
);
}
+2
View File
@@ -50,6 +50,8 @@ export abstract class ApiBase<ApiType extends ApiTypes> extends Getters<ApiType>
* @description Disconnect from the underlying provider, halting all network traffic
*/
public disconnect (): Promise<void> {
this._unsubscribe();
return this._rpcCore.disconnect();
}
+1 -1
View File
@@ -1,10 +1,10 @@
// Copyright 2017-2021 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type BN from 'bn.js';
import type { Metadata } from '@polkadot/metadata';
import type { Constants } from '@polkadot/metadata/decorate/types';
import type { Registry } from '@polkadot/types/types';
import type { BN } from '@polkadot/util';
export interface VersionedRegistry {
isDefault: boolean;
-82
View File
@@ -1,82 +0,0 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { bool } from '@polkadot/types';
import type { Releases } from '@polkadot/types/interfaces';
import type { InterfaceTypes } from '@polkadot/types/types';
import { combineLatest, Observable, of } from '@polkadot/x-rxjs';
import { map, take } from '@polkadot/x-rxjs/operators';
// the order and types needs to map with the all array setup below
type Extracted = [bool | null, bool | null, bool | null, Releases | null];
type DetectedKeys = keyof Pick<InterfaceTypes, 'AccountInfo' | 'ValidatorPrefs'>;
type DetectedValues = keyof InterfaceTypes;
interface DetectedTypes extends Record<DetectedKeys, DetectedValues> {
AccountInfo: 'AccountInfoWithRefCount' | 'AccountInfoWithDualRefCount' | 'AccountInfoWithTripleRefCount',
RefCount: 'u8' | 'u32',
ValidatorPrefs: 'ValidatorPrefsWithBlocked' | 'ValidatorPrefsWithCommission';
}
function mapCapabilities ([systemRefcount32, systemRefcountDual, systemRefcountTriple, stakingVersion]: Extracted): Partial<DetectedTypes> {
const types: Partial<DetectedTypes> = {};
// AccountInfo
if (systemRefcountTriple && systemRefcountTriple.isTrue) {
types.AccountInfo = 'AccountInfoWithTripleRefCount';
} else if (systemRefcountDual && systemRefcountDual.isTrue) {
types.AccountInfo = 'AccountInfoWithDualRefCount';
} else {
types.AccountInfo = 'AccountInfoWithRefCount';
if (!systemRefcount32 || systemRefcount32.isFalse) {
types.RefCount = 'u8';
}
}
// ValidatorPrefs
if (stakingVersion) {
if (stakingVersion.index >= 4) { // v1 = index 0, V5 = index 4
types.ValidatorPrefs = 'ValidatorPrefsWithBlocked';
} else {
types.ValidatorPrefs = 'ValidatorPrefsWithCommission';
}
}
return types;
}
/**
* @description Query the chain for the specific capabilities
*/
export function detectedCapabilities (api: ApiInterfaceRx, blockHash?: Uint8Array | string | undefined): Observable<Partial<DetectedTypes>> {
const all = [
api.query.system?.upgradedToU32RefCount,
api.query.system?.upgradedToDualRefCount,
api.query.system?.upgradedToTripleRefCount,
api.query.staking?.storageVersion
];
const included = all.map((c) => !!c);
const filtered = all.filter((_, index) => included[index]);
return (
filtered.length
? blockHash
? combineLatest(filtered.map((c) => c.at(blockHash)))
: api.queryMulti(filtered)
: of([])
).pipe(
map((results): Partial<DetectedTypes> => {
let offset = -1;
return mapCapabilities(
included.map((isIncluded) => isIncluded ? results[++offset] : null) as Extracted
);
}),
take(1)
);
}
+7 -1
View File
@@ -3,12 +3,12 @@
// Simple non-runnable checks to test type definitions in the editor itself
import type { HeaderExtended } from '@polkadot/api-derive/types';
import type { StorageKey } from '@polkadot/types';
import type { AccountId, Balance, DispatchErrorModule, Event, Header, Index } from '@polkadot/types/interfaces';
import type { AnyTuple, IExtrinsic, IMethod } from '@polkadot/types/types';
import { ApiPromise } from '@polkadot/api';
import { HeaderExtended } from '@polkadot/api-derive';
import { createTestPairs, TestKeyringMap } from '@polkadot/keyring/testingPairs';
import { createTypeUnsafe, TypeRegistry } from '@polkadot/types/create';
@@ -129,6 +129,12 @@ async function queryExtra (api: ApiPromise, pairs: TestKeyringMap): Promise<void
await api.query.system.account.entries(); // should not take a param
await api.query.staking.nominatorSlashInEra.entries(123); // should take a param
// nmap with keys
await api.query.assets.approvals.keys(123, 'blah');
await api.query.assets.account.keys(123);
await api.query.assets.account.entries(123);
await api.query.assets.blah.keys();
// check range
await api.query.balances.freeBalance.range<Balance>(['0x1234'], pairs.bob.address);
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api', version: '4.0.2' };
export const packageInfo = { name: '@polkadot/api', version: '4.16.1' };
+36 -22
View File
@@ -1,7 +1,9 @@
// Copyright 2017-2021 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ApiOptions, SubmittableExtrinsic } from '../types';
import type { SubmittableExtrinsic } from '../types';
import { jest } from '@jest/globals';
import { createPair } from '@polkadot/keyring/pair';
import { createTestKeyring } from '@polkadot/keyring/testing';
@@ -44,23 +46,20 @@ describe('ApiPromise', (): void => {
}
beforeEach((): void => {
jest.setTimeout(3000000);
jest.setTimeout(10000);
provider = new MockProvider(registry);
});
afterEach(async () => {
await provider.disconnect();
});
describe('initialization', (): void => {
it('Create API instance with metadata map and makes the runtime, rpc, state & extrinsics available', async (): Promise<void> => {
const rpcData = await provider.send('state_getMetadata', []);
const rpcData = await provider.send<string>('state_getMetadata', []);
const genesisHash = registry.createType('Hash', await provider.send('chain_getBlockHash', [])).toHex();
const specVersion = 0;
const metadata: any = {};
const key = `${genesisHash}-${specVersion}`;
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
metadata[key] = rpcData;
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const api = await ApiPromise.create({ metadata, provider, registry } as ApiOptions);
const api = await ApiPromise.create({ metadata: { [`${genesisHash}-${specVersion}`]: rpcData }, provider, registry });
expect(api.genesisHash).toBeDefined();
expect(api.runtimeMetadata).toBeDefined();
@@ -69,6 +68,8 @@ describe('ApiPromise', (): void => {
expect(api.query).toBeDefined();
expect(api.tx).toBeDefined();
expect(api.derive).toBeDefined();
await api.disconnect();
});
it('Create API instance without metadata and makes the runtime, rpc, state & extrinsics available', async (): Promise<void> => {
@@ -82,6 +83,8 @@ describe('ApiPromise', (): void => {
expect(api.query).toBeDefined();
expect(api.tx).toBeDefined();
expect(api.derive).toBeDefined();
await api.disconnect();
});
it('Create API instance will error on failure to await ready', async (): Promise<void> => {
@@ -90,17 +93,22 @@ describe('ApiPromise', (): void => {
super({ provider });
}
protected _loadMeta (): Promise<boolean> {
protected override _loadMeta (): Promise<boolean> {
throw new Error('Simulate failure to load meta');
}
}
const api = new ErrorApiPromise();
try {
await new ErrorApiPromise().isReadyOrError;
await api.isReadyOrError;
fail('Expected an error but none occurred.');
} catch {
// Pass
}
await api.disconnect();
});
});
@@ -110,31 +118,35 @@ describe('ApiPromise', (): void => {
const SIG = '0x659effefbbe5ab4d7136ebb5084b959eb424e32b862307371be4721ac2c46334245af4f1476c36c5e5aff04396c2fdd2ce561ec90382821d4aa071b559b1db0f';
it('signs data using a specified keyring', async (): Promise<void> => {
const api = new ApiPromise({ provider, registry });
const api = await ApiPromise.create({ provider, registry });
const sig = await api.sign(aliceEd, TEST);
expect(
await api.sign(aliceEd, TEST)
).toEqual(SIG);
expect(sig).toEqual(SIG);
await api.disconnect();
});
it('signs data using an external signer', async (): Promise<void> => {
const api = new ApiPromise({
const api = await ApiPromise.create({
provider,
registry,
signer: new SingleAccountSigner(registry, aliceEd)
});
const sig = await api.sign(ADDR, TEST);
expect(
await api.sign(ADDR, TEST)
).toEqual(SIG);
expect(sig).toEqual(SIG);
await api.disconnect();
});
});
describe('decorator.signAsync', (): void => {
it('signs a transfer using an external signer', async (): Promise<void> => {
const { transfer } = await createTransfer();
const { api, transfer } = await createTransfer();
expect(transfer.signature.toHex()).toEqual(TRANSFER_SIG);
await api.disconnect();
});
});
@@ -144,6 +156,8 @@ describe('ApiPromise', (): void => {
expect(api.tx(transfer.toHex()).signature.toHex()).toEqual(TRANSFER_SIG);
expect(api.tx(transfer).signature.toHex()).toEqual(TRANSFER_SIG);
await api.disconnect();
});
});
});
+18 -10
View File
@@ -211,7 +211,19 @@ export class ApiPromise extends ApiBase<'promise'> {
* ```
*/
public static create (options?: ApiOptions): Promise<ApiPromise> {
return new ApiPromise(options).isReady;
const instance = new ApiPromise(options);
if (options && options.throwOnConnect) {
return instance.isReadyOrError;
}
// Swallow any rejections on isReadyOrError
// (in Node 15.x this creates issues, when not being looked at)
instance.isReadyOrError.catch(() => {
// ignore
});
return instance.isReady;
}
/**
@@ -235,18 +247,14 @@ export class ApiPromise extends ApiBase<'promise'> {
super(options, 'promise', decorateMethod);
this.#isReadyPromise = new Promise((resolve): void => {
super.once('ready', (): void => {
resolve(this);
});
super.once('ready', () => resolve(this));
});
this.#isReadyOrErrorPromise = new Promise((resolve, reject): void => {
super.once('ready', (): void => {
resolve(this);
});
super.once('error', (e): void => {
reject(e);
});
const tracker = promiseTracker(resolve, reject);
super.once('ready', () => tracker.resolve(this));
super.once('error', (e) => tracker.reject(e));
});
}
-60
View File
@@ -1,60 +0,0 @@
// Copyright 2017-2021 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from '@polkadot/x-rxjs';
import type { SubmittableExtrinsic } from '../submittable/types';
import { createTestPairs } from '@polkadot/keyring/testingPairs';
import { MockProvider } from '@polkadot/rpc-provider/mock';
import { TypeRegistry } from '@polkadot/types/create';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { SingleAccountSigner } from '../../test/util';
import { ApiRx } from '.';
describe('ApiRx', (): void => {
const registry = new TypeRegistry();
const keyring = createTestPairs({ type: 'ed25519' });
let provider: MockProvider;
beforeEach((): void => {
jest.setTimeout(3000000);
provider = new MockProvider(registry);
});
describe('decorator.signAsync', (): void => {
it('signs a transfer using an external signer', (): void => {
const signer = new SingleAccountSigner(registry, keyring.alice_session);
ApiRx.create({ provider, registry, signer }).pipe(
switchMap((api: ApiRx): Observable<SubmittableExtrinsic<'rxjs'>> =>
api.tx.balances
.transfer(keyring.eve.address, 12345)
.signAsync(keyring.alice_session, {})
),
map((tx: SubmittableExtrinsic<'rxjs'>): void => {
expect(tx.signature.toHex()).toEqual(
'0x97f3cfe5088fcd575313e983f45d02b0f630e7b94ff9a3ac50e20cd096a8f554fda73d42ead891b5a1d3ce5607d83f20b0c6570b555e949cfb5763d0abcd590b'
);
})
);
});
it('allows the second argument to signAsync to be omitted', () => {
const signer = new SingleAccountSigner(registry, keyring.alice_session);
ApiRx.create({ provider, registry, signer }).pipe(
switchMap((api: ApiRx): Observable<SubmittableExtrinsic<'rxjs'>> =>
api.tx.balances
.transfer(keyring.eve.address, 12345)
.signAsync(keyring.alice_session)
),
map((tx: SubmittableExtrinsic<'rxjs'>): void => {
expect(tx.signature.toHex()).toEqual(
'0x97f3cfe5088fcd575313e983f45d02b0f630e7b94ff9a3ac50e20cd096a8f554fda73d42ead891b5a1d3ce5607d83f20b0c6570b555e949cfb5763d0abcd590b'
);
})
);
});
});
});
+1 -3
View File
@@ -165,9 +165,7 @@ export class ApiRx extends ApiBase<'rxjs'> {
this.#isReadyRx = from<Promise<ApiRx>>(
// You can create an observable from an event, however my mind groks this form better
new Promise((resolve): void => {
super.on('ready', (): void => {
resolve(this);
});
super.on('ready', () => resolve(this));
})
);
}
+5 -1
View File
@@ -32,14 +32,17 @@ export class SubmittableResult implements ISubmittableResult {
public readonly dispatchInfo?: DispatchInfo;
public readonly internalError?: Error;
public readonly events: EventRecord[];
public readonly status: ExtrinsicStatus;
constructor ({ dispatchError, dispatchInfo, events, status }: SubmittableResultValue) {
constructor ({ dispatchError, dispatchInfo, events, internalError, status }: SubmittableResultValue) {
this.dispatchError = dispatchError || extractError(events);
this.dispatchInfo = dispatchInfo || extractInfo(events);
this.events = events || [];
this.internalError = internalError;
this.status = status;
}
@@ -85,6 +88,7 @@ export class SubmittableResult implements ISubmittableResult {
dispatchError: this.dispatchError?.toHuman(),
dispatchInfo: this.dispatchInfo?.toHuman(),
events: this.events.map((event) => event.toHuman(isExtended)),
internalError: this.internalError?.message.toString(),
status: this.status.toHuman(isExtended)
};
}
+5 -2
View File
@@ -11,7 +11,7 @@ import type { AddressOrPair, SignerOptions, SubmittableDryRunResult, Submittable
import { assert, isBn, isFunction, isNumber, isString, isU8a } from '@polkadot/util';
import { of } from '@polkadot/x-rxjs';
import { first, map, mapTo, mergeMap, switchMap, tap } from '@polkadot/x-rxjs/operators';
import { catchError, first, map, mapTo, mergeMap, switchMap, tap } from '@polkadot/x-rxjs/operators';
import { ApiBase } from '../base';
import { filterEvents, isKeyringPair } from '../util';
@@ -110,7 +110,7 @@ export function createClass <ApiType extends ApiTypes> ({ api, apiType, decorate
* @description Sign a transaction, returning the this to allow chaining, i.e. .sign(...).send(). When options, e.g. nonce/blockHash are not specified, it will be inferred. To retrieve eg. nonce use `signAsync` (the preferred interface, this is provided for backwards compatibility)
* @deprecated
*/
public sign (account: IKeyringPair, optionsOrNonce?: Partial<SignerOptions>): this {
public override sign (account: IKeyringPair, optionsOrNonce?: Partial<SignerOptions>): this {
super.sign(account, this.#makeSignOptions(this.#optionsOrNonce(optionsOrNonce), {}));
return this;
@@ -242,6 +242,9 @@ export function createClass <ApiType extends ApiTypes> ({ api, apiType, decorate
events: filterEvents(hash, block, events, status),
status
}))
),
catchError((internalError: Error) =>
of(this.#transformResult(new SubmittableResult({ internalError, status })))
)
);
}
+1
View File
@@ -10,6 +10,7 @@ export interface SubmittableResultValue {
dispatchError?: DispatchError;
dispatchInfo?: DispatchInfo;
events?: EventRecord[];
internalError?: Error;
status: ExtrinsicStatus;
}
+4 -21
View File
@@ -1,30 +1,12 @@
// Copyright 2017-2021 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import type { AnyFunction, Callback, Codec, CodecArg } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
// Prepend an element V onto the beginning of a tuple T.
// Cons<1, [2,3,4]> is [1,2,3,4]
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export type Cons<V, T extends any[]> = ((v: V, ...t: T) => void) extends ((...r: infer R) => void)
? R
: never;
export type Push<T extends readonly unknown[], V> = [...T, V]
// Append an element V onto the end of a tuple T
// Push<[1,2,3],4> is [1,2,3,4]
// note that this DOES NOT PRESERVE optionality/readonly in tuples.
// So unfortunately Push<[1, 2?, 3?], 4> is [1,2|undefined,3|undefined,4]
export type Push<T extends any[], V> = (
(
Cons<any, Required<T>> extends infer R
? { [K in keyof R]: K extends keyof T ? T[K] : V }
: never
) extends infer P
? P extends any[] ? P : never
: never
);
export type DropLast<T extends readonly unknown[]> = T extends readonly [...infer U, any?] ? U : [...T];
export type ApiTypes = 'promise' | 'rxjs';
@@ -75,8 +57,9 @@ export interface DecorateMethodOptions {
export type DecorateFn <T extends Codec> = (...args: any[]) => Observable<T>;
// FIXME We need a solution for NMap
export interface PaginationOptions<ArgType = CodecArg> {
arg?: ArgType;
args: ArgType[];
pageSize: number;
startKey?: string;
}
+9 -1
View File
@@ -4,7 +4,6 @@
// Augment the modules
import '@polkadot/api/augment';
import type BN from 'bn.js';
import type { DeriveCustom, ExactDerive } from '@polkadot/api-derive';
import type { Metadata } from '@polkadot/metadata';
import type { RpcInterface } from '@polkadot/rpc-core/types';
@@ -12,6 +11,7 @@ import type { ProviderInterface, ProviderInterfaceEmitted } from '@polkadot/rpc-
import type { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types';
import type { Hash, RuntimeVersion } from '@polkadot/types/interfaces';
import type { DefinitionRpc, DefinitionRpcSub, RegisteredTypes, Registry, SignatureOptions, Signer } from '@polkadot/types/types';
import type { BN } from '@polkadot/util';
import type { ApiBase } from '../base';
import type { DeriveAllSections } from '../util/decorate';
import type { QueryableConsts } from './consts';
@@ -69,6 +69,14 @@ export interface ApiOptions extends RegisteredTypes {
* @description The source object to use for runtime information (only used when cloning)
*/
source?: ApiBase<any>;
/**
* @description Throws an error when the initial connection fails (same as isReadyOrError)
*/
throwOnConnect?: boolean;
/**
* @description Throws an error when some types are unknown (useful with throwOnConnect)
*/
throwOnUnknown?: boolean;
}
// A smaller interface of ApiRx, used in derive and in SubmittableExtrinsic
+3 -1
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import type { Json, Raw } from '@polkadot/types/codec';
import type { AnyFunction, Callback } from '@polkadot/types/types';
import type { AnyFunction, Callback, DefinitionRpc } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -11,6 +11,7 @@ import { ApiTypes, PromiseResult, Push, RxResult, UnsubscribePromise } from './b
export interface RpcRxResult<F extends AnyFunction> extends RxResult<F> {
json (...args: Parameters<F>): Observable<Json>;
raw (...args: Parameters<F>): Observable<Raw>;
meta: DefinitionRpc;
}
export interface RpcPromiseResult<F extends AnyFunction> extends PromiseResult<F> {
@@ -18,6 +19,7 @@ export interface RpcPromiseResult<F extends AnyFunction> extends PromiseResult<F
json (...args: Push<Parameters<F>, Callback<Json>>): UnsubscribePromise;
raw (...args: Parameters<F>): Promise<Raw>;
raw (...args: Push<Parameters<F>, Callback<Raw>>): UnsubscribePromise;
meta: DefinitionRpc;
}
export type RpcMethodResult<ApiType extends ApiTypes, F extends AnyFunction> = ApiType extends 'rxjs'

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