Compare commits

..
153 Commits
Author SHA1 Message Date
Github Actions 999dc6f8a5 [CI Skip] release/stable 3.7.3
skip-checks: true
2021-02-02 16:37:56 +00:00
Jaco Greeff 724574afe7 3.7.3 (w/ Polkadot 27 upgrade blocks) (#3139) 2021-02-02 17:29:43 +01:00
Github Actions 0352a30b6b [CI Skip] release/beta 3.7.3-1
skip-checks: true
2021-02-02 10:14:04 +00:00
Jaco Greeff 41b4cd5c55 Adjust known-types to use @polkadot/networks (#3138) 2021-02-02 11:06:52 +01:00
Github Actions 89f16f3123 [CI Skip] release/beta 3.7.3-0
skip-checks: true
2021-02-02 09:22:19 +00:00
Jaco Greeff 261a4eede3 Add 26 checkpoint for Polkadot (#3137) 2021-02-02 10:15:17 +01:00
Github Actions f623b382f7 [CI Skip] release/stable 3.7.2
skip-checks: true
2021-02-02 07:50:56 +00:00
Jaco Greeff 51537c619a Adjust Keys fro 28 (#3135)
* Adjust Keys fro 28

* 3.7.2
2021-02-02 08:41:24 +01:00
Github Actions 3df943572f [CI Skip] release/beta 3.7.2-0
skip-checks: true
2021-02-01 20:22:53 +00:00
Jaco Greeff aa10804f6f Westend upgrade block for 48 (#3134) 2021-02-01 21:13:58 +01:00
Github Actions 981407f00f [CI Skip] release/stable 3.7.1
skip-checks: true
2021-02-01 08:07:42 +00:00
Jaco Greeff 74f7098e0a 3.7 (#3131)
* 3.7

* Update CHANGELOG.md
2021-02-01 08:58:59 +01:00
Github Actions c2e46bf16d [CI Skip] release/beta 3.6.5-12
skip-checks: true
2021-01-31 11:55:30 +00:00
Jaco Greeff 78b26d2d40 Allow .slice on Vec types (#3130)
* Allow .slice on Vec types

* Apply suggestions from code review

* Update packages/types/src/codec/AbstractArray.ts
2021-01-31 12:48:05 +01:00
Github Actions e4d5be85f6 [CI Skip] release/beta 3.6.5-11
skip-checks: true
2021-01-31 10:12:00 +00:00
Jaco Greeff 23b5601eeb Use MultiAddress as the default type (#3123)
* Use MultiAddress as the default type

* Update tests

* Update tests
2021-01-31 11:02:54 +01:00
Github Actions 859679ce09 [CI Skip] release/beta 3.6.5-10
skip-checks: true
2021-01-31 08:38:26 +00:00
Jaco Greeff 71543c2351 Bump common (#3129) 2021-01-31 09:31:29 +01:00
Github Actions edae5057c8 [CI Skip] release/beta 3.6.5-9
skip-checks: true
2021-01-29 14:07:58 +00:00
Thibaut Sardan 8dd450ded4 no subscription for http (#3127) 2021-01-29 14:59:09 +01:00
Github Actions bc2061723e [CI Skip] release/beta 3.6.5-8
skip-checks: true
2021-01-29 10:58:08 +00:00
Jaco Greeff 5753e37307 Correctly use RelayChainBlockNumber in PersistedValidationData (#3126) 2021-01-29 11:48:46 +01:00
Github Actions e74da70a9d [CI Skip] release/beta 3.6.5-7
skip-checks: true
2021-01-28 18:35:59 +00:00
Jaco Greeff 737bbc225a Add Slot type (#3120) 2021-01-28 19:26:27 +01:00
Github Actions 9313551559 [CI Skip] release/beta 3.6.5-6
skip-checks: true
2021-01-28 15:41:03 +00:00
Jaco Greeff 5b8f53f050 Fix Kusama types order 2021-01-28 16:33:11 +01:00
Github Actions 7358e4715b [CI Skip] release/beta 3.6.5-5
skip-checks: true
2021-01-28 15:05:20 +00:00
Jaco Greeff a9005d86d6 Types for Polkadot 28+ (#3119)
* Types for Polkadot 28+

* Linting
2021-01-28 15:57:32 +01:00
Github Actions 788c05d86e [CI Skip] release/beta 3.6.5-4
skip-checks: true
2021-01-28 08:57:47 +00:00
Jaco Greeff de6ba69631 Add Kusama 2027 upgrade block (#3116) 2021-01-28 09:50:12 +01:00
Github Actions 4153fed250 [CI Skip] release/beta 3.6.5-3
skip-checks: true
2021-01-27 16:41:40 +00:00
Jaco Greeff c68b89831e Rococo MultiAddress for master (#3114) 2021-01-27 17:34:35 +01:00
Github Actions 01c9c5ed53 [CI Skip] release/beta 3.6.5-2
skip-checks: true
2021-01-27 09:30:20 +00:00
Jaco Greeff 573fb135a7 Updata parachain proposal type (#3111) 2021-01-27 10:22:25 +01:00
Github Actions 0ee7256e37 [CI Skip] release/beta 3.6.5-1
skip-checks: true
2021-01-26 20:00:28 +00:00
Jaco Greeff 9829ee558c Update CandidateDescriptor type (#3110)
* Update CandidateDescriptor type

* Add additional Cumulus missing types

* Add missing StorageProof

* trailing , :(
2021-01-26 20:51:23 +01:00
Github Actions 34b563dd48 [CI Skip] release/beta 3.6.5-0
skip-checks: true
2021-01-25 17:24:21 +00:00
Antoine Estienne f6bb200146 Adapted to display moonbeam author (#3108)
* adapted to display moonbeam author

* refactor and lint

* removed comments
2021-01-25 18:16:41 +01:00
Github Actions af36e3a52c [CI Skip] release/stable 3.6.4
skip-checks: true
2021-01-25 16:06:53 +00:00
Jaco Greeff c50c7ae6ef Remove capabilities detection log (#3107) 2021-01-25 16:59:14 +01:00
Github Actions 61739d5ba1 [CI Skip] release/stable 3.6.3
skip-checks: true
2021-01-24 16:09:21 +00:00
Jaco Greeff 34c4a6055e Jg refs (#3103)
* Remove global ref, use x-global

* Bump common
2021-01-24 17:00:49 +01:00
Github Actions 27dabdaf52 [CI Skip] release/stable 3.6.2
skip-checks: true
2021-01-24 15:18:34 +00:00
Jaco Greeff 2ee3242f41 Remove global ref, use x-global (#3102) 2021-01-24 16:11:43 +01:00
Github Actions 67ae9627af [CI Skip] release/stable 3.6.1
skip-checks: true
2021-01-24 13:00:12 +00:00
Jaco Greeff 29f7e12df6 3.6 (#3101) 2021-01-24 13:52:53 +01:00
Github Actions a4bb2c8268 [CI Skip] release/beta 3.5.2-16
skip-checks: true
2021-01-24 11:40:20 +00:00
Jaco Greeff 6521c5f533 Bump common (#3100) 2021-01-24 12:33:04 +01:00
Github Actions 6925c18821 [CI Skip] release/beta 3.5.2-15
skip-checks: true
2021-01-24 10:31:50 +00:00
Jaco Greeff 9269d94677 Bump common (#3099)
* Bump common

* Undefined value

* Test for undefined
2021-01-24 11:23:23 +01:00
Github Actions d438814ad6 [CI Skip] release/beta 3.5.2-14
skip-checks: true
2021-01-23 15:56:13 +00:00
Jaco Greeff bc205a350b Fix ChainProperties JSON decoding 2021-01-23 16:47:22 +01:00
Github Actions 6bf6fddd28 [CI Skip] release/beta 3.5.2-13
skip-checks: true
2021-01-23 13:53:50 +00:00
Jaco Greeff 23f8eb9713 Return locks for extended balance instances (#3097) 2021-01-23 14:45:17 +01:00
Github Actions 8ab3097328 [CI Skip] release/beta 3.5.2-12
skip-checks: true
2021-01-23 12:44:02 +00:00
Jaco Greeff 644d0e6c2e Change registry.chainToekn to registry.chainTokens (#3096) 2021-01-23 13:36:30 +01:00
Github Actions 6a69fdfbbf [CI Skip] release/beta 3.5.2-11
skip-checks: true
2021-01-23 11:24:22 +00:00
Jaco Greeff 16e9a64941 Allow multiples in system.properties (decimals, tokens) (#3093)
* Allow multiples in syste.propertis (decimals, tokens)

* registry.chain{Decimals, Token} returns array values

* Bump common

* AbstractInt format with first decimal/token

* Adjust ss58Format consistency

* u8 decimals/format

* cleanups

* More slight weidness

* Adjust all t u32

* Cleanup properties format from Codec
2021-01-23 12:16:10 +01:00
Github Actions f3cbc070ea [CI Skip] release/beta 3.5.2-10
skip-checks: true
2021-01-22 23:07:31 +00:00
Jaco Greeff df22526229 Bump deps (#3095) 2021-01-22 23:58:53 +01:00
Github Actions 3739bdaa89 [CI Skip] release/beta 3.5.2-9
skip-checks: true
2021-01-22 21:31:40 +00:00
Jaco Greeff 1f55f38bd2 Introduce instances, apply to balance derives (multi-result) (#3094)
* Introducce instances, apply to balance derives (multi-result)

* Nonce extraction

* Optimize
2021-01-22 22:24:10 +01:00
Github Actions c9deb0d88f [CI Skip] release/beta 3.5.2-8
skip-checks: true
2021-01-22 16:29:02 +00:00
Jaco Greeff eecfb39463 Bump common (#3092) 2021-01-22 17:21:33 +01:00
Github Actions 51bb27da42 [CI Skip] release/beta 3.5.2-7
skip-checks: true
2021-01-22 08:21:12 +00:00
Jaco Greeff 9c0d296e87 typegen dedup (#3089) 2021-01-22 09:12:29 +01:00
Github Actions 0793e0bf8c [CI Skip] release/beta 3.5.2-6
skip-checks: true
2021-01-21 21:45:15 +00:00
Jaco Greeff e9ad88d50e Register all types for error generation (#3088)
* Register all types for error generation

* type for ExtraTypes
2021-01-21 22:37:37 +01:00
Github Actions fbe24c04b8 [CI Skip] release/beta 3.5.2-5
skip-checks: true
2021-01-21 10:08:55 +00:00
Jaco Greeff 8a7d4d3be3 Bump metadata (#3085)
* Bump metadata

* linting
2021-01-21 11:01:31 +01:00
Github Actions 61c9a3bb93 [CI Skip] release/beta 3.5.2-4
skip-checks: true
2021-01-21 08:39:46 +00:00
Jaco Greeff 3721a11f34 Add errors/events Md interface endpoints (#3084) 2021-01-21 09:31:40 +01:00
Github Actions 21039dec1f [CI Skip] release/beta 3.5.2-3
skip-checks: true
2021-01-19 21:54:16 +00:00
Jaco Greeff 1393f565d8 Paras validator index alias (#3079) 2021-01-19 22:46:49 +01:00
Jaco Greeff 1530e55f9d Disallow primitive singular registration (#3077) 2021-01-19 22:46:29 +01:00
Github Actions c982505f73 [CI Skip] release/beta 3.5.2-2
skip-checks: true
2021-01-19 21:15:33 +00:00
Jaco Greeff ec8c0d3e8b Move x-rxjs into common (#3078)
* Moe x-rxjs into common

* yarn

* jest config

* Pull in new pubslished x-rxjs
2021-01-19 22:08:03 +01:00
Github Actions 8cb0269676 [CI Skip] release/beta 3.5.2-1
skip-checks: true
2021-01-19 12:27:07 +00:00
Jaco Greeff 27f460cfe3 Add payment_queryFeeDetails (#3076) 2021-01-19 13:18:23 +01:00
Jaco Greeff e98e8d6a0d Type capability detection (#3075)
* Type capability detection

* re-add Observable export

* Remove unused exports

* Decorate capabilities

* log capabilities

* Detect capabilities for historic

* Re-add logging

* Log

* Rework ValidatorPrefs types
2021-01-19 13:15:18 +01:00
Github Actions 2f94662837 [CI Skip] release/beta 3.5.2-0
skip-checks: true
2021-01-19 10:49:10 +00:00
Jaco Greeff d46d6a9acd Add ValidatorPrefs w/ blocked flag (#3073) 2021-01-19 11:41:23 +01:00
Github Actions 093d2cfa7c [CI Skip] release/stable 3.5.1
skip-checks: true
2021-01-18 11:37:28 +00:00
Jaco Greeff 35b31a21dc 3.5 (#3071) 2021-01-18 12:29:58 +01:00
Github Actions 8b9741a722 [CI Skip] release/beta 3.4.2-18
skip-checks: true
2021-01-18 08:42:18 +00:00
Ewa Kowalska d5cfa9b0e9 Handle no council for bounties proposals (#3062)
* Handle no council for bounties proposals

* Fix code climate

* Handle no council present with api derive
2021-01-18 09:33:20 +01:00
Github Actions 129d1214fe [CI Skip] release/beta 3.4.2-17
skip-checks: true
2021-01-17 15:11:37 +00:00
Jaco Greeff abb3375c3a Bump common (& Substrate node references) (#3069) 2021-01-17 16:04:26 +01:00
Github Actions 4cfa06b43f [CI Skip] release/beta 3.4.2-16
skip-checks: true
2021-01-17 13:30:25 +00:00
Jaco Greeff 8fa80ac0f6 Adjust node-template for MultiAddress (>= 100) (#3068)
* Adjust node-template for MultiAddress (>= 100)

* Bump deps
2021-01-17 14:22:09 +01:00
Github Actions 2d011c68df [CI Skip] release/beta 3.4.2-15
skip-checks: true
2021-01-17 12:48:44 +00:00
Jaco Greeff 640ef4bdab Adjust Rococo types (#3067) 2021-01-17 13:39:29 +01:00
Github Actions cdd20c0b99 [CI Skip] release/beta 3.4.2-14
skip-checks: true
2021-01-15 21:41:55 +00:00
Jaco Greeff 3a12123bf9 Remove recursion on decodeU8a (#3063)
* Remove recursion on decodeU8a

* Remove skipped tests

* Remove extra allocation
2021-01-15 22:34:30 +01:00
Github Actions 5657d5395b [CI Skip] release/beta 3.4.2-13
skip-checks: true
2021-01-15 15:14:00 +00:00
Jeremías Díaz 66b1108c5c feat(types): add correct tuple type to storage key (#3054)
* feat(types): add correct tuple type to storage key

* refactor(types): remove unneeded type assertions
2021-01-15 16:06:23 +01:00
Github Actions 7bf7e207c2 [CI Skip] release/beta 3.4.2-12
skip-checks: true
2021-01-15 13:38:01 +00:00
Jaco Greeff 01098395ec Add crowdloan types (#3060)
* Add crowdloan types

* Update
2021-01-15 14:28:57 +01:00
Github Actions 3e21dfdc03 [CI Skip] release/beta 3.4.2-11
skip-checks: true
2021-01-15 12:56:17 +00:00
Jaco Greeff a400fb2362 Sort registry (#3061) 2021-01-15 13:49:12 +01:00
Github Actions 44172aa359 [CI Skip] release/beta 3.4.2-10
skip-checks: true
2021-01-15 11:32:08 +00:00
Jaco Greeff 82cab2827a Add lottery types (#3059) 2021-01-15 12:23:19 +01:00
Github Actions a198eb1515 [CI Skip] release/beta 3.4.2-9
skip-checks: true
2021-01-15 10:57:12 +00:00
Jaco Greeff 6e67cd6c97 Bump common (#3058) 2021-01-15 11:48:25 +01:00
Github Actions e51e89df56 [CI Skip] release/beta 3.4.2-8
skip-checks: true
2021-01-13 23:12:15 +00:00
Jaco Greeff e46fd07d39 align aura/babe without staking 2021-01-14 00:03:28 +01:00
Jaco Greeff b2cf9aed83 Info changes for no staking (but with babe) 2021-01-14 00:01:42 +01:00
Jaco Greeff c632030437 Fix derive session.info with no staking 2021-01-13 23:59:59 +01:00
Github Actions 9dc683d289 [CI Skip] release/beta 3.4.2-7
skip-checks: true
2021-01-13 22:53:45 +00:00
Jaco Greeff 6cef6190b1 Optional staking in session progress calcs (#3051)
* Optional staking in session progress calcs

* No extra pipe
2021-01-13 23:46:15 +01:00
Github Actions 75dd443d79 [CI Skip] release/beta 3.4.2-6
skip-checks: true
2021-01-13 12:14:07 +00:00
Jaco Greeff 13dacb591d Updata parachain types (#3050) 2021-01-13 13:07:07 +01:00
Jaco Greeff 429bf5456e Add tests for toBigInt usage (#3049)
* Add tests for toBigInt usage

* Update packages/types/src/codec/UInt.spec.ts
2021-01-13 13:00:10 +01:00
Github Actions 527c0f5015 [CI Skip] release/beta 3.4.2-5
skip-checks: true
2021-01-13 10:19:11 +00:00
Jaco Greeff 527ab27bee Westend 46, 47 blocks (#3044) 2021-01-13 11:09:33 +01:00
Github Actions 7991403022 [CI Skip] release/beta 3.4.2-4
skip-checks: true
2021-01-13 08:07:59 +00:00
Ian He 61d2e6c5e5 toBigInt() uses primitive type bigint (#3047) 2021-01-13 09:01:11 +01:00
Github Actions e005a3fc0c [CI Skip] release/beta 3.4.2-3
skip-checks: true
2021-01-12 13:54:07 +00:00
Jaco Greeff 2dfb0fb59a Dedupe parachain types (#3043)
* Updata parachain types

* Remove duplication

* hrmp update
2021-01-12 14:46:57 +01:00
Github Actions 70c011e7e2 [CI Skip] release/beta 3.4.2-2
skip-checks: true
2021-01-12 13:23:32 +00:00
Jaco Greeff 8134322626 Updata parachain types (#3042) 2021-01-12 14:14:54 +01:00
Github Actions 60152749bb [CI Skip] release/beta 3.4.2-1
skip-checks: true
2021-01-11 23:27:12 +00:00
Jaco Greeff b257e120d4 Update parachain types (#3041) 2021-01-12 00:20:20 +01:00
Github Actions 6dc75acd21 [CI Skip] release/beta 3.4.2-0
skip-checks: true
2021-01-11 15:44:17 +00:00
Jaco Greeff a04400170c Set Rococo Keys to 6 (#3040) 2021-01-11 16:36:32 +01:00
Github Actions e3f16e6066 [CI Skip] release/stable 3.4.1
skip-checks: true
2021-01-11 08:13:52 +00:00
Jaco Greeff c3b697d52d 3.4 (#3037) 2021-01-11 09:04:19 +01:00
Github Actions 645fb58e82 [CI Skip] release/beta 3.3.3-5
skip-checks: true
2021-01-10 09:27:13 +00:00
icodezjb 474e509507 Update SessionKeys (#3035)
SessionKeys6, SessionKeys7, SessionKeys8, SessionKeys9
2021-01-10 10:19:55 +01:00
Github Actions df9aff3bac [CI Skip] release/beta 3.3.3-4
skip-checks: true
2021-01-08 16:15:40 +00:00
Jaco Greeff caface921e Adjust max signed check (#3034) 2021-01-08 17:08:04 +01:00
Github Actions ba9cc785c1 [CI Skip] release/beta 3.3.3-3
skip-checks: true
2021-01-08 13:51:18 +00:00
Jaco Greeff 4ff9b51af2 Add API option for chain-specific signedExtensions (#3033)
* Add API option for chain-specific signedExtensions

* typo
2021-01-08 14:42:26 +01:00
Github Actions 2c20a9f395 [CI Skip] release/beta 3.3.3-2
skip-checks: true
2021-01-08 10:28:58 +00:00
Jaco Greeff ee17aa7464 Fix v12 static json 2021-01-08 11:20:18 +01:00
Jaco Greeff 2d01a7b593 Update alias mapping (asset Balance in events) 2021-01-08 11:01:48 +01:00
Github Actions 000e8089d9 [CI Skip] release/beta 3.3.3-1
skip-checks: true
2021-01-08 09:53:41 +00:00
Jaco Greeff 43000b6aaf Update contract types (#3032)
* Update contract types

* Add registry lookup name compat

* cleanup

* Rebuild ts defs
2021-01-08 10:46:12 +01:00
Github Actions 0f8b204db8 [CI Skip] release/beta 3.3.3-0
skip-checks: true
2021-01-07 18:53:56 +00:00
Jaco Greeff 679f4103e1 Fix EthTransaction to ethereum crate (#3030)
* Fix (alhabetically sorted??) EthTransaction

* EthTransaction from ethereum crate
2021-01-07 19:45:37 +01:00
Github Actions 6c61708eff [CI Skip] release/stable 3.3.2
skip-checks: true
2021-01-06 17:30:18 +00:00
Jaco Greeff f0ce53f5a5 dispatchInfo on failed 2021-01-06 18:20:52 +01:00
Jaco Greeff d826ac85fa Event check index (#3028)
* Event check index

* patch
2021-01-06 18:18:08 +01:00
Github Actions 18a81fbbcb [CI Skip] release/beta 3.3.2-4
skip-checks: true
2021-01-06 10:56:45 +00:00
Jeremías Díaz 9ab59c9241 fix(typegen): support vecs of tuples in enums (#3022) 2021-01-06 11:48:32 +01:00
Github Actions 0161996cf6 [CI Skip] release/beta 3.3.2-3
skip-checks: true
2021-01-06 09:51:22 +00:00
Jaco Greeff 99463a3f1d Return result with entries with 0 keys (#3025)
* Return result with entries with 0 keys

* Cleanup
2021-01-06 10:42:53 +01:00
Github Actions cec4c69374 [CI Skip] release/beta 3.3.2-2
skip-checks: true
2021-01-05 13:13:44 +00:00
Jaco Greeff 44077c7cf6 Add ParaGenesisArgs type (#3021) 2021-01-05 14:04:50 +01:00
Github Actions ac7b1bdeeb [CI Skip] release/beta 3.3.2-1
skip-checks: true
2021-01-05 11:30:57 +00:00
Jaco Greeff 1c86333b5f derive.chain.getBlock() now maps events to extrinsics (#3020)
* derive.chain.getBlock() now maps events to extrinsics

* Also apply to subscribeNewBlocks

* Cleanup

* breaking
2021-01-05 12:21:58 +01:00
Github Actions da4108ff9b [CI Skip] release/beta 3.3.2-0
skip-checks: true
2021-01-05 09:46:04 +00:00
Ewa Kowalska 0c5fc15935 Add motions to bounty derive (#3016)
* Add proposals to BountyDerive

* Extract filterBountiesProposals method

* Apply review suggestions
2021-01-05 10:37:45 +01:00
153 changed files with 5950 additions and 4323 deletions
+7
View File
@@ -8,3 +8,10 @@
2.8.2 2.8.2
3.2.2 3.2.2
3.2.3 3.2.3
3.3.2
3.6.2
3.6.3
3.6.4
3.7.2
3.7.3
+108
View File
@@ -1,5 +1,113 @@
# CHANGELOG # CHANGELOG
## 3.7.3 Feb 2, 2021
Changes:
- Added Polkadot upgrade block for runtime 27 (known checkpoint optimization)
## 3.7.2 Feb 2, 2021
Changes:
- Adjusted the `Keys` type for the 28 runtime on Kusama, Polkadot & Westend
## 3.7.1 Feb 1, 2021
Upgrade priority: Low. However recommended for current Substrate master, Polkadot and Rococo users and those wishing to support the upcoming Polkadot 28 runtime with the new `MultiAddress`.
- **Breaking change** As indicated in the 3.5.1 release notes, the `Address`/`LookupSource` defaults have now been adjusted for `MultiAddress`. If your chain does not use these types, explicitly add the correct `Address`/`LookupSource` types. This new extensible format is mean to cater for all address types into the future, removing a lot of discrepancies between chains.
Contributed:
- Extraction of the block author on Moonbeam (Thanks to https://github.com/joelamouche)
- Cleanup logs with HTTP providers, no subs (Thanks to https://github.com/Tbaut)
Changes:
- Allow `.slice` operator on the `Vec` type
- Apply `MultiAddress` as a default
- Adds support for the upcoming Polkadot 28 and Kusama 2028 runtimes
- Add checkpoint for Kusama 2027 upgrade
- Update all parachain types (as per latest Rococo)
- Correctly use relay blockNumber in parachain validation data
- remove information log for capabilities detection (creates confusion)
- Remove explicit references to `global`, use the `x-global` detection
- Remove explicit `module` in `package.json` (exports map available)
## 3.6.1 Jan 24, 2020
Upgrade priority: Medium if not already on at least 3.3.1. The next upgrade of Kusama/Polkadot requires it.
- **Breaking change** To support chains with multiple tokens, such as bridges, the `ChainProperties` type now returns an array of tokens and decimals (instead of singular values) in the `token{Decimals, Symbol}` getters. Additionally, this means that the `registry` interfaces has been changes, to `registry.chainDecimals: number[]` and `registry.chainTokens: string[]`. Where used the `[0]` index will return the first value if only interested in a single, for a straight conversion.
Changes:
- Allow for the detection of on-chain capabilities as available (e.g. `AccountData`, `ValidatorPrefs`)
- Cater for multiple tokens and decimals in the chain the chain `system.properties` (as per the chain specification)
- Add a `instances: { [key]: [module1, module2] }` definition in teh bundle types, allowing for multiple instances (e.g. Balances)
- Adjust the `api-derive` for balances to retrieve values via `instances` as well as across multiple modules
- Ensure all types are registered for all metadata typegen steps
- Add `rpc.payment.queryFeeDetails` RPC endpoint
- Update types & metadata to latest Substrate
- Move the `@polkadot/x-rxjs` package into the common repo
- Allow doc generation for errors/events (markdown outputs)
## 3.5.1 Jan 18, 2020
Upgrade priority: Low. Recommended for parachain developers.
- **Important** The default for Substrate on the Address types are `MultiAddress`. It is recommended that chains add explicit definitions for `Address` and `LookupSource` in their types, instead of relying on the API-defaults. A future update will swap the API defaults to align with Substrate.
- **Important** Like the above changes in Substrate, the `AccountInfo` structure has also changed. It is recommended that chain developers explicitly add `AccountInfo: 'AccountInfoWithRefCount'` for the version with `refCount` on and `AccountInfoWithProviders` for the latest Substrate version. As per the above, the API defaults will be changed to align with Substrate.
Contributed:
- Apply correct TypeScript type for `toBigInt()` (Thanks to https://github.com/ianhe8x)
- Expand type definitions for storage key tuples (Thanks to https://github.com/monitz87)
- Adjust bounty derive to cater for non-council chains (Thanks to https://github.com/ekowalsk)
Changes:
- Remove recursion in vector/struct U8a stream decoding
- Availability of staking made optional in session length calcs (era does require it)
- Updates to parachain types, ensuring it has coverage for all the latest
- Update all Rococo types to the latest (session keys, session reports, parachain indexes)
- Update known upgrade checkpoints fo WestEnd
- Add types of the lottery module in Substrate
- Add and extend types for the crowdloan module in Polkadot
- Adjust node-template to default to `MultiAddress` on specVersion >= 100
## 3.4.1 Jan 11, 2020
Upgrade priority: Low. Fixes for parachain types, `.entries()` (with no values) and `event.is(...)` checks, users of these interfaces will have benefit.
- **Breaking change** The `derive.chain.{getBlock, subscribeNewBlocks}` now return `SignedBlockExtended`, all with the actual extrinsics and events mapped. Users of the latter interface should take note.
Contributed:
- Fix `SessionKeys{6-9}` definitions (Thanks to https://github.com/icodezjb)
- Support `Vec<(a, b)>` in enums (Thanks to https://github.com/monitz87)
- Add motions to bounty derive (Thanks to https://github.com/ekowalsk)
Changes:
- `derive.chain.getBlock()` now maps events to extrinsics via `.extrinsics` getter
- Ensure dispatchInfo is extracted on failed extrinsics (`getBlock` derive)
- Allow specification of additional signed extrinsic via API options
- Add missing parachain types, `ParaGenesisArgs`
- Correct `EthTransaction` type (as per the correct cargo crate)
- Update with latest contract types for Substrate master
- Update alias mapping for asset palette (including Substrate starting defaults)
- Allow `.entries()` call where 0 keys are present
- Fix `.is` on events not checking the correct index
- Construction of `i*` types ow correctly checks for max positive/negative
## 3.3.1 Jan 4, 2021 ## 3.3.1 Jan 4, 2021
Upgrade priority: Low. Recommended for users of frontier evm module with additional types. Upgrade priority: Low. Recommended for users of frontier evm module with additional types.
+2 -4
View File
@@ -13,8 +13,7 @@ module.exports = Object.assign({}, config, {
'@polkadot/typegen(.*)$': '<rootDir>/packages/typegen/src/$1', '@polkadot/typegen(.*)$': '<rootDir>/packages/typegen/src/$1',
'@polkadot/types-known(.*)$': '<rootDir>/packages/types-known/src/$1', '@polkadot/types-known(.*)$': '<rootDir>/packages/types-known/src/$1',
// eslint-disable-next-line sort-keys // eslint-disable-next-line sort-keys
'@polkadot/types(.*)$': '<rootDir>/packages/types/src/$1', '@polkadot/types(.*)$': '<rootDir>/packages/types/src/$1'
'@polkadot/x-rxjs(.*)$': '<rootDir>/packages/x-rxjs/src/$1'
}, },
modulePathIgnorePatterns: [ modulePathIgnorePatterns: [
'<rootDir>/packages/api/build', '<rootDir>/packages/api/build',
@@ -25,8 +24,7 @@ module.exports = Object.assign({}, config, {
'<rootDir>/packages/rpc-provider/build', '<rootDir>/packages/rpc-provider/build',
'<rootDir>/packages/typegen/build', '<rootDir>/packages/typegen/build',
'<rootDir>/packages/types/build', '<rootDir>/packages/types/build',
'<rootDir>/packages/types-known/build', '<rootDir>/packages/types-known/build'
'<rootDir>/packages/x-rxjs/build'
], ],
resolver: '@polkadot/dev/config/jest-resolver.cjs' resolver: '@polkadot/dev/config/jest-resolver.cjs'
}); });
+3 -3
View File
@@ -28,11 +28,11 @@
"@babel/core": "^7.12.10", "@babel/core": "^7.12.10",
"@babel/register": "^7.12.10", "@babel/register": "^7.12.10",
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@polkadot/dev": "^0.61.22", "@polkadot/dev": "^0.61.24",
"@polkadot/ts": "^0.3.59", "@polkadot/ts": "^0.3.59",
"@polkadot/typegen": "workspace:packages/typegen", "@polkadot/typegen": "workspace:packages/typegen",
"@types/jest": "^26.0.19", "@types/jest": "^26.0.20",
"copyfiles": "^2.4.1" "copyfiles": "^2.4.1"
}, },
"version": "3.3.1" "version": "3.7.3"
} }
+5 -6
View File
@@ -1,9 +1,8 @@
{ {
"name": "@polkadot/api-contract", "name": "@polkadot/api-contract",
"version": "3.3.1", "version": "3.7.3",
"description": "Interfaces for interacting with contracts and contract ABIs", "description": "Interfaces for interacting with contracts and contract ABIs",
"main": "index.js", "main": "index.js",
"module": "index.mjs",
"sideEffects": false, "sideEffects": false,
"author": "Jaco Greeff <jacogr@gmail.com>", "author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [], "maintainers": [],
@@ -14,10 +13,10 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme", "homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@polkadot/api": "3.3.1", "@polkadot/api": "3.7.3",
"@polkadot/types": "3.3.1", "@polkadot/types": "3.7.3",
"@polkadot/util": "^5.2.3", "@polkadot/util": "^5.5.2",
"@polkadot/x-rxjs": "3.3.1", "@polkadot/x-rxjs": "^5.5.2",
"bn.js": "^4.11.9" "bn.js": "^4.11.9"
} }
} }
+9 -10
View File
@@ -1,9 +1,8 @@
{ {
"name": "@polkadot/api-derive", "name": "@polkadot/api-derive",
"version": "3.3.1", "version": "3.7.3",
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.", "description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
"main": "index.js", "main": "index.js",
"module": "index.mjs",
"sideEffects": false, "sideEffects": false,
"author": "Jaco Greeff <jacogr@gmail.com>", "author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [], "maintainers": [],
@@ -14,16 +13,16 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme", "homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@polkadot/api": "3.3.1", "@polkadot/api": "3.7.3",
"@polkadot/rpc-core": "3.3.1", "@polkadot/rpc-core": "3.7.3",
"@polkadot/types": "3.3.1", "@polkadot/types": "3.7.3",
"@polkadot/util": "^5.2.3", "@polkadot/util": "^5.5.2",
"@polkadot/util-crypto": "^5.2.3", "@polkadot/util-crypto": "^5.5.2",
"@polkadot/x-rxjs": "3.3.1", "@polkadot/x-rxjs": "^5.5.2",
"bn.js": "^4.11.9" "bn.js": "^4.11.9"
}, },
"devDependencies": { "devDependencies": {
"@polkadot/keyring": "^5.2.3", "@polkadot/keyring": "^5.5.2",
"@polkadot/rpc-provider": "3.3.1" "@polkadot/rpc-provider": "3.7.3"
} }
} }
+1 -2
View File
@@ -2,7 +2,6 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx } from '@polkadot/api/types'; import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AccountIndex } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs'; import type { Observable } from '@polkadot/x-rxjs';
import type { AccountIndexes } from '../types'; import type { AccountIndexes } from '../types';
@@ -18,7 +17,7 @@ function queryAccounts (api: ApiInterfaceRx): Observable<AccountIndexes> {
map((entries): AccountIndexes => map((entries): AccountIndexes =>
entries.reduce((indexes: AccountIndexes, [key, idOpt]): AccountIndexes => { entries.reduce((indexes: AccountIndexes, [key, idOpt]): AccountIndexes => {
if (idOpt.isSome) { if (idOpt.isSome) {
indexes[idOpt.unwrap()[0].toString()] = key.args[0] as AccountIndex; indexes[idOpt.unwrap()[0].toString()] = key.args[0];
} }
return indexes; return indexes;
+52 -25
View File
@@ -1,24 +1,24 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors // Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx } from '@polkadot/api/types'; import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
import type { AccountData, AccountId, AccountIndex, AccountInfo, Address, Balance, Index } from '@polkadot/types/interfaces'; import type { AccountData, AccountId, AccountIndex, AccountInfo, Address, Balance, Index } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types'; import type { ITuple } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs'; import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveBalancesAccount } from '../types'; import type { DeriveBalancesAccount, DeriveBalancesAccountData } from '../types';
import { isFunction } from '@polkadot/util'; import { assert, isFunction } from '@polkadot/util';
import { combineLatest, of } from '@polkadot/x-rxjs'; import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators'; import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { memo } from '../util'; import { memo } from '../util';
type Result = [Balance, Balance, Balance, Balance, Index]; type BalanceResult = [Balance, Balance, Balance, Balance];
function calcBalances (api: ApiInterfaceRx, [accountId, [freeBalance, reservedBalance, frozenFee, frozenMisc, accountNonce]]: [AccountId, Result]): DeriveBalancesAccount { type Result = [Index, BalanceResult[]];
function getBalance (api: ApiInterfaceRx, [freeBalance, reservedBalance, frozenFee, frozenMisc]: BalanceResult): DeriveBalancesAccountData {
return { return {
accountId,
accountNonce,
freeBalance, freeBalance,
frozenFee, frozenFee,
frozenMisc, frozenMisc,
@@ -27,6 +27,19 @@ function calcBalances (api: ApiInterfaceRx, [accountId, [freeBalance, reservedBa
}; };
} }
function calcBalances (api: ApiInterfaceRx, [accountId, [accountNonce, balances]]: [AccountId, Result]): DeriveBalancesAccount {
const primary = balances[0];
assert(primary, 'No balances retrieved for account');
return {
accountId,
accountNonce,
additional: balances.filter((_, index) => index !== 0).map((b) => getBalance(api, b)),
...getBalance(api, primary)
};
}
// old // old
function queryBalancesFree (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> { function queryBalancesFree (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
return api.queryMulti<[Balance, Balance, Index]>([ return api.queryMulti<[Balance, Balance, Index]>([
@@ -34,21 +47,25 @@ function queryBalancesFree (api: ApiInterfaceRx, accountId: AccountId): Observab
[api.query.balances.reservedBalance, accountId], [api.query.balances.reservedBalance, accountId],
[api.query.system.accountNonce, accountId] [api.query.system.accountNonce, accountId]
]).pipe( ]).pipe(
map(([freeBalance, reservedBalance, accountNonce]): Result => map(([freeBalance, reservedBalance, accountNonce]): Result => [
[freeBalance, reservedBalance, api.registry.createType('Balance'), api.registry.createType('Balance'), accountNonce] accountNonce,
) [[freeBalance, reservedBalance, api.registry.createType('Balance'), api.registry.createType('Balance')]]
])
); );
} }
function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> { function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId, modules: string[] = ['balances']): Observable<Result> {
return api.queryMulti<[AccountData, Index]>([ const balances = modules.map((m): QueryableStorageMultiArg<'rxjs'> => [api.query[m].account, accountId]);
[api.query.balances.account, accountId], const extract = (data: AccountData[]) =>
[api.query.system.accountNonce, accountId] data.map(({ feeFrozen, free, miscFrozen, reserved }): BalanceResult => [free, reserved, feeFrozen, miscFrozen]);
]).pipe(
map(([{ feeFrozen, free, miscFrozen, reserved }, accountNonce]): Result => return isFunction(api.query.system.account)
[free, reserved, feeFrozen, miscFrozen, accountNonce] ? api.queryMulti<[AccountInfo, ...(AccountData[])]>([[api.query.system.account, accountId], ...balances]).pipe(
map(([{ nonce }, ...balances]): Result => [nonce, extract(balances)])
) )
); : api.queryMulti<[Index, ...(AccountData[])]>([[api.query.system.accountNonce, accountId], ...balances]).pipe(
map(([nonce, ...balances]): Result => [nonce, extract(balances)])
);
} }
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> { function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
@@ -60,7 +77,7 @@ function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Re
: (infoOrTuple as [Index, AccountData])[1]; : (infoOrTuple as [Index, AccountData])[1];
const accountNonce = (infoOrTuple as AccountInfo).nonce || (infoOrTuple as [Index, AccountData])[0]; const accountNonce = (infoOrTuple as AccountInfo).nonce || (infoOrTuple as [Index, AccountData])[0];
return [free, reserved, feeFrozen, miscFrozen, accountNonce]; return [accountNonce, [[free, reserved, feeFrozen, miscFrozen]]];
}) })
); );
} }
@@ -81,19 +98,29 @@ function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Re
* ``` * ```
*/ */
export function account (instanceId: string, api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAccount> { export function account (instanceId: string, api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAccount> {
const balanceInstances = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), 'balances');
return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAccount> => return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAccount> =>
api.derive.accounts.accountId(address).pipe( api.derive.accounts.accountId(address).pipe(
switchMap((accountId): Observable<[AccountId, Result]> => switchMap((accountId): Observable<[AccountId, Result]> =>
(accountId (accountId
? combineLatest([ ? combineLatest([
of(accountId), of(accountId),
isFunction(api.query.system.account) balanceInstances
? queryCurrent(api, accountId) ? queryBalancesAccount(api, accountId, balanceInstances)
: isFunction(api.query.balances.account) : isFunction(api.query.system.account)
? queryBalancesAccount(api, accountId) ? queryCurrent(api, accountId)
: queryBalancesFree(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')]]
]
]) ])
: of([api.registry.createType('AccountId'), [api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Index')]])
) )
), ),
map((result): DeriveBalancesAccount => calcBalances(api, result)) map((result): DeriveBalancesAccount => calcBalances(api, result))
+54 -36
View File
@@ -1,21 +1,23 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors // Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx } from '@polkadot/api/types'; import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
import type { Option, Vec } from '@polkadot/types'; import type { Option, Vec } from '@polkadot/types';
import type { AccountId, AccountIndex, Address, Balance, BalanceLock, BalanceLockTo212, BlockNumber, VestingInfo, VestingSchedule } from '@polkadot/types/interfaces'; import type { AccountId, AccountIndex, Address, Balance, BalanceLock, BalanceLockTo212, BlockNumber, VestingInfo, VestingSchedule } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs'; import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveBalancesAccount, DeriveBalancesAll } from '../types'; import type { DeriveBalancesAccount, DeriveBalancesAccountData, DeriveBalancesAll, DeriveBalancesAllAccountData } from '../types';
import BN from 'bn.js'; import BN from 'bn.js';
import { bnMax, isFunction } from '@polkadot/util'; import { bnMax } from '@polkadot/util';
import { combineLatest, of } from '@polkadot/x-rxjs'; import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators'; import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { memo } from '../util'; import { memo } from '../util';
type ResultBalance = [VestingInfo | null, (BalanceLock | BalanceLockTo212)[]]; type BalanceLocksEntry = Vec<BalanceLock | BalanceLockTo212>;
type BalanceLocks = BalanceLocksEntry[];
type ResultBalance = [VestingInfo | null, ((BalanceLock | BalanceLockTo212)[])[]];
type Result = [DeriveBalancesAccount, BlockNumber, ResultBalance]; type Result = [DeriveBalancesAccount, BlockNumber, ResultBalance];
interface AllLocked { interface AllLocked {
@@ -50,8 +52,21 @@ function calcLocked (api: ApiInterfaceRx, bestNumber: BlockNumber, locks: (Balan
return { allLocked, lockedBalance, lockedBreakdown, vestingLocked }; return { allLocked, lockedBalance, lockedBreakdown, vestingLocked };
} }
function calcBalances (api: ApiInterfaceRx, [{ accountId, accountNonce, freeBalance, frozenFee, frozenMisc, reservedBalance, votingBalance }, bestNumber, [vesting, locks]]: Result): DeriveBalancesAll { function calcShared (api: ApiInterfaceRx, bestNumber: BlockNumber, data: DeriveBalancesAccountData, locks: (BalanceLock | BalanceLockTo212)[]): DeriveBalancesAllAccountData {
const { allLocked, lockedBalance, lockedBreakdown, vestingLocked } = calcLocked(api, bestNumber, locks); const { allLocked, lockedBalance, lockedBreakdown, vestingLocked } = calcLocked(api, bestNumber, locks);
const availableBalance = api.registry.createType('Balance', allLocked ? 0 : bnMax(new BN(0), data.freeBalance.sub(lockedBalance)));
return {
...data,
availableBalance,
lockedBalance,
lockedBreakdown,
vestingLocked
};
}
function calcBalances (api: ApiInterfaceRx, [data, bestNumber, [vesting, allLocks]]: Result): DeriveBalancesAll {
const shared = calcShared(api, bestNumber, data, allLocks[0]);
// Calculate the vesting balances, // Calculate the vesting balances,
// - offset = balance locked at startingBlock // - offset = balance locked at startingBlock
// - perBlock is the unlock amount // - perBlock is the unlock amount
@@ -59,29 +74,21 @@ function calcBalances (api: ApiInterfaceRx, [{ accountId, accountNonce, freeBala
const isStarted = bestNumber.gt(startingBlock); const isStarted = bestNumber.gt(startingBlock);
const vestedNow = isStarted ? perBlock.mul(bestNumber.sub(startingBlock)) : new BN(0); const vestedNow = isStarted ? perBlock.mul(bestNumber.sub(startingBlock)) : new BN(0);
const vestedBalance = vestedNow.gt(vestingTotal) ? vestingTotal : api.registry.createType('Balance', vestedNow); const vestedBalance = vestedNow.gt(vestingTotal) ? vestingTotal : api.registry.createType('Balance', vestedNow);
const isVesting = isStarted && !vestingLocked.isZero(); const isVesting = isStarted && !shared.vestingLocked.isZero();
const vestedClaimable = api.registry.createType('Balance', isVesting ? vestingLocked.sub(vestingTotal.sub(vestedBalance)) : 0); const vestedClaimable = api.registry.createType('Balance', isVesting ? shared.vestingLocked.sub(vestingTotal.sub(vestedBalance)) : 0);
const availableBalance = api.registry.createType('Balance', allLocked ? 0 : bnMax(new BN(0), freeBalance.sub(lockedBalance)));
const vestingEndBlock = api.registry.createType('BlockNumber', isVesting ? vestingTotal.div(perBlock).add(startingBlock) : 0); const vestingEndBlock = api.registry.createType('BlockNumber', isVesting ? vestingTotal.div(perBlock).add(startingBlock) : 0);
return { return {
accountId, ...shared,
accountNonce, accountId: data.accountId,
availableBalance, accountNonce: data.accountNonce,
freeBalance, additional: allLocks.filter((_, index) => index !== 0).map((l, index) => calcShared(api, bestNumber, data.additional[index], l)),
frozenFee,
frozenMisc,
isVesting, isVesting,
lockedBalance,
lockedBreakdown,
reservedBalance,
vestedBalance, vestedBalance,
vestedClaimable, vestedClaimable,
vestingEndBlock, vestingEndBlock,
vestingLocked,
vestingPerBlock: perBlock, vestingPerBlock: perBlock,
vestingTotal, vestingTotal
votingBalance
}; };
} }
@@ -100,28 +107,37 @@ function queryOld (api: ApiInterfaceRx, accountId: AccountId): Observable<Result
vestingNew = api.registry.createType('VestingInfo', { locked, perBlock, startingBlock }); vestingNew = api.registry.createType('VestingInfo', { locked, perBlock, startingBlock });
} }
return [vestingNew, locks]; return [vestingNew, [locks]];
}) })
); );
} }
// current (balances vesting) // current (balances, vesting)
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<ResultBalance> { function queryCurrent (api: ApiInterfaceRx, accountId: AccountId, balanceInstances: string[] = ['balances']): Observable<ResultBalance> {
const lockCalls = balanceInstances.map((m) => api.query[m].locks);
const lockEmpty = lockCalls.map((c) => !c);
const lockQueries = lockCalls.filter((c) => c).map((c): QueryableStorageMultiArg<'rxjs'> => [c, accountId]);
return ( return (
api.query.vesting?.vesting api.query.vesting?.vesting
? api.queryMulti<[Vec<BalanceLock>, Option<VestingInfo>]>([ ? api.queryMulti<[Option<VestingInfo>, ...BalanceLocks]>([
[api.query.balances.locks, accountId], [api.query.vesting.vesting, accountId],
[api.query.vesting.vesting, accountId] ...lockQueries
]) ])
: api.query.balances.locks(accountId).pipe( // TODO We need to check module instances here as well, not only the balances module
map((locks): [Vec<BalanceLock>, Option<VestingInfo>] => : lockQueries.length
[locks, api.registry.createType('Option<VestingInfo>')] ? api.queryMulti<[...(Vec<BalanceLock>)[]]>(lockQueries).pipe(
map((locks): [Option<VestingInfo>, ...BalanceLocks] =>
[api.registry.createType('Option<VestingInfo>'), ...locks]
)
) )
) : of([api.registry.createType('Option<VestingInfo>')] as [Option<VestingInfo>])
).pipe( ).pipe(
map(([locks, optVesting]): ResultBalance => map(([optVesting, ...locks]): ResultBalance => {
[optVesting.unwrapOr(null), locks] let offset = -1;
)
return [optVesting.unwrapOr(null), lockEmpty.map((e) => e ? api.registry.createType('Vec<BalanceLock>') : locks[++offset])];
})
); );
} }
@@ -141,6 +157,8 @@ function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Re
* ``` * ```
*/ */
export function all (instanceId: string, api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAll> { export function all (instanceId: string, api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAll> {
const balanceInstances = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), 'balances');
return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAll> => return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAll> =>
api.derive.balances.account(address).pipe( api.derive.balances.account(address).pipe(
switchMap((account): Observable<Result> => switchMap((account): Observable<Result> =>
@@ -148,11 +166,11 @@ export function all (instanceId: string, api: ApiInterfaceRx): (address: Account
? combineLatest([ ? combineLatest([
of(account), of(account),
api.derive.chain.bestNumber(), api.derive.chain.bestNumber(),
isFunction(api.query.system.account) || isFunction(api.query.balances.account) api.query.system?.account || api.query.balances?.account
? queryCurrent(api, account.accountId) ? queryCurrent(api, account.accountId, balanceInstances)
: queryOld(api, account.accountId) : queryOld(api, account.accountId)
]) ])
: of([account, api.registry.createType('BlockNumber'), [null, api.registry.createType('Vec<BalanceLock>')]]) : of([account, api.registry.createType('BlockNumber'), [null, []]])
) )
), ),
map((result): DeriveBalancesAll => calcBalances(api, result)) map((result): DeriveBalancesAll => calcBalances(api, result))
@@ -1,16 +1,20 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors // Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx } from '@polkadot/api/types'; import type { ApiInterfaceRx, SubmittableExtrinsic } from '@polkadot/api/types';
import type { Bytes, Option, StorageKey } from '@polkadot/types'; import type { Bytes, Option, StorageKey } from '@polkadot/types';
import type { Bounty, BountyIndex } from '@polkadot/types/interfaces'; import type { Bounty, BountyIndex, ProposalIndex } from '@polkadot/types/interfaces';
import type { Codec, InterfaceTypes } from '@polkadot/types/types'; import type { Codec, InterfaceTypes } from '@polkadot/types/types';
import { ApiPromise } from '@polkadot/api';
import { DeriveCollectiveProposal } from '@polkadot/api-derive/types';
import { Proposal } from '@polkadot/types/interfaces';
import { of } from '@polkadot/x-rxjs'; import { of } from '@polkadot/x-rxjs';
import { BountyFactory } from '../../test/bountyFactory'; import { BountyFactory } from '../../test/bountyFactory';
import { BytesFactory } from '../../test/bytesFactory'; import { BytesFactory } from '../../test/bytesFactory';
import { createApiWithAugmentations } from '../../test/helpers'; import { createApiWithAugmentations } from '../../test/helpers';
import { ProposalFactory } from '../../test/proposalFactory';
import { bounties } from '.'; import { bounties } from '.';
const DEFAULT_PROPOSER = '5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM'; const DEFAULT_PROPOSER = '5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM';
@@ -21,22 +25,62 @@ describe('bounties derive', () => {
let emptyOption: <T extends Codec> (typeName: keyof InterfaceTypes) => Option<T>; let emptyOption: <T extends Codec> (typeName: keyof InterfaceTypes) => Option<T>;
let optionOf: <T extends Codec> (value: T)=> Option<T>; let optionOf: <T extends Codec> (value: T)=> Option<T>;
let bountyIndex: (index: number) => BountyIndex; let bountyIndex: (index: number) => BountyIndex;
let proposalIndex: (index: number) => ProposalIndex;
let bytes: (value: string) => Bytes; let bytes: (value: string) => Bytes;
let api: ApiPromise;
let createProposal: (method: SubmittableExtrinsic<'promise'>) => Proposal;
let defaultMockApi: ApiInterfaceRx;
beforeAll(() => { beforeAll(() => {
const api = createApiWithAugmentations(); api = createApiWithAugmentations();
({ bountyIndex, defaultBounty, emptyOption, optionOf, storageKey } = new BountyFactory(api)); ({ bountyIndex, defaultBounty, emptyOption, optionOf, storageKey } = new BountyFactory(api));
({ bytes } = new BytesFactory(api.registry)); ({ bytes } = new BytesFactory(api.registry));
({ createProposal, proposalIndex } = new ProposalFactory(api));
});
beforeEach(() => {
defaultMockApi = {
derive: {
council: {
proposals: () => of([] as DeriveCollectiveProposal[])
}
},
query: {
council: {
proposalCount: () => of(proposalIndex(2))
},
treasury: {
bounties: {
keys: () => of([storageKey(0), storageKey(1)]),
multi: () => of([optionOf(defaultBounty()), optionOf(defaultBounty())])
},
bountyCount: () => of(bountyIndex(2)),
bountyDescriptions: {
multi: () => of([
optionOf(bytes('make polkadot even better')),
optionOf(bytes('some other bounty'))
])
}
}
},
tx: api.tx
} as unknown as ApiInterfaceRx;
}); });
it('creates storage key', function () { it('creates storage key', function () {
expect(storageKey(194).args[0].eq(194)).toBe(true); expect(storageKey(194).args[0].eq(194)).toBe(true);
}); });
it('creates proposal', function () {
expect(createProposal(api.tx.balances.transfer('5EYCAe5ijiYfyeZ2JJCGq56LmPyNRAKzpG4QkoQkkQNB5e6Z', 1))).toBeTruthy();
});
it('combines bounties with descriptions', async () => { it('combines bounties with descriptions', async () => {
const mockApi = { const mockApi = {
...defaultMockApi,
query: { query: {
...defaultMockApi.query,
treasury: { treasury: {
bounties: { bounties: {
keys: () => of([storageKey(0), storageKey(2), storageKey(3)]), keys: () => of([storageKey(0), storageKey(2), storageKey(3)]),
@@ -64,4 +108,54 @@ describe('bounties derive', () => {
expect(result[1].description).toEqual(''); expect(result[1].description).toEqual('');
expect(result[1].index.eq(3)).toBe(true); expect(result[1].index.eq(3)).toBe(true);
}); });
it('returns motions', async () => {
const result = await bounties('', defaultMockApi)().toPromise();
expect(result).toHaveLength(2);
expect(result[0].proposals).toHaveLength(0);
expect(result[1].proposals).toHaveLength(0);
});
it('when no council, returns bounties without motions', async () => {
const mockApi = {
...defaultMockApi,
query: {
...defaultMockApi.query,
council: null
}
} as unknown as ApiInterfaceRx;
const result = await bounties('', mockApi)().toPromise();
expect(result).toHaveLength(2);
expect(result[0].bounty.proposer.toString()).toEqual(DEFAULT_PROPOSER);
expect(result[0].description).toEqual('make polkadot even better');
expect(result[0].index.eq(0)).toBe(true);
expect(result[0].proposals).toHaveLength(0);
expect(result[1].bounty.proposer.toString()).toEqual(DEFAULT_PROPOSER);
expect(result[1].description).toEqual('some other bounty');
expect(result[1].index.eq(1)).toBe(true);
expect(result[1].proposals).toHaveLength(0);
});
it('combines bounties with motions', async () => {
const mockApi = {
...defaultMockApi,
derive: {
council: {
proposals: () => of([
{ proposal: createProposal(api.tx.bounties.approveBounty(1)) },
{ proposal: createProposal(api.tx.treasury.approveProposal(1)) }] as DeriveCollectiveProposal[])
}
}
} as unknown as ApiInterfaceRx;
const result = await bounties('', mockApi)().toPromise();
expect(result).toHaveLength(2);
expect(result[0].proposals).toHaveLength(0);
expect(result[1].proposals).toHaveLength(1);
expect(result[1].proposals[0].proposal.method).toEqual('approveBounty');
});
}); });
+25 -15
View File
@@ -2,17 +2,19 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx } from '@polkadot/api/types'; import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { DeriveBounties } from '@polkadot/api-derive/types'; import type { DeriveBounties, DeriveCollectiveProposal } from '@polkadot/api-derive/types';
import type { Bytes, Option } from '@polkadot/types'; import type { Bytes, Option, StorageKey } from '@polkadot/types';
import type { Bounty, BountyIndex } from '@polkadot/types/interfaces'; import type { Bounty, BountyIndex, ProposalIndex } from '@polkadot/types/interfaces';
import { memo } from '@polkadot/api-derive/util'; import { memo } from '@polkadot/api-derive/util';
import { combineLatest, Observable, of } from '@polkadot/x-rxjs'; import { combineLatest, Observable, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators'; import { map, switchMap } from '@polkadot/x-rxjs/operators';
type Result = [Option<Bounty>[], Option<Bytes>[], BountyIndex[]]; import { filterBountiesProposals } from './helpers/filterBountyProposals';
function parseResult (api: ApiInterfaceRx, [maybeBounties, maybeDescriptions, ids]: Result): DeriveBounties { type Result = [Option<Bounty>[], Option<Bytes>[], BountyIndex[], DeriveCollectiveProposal[]];
function parseResult ([maybeBounties, maybeDescriptions, ids, bountyProposals]: Result): DeriveBounties {
const bounties: DeriveBounties = []; const bounties: DeriveBounties = [];
maybeBounties.forEach((bounty, index) => { maybeBounties.forEach((bounty, index) => {
@@ -20,7 +22,8 @@ function parseResult (api: ApiInterfaceRx, [maybeBounties, maybeDescriptions, id
bounties.push({ bounties.push({
bounty: bounty.unwrap(), bounty: bounty.unwrap(),
description: maybeDescriptions[index].unwrapOrDefault().toUtf8(), description: maybeDescriptions[index].unwrapOrDefault().toUtf8(),
index: ids[index] index: ids[index],
proposals: bountyProposals.filter((bountyProposal) => ids[index].eq(bountyProposal.proposal.args[0]))
}); });
} }
}); });
@@ -29,23 +32,30 @@ function parseResult (api: ApiInterfaceRx, [maybeBounties, maybeDescriptions, id
} }
export function bounties (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveBounties> { export function bounties (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveBounties> {
const bountyBase = api.query.bounties const bountyBase = api.query.bounties ? api.query.bounties : api.query.treasury;
? api.query.bounties
: api.query.treasury;
return memo(instanceId, (): Observable<DeriveBounties> => return memo(instanceId, (): Observable<DeriveBounties> =>
bountyBase.bountyCount<BountyIndex>().pipe( combineLatest([
switchMap(() => bountyBase.bounties.keys()), bountyBase.bountyCount<BountyIndex>(),
switchMap((keys): Observable<Result> => { api.query.council ? api.query.council.proposalCount<ProposalIndex>() : of(0)
const ids = keys.map(({ args: [id] }) => id as BountyIndex); ]).pipe(
switchMap(() =>
combineLatest([
bountyBase.bounties.keys(),
api.derive.council ? api.derive.council.proposals() : of([])
])
),
switchMap(([keys, proposals]): Observable<Result> => {
const ids = (keys as StorageKey<[BountyIndex]>[]).map(({ args: [id] }) => id);
return combineLatest([ return combineLatest([
bountyBase.bounties.multi<Option<Bounty>>(ids), bountyBase.bounties.multi<Option<Bounty>>(ids),
bountyBase.bountyDescriptions.multi<Option<Bytes>>(ids), bountyBase.bountyDescriptions.multi<Option<Bytes>>(ids),
of(ids) of(ids),
of(filterBountiesProposals(api, proposals))
]); ]);
}), }),
map(([maybeBounties, maybeDescriptions, ids]) => parseResult(api, [maybeBounties, maybeDescriptions, ids])) map(parseResult)
) )
); );
} }
@@ -0,0 +1,12 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { DeriveCollectiveProposal } from '@polkadot/api-derive/types';
export function filterBountiesProposals (api: ApiInterfaceRx, allProposals: DeriveCollectiveProposal[]): DeriveCollectiveProposal[] {
const bountyTxBase = api.tx.bounties ? api.tx.bounties : api.tx.treasury;
const bountyProposalCalls = [bountyTxBase.approveBounty, bountyTxBase.closeBounty, bountyTxBase.proposeCurator, bountyTxBase.unassignCurator];
return allProposals.filter((proposal) => bountyProposalCalls.find((bountyCall) => bountyCall.is(proposal.proposal)));
}
+3 -2
View File
@@ -27,12 +27,13 @@ export function getBlock (instanceId: string, api: ApiInterfaceRx): (hash: Uint8
return memo(instanceId, (hash: Uint8Array | string): Observable<SignedBlockExtended | undefined> => return memo(instanceId, (hash: Uint8Array | string): Observable<SignedBlockExtended | undefined> =>
combineLatest([ combineLatest([
api.rpc.chain.getBlock(hash), api.rpc.chain.getBlock(hash),
api.query.system.events.at(hash),
api.query.session api.query.session
? api.query.session.validators.at(hash) ? api.query.session.validators.at(hash)
: of([]) : of([])
]).pipe( ]).pipe(
map(([signedBlock, validators]): SignedBlockExtended => map(([signedBlock, events, validators]): SignedBlockExtended =>
new SignedBlockExtended(api.registry, signedBlock, validators) new SignedBlockExtended(api.registry, signedBlock, events, validators)
), ),
catchError((): Observable<undefined> => catchError((): Observable<undefined> =>
// where rpc.chain.getHeader throws, we will land here - it can happen that // where rpc.chain.getHeader throws, we will land here - it can happen that
@@ -2,32 +2,34 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx } from '@polkadot/api/types'; import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { EventRecord, Hash, SignedBlock } from '@polkadot/types/interfaces'; import type { AccountId, EventRecord, SignedBlock } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs'; import type { Observable } from '@polkadot/x-rxjs';
import type { FullNewBlock } from '../types';
import { combineLatest, of } from '@polkadot/x-rxjs'; import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators'; import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { SignedBlockExtended } from '../type';
import { memo } from '../util'; import { memo } from '../util';
/** /**
* @name subscribeNewBlocks * @name subscribeNewBlocks
* @returns The latest block & events for that block * @returns The latest block & events for that block
*/ */
export function subscribeNewBlocks (instanceId: string, api: ApiInterfaceRx): () => Observable<FullNewBlock> { export function subscribeNewBlocks (instanceId: string, api: ApiInterfaceRx): () => Observable<SignedBlockExtended> {
return memo(instanceId, (): Observable<FullNewBlock> => return memo(instanceId, (): Observable<SignedBlockExtended> =>
api.derive.chain.subscribeNewHeads().pipe( api.derive.chain.subscribeNewHeads().pipe(
switchMap((header): Observable<[Hash, EventRecord[], SignedBlock]> => { switchMap((header): Observable<[SignedBlock, EventRecord[], AccountId[] | undefined]> => {
const blockHash = header.hash; const blockHash = header.hash;
return combineLatest( return combineLatest(
of(blockHash), api.rpc.chain.getBlock(blockHash),
api.query.system.events.at(blockHash), api.query.system.events.at(blockHash),
api.rpc.chain.getBlock(header.hash) of(header.validators)
); );
}), }),
map(([blockHash, events, block]) => ({ block: block.block, blockHash, blockNumber: block.block.header.number.unwrap(), events, justification: block.justification })) map(([block, events, validators]) =>
new SignedBlockExtended(api.registry, block, events, validators)
)
) )
); );
} }
-12
View File
@@ -1,12 +0,0 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Block, BlockNumber, EventRecord, Hash, Justification } from '@polkadot/types/interfaces';
export interface FullNewBlock {
block: Block;
blockHash: Hash;
blockNumber: BlockNumber;
events: EventRecord[];
justification: Justification;
}
@@ -51,7 +51,7 @@ function schedulerEntries (api: ApiInterfaceRx): Observable<[BlockNumber[], Opti
api.query.scheduler.agenda.keys() api.query.scheduler.agenda.keys()
), ),
switchMap((keys) => { switchMap((keys) => {
const blockNumbers = keys.map((key) => key.args[0] as BlockNumber); const blockNumbers = keys.map((key) => key.args[0]);
return combineLatest([ return combineLatest([
of(blockNumbers), of(blockNumbers),
@@ -69,7 +69,7 @@ function extractVotes (mapped: [AccountId, Voting][], referendumId: BN): DeriveR
function votesCurr (api: ApiInterfaceRx, referendumId: BN): Observable<DeriveReferendumVote[]> { function votesCurr (api: ApiInterfaceRx, referendumId: BN): Observable<DeriveReferendumVote[]> {
return api.query.democracy.votingOf.entries<Voting>().pipe( return api.query.democracy.votingOf.entries<Voting>().pipe(
map((allVoting): DeriveReferendumVote[] => { map((allVoting): DeriveReferendumVote[] => {
const mapped = allVoting.map(([key, voting]): [AccountId, Voting] => [key.args[0] as AccountId, voting]); const mapped = allVoting.map(([key, voting]): [AccountId, Voting] => [key.args[0], voting]);
const votes = extractVotes(mapped, referendumId); const votes = extractVotes(mapped, referendumId);
const delegations = mapped const delegations = mapped
.filter(([, voting]) => voting.isDelegating) .filter(([, voting]) => voting.isDelegating)
+3 -1
View File
@@ -35,6 +35,7 @@ function queryAura (api: ApiInterfaceRx): Observable<DeriveSessionInfo> {
[ [
false, false,
api.registry.createType('u64', 1), api.registry.createType('u64', 1),
// we may have aura without staking (permissioned)
api.consts.staking?.sessionsPerEra || api.registry.createType('SessionIndex', 1) api.consts.staking?.sessionsPerEra || api.registry.createType('SessionIndex', 1)
], ],
indexes indexes
@@ -50,7 +51,8 @@ function queryBabe (api: ApiInterfaceRx): Observable<DeriveSessionInfo> {
[ [
true, true,
api.consts.babe.epochDuration, api.consts.babe.epochDuration,
api.consts.staking.sessionsPerEra // we may have babe without staking (permissioned)
api.consts.staking?.sessionsPerEra || api.registry.createType('SessionIndex', 1)
], ],
indexes indexes
]) ])
+16 -8
View File
@@ -12,6 +12,7 @@ import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { memo } from '../util'; import { memo } from '../util';
type ResultSlotsNoSession = [u64, u64, u64];
type ResultSlots = [u64, u64, u64, Option<SessionIndex>]; type ResultSlots = [u64, u64, u64, Option<SessionIndex>];
type ResultSlotsFlat = [u64, u64, u64, SessionIndex]; type ResultSlotsFlat = [u64, u64, u64, SessionIndex];
@@ -39,19 +40,26 @@ function queryAura (api: ApiInterfaceRx): Observable<DeriveSessionProgress> {
function queryBabe (api: ApiInterfaceRx): Observable<[DeriveSessionInfo, ResultSlotsFlat]> { function queryBabe (api: ApiInterfaceRx): Observable<[DeriveSessionInfo, ResultSlotsFlat]> {
return api.derive.session.info().pipe( return api.derive.session.info().pipe(
switchMap((info): Observable<[DeriveSessionInfo, ResultSlots]> => switchMap((info): Observable<[DeriveSessionInfo, ResultSlots | ResultSlotsNoSession]> =>
combineLatest([ combineLatest([
of(info), of(info),
api.queryMulti<ResultSlots>([ // we may have no staking, but have babe (permissioned)
api.query.babe.currentSlot, api.query.staking
api.query.babe.epochIndex, ? api.queryMulti<ResultSlots>([
api.query.babe.genesisSlot, api.query.babe.currentSlot,
[api.query.staking.erasStartSessionIndex, info.activeEra] api.query.babe.epochIndex,
]) api.query.babe.genesisSlot,
[api.query.staking.erasStartSessionIndex, info.activeEra]
])
: api.queryMulti<ResultSlotsNoSession>([
api.query.babe.currentSlot,
api.query.babe.epochIndex,
api.query.babe.genesisSlot
])
]) ])
), ),
map(([info, [currentSlot, epochIndex, genesisSlot, optStartIndex]]): [DeriveSessionInfo, ResultSlotsFlat] => [ map(([info, [currentSlot, epochIndex, genesisSlot, optStartIndex]]): [DeriveSessionInfo, ResultSlotsFlat] => [
info, [currentSlot, epochIndex, genesisSlot, optStartIndex.unwrapOr(api.registry.createType('SessionIndex', 1))] info, [currentSlot, epochIndex, genesisSlot, optStartIndex && optStartIndex.isSome ? optStartIndex.unwrap() : api.registry.createType('SessionIndex', 1)]
]) ])
); );
} }
@@ -10,7 +10,7 @@ import type { DeriveStakingQuery } from './types';
import BN from 'bn.js'; import BN from 'bn.js';
import { isFunction } from '@polkadot/util'; import { BN_BILLION, BN_ZERO, isFunction } from '@polkadot/util';
import { combineLatest, of } from '@polkadot/x-rxjs'; import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators'; import { map, switchMap } from '@polkadot/x-rxjs/operators';
@@ -18,29 +18,27 @@ import { memo } from '../util';
type ErasResult = [{ unwrapOr: (value: BN) => BN }, DeriveEraPoints[], DeriveEraPrefs[], DeriveEraRewards[]]; type ErasResult = [{ unwrapOr: (value: BN) => BN }, DeriveEraPoints[], DeriveEraPrefs[], DeriveEraRewards[]];
const ZERO = new BN(0);
const MIN_ONE = new BN(-1); const MIN_ONE = new BN(-1);
const COMM_DIV = new BN(1_000_000_000);
function parseRewards (api: ApiInterfaceRx, stashId: AccountId, [, erasPoints, erasPrefs, erasRewards]: ErasResult, exposures: DeriveStakerExposure[]): DeriveStakerReward[] { function parseRewards (api: ApiInterfaceRx, stashId: AccountId, [, erasPoints, erasPrefs, erasRewards]: ErasResult, exposures: DeriveStakerExposure[]): DeriveStakerReward[] {
return exposures.map(({ era, isEmpty, isValidator, nominating, validators: eraValidators }): DeriveStakerReward => { return exposures.map(({ era, isEmpty, isValidator, nominating, validators: eraValidators }): DeriveStakerReward => {
const { eraPoints, validators: allValPoints } = erasPoints.find((p) => p.era.eq(era)) || { eraPoints: ZERO, validators: {} }; const { eraPoints, validators: allValPoints } = erasPoints.find((p) => p.era.eq(era)) || { eraPoints: BN_ZERO, validators: {} };
const { eraReward } = erasRewards.find((r) => r.era.eq(era)) || { eraReward: api.registry.createType('Balance') }; const { eraReward } = erasRewards.find((r) => r.era.eq(era)) || { eraReward: api.registry.createType('Balance') };
const { validators: allValPrefs } = erasPrefs.find((p) => p.era.eq(era)) || { validators: {} as DeriveEraValPrefs }; const { validators: allValPrefs } = erasPrefs.find((p) => p.era.eq(era)) || { validators: {} as DeriveEraValPrefs };
const validators: Record<string, DeriveStakerRewardValidator> = {}; const validators: Record<string, DeriveStakerRewardValidator> = {};
const stakerId = stashId.toString(); const stakerId = stashId.toString();
Object.entries(eraValidators).forEach(([validatorId, exposure]): void => { Object.entries(eraValidators).forEach(([validatorId, exposure]): void => {
const valPoints = allValPoints[validatorId] || ZERO; const valPoints = allValPoints[validatorId] || BN_ZERO;
const valComm = allValPrefs[validatorId]?.commission.unwrap() || ZERO; const valComm = allValPrefs[validatorId]?.commission.unwrap() || BN_ZERO;
const expTotal = exposure.total.unwrap(); const expTotal = exposure.total.unwrap();
let avail = ZERO; let avail = BN_ZERO;
let value: BN | undefined; let value: BN | undefined;
if (!(expTotal.isZero() || valPoints.isZero() || eraPoints.isZero())) { if (!(expTotal.isZero() || valPoints.isZero() || eraPoints.isZero())) {
avail = eraReward.mul(valPoints).div(eraPoints); avail = eraReward.mul(valPoints).div(eraPoints);
const valCut = valComm.mul(avail).div(COMM_DIV); const valCut = valComm.mul(avail).div(BN_BILLION);
let staked: BN; let staked: BN;
if (validatorId === stakerId) { if (validatorId === stakerId) {
@@ -50,10 +48,10 @@ function parseRewards (api: ApiInterfaceRx, stashId: AccountId, [, erasPoints, e
staked = stakerExp staked = stakerExp
? stakerExp.value.unwrap() ? stakerExp.value.unwrap()
: ZERO; : BN_ZERO;
} }
value = avail.sub(valCut).imul(staked).div(expTotal).iadd(validatorId === stakerId ? valCut : ZERO); value = avail.sub(valCut).imul(staked).div(expTotal).iadd(validatorId === stakerId ? valCut : BN_ZERO);
} }
validators[validatorId] = { validators[validatorId] = {
@@ -181,7 +179,7 @@ export function _stakerRewards (instanceId: string, api: ApiInterfaceRx): (accou
return withActive return withActive
? of(rewards) ? of(rewards)
: filterRewards(api, eras, { migrateEra: erasResult[0].unwrapOr(ZERO), rewards, stakingLedger }); : filterRewards(api, eras, { migrateEra: erasResult[0].unwrapOr(BN_ZERO), rewards, stakingLedger });
}) })
) )
); );
+1 -1
View File
@@ -15,7 +15,7 @@ import { memo } from '../util';
export function stashes (instanceId: string, api: ApiInterfaceRx): () => Observable<AccountId[]> { export function stashes (instanceId: string, api: ApiInterfaceRx): () => Observable<AccountId[]> {
return memo(instanceId, (): Observable<AccountId[]> => return memo(instanceId, (): Observable<AccountId[]> =>
api.query.staking.validators.keys().pipe( api.query.staking.validators.keys().pipe(
map((keys) => keys.map((key) => key.args[0] as AccountId).filter((a) => a)) map((keys) => keys.map((key) => key.args[0]).filter((a) => a))
) )
); );
} }
@@ -18,7 +18,7 @@ export function nextElected (instanceId: string, api: ApiInterfaceRx): () => Obs
// only populate for next era in the last session, so track both here - entries are not // only populate for next era in the last session, so track both here - entries are not
// subscriptions, so we need a trigger - currentIndex acts as that trigger to refresh // subscriptions, so we need a trigger - currentIndex acts as that trigger to refresh
switchMap(({ currentEra }) => api.query.staking.erasStakers.keys(currentEra)), switchMap(({ currentEra }) => api.query.staking.erasStakers.keys(currentEra)),
map((keys) => keys.map((key) => key.args[1] as AccountId)) map((keys) => keys.map((key) => key.args[1]))
) )
: api.query.staking.currentElected<AccountId[]>() : api.query.staking.currentElected<AccountId[]>()
); );
+8 -23
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { AccountId, Header } from '@polkadot/types/interfaces'; import type { AccountId, Header } from '@polkadot/types/interfaces';
import type { AnyJson, Constructor, Registry } from '@polkadot/types/types'; import type { Constructor, Registry } from '@polkadot/types/types';
import { Struct } from '@polkadot/types'; import { Struct } from '@polkadot/types';
import runtimeTypes from '@polkadot/types/interfaces/runtime/definitions'; import runtimeTypes from '@polkadot/types/interfaces/runtime/definitions';
@@ -19,11 +19,13 @@ const _Header = Struct.with(runtimeTypes.types.Header as any) as Constructor<Hea
*/ */
export class HeaderExtended extends _Header { export class HeaderExtended extends _Header {
readonly #author?: AccountId; readonly #author?: AccountId;
readonly #validators?: AccountId[];
constructor (registry: Registry, header?: Header, sessionValidators?: AccountId[]) { constructor (registry: Registry, header?: Header, validators?: AccountId[]) {
super(registry, header); super(registry, header);
this.#author = extractAuthor(this.digest, sessionValidators); this.#author = extractAuthor(this.digest, validators);
this.#validators = validators;
} }
/** /**
@@ -34,26 +36,9 @@ export class HeaderExtended extends _Header {
} }
/** /**
* @description Creates a human-friendly JSON representation * @description Convenience method, returns the validators for the block
*/ */
public toHuman (isExtended?: boolean): Record<string, AnyJson> { public get validators (): AccountId[] | undefined {
return { return this.#validators;
...super.toHuman(isExtended),
author: this.author
? this.author.toHuman()
: undefined
};
}
/**
* @description Creates the JSON representation
*/
public toJSON (): Record<string, AnyJson> {
return {
...super.toJSON(),
author: this.author
? this.author.toJSON()
: undefined
};
} }
} }
@@ -1,8 +1,8 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors // Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { AccountId, SignedBlock } from '@polkadot/types/interfaces'; import type { AccountId, DispatchError, DispatchInfo, Event, EventRecord, Extrinsic, SignedBlock } from '@polkadot/types/interfaces';
import type { AnyJson, Constructor, Registry } from '@polkadot/types/types'; import type { Constructor, Registry } from '@polkadot/types/types';
import { Struct } from '@polkadot/types'; import { Struct } from '@polkadot/types';
import runtimeTypes from '@polkadot/types/interfaces/runtime/definitions'; import runtimeTypes from '@polkadot/types/interfaces/runtime/definitions';
@@ -12,6 +12,37 @@ import { extractAuthor } from './util';
// We can ignore the properties, added via Struct.with // We can ignore the properties, added via Struct.with
const _SignedBlock = Struct.with(runtimeTypes.types.SignedBlock as any) as Constructor<SignedBlock>; 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;
let dispatchInfo: DispatchInfo | undefined;
const events = records
.filter(({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eq(index))
.map(({ event }) => {
if (event.section === 'system') {
if (event.method === 'ExtrinsicSuccess') {
dispatchInfo = event.data[0] as DispatchInfo;
} else if (event.method === 'ExtrinsicFailed') {
dispatchError = event.data[0] as DispatchError;
dispatchInfo = event.data[1] as DispatchInfo;
}
}
return event;
});
return { dispatchError, dispatchInfo, events, extrinsic };
});
}
/** /**
* @name SignedBlockExtended * @name SignedBlockExtended
* @description * @description
@@ -19,11 +50,15 @@ const _SignedBlock = Struct.with(runtimeTypes.types.SignedBlock as any) as Const
*/ */
export class SignedBlockExtended extends _SignedBlock { export class SignedBlockExtended extends _SignedBlock {
readonly #author?: AccountId; readonly #author?: AccountId;
readonly #events: EventRecord[];
readonly #extrinsics: TxWithEvent[];
constructor (registry: Registry, block?: SignedBlock, sessionValidators?: AccountId[]) { constructor (registry: Registry, block?: SignedBlock, events?: EventRecord[], sessionValidators?: AccountId[]) {
super(registry, block); super(registry, block);
this.#author = extractAuthor(this.block.header.digest, sessionValidators); this.#author = extractAuthor(this.block.header.digest, sessionValidators);
this.#events = events || ([] as EventRecord[]);
this.#extrinsics = mapExtrinsics(this.block.extrinsics, this.#events);
} }
/** /**
@@ -34,26 +69,16 @@ export class SignedBlockExtended extends _SignedBlock {
} }
/** /**
* @description Creates a human-friendly JSON representation * @description Convenience method, returns the events associated with the block
*/ */
public toHuman (isExtended?: boolean): Record<string, AnyJson> { public get events (): EventRecord[] {
return { return this.#events;
...super.toHuman(isExtended),
author: this.author
? this.author.toHuman()
: undefined
};
} }
/** /**
* @description Creates the JSON representation * @description Returns the extrinsics and their events, mapped
*/ */
public toJSON (): Record<string, AnyJson> { public get extrinsics (): TxWithEvent[] {
return { return this.#extrinsics;
...super.toJSON(),
author: this.author
? this.author.toJSON()
: undefined
};
} }
} }
+6 -8
View File
@@ -4,19 +4,17 @@
import type { AccountId, Digest } from '@polkadot/types/interfaces'; import type { AccountId, Digest } from '@polkadot/types/interfaces';
export function extractAuthor (digest: Digest, sessionValidators: AccountId[] = []): AccountId | undefined { export function extractAuthor (digest: Digest, sessionValidators: AccountId[] = []): AccountId | undefined {
const [pitem] = digest.logs.filter(({ type }) => type === 'PreRuntime'); const [citem] = digest.logs.filter(({ type }) => type === 'Consensus');
// extract from the substrate 2.0 PreRuntime digest if (citem) {
if (pitem) { const [engine, data] = citem.asConsensus;
const [engine, data] = pitem.asPreRuntime;
return engine.extractAuthor(data, sessionValidators); return engine.extractAuthor(data, sessionValidators);
} else { } else {
const [citem] = digest.logs.filter(({ type }) => type === 'Consensus'); const [pitem] = digest.logs.filter(({ type }) => type === 'PreRuntime');
// extract author from the consensus (substrate 1.0, digest) if (pitem) {
if (citem) { const [engine, data] = pitem.asPreRuntime;
const [engine, data] = citem.asConsensus;
return engine.extractAuthor(data, sessionValidators); return engine.extractAuthor(data, sessionValidators);
} }
+16 -9
View File
@@ -6,7 +6,6 @@ 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 { AccountId, Balance, BalanceLock, BalanceLockTo212, BalanceOf, Bid, BidKind, BlockNumber, Bounty, BountyIndex, Hash, Index, Proposal, ProposalIndex, SetIndex, SocietyVote, StrikeCount, TreasuryProposal, Votes, VouchingStatus } from '@polkadot/types/interfaces';
export * from './accounts/types'; export * from './accounts/types';
export * from './chain/types';
export * from './council/types'; export * from './council/types';
export * from './democracy/types'; export * from './democracy/types';
export * from './elections/types'; export * from './elections/types';
@@ -14,9 +13,7 @@ export * from './parachains/types';
export * from './session/types'; export * from './session/types';
export * from './staking/types'; export * from './staking/types';
export interface DeriveBalancesAccount { export interface DeriveBalancesAccountData {
accountId: AccountId;
accountNonce: Index;
freeBalance: Balance; freeBalance: Balance;
frozenFee: Balance; frozenFee: Balance;
frozenMisc: Balance; frozenMisc: Balance;
@@ -24,16 +21,25 @@ export interface DeriveBalancesAccount {
votingBalance: Balance; votingBalance: Balance;
} }
export interface DeriveBalancesAll extends DeriveBalancesAccount { export interface DeriveBalancesAccount extends DeriveBalancesAccountData {
isVesting: boolean; accountId: AccountId;
accountNonce: Index;
additional: DeriveBalancesAccountData[];
}
export interface DeriveBalancesAllAccountData extends DeriveBalancesAccountData {
availableBalance: Balance;
lockedBalance: Balance; lockedBalance: Balance;
lockedBreakdown: (BalanceLock | BalanceLockTo212)[]; lockedBreakdown: (BalanceLock | BalanceLockTo212)[];
availableBalance: Balance; vestingLocked: Balance;
votingBalance: Balance; }
export interface DeriveBalancesAll extends DeriveBalancesAccount, DeriveBalancesAllAccountData {
additional: DeriveBalancesAllAccountData[];
isVesting: boolean;
vestedBalance: Balance; vestedBalance: Balance;
vestedClaimable: Balance; vestedClaimable: Balance;
vestingEndBlock: BlockNumber; vestingEndBlock: BlockNumber;
vestingLocked: Balance;
vestingPerBlock: Balance; vestingPerBlock: Balance;
vestingTotal: Balance; vestingTotal: Balance;
} }
@@ -132,6 +138,7 @@ export interface DeriveBounty {
bounty: Bounty; bounty: Bounty;
description: string; description: string;
index: BountyIndex; index: BountyIndex;
proposals: DeriveCollectiveProposal[];
} }
export type DeriveBounties = DeriveBounty[]; export type DeriveBounties = DeriveBounty[];
+3 -1
View File
@@ -10,7 +10,9 @@ export function createApiWithAugmentations (): ApiPromise {
const registry = new TypeRegistry(); const registry = new TypeRegistry();
const metadata = new Metadata(registry, metaStatic); const metadata = new Metadata(registry, metaStatic);
const api = new ApiPromise({ provider: new WsProvider('ws://', false) }); registry.setMetadata(metadata);
const api = new ApiPromise({ provider: new WsProvider('ws://', false), registry });
api.injectMetadata(metadata, true); api.injectMetadata(metadata, true);
@@ -0,0 +1,25 @@
// Copyright 2017-2021 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiPromise } from '@polkadot/api';
import { SubmittableExtrinsic } from '@polkadot/api/types';
import { Proposal, ProposalIndex } from '@polkadot/types/interfaces';
import { Registry } from '@polkadot/types/types';
export class ProposalFactory {
readonly #api: ApiPromise;
readonly #registry: Registry;
constructor (api: ApiPromise) {
this.#api = api;
this.#registry = this.#api.registry;
}
public createProposal = (method: SubmittableExtrinsic<'promise'>): Proposal => {
return this.#registry.createType('Proposal', method);
};
public proposalIndex = (index: number): ProposalIndex => {
return this.#registry.createType('ProposalIndex', index);
}
}
+11 -12
View File
@@ -1,9 +1,8 @@
{ {
"name": "@polkadot/api", "name": "@polkadot/api",
"version": "3.3.1", "version": "3.7.3",
"description": "Promise and RxJS wrappers around the Polkadot JS RPC", "description": "Promise and RxJS wrappers around the Polkadot JS RPC",
"main": "index.js", "main": "index.js",
"module": "index.mjs",
"sideEffects": [ "sideEffects": [
"./detectPackage.js", "./detectPackage.js",
"./detectPackage.mjs" "./detectPackage.mjs"
@@ -17,16 +16,16 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme", "homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@polkadot/api-derive": "3.3.1", "@polkadot/api-derive": "3.7.3",
"@polkadot/keyring": "^5.2.3", "@polkadot/keyring": "^5.5.2",
"@polkadot/metadata": "3.3.1", "@polkadot/metadata": "3.7.3",
"@polkadot/rpc-core": "3.3.1", "@polkadot/rpc-core": "3.7.3",
"@polkadot/rpc-provider": "3.3.1", "@polkadot/rpc-provider": "3.7.3",
"@polkadot/types": "3.3.1", "@polkadot/types": "3.7.3",
"@polkadot/types-known": "3.3.1", "@polkadot/types-known": "3.7.3",
"@polkadot/util": "^5.2.3", "@polkadot/util": "^5.5.2",
"@polkadot/util-crypto": "^5.2.3", "@polkadot/util-crypto": "^5.5.2",
"@polkadot/x-rxjs": "3.3.1", "@polkadot/x-rxjs": "^5.5.2",
"bn.js": "^4.11.9", "bn.js": "^4.11.9",
"eventemitter3": "^4.0.7" "eventemitter3": "^4.0.7"
} }
+66 -25
View File
@@ -3,11 +3,12 @@
import type { Vec, u16, u32, u64, u8 } from '@polkadot/types'; import type { Vec, u16, u32, u64, u8 } from '@polkadot/types';
import type { Codec } from '@polkadot/types/types'; import type { Codec } from '@polkadot/types/types';
import type { Balance, BalanceOf, BlockNumber, LockIdentifier, ModuleId, Moment, Perbill, Percent, Permill, RuntimeDbWeight } from '@polkadot/types/interfaces/runtime'; import type { Balance, BalanceOf, BlockNumber, LockIdentifier, ModuleId, Moment, Perbill, Percent, Permill, RuntimeDbWeight, Weight } from '@polkadot/types/interfaces/runtime';
import type { SessionIndex } from '@polkadot/types/interfaces/session'; import type { SessionIndex } from '@polkadot/types/interfaces/session';
import type { EraIndex } from '@polkadot/types/interfaces/staking'; import type { EraIndex } from '@polkadot/types/interfaces/staking';
import type { RuntimeVersion } from '@polkadot/types/interfaces/state';
import type { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support'; import type { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
import type { BlockWeights } from '@polkadot/types/interfaces/system'; import type { BlockLength, BlockWeights } from '@polkadot/types/interfaces/system';
import type { ApiTypes } from '@polkadot/api/types'; import type { ApiTypes } from '@polkadot/api/types';
declare module '@polkadot/api/types/consts' { declare module '@polkadot/api/types/consts' {
@@ -17,6 +18,9 @@ declare module '@polkadot/api/types/consts' {
/** /**
* The number of **slots** that an epoch takes. We couple sessions to * 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. * 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.
**/ **/
epochDuration: u64 & AugmentedConst<ApiType>; epochDuration: u64 & AugmentedConst<ApiType>;
/** /**
@@ -49,6 +53,10 @@ declare module '@polkadot/api/types/consts' {
* The delay period for which a bounty beneficiary need to wait before claim the payout. * The delay period for which a bounty beneficiary need to wait before claim the payout.
**/ **/
bountyDepositPayoutDelay: BlockNumber & AugmentedConst<ApiType>; bountyDepositPayoutDelay: BlockNumber & AugmentedConst<ApiType>;
/**
* Bounty duration in blocks.
**/
bountyUpdatePeriod: BlockNumber & AugmentedConst<ApiType>;
/** /**
* Minimum value for a bounty. * Minimum value for a bounty.
**/ **/
@@ -64,6 +72,40 @@ declare module '@polkadot/api/types/consts' {
}; };
contracts: { contracts: {
[key: string]: Codec; [key: string]: Codec;
/**
* The maximum number of tries that can be queued for deletion.
**/
deletionQueueDepth: u32 & AugmentedConst<ApiType>;
/**
* The maximum amount of weight that can be consumed per block for lazy trie removal.
**/
deletionWeightLimit: Weight & AugmentedConst<ApiType>;
/**
* The balance every contract needs to deposit to stay alive indefinitely.
*
* This is different from the [`Self::TombstoneDeposit`] because this only needs to be
* deposited while the contract is alive. Costs for additional storage are added to
* this base cost.
*
* This is a simple way to ensure that contracts with empty storage eventually get deleted by
* making them pay rent. This creates an incentive to remove them early in order to save rent.
**/
depositPerContract: BalanceOf & AugmentedConst<ApiType>;
/**
* The balance a contract needs to deposit per storage byte to stay alive indefinitely.
*
* Let's suppose the deposit is 1,000 BU (balance units)/byte and the rent is 1 BU/byte/day,
* then a contract with 1,000,000 BU that uses 1,000 bytes of storage would pay no rent.
* But if the balance reduced to 500,000 BU and the storage stayed the same at 1,000,
* then it would pay 500 BU/day.
**/
depositPerStorageByte: BalanceOf & AugmentedConst<ApiType>;
/**
* The balance a contract needs to deposit per storage item to stay alive indefinitely.
*
* It works the same as [`Self::DepositPerStorageByte`] but for storage items.
**/
depositPerStorageItem: BalanceOf & AugmentedConst<ApiType>;
/** /**
* The maximum nesting level of a call/instantiate stack. A reasonable default * The maximum nesting level of a call/instantiate stack. A reasonable default
* value is 100. * value is 100.
@@ -74,19 +116,13 @@ declare module '@polkadot/api/types/consts' {
**/ **/
maxValueSize: u32 & AugmentedConst<ApiType>; maxValueSize: u32 & AugmentedConst<ApiType>;
/** /**
* Price of a byte of storage per one block interval. Should be greater than 0. * The fraction of the deposit that should be used as rent per block.
**/
rentByteFee: BalanceOf & AugmentedConst<ApiType>;
/**
* The amount of funds a contract should deposit in order to offset
* the cost of one byte.
* *
* Let's suppose the deposit is 1,000 BU (balance units)/byte and the rent is 1 BU/byte/day, * When a contract hasn't enough balance deposited to stay alive indefinitely it needs
* then a contract with 1,000,000 BU that uses 1,000 bytes of storage would pay no rent. * to pay per block for the storage it consumes that is not covered by the deposit.
* But if the balance reduced to 500,000 BU and the storage stayed the same at 1,000, * This determines how high this rent payment is per block as a fraction of the deposit.
* then it would pay 500 BU/day.
**/ **/
rentDepositOffset: BalanceOf & AugmentedConst<ApiType>; rentFraction: Perbill & AugmentedConst<ApiType>;
/** /**
* Number of block delay an extrinsic claim surcharge has. * Number of block delay an extrinsic claim surcharge has.
* *
@@ -94,15 +130,6 @@ declare module '@polkadot/api/types/consts' {
* for current_block - delay * for current_block - delay
**/ **/
signedClaimHandicap: BlockNumber & AugmentedConst<ApiType>; signedClaimHandicap: BlockNumber & AugmentedConst<ApiType>;
/**
* A size offset for an contract. A just created account with untouched storage will have that
* much of storage from the perspective of the state rent.
*
* This is a simple way to ensure that contracts with empty storage eventually get deleted
* by making them pay rent. This creates an incentive to remove them early in order to save
* rent.
**/
storageSizeOffset: u32 & AugmentedConst<ApiType>;
/** /**
* Reward that is received by the party whose touch has led * Reward that is received by the party whose touch has led
* to removal of a contract. * to removal of a contract.
@@ -159,7 +186,8 @@ declare module '@polkadot/api/types/consts' {
desiredRunnersUp: u32 & AugmentedConst<ApiType>; desiredRunnersUp: u32 & AugmentedConst<ApiType>;
moduleId: LockIdentifier & AugmentedConst<ApiType>; moduleId: LockIdentifier & AugmentedConst<ApiType>;
termDuration: BlockNumber & AugmentedConst<ApiType>; termDuration: BlockNumber & AugmentedConst<ApiType>;
votingBond: BalanceOf & AugmentedConst<ApiType>; votingBondBase: BalanceOf & AugmentedConst<ApiType>;
votingBondFactor: BalanceOf & AugmentedConst<ApiType>;
}; };
identity: { identity: {
[key: string]: Codec; [key: string]: Codec;
@@ -199,6 +227,11 @@ declare module '@polkadot/api/types/consts' {
**/ **/
deposit: BalanceOf & AugmentedConst<ApiType>; deposit: BalanceOf & AugmentedConst<ApiType>;
}; };
lottery: {
[key: string]: Codec;
maxCalls: u32 & AugmentedConst<ApiType>;
moduleId: ModuleId & AugmentedConst<ApiType>;
};
multisig: { multisig: {
[key: string]: Codec; [key: string]: Codec;
/** /**
@@ -343,11 +376,15 @@ declare module '@polkadot/api/types/consts' {
system: { system: {
[key: string]: Codec; [key: string]: Codec;
/** /**
* The maximum number of blocks to allow in mortal eras. * Maximum number of block number to block hash mappings to keep (oldest pruned first).
**/ **/
blockHashCount: BlockNumber & AugmentedConst<ApiType>; blockHashCount: BlockNumber & AugmentedConst<ApiType>;
/** /**
* The weight configuration (limits & base values) for each class of extrinsics and block. * The maximum length of a block (in bytes).
**/
blockLength: BlockLength & AugmentedConst<ApiType>;
/**
* Block & extrinsics weights: base values and limits.
**/ **/
blockWeights: BlockWeights & AugmentedConst<ApiType>; blockWeights: BlockWeights & AugmentedConst<ApiType>;
/** /**
@@ -362,6 +399,10 @@ declare module '@polkadot/api/types/consts' {
* an identifier of the chain. * an identifier of the chain.
**/ **/
ss58Prefix: u8 & AugmentedConst<ApiType>; ss58Prefix: u8 & AugmentedConst<ApiType>;
/**
* Get the chain's current version.
**/
version: RuntimeVersion & AugmentedConst<ApiType>;
}; };
timestamp: { timestamp: {
[key: string]: Codec; [key: string]: Codec;
+61 -5
View File
@@ -11,6 +11,14 @@ declare module '@polkadot/api/types/errors' {
* Transfer amount should be non-zero. * Transfer amount should be non-zero.
**/ **/
AmountZero: AugmentedError<ApiType>; AmountZero: AugmentedError<ApiType>;
/**
* Invalid metadata given.
**/
BadMetadata: AugmentedError<ApiType>;
/**
* Some internal state is broken.
**/
BadState: AugmentedError<ApiType>;
/** /**
* Invalid witness data given. * Invalid witness data given.
**/ **/
@@ -179,6 +187,13 @@ declare module '@polkadot/api/types/errors' {
* The code supplied to `put_code` exceeds the limit specified in the current schedule. * The code supplied to `put_code` exceeds the limit specified in the current schedule.
**/ **/
CodeTooLarge: AugmentedError<ApiType>; CodeTooLarge: AugmentedError<ApiType>;
/**
* A contract could not be evicted because it has enough balance to pay rent.
*
* This can be returned from [`Module::claim_surcharge`] because the target
* contract has enough balance to pay for its rent.
**/
ContractNotEvictable: AugmentedError<ApiType>;
/** /**
* Contract trapped during execution. * Contract trapped during execution.
**/ **/
@@ -187,6 +202,14 @@ declare module '@polkadot/api/types/errors' {
* Input passed to a contract API function failed to decode as expected type. * Input passed to a contract API function failed to decode as expected type.
**/ **/
DecodingFailed: AugmentedError<ApiType>; DecodingFailed: AugmentedError<ApiType>;
/**
* Removal of a contract failed because the deletion queue is full.
*
* This can happen when either calling [`Module::claim_surcharge`] or `seal_terminate`.
* The queue is filled by deleting contracts and emptied by a fixed amount each block.
* Trying again during another block is the only way to resolve this issue.
**/
DeletionQueueFull: AugmentedError<ApiType>;
/** /**
* The topics passed to `seal_deposit_events` contains at least one duplicate. * The topics passed to `seal_deposit_events` contains at least one duplicate.
**/ **/
@@ -229,6 +252,12 @@ declare module '@polkadot/api/types/errors' {
* its contructor. No contracts are allowed to exist below that threshold. * its contructor. No contracts are allowed to exist below that threshold.
**/ **/
NewContractNotFunded: AugmentedError<ApiType>; NewContractNotFunded: AugmentedError<ApiType>;
/**
* The chain does not provide a chain extension. Calling the chain extension results
* in this error. Note that this usually shouldn't happen as deploying such contracts
* is rejected.
**/
NoChainExtension: AugmentedError<ApiType>;
/** /**
* The contract that was called is either no contract at all (a plain account) * The contract that was called is either no contract at all (a plain account)
* or is a tombstone. * or is a tombstone.
@@ -256,6 +285,13 @@ declare module '@polkadot/api/types/errors' {
* of a tombstone. * of a tombstone.
**/ **/
ReentranceDenied: AugmentedError<ApiType>; ReentranceDenied: AugmentedError<ApiType>;
/**
* A storage modification exhausted the 32bit type that holds the storage size.
*
* This can either happen when the accumulated storage in bytes is too large or
* when number of storage items is too large.
**/
StorageExhausted: AugmentedError<ApiType>;
/** /**
* The amount of topics passed to `seal_deposit_events` exceeds the limit. * The amount of topics passed to `seal_deposit_events` exceeds the limit.
**/ **/
@@ -468,10 +504,6 @@ declare module '@polkadot/api/types/errors' {
* Candidate does not have enough funds. * Candidate does not have enough funds.
**/ **/
InsufficientCandidateFunds: AugmentedError<ApiType>; InsufficientCandidateFunds: AugmentedError<ApiType>;
/**
* The provided count of number of candidates is incorrect.
**/
InvalidCandidateCount: AugmentedError<ApiType>;
/** /**
* The renouncing origin presented a wrong `Renouncing` parameter. * The renouncing origin presented a wrong `Renouncing` parameter.
**/ **/
@@ -484,6 +516,10 @@ declare module '@polkadot/api/types/errors' {
* The provided count of number of votes is incorrect. * The provided count of number of votes is incorrect.
**/ **/
InvalidVoteCount: AugmentedError<ApiType>; InvalidVoteCount: AugmentedError<ApiType>;
/**
* The provided count of number of candidates is incorrect.
**/
InvalidWitnessData: AugmentedError<ApiType>;
/** /**
* Cannot vote with stake less than minimum balance. * Cannot vote with stake less than minimum balance.
**/ **/
@@ -515,7 +551,7 @@ declare module '@polkadot/api/types/errors' {
/** /**
* Runner cannot re-submit candidacy. * Runner cannot re-submit candidacy.
**/ **/
RunnerSubmit: AugmentedError<ApiType>; RunnerUpSubmit: AugmentedError<ApiType>;
/** /**
* Cannot vote more than candidates. * Cannot vote more than candidates.
**/ **/
@@ -752,6 +788,10 @@ declare module '@polkadot/api/types/errors' {
* This user has already vouched for this recovery * This user has already vouched for this recovery
**/ **/
AlreadyVouched: AugmentedError<ApiType>; AlreadyVouched: AugmentedError<ApiType>;
/**
* Some internal state is broken.
**/
BadState: AugmentedError<ApiType>;
/** /**
* The friend must wait until the delay period to vouch for this recovery * The friend must wait until the delay period to vouch for this recovery
**/ **/
@@ -830,6 +870,10 @@ declare module '@polkadot/api/types/errors' {
* Invalid ownership proof. * Invalid ownership proof.
**/ **/
InvalidProof: AugmentedError<ApiType>; InvalidProof: AugmentedError<ApiType>;
/**
* Key setting account is not live, so it's impossible to associate keys.
**/
NoAccount: AugmentedError<ApiType>;
/** /**
* No associated validator ID for account. * No associated validator ID for account.
**/ **/
@@ -928,6 +972,14 @@ declare module '@polkadot/api/types/errors' {
* Controller is already paired. * Controller is already paired.
**/ **/
AlreadyPaired: AugmentedError<ApiType>; AlreadyPaired: AugmentedError<ApiType>;
/**
* Internal state has become somehow corrupted and the operation cannot continue.
**/
BadState: AugmentedError<ApiType>;
/**
* A nomination target was supplied that was blocked or otherwise not a validator.
**/
BadTarget: AugmentedError<ApiType>;
/** /**
* The call is not allowed at the given time due to restrictions of election period. * The call is not allowed at the given time due to restrictions of election period.
**/ **/
@@ -1043,6 +1095,10 @@ declare module '@polkadot/api/types/errors' {
* The snapshot data of the current window is missing. * The snapshot data of the current window is missing.
**/ **/
SnapshotUnavailable: AugmentedError<ApiType>; SnapshotUnavailable: AugmentedError<ApiType>;
/**
* Too many nomination targets supplied.
**/
TooManyTargets: AugmentedError<ApiType>;
}; };
sudo: { sudo: {
[key: string]: AugmentedError<ApiType>; [key: string]: AugmentedError<ApiType>;
+51 -16
View File
@@ -1,8 +1,9 @@
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit // Auto-generated via `yarn polkadot-types-from-chain`, do not edit
/* eslint-disable */ /* eslint-disable */
import type { Bytes, Option, Vec, bool, u16, u32 } from '@polkadot/types'; import type { Bytes, Option, Vec, bool, u16, u32, u8 } from '@polkadot/types';
import type { ITuple } from '@polkadot/types/types'; import type { ITuple } from '@polkadot/types/types';
import type { TAssetBalance } from '@polkadot/types/interfaces/assets';
import type { BalanceStatus } from '@polkadot/types/interfaces/balances'; import type { BalanceStatus } from '@polkadot/types/interfaces/balances';
import type { MemberCount, ProposalIndex } from '@polkadot/types/interfaces/collective'; import type { MemberCount, ProposalIndex } from '@polkadot/types/interfaces/collective';
import type { AuthorityId } from '@polkadot/types/interfaces/consensus'; import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
@@ -10,6 +11,7 @@ import type { PropIndex, ReferendumIndex } from '@polkadot/types/interfaces/demo
import type { VoteThreshold } from '@polkadot/types/interfaces/elections'; import type { VoteThreshold } from '@polkadot/types/interfaces/elections';
import type { AuthorityList } from '@polkadot/types/interfaces/grandpa'; import type { AuthorityList } from '@polkadot/types/interfaces/grandpa';
import type { RegistrarIndex } from '@polkadot/types/interfaces/identity'; 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 { Kind, OpaqueTimeSlot } from '@polkadot/types/interfaces/offences';
import type { ProxyType } from '@polkadot/types/interfaces/proxy'; 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, BlockNumber, CallHash, Hash, PhantomData } from '@polkadot/types/interfaces/runtime';
@@ -25,10 +27,18 @@ declare module '@polkadot/api/types/events' {
export interface AugmentedEvents<ApiType> { export interface AugmentedEvents<ApiType> {
assets: { assets: {
[key: string]: AugmentedEvent<ApiType>; [key: string]: AugmentedEvent<ApiType>;
/**
* Some asset `asset_id` was frozen. \[asset_id\]
**/
AssetFrozen: AugmentedEvent<ApiType, [AssetId]>;
/**
* Some asset `asset_id` was thawed. \[asset_id\]
**/
AssetThawed: AugmentedEvent<ApiType, [AssetId]>;
/** /**
* Some assets were destroyed. \[asset_id, owner, balance\] * Some assets were destroyed. \[asset_id, owner, balance\]
**/ **/
Burned: AugmentedEvent<ApiType, [AssetId, AccountId, Balance]>; Burned: AugmentedEvent<ApiType, [AssetId, AccountId, TAssetBalance]>;
/** /**
* Some asset class was created. \[asset_id, creator, owner\] * Some asset class was created. \[asset_id, creator, owner\]
**/ **/
@@ -44,7 +54,7 @@ declare module '@polkadot/api/types/events' {
/** /**
* Some assets was transferred by an admin. \[asset_id, from, to, amount\] * Some assets was transferred by an admin. \[asset_id, from, to, amount\]
**/ **/
ForceTransferred: AugmentedEvent<ApiType, [AssetId, AccountId, AccountId, Balance]>; ForceTransferred: AugmentedEvent<ApiType, [AssetId, AccountId, AccountId, TAssetBalance]>;
/** /**
* Some account `who` was frozen. \[asset_id, who\] * Some account `who` was frozen. \[asset_id, who\]
**/ **/
@@ -52,11 +62,15 @@ declare module '@polkadot/api/types/events' {
/** /**
* Some assets were issued. \[asset_id, owner, total_supply\] * Some assets were issued. \[asset_id, owner, total_supply\]
**/ **/
Issued: AugmentedEvent<ApiType, [AssetId, AccountId, Balance]>; Issued: AugmentedEvent<ApiType, [AssetId, AccountId, TAssetBalance]>;
/** /**
* The maximum amount of zombies allowed has changed. \[asset_id, max_zombies\] * The maximum amount of zombies allowed has changed. \[asset_id, max_zombies\]
**/ **/
MaxZombiesChanged: AugmentedEvent<ApiType, [AssetId, u32]>; MaxZombiesChanged: AugmentedEvent<ApiType, [AssetId, u32]>;
/**
* New metadata has been set for an asset. \[asset_id, name, symbol, decimals\]
**/
MetadataSet: AugmentedEvent<ApiType, [AssetId, Bytes, Bytes, u8]>;
/** /**
* The owner changed \[asset_id, owner\] * The owner changed \[asset_id, owner\]
**/ **/
@@ -72,7 +86,7 @@ declare module '@polkadot/api/types/events' {
/** /**
* Some assets were transferred. \[asset_id, from, to, amount\] * Some assets were transferred. \[asset_id, from, to, amount\]
**/ **/
Transferred: AugmentedEvent<ApiType, [AssetId, AccountId, AccountId, Balance]>; Transferred: AugmentedEvent<ApiType, [AssetId, AccountId, AccountId, TAssetBalance]>;
}; };
balances: { balances: {
[key: string]: AugmentedEvent<ApiType>; [key: string]: AugmentedEvent<ApiType>;
@@ -308,7 +322,10 @@ declare module '@polkadot/api/types/events' {
elections: { elections: {
[key: string]: AugmentedEvent<ApiType>; [key: string]: AugmentedEvent<ApiType>;
/** /**
* A candidate was slashed due to failing to obtain a seat as member or runner-up * A \[candidate\] was slashed by \[amount\] due to failing to obtain a seat as member or
* runner-up.
*
* Note that old members and runners-up are also candidates.
**/ **/
CandidateSlashed: AugmentedEvent<ApiType, [AccountId, Balance]>; CandidateSlashed: AugmentedEvent<ApiType, [AccountId, Balance]>;
/** /**
@@ -325,10 +342,6 @@ declare module '@polkadot/api/types/events' {
* `EmptyTerm`. * `EmptyTerm`.
**/ **/
MemberKicked: AugmentedEvent<ApiType, [AccountId]>; MemberKicked: AugmentedEvent<ApiType, [AccountId]>;
/**
* A \[member\] has renounced their candidacy.
**/
MemberRenounced: AugmentedEvent<ApiType, [AccountId]>;
/** /**
* A new term with \[new_members\]. This indicates that enough candidates existed to run the * 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 * election, not that enough have has been elected. The inner value must be examined for
@@ -337,14 +350,13 @@ declare module '@polkadot/api/types/events' {
**/ **/
NewTerm: AugmentedEvent<ApiType, [Vec<ITuple<[AccountId, Balance]>>]>; NewTerm: AugmentedEvent<ApiType, [Vec<ITuple<[AccountId, Balance]>>]>;
/** /**
* A seat holder (member or runner-up) was slashed due to failing to retaining their position. * Someone has renounced their candidacy.
**/
Renounced: AugmentedEvent<ApiType, [AccountId]>;
/**
* A \[seat holder\] was slashed by \[amount\] by being forcefully removed from the set.
**/ **/
SeatHolderSlashed: AugmentedEvent<ApiType, [AccountId, Balance]>; SeatHolderSlashed: AugmentedEvent<ApiType, [AccountId, Balance]>;
/**
* A voter was reported with the the report being successful or not.
* \[voter, reporter, success\]
**/
VoterReported: AugmentedEvent<ApiType, [AccountId, AccountId, bool]>;
}; };
grandpa: { grandpa: {
[key: string]: AugmentedEvent<ApiType>; [key: string]: AugmentedEvent<ApiType>;
@@ -436,6 +448,25 @@ declare module '@polkadot/api/types/events' {
**/ **/
IndexFrozen: AugmentedEvent<ApiType, [AccountIndex, AccountId]>; IndexFrozen: AugmentedEvent<ApiType, [AccountIndex, AccountId]>;
}; };
lottery: {
[key: string]: AugmentedEvent<ApiType>;
/**
* A new set of calls have been set!
**/
CallsUpdated: AugmentedEvent<ApiType, []>;
/**
* A lottery has been started!
**/
LotteryStarted: AugmentedEvent<ApiType, []>;
/**
* A ticket has been bought!
**/
TicketBought: AugmentedEvent<ApiType, [AccountId, CallIndex]>;
/**
* A winner has been chosen!
**/
Winner: AugmentedEvent<ApiType, [AccountId, Balance]>;
};
multisig: { multisig: {
[key: string]: AugmentedEvent<ApiType>; [key: string]: AugmentedEvent<ApiType>;
/** /**
@@ -621,6 +652,10 @@ declare module '@polkadot/api/types/events' {
* \[era_index, validator_payout, remainder\] * \[era_index, validator_payout, remainder\]
**/ **/
EraPayout: AugmentedEvent<ApiType, [EraIndex, Balance, Balance]>; EraPayout: AugmentedEvent<ApiType, [EraIndex, Balance, Balance]>;
/**
* A nominator has been kicked from a validator. \[nominator, stash\]
**/
Kicked: AugmentedEvent<ApiType, [AccountId, AccountId]>;
/** /**
* An old slashing report from a prior era was discarded because it could * An old slashing report from a prior era was discarded because it could
* not be processed. \[session_index\] * not be processed. \[session_index\]
+71 -13
View File
@@ -3,18 +3,19 @@
import type { Bytes, Data, Option, U8aFixed, Vec, bool, u32, u64 } from '@polkadot/types'; import type { Bytes, Data, Option, U8aFixed, Vec, bool, u32, u64 } from '@polkadot/types';
import type { AnyNumber, ITuple, Observable } from '@polkadot/types/types'; import type { AnyNumber, ITuple, Observable } from '@polkadot/types/types';
import type { AssetBalance, AssetDetails } from '@polkadot/types/interfaces/assets'; import type { AssetBalance, AssetDetails, AssetMetadata } from '@polkadot/types/interfaces/assets';
import type { UncleEntryItem } from '@polkadot/types/interfaces/authorship'; import type { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
import type { BabeAuthorityWeight, MaybeRandomness, NextConfigDescriptor, Randomness } from '@polkadot/types/interfaces/babe'; import type { BabeAuthorityWeight, MaybeRandomness, NextConfigDescriptor, Randomness } from '@polkadot/types/interfaces/babe';
import type { AccountData, BalanceLock } from '@polkadot/types/interfaces/balances'; import type { AccountData, BalanceLock } from '@polkadot/types/interfaces/balances';
import type { ProposalIndex, Votes } from '@polkadot/types/interfaces/collective'; import type { ProposalIndex, Votes } from '@polkadot/types/interfaces/collective';
import type { AuthorityId } from '@polkadot/types/interfaces/consensus'; import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
import type { CodeHash, ContractInfo, PrefabWasmModule, Schedule } from '@polkadot/types/interfaces/contracts'; import type { CodeHash, ContractInfo, DeletedContract, PrefabWasmModule, Schedule } from '@polkadot/types/interfaces/contracts';
import type { PreimageStatus, PropIndex, Proposal, ReferendumIndex, ReferendumInfo, Voting } from '@polkadot/types/interfaces/democracy'; import type { PreimageStatus, PropIndex, Proposal, ReferendumIndex, ReferendumInfo, Voting } from '@polkadot/types/interfaces/democracy';
import type { VoteThreshold } from '@polkadot/types/interfaces/elections'; import type { VoteThreshold } from '@polkadot/types/interfaces/elections';
import type { SetId, StoredPendingChange, StoredState } from '@polkadot/types/interfaces/grandpa'; import type { SetId, StoredPendingChange, StoredState } from '@polkadot/types/interfaces/grandpa';
import type { RegistrarInfo, Registration } from '@polkadot/types/interfaces/identity'; import type { RegistrarInfo, Registration } from '@polkadot/types/interfaces/identity';
import type { AuthIndex } from '@polkadot/types/interfaces/imOnline'; 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 { DeferredOffenceOf, Kind, OffenceDetails, OpaqueTimeSlot, ReportIdOf } from '@polkadot/types/interfaces/offences';
import type { ProxyAnnouncement, ProxyDefinition } from '@polkadot/types/interfaces/proxy'; import type { ProxyAnnouncement, ProxyDefinition } from '@polkadot/types/interfaces/proxy';
import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery'; import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
@@ -22,7 +23,7 @@ import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber,
import type { Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler'; import type { Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler';
import type { Keys, SessionIndex } from '@polkadot/types/interfaces/session'; import type { Keys, SessionIndex } from '@polkadot/types/interfaces/session';
import type { Bid, BidKind, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society'; import type { Bid, BidKind, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
import type { ActiveEraInfo, ElectionResult, ElectionScore, ElectionStatus, EraIndex, EraRewardPoints, Exposure, Forcing, Nominations, RewardDestination, SlashingSpans, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs } from '@polkadot/types/interfaces/staking'; import type { ActiveEraInfo, ElectionResult, ElectionScore, ElectionStatus, EraIndex, EraRewardPoints, Exposure, Forcing, Nominations, RewardDestination, SeatHolder, SlashingSpans, 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 { 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 { Bounty, BountyIndex, OpenTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
import type { Multiplier } from '@polkadot/types/interfaces/txpayment'; import type { Multiplier } from '@polkadot/types/interfaces/txpayment';
@@ -42,6 +43,10 @@ declare module '@polkadot/api/types/storage' {
* Details of an asset. * Details of an asset.
**/ **/
asset: AugmentedQuery<ApiType, (arg: AssetId | AnyNumber | Uint8Array) => Observable<Option<AssetDetails>>, [AssetId]> & QueryableStorageEntry<ApiType, [AssetId]>; asset: AugmentedQuery<ApiType, (arg: AssetId | AnyNumber | Uint8Array) => Observable<Option<AssetDetails>>, [AssetId]> & QueryableStorageEntry<ApiType, [AssetId]>;
/**
* Metadata of an asset.
**/
metadata: AugmentedQuery<ApiType, (arg: AssetId | AnyNumber | Uint8Array) => Observable<AssetMetadata>, [AssetId]> & QueryableStorageEntry<ApiType, [AssetId]>;
}; };
authorship: { authorship: {
[key: string]: QueryableStorageEntry<ApiType>; [key: string]: QueryableStorageEntry<ApiType>;
@@ -96,6 +101,10 @@ declare module '@polkadot/api/types/storage' {
* execution context should always yield zero. * execution context should always yield zero.
**/ **/
lateness: AugmentedQuery<ApiType, () => Observable<BlockNumber>, []> & QueryableStorageEntry<ApiType, []>; lateness: AugmentedQuery<ApiType, () => Observable<BlockNumber>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Next epoch authorities.
**/
nextAuthorities: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[AuthorityId, BabeAuthorityWeight]>>>, []> & QueryableStorageEntry<ApiType, []>;
/** /**
* Next epoch configuration, if changed. * Next epoch configuration, if changed.
**/ **/
@@ -197,6 +206,13 @@ declare module '@polkadot/api/types/storage' {
* Current cost schedule for contracts. * Current cost schedule for contracts.
**/ **/
currentSchedule: AugmentedQuery<ApiType, () => Observable<Schedule>, []> & QueryableStorageEntry<ApiType, []>; currentSchedule: AugmentedQuery<ApiType, () => Observable<Schedule>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Evicted contracts that await child trie deletion.
*
* Child trie deletion is a heavy operation depending on the amount of storage items
* stored in said trie. Therefore this operation is performed lazily in `on_initialize`.
**/
deletionQueue: AugmentedQuery<ApiType, () => Observable<Vec<DeletedContract>>, []> & QueryableStorageEntry<ApiType, []>;
/** /**
* A mapping from an original code hash to the original code, untouched by instrumentation. * A mapping from an original code hash to the original code, untouched by instrumentation.
**/ **/
@@ -310,28 +326,37 @@ declare module '@polkadot/api/types/storage' {
elections: { elections: {
[key: string]: QueryableStorageEntry<ApiType>; [key: string]: QueryableStorageEntry<ApiType>;
/** /**
* The present candidate list. Sorted based on account-id. A current member or runner-up * The present candidate list. A current member or runner-up can never enter this vector
* can never enter this vector and is always implicitly assumed to be a candidate. * and is always implicitly assumed to be a candidate.
*
* Second element is the deposit.
*
* Invariant: Always sorted based on account id.
**/ **/
candidates: AugmentedQuery<ApiType, () => Observable<Vec<AccountId>>, []> & QueryableStorageEntry<ApiType, []>; candidates: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[AccountId, BalanceOf]>>>, []> & QueryableStorageEntry<ApiType, []>;
/** /**
* The total number of vote rounds that have happened, excluding the upcoming one. * The total number of vote rounds that have happened, excluding the upcoming one.
**/ **/
electionRounds: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>; electionRounds: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
/** /**
* The current elected membership. Sorted based on account id. * The current elected members.
*
* Invariant: Always sorted based on account id.
**/ **/
members: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[AccountId, BalanceOf]>>>, []> & QueryableStorageEntry<ApiType, []>; members: AugmentedQuery<ApiType, () => Observable<Vec<SeatHolder>>, []> & QueryableStorageEntry<ApiType, []>;
/** /**
* The current runners_up. Sorted based on low to high merit (worse to best). * The current reserved runners-up.
*
* Invariant: Always sorted based on rank (worse to best). Upon removal of a member, the
* last (i.e. _best_) runner-up will be replaced.
**/ **/
runnersUp: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[AccountId, BalanceOf]>>>, []> & QueryableStorageEntry<ApiType, []>; runnersUp: AugmentedQuery<ApiType, () => Observable<Vec<SeatHolder>>, []> & QueryableStorageEntry<ApiType, []>;
/** /**
* Votes and locked stake of a particular voter. * Votes and locked stake of a particular voter.
* *
* TWOX-NOTE: SAFE as `AccountId` is a crypto hash * TWOX-NOTE: SAFE as `AccountId` is a crypto hash.
**/ **/
voting: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ITuple<[BalanceOf, Vec<AccountId>]>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>; voting: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Voter>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
}; };
grandpa: { grandpa: {
[key: string]: QueryableStorageEntry<ApiType>; [key: string]: QueryableStorageEntry<ApiType>;
@@ -426,6 +451,34 @@ declare module '@polkadot/api/types/storage' {
**/ **/
accounts: AugmentedQuery<ApiType, (arg: AccountIndex | AnyNumber | Uint8Array) => Observable<Option<ITuple<[AccountId, BalanceOf, bool]>>>, [AccountIndex]> & QueryableStorageEntry<ApiType, [AccountIndex]>; accounts: AugmentedQuery<ApiType, (arg: AccountIndex | AnyNumber | Uint8Array) => Observable<Option<ITuple<[AccountId, BalanceOf, bool]>>>, [AccountIndex]> & QueryableStorageEntry<ApiType, [AccountIndex]>;
}; };
lottery: {
[key: string]: QueryableStorageEntry<ApiType>;
/**
* The calls stored in this pallet to be used in an active lottery if configured
* by `Config::ValidateCall`.
**/
callIndices: AugmentedQuery<ApiType, () => Observable<Vec<CallIndex>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The configuration for the current lottery.
**/
lottery: AugmentedQuery<ApiType, () => Observable<Option<LotteryConfig>>, []> & QueryableStorageEntry<ApiType, []>;
lotteryIndex: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Users who have purchased a ticket. (Lottery Index, Tickets Purchased)
**/
participants: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ITuple<[u32, Vec<CallIndex>]>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* Each ticket's owner.
*
* May have residual storage from previous lotteries. Use `TicketsCount` to see which ones
* are actually valid ticket mappings.
**/
tickets: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Option<AccountId>>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
/**
* Total number of tickets sold.
**/
ticketsCount: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
};
mmr: { mmr: {
[key: string]: QueryableStorageEntry<ApiType>; [key: string]: QueryableStorageEntry<ApiType>;
/** /**
@@ -817,7 +870,7 @@ declare module '@polkadot/api/types/storage' {
* True if network has been upgraded to this version. * True if network has been upgraded to this version.
* Storage version of the pallet. * Storage version of the pallet.
* *
* This is set to v3.0.0 for new networks. * This is set to v5.0.0 for new networks.
**/ **/
storageVersion: AugmentedQuery<ApiType, () => Observable<Releases>, []> & QueryableStorageEntry<ApiType, []>; storageVersion: AugmentedQuery<ApiType, () => Observable<Releases>, []> & QueryableStorageEntry<ApiType, []>;
/** /**
@@ -912,6 +965,11 @@ declare module '@polkadot/api/types/storage' {
* Hash of the previous block. * Hash of the previous block.
**/ **/
parentHash: AugmentedQuery<ApiType, () => Observable<Hash>, []> & QueryableStorageEntry<ApiType, []>; parentHash: AugmentedQuery<ApiType, () => Observable<Hash>, []> & QueryableStorageEntry<ApiType, []>;
/**
* True if we have upgraded so that AccountInfo contains two types of `RefCount`. False
* (default) if not.
**/
upgradedToDualRefCount: AugmentedQuery<ApiType, () => Observable<bool>, []> & QueryableStorageEntry<ApiType, []>;
/** /**
* True if we have upgraded so that `type RefCount` is `u32`. False (default) if not. * True if we have upgraded so that `type RefCount` is `u32`. False (default) if not.
**/ **/
+5 -1
View File
@@ -15,7 +15,7 @@ import type { EthAccount, EthCallRequest, EthFilter, EthLog, EthReceipt, EthRich
import type { Extrinsic } from '@polkadot/types/interfaces/extrinsics'; import type { Extrinsic } from '@polkadot/types/interfaces/extrinsics';
import type { EncodedFinalityProofs, JustificationNotification, ReportedRoundStates } from '@polkadot/types/interfaces/grandpa'; import type { EncodedFinalityProofs, JustificationNotification, ReportedRoundStates } from '@polkadot/types/interfaces/grandpa';
import type { StorageKind } from '@polkadot/types/interfaces/offchain'; import type { StorageKind } from '@polkadot/types/interfaces/offchain';
import type { RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment'; import type { FeeDetails, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
import type { RpcMethods } from '@polkadot/types/interfaces/rpc'; 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 { 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 } from '@polkadot/types/interfaces/state';
@@ -316,6 +316,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
localStorageSet: AugmentedRpc<(kind: StorageKind | '__UNUSED' | 'PERSISTENT' | 'LOCAL' | number | Uint8Array, key: Bytes | string | Uint8Array, value: Bytes | string | Uint8Array) => Observable<Null>>; localStorageSet: AugmentedRpc<(kind: StorageKind | '__UNUSED' | 'PERSISTENT' | 'LOCAL' | number | Uint8Array, key: Bytes | string | Uint8Array, value: Bytes | string | Uint8Array) => Observable<Null>>;
}; };
payment: { payment: {
/**
* Query the detailed fee of a given encoded extrinsic
**/
queryFeeDetails: AugmentedRpc<(extrinsic: Bytes | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<FeeDetails>>;
/** /**
* Retrieves the fee information for an encoded extrinsic * Retrieves the fee information for an encoded extrinsic
**/ **/
+225 -164
View File
@@ -1,19 +1,20 @@
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit // Auto-generated via `yarn polkadot-types-from-chain`, do not edit
/* eslint-disable */ /* eslint-disable */
import type { Bytes, Compact, Data, Option, U8aFixed, Vec, bool, u16, u32, u64 } from '@polkadot/types'; import type { Bytes, Compact, Data, Option, U8aFixed, Vec, bool, u16, u32, u64, u8 } from '@polkadot/types';
import type { AnyNumber, ITuple } from '@polkadot/types/types'; import type { AnyNumber, ITuple } from '@polkadot/types/types';
import type { TAssetBalance } from '@polkadot/types/interfaces/assets';
import type { BabeEquivocationProof } from '@polkadot/types/interfaces/babe'; import type { BabeEquivocationProof } from '@polkadot/types/interfaces/babe';
import type { MemberCount, ProposalIndex } from '@polkadot/types/interfaces/collective'; import type { MemberCount, ProposalIndex } from '@polkadot/types/interfaces/collective';
import type { CodeHash, Gas, Schedule } from '@polkadot/types/interfaces/contracts'; import type { CodeHash, Gas, Schedule } from '@polkadot/types/interfaces/contracts';
import type { AccountVote, Conviction, PropIndex, Proposal, ReferendumIndex } from '@polkadot/types/interfaces/democracy'; import type { AccountVote, Conviction, PropIndex, Proposal, ReferendumIndex } from '@polkadot/types/interfaces/democracy';
import type { DefunctVoter, Renouncing } from '@polkadot/types/interfaces/elections'; import type { Renouncing } from '@polkadot/types/interfaces/elections';
import type { Extrinsic, Signature } from '@polkadot/types/interfaces/extrinsics'; import type { Extrinsic, Signature } from '@polkadot/types/interfaces/extrinsics';
import type { GrandpaEquivocationProof, KeyOwnerProof } from '@polkadot/types/interfaces/grandpa'; import type { GrandpaEquivocationProof, KeyOwnerProof } from '@polkadot/types/interfaces/grandpa';
import type { IdentityFields, IdentityInfo, IdentityJudgement, RegistrarIndex } from '@polkadot/types/interfaces/identity'; import type { IdentityFields, IdentityInfo, IdentityJudgement, RegistrarIndex } from '@polkadot/types/interfaces/identity';
import type { Heartbeat } from '@polkadot/types/interfaces/imOnline'; import type { Heartbeat } from '@polkadot/types/interfaces/imOnline';
import type { ProxyType } from '@polkadot/types/interfaces/proxy'; import type { ProxyType } from '@polkadot/types/interfaces/proxy';
import type { AccountId, AccountIndex, Address, AssetId, Balance, BalanceOf, BlockNumber, Call, CallHashOf, ChangesTrieConfiguration, Hash, Header, KeyValue, LookupSource, Moment, OpaqueCall, Perbill, Percent, Weight } from '@polkadot/types/interfaces/runtime'; import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber, Call, CallHashOf, ChangesTrieConfiguration, Hash, Header, KeyValue, LookupSource, Moment, OpaqueCall, Perbill, Percent, Weight } from '@polkadot/types/interfaces/runtime';
import type { Period, Priority } from '@polkadot/types/interfaces/scheduler'; import type { Period, Priority } from '@polkadot/types/interfaces/scheduler';
import type { Keys } from '@polkadot/types/interfaces/session'; import type { Keys } from '@polkadot/types/interfaces/session';
import type { SocietyJudgement } from '@polkadot/types/interfaces/society'; import type { SocietyJudgement } from '@polkadot/types/interfaces/society';
@@ -45,7 +46,7 @@ declare module '@polkadot/api/types/submittable' {
* Weight: `O(1)` * Weight: `O(1)`
* Modes: Post-existence of `who`; Pre & post Zombie-status of `who`. * Modes: Post-existence of `who`; Pre & post Zombie-status of `who`.
**/ **/
burn: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, who: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, amount: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<Balance>]>; burn: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, who: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, amount: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<TAssetBalance>]>;
/** /**
* Issue a new class of fungible assets from a public origin. * Issue a new class of fungible assets from a public origin.
* *
@@ -71,7 +72,7 @@ declare module '@polkadot/api/types/submittable' {
* *
* Weight: `O(1)` * Weight: `O(1)`
**/ **/
create: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, admin: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, maxZombies: u32 | AnyNumber | Uint8Array, minBalance: Balance | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, u32, Balance]>; create: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, admin: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, maxZombies: u32 | AnyNumber | Uint8Array, minBalance: TAssetBalance | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, u32, TAssetBalance]>;
/** /**
* Destroy a class of fungible assets owned by the sender. * Destroy a class of fungible assets owned by the sender.
* *
@@ -108,7 +109,7 @@ declare module '@polkadot/api/types/submittable' {
* *
* Weight: `O(1)` * Weight: `O(1)`
**/ **/
forceCreate: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, owner: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, maxZombies: Compact<u32> | AnyNumber | Uint8Array, minBalance: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<u32>, Compact<Balance>]>; forceCreate: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, owner: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, maxZombies: Compact<u32> | AnyNumber | Uint8Array, minBalance: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<u32>, Compact<TAssetBalance>]>;
/** /**
* Destroy a class of fungible assets. * Destroy a class of fungible assets.
* *
@@ -143,7 +144,7 @@ declare module '@polkadot/api/types/submittable' {
* Modes: Pre-existence of `dest`; Post-existence of `source`; Prior & post zombie-status * Modes: Pre-existence of `dest`; Post-existence of `source`; Prior & post zombie-status
* of `source`; Account pre-existence of `dest`. * of `source`; Account pre-existence of `dest`.
**/ **/
forceTransfer: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, source: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, dest: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, amount: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, LookupSource, Compact<Balance>]>; forceTransfer: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, source: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, dest: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, amount: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, LookupSource, Compact<TAssetBalance>]>;
/** /**
* Disallow further unprivileged transfers from an account. * Disallow further unprivileged transfers from an account.
* *
@@ -156,7 +157,19 @@ declare module '@polkadot/api/types/submittable' {
* *
* Weight: `O(1)` * Weight: `O(1)`
**/ **/
freeze: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, who: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource]>; freeze: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, who: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource]>;
/**
* Disallow further unprivileged transfers for the asset class.
*
* Origin must be Signed and the sender should be the Freezer of the asset `id`.
*
* - `id`: The identifier of the asset to be frozen.
*
* Emits `Frozen`.
*
* Weight: `O(1)`
**/
freezeAsset: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>]>;
/** /**
* Mint assets of a particular class. * Mint assets of a particular class.
* *
@@ -171,8 +184,47 @@ declare module '@polkadot/api/types/submittable' {
* Weight: `O(1)` * Weight: `O(1)`
* Modes: Pre-existing balance of `beneficiary`; Account pre-existence of `beneficiary`. * Modes: Pre-existing balance of `beneficiary`; Account pre-existence of `beneficiary`.
**/ **/
mint: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, beneficiary: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, amount: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<Balance>]>; mint: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, beneficiary: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, amount: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<TAssetBalance>]>;
/**
* Set the maximum number of zombie accounts for an asset.
*
* Origin must be Signed and the sender should be the Owner of the asset `id`.
*
* Funds of sender are reserved according to the formula:
* `AssetDepositBase + AssetDepositPerZombie * max_zombies` taking into account
* any already reserved funds.
*
* - `id`: The identifier of the asset to update zombie count.
* - `max_zombies`: The new number of zombies allowed for this asset.
*
* Emits `MaxZombiesChanged`.
*
* Weight: `O(1)`
**/
setMaxZombies: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, maxZombies: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, Compact<u32>]>; setMaxZombies: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, maxZombies: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, Compact<u32>]>;
/**
* Set the metadata for an asset.
*
* NOTE: There is no `unset_metadata` call. Simply pass an empty name, symbol,
* and 0 decimals to this function to remove the metadata of an asset and
* return your deposit.
*
* Origin must be Signed and the sender should be the Owner of the asset `id`.
*
* Funds of sender are reserved according to the formula:
* `MetadataDepositBase + MetadataDepositPerByte * (name.len + symbol.len)` taking into
* account any already reserved funds.
*
* - `id`: The identifier of the asset to update.
* - `name`: The user friendly name of this asset. Limited in length by `StringLimit`.
* - `symbol`: The exchange symbol for this asset. Limited in length by `StringLimit`.
* - `decimals`: The number of decimals this asset uses to represent one unit.
*
* Emits `MaxZombiesChanged`.
*
* Weight: `O(1)`
**/
setMetadata: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, name: Bytes | string | Uint8Array, symbol: Bytes | string | Uint8Array, decimals: u8 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, Bytes, Bytes, u8]>;
/** /**
* Change the Issuer, Admin and Freezer of an asset. * Change the Issuer, Admin and Freezer of an asset.
* *
@@ -187,7 +239,7 @@ declare module '@polkadot/api/types/submittable' {
* *
* Weight: `O(1)` * Weight: `O(1)`
**/ **/
setTeam: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, issuer: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, admin: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, freezer: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, LookupSource, LookupSource]>; setTeam: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, issuer: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, admin: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, freezer: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, LookupSource, LookupSource]>;
/** /**
* Allow unprivileged transfers from an account again. * Allow unprivileged transfers from an account again.
* *
@@ -200,7 +252,19 @@ declare module '@polkadot/api/types/submittable' {
* *
* Weight: `O(1)` * Weight: `O(1)`
**/ **/
thaw: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, who: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource]>; thaw: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, who: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource]>;
/**
* Allow unprivileged transfers for the asset again.
*
* Origin must be Signed and the sender should be the Admin of the asset `id`.
*
* - `id`: The identifier of the asset to be frozen.
*
* Emits `Thawed`.
*
* Weight: `O(1)`
**/
thawAsset: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>]>;
/** /**
* Move some assets from the sender account to another. * Move some assets from the sender account to another.
* *
@@ -221,7 +285,7 @@ declare module '@polkadot/api/types/submittable' {
* Modes: Pre-existence of `target`; Post-existence of sender; Prior & post zombie-status * Modes: Pre-existence of `target`; Post-existence of sender; Prior & post zombie-status
* of sender; Account pre-existence of `target`. * of sender; Account pre-existence of `target`.
**/ **/
transfer: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, amount: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<Balance>]>; transfer: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, target: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, amount: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<TAssetBalance>]>;
/** /**
* Change the Owner of an asset. * Change the Owner of an asset.
* *
@@ -234,7 +298,7 @@ declare module '@polkadot/api/types/submittable' {
* *
* Weight: `O(1)` * Weight: `O(1)`
**/ **/
transferOwnership: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, owner: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource]>; transferOwnership: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, owner: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource]>;
}; };
authorship: { authorship: {
[key: string]: SubmittableExtrinsicFunction<ApiType>; [key: string]: SubmittableExtrinsicFunction<ApiType>;
@@ -274,7 +338,7 @@ declare module '@polkadot/api/types/submittable' {
* not assumed to be in the overlay. * not assumed to be in the overlay.
* # </weight> * # </weight>
**/ **/
forceTransfer: AugmentedSubmittable<(source: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, dest: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, LookupSource, Compact<Balance>]>; forceTransfer: AugmentedSubmittable<(source: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, dest: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, LookupSource, Compact<Balance>]>;
/** /**
* Set the balances of a given account. * Set the balances of a given account.
* *
@@ -295,7 +359,7 @@ declare module '@polkadot/api/types/submittable' {
* - DB Weight: 1 Read, 1 Write to `who` * - DB Weight: 1 Read, 1 Write to `who`
* # </weight> * # </weight>
**/ **/
setBalance: AugmentedSubmittable<(who: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, newFree: Compact<Balance> | AnyNumber | Uint8Array, newReserved: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<Balance>, Compact<Balance>]>; setBalance: AugmentedSubmittable<(who: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, newFree: Compact<Balance> | AnyNumber | Uint8Array, newReserved: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<Balance>, Compact<Balance>]>;
/** /**
* Transfer some liquid free balance to another account. * Transfer some liquid free balance to another account.
* *
@@ -325,7 +389,7 @@ declare module '@polkadot/api/types/submittable' {
* - Origin account is already in memory, so no DB operations for them. * - Origin account is already in memory, so no DB operations for them.
* # </weight> * # </weight>
**/ **/
transfer: AugmentedSubmittable<(dest: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<Balance>]>; transfer: AugmentedSubmittable<(dest: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<Balance>]>;
/** /**
* Same as the [`transfer`] call, but with a check that the transfer will not kill the * Same as the [`transfer`] call, but with a check that the transfer will not kill the
* origin account. * origin account.
@@ -339,7 +403,7 @@ declare module '@polkadot/api/types/submittable' {
* - DB Weight: 1 Read and 1 Write to dest (sender is in overlay already) * - DB Weight: 1 Read and 1 Write to dest (sender is in overlay already)
* #</weight> * #</weight>
**/ **/
transferKeepAlive: AugmentedSubmittable<(dest: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<Balance>]>; transferKeepAlive: AugmentedSubmittable<(dest: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<Balance>]>;
}; };
bounties: { bounties: {
[key: string]: SubmittableExtrinsicFunction<ApiType>; [key: string]: SubmittableExtrinsicFunction<ApiType>;
@@ -377,7 +441,7 @@ declare module '@polkadot/api/types/submittable' {
* - O(1). * - O(1).
* # </weight> * # </weight>
**/ **/
awardBounty: AugmentedSubmittable<(bountyId: Compact<BountyIndex> | AnyNumber | Uint8Array, beneficiary: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BountyIndex>, LookupSource]>; awardBounty: AugmentedSubmittable<(bountyId: Compact<BountyIndex> | AnyNumber | Uint8Array, beneficiary: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BountyIndex>, LookupSource]>;
/** /**
* Claim the payout from an awarded bounty after payout delay. * Claim the payout from an awarded bounty after payout delay.
* *
@@ -440,7 +504,7 @@ declare module '@polkadot/api/types/submittable' {
* - O(1). * - O(1).
* # </weight> * # </weight>
**/ **/
proposeCurator: AugmentedSubmittable<(bountyId: Compact<BountyIndex> | AnyNumber | Uint8Array, curator: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, fee: Compact<BalanceOf> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BountyIndex>, LookupSource, Compact<BalanceOf>]>; proposeCurator: AugmentedSubmittable<(bountyId: Compact<BountyIndex> | AnyNumber | Uint8Array, curator: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, fee: Compact<BalanceOf> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BountyIndex>, LookupSource, Compact<BalanceOf>]>;
/** /**
* Unassign curator from a bounty. * Unassign curator from a bounty.
* *
@@ -474,13 +538,17 @@ declare module '@polkadot/api/types/submittable' {
* * If no account exists and the call value is not less than `existential_deposit`, * * If no account exists and the call value is not less than `existential_deposit`,
* a regular account will be created and any value will be transferred. * a regular account will be created and any value will be transferred.
**/ **/
call: AugmentedSubmittable<(dest: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, value: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Gas> | AnyNumber | Uint8Array, data: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<BalanceOf>, Compact<Gas>, Bytes]>; call: AugmentedSubmittable<(dest: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, value: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Gas> | AnyNumber | Uint8Array, data: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<BalanceOf>, Compact<Gas>, Bytes]>;
/** /**
* Allows block producers to claim a small reward for evicting a contract. If a block producer * Allows block producers to claim a small reward for evicting a contract. If a block
* fails to do so, a regular users will be allowed to claim the reward. * producer fails to do so, a regular users will be allowed to claim the reward.
* *
* If contract is not evicted as a result of this call, no actions are taken and * In case of a successful eviction no fees are charged from the sender. However, the
* the sender is not eligible for the reward. * reward is capped by the total amount of rent that was payed by the contract while
* it was alive.
*
* If contract is not evicted as a result of this call, [`Error::ContractNotEvictable`]
* is returned and the sender is not eligible for the reward.
**/ **/
claimSurcharge: AugmentedSubmittable<(dest: AccountId | string | Uint8Array, auxSender: Option<AccountId> | null | object | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId, Option<AccountId>]>; claimSurcharge: AugmentedSubmittable<(dest: AccountId | string | Uint8Array, auxSender: Option<AccountId> | null | object | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId, Option<AccountId>]>;
/** /**
@@ -985,6 +1053,19 @@ declare module '@polkadot/api/types/submittable' {
}; };
elections: { elections: {
[key: string]: SubmittableExtrinsicFunction<ApiType>; [key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Clean all voters who are defunct (i.e. they do not serve any purpose at all). The
* deposit of the removed voters are returned.
*
* This is an root function to be used only for cleaning the state.
*
* The dispatch origin of this call must be root.
*
* # <weight>
* The total number of voters and those that are defunct must be provided as witness data.
* # </weight>
**/
cleanDefunctVoters: AugmentedSubmittable<(numVoters: u32 | AnyNumber | Uint8Array, numDefunct: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32]>;
/** /**
* Remove a particular member from the set. This is effective immediately and the bond of * Remove a particular member from the set. This is effective immediately and the bond of
* the outgoing member is slashed. * the outgoing member is slashed.
@@ -992,125 +1073,59 @@ declare module '@polkadot/api/types/submittable' {
* If a runner-up is available, then the best runner-up will be removed and replaces the * If a runner-up is available, then the best runner-up will be removed and replaces the
* outgoing member. Otherwise, a new phragmen election is started. * outgoing member. Otherwise, a new phragmen election is started.
* *
* The dispatch origin of this call must be root.
*
* Note that this does not affect the designated block number of the next election. * Note that this does not affect the designated block number of the next election.
* *
* # <weight> * # <weight>
* If we have a replacement: * If we have a replacement, we use a small weight. Else, since this is a root call and
* - Base weight: 50.93 µs * will go into phragmen, we assume full block for now.
* - State reads:
* - RunnersUp.len()
* - Members, RunnersUp (remove_and_replace_member)
* - State writes:
* - Members, RunnersUp (remove_and_replace_member)
* Else, since this is a root call and will go into phragmen, we assume full block for now.
* # </weight> * # </weight>
**/ **/
removeMember: AugmentedSubmittable<(who: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, hasReplacement: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, bool]>; removeMember: AugmentedSubmittable<(who: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, hasReplacement: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, bool]>;
/** /**
* Remove `origin` as a voter. This removes the lock and returns the bond. * Remove `origin` as a voter.
* *
* # <weight> * This removes the lock and returns the deposit.
* Base weight: 36.8 µs *
* All state access is from do_remove_voter. * The dispatch origin of this call must be signed and be a voter.
* State reads:
* - Voting
* - [AccountData(who)]
* State writes:
* - Voting
* - Locks
* - [AccountData(who)]
* # </weight>
**/ **/
removeVoter: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>; removeVoter: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
/** /**
* Renounce one's intention to be a candidate for the next election round. 3 potential * Renounce one's intention to be a candidate for the next election round. 3 potential
* outcomes exist: * outcomes exist:
* - `origin` is a candidate and not elected in any set. In this case, the bond is *
* - `origin` is a candidate and not elected in any set. In this case, the deposit is
* unreserved, returned and origin is removed as a candidate. * unreserved, returned and origin is removed as a candidate.
* - `origin` is a current runner-up. In this case, the bond is unreserved, returned and * - `origin` is a current runner-up. In this case, the deposit is unreserved, returned and
* origin is removed as a runner-up. * origin is removed as a runner-up.
* - `origin` is a current member. In this case, the bond is unreserved and origin is * - `origin` is a current member. In this case, the deposit is unreserved and origin is
* removed as a member, consequently not being a candidate for the next round anymore. * removed as a member, consequently not being a candidate for the next round anymore.
* Similar to [`remove_voter`], if replacement runners exists, they are immediately used. * Similar to [`remove_members`], if replacement runners exists, they are immediately used.
* <weight> * If the prime is renouncing, then no prime will exist until the next round.
* If a candidate is renouncing: *
* Base weight: 17.28 µs * The dispatch origin of this call must be signed, and have one of the above roles.
* Complexity of candidate_count: 0.235 µs *
* State reads: * # <weight>
* - Candidates * The type of renouncing must be provided as witness data.
* - [AccountBalance(who) (unreserve)] * # </weight>
* State writes:
* - Candidates
* - [AccountBalance(who) (unreserve)]
* If member is renouncing:
* Base weight: 46.25 µs
* State reads:
* - Members, RunnersUp (remove_and_replace_member),
* - [AccountData(who) (unreserve)]
* State writes:
* - Members, RunnersUp (remove_and_replace_member),
* - [AccountData(who) (unreserve)]
* If runner is renouncing:
* Base weight: 46.25 µs
* State reads:
* - RunnersUp (remove_and_replace_member),
* - [AccountData(who) (unreserve)]
* State writes:
* - RunnersUp (remove_and_replace_member),
* - [AccountData(who) (unreserve)]
* </weight>
**/ **/
renounceCandidacy: AugmentedSubmittable<(renouncing: Renouncing | { Member: any } | { RunnerUp: any } | { Candidate: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Renouncing]>; renounceCandidacy: AugmentedSubmittable<(renouncing: Renouncing | { Member: any } | { RunnerUp: any } | { Candidate: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Renouncing]>;
/** /**
* Report `target` for being an defunct voter. In case of a valid report, the reporter is * Submit oneself for candidacy. A fixed amount of deposit is recorded.
* rewarded by the bond amount of `target`. Otherwise, the reporter itself is removed and
* their bond is slashed.
* *
* A defunct voter is defined to be: * All candidates are wiped at the end of the term. They either become a member/runner-up,
* - a voter whose current submitted votes are all invalid. i.e. all of them are no * or leave the system while their deposit is slashed.
* longer a candidate nor an active member or a runner-up.
* *
* The dispatch origin of this call must be signed.
* *
* The origin must provide the number of current candidates and votes of the reported target * ### Warning
* for the purpose of accurate weight calculation. *
* Even if a candidate ends up being a member, they must call [`Call::renounce_candidacy`]
* to get their deposit back. Losing the spot in an election will always lead to a slash.
* *
* # <weight> * # <weight>
* No Base weight based on min square analysis. * The number of current candidates must be provided as witness data.
* Complexity of candidate_count: 1.755 µs
* Complexity of vote_count: 18.51 µs
* State reads:
* - Voting(reporter)
* - Candidate.len()
* - Voting(Target)
* - Candidates, Members, RunnersUp (is_defunct_voter)
* State writes:
* - Lock(reporter || target)
* - [AccountBalance(reporter)] + AccountBalance(target)
* - Voting(reporter || target)
* Note: the db access is worse with respect to db, which is when the report is correct.
* # </weight>
**/
reportDefunctVoter: AugmentedSubmittable<(defunct: DefunctVoter | { who?: any; voteCount?: any; candidateCount?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [DefunctVoter]>;
/**
* Submit oneself for candidacy.
*
* A candidate will either:
* - Lose at the end of the term and forfeit their deposit.
* - Win and become a member. Members will eventually get their stash back.
* - Become a runner-up. Runners-ups are reserved members in case one gets forcefully
* removed.
*
* # <weight>
* Base weight = 33.33 µs
* Complexity of candidate_count: 0.375 µs
* State reads:
* - Candidates
* - Members
* - RunnersUp
* - [AccountBalance(who)]
* State writes:
* - [AccountBalance(who)]
* - Candidates
* # </weight> * # </weight>
**/ **/
submitCandidacy: AugmentedSubmittable<(candidateCount: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<u32>]>; submitCandidacy: AugmentedSubmittable<(candidateCount: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<u32>]>;
@@ -1118,28 +1133,25 @@ declare module '@polkadot/api/types/submittable' {
* Vote for a set of candidates for the upcoming round of election. This can be called to * Vote for a set of candidates for the upcoming round of election. This can be called to
* set the initial votes, or update already existing votes. * set the initial votes, or update already existing votes.
* *
* Upon initial voting, `value` units of `who`'s balance is locked and a bond amount is * Upon initial voting, `value` units of `who`'s balance is locked and a deposit amount is
* reserved. * reserved. The deposit is based on the number of votes and can be updated over time.
* *
* The `votes` should: * The `votes` should:
* - not be empty. * - not be empty.
* - be less than the number of possible candidates. Note that all current members and * - be less than the number of possible candidates. Note that all current members and
* runners-up are also automatically candidates for the next round. * runners-up are also automatically candidates for the next round.
* *
* It is the responsibility of the caller to not place all of their balance into the lock * If `value` is more than `who`'s total balance, then the maximum of the two is used.
* and keep some for further transactions. *
* The dispatch origin of this call must be signed.
*
* ### Warning
*
* It is the responsibility of the caller to **NOT** place all of their balance into the
* lock and keep some for further operations.
* *
* # <weight> * # <weight>
* Base weight: 47.93 µs * We assume the maximum weight among all 3 cases: vote_equal, vote_more and vote_less.
* State reads:
* - Candidates.len() + Members.len() + RunnersUp.len()
* - Voting (is_voter)
* - Lock
* - [AccountBalance(who) (unreserve + total_balance)]
* State writes:
* - Voting
* - Lock
* - [AccountBalance(who) (unreserve -- only when creating a new voter)]
* # </weight> * # </weight>
**/ **/
vote: AugmentedSubmittable<(votes: Vec<AccountId> | (AccountId | string | Uint8Array)[], value: Compact<BalanceOf> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Vec<AccountId>, Compact<BalanceOf>]>; vote: AugmentedSubmittable<(votes: Vec<AccountId> | (AccountId | string | Uint8Array)[], value: Compact<BalanceOf> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Vec<AccountId>, Compact<BalanceOf>]>;
@@ -1203,7 +1215,7 @@ declare module '@polkadot/api/types/submittable' {
* The dispatch origin for this call must be _Signed_ and the sender must have a registered * The dispatch origin for this call must be _Signed_ and the sender must have a registered
* sub identity of `sub`. * sub identity of `sub`.
**/ **/
addSub: AugmentedSubmittable<(sub: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, data: Data | { None: any } | { Raw: any } | { BlakeTwo256: any } | { Sha256: any } | { Keccak256: any } | { ShaThree256: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Data]>; addSub: AugmentedSubmittable<(sub: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, data: Data | { None: any } | { Raw: any } | { BlakeTwo256: any } | { Sha256: any } | { Keccak256: any } | { ShaThree256: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Data]>;
/** /**
* Cancel a previous request. * Cancel a previous request.
* *
@@ -1266,7 +1278,7 @@ declare module '@polkadot/api/types/submittable' {
* - One event. * - One event.
* # </weight> * # </weight>
**/ **/
killIdentity: AugmentedSubmittable<(target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>; killIdentity: AugmentedSubmittable<(target: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>;
/** /**
* Provide a judgement for an account's identity. * Provide a judgement for an account's identity.
* *
@@ -1288,7 +1300,7 @@ declare module '@polkadot/api/types/submittable' {
* - One event. * - One event.
* # </weight> * # </weight>
**/ **/
provideJudgement: AugmentedSubmittable<(regIndex: Compact<RegistrarIndex> | AnyNumber | Uint8Array, target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, judgement: IdentityJudgement | { Unknown: any } | { FeePaid: any } | { Reasonable: any } | { KnownGood: any } | { OutOfDate: any } | { LowQuality: any } | { Erroneous: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<RegistrarIndex>, LookupSource, IdentityJudgement]>; provideJudgement: AugmentedSubmittable<(regIndex: Compact<RegistrarIndex> | AnyNumber | Uint8Array, target: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, judgement: IdentityJudgement | { Unknown: any } | { FeePaid: any } | { Reasonable: any } | { KnownGood: any } | { OutOfDate: any } | { LowQuality: any } | { Erroneous: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<RegistrarIndex>, LookupSource, IdentityJudgement]>;
/** /**
* Remove the sender as a sub-account. * Remove the sender as a sub-account.
* *
@@ -1311,14 +1323,14 @@ declare module '@polkadot/api/types/submittable' {
* The dispatch origin for this call must be _Signed_ and the sender must have a registered * The dispatch origin for this call must be _Signed_ and the sender must have a registered
* sub identity of `sub`. * sub identity of `sub`.
**/ **/
removeSub: AugmentedSubmittable<(sub: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>; removeSub: AugmentedSubmittable<(sub: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>;
/** /**
* Alter the associated name of the given sub-account. * Alter the associated name of the given sub-account.
* *
* The dispatch origin for this call must be _Signed_ and the sender must have a registered * The dispatch origin for this call must be _Signed_ and the sender must have a registered
* sub identity of `sub`. * sub identity of `sub`.
**/ **/
renameSub: AugmentedSubmittable<(sub: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, data: Data | { None: any } | { Raw: any } | { BlakeTwo256: any } | { Sha256: any } | { Keccak256: any } | { ShaThree256: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Data]>; renameSub: AugmentedSubmittable<(sub: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, data: Data | { None: any } | { Raw: any } | { BlakeTwo256: any } | { Sha256: any } | { Keccak256: any } | { ShaThree256: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Data]>;
/** /**
* Request a judgement from a registrar. * Request a judgement from a registrar.
* *
@@ -1567,6 +1579,52 @@ declare module '@polkadot/api/types/submittable' {
**/ **/
transfer: AugmentedSubmittable<(updated: AccountId | string | Uint8Array, index: AccountIndex | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId, AccountIndex]>; transfer: AugmentedSubmittable<(updated: AccountId | string | Uint8Array, index: AccountIndex | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId, AccountIndex]>;
}; };
lottery: {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
/**
* Buy a ticket to enter the lottery.
*
* This extrinsic acts as a passthrough function for `call`. In all
* situations where `call` alone would succeed, this extrinsic should
* succeed.
*
* If `call` is successful, then we will attempt to purchase a ticket,
* which may fail silently. To detect success of a ticket purchase, you
* should listen for the `TicketBought` event.
*
* This extrinsic must be called by a signed origin.
**/
buyTicket: AugmentedSubmittable<(call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Call]>;
/**
* Set calls in storage which can be used to purchase a lottery ticket.
*
* This function only matters if you use the `ValidateCall` implementation
* provided by this pallet, which uses storage to determine the valid calls.
*
* This extrinsic must be called by the Manager origin.
**/
setCalls: AugmentedSubmittable<(calls: Vec<Call> | (Call | { callIndex?: any; args?: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [Vec<Call>]>;
/**
* Start a lottery using the provided configuration.
*
* This extrinsic must be called by the `ManagerOrigin`.
*
* Parameters:
*
* * `price`: The cost of a single ticket.
* * `length`: How long the lottery should run for starting at the current block.
* * `delay`: How long after the lottery end we should wait before picking a winner.
* * `repeat`: If the lottery should repeat when completed.
**/
startLottery: AugmentedSubmittable<(price: BalanceOf | AnyNumber | Uint8Array, length: BlockNumber | AnyNumber | Uint8Array, delay: BlockNumber | AnyNumber | Uint8Array, repeat: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [BalanceOf, BlockNumber, BlockNumber, bool]>;
/**
* If a lottery is repeating, you can use this to stop the repeat.
* The lottery will continue to run to completion.
*
* This extrinsic must be called by the `ManagerOrigin`.
**/
stopRepeat: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
};
multisig: { multisig: {
[key: string]: SubmittableExtrinsicFunction<ApiType>; [key: string]: SubmittableExtrinsicFunction<ApiType>;
/** /**
@@ -2480,7 +2538,7 @@ declare module '@polkadot/api/types/submittable' {
* Total Complexity: O(M + logM + C) * Total Complexity: O(M + logM + C)
* # </weight> * # </weight>
**/ **/
vote: AugmentedSubmittable<(candidate: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, approve: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, bool]>; vote: AugmentedSubmittable<(candidate: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, approve: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, bool]>;
/** /**
* As a member, vouch for someone to join society by placing a bid on their behalf. * As a member, vouch for someone to join society by placing a bid on their behalf.
* *
@@ -2555,7 +2613,7 @@ declare module '@polkadot/api/types/submittable' {
* - Write: Bonded, Payee, [Origin Account], Locks, Ledger * - Write: Bonded, Payee, [Origin Account], Locks, Ledger
* # </weight> * # </weight>
**/ **/
bond: AugmentedSubmittable<(controller: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, value: Compact<BalanceOf> | AnyNumber | Uint8Array, payee: RewardDestination | { Staked: any } | { Stash: any } | { Controller: any } | { Account: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<BalanceOf>, RewardDestination]>; bond: AugmentedSubmittable<(controller: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, value: Compact<BalanceOf> | AnyNumber | Uint8Array, payee: RewardDestination | { Staked: any } | { Stash: any } | { Controller: any } | { Account: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<BalanceOf>, RewardDestination]>;
/** /**
* Add some extra amount that have appeared in the stash `free_balance` into the balance up * Add some extra amount that have appeared in the stash `free_balance` into the balance up
* for staking. * for staking.
@@ -2675,6 +2733,22 @@ declare module '@polkadot/api/types/submittable' {
* # </weight> * # </weight>
**/ **/
increaseValidatorCount: AugmentedSubmittable<(additional: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<u32>]>; increaseValidatorCount: AugmentedSubmittable<(additional: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<u32>]>;
/**
* Remove the given nominations from the calling validator.
*
* Effects will be felt at the beginning of the next era.
*
* The dispatch origin for this call must be _Signed_ by the controller, not the stash.
* And, it can be only called when [`EraElectionStatus`] is `Closed`. The controller
* account should represent a validator.
*
* - `who`: A list of nominator stash accounts who are nominating this validator which
* should no longer be nominating this validator.
*
* Note: Making this call only makes sense if you first set the validator preferences to
* block any further nominations.
**/
kick: AugmentedSubmittable<(who: Vec<LookupSource> | (LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [Vec<LookupSource>]>;
/** /**
* Declare the desire to nominate `targets` for the origin controller. * Declare the desire to nominate `targets` for the origin controller.
* *
@@ -2696,7 +2770,7 @@ declare module '@polkadot/api/types/submittable' {
* - Writes: Validators, Nominators * - Writes: Validators, Nominators
* # </weight> * # </weight>
**/ **/
nominate: AugmentedSubmittable<(targets: Vec<LookupSource> | (LookupSource | Address | AccountId | AccountIndex | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [Vec<LookupSource>]>; nominate: AugmentedSubmittable<(targets: Vec<LookupSource> | (LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [Vec<LookupSource>]>;
/** /**
* Pay out all the stakers behind a single validator for a single era. * Pay out all the stakers behind a single validator for a single era.
* *
@@ -2729,9 +2803,9 @@ declare module '@polkadot/api/types/submittable' {
**/ **/
payoutStakers: AugmentedSubmittable<(validatorStash: AccountId | string | Uint8Array, era: EraIndex | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId, EraIndex]>; payoutStakers: AugmentedSubmittable<(validatorStash: AccountId | string | Uint8Array, era: EraIndex | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId, EraIndex]>;
/** /**
* Remove all data structure concerning a staker/stash once its balance is zero. * Remove all data structure concerning a staker/stash once its balance is at the minimum.
* This is essentially equivalent to `withdraw_unbonded` except it can be called by anyone * This is essentially equivalent to `withdraw_unbonded` except it can be called by anyone
* and the target `stash` must have no funds left. * and the target `stash` must have no funds left beyond the ED.
* *
* This can be called from any origin. * This can be called from any origin.
* *
@@ -2791,7 +2865,7 @@ declare module '@polkadot/api/types/submittable' {
* - Write: Bonded, Ledger New Controller, Ledger Old Controller * - Write: Bonded, Ledger New Controller, Ledger Old Controller
* # </weight> * # </weight>
**/ **/
setController: AugmentedSubmittable<(controller: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>; setController: AugmentedSubmittable<(controller: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>;
/** /**
* Set `HistoryDepth` value. This function will delete any history information * Set `HistoryDepth` value. This function will delete any history information
* when `HistoryDepth` is reduced. * when `HistoryDepth` is reduced.
@@ -3024,7 +3098,7 @@ declare module '@polkadot/api/types/submittable' {
* - One DB change. * - One DB change.
* # </weight> * # </weight>
**/ **/
setKey: AugmentedSubmittable<(updated: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>; setKey: AugmentedSubmittable<(updated: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>;
/** /**
* Authenticates the sudo key and dispatches a function call with `Root` origin. * Authenticates the sudo key and dispatches a function call with `Root` origin.
* *
@@ -3051,7 +3125,7 @@ declare module '@polkadot/api/types/submittable' {
* - Weight of derivative `call` execution + 10,000. * - Weight of derivative `call` execution + 10,000.
* # </weight> * # </weight>
**/ **/
sudoAs: AugmentedSubmittable<(who: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Call]>; sudoAs: AugmentedSubmittable<(who: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Call]>;
/** /**
* Authenticates the sudo key and dispatches a function call with `Root` origin. * Authenticates the sudo key and dispatches a function call with `Root` origin.
* This function does not check the weight of the call, and instead allows the * This function does not check the weight of the call, and instead allows the
@@ -3166,19 +3240,6 @@ declare module '@polkadot/api/types/submittable' {
* # </weight> * # </weight>
**/ **/
setStorage: AugmentedSubmittable<(items: Vec<KeyValue> | (KeyValue)[]) => SubmittableExtrinsic<ApiType>, [Vec<KeyValue>]>; setStorage: AugmentedSubmittable<(items: Vec<KeyValue> | (KeyValue)[]) => SubmittableExtrinsic<ApiType>, [Vec<KeyValue>]>;
/**
* Kill the sending account, assuming there are no references outstanding and the composite
* data is equal to its default value.
*
* # <weight>
* - `O(1)`
* - 1 storage read and deletion.
* --------------------
* Base Weight: 8.626 µs
* No DB Read or Write operations because caller is already in overlay
* # </weight>
**/
suicide: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
}; };
technicalCommittee: { technicalCommittee: {
[key: string]: SubmittableExtrinsicFunction<ApiType>; [key: string]: SubmittableExtrinsicFunction<ApiType>;
@@ -3551,7 +3612,7 @@ declare module '@polkadot/api/types/submittable' {
* - DbWrites: `ProposalCount`, `Proposals`, `origin account` * - DbWrites: `ProposalCount`, `Proposals`, `origin account`
* # </weight> * # </weight>
**/ **/
proposeSpend: AugmentedSubmittable<(value: Compact<BalanceOf> | AnyNumber | Uint8Array, beneficiary: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BalanceOf>, LookupSource]>; proposeSpend: AugmentedSubmittable<(value: Compact<BalanceOf> | AnyNumber | Uint8Array, beneficiary: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BalanceOf>, LookupSource]>;
/** /**
* Reject a proposed spend. The original deposit will be slashed. * Reject a proposed spend. The original deposit will be slashed.
* *
@@ -3642,7 +3703,7 @@ declare module '@polkadot/api/types/submittable' {
* - Writes: Vesting Storage, Balances Locks, Target Account, Source Account * - Writes: Vesting Storage, Balances Locks, Target Account, Source Account
* # </weight> * # </weight>
**/ **/
forceVestedTransfer: AugmentedSubmittable<(source: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, schedule: VestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, LookupSource, VestingInfo]>; forceVestedTransfer: AugmentedSubmittable<(source: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, target: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, schedule: VestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, LookupSource, VestingInfo]>;
/** /**
* Unlock any vested funds of the sender account. * Unlock any vested funds of the sender account.
* *
@@ -3676,7 +3737,7 @@ declare module '@polkadot/api/types/submittable' {
* - Writes: Vesting Storage, Balances Locks, Target Account * - Writes: Vesting Storage, Balances Locks, Target Account
* # </weight> * # </weight>
**/ **/
vestOther: AugmentedSubmittable<(target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>; vestOther: AugmentedSubmittable<(target: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>;
/** /**
* Create a vested transfer. * Create a vested transfer.
* *
@@ -3695,7 +3756,7 @@ declare module '@polkadot/api/types/submittable' {
* - Writes: Vesting Storage, Balances Locks, Target Account, [Sender Account] * - Writes: Vesting Storage, Balances Locks, Target Account, [Sender Account]
* # </weight> * # </weight>
**/ **/
vestedTransfer: AugmentedSubmittable<(target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, schedule: VestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, VestingInfo]>; vestedTransfer: AugmentedSubmittable<(target: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, schedule: VestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, VestingInfo]>;
}; };
} }
+12 -10
View File
@@ -518,13 +518,13 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
return this._retrieveMapKeys(entry, at, arg).pipe( return this._retrieveMapKeys(entry, at, arg).pipe(
switchMap((keys) => switchMap((keys) =>
combineLatest( keys.length
arrayChunk(keys, PAGE_SIZE).map((keys) => query(keys)) ? combineLatest(arrayChunk(keys, PAGE_SIZE).map(query)).pipe(
).pipe( map((valsArr) =>
map((valsArr) => arrayFlatten(valsArr).map((value, index): [StorageKey, Codec] => [keys[index], value])
arrayFlatten(valsArr).map((value, index): [StorageKey, Codec] => [keys[index], value]) )
) )
) : of([])
) )
); );
} }
@@ -532,11 +532,13 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
private _retrieveMapEntriesPaged (entry: StorageEntry, opts: PaginationOptions): Observable<[StorageKey, Codec][]> { private _retrieveMapEntriesPaged (entry: StorageEntry, opts: PaginationOptions): Observable<[StorageKey, Codec][]> {
return this._retrieveMapKeysPaged(entry, opts).pipe( return this._retrieveMapKeysPaged(entry, opts).pipe(
switchMap((keys) => switchMap((keys) =>
this._rpcCore.state.queryStorageAt(keys).pipe( keys.length
map((valsArr) => ? this._rpcCore.state.queryStorageAt(keys).pipe(
valsArr.map((value, index): [StorageKey, Codec] => [keys[index], value]) map((valsArr) =>
valsArr.map((value, index): [StorageKey, Codec] => [keys[index], value])
)
) )
) : of([])
) )
); );
} }
+33 -10
View File
@@ -14,12 +14,13 @@ import { Metadata } from '@polkadot/metadata';
import { TypeRegistry } from '@polkadot/types/create'; import { TypeRegistry } from '@polkadot/types/create';
import { LATEST_EXTRINSIC_VERSION } from '@polkadot/types/extrinsic/Extrinsic'; import { LATEST_EXTRINSIC_VERSION } from '@polkadot/types/extrinsic/Extrinsic';
import { getSpecAlias, getSpecRpc, getSpecTypes, getUpgradeVersion } from '@polkadot/types-known'; import { getSpecAlias, getSpecRpc, getSpecTypes, getUpgradeVersion } from '@polkadot/types-known';
import { assert, BN_ZERO, logger, u8aEq, u8aToU8a } from '@polkadot/util'; import { assert, BN_ZERO, logger, u8aEq, u8aToHex, u8aToU8a } from '@polkadot/util';
import { cryptoWaitReady } from '@polkadot/util-crypto'; import { cryptoWaitReady } from '@polkadot/util-crypto';
import { of } from '@polkadot/x-rxjs'; import { of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators'; import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { Decorate } from './Decorate'; import { Decorate } from './Decorate';
import { detectedCapabilities } from './util';
const KEEPALIVE_INTERVAL = 15000; const KEEPALIVE_INTERVAL = 15000;
const DEFAULT_BLOCKNUMBER = { unwrap: () => BN_ZERO }; const DEFAULT_BLOCKNUMBER = { unwrap: () => BN_ZERO };
@@ -36,10 +37,6 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
constructor (options: ApiOptions, type: ApiTypes, decorateMethod: DecorateMethod<ApiType>) { constructor (options: ApiOptions, type: ApiTypes, decorateMethod: DecorateMethod<ApiType>) {
super(options, type, decorateMethod); super(options, type, decorateMethod);
if (!this.hasSubscriptions) {
l.warn('Api will be available in a limited mode since the provider does not support subscriptions');
}
// all injected types added to the registry for overrides // all injected types added to the registry for overrides
this.registry.setKnownTypes(options); this.registry.setKnownTypes(options);
@@ -63,9 +60,14 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
this._rx.signer = options.signer; this._rx.signer = options.signer;
this._rpcCore.setRegistrySwap((hash: string | Uint8Array) => this.getBlockRegistry(hash)); this._rpcCore.setRegistrySwap((hash: string | Uint8Array) => this.getBlockRegistry(hash));
this._rpcCore.provider.on('disconnected', this.#onProviderDisconnect);
this._rpcCore.provider.on('error', this.#onProviderError); if (this.hasSubscriptions) {
this._rpcCore.provider.on('connected', this.#onProviderConnect); this._rpcCore.provider.on('disconnected', this.#onProviderDisconnect);
this._rpcCore.provider.on('error', this.#onProviderError);
this._rpcCore.provider.on('connected', this.#onProviderConnect);
} else {
l.warn('Api will be available in a limited mode since the provider does not support subscriptions');
}
// If the provider was instantiated earlier, and has already emitted a // If the provider was instantiated earlier, and has already emitted a
// 'connected' event, then the `on('connected')` won't fire anymore. To // 'connected' event, then the `on('connected')` won't fire anymore. To
@@ -89,7 +91,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
registry.knownTypes.typesAlias = getSpecAlias(registry, chain, version.specName); registry.knownTypes.typesAlias = getSpecAlias(registry, chain, version.specName);
} }
registry.setMetadata(metadata); registry.setMetadata(metadata, undefined, this._options.signedExtensions);
return registry; return registry;
} }
@@ -135,6 +137,11 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
// nothing has been found, construct new // nothing has been found, construct new
const metadata = await this._rpcCore.state.getMetadata(header.parentHash).toPromise(); const metadata = await this._rpcCore.state.getMetadata(header.parentHash).toPromise();
const registry = this._initRegistry(new TypeRegistry(), this._runtimeChain as Text, version, metadata); const registry = this._initRegistry(new TypeRegistry(), 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, metadata, metadataConsts: null, registry, specVersion: version.specVersion };
this.#registries.push(result); this.#registries.push(result);
@@ -180,6 +187,19 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
return [source.genesisHash, source.runtimeMetadata]; return [source.genesisHash, source.runtimeMetadata];
} }
private _detectCapabilities (registry?: Registry, blockHash?: string | Uint8Array): void {
detectedCapabilities(this._rx, blockHash)
.toPromise()
.then((types): void => {
if (Object.keys(types).length) {
(registry || this.registry).register(types as Record<string, string>);
l.debug(`Capabilities detected${blockHash ? ` (${u8aToHex(u8aToU8a(blockHash))})` : ''}: ${JSON.stringify(types)}`);
}
})
.catch(l.error);
}
// subscribe to metadata updates, inject the types on changes // subscribe to metadata updates, inject the types on changes
private _subscribeUpdates (): void { private _subscribeUpdates (): void {
if (this.#updateSub || !this.hasSubscriptions) { if (this.#updateSub || !this.hasSubscriptions) {
@@ -212,6 +232,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
// clear the registry types to ensure that we override correctly // clear the registry types to ensure that we override correctly
this._initRegistry(thisRegistry.registry.init(), this._runtimeChain as Text, version, metadata); this._initRegistry(thisRegistry.registry.init(), this._runtimeChain as Text, version, metadata);
this.injectMetadata(metadata, false, thisRegistry.registry); this.injectMetadata(metadata, false, thisRegistry.registry);
this._detectCapabilities(thisRegistry.registry);
return true; return true;
}) })
@@ -277,9 +298,11 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
this._rx.extrinsicType = this._extrinsicType; this._rx.extrinsicType = this._extrinsicType;
this._rx.genesisHash = this._genesisHash; this._rx.genesisHash = this._genesisHash;
this._rx.runtimeVersion = this._runtimeVersion; this._rx.runtimeVersion = this._runtimeVersion as RuntimeVersion; // must be set here
// inject metadata and adjust the types as detected
this.injectMetadata(metadata, true); this.injectMetadata(metadata, true);
this._detectCapabilities();
// derive is last, since it uses the decorated rx // derive is last, since it uses the decorated rx
this._rx.derive = this._decorateDeriveRx(this._rxDecorateMethod); this._rx.derive = this._decorateDeriveRx(this._rxDecorateMethod);
+74
View File
@@ -0,0 +1,74 @@
// 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, Releases | null];
type DetectedKeys = keyof Pick<InterfaceTypes, 'AccountInfo' | 'ValidatorPrefs'>;
type DetectedValues = keyof InterfaceTypes;
interface DetectedTypes extends Record<DetectedKeys, DetectedValues> {
AccountInfo: 'AccountInfoWithRefCount' | 'AccountInfoWithProviders',
ValidatorPrefs: 'ValidatorPrefsWithBlocked' | 'ValidatorPrefsWithCommission';
}
function mapCapabilities ([systemRefcount32, systemRefcountDual, stakingVersion]: Extracted): Partial<DetectedTypes> {
const types: Partial<DetectedTypes> = {};
// AccountInfo
if (systemRefcountDual && systemRefcountDual.isTrue) {
types.AccountInfo = 'AccountInfoWithProviders';
} else if (systemRefcount32 && systemRefcount32.isTrue) {
types.AccountInfo = 'AccountInfoWithRefCount';
}
// 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.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)
);
}
+1 -1
View File
@@ -12,7 +12,7 @@ import { hexToU8a } from '@polkadot/util';
import { SingleAccountSigner } from '../../test/util'; import { SingleAccountSigner } from '../../test/util';
import { ApiPromise } from '.'; import { ApiPromise } from '.';
const TRANSFER_SIG = '0x7a10e5ed9a14284eca7bea53f81631981dddda5a3d2dee973b136475947264801465726e4829ae3994d9058df638d959d4e043c7f1924299546790dda1dea20a'; const TRANSFER_SIG = '0x54f39e43f32376a5ab6cdfd4d0ce57802aa9ff85514a7ffa9f2a949078f02beca16af87427c45fe60d54aa847fd241d127ed39e21b101806f6b1f50f7a82500b';
describe('ApiPromise', (): void => { describe('ApiPromise', (): void => {
const registry = new TypeRegistry(); const registry = new TypeRegistry();
+6 -1
View File
@@ -9,6 +9,7 @@ import type { DeriveCustom, ExactDerive } from '@polkadot/api-derive';
import type { Metadata } from '@polkadot/metadata'; import type { Metadata } from '@polkadot/metadata';
import type { RpcInterface } from '@polkadot/rpc-core/types'; import type { RpcInterface } from '@polkadot/rpc-core/types';
import type { ProviderInterface, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types'; import type { ProviderInterface, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types';
import type { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types';
import type { Hash, RuntimeVersion } from '@polkadot/types/interfaces'; import type { Hash, RuntimeVersion } from '@polkadot/types/interfaces';
import type { DefinitionRpc, DefinitionRpcSub, RegisteredTypes, Registry, SignatureOptions, Signer } from '@polkadot/types/types'; import type { DefinitionRpc, DefinitionRpcSub, RegisteredTypes, Registry, SignatureOptions, Signer } from '@polkadot/types/types';
import type { ApiBase } from '../base'; import type { ApiBase } from '../base';
@@ -56,6 +57,10 @@ export interface ApiOptions extends RegisteredTypes {
* @description User-defined RPC methods * @description User-defined RPC methods
*/ */
rpc?: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>; rpc?: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>;
/**
* @description Any chain-specific signed extensions that are now well-known
*/
signedExtensions?: Record<string, ExtDef>;
/** /**
* @description An external signer which will be used to sign extrinsic when account passed in is not KeyringPair * @description An external signer which will be used to sign extrinsic when account passed in is not KeyringPair
*/ */
@@ -76,7 +81,7 @@ export interface ApiInterfaceRx {
hasSubscriptions: boolean; hasSubscriptions: boolean;
registry: Registry; registry: Registry;
runtimeMetadata: Metadata; runtimeMetadata: Metadata;
runtimeVersion?: RuntimeVersion; runtimeVersion: RuntimeVersion;
query: QueryableStorage<'rxjs'>; query: QueryableStorage<'rxjs'>;
queryMulti: QueryableStorageMulti<'rxjs'>; queryMulti: QueryableStorageMulti<'rxjs'>;
rpc: DecoratedRpc<'rxjs', RpcInterface>; rpc: DecoratedRpc<'rxjs', RpcInterface>;
+6 -6
View File
@@ -38,16 +38,16 @@ export type QueryableStorageEntry<ApiType extends ApiTypes, A extends AnyTuple =
export interface StorageEntryBase<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple> { export interface StorageEntryBase<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple> {
at: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(hash: Hash | Uint8Array | string, ...args: Parameters<F>) => PromiseOrObs<ApiType, T>; at: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(hash: Hash | Uint8Array | string, ...args: Parameters<F>) => PromiseOrObs<ApiType, T>;
creator: StorageEntry; creator: StorageEntry;
entries: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(arg?: Parameters<F>[0]) => PromiseOrObs<ApiType, [StorageKey, T][]>; entries: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(arg?: Parameters<F>[0]) => PromiseOrObs<ApiType, [StorageKey<A>, T][]>;
entriesAt: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(hash: Hash | Uint8Array | string, arg?: Parameters<F>[0]) => PromiseOrObs<ApiType, [StorageKey, T][]>; entriesAt: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(hash: Hash | Uint8Array | string, arg?: Parameters<F>[0]) => PromiseOrObs<ApiType, [StorageKey<A>, T][]>;
entriesPaged: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, [StorageKey, T][]>; entriesPaged: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, [StorageKey<A>, T][]>;
hash: (...args: Parameters<F>) => PromiseOrObs<ApiType, Hash>; hash: (...args: Parameters<F>) => PromiseOrObs<ApiType, Hash>;
is: (key: IStorageKey<AnyTuple>) => key is IStorageKey<A>; is: (key: IStorageKey<AnyTuple>) => key is IStorageKey<A>;
key: (...args: Parameters<F>) => string; key: (...args: Parameters<F>) => string;
keyPrefix: () => string; keyPrefix: () => string;
keys: (arg?: any) => PromiseOrObs<ApiType, StorageKey[]>; keys: (arg?: any) => PromiseOrObs<ApiType, StorageKey<A>[]>;
keysAt: (hash: Hash | Uint8Array | string, arg?: any) => PromiseOrObs<ApiType, StorageKey[]>; keysAt: (hash: Hash | Uint8Array | string, arg?: any) => PromiseOrObs<ApiType, StorageKey<A>[]>;
keysPaged: (opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, StorageKey[]>; keysPaged: (opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, StorageKey<A>[]>;
// @deprecated The underlying RPC this been marked unsafe and is generally not exposed // @deprecated The underlying RPC this been marked unsafe and is generally not exposed
range: <T extends Codec | any = ObsInnerType<ReturnType<F>>>([from, to]: [Hash | Uint8Array | string, Hash | Uint8Array | string | undefined] | [Hash | Uint8Array | string], ...args: Parameters<F>) => PromiseOrObs<ApiType, [Hash, T][]>; range: <T extends Codec | any = ObsInnerType<ReturnType<F>>>([from, to]: [Hash | Uint8Array | string, Hash | Uint8Array | string | undefined] | [Hash | Uint8Array | string], ...args: Parameters<F>) => PromiseOrObs<ApiType, [Hash, T][]>;
size: (...args: Parameters<F>) => PromiseOrObs<ApiType, u64>; size: (...args: Parameters<F>) => PromiseOrObs<ApiType, u64>;
+6 -7
View File
@@ -1,9 +1,8 @@
{ {
"name": "@polkadot/metadata", "name": "@polkadot/metadata",
"version": "3.3.1", "version": "3.7.3",
"description": "Helpers to extract information from runtime metadata", "description": "Helpers to extract information from runtime metadata",
"main": "index.js", "main": "index.js",
"module": "index.mjs",
"sideEffects": [ "sideEffects": [
"./detectPackage.js", "./detectPackage.js",
"./detectPackage.mjs" "./detectPackage.mjs"
@@ -17,13 +16,13 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme", "homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@polkadot/types": "3.3.1", "@polkadot/types": "3.7.3",
"@polkadot/types-known": "3.3.1", "@polkadot/types-known": "3.7.3",
"@polkadot/util": "^5.2.3", "@polkadot/util": "^5.5.2",
"@polkadot/util-crypto": "^5.2.3", "@polkadot/util-crypto": "^5.5.2",
"bn.js": "^4.11.9" "bn.js": "^4.11.9"
}, },
"devDependencies": { "devDependencies": {
"@polkadot/keyring": "^5.2.3" "@polkadot/keyring": "^5.5.2"
} }
} }
@@ -8,7 +8,7 @@ import type { Events, ModuleEvents } from '../types';
import { stringCamelCase } from '@polkadot/util'; import { stringCamelCase } from '@polkadot/util';
function isEvent <T extends AnyTuple> (event: IEvent<AnyTuple>, sectionIndex: number, eventIndex: number): event is IEvent<T> { function isEvent <T extends AnyTuple> (event: IEvent<AnyTuple>, sectionIndex: number, eventIndex: number): event is IEvent<T> {
return event.index[0] === sectionIndex && event.index[0] === eventIndex; return event.index[0] === sectionIndex && event.index[1] === eventIndex;
} }
/** @internal */ /** @internal */
@@ -15,6 +15,7 @@ const registry = new TypeRegistry();
const metadata = new Metadata(registry, metadataStatic); const metadata = new Metadata(registry, metadataStatic);
registry.setMetadata(metadata); registry.setMetadata(metadata);
registry.register({ Address: 'IndicesLookupSource', LookupSource: 'IndicesLookupSource' });
const extrinsics = decorateExtrinsics(registry, metadata.asLatest, metadata.version); const extrinsics = decorateExtrinsics(registry, metadata.asLatest, metadata.version);
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+7 -8
View File
@@ -1,9 +1,8 @@
{ {
"name": "@polkadot/rpc-core", "name": "@polkadot/rpc-core",
"version": "3.3.1", "version": "3.7.3",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface", "description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js", "main": "index.js",
"module": "index.mjs",
"sideEffects": false, "sideEffects": false,
"author": "Jaco Greeff <jacogr@gmail.com>", "author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [], "maintainers": [],
@@ -14,13 +13,13 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme", "homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@polkadot/metadata": "3.3.1", "@polkadot/metadata": "3.7.3",
"@polkadot/rpc-provider": "3.3.1", "@polkadot/rpc-provider": "3.7.3",
"@polkadot/types": "3.3.1", "@polkadot/types": "3.7.3",
"@polkadot/util": "^5.2.3", "@polkadot/util": "^5.5.2",
"@polkadot/x-rxjs": "3.3.1" "@polkadot/x-rxjs": "^5.5.2"
}, },
"devDependencies": { "devDependencies": {
"@polkadot/keyring": "^5.2.3" "@polkadot/keyring": "^5.5.2"
} }
} }
+10 -10
View File
@@ -1,9 +1,8 @@
{ {
"name": "@polkadot/rpc-provider", "name": "@polkadot/rpc-provider",
"version": "3.3.1", "version": "3.7.3",
"description": "Transport providers for the API", "description": "Transport providers for the API",
"main": "index.js", "main": "index.js",
"module": "index.mjs",
"sideEffects": false, "sideEffects": false,
"author": "Jaco Greeff <jacogr@gmail.com>", "author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [], "maintainers": [],
@@ -14,18 +13,19 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme", "homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@polkadot/types": "3.3.1", "@polkadot/types": "3.7.3",
"@polkadot/util": "^5.2.3", "@polkadot/util": "^5.5.2",
"@polkadot/util-crypto": "^5.2.3", "@polkadot/util-crypto": "^5.5.2",
"@polkadot/x-fetch": "^5.2.3", "@polkadot/x-fetch": "^5.5.2",
"@polkadot/x-ws": "^5.2.3", "@polkadot/x-global": "^5.5.2",
"@polkadot/x-ws": "^5.5.2",
"bn.js": "^4.11.9", "bn.js": "^4.11.9",
"eventemitter3": "^4.0.7" "eventemitter3": "^4.0.7"
}, },
"devDependencies": { "devDependencies": {
"@polkadot/keyring": "^5.2.3", "@polkadot/keyring": "^5.5.2",
"@polkadot/metadata": "3.3.1", "@polkadot/metadata": "3.7.3",
"mock-socket": "^9.0.3", "mock-socket": "^9.0.3",
"nock": "^13.0.5" "nock": "^13.0.7"
} }
} }
+2 -1
View File
@@ -8,6 +8,7 @@ import type { JsonRpcResponse, ProviderInterface, ProviderInterfaceCallback, Pro
import EventEmitter from 'eventemitter3'; import EventEmitter from 'eventemitter3';
import { assert, isChildClass, isNull, isUndefined, logger } from '@polkadot/util'; import { assert, isChildClass, isNull, isUndefined, logger } from '@polkadot/util';
import { xglobal } from '@polkadot/x-global';
import { WebSocket } from '@polkadot/x-ws'; import { WebSocket } from '@polkadot/x-ws';
import { RpcCoder } from '../coder'; import { RpcCoder } from '../coder';
@@ -160,7 +161,7 @@ export class WsProvider implements ProviderInterface {
public async connect (): Promise<void> { public async connect (): Promise<void> {
try { try {
this.#endpointIndex = (this.#endpointIndex + 1) % this.#endpoints.length; this.#endpointIndex = (this.#endpointIndex + 1) % this.#endpoints.length;
this.#websocket = typeof global.WebSocket !== 'undefined' && isChildClass(global.WebSocket, WebSocket) this.#websocket = typeof xglobal.WebSocket !== 'undefined' && isChildClass(xglobal.WebSocket, WebSocket)
? new WebSocket(this.#endpoints[this.#endpointIndex]) ? new WebSocket(this.#endpoints[this.#endpointIndex])
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore - WS may be an instance of w3cwebsocket, which supports headers // @ts-ignore - WS may be an instance of w3cwebsocket, which supports headers
+7 -8
View File
@@ -1,9 +1,8 @@
{ {
"name": "@polkadot/typegen", "name": "@polkadot/typegen",
"version": "3.3.1", "version": "3.7.3",
"description": "Type generation scripts", "description": "Type generation scripts",
"main": "index.js", "main": "index.js",
"module": "index.mjs",
"sideEffects": false, "sideEffects": false,
"bin": { "bin": {
"polkadot-types-chain-info": "./scripts/polkadot-types-chain-info.js", "polkadot-types-chain-info": "./scripts/polkadot-types-chain-info.js",
@@ -23,17 +22,17 @@
"@babel/core": "^7.12.10", "@babel/core": "^7.12.10",
"@babel/register": "^7.12.10", "@babel/register": "^7.12.10",
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@polkadot/api": "3.3.1", "@polkadot/api": "3.7.3",
"@polkadot/metadata": "3.3.1", "@polkadot/metadata": "3.7.3",
"@polkadot/rpc-provider": "3.3.1", "@polkadot/rpc-provider": "3.7.3",
"@polkadot/types": "3.3.1", "@polkadot/types": "3.7.3",
"@polkadot/util": "^5.2.3", "@polkadot/util": "^5.5.2",
"handlebars": "^4.7.6", "handlebars": "^4.7.6",
"websocket": "^1.0.33", "websocket": "^1.0.33",
"yargs": "^16.2.0" "yargs": "^16.2.0"
}, },
"devDependencies": { "devDependencies": {
"@types/websocket": "^1.0.1", "@types/websocket": "^1.0.1",
"@types/yargs": "^15.0.12" "@types/yargs": "^15.0.13"
} }
} }
+1 -1
View File
@@ -19,7 +19,7 @@ function generate (metaHex: string, pkg: string | undefined, output: string, isS
: {}; : {};
generateDefaultConsts(path.join(process.cwd(), output, 'augment-api-consts.ts'), metaHex, extraTypes, isStrict); generateDefaultConsts(path.join(process.cwd(), output, 'augment-api-consts.ts'), metaHex, extraTypes, isStrict);
generateDefaultErrors(path.join(process.cwd(), output, 'augment-api-errors.ts'), metaHex, isStrict); generateDefaultErrors(path.join(process.cwd(), output, 'augment-api-errors.ts'), metaHex, extraTypes, isStrict);
generateDefaultEvents(path.join(process.cwd(), output, 'augment-api-events.ts'), metaHex, extraTypes, isStrict); generateDefaultEvents(path.join(process.cwd(), output, 'augment-api-events.ts'), metaHex, extraTypes, isStrict);
generateDefaultQuery(path.join(process.cwd(), output, 'augment-api-query.ts'), metaHex, extraTypes, isStrict); generateDefaultQuery(path.join(process.cwd(), output, 'augment-api-query.ts'), metaHex, extraTypes, isStrict);
generateDefaultRpc(path.join(process.cwd(), output, 'augment-api-rpc.ts'), extraTypes); generateDefaultRpc(path.join(process.cwd(), output, 'augment-api-rpc.ts'), extraTypes);
+8 -14
View File
@@ -1,23 +1,23 @@
// Copyright 2017-2021 @polkadot/typegen authors & contributors // Copyright 2017-2021 @polkadot/typegen authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { Metadata } from '@polkadot/metadata/Metadata';
import type { ExtraTypes } from './types';
import Handlebars from 'handlebars'; import Handlebars from 'handlebars';
import { Metadata } from '@polkadot/metadata/Metadata';
import staticData from '@polkadot/metadata/static';
import { TypeRegistry } from '@polkadot/types/create';
import * as defaultDefs from '@polkadot/types/interfaces/definitions'; import * as defaultDefs from '@polkadot/types/interfaces/definitions';
import { stringCamelCase } from '@polkadot/util'; import { stringCamelCase } from '@polkadot/util';
import { compareName, createImports, formatType, readTemplate, registerDefinitions, setImports, writeFile } from '../util'; import { compareName, createImports, formatType, initMeta, readTemplate, setImports, writeFile } from '../util';
const template = readTemplate('consts'); const template = readTemplate('consts');
const generateForMetaTemplate = Handlebars.compile(template); const generateForMetaTemplate = Handlebars.compile(template);
/** @internal */ /** @internal */
function generateForMeta (meta: Metadata, dest: string, extraTypes: Record<string, Record<string, { types: Record<string, any> }>>, isStrict: boolean): void { function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes, isStrict: boolean): void {
writeFile(dest, (): string => { writeFile(dest, (): string => {
const allTypes: Record<string, Record<string, { types: Record<string, unknown> }>> = { '@polkadot/types/interfaces': defaultDefs, ...extraTypes }; const allTypes = { '@polkadot/types/interfaces': defaultDefs, ...extraTypes };
const imports = createImports(allTypes); const imports = createImports(allTypes);
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => { const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs); return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
@@ -74,14 +74,8 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: Record<strin
// Call `generateForMeta()` with current static metadata // Call `generateForMeta()` with current static metadata
/** @internal */ /** @internal */
export function generateDefaultConsts (dest = 'packages/api/src/augment/consts.ts', data = staticData, extraTypes: Record<string, Record<string, { types: Record<string, any> }>> = {}, isStrict = false): void { export function generateDefaultConsts (dest = 'packages/api/src/augment/consts.ts', data?: string, extraTypes: ExtraTypes = {}, isStrict = false): void {
const registry = new TypeRegistry(); const { metadata } = initMeta(data, extraTypes);
registerDefinitions(registry, extraTypes);
const metadata = new Metadata(registry, data);
registry.setMetadata(metadata);
return generateForMeta(metadata, dest, extraTypes, isStrict); return generateForMeta(metadata, dest, extraTypes, isStrict);
} }
+6 -9
View File
@@ -1,14 +1,14 @@
// Copyright 2017-2021 @polkadot/typegen authors & contributors // Copyright 2017-2021 @polkadot/typegen authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { Metadata } from '@polkadot/metadata/Metadata';
import type { ExtraTypes } from './types';
import Handlebars from 'handlebars'; import Handlebars from 'handlebars';
import { Metadata } from '@polkadot/metadata/Metadata';
import staticData from '@polkadot/metadata/static';
import { TypeRegistry } from '@polkadot/types/create';
import { stringCamelCase } from '@polkadot/util'; import { stringCamelCase } from '@polkadot/util';
import { compareName, createImports, readTemplate, writeFile } from '../util'; import { compareName, createImports, initMeta, readTemplate, writeFile } from '../util';
const template = readTemplate('errors'); const template = readTemplate('errors');
const generateForMetaTemplate = Handlebars.compile(template); const generateForMetaTemplate = Handlebars.compile(template);
@@ -50,11 +50,8 @@ function generateForMeta (meta: Metadata, dest: string, isStrict: boolean): void
// Call `generateForMeta()` with current static metadata // Call `generateForMeta()` with current static metadata
/** @internal */ /** @internal */
export function generateDefaultErrors (dest = 'packages/api/src/augment/errors.ts', data = staticData, isStrict = false): void { export function generateDefaultErrors (dest = 'packages/api/src/augment/errors.ts', data?: string, extraTypes: ExtraTypes = {}, isStrict = false): void {
const registry = new TypeRegistry(); const { metadata } = initMeta(data, extraTypes);
const metadata = new Metadata(registry, data);
registry.setMetadata(metadata);
return generateForMeta(metadata, dest, isStrict); return generateForMeta(metadata, dest, isStrict);
} }
+8 -14
View File
@@ -1,23 +1,23 @@
// Copyright 2017-2021 @polkadot/typegen authors & contributors // Copyright 2017-2021 @polkadot/typegen authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { Metadata } from '@polkadot/metadata/Metadata';
import type { ExtraTypes } from './types';
import Handlebars from 'handlebars'; import Handlebars from 'handlebars';
import { Metadata } from '@polkadot/metadata/Metadata';
import staticData from '@polkadot/metadata/static';
import { TypeRegistry } from '@polkadot/types/create';
import * as defaultDefs from '@polkadot/types/interfaces/definitions'; import * as defaultDefs from '@polkadot/types/interfaces/definitions';
import { stringCamelCase } from '@polkadot/util'; import { stringCamelCase } from '@polkadot/util';
import { compareName, createImports, formatType, readTemplate, registerDefinitions, setImports, writeFile } from '../util'; import { compareName, createImports, formatType, initMeta, readTemplate, setImports, writeFile } from '../util';
const template = readTemplate('events'); const template = readTemplate('events');
const generateForMetaTemplate = Handlebars.compile(template); const generateForMetaTemplate = Handlebars.compile(template);
/** @internal */ /** @internal */
function generateForMeta (meta: Metadata, dest: string, extraTypes: Record<string, Record<string, { types: Record<string, any> }>>, isStrict: boolean): void { function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes, isStrict: boolean): void {
writeFile(dest, (): string => { writeFile(dest, (): string => {
const allTypes: Record<string, Record<string, { types: Record<string, unknown> }>> = { '@polkadot/types/interfaces': defaultDefs, ...extraTypes }; const allTypes = { '@polkadot/types/interfaces': defaultDefs, ...extraTypes };
const imports = createImports(allTypes); const imports = createImports(allTypes);
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => { const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs); return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
@@ -67,14 +67,8 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: Record<strin
// Call `generateForMeta()` with current static metadata // Call `generateForMeta()` with current static metadata
/** @internal */ /** @internal */
export function generateDefaultEvents (dest = 'packages/api/src/augment/events.ts', data = staticData, extraTypes: Record<string, Record<string, { types: Record<string, any> }>> = {}, isStrict = false): void { export function generateDefaultEvents (dest = 'packages/api/src/augment/events.ts', data?: string, extraTypes: ExtraTypes = {}, isStrict = false): void {
const registry = new TypeRegistry(); const { metadata } = initMeta(data, extraTypes);
registerDefinitions(registry, extraTypes);
const metadata = new Metadata(registry, data);
registry.setMetadata(metadata);
return generateForMeta(metadata, dest, extraTypes, isStrict); return generateForMeta(metadata, dest, extraTypes, isStrict);
} }
@@ -72,7 +72,7 @@ export function generateInterfaceTypes (importDefinitions: { [importPath: string
return generateInterfaceTypesTemplate({ return generateInterfaceTypesTemplate({
headerType: 'defs', headerType: 'defs',
imports, imports,
items, items: items.sort((a, b) => a.localeCompare(b)),
types types
}); });
}); });
+7 -14
View File
@@ -1,19 +1,18 @@
// Copyright 2017-2021 @polkadot/typegen authors & contributors // Copyright 2017-2021 @polkadot/typegen authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { Metadata } from '@polkadot/metadata/Metadata';
import type { StorageEntryMetadataLatest } from '@polkadot/types/interfaces/metadata'; import type { StorageEntryMetadataLatest } from '@polkadot/types/interfaces/metadata';
import type { Registry } from '@polkadot/types/types'; import type { Registry } from '@polkadot/types/types';
import type { ExtraTypes } from './types';
import Handlebars from 'handlebars'; import Handlebars from 'handlebars';
import { Metadata } from '@polkadot/metadata/Metadata';
import staticData from '@polkadot/metadata/static';
import { TypeRegistry } from '@polkadot/types/create';
import * as defaultDefs from '@polkadot/types/interfaces/definitions'; import * as defaultDefs from '@polkadot/types/interfaces/definitions';
import { unwrapStorageType } from '@polkadot/types/primitive/StorageKey'; import { unwrapStorageType } from '@polkadot/types/primitive/StorageKey';
import { stringCamelCase } from '@polkadot/util'; import { stringCamelCase } from '@polkadot/util';
import { compareName, createImports, formatType, getSimilarTypes, readTemplate, registerDefinitions, setImports, TypeImports, writeFile } from '../util'; import { compareName, createImports, formatType, getSimilarTypes, initMeta, readTemplate, setImports, TypeImports, writeFile } from '../util';
import { ModuleTypes } from '../util/imports'; import { ModuleTypes } from '../util/imports';
// From a storage entry metadata, we return [args, returnType] // From a storage entry metadata, we return [args, returnType]
@@ -67,9 +66,9 @@ const template = readTemplate('query');
const generateForMetaTemplate = Handlebars.compile(template); const generateForMetaTemplate = Handlebars.compile(template);
/** @internal */ /** @internal */
function generateForMeta (registry: Registry, meta: Metadata, dest: string, extraTypes: Record<string, Record<string, { types: Record<string, any> }>>, isStrict: boolean): void { function generateForMeta (registry: Registry, meta: Metadata, dest: string, extraTypes: ExtraTypes, isStrict: boolean): void {
writeFile(dest, (): string => { writeFile(dest, (): string => {
const allTypes: Record<string, Record<string, { types: Record<string, any> }>> = { '@polkadot/types/interfaces': defaultDefs, ...extraTypes }; const allTypes: ExtraTypes = { '@polkadot/types/interfaces': defaultDefs, ...extraTypes };
const imports = createImports(allTypes); const imports = createImports(allTypes);
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => { const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs); return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
@@ -130,14 +129,8 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
// Call `generateForMeta()` with current static metadata // Call `generateForMeta()` with current static metadata
/** @internal */ /** @internal */
export function generateDefaultQuery (dest = 'packages/api/src/augment/query.ts', data = staticData, extraTypes: Record<string, Record<string, { types: Record<string, any> }>> = {}, isStrict = false): void { export function generateDefaultQuery (dest = 'packages/api/src/augment/query.ts', data?: string, extraTypes: ExtraTypes = {}, isStrict = false): void {
const registry = new TypeRegistry(); const { metadata, registry } = initMeta(data, extraTypes);
registerDefinitions(registry, extraTypes);
const metadata = new Metadata(registry, data);
registry.setMetadata(metadata);
return generateForMeta(registry, metadata, dest, extraTypes, isStrict); return generateForMeta(registry, metadata, dest, extraTypes, isStrict);
} }
+7 -8
View File
@@ -1,14 +1,15 @@
// Copyright 2017-2021 @polkadot/typegen authors & contributors // Copyright 2017-2021 @polkadot/typegen authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { TypeRegistry } from '@polkadot/types/create';
import type { Definitions } from '@polkadot/types/types'; import type { Definitions } from '@polkadot/types/types';
import type { ExtraTypes } from './types';
import Handlebars from 'handlebars'; import Handlebars from 'handlebars';
import { TypeRegistry } from '@polkadot/types/create';
import * as defaultDefinitions from '@polkadot/types/interfaces/definitions'; import * as defaultDefinitions from '@polkadot/types/interfaces/definitions';
import { createImports, formatType, getSimilarTypes, readTemplate, registerDefinitions, setImports, writeFile } from '../util'; import { createImports, formatType, getSimilarTypes, initMeta, readTemplate, setImports, writeFile } from '../util';
interface ItemDef { interface ItemDef {
args: string; args: string;
@@ -29,9 +30,9 @@ const template = readTemplate('rpc');
const generateRpcTypesTemplate = Handlebars.compile(template); const generateRpcTypesTemplate = Handlebars.compile(template);
/** @internal */ /** @internal */
export function generateRpcTypes (registry: TypeRegistry, importDefinitions: Record<string, Definitions>, dest: string, extraTypes: Record<string, Record<string, { types: Record<string, any> }>> = {}): void { export function generateRpcTypes (registry: TypeRegistry, importDefinitions: Record<string, Definitions>, dest: string, extraTypes: ExtraTypes = {}): void {
writeFile(dest, (): string => { writeFile(dest, (): string => {
const allTypes: Record<string, Record<string, { types: Record<string, any> }>> = { '@polkadot/types/interfaces': importDefinitions, ...extraTypes }; const allTypes: ExtraTypes = { '@polkadot/types/interfaces': importDefinitions, ...extraTypes };
const imports = createImports(allTypes); const imports = createImports(allTypes);
const definitions = imports.definitions as Record<string, Definitions>; const definitions = imports.definitions as Record<string, Definitions>;
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => { const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
@@ -141,10 +142,8 @@ export function generateRpcTypes (registry: TypeRegistry, importDefinitions: Rec
}); });
} }
export function generateDefaultRpc (dest = 'packages/api/src/augment/rpc.ts', extraTypes: Record<string, Record<string, { types: Record<string, any> }>> = {}): void { export function generateDefaultRpc (dest = 'packages/api/src/augment/rpc.ts', extraTypes: ExtraTypes = {}): void {
const registry = new TypeRegistry(); const { registry } = initMeta(undefined, extraTypes);
registerDefinitions(registry, extraTypes);
generateRpcTypes( generateRpcTypes(
registry, registry,
+1 -1
View File
@@ -52,7 +52,7 @@ function tsEnum (definitions: Record<string, ModuleTypes>, { name: enumName, sub
const keys = (sub as TypeDef[]).map(({ info, name = '', type }): string => { const keys = (sub as TypeDef[]).map(({ info, name = '', type }): string => {
const getter = stringUpperFirst(stringCamelCase(name.replace(' ', '_'))); const getter = stringUpperFirst(stringCamelCase(name.replace(' ', '_')));
const isComplexType = [TypeDefInfo.Tuple, TypeDefInfo.VecFixed].includes(info); const isComplexType = [TypeDefInfo.Tuple, TypeDefInfo.Vec, TypeDefInfo.VecFixed].includes(info);
const asGetter = type === 'Null' || info === TypeDefInfo.DoNotConstruct const asGetter = type === 'Null' || info === TypeDefInfo.DoNotConstruct
? '' ? ''
: createGetter(definitions, `as${getter}`, isComplexType ? formatType(definitions, type, imports) : type, imports); : createGetter(definitions, `as${getter}`, isComplexType ? formatType(definitions, type, imports) : type, imports);
+7 -14
View File
@@ -1,18 +1,17 @@
// Copyright 2017-2021 @polkadot/typegen authors & contributors // Copyright 2017-2021 @polkadot/typegen authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { Metadata } from '@polkadot/metadata/Metadata';
import type { Registry } from '@polkadot/types/types'; import type { Registry } from '@polkadot/types/types';
import type { ExtraTypes } from './types';
import Handlebars from 'handlebars'; import Handlebars from 'handlebars';
import { Metadata } from '@polkadot/metadata/Metadata';
import staticData from '@polkadot/metadata/static';
import { TypeRegistry } from '@polkadot/types/create';
import * as defaultDefs from '@polkadot/types/interfaces/definitions'; import * as defaultDefs from '@polkadot/types/interfaces/definitions';
import { Text } from '@polkadot/types/primitive'; import { Text } from '@polkadot/types/primitive';
import { stringCamelCase } from '@polkadot/util'; import { stringCamelCase } from '@polkadot/util';
import { compareName, createImports, formatType, getSimilarTypes, readTemplate, registerDefinitions, setImports, writeFile } from '../util'; import { compareName, createImports, formatType, getSimilarTypes, initMeta, readTemplate, setImports, writeFile } from '../util';
const MAPPED_NAMES: Record<string, string> = { const MAPPED_NAMES: Record<string, string> = {
new: 'updated' new: 'updated'
@@ -28,9 +27,9 @@ const template = readTemplate('tx');
const generateForMetaTemplate = Handlebars.compile(template); const generateForMetaTemplate = Handlebars.compile(template);
/** @internal */ /** @internal */
function generateForMeta (registry: Registry, meta: Metadata, dest: string, extraTypes: Record<string, Record<string, { types: Record<string, any> }>>, isStrict: boolean): void { function generateForMeta (registry: Registry, meta: Metadata, dest: string, extraTypes: ExtraTypes, isStrict: boolean): void {
writeFile(dest, (): string => { writeFile(dest, (): string => {
const allTypes: Record<string, Record<string, { types: Record<string, any> }>> = { '@polkadot/types/interfaces': defaultDefs, ...extraTypes }; const allTypes: ExtraTypes = { '@polkadot/types/interfaces': defaultDefs, ...extraTypes };
const imports = createImports(allTypes); const imports = createImports(allTypes);
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => { const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs); return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
@@ -93,14 +92,8 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
// Call `generateForMeta()` with current static metadata // Call `generateForMeta()` with current static metadata
/** @internal */ /** @internal */
export function generateDefaultTx (dest = 'packages/api/src/augment/tx.ts', data = staticData, extraTypes: Record<string, Record<string, { types: Record<string, any> }>> = {}, isStrict = false): void { export function generateDefaultTx (dest = 'packages/api/src/augment/tx.ts', data?: string, extraTypes: ExtraTypes = {}, isStrict = false): void {
const registry = new TypeRegistry(); const { metadata, registry } = initMeta(data, extraTypes);
registerDefinitions(registry, extraTypes);
const metadata = new Metadata(registry, data);
registry.setMetadata(metadata);
return generateForMeta(registry, metadata, dest, extraTypes, isStrict); return generateForMeta(registry, metadata, dest, extraTypes, isStrict);
} }
+4
View File
@@ -0,0 +1,4 @@
// Copyright 2017-2021 @polkadot/typegen authors & contributors
// SPDX-License-Identifier: Apache-2.0
export type ExtraTypes = Record<string, Record<string, { types: Record<string, any> }>>;
+2
View File
@@ -275,6 +275,7 @@ function addEvents (metadata: MetadataLatest): string {
const args = func.args.map((type): string => '`' + type.toString() + '`').join(', '); const args = func.args.map((type): string => '`' + type.toString() + '`').join(', ');
return { return {
interface: '`' + `api.events.${stringCamelCase(meta.name)}.${methodName}.is` + '`',
name: `${methodName}(${args})`, name: `${methodName}(${args})`,
...(func.documentation.length && { summary: func.documentation }) ...(func.documentation.length && { summary: func.documentation })
}; };
@@ -296,6 +297,7 @@ function addErrors (metadata: MetadataLatest): string {
items: moduleMetadata.errors items: moduleMetadata.errors
.sort(sortByName) .sort(sortByName)
.map((error) => ({ .map((error) => ({
interface: '`' + `api.errors.${stringCamelCase(moduleMetadata.name)}.${error.name.toString()}.is` + '`',
name: error.name.toString(), name: error.name.toString(),
...(error.documentation.length && { summary: error.documentation }) ...(error.documentation.length && { summary: error.documentation })
})), })),
+1
View File
@@ -6,6 +6,7 @@ export * from './docs';
export * from './file'; export * from './file';
export * from './formatting'; export * from './formatting';
export * from './imports'; export * from './imports';
export * from './initMeta';
export * from './register'; export * from './register';
export const compareName = (a: { name: { toString(): string } }, b: { name: { toString(): string } }): number => export const compareName = (a: { name: { toString(): string } }, b: { name: { toString(): string } }): number =>
+27
View File
@@ -0,0 +1,27 @@
// Copyright 2017-2021 @polkadot/typegen authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ExtraTypes } from '../generate/types';
import { Metadata } from '@polkadot/metadata/Metadata';
import staticData from '@polkadot/metadata/static';
import { TypeRegistry } from '@polkadot/types/create';
import { registerDefinitions } from './register';
interface Result {
metadata: Metadata;
registry: TypeRegistry;
}
export function initMeta (data = staticData, extraTypes: ExtraTypes = {}): Result {
const registry = new TypeRegistry();
registerDefinitions(registry, extraTypes);
const metadata = new Metadata(registry, data);
registry.setMetadata(metadata);
return { metadata, registry };
}
+4 -4
View File
@@ -1,9 +1,8 @@
{ {
"name": "@polkadot/types-known", "name": "@polkadot/types-known",
"version": "3.3.1", "version": "3.7.3",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface", "description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js", "main": "index.js",
"module": "index.mjs",
"sideEffects": false, "sideEffects": false,
"author": "Jaco Greeff <jacogr@gmail.com>", "author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [], "maintainers": [],
@@ -14,8 +13,9 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme", "homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@polkadot/types": "3.3.1", "@polkadot/networks": "^5.5.2",
"@polkadot/util": "^5.2.3", "@polkadot/types": "3.7.3",
"@polkadot/util": "^5.5.2",
"bn.js": "^4.11.9" "bn.js": "^4.11.9"
}, },
"devDependencies": { "devDependencies": {
+12
View File
@@ -5,6 +5,9 @@ import type { OverrideModuleType } from '@polkadot/types/types';
// type overrides for modules (where duplication between modules exist) // type overrides for modules (where duplication between modules exist)
const typesModules: Record<string, OverrideModuleType> = { const typesModules: Record<string, OverrideModuleType> = {
assets: {
Balance: 'TAssetBalance'
},
babe: { babe: {
EquivocationProof: 'BabeEquivocationProof' EquivocationProof: 'BabeEquivocationProof'
}, },
@@ -33,15 +36,24 @@ const typesModules: Record<string, OverrideModuleType> = {
identity: { identity: {
Judgement: 'IdentityJudgement' Judgement: 'IdentityJudgement'
}, },
inclusion: {
ValidatorIndex: 'ParaValidatorIndex'
},
parachains: { parachains: {
Id: 'ParaId' Id: 'ParaId'
}, },
parasScheduler: {
ValidatorIndex: 'ParaValidatorIndex'
},
proposeParachain: { proposeParachain: {
Proposal: 'ParachainProposal' Proposal: 'ParachainProposal'
}, },
proxy: { proxy: {
Announcement: 'ProxyAnnouncement' Announcement: 'ProxyAnnouncement'
}, },
scheduler: {
ValidatorIndex: 'ParaValidatorIndex'
},
society: { society: {
Judgement: 'SocietyJudgement', Judgement: 'SocietyJudgement',
Vote: 'SocietyVote' Vote: 'SocietyVote'
+37 -13
View File
@@ -6,19 +6,30 @@
import type { OverrideVersionedType } from '@polkadot/types/types'; import type { OverrideVersionedType } from '@polkadot/types/types';
const sharedTypes = { const sharedTypes = {
AccountInfo: 'AccountInfoWithProviders',
Address: 'MultiAddress',
Keys: 'SessionKeys6',
LookupSource: 'MultiAddress',
ProxyType: {
_enum: ['Any', 'NonTransfer', 'Governance', 'Staking', 'IdentityJudgement']
},
ValidatorPrefs: 'ValidatorPrefsWithBlocked'
};
const addrIndicesTypes = {
AccountInfo: 'AccountInfoWithRefCount',
Address: 'LookupSource',
Keys: 'SessionKeys5',
LookupSource: 'IndicesLookupSource',
ValidatorPrefs: 'ValidatorPrefsWithCommission'
};
const addrAccountIdTypes = {
AccountInfo: 'AccountInfoWithRefCount', AccountInfo: 'AccountInfoWithRefCount',
Address: 'AccountId', Address: 'AccountId',
Keys: 'SessionKeys5', Keys: 'SessionKeys5',
LookupSource: 'AccountId', LookupSource: 'AccountId',
ProxyType: { ValidatorPrefs: 'ValidatorPrefsWithCommission'
_enum: ['Any', 'NonTransfer', 'Governance', 'Staking', 'IdentityJudgement']
}
};
const indicesTypes = {
AccountInfo: 'AccountInfoWithRefCount',
Address: 'LookupSource',
LookupSource: 'IndicesLookupSource'
}; };
const versioned: OverrideVersionedType[] = [ const versioned: OverrideVersionedType[] = [
@@ -26,7 +37,7 @@ const versioned: OverrideVersionedType[] = [
// 1020 is first CC3 // 1020 is first CC3
minmax: [1019, 1031], minmax: [1019, 1031],
types: { types: {
...indicesTypes, ...addrIndicesTypes,
BalanceLock: 'BalanceLockTo212', BalanceLock: 'BalanceLockTo212',
CompactAssignments: 'CompactAssignmentsTo257', CompactAssignments: 'CompactAssignmentsTo257',
DispatchError: 'DispatchErrorTo198', DispatchError: 'DispatchErrorTo198',
@@ -46,7 +57,7 @@ const versioned: OverrideVersionedType[] = [
{ {
minmax: [1032, 1042], minmax: [1032, 1042],
types: { types: {
...indicesTypes, ...addrIndicesTypes,
BalanceLock: 'BalanceLockTo212', BalanceLock: 'BalanceLockTo212',
CompactAssignments: 'CompactAssignmentsTo257', CompactAssignments: 'CompactAssignmentsTo257',
DispatchInfo: 'DispatchInfoTo244', DispatchInfo: 'DispatchInfoTo244',
@@ -66,7 +77,7 @@ const versioned: OverrideVersionedType[] = [
// actual at 1045 (1043-1044 is dev) // actual at 1045 (1043-1044 is dev)
minmax: [1043, 1045], minmax: [1043, 1045],
types: { types: {
...indicesTypes, ...addrIndicesTypes,
BalanceLock: 'BalanceLockTo212', BalanceLock: 'BalanceLockTo212',
CompactAssignments: 'CompactAssignmentsTo257', CompactAssignments: 'CompactAssignmentsTo257',
DispatchInfo: 'DispatchInfoTo244', DispatchInfo: 'DispatchInfoTo244',
@@ -86,6 +97,7 @@ const versioned: OverrideVersionedType[] = [
types: { types: {
// Indices optional, not in transaction // Indices optional, not in transaction
...sharedTypes, ...sharedTypes,
...addrAccountIdTypes,
CompactAssignments: 'CompactAssignmentsTo257', CompactAssignments: 'CompactAssignmentsTo257',
DispatchInfo: 'DispatchInfoTo244', DispatchInfo: 'DispatchInfoTo244',
Multiplier: 'Fixed64', Multiplier: 'Fixed64',
@@ -101,6 +113,7 @@ const versioned: OverrideVersionedType[] = [
minmax: [1055, 1056], minmax: [1055, 1056],
types: { types: {
...sharedTypes, ...sharedTypes,
...addrAccountIdTypes,
CompactAssignments: 'CompactAssignmentsTo257', CompactAssignments: 'CompactAssignmentsTo257',
DispatchInfo: 'DispatchInfoTo244', DispatchInfo: 'DispatchInfoTo244',
Multiplier: 'Fixed64', Multiplier: 'Fixed64',
@@ -115,6 +128,7 @@ const versioned: OverrideVersionedType[] = [
minmax: [1057, 1061], minmax: [1057, 1061],
types: { types: {
...sharedTypes, ...sharedTypes,
...addrAccountIdTypes,
CompactAssignments: 'CompactAssignmentsTo257', CompactAssignments: 'CompactAssignmentsTo257',
DispatchInfo: 'DispatchInfoTo244', DispatchInfo: 'DispatchInfoTo244',
OpenTip: 'OpenTipTo225', OpenTip: 'OpenTipTo225',
@@ -126,6 +140,7 @@ const versioned: OverrideVersionedType[] = [
minmax: [1062, 2012], minmax: [1062, 2012],
types: { types: {
...sharedTypes, ...sharedTypes,
...addrAccountIdTypes,
CompactAssignments: 'CompactAssignmentsTo257', CompactAssignments: 'CompactAssignmentsTo257',
OpenTip: 'OpenTipTo225', OpenTip: 'OpenTipTo225',
RefCount: 'RefCountTo259', RefCount: 'RefCountTo259',
@@ -136,6 +151,7 @@ const versioned: OverrideVersionedType[] = [
minmax: [2013, 2022], minmax: [2013, 2022],
types: { types: {
...sharedTypes, ...sharedTypes,
...addrAccountIdTypes,
CompactAssignments: 'CompactAssignmentsTo257', CompactAssignments: 'CompactAssignmentsTo257',
RefCount: 'RefCountTo259', RefCount: 'RefCountTo259',
RewardDestination: 'RewardDestinationTo257' RewardDestination: 'RewardDestinationTo257'
@@ -145,11 +161,19 @@ const versioned: OverrideVersionedType[] = [
minmax: [2023, 2024], minmax: [2023, 2024],
types: { types: {
...sharedTypes, ...sharedTypes,
...addrAccountIdTypes,
RefCount: 'RefCountTo259' RefCount: 'RefCountTo259'
} }
}, },
{ {
minmax: [2025, undefined], minmax: [2025, 2027],
types: {
...sharedTypes,
...addrAccountIdTypes
}
},
{
minmax: [2028, undefined],
types: { types: {
...sharedTypes ...sharedTypes
} }
@@ -9,8 +9,8 @@ const versioned: OverrideVersionedType[] = [
{ {
minmax: [0, undefined], minmax: [0, undefined],
types: { types: {
Address: 'AccountId', Address: 'MultiAddress',
LookupSource: 'AccountId' LookupSource: 'MultiAddress'
} }
} }
]; ];
+3 -3
View File
@@ -8,7 +8,7 @@ import type { OverrideVersionedType } from '@polkadot/types/types';
// these are override types for Polkadot // these are override types for Polkadot
const versioned: OverrideVersionedType[] = [ const versioned: OverrideVersionedType[] = [
{ {
minmax: [0, 259], minmax: [0, 260],
types: { types: {
AccountInfo: 'AccountInfoWithRefCount', AccountInfo: 'AccountInfoWithRefCount',
Address: 'LookupSource', Address: 'LookupSource',
@@ -16,9 +16,9 @@ const versioned: OverrideVersionedType[] = [
} }
}, },
{ {
minmax: [260, undefined], minmax: [261, undefined],
types: { types: {
AccountInfo: 'AccountInfoWithRefCount', AccountInfo: 'AccountInfoWithProviders',
Address: 'MultiAddress', Address: 'MultiAddress',
LookupSource: 'MultiAddress' LookupSource: 'MultiAddress'
} }
+24 -5
View File
@@ -6,14 +6,23 @@
import type { OverrideVersionedType } from '@polkadot/types/types'; import type { OverrideVersionedType } from '@polkadot/types/types';
const sharedTypes = { const sharedTypes = {
AccountInfo: 'AccountInfoWithProviders',
Address: 'MultiAddress',
Keys: 'SessionKeys6',
LookupSource: 'MultiAddress',
ProxyType: {
// was: SudoBalances
_enum: ['Any', 'NonTransfer', 'Governance', 'Staking', 'Unused', 'IdentityJudgement']
},
ValidatorPrefs: 'ValidatorPrefsWithBlocked'
};
const addrAccountIdTypes = {
AccountInfo: 'AccountInfoWithRefCount', AccountInfo: 'AccountInfoWithRefCount',
Address: 'AccountId', Address: 'AccountId',
Keys: 'SessionKeys5', Keys: 'SessionKeys5',
LookupSource: 'AccountId', LookupSource: 'AccountId',
ProxyType: { ValidatorPrefs: 'ValidatorPrefsWithCommission'
// was: SudoBalances
_enum: ['Any', 'NonTransfer', 'Governance', 'Staking', 'Unused', 'IdentityJudgement']
}
}; };
// these are override types for Polkadot // these are override types for Polkadot
@@ -22,6 +31,7 @@ const versioned: OverrideVersionedType[] = [
minmax: [0, 12], minmax: [0, 12],
types: { types: {
...sharedTypes, ...sharedTypes,
...addrAccountIdTypes,
CompactAssignments: 'CompactAssignmentsTo257', CompactAssignments: 'CompactAssignmentsTo257',
OpenTip: 'OpenTipTo225', OpenTip: 'OpenTipTo225',
RefCount: 'RefCountTo259', RefCount: 'RefCountTo259',
@@ -32,6 +42,7 @@ const versioned: OverrideVersionedType[] = [
minmax: [13, 22], minmax: [13, 22],
types: { types: {
...sharedTypes, ...sharedTypes,
...addrAccountIdTypes,
CompactAssignments: 'CompactAssignmentsTo257', CompactAssignments: 'CompactAssignmentsTo257',
RefCount: 'RefCountTo259', RefCount: 'RefCountTo259',
RewardDestination: 'RewardDestinationTo257' RewardDestination: 'RewardDestinationTo257'
@@ -41,11 +52,19 @@ const versioned: OverrideVersionedType[] = [
minmax: [23, 24], minmax: [23, 24],
types: { types: {
...sharedTypes, ...sharedTypes,
...addrAccountIdTypes,
RefCount: 'RefCountTo259' RefCount: 'RefCountTo259'
} }
}, },
{ {
minmax: [25, undefined], minmax: [25, 27],
types: {
...sharedTypes,
...addrAccountIdTypes
}
},
{
minmax: [28, undefined],
types: { types: {
...sharedTypes ...sharedTypes
} }
+30 -11
View File
@@ -9,10 +9,11 @@ import type { OverrideVersionedType } from '@polkadot/types/types';
/* eslint-disable sort-keys */ /* eslint-disable sort-keys */
const sharedTypes = { const sharedTypes = {
AccountInfo: 'AccountInfoWithRefCount', AccountInfo: 'AccountInfoWithProviders',
Address: 'AccountId', Address: 'MultiAddress',
Keys: 'SessionKeys5', FullIdentification: '()', // No staking, only session (as per config)
LookupSource: 'AccountId' LookupSource: 'MultiAddress',
Keys: 'SessionKeys6'
}; };
const versioned: OverrideVersionedType[] = [ const versioned: OverrideVersionedType[] = [
@@ -20,20 +21,38 @@ const versioned: OverrideVersionedType[] = [
minmax: [0, 9], minmax: [0, 9],
types: { types: {
...sharedTypes, ...sharedTypes,
AccountInfo: 'AccountInfoWithRefCount',
Address: 'AccountId',
CompactAssignments: 'CompactAssignmentsTo257', CompactAssignments: 'CompactAssignmentsTo257',
LookupSource: 'AccountId',
RefCount: 'RefCountTo259', RefCount: 'RefCountTo259',
RewardDestination: 'RewardDestinationTo257' RewardDestination: 'RewardDestinationTo257',
Keys: 'SessionKeys5'
} }
}, },
{ {
minmax: [10, undefined], minmax: [10, 12],
types: { types: {
...sharedTypes, ...sharedTypes,
ParaGenesisArgs: { AccountInfo: 'AccountInfoWithRefCount',
genesisHead: 'Bytes', Address: 'AccountId',
validationCode: 'Bytes', Keys: 'SessionKeys5',
parachain: 'bool' LookupSource: 'AccountId'
} }
},
{
minmax: [13, 201],
types: {
...sharedTypes,
AccountInfo: 'AccountInfoWithRefCount',
Address: 'AccountId',
LookupSource: 'AccountId'
}
},
{
minmax: [202, undefined],
types: {
...sharedTypes
} }
} }
]; ];
+26 -6
View File
@@ -6,14 +6,23 @@
import type { OverrideVersionedType } from '@polkadot/types/types'; import type { OverrideVersionedType } from '@polkadot/types/types';
const sharedTypes = { const sharedTypes = {
AccountInfo: 'AccountInfoWithRefCount', AccountInfo: 'AccountInfoWithProviders',
Address: 'AccountId', Address: 'MultiAddress',
Keys: 'SessionKeys5', Keys: 'SessionKeys6',
LookupSource: 'AccountId', LookupSource: 'MultiAddress',
ProxyType: { ProxyType: {
// was: SudoBalances // was: SudoBalances
_enum: ['Any', 'NonTransfer', 'Staking', 'Unused', 'IdentityJudgement'] _enum: ['Any', 'NonTransfer', 'Staking', 'Unused', 'IdentityJudgement']
} },
ValidatorPrefs: 'ValidatorPrefsWithBlocked'
};
const addrAccountIdTypes = {
AccountInfo: 'AccountInfoWithRefCount',
Address: 'AccountId',
LookupSource: 'AccountId',
Keys: 'SessionKeys5',
ValidatorPrefs: 'ValidatorPrefsWithCommission'
}; };
const versioned: OverrideVersionedType[] = [ const versioned: OverrideVersionedType[] = [
@@ -21,6 +30,7 @@ const versioned: OverrideVersionedType[] = [
minmax: [1, 2], minmax: [1, 2],
types: { types: {
...sharedTypes, ...sharedTypes,
...addrAccountIdTypes,
CompactAssignments: 'CompactAssignmentsTo257', CompactAssignments: 'CompactAssignmentsTo257',
Multiplier: 'Fixed64', Multiplier: 'Fixed64',
OpenTip: 'OpenTipTo225', OpenTip: 'OpenTipTo225',
@@ -33,6 +43,7 @@ const versioned: OverrideVersionedType[] = [
minmax: [3, 22], minmax: [3, 22],
types: { types: {
...sharedTypes, ...sharedTypes,
...addrAccountIdTypes,
CompactAssignments: 'CompactAssignmentsTo257', CompactAssignments: 'CompactAssignmentsTo257',
OpenTip: 'OpenTipTo225', OpenTip: 'OpenTipTo225',
RefCount: 'RefCountTo259', RefCount: 'RefCountTo259',
@@ -43,6 +54,7 @@ const versioned: OverrideVersionedType[] = [
minmax: [23, 42], minmax: [23, 42],
types: { types: {
...sharedTypes, ...sharedTypes,
...addrAccountIdTypes,
CompactAssignments: 'CompactAssignmentsTo257', CompactAssignments: 'CompactAssignmentsTo257',
RefCount: 'RefCountTo259', RefCount: 'RefCountTo259',
RewardDestination: 'RewardDestinationTo257' RewardDestination: 'RewardDestinationTo257'
@@ -52,11 +64,19 @@ const versioned: OverrideVersionedType[] = [
minmax: [43, 44], minmax: [43, 44],
types: { types: {
...sharedTypes, ...sharedTypes,
...addrAccountIdTypes,
RefCount: 'RefCountTo259' RefCount: 'RefCountTo259'
} }
}, },
{ {
minmax: [45, undefined], minmax: [45, 47],
types: {
...sharedTypes,
...addrAccountIdTypes
}
},
{
minmax: [48, undefined],
types: { types: {
...sharedTypes ...sharedTypes
} }
@@ -1,10 +1,62 @@
// Copyright 2017-2021 @polkadot/types-known authors & contributors // Copyright 2017-2021 @polkadot/types-known authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import { assert, u8aEq } from '@polkadot/util';
import all from '.'; import all from '.';
interface TestDef {
genesisHash: string;
network: string;
versions: [number, [number, number]][];
}
const TESTS: TestDef[] = [
{
genesisHash: '0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe',
network: 'kusama',
versions: [
[0, [0, 1020]],
[17, [901442, 1045]]
]
},
{
genesisHash: '0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3',
network: 'polkadot',
versions: [
[0, [0, 0]],
[19, [2436698, 26]]
]
},
{
genesisHash: '0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e',
network: 'westend',
versions: [
[0, [214356, 4]],
[23, [4207800, 48]]
]
}
];
describe('upgrades', (): void => { describe('upgrades', (): void => {
it('is valid', (): void => { TESTS.forEach(({ genesisHash, network, versions }): void => {
expect(all).toBeDefined(); describe(network, (): void => {
const chain = all.find((n) => n.network === network);
assert(chain, `Unable to find the entry for ${network}`);
it('has a valid genesisHash', (): void => {
expect(u8aEq(chain.genesisHash, genesisHash)).toBe(true);
});
versions.forEach(([index, [blockNumber, specVersion]]): void => {
it(`has a valid entry at index ${index}`, (): void => {
const version = chain.versions[index];
expect(version.blockNumber.eqn(blockNumber)).toBe(true);
expect(version.specVersion.eqn(specVersion)).toBe(true);
});
});
});
}); });
}); });
+16 -8
View File
@@ -6,14 +6,22 @@ import type { ChainUpgradesRaw } from './types';
import BN from 'bn.js'; import BN from 'bn.js';
import networks from '@polkadot/networks';
import { assert, hexToU8a } from '@polkadot/util'; import { assert, hexToU8a } from '@polkadot/util';
import kusama from './kusama'; import kusama from './kusama';
import polkadot from './polkadot'; import polkadot from './polkadot';
import westend from './westend'; import westend from './westend';
// testnets are not available in the networks map
const NET_EXTRA: Record<string, { genesisHash: string[] }> = {
westend: {
genesisHash: ['0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e']
}
};
/** @internal */ /** @internal */
function checkOrder (network: string, versions: [number, number][]): [number, number][] { function checkOrder (network: string, versions: ChainUpgradesRaw): [number, number][] {
const ooo = versions.filter((curr, index): boolean => { const ooo = versions.filter((curr, index): boolean => {
const prev = versions[index - 1]; const prev = versions[index - 1];
@@ -28,9 +36,13 @@ function checkOrder (network: string, versions: [number, number][]): [number, nu
} }
/** @internal */ /** @internal */
function rawToFinal (network: string, { genesisHash, versions }: ChainUpgradesRaw): ChainUpgrades { function mapRaw ([network, versions]: [string, ChainUpgradesRaw]): ChainUpgrades {
const chain = networks.find((n) => n.network === network) || NET_EXTRA[network];
assert(chain, `Unable to find info for chain ${network}`);
return { return {
genesisHash: hexToU8a(genesisHash), genesisHash: hexToU8a(chain.genesisHash[0]),
network, network,
versions: checkOrder(network, versions).map(([blockNumber, specVersion]) => ({ versions: checkOrder(network, versions).map(([blockNumber, specVersion]) => ({
blockNumber: new BN(blockNumber), blockNumber: new BN(blockNumber),
@@ -40,10 +52,6 @@ function rawToFinal (network: string, { genesisHash, versions }: ChainUpgradesRa
} }
// Type overrides for specific spec types & versions as given in runtimeVersion // Type overrides for specific spec types & versions as given in runtimeVersion
const upgrades: ChainUpgrades[] = [ const upgrades = Object.entries({ kusama, polkadot, westend }).map(mapRaw);
rawToFinal('kusama', kusama),
rawToFinal('polkadot', polkadot),
rawToFinal('westend', westend)
];
export default upgrades; export default upgrades;
+10 -13
View File
@@ -3,18 +3,15 @@
import type { ChainUpgradesRaw } from './types'; import type { ChainUpgradesRaw } from './types';
const upgrades: ChainUpgradesRaw = { const upgrades: ChainUpgradesRaw = [
genesisHash: '0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe', [0, 1020], [26669, 1021], [38245, 1022], [54248, 1023], [59659, 1024],
versions: [ [67651, 1025], [82191, 1027], [83238, 1028], [101503, 1029], [203466, 1030],
[0, 1020], [26669, 1021], [38245, 1022], [54248, 1023], [59659, 1024], [295787, 1031], [461692, 1032], [504329, 1033], [569327, 1038], [587687, 1039],
[67651, 1025], [82191, 1027], [83238, 1028], [101503, 1029], [203466, 1030], [653183, 1040], [693488, 1042], [901442, 1045], [1375086, 1050], [1445458, 1051],
[295787, 1031], [461692, 1032], [504329, 1033], [569327, 1038], [587687, 1039], [1472960, 1052], [1475648, 1053], [1491596, 1054], [1574408, 1055], [2064961, 1058],
[653183, 1040], [693488, 1042], [901442, 1045], [1375086, 1050], [1445458, 1051], [2201991, 1062], [2671528, 2005], [2704202, 2007], [2728002, 2008], [2832534, 2011],
[1472960, 1052], [1475648, 1053], [1491596, 1054], [1574408, 1055], [2064961, 1058], [2962294, 2012], [3240000, 2013], [3274408, 2015], [3323565, 2019], [3534175, 2022],
[2201991, 1062], [2671528, 2005], [2704202, 2007], [2728002, 2008], [2832534, 2011], [3860281, 2023], [4143129, 2024], [4401242, 2025], [4841367, 2026], [5961600, 2027]
[2962294, 2012], [3240000, 2013], [3274408, 2015], [3323565, 2019], [3534175, 2022], ];
[3860281, 2023], [4143129, 2024], [4401242, 2025], [4841367, 2026]
]
};
export default upgrades; export default upgrades;
@@ -3,14 +3,12 @@
import type { ChainUpgradesRaw } from './types'; import type { ChainUpgradesRaw } from './types';
const upgrades: ChainUpgradesRaw = { const upgrades: ChainUpgradesRaw = [
genesisHash: '0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3', [0, 0], [29231, 1], [188836, 5], [199405, 6], [214264, 7],
versions: [ [244358, 8], [303079, 9], [314201, 10], [342400, 11], [443963, 12],
[0, 0], [29231, 1], [188836, 5], [199405, 6], [214264, 7], [528470, 13], [687751, 14], [746085, 15], [787923, 16], [799302, 17],
[244358, 8], [303079, 9], [314201, 10], [342400, 11], [443963, 12], [1205128, 18], [1603423, 23], [1733218, 24], [2005673, 25], [2436698, 26],
[528470, 13], [687751, 14], [746085, 15], [787923, 16], [799302, 17], [3613564, 27]
[1205128, 18], [1603423, 23], [1733218, 24], [2005673, 25] ];
]
};
export default upgrades; export default upgrades;
+1 -4
View File
@@ -1,7 +1,4 @@
// Copyright 2017-2021 @polkadot/types-known authors & contributors // Copyright 2017-2021 @polkadot/types-known authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
export interface ChainUpgradesRaw { export type ChainUpgradesRaw = [number, number][];
genesisHash: string;
versions: [number, number][];
}
+7 -10
View File
@@ -3,15 +3,12 @@
import type { ChainUpgradesRaw } from './types'; import type { ChainUpgradesRaw } from './types';
const upgrades: ChainUpgradesRaw = { const upgrades: ChainUpgradesRaw = [
genesisHash: '0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e', [214356, 4], [392764, 7], [409740, 8], [809976, 20], [877581, 24],
versions: [ [879238, 25], [889472, 26], [902937, 27], [932751, 28], [991142, 29],
[214356, 4], [392764, 7], [409740, 8], [809976, 20], [877581, 24], [1030162, 31], [1119657, 32], [1199282, 33], [1342534, 34], [1392263, 35],
[879238, 25], [889472, 26], [902937, 27], [932751, 28], [991142, 29], [1431703, 36], [1433369, 37], [1490972, 41], [2087397, 43], [2316688, 44],
[1030162, 31], [1119657, 32], [1199282, 33], [1342534, 34], [1392263, 35], [2549864, 45], [3925782, 46], [3925843, 47], [4207800, 48]
[1431703, 36], [1433369, 37], [1490972, 41], [2087397, 43], [2316688, 44], ];
[2549864, 45]
]
};
export default upgrades; export default upgrades;
+6 -7
View File
@@ -1,9 +1,8 @@
{ {
"name": "@polkadot/types", "name": "@polkadot/types",
"version": "3.3.1", "version": "3.7.3",
"description": "Implementation of the Parity codec", "description": "Implementation of the Parity codec",
"main": "index.js", "main": "index.js",
"module": "index.mjs",
"sideEffects": [ "sideEffects": [
"./detectPackage.js", "./detectPackage.js",
"./detectPackage.mjs" "./detectPackage.mjs"
@@ -17,14 +16,14 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme", "homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@polkadot/metadata": "3.3.1", "@polkadot/metadata": "3.7.3",
"@polkadot/util": "^5.2.3", "@polkadot/util": "^5.5.2",
"@polkadot/util-crypto": "^5.2.3", "@polkadot/util-crypto": "^5.5.2",
"@polkadot/x-rxjs": "3.3.1", "@polkadot/x-rxjs": "^5.5.2",
"@types/bn.js": "^4.11.6", "@types/bn.js": "^4.11.6",
"bn.js": "^4.11.9" "bn.js": "^4.11.9"
}, },
"devDependencies": { "devDependencies": {
"@polkadot/keyring": "^5.2.3" "@polkadot/keyring": "^5.5.2"
} }
} }
File diff suppressed because it is too large Load Diff
@@ -159,4 +159,11 @@ export abstract class AbstractArray<T extends Codec> extends Array<T> implements
public includes (check: unknown): boolean { public includes (check: unknown): boolean {
return this.some((value: T) => value.eq(check)); return this.some((value: T) => value.eq(check));
} }
/**
* @description Returns a slice of an array
*/
public slice (start?: number, end?: number): T[] {
return this.toArray().slice(start, end);
}
} }
+13 -8
View File
@@ -7,7 +7,7 @@ import type { UIntBitLength } from './types';
import BN from 'bn.js'; import BN from 'bn.js';
import { assert, BN_ZERO, bnToBn, bnToHex, bnToU8a, formatBalance, formatNumber, hexToBn, isHex, isString, isU8a, u8aToBn } from '@polkadot/util'; import { assert, BN_BILLION, BN_HUNDRED, BN_MILLION, BN_ZERO, bnToBn, bnToHex, bnToU8a, formatBalance, formatNumber, hexToBn, isHex, isString, isU8a, u8aToBn } from '@polkadot/util';
export const DEFAULT_UINT_BITS = 64; export const DEFAULT_UINT_BITS = 64;
@@ -18,9 +18,9 @@ const MUL_P = new BN(1_00_00);
const FORMATTERS: [string, BN][] = [ const FORMATTERS: [string, BN][] = [
['Perquintill', new BN(1_000_000_000_000)], ['Perquintill', new BN(1_000_000_000_000)],
['Perbill', new BN(1_000_000_000)], ['Perbill', BN_BILLION],
['Permill', new BN(1_000_000)], ['Permill', BN_MILLION],
['Percent', new BN(100)] ['Percent', BN_HUNDRED]
]; ];
function toPercentage (value: BN, divisor: BN): string { function toPercentage (value: BN, divisor: BN): string {
@@ -78,8 +78,11 @@ export abstract class AbstractInt extends BN implements Codec {
this.#bitLength = bitLength; this.#bitLength = bitLength;
this.#isSigned = isSigned; this.#isSigned = isSigned;
assert(isSigned || this.gte(BN_ZERO), `${this.toRawType()}: Negative number passed to unsigned type`); const isPositive = this.gte(BN_ZERO);
assert(super.bitLength() <= bitLength, `${this.toRawType()}: Input too large. Found input with ${super.bitLength()} bits, expected ${bitLength}`); const maxBits = bitLength - (isSigned && isPositive ? 1 : 0);
assert(isSigned || isPositive, `${this.toRawType()}: Negative number passed to unsigned type`);
assert(super.bitLength() <= maxBits, `${this.toRawType()}: Input too large. Found input with ${super.bitLength()} bits, expected ${maxBits}`);
} }
/** /**
@@ -143,7 +146,7 @@ export abstract class AbstractInt extends BN implements Codec {
/** /**
* @description Returns a BigInt representation of the number * @description Returns a BigInt representation of the number
*/ */
public toBigInt (): BigInt { public toBigInt (): bigint {
return BigInt(this.toString()); return BigInt(this.toString());
} }
@@ -176,7 +179,9 @@ export abstract class AbstractInt extends BN implements Codec {
if (rawType === 'Balance') { if (rawType === 'Balance') {
return this.isMax() return this.isMax()
? 'everything' ? 'everything'
: formatBalance(this, { decimals: this.registry.chainDecimals, withSi: true, withUnit: this.registry.chainToken }); // FIXME In the case of multiples we need some way of detecting which instance this belongs
// to. as it stands we will always format (incorrectly) against the first token defined
: formatBalance(this, { decimals: this.registry.chainDecimals[0], withSi: true, withUnit: this.registry.chainTokens[0] });
} }
const [, divisor] = FORMATTERS.find(([type]) => type === rawType) || []; const [, divisor] = FORMATTERS.find(([type]) => type === rawType) || [];
+2 -4
View File
@@ -4,7 +4,7 @@
import type { H256 } from '../interfaces/runtime'; import type { H256 } from '../interfaces/runtime';
import type { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types'; import type { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types';
import { compactFromU8a, compactToU8a, hexToU8a, isHex, isU8a, logger, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util'; import { compactFromU8a, compactToU8a, isHex, isU8a, logger, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';
import { compareSet, decodeU8a, typeToConstructor } from './utils'; import { compareSet, decodeU8a, typeToConstructor } from './utils';
@@ -67,9 +67,7 @@ function decodeSet<V extends Codec = Codec> (registry: Registry, valType: Constr
const ValClass = typeToConstructor(registry, valType); const ValClass = typeToConstructor(registry, valType);
if (isHex(value)) { if (isHex(value) || isU8a(value)) {
return decodeSet(registry, ValClass, hexToU8a(value));
} else if (isU8a(value)) {
return decodeSetFromU8a<V>(registry, ValClass, u8aToU8a(value)); return decodeSetFromU8a<V>(registry, ValClass, u8aToU8a(value));
} else if (Array.isArray(value) || value instanceof Set) { } else if (Array.isArray(value) || value instanceof Set) {
return decodeSetFromSet<V>(registry, ValClass, value); return decodeSetFromSet<V>(registry, ValClass, value);
+3 -1
View File
@@ -73,7 +73,9 @@ describe('Compact', (): void => {
}); });
it('has a valid toBigInt interface', (): void => { it('has a valid toBigInt interface', (): void => {
expect(new (Compact.with('u128'))(registry, 12345678987654321n).toBigInt() === 12345678987654321n).toBe(true); expect(
(new (Compact.with('u128'))(registry, 12345678987654321n).toBigInt() + 1n) === 12345678987654322n
).toBe(true);
}); });
}); });
}); });
+1 -1
View File
@@ -95,7 +95,7 @@ export class Compact<T extends CompactEncodable> implements ICompact<T> {
/** /**
* @description Returns a BigInt representation of the number * @description Returns a BigInt representation of the number
*/ */
public toBigInt (): BigInt { public toBigInt (): bigint {
return BigInt(this.toString()); return BigInt(this.toString());
} }
+6
View File
@@ -59,6 +59,12 @@ describe('Date', (): void => {
new CodecDate(registry, 3).toHex(true) new CodecDate(registry, 3).toHex(true)
).toEqual('0x0300000000000000'); ).toEqual('0x0300000000000000');
}); });
it('encodes correctly to BigInt', (): void => {
expect(
new CodecDate(registry, 41).toBigInt() + 1n
).toEqual(42n);
});
}); });
describe('utils', (): void => { describe('utils', (): void => {
+1 -1
View File
@@ -83,7 +83,7 @@ export class CodecDate extends Date implements Codec {
/** /**
* @description Returns a BigInt representation of the number * @description Returns a BigInt representation of the number
*/ */
public toBigInt (): BigInt { public toBigInt (): bigint {
return BigInt(this.toNumber()); return BigInt(this.toNumber());
} }
+1 -1
View File
@@ -389,7 +389,7 @@ describe('Enum', (): void => {
expect(test.toHex()).toEqual( expect(test.toHex()).toEqual(
'0x' + '0x' +
'00' + // index '00' + // index
'ff' + // Address indicating an embedded AccountId '00' + // MultiAddress indicating an embedded AccountId
'0001020304050607080910111213141516171819202122232425262728293031' // AccountId '0001020304050607080910111213141516171819202122232425262728293031' // AccountId
); );
}); });
+8 -2
View File
@@ -4,7 +4,7 @@
import type { H256 } from '../interfaces/runtime'; import type { H256 } from '../interfaces/runtime';
import type { AnyJson, Codec, Registry } from '../types'; import type { AnyJson, Codec, Registry } from '../types';
import { isUndefined } from '@polkadot/util'; import { isFunction, isUndefined } from '@polkadot/util';
import { compareMap } from './utils'; import { compareMap } from './utils';
@@ -79,7 +79,13 @@ export class Json extends Map<string, any> implements Codec {
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
*/ */
public toHuman (): Record<string, AnyJson> { public toHuman (): Record<string, AnyJson> {
return this.toJSON(); return [...this.entries()].reduce((json: Record<string, AnyJson>, [key, value]): Record<string, AnyJson> => {
json[key] = isFunction((value as Codec).toHuman)
? (value as Codec).toHuman()
: value as AnyJson;
return json;
}, {});
} }
/** /**
+2 -4
View File
@@ -4,7 +4,7 @@
import type { H256 } from '../interfaces/runtime'; import type { H256 } from '../interfaces/runtime';
import type { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types'; import type { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types';
import { compactFromU8a, compactToU8a, hexToU8a, isHex, isObject, isU8a, logger, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util'; import { compactFromU8a, compactToU8a, isHex, isObject, isU8a, logger, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';
import { compareMap, decodeU8a, typeToConstructor } from './utils'; import { compareMap, decodeU8a, typeToConstructor } from './utils';
@@ -74,9 +74,7 @@ function decodeMap<K extends Codec = Codec, V extends Codec = Codec> (registry:
if (!value) { if (!value) {
return new Map<K, V>(); return new Map<K, V>();
} else if (isHex(value)) { } else if (isU8a(value) || isHex(value)) {
return decodeMap(registry, KeyClass, ValClass, hexToU8a(value));
} else if (isU8a(value)) {
return decodeMapFromU8a<K, V>(registry, KeyClass, ValClass, u8aToU8a(value)); return decodeMapFromU8a<K, V>(registry, KeyClass, ValClass, u8aToU8a(value));
} else if (value instanceof Map) { } else if (value instanceof Map) {
return decodeMapFromMap<K, V>(registry, KeyClass, ValClass, value); return decodeMapFromMap<K, V>(registry, KeyClass, ValClass, value);
+3 -12
View File
@@ -4,16 +4,7 @@
import type { H256 } from '../interfaces/runtime'; import type { H256 } from '../interfaces/runtime';
import type { AnyJson, AnyU8a, IU8a, Registry } from '../types'; import type { AnyJson, AnyU8a, IU8a, Registry } from '../types';
import { assert, isAscii, isU8a, isUndefined, isUtf8, u8aToHex, u8aToString, u8aToU8a } from '@polkadot/util'; import { assert, isAscii, isUndefined, isUtf8, u8aToHex, u8aToString, u8aToU8a } from '@polkadot/util';
/** @internal */
function decodeU8a (value?: any): Uint8Array {
if (isU8a(value)) {
return value;
}
return u8aToU8a(value);
}
/** /**
* @name Raw * @name Raw
@@ -28,7 +19,7 @@ export class Raw extends Uint8Array implements IU8a {
public readonly registry: Registry; public readonly registry: Registry;
constructor (registry: Registry, value?: AnyU8a) { constructor (registry: Registry, value?: AnyU8a) {
super(decodeU8a(value)); super(u8aToU8a(value));
this.registry = registry; this.registry = registry;
} }
@@ -92,7 +83,7 @@ export class Raw extends Uint8Array implements IU8a {
!this.some((value, index) => value !== other[index]); !this.some((value, index) => value !== other[index]);
} }
return this.eq(decodeU8a(other)); return this.eq(u8aToU8a(other as any));
} }
/** /**
+3 -5
View File
@@ -3,7 +3,7 @@
import type { AnyNumber, AnyString, AnyU8a, Codec, Constructor, InterfaceTypes, Registry } from '../types'; import type { AnyNumber, AnyString, AnyU8a, Codec, Constructor, InterfaceTypes, Registry } from '../types';
import { hexToU8a, isHex, isU8a, u8aConcat } from '@polkadot/util'; import { isHex, isU8a, u8aConcat, u8aToU8a } from '@polkadot/util';
import { AbstractArray } from './AbstractArray'; import { AbstractArray } from './AbstractArray';
import { decodeU8a, mapToTypeMap, typeToConstructor } from './utils'; import { decodeU8a, mapToTypeMap, typeToConstructor } from './utils';
@@ -20,10 +20,8 @@ type TupleTypes = (Constructor | keyof InterfaceTypes)[] | {
/** @internal */ /** @internal */
function decodeTuple (registry: Registry, _Types: TupleConstructors, value?: AnyTuple): Codec[] { function decodeTuple (registry: Registry, _Types: TupleConstructors, value?: AnyTuple): Codec[] {
if (isU8a(value)) { if (isU8a(value) || isHex(value)) {
return decodeU8a(registry, value, _Types); return decodeU8a(registry, u8aToU8a(value), _Types);
} else if (isHex(value)) {
return decodeTuple(registry, _Types, hexToU8a(value));
} }
const Types: Constructor[] = Array.isArray(_Types) const Types: Constructor[] = Array.isArray(_Types)
+6
View File
@@ -45,6 +45,12 @@ describe('UInt', (): void => {
).toEqual(4567); ).toEqual(4567);
}); });
it('has a working toBigInt', (): void => {
expect(
new UInt(registry, 4567).toBigInt() + BigInt(1)
).toEqual(BigInt(4568));
});
it('converts to Little Endian from the provided value', (): void => { it('converts to Little Endian from the provided value', (): void => {
expect( expect(
new UInt(registry, 1234567).toU8a() new UInt(registry, 1234567).toU8a()
+10
View File
@@ -6,6 +6,7 @@ import type { Codec, CodecTo } from '../types';
import { Metadata } from '@polkadot/metadata'; import { Metadata } from '@polkadot/metadata';
import rpcMetadata from '@polkadot/metadata/static'; import rpcMetadata from '@polkadot/metadata/static';
import { randomAsU8a } from '@polkadot/util-crypto';
import { createTypeUnsafe, TypeRegistry } from '../create'; import { createTypeUnsafe, TypeRegistry } from '../create';
import { GenericAccountId as AccountId } from '../generic'; import { GenericAccountId as AccountId } from '../generic';
@@ -170,5 +171,14 @@ describe('Vec', (): void => {
expect(vec.indexOf(myId)).toEqual(2); expect(vec.indexOf(myId)).toEqual(2);
}); });
it('allows a slice operator', (): void => {
const vec = registry.createType('Vec<AccountId>', [
randomAsU8a(), randomAsU8a(), randomAsU8a(), randomAsU8a(), randomAsU8a(), randomAsU8a(), randomAsU8a(), randomAsU8a(), randomAsU8a(), randomAsU8a()
]);
expect(vec).toHaveLength(10);
expect(vec.slice(2, 7)).toHaveLength(5);
});
}); });
}); });
+8 -8
View File
@@ -3,8 +3,6 @@
import type { Codec, Constructor, Registry } from '../../types'; import type { Codec, Constructor, Registry } from '../../types';
import { arrayFlatten } from '@polkadot/util';
/** /**
* Given an u8a, and an array of Type constructors, decode the u8a against the * Given an u8a, and an array of Type constructors, decode the u8a against the
* types, and return an array of decoded values. * types, and return an array of decoded values.
@@ -16,13 +14,15 @@ export function decodeU8a (registry: Registry, u8a: Uint8Array, _types: Construc
const types = Array.isArray(_types) const types = Array.isArray(_types)
? _types ? _types
: Object.values(_types); : Object.values(_types);
const result: Codec[] = [];
let offset = 0;
if (!types.length) { for (let i = 0; i < types.length; i++) {
return []; const value = new types[i](registry, u8a.subarray(offset));
result.push(value);
offset += value.encodedLength;
} }
const Type = types[0]; return result;
const value = new Type(registry, u8a);
return arrayFlatten([[value], decodeU8a(registry, u8a.subarray(value.encodedLength), types.slice(1))]);
} }
+45 -21
View File
@@ -3,6 +3,7 @@
/* eslint-disable @typescript-eslint/no-var-requires */ /* eslint-disable @typescript-eslint/no-var-requires */
import type { ExtDef } from '../extrinsic/signedExtensions/types';
import type { ChainProperties, DispatchErrorModule, H256 } from '../interfaces/types'; import type { ChainProperties, DispatchErrorModule, H256 } from '../interfaces/types';
import type { CallFunction, Codec, Constructor, InterfaceTypes, RegisteredTypes, Registry, RegistryError, RegistryTypes } from '../types'; import type { CallFunction, Codec, Constructor, InterfaceTypes, RegisteredTypes, Registry, RegistryError, RegistryTypes } from '../types';
@@ -38,8 +39,9 @@ function injectErrors (_: Registry, metadata: Metadata, metadataErrors: Record<s
const eventIndex = new Uint8Array([sectionIndex, index]); const eventIndex = new Uint8Array([sectionIndex, index]);
metadataErrors[u8aToHex(eventIndex)] = { metadataErrors[u8aToHex(eventIndex)] = {
documentation: documentation.map((d): string => d.toString()), documentation: documentation.map((d) => d.toString()),
index, index,
method: name.toString(),
name: name.toString(), name: name.toString(),
section: sectionName section: sectionName
}; };
@@ -102,10 +104,9 @@ function extractProperties (registry: Registry, metadata: Metadata): ChainProper
return original; return original;
} }
return registry.createType('ChainProperties', { const { tokenDecimals, tokenSymbol } = original || {};
...(original || {}),
ss58Format return registry.createType('ChainProperties', { ss58Format, tokenDecimals, tokenSymbol });
});
} }
export class TypeRegistry implements Registry { export class TypeRegistry implements Registry {
@@ -133,6 +134,8 @@ export class TypeRegistry implements Registry {
#signedExtensions: string[] = defaultExtensions; #signedExtensions: string[] = defaultExtensions;
#userExtensions?: Record<string, ExtDef>;
constructor () { constructor () {
this.#knownDefaults = { Json, Metadata, Raw, ...baseTypes }; this.#knownDefaults = { Json, Metadata, Raw, ...baseTypes };
this.#knownDefinitions = definitions as unknown as Record<string, { types: RegistryTypes }>; this.#knownDefinitions = definitions as unknown as Record<string, { types: RegistryTypes }>;
@@ -156,10 +159,16 @@ export class TypeRegistry implements Registry {
return this; return this;
} }
public get chainDecimals (): number { public get chainDecimals (): number[] {
return this.#chainProperties?.tokenDecimals.isSome if (this.#chainProperties?.tokenDecimals.isSome) {
? this.#chainProperties.tokenDecimals.unwrap().toNumber() const allDecimals = this.#chainProperties.tokenDecimals.unwrap();
: 12;
if (allDecimals.length) {
return allDecimals.map((b) => b.toNumber());
}
}
return [12];
} }
public get chainSS58 (): number | undefined { public get chainSS58 (): number | undefined {
@@ -168,10 +177,16 @@ export class TypeRegistry implements Registry {
: undefined; : undefined;
} }
public get chainToken (): string { public get chainTokens (): string[] {
return this.#chainProperties?.tokenSymbol.isSome if (this.#chainProperties?.tokenSymbol.isSome) {
? this.#chainProperties.tokenSymbol.unwrap().toString() const allTokens = this.#chainProperties.tokenSymbol.unwrap();
: formatBalance.getDefaults().unit;
if (allTokens.length) {
return allTokens.map((s) => s.toString());
}
}
return [formatBalance.getDefaults().unit];
} }
public get knownTypes (): RegisteredTypes { public get knownTypes (): RegisteredTypes {
@@ -264,8 +279,12 @@ export class TypeRegistry implements Registry {
: undefined; : undefined;
} }
public getDefinition (name: string): string | undefined { public getDefinition (typeName: string): string | undefined {
return this.#definitions.get(name); return this.#definitions.get(typeName);
}
public getModuleInstances (specName: string, moduleName: string): string[] | undefined {
return this.#knownTypes?.typesBundle?.spec?.[specName]?.instances?.[moduleName];
} }
public getOrThrow <T extends Codec = Codec> (name: string, msg?: string): Constructor<T> { public getOrThrow <T extends Codec = Codec> (name: string, msg?: string): Constructor<T> {
@@ -277,11 +296,11 @@ export class TypeRegistry implements Registry {
} }
public getSignedExtensionExtra (): Record<string, keyof InterfaceTypes> { public getSignedExtensionExtra (): Record<string, keyof InterfaceTypes> {
return expandExtensionTypes(this.#signedExtensions, 'extra'); return expandExtensionTypes(this.#signedExtensions, 'payload', this.#userExtensions);
} }
public getSignedExtensionTypes (): Record<string, keyof InterfaceTypes> { public getSignedExtensionTypes (): Record<string, keyof InterfaceTypes> {
return expandExtensionTypes(this.#signedExtensions, 'types'); return expandExtensionTypes(this.#signedExtensions, 'extrinsic', this.#userExtensions);
} }
public hasClass (name: string): boolean { public hasClass (name: string): boolean {
@@ -312,6 +331,7 @@ export class TypeRegistry implements Registry {
this.#classes.set(arg1.name, arg1); this.#classes.set(arg1.name, arg1);
} else if (isString(arg1)) { } else if (isString(arg1)) {
assert(isFunction(arg2), `Expected class definition passed to '${arg1}' registration`); assert(isFunction(arg2), `Expected class definition passed to '${arg1}' registration`);
assert(arg1 !== arg2.toString(), `Unable to register circular ${arg1} === ${arg1}`);
this.#classes.set(arg1, arg2); this.#classes.set(arg1, arg2);
} else { } else {
@@ -329,6 +349,8 @@ export class TypeRegistry implements Registry {
? type ? type
: JSON.stringify(type); : JSON.stringify(type);
assert(name !== def, `Unable to register circular ${name} === ${def}`);
// we already have this type, remove the classes registered for it // we already have this type, remove the classes registered for it
if (this.#classes.has(name)) { if (this.#classes.has(name)) {
this.#classes.delete(name); this.#classes.delete(name);
@@ -355,7 +377,7 @@ export class TypeRegistry implements Registry {
} }
// sets the metadata // sets the metadata
public setMetadata (metadata: Metadata, signedExtensions?: string[]): void { public setMetadata (metadata: Metadata, signedExtensions?: string[], userExtensions?: Record<string, ExtDef>): void {
injectExtrinsics(this, metadata, this.#metadataCalls); injectExtrinsics(this, metadata, this.#metadataCalls);
injectErrors(this, metadata, this.#metadataErrors); injectErrors(this, metadata, this.#metadataErrors);
injectEvents(this, metadata, this.#metadataEvents); injectEvents(this, metadata, this.#metadataEvents);
@@ -366,7 +388,8 @@ export class TypeRegistry implements Registry {
metadata.asLatest.extrinsic.version.gt(BN_ZERO) metadata.asLatest.extrinsic.version.gt(BN_ZERO)
? metadata.asLatest.extrinsic.signedExtensions.map((key) => key.toString()) ? metadata.asLatest.extrinsic.signedExtensions.map((key) => key.toString())
: defaultExtensions : defaultExtensions
) ),
userExtensions
); );
// setup the chain properties with format overrides // setup the chain properties with format overrides
@@ -376,10 +399,11 @@ export class TypeRegistry implements Registry {
} }
// sets the available signed extensions // sets the available signed extensions
setSignedExtensions (signedExtensions: string[] = defaultExtensions): void { setSignedExtensions (signedExtensions: string[] = defaultExtensions, userExtensions?: Record<string, ExtDef>): void {
this.#signedExtensions = signedExtensions; this.#signedExtensions = signedExtensions;
this.#userExtensions = userExtensions;
const unknown = findUnknownExtensions(this.#signedExtensions); const unknown = findUnknownExtensions(this.#signedExtensions, this.#userExtensions);
if (unknown.length) { if (unknown.length) {
l.warn(`Unknown signed extensions ${unknown.join(', ')} found, treating them as no-effect`); l.warn(`Unknown signed extensions ${unknown.join(', ')} found, treating them as no-effect`);
@@ -20,7 +20,7 @@ describe('Extrinsic', (): void => {
'0x' + '0x' +
'5d02' + // length '5d02' + // length
'84' + // V4, signing bit set '84' + // V4, signing bit set
'ff' + // lookup, AccountId of sender follows '00' + // MultiAddress, AccountId of sender follows
'fcc4910cb536b4333db4bccb40e2cf6427b4766518e754b91e70c97e4a87dbb3' + // sender 'fcc4910cb536b4333db4bccb40e2cf6427b4766518e754b91e70c97e4a87dbb3' + // sender
'00' + // multisig, type ed25519 '00' + // multisig, type ed25519
'd99ffe3e610ad234e1414bda5831395a6df9098bf80b01561ce89a5065ae89d5' + // sig first 32 'd99ffe3e610ad234e1414bda5831395a6df9098bf80b01561ce89a5065ae89d5' + // sig first 32
@@ -29,7 +29,7 @@ describe('Extrinsic', (): void => {
'1101' + // nonce, compact 68 '1101' + // nonce, compact 68
'0700ac23fc06' + // tip, 0.03 KSM '0700ac23fc06' + // tip, 0.03 KSM
'0600' + // balances.transfer (on Kusama this was 0400, changed here to match metadata) '0600' + // balances.transfer (on Kusama this was 0400, changed here to match metadata)
'ff' + // lookup, AccountId of recipient follows '00' + // MultiAddress, AccountId of recipient follows
'495e1e506f266418af07fa0c5c108dd436f2faa59fe7d9e54403779f5bbd7718' + // recipient '495e1e506f266418af07fa0c5c108dd436f2faa59fe7d9e54403779f5bbd7718' + // recipient
'0bc01eb1fc185f' // value, 104.560 KSM '0bc01eb1fc185f' // value, 104.560 KSM
); );
@@ -38,7 +38,7 @@ describe('Extrinsic', (): void => {
expect(extrinsic.nonce.toNumber()).toEqual(68); expect(extrinsic.nonce.toNumber()).toEqual(68);
expect(extrinsic.tip.toHuman()).toEqual('30.0000 mUnit'); expect(extrinsic.tip.toHuman()).toEqual('30.0000 mUnit');
expect(extrinsic.callIndex).toEqual(new Uint8Array([6, 0])); expect(extrinsic.callIndex).toEqual(new Uint8Array([6, 0]));
expect(extrinsic.args[0].toHex()).toEqual('0xff495e1e506f266418af07fa0c5c108dd436f2faa59fe7d9e54403779f5bbd7718'); expect(extrinsic.args[0].toHex()).toEqual('0x00495e1e506f266418af07fa0c5c108dd436f2faa59fe7d9e54403779f5bbd7718');
expect(extrinsic.args[1].toHuman()).toEqual('104.5609 Unit'); expect(extrinsic.args[1].toHuman()).toEqual('104.5609 Unit');
}); });
}); });
@@ -19,7 +19,7 @@ describe('SignerPayload', (): void => {
blockNumber: '0x00231d30', blockNumber: '0x00231d30',
era: '0x0703', era: '0x0703',
genesisHash: '0xdcd1346701ca8396496e52aa2785b1748deb6db09551b72159dcb3e08991025b', genesisHash: '0xdcd1346701ca8396496e52aa2785b1748deb6db09551b72159dcb3e08991025b',
method: '0x0600ffd7568e5f0a7eda67a82691ff379ac4bba4f9c9b859fe779b5d46363b61ad2db9e56c', method: '0x060000d7568e5f0a7eda67a82691ff379ac4bba4f9c9b859fe779b5d46363b61ad2db9e56c',
nonce: '0x00001234', nonce: '0x00001234',
signedExtensions: ['CheckNonce', 'CheckWeight'], signedExtensions: ['CheckNonce', 'CheckWeight'],
specVersion: '0x00000006', specVersion: '0x00000006',
@@ -36,7 +36,7 @@ describe('SignerPayload', (): void => {
blockNumber: '0x231d30', blockNumber: '0x231d30',
era: registry.createType('ExtrinsicEra', { current: 2301232, period: 200 }), era: registry.createType('ExtrinsicEra', { current: 2301232, period: 200 }),
genesisHash: '0xdcd1346701ca8396496e52aa2785b1748deb6db09551b72159dcb3e08991025b', genesisHash: '0xdcd1346701ca8396496e52aa2785b1748deb6db09551b72159dcb3e08991025b',
method: registry.createType('Call', '0x0600ffd7568e5f0a7eda67a82691ff379ac4bba4f9c9b859fe779b5d46363b61ad2db9e56c'), method: registry.createType('Call', '0x060000d7568e5f0a7eda67a82691ff379ac4bba4f9c9b859fe779b5d46363b61ad2db9e56c'),
nonce: 0x1234, nonce: 0x1234,
signedExtensions: ['CheckNonce'], signedExtensions: ['CheckNonce'],
tip: 0x5678, tip: 0x5678,
@@ -48,7 +48,7 @@ describe('SignerPayload', (): void => {
blockNumber: '0x00231d30', blockNumber: '0x00231d30',
era: '0x0703', era: '0x0703',
genesisHash: '0xdcd1346701ca8396496e52aa2785b1748deb6db09551b72159dcb3e08991025b', genesisHash: '0xdcd1346701ca8396496e52aa2785b1748deb6db09551b72159dcb3e08991025b',
method: '0x0600ffd7568e5f0a7eda67a82691ff379ac4bba4f9c9b859fe779b5d46363b61ad2db9e56c', method: '0x060000d7568e5f0a7eda67a82691ff379ac4bba4f9c9b859fe779b5d46363b61ad2db9e56c',
nonce: '0x00001234', nonce: '0x00001234',
signedExtensions: ['CheckNonce'], signedExtensions: ['CheckNonce'],
specVersion: '0x00000000', specVersion: '0x00000000',
@@ -2,6 +2,6 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
export const emptyCheck = { export const emptyCheck = {
extra: {}, extrinsic: {},
types: {} payload: {}
}; };
@@ -9,7 +9,7 @@ import substrateExtensions from './substrate';
// A mapping of the known signed extensions to the extra fields that they contain. Unlike in the actual extensions, // A mapping of the known signed extensions to the extra fields that they contain. Unlike in the actual extensions,
// we define the extra fields not as a Tuple, but rather as a struct so they can be named. These will be expanded // we define the extra fields not as a Tuple, but rather as a struct so they can be named. These will be expanded
// into the various fields when added to the payload (we only support V4 onwards with these, V3 and earlier are // into the various fields when added to the payload (we only support V4 onwards with these, V3 and earlier are
// deemded fixed and non-changeable) // deemed fixed and non-changeable)
const allExtensions: ExtDef = { const allExtensions: ExtDef = {
...substrateExtensions, ...substrateExtensions,
...polkadotExtensions ...polkadotExtensions
@@ -26,16 +26,16 @@ const defaultExtensions: Array<keyof typeof allExtensions> = [
'CheckBlockGasLimit' 'CheckBlockGasLimit'
]; ];
function findUnknownExtensions (extensions: string[]): string[] { function findUnknownExtensions (extensions: string[], userExtensions: Record<string, ExtDef> = {}): string[] {
const names = Object.keys(allExtensions); const names = [...Object.keys(allExtensions), ...Object.keys(userExtensions)];
return extensions.filter((key): boolean => !names.includes(key)); return extensions.filter((key) => !names.includes(key));
} }
function expandExtensionTypes (extensions: string[], type: keyof ExtInfo): ExtTypes { function expandExtensionTypes (extensions: string[], type: keyof ExtInfo, userExtensions: Record<string, ExtDef> = {}): ExtTypes {
return extensions return extensions
.map((key): ExtInfo => allExtensions[key]) .map((key) => allExtensions[key] || userExtensions[key])
.filter((info): boolean => !!info) .filter((info): info is ExtInfo => !!info)
.reduce((result, info): ExtTypes => ({ ...result, ...info[type] }), {}); .reduce((result, info): ExtTypes => ({ ...result, ...info[type] }), {});
} }
@@ -6,53 +6,53 @@ import type { ExtDef } from './types';
import { emptyCheck } from './emptyCheck'; import { emptyCheck } from './emptyCheck';
const CheckMortality = { const CheckMortality = {
extra: { extrinsic: {
blockHash: 'Hash'
},
types: {
era: 'ExtrinsicEra' era: 'ExtrinsicEra'
},
payload: {
blockHash: 'Hash'
} }
}; };
export default { export default {
ChargeTransactionPayment: { ChargeTransactionPayment: {
extra: {}, extrinsic: {
types: {
tip: 'Compact<Balance>' tip: 'Compact<Balance>'
} },
payload: {}
}, },
CheckBlockGasLimit: emptyCheck, CheckBlockGasLimit: emptyCheck,
CheckEra: CheckMortality, CheckEra: CheckMortality,
CheckGenesis: { CheckGenesis: {
extra: { extrinsic: {},
payload: {
genesisHash: 'Hash' genesisHash: 'Hash'
}, }
types: {}
}, },
CheckMortality, CheckMortality,
CheckNonce: { CheckNonce: {
extra: {}, extrinsic: {
types: {
nonce: 'Compact<Index>' nonce: 'Compact<Index>'
} },
payload: {}
}, },
CheckSpecVersion: { CheckSpecVersion: {
extra: { extrinsic: {},
payload: {
specVersion: 'u32' specVersion: 'u32'
}, }
types: {}
}, },
CheckTxVersion: { CheckTxVersion: {
extra: { extrinsic: {},
payload: {
transactionVersion: 'u32' transactionVersion: 'u32'
}, }
types: {}
}, },
CheckVersion: { CheckVersion: {
extra: { extrinsic: {},
payload: {
specVersion: 'u32' specVersion: 'u32'
}, }
types: {}
}, },
CheckWeight: emptyCheck, CheckWeight: emptyCheck,
LockStakingStatus: emptyCheck, LockStakingStatus: emptyCheck,

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